summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:52 +0000
commit5f29bb8a675e8f96452b632e7129113f7dec850e (patch)
tree3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147
parent88c643b6fec27eec436c8d138fee6346e92337d6 (diff)
Notes
-rw-r--r--LICENSE.TXT238
-rw-r--r--include/lldb/API/LLDB.h8
-rw-r--r--include/lldb/API/SBAddress.h15
-rw-r--r--include/lldb/API/SBAttachInfo.h35
-rw-r--r--include/lldb/API/SBBlock.h13
-rw-r--r--include/lldb/API/SBBreakpoint.h9
-rw-r--r--include/lldb/API/SBBreakpointLocation.h9
-rw-r--r--include/lldb/API/SBBreakpointName.h9
-rw-r--r--include/lldb/API/SBBroadcaster.h9
-rw-r--r--include/lldb/API/SBCommandInterpreter.h29
-rw-r--r--include/lldb/API/SBCommandReturnObject.h11
-rw-r--r--include/lldb/API/SBCommunication.h9
-rw-r--r--include/lldb/API/SBCompileUnit.h15
-rw-r--r--include/lldb/API/SBData.h9
-rw-r--r--include/lldb/API/SBDebugger.h31
-rw-r--r--include/lldb/API/SBDeclaration.h11
-rw-r--r--include/lldb/API/SBDefines.h12
-rw-r--r--include/lldb/API/SBError.h22
-rw-r--r--include/lldb/API/SBEvent.h9
-rw-r--r--include/lldb/API/SBExecutionContext.h9
-rw-r--r--include/lldb/API/SBExpressionOptions.h18
-rw-r--r--include/lldb/API/SBFileSpec.h16
-rw-r--r--include/lldb/API/SBFileSpecList.h9
-rw-r--r--include/lldb/API/SBFrame.h9
-rw-r--r--include/lldb/API/SBFunction.h9
-rw-r--r--include/lldb/API/SBHostOS.h7
-rw-r--r--include/lldb/API/SBInitializerOptions.h43
-rw-r--r--include/lldb/API/SBInstruction.h9
-rw-r--r--include/lldb/API/SBInstructionList.h11
-rw-r--r--include/lldb/API/SBLanguageRuntime.h7
-rw-r--r--include/lldb/API/SBLaunchInfo.h17
-rw-r--r--include/lldb/API/SBLineEntry.h11
-rw-r--r--include/lldb/API/SBListener.h9
-rw-r--r--include/lldb/API/SBMemoryRegionInfo.h37
-rw-r--r--include/lldb/API/SBMemoryRegionInfoList.h9
-rw-r--r--include/lldb/API/SBModule.h81
-rw-r--r--include/lldb/API/SBModuleSpec.h21
-rw-r--r--include/lldb/API/SBPlatform.h11
-rw-r--r--include/lldb/API/SBProcess.h97
-rw-r--r--include/lldb/API/SBProcessInfo.h11
-rw-r--r--include/lldb/API/SBQueue.h13
-rw-r--r--include/lldb/API/SBQueueItem.h9
-rw-r--r--include/lldb/API/SBReproducer.h28
-rw-r--r--include/lldb/API/SBSection.h17
-rw-r--r--include/lldb/API/SBSourceManager.h11
-rw-r--r--include/lldb/API/SBStream.h11
-rw-r--r--include/lldb/API/SBStringList.h11
-rw-r--r--include/lldb/API/SBStructuredData.h45
-rw-r--r--include/lldb/API/SBSymbol.h13
-rw-r--r--include/lldb/API/SBSymbolContext.h11
-rw-r--r--include/lldb/API/SBSymbolContextList.h11
-rw-r--r--include/lldb/API/SBTarget.h271
-rw-r--r--include/lldb/API/SBThread.h30
-rw-r--r--include/lldb/API/SBThreadCollection.h9
-rw-r--r--include/lldb/API/SBThreadPlan.h23
-rw-r--r--include/lldb/API/SBTrace.h37
-rw-r--r--include/lldb/API/SBTraceOptions.h9
-rw-r--r--include/lldb/API/SBType.h19
-rw-r--r--include/lldb/API/SBTypeCategory.h27
-rw-r--r--include/lldb/API/SBTypeEnumMember.h13
-rw-r--r--include/lldb/API/SBTypeFilter.h9
-rw-r--r--include/lldb/API/SBTypeFormat.h9
-rw-r--r--include/lldb/API/SBTypeNameSpecifier.h9
-rw-r--r--include/lldb/API/SBTypeSummary.h13
-rw-r--r--include/lldb/API/SBTypeSynthetic.h13
-rw-r--r--include/lldb/API/SBUnixSignals.h9
-rw-r--r--include/lldb/API/SBValue.h78
-rw-r--r--include/lldb/API/SBValueList.h11
-rw-r--r--include/lldb/API/SBVariablesOptions.h11
-rw-r--r--include/lldb/API/SBWatchpoint.h13
-rw-r--r--include/lldb/Breakpoint/Breakpoint.h260
-rw-r--r--include/lldb/Breakpoint/BreakpointID.h29
-rw-r--r--include/lldb/Breakpoint/BreakpointIDList.h9
-rw-r--r--include/lldb/Breakpoint/BreakpointList.h69
-rw-r--r--include/lldb/Breakpoint/BreakpointLocation.h161
-rw-r--r--include/lldb/Breakpoint/BreakpointLocationCollection.h83
-rw-r--r--include/lldb/Breakpoint/BreakpointLocationList.h91
-rw-r--r--include/lldb/Breakpoint/BreakpointName.h15
-rw-r--r--include/lldb/Breakpoint/BreakpointOptions.h125
-rw-r--r--include/lldb/Breakpoint/BreakpointPrecondition.h30
-rw-r--r--include/lldb/Breakpoint/BreakpointResolver.h55
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverAddress.h11
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileLine.h11
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverFileRegex.h11
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverName.h13
-rw-r--r--include/lldb/Breakpoint/BreakpointResolverScripted.h11
-rw-r--r--include/lldb/Breakpoint/BreakpointSite.h89
-rw-r--r--include/lldb/Breakpoint/BreakpointSiteList.h81
-rw-r--r--include/lldb/Breakpoint/Stoppoint.h13
-rw-r--r--include/lldb/Breakpoint/StoppointCallbackContext.h17
-rw-r--r--include/lldb/Breakpoint/StoppointLocation.h19
-rw-r--r--include/lldb/Breakpoint/Watchpoint.h43
-rw-r--r--include/lldb/Breakpoint/WatchpointList.h101
-rw-r--r--include/lldb/Breakpoint/WatchpointOptions.h77
-rw-r--r--include/lldb/Core/Address.h184
-rw-r--r--include/lldb/Core/AddressRange.h130
-rw-r--r--include/lldb/Core/AddressResolver.h19
-rw-r--r--include/lldb/Core/AddressResolverFileLine.h18
-rw-r--r--include/lldb/Core/AddressResolverName.h18
-rw-r--r--include/lldb/Core/Architecture.h19
-rw-r--r--include/lldb/Core/ClangForward.h7
-rw-r--r--include/lldb/Core/Communication.h116
-rw-r--r--include/lldb/Core/Debugger.h68
-rw-r--r--include/lldb/Core/Disassembler.h89
-rw-r--r--include/lldb/Core/DumpDataExtractor.h29
-rw-r--r--include/lldb/Core/DumpRegisterValue.h7
-rw-r--r--include/lldb/Core/EmulateInstruction.h47
-rw-r--r--include/lldb/Core/FileLineResolver.h16
-rw-r--r--include/lldb/Core/FileSpecList.h92
-rw-r--r--include/lldb/Core/FormatEntity.h25
-rw-r--r--include/lldb/Core/Highlighter.h19
-rw-r--r--include/lldb/Core/IOHandler.h52
-rw-r--r--include/lldb/Core/IOStreamMacros.h7
-rw-r--r--include/lldb/Core/LoadedModuleInfoList.h7
-rw-r--r--include/lldb/Core/Mangled.h141
-rw-r--r--include/lldb/Core/MappedHash.h7
-rw-r--r--include/lldb/Core/Module.h417
-rw-r--r--include/lldb/Core/ModuleChild.h41
-rw-r--r--include/lldb/Core/ModuleList.h287
-rw-r--r--include/lldb/Core/ModuleSpec.h15
-rw-r--r--include/lldb/Core/Opcode.h16
-rw-r--r--include/lldb/Core/PluginInterface.h7
-rw-r--r--include/lldb/Core/PluginManager.h211
-rw-r--r--include/lldb/Core/RichManglingContext.h11
-rw-r--r--include/lldb/Core/STLUtils.h13
-rw-r--r--include/lldb/Core/SearchFilter.h141
-rw-r--r--include/lldb/Core/Section.h53
-rw-r--r--include/lldb/Core/SourceManager.h22
-rw-r--r--include/lldb/Core/StreamAsynchronousIO.h10
-rw-r--r--include/lldb/Core/StreamBuffer.h13
-rw-r--r--include/lldb/Core/StreamFile.h11
-rw-r--r--include/lldb/Core/StructuredDataImpl.h7
-rw-r--r--include/lldb/Core/ThreadSafeDenseMap.h7
-rw-r--r--include/lldb/Core/ThreadSafeDenseSet.h7
-rw-r--r--include/lldb/Core/ThreadSafeSTLMap.h11
-rw-r--r--include/lldb/Core/ThreadSafeSTLVector.h11
-rw-r--r--include/lldb/Core/ThreadSafeValue.h11
-rw-r--r--include/lldb/Core/UniqueCStringMap.h121
-rw-r--r--include/lldb/Core/UserSettingsController.h17
-rw-r--r--include/lldb/Core/Value.h17
-rw-r--r--include/lldb/Core/ValueObject.h64
-rw-r--r--include/lldb/Core/ValueObjectCast.h18
-rw-r--r--include/lldb/Core/ValueObjectChild.h11
-rw-r--r--include/lldb/Core/ValueObjectConstResult.h31
-rw-r--r--include/lldb/Core/ValueObjectConstResultCast.h16
-rw-r--r--include/lldb/Core/ValueObjectConstResultChild.h19
-rw-r--r--include/lldb/Core/ValueObjectConstResultImpl.h15
-rw-r--r--include/lldb/Core/ValueObjectDynamicValue.h15
-rw-r--r--include/lldb/Core/ValueObjectList.h23
-rw-r--r--include/lldb/Core/ValueObjectMemory.h14
-rw-r--r--include/lldb/Core/ValueObjectRegister.h30
-rw-r--r--include/lldb/Core/ValueObjectSyntheticFilter.h21
-rw-r--r--include/lldb/Core/ValueObjectVariable.h24
-rw-r--r--include/lldb/Core/dwarf.h17
-rw-r--r--include/lldb/DataFormatters/CXXFunctionPointer.h7
-rw-r--r--include/lldb/DataFormatters/DataVisualization.h34
-rw-r--r--include/lldb/DataFormatters/DumpValueObjectOptions.h7
-rw-r--r--include/lldb/DataFormatters/FormatCache.h25
-rw-r--r--include/lldb/DataFormatters/FormatClasses.h26
-rw-r--r--include/lldb/DataFormatters/FormatManager.h30
-rw-r--r--include/lldb/DataFormatters/FormattersContainer.h11
-rw-r--r--include/lldb/DataFormatters/FormattersHelpers.h9
-rw-r--r--include/lldb/DataFormatters/LanguageCategory.h7
-rw-r--r--include/lldb/DataFormatters/StringPrinter.h7
-rw-r--r--include/lldb/DataFormatters/TypeCategory.h29
-rw-r--r--include/lldb/DataFormatters/TypeCategoryMap.h9
-rw-r--r--include/lldb/DataFormatters/TypeFormat.h7
-rw-r--r--include/lldb/DataFormatters/TypeSummary.h10
-rw-r--r--include/lldb/DataFormatters/TypeSynthetic.h18
-rw-r--r--include/lldb/DataFormatters/TypeValidator.h7
-rw-r--r--include/lldb/DataFormatters/ValueObjectPrinter.h7
-rw-r--r--include/lldb/DataFormatters/VectorIterator.h9
-rw-r--r--include/lldb/DataFormatters/VectorType.h7
-rw-r--r--include/lldb/Expression/DWARFExpression.h224
-rw-r--r--include/lldb/Expression/DiagnosticManager.h7
-rw-r--r--include/lldb/Expression/DynamicCheckerFunctions.h62
-rw-r--r--include/lldb/Expression/Expression.h54
-rw-r--r--include/lldb/Expression/ExpressionParser.h59
-rw-r--r--include/lldb/Expression/ExpressionSourceCode.h34
-rw-r--r--include/lldb/Expression/ExpressionTypeSystemHelper.h11
-rw-r--r--include/lldb/Expression/ExpressionVariable.h38
-rw-r--r--include/lldb/Expression/FunctionCaller.h138
-rw-r--r--include/lldb/Expression/IRDynamicChecks.h171
-rw-r--r--include/lldb/Expression/IRExecutionUnit.h133
-rw-r--r--include/lldb/Expression/IRInterpreter.h11
-rw-r--r--include/lldb/Expression/IRMemoryMap.h13
-rw-r--r--include/lldb/Expression/LLVMUserExpression.h27
-rw-r--r--include/lldb/Expression/Materializer.h7
-rw-r--r--include/lldb/Expression/REPL.h39
-rw-r--r--include/lldb/Expression/UserExpression.h134
-rw-r--r--include/lldb/Expression/UtilityFunction.h48
-rw-r--r--include/lldb/Host/Config.h.cmake7
-rw-r--r--include/lldb/Host/ConnectionFileDescriptor.h7
-rw-r--r--include/lldb/Host/Debug.h11
-rw-r--r--include/lldb/Host/Editline.h7
-rw-r--r--include/lldb/Host/File.h141
-rw-r--r--include/lldb/Host/FileAction.h (renamed from include/lldb/Target/FileAction.h)11
-rw-r--r--include/lldb/Host/FileCache.h7
-rw-r--r--include/lldb/Host/FileSystem.h81
-rw-r--r--include/lldb/Host/Host.h119
-rw-r--r--include/lldb/Host/HostGetOpt.h9
-rw-r--r--include/lldb/Host/HostInfo.h13
-rw-r--r--include/lldb/Host/HostInfoBase.h22
-rw-r--r--include/lldb/Host/HostNativeProcess.h7
-rw-r--r--include/lldb/Host/HostNativeProcessBase.h9
-rw-r--r--include/lldb/Host/HostNativeThread.h7
-rw-r--r--include/lldb/Host/HostNativeThreadBase.h7
-rw-r--r--include/lldb/Host/HostNativeThreadForward.h7
-rw-r--r--include/lldb/Host/HostProcess.h16
-rw-r--r--include/lldb/Host/HostThread.h11
-rw-r--r--include/lldb/Host/LockFile.h7
-rw-r--r--include/lldb/Host/LockFileBase.h7
-rw-r--r--include/lldb/Host/MainLoop.h7
-rw-r--r--include/lldb/Host/MainLoopBase.h7
-rw-r--r--include/lldb/Host/MonitoringProcessLauncher.h7
-rw-r--r--include/lldb/Host/OptionParser.h15
-rw-r--r--include/lldb/Host/Pipe.h7
-rw-r--r--include/lldb/Host/PipeBase.h7
-rw-r--r--include/lldb/Host/PosixApi.h7
-rw-r--r--include/lldb/Host/ProcessLaunchInfo.h (renamed from include/lldb/Target/ProcessLaunchInfo.h)13
-rw-r--r--include/lldb/Host/ProcessLauncher.h7
-rw-r--r--include/lldb/Host/ProcessRunLock.h13
-rw-r--r--include/lldb/Host/PseudoTerminal.h87
-rw-r--r--include/lldb/Host/SafeMachO.h7
-rw-r--r--include/lldb/Host/Socket.h17
-rw-r--r--include/lldb/Host/SocketAddress.h46
-rw-r--r--include/lldb/Host/StringConvert.h11
-rw-r--r--include/lldb/Host/TaskPool.h7
-rw-r--r--include/lldb/Host/Terminal.h75
-rw-r--r--include/lldb/Host/ThreadLauncher.h16
-rw-r--r--include/lldb/Host/Time.h7
-rw-r--r--include/lldb/Host/XML.h15
-rw-r--r--include/lldb/Host/common/NativeBreakpointList.h7
-rw-r--r--include/lldb/Host/common/NativeProcessProtocol.h123
-rw-r--r--include/lldb/Host/common/NativeRegisterContext.h19
-rw-r--r--include/lldb/Host/common/NativeThreadProtocol.h13
-rw-r--r--include/lldb/Host/common/NativeWatchpointList.h7
-rw-r--r--include/lldb/Host/common/TCPSocket.h9
-rw-r--r--include/lldb/Host/common/UDPSocket.h9
-rw-r--r--include/lldb/Host/freebsd/HostInfoFreeBSD.h7
-rw-r--r--include/lldb/Host/netbsd/HostInfoNetBSD.h7
-rw-r--r--include/lldb/Host/openbsd/HostInfoOpenBSD.h10
-rw-r--r--include/lldb/Host/posix/ConnectionFileDescriptorPosix.h7
-rw-r--r--include/lldb/Host/posix/DomainSocket.h10
-rw-r--r--include/lldb/Host/posix/Fcntl.h7
-rw-r--r--include/lldb/Host/posix/HostInfoPosix.h14
-rw-r--r--include/lldb/Host/posix/HostProcessPosix.h12
-rw-r--r--include/lldb/Host/posix/HostThreadPosix.h7
-rw-r--r--include/lldb/Host/posix/LockFilePosix.h7
-rw-r--r--include/lldb/Host/posix/PipePosix.h11
-rw-r--r--include/lldb/Host/posix/ProcessLauncherPosixFork.h7
-rw-r--r--include/lldb/Initialization/SystemInitializer.h15
-rw-r--r--include/lldb/Initialization/SystemInitializerCommon.h11
-rw-r--r--include/lldb/Initialization/SystemLifetimeManager.h8
-rw-r--r--include/lldb/Interpreter/CommandAlias.h7
-rw-r--r--include/lldb/Interpreter/CommandCompletions.h23
-rw-r--r--include/lldb/Interpreter/CommandHistory.h7
-rw-r--r--include/lldb/Interpreter/CommandInterpreter.h103
-rw-r--r--include/lldb/Interpreter/CommandObject.h40
-rw-r--r--include/lldb/Interpreter/CommandObjectMultiword.h9
-rw-r--r--include/lldb/Interpreter/CommandObjectRegexCommand.h9
-rw-r--r--include/lldb/Interpreter/CommandOptionValidators.h7
-rw-r--r--include/lldb/Interpreter/CommandReturnObject.h7
-rw-r--r--include/lldb/Interpreter/OptionArgParser.h7
-rw-r--r--include/lldb/Interpreter/OptionGroupArchitecture.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupBoolean.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupFile.h11
-rw-r--r--include/lldb/Interpreter/OptionGroupFormat.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupOutputFile.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupPlatform.h17
-rw-r--r--include/lldb/Interpreter/OptionGroupString.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupUInt64.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupUUID.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupValueObjectDisplay.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupVariable.h9
-rw-r--r--include/lldb/Interpreter/OptionGroupWatchpoint.h13
-rw-r--r--include/lldb/Interpreter/OptionValue.h19
-rw-r--r--include/lldb/Interpreter/OptionValueArch.h11
-rw-r--r--include/lldb/Interpreter/OptionValueArgs.h7
-rw-r--r--include/lldb/Interpreter/OptionValueArray.h11
-rw-r--r--include/lldb/Interpreter/OptionValueBoolean.h19
-rw-r--r--include/lldb/Interpreter/OptionValueChar.h13
-rw-r--r--include/lldb/Interpreter/OptionValueDictionary.h17
-rw-r--r--include/lldb/Interpreter/OptionValueEnumeration.h11
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpec.h11
-rw-r--r--include/lldb/Interpreter/OptionValueFileSpecList.h30
-rw-r--r--include/lldb/Interpreter/OptionValueFormat.h11
-rw-r--r--include/lldb/Interpreter/OptionValueFormatEntity.h11
-rw-r--r--include/lldb/Interpreter/OptionValueLanguage.h11
-rw-r--r--include/lldb/Interpreter/OptionValuePathMappings.h11
-rw-r--r--include/lldb/Interpreter/OptionValueProperties.h27
-rw-r--r--include/lldb/Interpreter/OptionValueRegex.h11
-rw-r--r--include/lldb/Interpreter/OptionValueSInt64.h11
-rw-r--r--include/lldb/Interpreter/OptionValueString.h11
-rw-r--r--include/lldb/Interpreter/OptionValueUInt64.h13
-rw-r--r--include/lldb/Interpreter/OptionValueUUID.h11
-rw-r--r--include/lldb/Interpreter/OptionValues.h7
-rw-r--r--include/lldb/Interpreter/Options.h59
-rw-r--r--include/lldb/Interpreter/Property.h9
-rw-r--r--include/lldb/Interpreter/ScriptInterpreter.h20
-rw-r--r--include/lldb/Symbol/ArmUnwindInfo.h12
-rw-r--r--include/lldb/Symbol/Block.h170
-rw-r--r--include/lldb/Symbol/ClangASTContext.h154
-rw-r--r--include/lldb/Symbol/ClangASTImporter.h106
-rw-r--r--include/lldb/Symbol/ClangExternalASTSourceCallbacks.h11
-rw-r--r--include/lldb/Symbol/ClangExternalASTSourceCommon.h7
-rw-r--r--include/lldb/Symbol/ClangUtil.h7
-rw-r--r--include/lldb/Symbol/CompactUnwindInfo.h14
-rw-r--r--include/lldb/Symbol/CompileUnit.h195
-rw-r--r--include/lldb/Symbol/CompilerDecl.h13
-rw-r--r--include/lldb/Symbol/CompilerDeclContext.h36
-rw-r--r--include/lldb/Symbol/CompilerType.h62
-rw-r--r--include/lldb/Symbol/CxxModuleHandler.h65
-rw-r--r--include/lldb/Symbol/DWARFCallFrameInfo.h31
-rw-r--r--include/lldb/Symbol/DebugMacros.h7
-rw-r--r--include/lldb/Symbol/DeclVendor.h42
-rw-r--r--include/lldb/Symbol/Declaration.h92
-rw-r--r--include/lldb/Symbol/FuncUnwinders.h37
-rw-r--r--include/lldb/Symbol/Function.h251
-rw-r--r--include/lldb/Symbol/LineEntry.h83
-rw-r--r--include/lldb/Symbol/LineTable.h104
-rw-r--r--include/lldb/Symbol/LocateSymbolFile.h (renamed from include/lldb/Host/Symbols.h)20
-rw-r--r--include/lldb/Symbol/ObjectContainer.h51
-rw-r--r--include/lldb/Symbol/ObjectFile.h247
-rw-r--r--include/lldb/Symbol/PostfixExpression.h226
-rw-r--r--include/lldb/Symbol/SourceModule.h27
-rw-r--r--include/lldb/Symbol/Symbol.h38
-rw-r--r--include/lldb/Symbol/SymbolContext.h183
-rw-r--r--include/lldb/Symbol/SymbolContextScope.h35
-rw-r--r--include/lldb/Symbol/SymbolFile.h52
-rw-r--r--include/lldb/Symbol/SymbolVendor.h37
-rw-r--r--include/lldb/Symbol/Symtab.h44
-rw-r--r--include/lldb/Symbol/TaggedASTType.h7
-rw-r--r--include/lldb/Symbol/Type.h212
-rw-r--r--include/lldb/Symbol/TypeList.h11
-rw-r--r--include/lldb/Symbol/TypeMap.h11
-rw-r--r--include/lldb/Symbol/TypeSystem.h60
-rw-r--r--include/lldb/Symbol/UnwindPlan.h7
-rw-r--r--include/lldb/Symbol/UnwindTable.h16
-rw-r--r--include/lldb/Symbol/Variable.h22
-rw-r--r--include/lldb/Symbol/VariableList.h15
-rw-r--r--include/lldb/Symbol/VerifyDecl.h7
-rw-r--r--include/lldb/Target/ABI.h15
-rw-r--r--include/lldb/Target/DynamicLoader.h113
-rw-r--r--include/lldb/Target/ExecutionContext.h173
-rw-r--r--include/lldb/Target/ExecutionContextScope.h15
-rw-r--r--include/lldb/Target/InstrumentationRuntime.h7
-rw-r--r--include/lldb/Target/InstrumentationRuntimeStopInfo.h7
-rw-r--r--include/lldb/Target/JITLoader.h25
-rw-r--r--include/lldb/Target/JITLoaderList.h11
-rw-r--r--include/lldb/Target/Language.h22
-rw-r--r--include/lldb/Target/LanguageRuntime.h44
-rw-r--r--include/lldb/Target/Memory.h25
-rw-r--r--include/lldb/Target/MemoryHistory.h7
-rw-r--r--include/lldb/Target/MemoryRegionInfo.h17
-rw-r--r--include/lldb/Target/ModuleCache.h11
-rw-r--r--include/lldb/Target/OperatingSystem.h23
-rw-r--r--include/lldb/Target/PathMappingList.h43
-rw-r--r--include/lldb/Target/Platform.h295
-rw-r--r--include/lldb/Target/Process.h934
-rw-r--r--include/lldb/Target/ProcessInfo.h102
-rw-r--r--include/lldb/Target/ProcessStructReader.h7
-rw-r--r--include/lldb/Target/Queue.h47
-rw-r--r--include/lldb/Target/QueueItem.h35
-rw-r--r--include/lldb/Target/QueueList.h45
-rw-r--r--include/lldb/Target/RegisterCheckpoint.h7
-rw-r--r--include/lldb/Target/RegisterContext.h29
-rw-r--r--include/lldb/Target/RegisterNumber.h9
-rw-r--r--include/lldb/Target/RemoteAwarePlatform.h97
-rw-r--r--include/lldb/Target/SectionLoadHistory.h9
-rw-r--r--include/lldb/Target/SectionLoadList.h9
-rw-r--r--include/lldb/Target/StackFrame.h191
-rw-r--r--include/lldb/Target/StackFrameList.h11
-rw-r--r--include/lldb/Target/StackFrameRecognizer.h62
-rw-r--r--include/lldb/Target/StackID.h11
-rw-r--r--include/lldb/Target/StopInfo.h11
-rw-r--r--include/lldb/Target/StructuredDataPlugin.h57
-rw-r--r--include/lldb/Target/SystemRuntime.h94
-rw-r--r--include/lldb/Target/Target.h215
-rw-r--r--include/lldb/Target/TargetList.h59
-rw-r--r--include/lldb/Target/Thread.h313
-rw-r--r--include/lldb/Target/ThreadCollection.h7
-rw-r--r--include/lldb/Target/ThreadList.h15
-rw-r--r--include/lldb/Target/ThreadPlan.h43
-rw-r--r--include/lldb/Target/ThreadPlanBase.h9
-rw-r--r--include/lldb/Target/ThreadPlanCallFunction.h7
-rw-r--r--include/lldb/Target/ThreadPlanCallFunctionUsingABI.h7
-rw-r--r--include/lldb/Target/ThreadPlanCallOnFunctionExit.h9
-rw-r--r--include/lldb/Target/ThreadPlanCallUserExpression.h7
-rw-r--r--include/lldb/Target/ThreadPlanPython.h9
-rw-r--r--include/lldb/Target/ThreadPlanRunToAddress.h7
-rw-r--r--include/lldb/Target/ThreadPlanShouldStopHere.h9
-rw-r--r--include/lldb/Target/ThreadPlanStepInRange.h9
-rw-r--r--include/lldb/Target/ThreadPlanStepInstruction.h7
-rw-r--r--include/lldb/Target/ThreadPlanStepOut.h7
-rw-r--r--include/lldb/Target/ThreadPlanStepOverBreakpoint.h7
-rw-r--r--include/lldb/Target/ThreadPlanStepOverRange.h7
-rw-r--r--include/lldb/Target/ThreadPlanStepRange.h7
-rw-r--r--include/lldb/Target/ThreadPlanStepThrough.h7
-rw-r--r--include/lldb/Target/ThreadPlanStepUntil.h7
-rw-r--r--include/lldb/Target/ThreadPlanTracer.h11
-rw-r--r--include/lldb/Target/ThreadSpec.h11
-rw-r--r--include/lldb/Target/UnixSignals.h12
-rw-r--r--include/lldb/Target/Unwind.h11
-rw-r--r--include/lldb/Target/UnwindAssembly.h9
-rw-r--r--include/lldb/Utility/AnsiTerminal.h7
-rw-r--r--include/lldb/Utility/ArchSpec.h150
-rw-r--r--include/lldb/Utility/Args.h127
-rw-r--r--include/lldb/Utility/Baton.h16
-rw-r--r--include/lldb/Utility/Broadcaster.h254
-rw-r--r--include/lldb/Utility/CleanUp.h7
-rw-r--r--include/lldb/Utility/CompletionRequest.h37
-rw-r--r--include/lldb/Utility/Connection.h79
-rw-r--r--include/lldb/Utility/ConstString.h236
-rw-r--r--include/lldb/Utility/DataBuffer.h25
-rw-r--r--include/lldb/Utility/DataBufferHeap.h53
-rw-r--r--include/lldb/Utility/DataBufferLLVM.h9
-rw-r--r--include/lldb/Utility/DataEncoder.h139
-rw-r--r--include/lldb/Utility/DataExtractor.h370
-rw-r--r--include/lldb/Utility/Endian.h9
-rw-r--r--include/lldb/Utility/Environment.h7
-rw-r--r--include/lldb/Utility/Event.h45
-rw-r--r--include/lldb/Utility/FileCollector.h77
-rw-r--r--include/lldb/Utility/FileSpec.h194
-rw-r--r--include/lldb/Utility/Flags.h77
-rw-r--r--include/lldb/Utility/IOObject.h11
-rw-r--r--include/lldb/Utility/Iterable.h7
-rw-r--r--include/lldb/Utility/JSON.h9
-rw-r--r--include/lldb/Utility/LLDBAssert.h7
-rw-r--r--include/lldb/Utility/Listener.h22
-rw-r--r--include/lldb/Utility/Log.h22
-rw-r--r--include/lldb/Utility/Logging.h10
-rw-r--r--include/lldb/Utility/NameMatches.h7
-rw-r--r--include/lldb/Utility/Predicate.h77
-rw-r--r--include/lldb/Utility/ProcessInfo.h245
-rw-r--r--include/lldb/Utility/RangeMap.h (renamed from include/lldb/Core/RangeMap.h)34
-rw-r--r--include/lldb/Utility/RegisterValue.h10
-rw-r--r--include/lldb/Utility/RegularExpression.h41
-rw-r--r--include/lldb/Utility/Reproducer.h154
-rw-r--r--include/lldb/Utility/ReproducerInstrumentation.h717
-rw-r--r--include/lldb/Utility/Scalar.h113
-rw-r--r--include/lldb/Utility/SelectHelper.h7
-rw-r--r--include/lldb/Utility/SharedCluster.h7
-rw-r--r--include/lldb/Utility/SharingPtr.h21
-rw-r--r--include/lldb/Utility/State.h27
-rw-r--r--include/lldb/Utility/Status.h76
-rw-r--r--include/lldb/Utility/Stream.h231
-rw-r--r--include/lldb/Utility/StreamCallback.h7
-rw-r--r--include/lldb/Utility/StreamGDBRemote.h15
-rw-r--r--include/lldb/Utility/StreamString.h7
-rw-r--r--include/lldb/Utility/StreamTee.h14
-rw-r--r--include/lldb/Utility/StringExtractor.h17
-rw-r--r--include/lldb/Utility/StringExtractorGDBRemote.h11
-rw-r--r--include/lldb/Utility/StringLexer.h9
-rw-r--r--include/lldb/Utility/StringList.h9
-rw-r--r--include/lldb/Utility/StructuredData.h13
-rw-r--r--include/lldb/Utility/TildeExpressionResolver.h7
-rw-r--r--include/lldb/Utility/Timeout.h7
-rw-r--r--include/lldb/Utility/Timer.h17
-rw-r--r--include/lldb/Utility/TraceOptions.h7
-rw-r--r--include/lldb/Utility/UUID.h20
-rw-r--r--include/lldb/Utility/UriParser.h7
-rw-r--r--include/lldb/Utility/UserID.h41
-rw-r--r--include/lldb/Utility/UserIDResolver.h56
-rw-r--r--include/lldb/Utility/VASPrintf.h7
-rw-r--r--include/lldb/Utility/VMRange.h9
-rw-r--r--include/lldb/lldb-defines.h27
-rw-r--r--include/lldb/lldb-enumerations.h86
-rw-r--r--include/lldb/lldb-forward.h33
-rw-r--r--include/lldb/lldb-private-defines.h7
-rw-r--r--include/lldb/lldb-private-enumerations.h109
-rw-r--r--include/lldb/lldb-private-forward.h9
-rw-r--r--include/lldb/lldb-private-interfaces.h12
-rw-r--r--include/lldb/lldb-private-types.h11
-rw-r--r--include/lldb/lldb-private.h7
-rw-r--r--include/lldb/lldb-public.h9
-rw-r--r--include/lldb/lldb-types.h11
-rw-r--r--include/lldb/lldb-versioning.h9
-rw-r--r--include/lldb/module.modulemap8
-rw-r--r--source/API/SBAddress.cpp250
-rw-r--r--source/API/SBAttachInfo.cpp175
-rw-r--r--source/API/SBBlock.cpp139
-rw-r--r--source/API/SBBreakpoint.cpp436
-rw-r--r--source/API/SBBreakpointLocation.cpp212
-rw-r--r--source/API/SBBreakpointName.cpp391
-rw-r--r--source/API/SBBreakpointOptionCommon.cpp9
-rw-r--r--source/API/SBBreakpointOptionCommon.h9
-rw-r--r--source/API/SBBroadcaster.cpp144
-rw-r--r--source/API/SBCommandInterpreter.cpp517
-rw-r--r--source/API/SBCommandReturnObject.cpp284
-rw-r--r--source/API/SBCommunication.cpp218
-rw-r--r--source/API/SBCompileUnit.cpp187
-rw-r--r--source/API/SBData.cpp456
-rw-r--r--source/API/SBDebugger.cpp754
-rw-r--r--source/API/SBDeclaration.cpp158
-rw-r--r--source/API/SBError.cpp167
-rw-r--r--source/API/SBEvent.cpp127
-rw-r--r--source/API/SBExecutionContext.cpp85
-rw-r--r--source/API/SBExpressionOptions.cpp257
-rw-r--r--source/API/SBFileSpec.cpp193
-rw-r--r--source/API/SBFileSpecList.cpp123
-rw-r--r--source/API/SBFrame.cpp660
-rw-r--r--source/API/SBFunction.cpp154
-rw-r--r--source/API/SBHostOS.cpp97
-rw-r--r--source/API/SBInitializerOptions.cpp49
-rw-r--r--source/API/SBInstruction.cpp133
-rw-r--r--source/API/SBInstructionList.cpp107
-rw-r--r--source/API/SBLanguageRuntime.cpp29
-rw-r--r--source/API/SBLaunchInfo.cpp201
-rw-r--r--source/API/SBLineEntry.cpp204
-rw-r--r--source/API/SBListener.cpp219
-rw-r--r--source/API/SBMemoryRegionInfo.cpp124
-rw-r--r--source/API/SBMemoryRegionInfoList.cpp101
-rw-r--r--source/API/SBModule.cpp339
-rw-r--r--source/API/SBModuleSpec.cpp231
-rw-r--r--source/API/SBPlatform.cpp375
-rw-r--r--source/API/SBProcess.cpp820
-rw-r--r--source/API/SBProcessInfo.cpp159
-rw-r--r--source/API/SBQueue.cpp170
-rw-r--r--source/API/SBQueueItem.cpp111
-rw-r--r--source/API/SBReproducer.cpp153
-rw-r--r--source/API/SBReproducerPrivate.h75
-rw-r--r--source/API/SBSection.cpp137
-rw-r--r--source/API/SBSourceManager.cpp70
-rw-r--r--source/API/SBStream.cpp114
-rw-r--r--source/API/SBStringList.cpp128
-rw-r--r--source/API/SBStructuredData.cpp141
-rw-r--r--source/API/SBSymbol.cpp133
-rw-r--r--source/API/SBSymbolContext.cpp236
-rw-r--r--source/API/SBSymbolContextList.cpp117
-rw-r--r--source/API/SBTarget.cpp1355
-rw-r--r--source/API/SBThread.cpp708
-rw-r--r--source/API/SBThreadCollection.cpp61
-rw-r--r--source/API/SBThreadPlan.cpp232
-rw-r--r--source/API/SBTrace.cpp60
-rw-r--r--source/API/SBTraceOptions.cpp77
-rw-r--r--source/API/SBType.cpp526
-rw-r--r--source/API/SBTypeCategory.cpp306
-rw-r--r--source/API/SBTypeEnumMember.cpp152
-rw-r--r--source/API/SBTypeFilter.cpp101
-rw-r--r--source/API/SBTypeFormat.cpp95
-rw-r--r--source/API/SBTypeNameSpecifier.cpp100
-rw-r--r--source/API/SBTypeSummary.cpp229
-rw-r--r--source/API/SBTypeSynthetic.cpp120
-rw-r--r--source/API/SBUnixSignals.cpp119
-rw-r--r--source/API/SBValue.cpp897
-rw-r--r--source/API/SBValueList.cpp170
-rw-r--r--source/API/SBVariablesOptions.cpp158
-rw-r--r--source/API/SBWatchpoint.cpp181
-rw-r--r--source/API/SystemInitializerFull.cpp222
-rw-r--r--source/API/SystemInitializerFull.h14
-rw-r--r--source/API/Utils.h30
-rw-r--r--source/Breakpoint/Breakpoint.cpp47
-rw-r--r--source/Breakpoint/BreakpointID.cpp7
-rw-r--r--source/Breakpoint/BreakpointIDList.cpp9
-rw-r--r--source/Breakpoint/BreakpointList.cpp7
-rw-r--r--source/Breakpoint/BreakpointLocation.cpp104
-rw-r--r--source/Breakpoint/BreakpointLocationCollection.cpp22
-rw-r--r--source/Breakpoint/BreakpointLocationList.cpp9
-rw-r--r--source/Breakpoint/BreakpointName.cpp11
-rw-r--r--source/Breakpoint/BreakpointOptions.cpp99
-rw-r--r--source/Breakpoint/BreakpointPrecondition.cpp26
-rw-r--r--source/Breakpoint/BreakpointResolver.cpp9
-rw-r--r--source/Breakpoint/BreakpointResolverAddress.cpp11
-rw-r--r--source/Breakpoint/BreakpointResolverFileLine.cpp11
-rw-r--r--source/Breakpoint/BreakpointResolverFileRegex.cpp13
-rw-r--r--source/Breakpoint/BreakpointResolverName.cpp43
-rw-r--r--source/Breakpoint/BreakpointResolverScripted.cpp18
-rw-r--r--source/Breakpoint/BreakpointSite.cpp19
-rw-r--r--source/Breakpoint/BreakpointSiteList.cpp11
-rw-r--r--source/Breakpoint/Stoppoint.cpp11
-rw-r--r--source/Breakpoint/StoppointCallbackContext.cpp7
-rw-r--r--source/Breakpoint/StoppointLocation.cpp11
-rw-r--r--source/Breakpoint/Watchpoint.cpp26
-rw-r--r--source/Breakpoint/WatchpointList.cpp7
-rw-r--r--source/Breakpoint/WatchpointOptions.cpp41
-rw-r--r--source/Commands/CommandCompletions.cpp13
-rw-r--r--source/Commands/CommandObjectApropos.cpp11
-rw-r--r--source/Commands/CommandObjectApropos.h9
-rw-r--r--source/Commands/CommandObjectBreakpoint.cpp64
-rw-r--r--source/Commands/CommandObjectBreakpoint.h9
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.cpp23
-rw-r--r--source/Commands/CommandObjectBreakpointCommand.h9
-rw-r--r--source/Commands/CommandObjectBugreport.cpp12
-rw-r--r--source/Commands/CommandObjectBugreport.h9
-rw-r--r--source/Commands/CommandObjectCommands.cpp113
-rw-r--r--source/Commands/CommandObjectCommands.h9
-rw-r--r--source/Commands/CommandObjectDisassemble.cpp23
-rw-r--r--source/Commands/CommandObjectDisassemble.h9
-rw-r--r--source/Commands/CommandObjectExpression.cpp43
-rw-r--r--source/Commands/CommandObjectExpression.h11
-rw-r--r--source/Commands/CommandObjectFrame.cpp31
-rw-r--r--source/Commands/CommandObjectFrame.h9
-rw-r--r--source/Commands/CommandObjectGUI.cpp11
-rw-r--r--source/Commands/CommandObjectGUI.h9
-rw-r--r--source/Commands/CommandObjectHelp.cpp23
-rw-r--r--source/Commands/CommandObjectHelp.h11
-rw-r--r--source/Commands/CommandObjectLanguage.cpp7
-rw-r--r--source/Commands/CommandObjectLanguage.h7
-rw-r--r--source/Commands/CommandObjectLog.cpp21
-rw-r--r--source/Commands/CommandObjectLog.h13
-rw-r--r--source/Commands/CommandObjectMemory.cpp130
-rw-r--r--source/Commands/CommandObjectMemory.h7
-rw-r--r--source/Commands/CommandObjectMultiword.cpp9
-rw-r--r--source/Commands/CommandObjectPlatform.cpp129
-rw-r--r--source/Commands/CommandObjectPlatform.h9
-rw-r--r--source/Commands/CommandObjectPlugin.cpp9
-rw-r--r--source/Commands/CommandObjectPlugin.h7
-rw-r--r--source/Commands/CommandObjectProcess.cpp101
-rw-r--r--source/Commands/CommandObjectProcess.h9
-rw-r--r--source/Commands/CommandObjectQuit.cpp9
-rw-r--r--source/Commands/CommandObjectQuit.h9
-rw-r--r--source/Commands/CommandObjectRegister.cpp13
-rw-r--r--source/Commands/CommandObjectRegister.h13
-rw-r--r--source/Commands/CommandObjectReproducer.cpp45
-rw-r--r--source/Commands/CommandObjectReproducer.h9
-rw-r--r--source/Commands/CommandObjectSettings.cpp94
-rw-r--r--source/Commands/CommandObjectSettings.h9
-rw-r--r--source/Commands/CommandObjectSource.cpp30
-rw-r--r--source/Commands/CommandObjectSource.h9
-rw-r--r--source/Commands/CommandObjectStats.cpp7
-rw-r--r--source/Commands/CommandObjectStats.h7
-rw-r--r--source/Commands/CommandObjectTarget.cpp260
-rw-r--r--source/Commands/CommandObjectTarget.h9
-rw-r--r--source/Commands/CommandObjectThread.cpp105
-rw-r--r--source/Commands/CommandObjectThread.h7
-rw-r--r--source/Commands/CommandObjectType.cpp223
-rw-r--r--source/Commands/CommandObjectType.h7
-rw-r--r--source/Commands/CommandObjectVersion.cpp9
-rw-r--r--source/Commands/CommandObjectVersion.h9
-rw-r--r--source/Commands/CommandObjectWatchpoint.cpp62
-rw-r--r--source/Commands/CommandObjectWatchpoint.h9
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.cpp59
-rw-r--r--source/Commands/CommandObjectWatchpointCommand.h9
-rw-r--r--source/Commands/Options.td308
-rw-r--r--source/Commands/OptionsBase.td160
-rw-r--r--source/Core/Address.cpp11
-rw-r--r--source/Core/AddressRange.cpp25
-rw-r--r--source/Core/AddressResolver.cpp9
-rw-r--r--source/Core/AddressResolverFileLine.cpp9
-rw-r--r--source/Core/AddressResolverName.cpp7
-rw-r--r--source/Core/Communication.cpp26
-rw-r--r--source/Core/Debugger.cpp133
-rw-r--r--source/Core/Disassembler.cpp44
-rw-r--r--source/Core/DumpDataExtractor.cpp13
-rw-r--r--source/Core/DumpRegisterValue.cpp7
-rw-r--r--source/Core/DynamicLoader.cpp29
-rw-r--r--source/Core/EmulateInstruction.cpp16
-rw-r--r--source/Core/FileLineResolver.cpp9
-rw-r--r--source/Core/FileSpecList.cpp34
-rw-r--r--source/Core/FormatEntity.cpp216
-rw-r--r--source/Core/Highlighter.cpp7
-rw-r--r--source/Core/IOHandler.cpp148
-rw-r--r--source/Core/Mangled.cpp69
-rw-r--r--source/Core/Module.cpp94
-rw-r--r--source/Core/ModuleChild.cpp10
-rw-r--r--source/Core/ModuleList.cpp85
-rw-r--r--source/Core/Opcode.cpp7
-rw-r--r--source/Core/PluginManager.cpp176
-rw-r--r--source/Core/RichManglingContext.cpp13
-rw-r--r--source/Core/SearchFilter.cpp36
-rw-r--r--source/Core/Section.cpp33
-rw-r--r--source/Core/SourceManager.cpp21
-rw-r--r--source/Core/StreamAsynchronousIO.cpp7
-rw-r--r--source/Core/StreamFile.cpp9
-rw-r--r--source/Core/UserSettingsController.cpp9
-rw-r--r--source/Core/Value.cpp41
-rw-r--r--source/Core/ValueObject.cpp234
-rw-r--r--source/Core/ValueObjectCast.cpp11
-rw-r--r--source/Core/ValueObjectChild.cpp9
-rw-r--r--source/Core/ValueObjectConstResult.cpp23
-rw-r--r--source/Core/ValueObjectConstResultCast.cpp9
-rw-r--r--source/Core/ValueObjectConstResultChild.cpp9
-rw-r--r--source/Core/ValueObjectConstResultImpl.cpp27
-rw-r--r--source/Core/ValueObjectDynamicValue.cpp7
-rw-r--r--source/Core/ValueObjectList.cpp14
-rw-r--r--source/Core/ValueObjectMemory.cpp15
-rw-r--r--source/Core/ValueObjectRegister.cpp31
-rw-r--r--source/Core/ValueObjectSyntheticFilter.cpp43
-rw-r--r--source/Core/ValueObjectVariable.cpp15
-rw-r--r--source/DataFormatters/CXXFunctionPointer.cpp7
-rw-r--r--source/DataFormatters/DataVisualization.cpp38
-rw-r--r--source/DataFormatters/DumpValueObjectOptions.cpp7
-rw-r--r--source/DataFormatters/FormatCache.cpp25
-rw-r--r--source/DataFormatters/FormatClasses.cpp7
-rw-r--r--source/DataFormatters/FormatManager.cpp43
-rw-r--r--source/DataFormatters/FormattersHelpers.cpp11
-rw-r--r--source/DataFormatters/LanguageCategory.cpp7
-rw-r--r--source/DataFormatters/StringPrinter.cpp19
-rw-r--r--source/DataFormatters/TypeCategory.cpp32
-rw-r--r--source/DataFormatters/TypeCategoryMap.cpp11
-rw-r--r--source/DataFormatters/TypeFormat.cpp9
-rw-r--r--source/DataFormatters/TypeSummary.cpp19
-rw-r--r--source/DataFormatters/TypeSynthetic.cpp36
-rw-r--r--source/DataFormatters/TypeValidator.cpp7
-rw-r--r--source/DataFormatters/ValueObjectPrinter.cpp14
-rw-r--r--source/DataFormatters/VectorType.cpp9
-rw-r--r--source/Expression/DWARFExpression.cpp367
-rw-r--r--source/Expression/DiagnosticManager.cpp7
-rw-r--r--source/Expression/Expression.cpp17
-rw-r--r--source/Expression/ExpressionVariable.cpp11
-rw-r--r--source/Expression/FunctionCaller.cpp34
-rw-r--r--source/Expression/IRExecutionUnit.cpp193
-rw-r--r--source/Expression/IRInterpreter.cpp20
-rw-r--r--source/Expression/IRMemoryMap.cpp11
-rw-r--r--source/Expression/LLVMUserExpression.cpp44
-rw-r--r--source/Expression/Materializer.cpp20
-rw-r--r--source/Expression/REPL.cpp46
-rw-r--r--source/Expression/UserExpression.cpp43
-rw-r--r--source/Expression/UtilityFunction.cpp27
-rw-r--r--source/Host/common/Editline.cpp77
-rw-r--r--source/Host/common/File.cpp40
-rw-r--r--source/Host/common/FileAction.cpp (renamed from source/Target/FileAction.cpp)11
-rw-r--r--source/Host/common/FileCache.cpp7
-rw-r--r--source/Host/common/FileSystem.cpp109
-rw-r--r--source/Host/common/GetOptInc.cpp11
-rw-r--r--source/Host/common/Host.cpp51
-rw-r--r--source/Host/common/HostInfoBase.cpp41
-rw-r--r--source/Host/common/HostNativeThreadBase.cpp7
-rw-r--r--source/Host/common/HostProcess.cpp9
-rw-r--r--source/Host/common/HostThread.cpp7
-rw-r--r--source/Host/common/LockFileBase.cpp7
-rw-r--r--source/Host/common/MainLoop.cpp32
-rw-r--r--source/Host/common/MonitoringProcessLauncher.cpp17
-rw-r--r--source/Host/common/NativeProcessProtocol.cpp9
-rw-r--r--source/Host/common/NativeRegisterContext.cpp9
-rw-r--r--source/Host/common/NativeThreadProtocol.cpp7
-rw-r--r--source/Host/common/NativeWatchpointList.cpp7
-rw-r--r--source/Host/common/OptionParser.cpp21
-rw-r--r--source/Host/common/PipeBase.cpp7
-rw-r--r--source/Host/common/ProcessLaunchInfo.cpp (renamed from source/Target/ProcessLaunchInfo.cpp)18
-rw-r--r--source/Host/common/ProcessRunLock.cpp15
-rw-r--r--source/Host/common/PseudoTerminal.cpp35
-rw-r--r--source/Host/common/Socket.cpp64
-rw-r--r--source/Host/common/SocketAddress.cpp25
-rw-r--r--source/Host/common/StringConvert.cpp7
-rw-r--r--source/Host/common/TCPSocket.cpp24
-rw-r--r--source/Host/common/TaskPool.cpp23
-rw-r--r--source/Host/common/Terminal.cpp53
-rw-r--r--source/Host/common/ThreadLauncher.cpp38
-rw-r--r--source/Host/common/UDPSocket.cpp15
-rw-r--r--source/Host/common/XML.cpp9
-rw-r--r--source/Host/freebsd/Host.cpp13
-rw-r--r--source/Host/freebsd/HostInfoFreeBSD.cpp7
-rw-r--r--source/Host/netbsd/Host.cpp13
-rw-r--r--source/Host/netbsd/HostInfoNetBSD.cpp7
-rw-r--r--source/Host/openbsd/Host.cpp16
-rw-r--r--source/Host/openbsd/HostInfoOpenBSD.cpp18
-rw-r--r--source/Host/posix/ConnectionFileDescriptorPosix.cpp32
-rw-r--r--source/Host/posix/DomainSocket.cpp40
-rw-r--r--source/Host/posix/FileSystem.cpp12
-rw-r--r--source/Host/posix/HostInfoPosix.cpp104
-rw-r--r--source/Host/posix/HostProcessPosix.cpp9
-rw-r--r--source/Host/posix/HostThreadPosix.cpp9
-rw-r--r--source/Host/posix/LockFilePosix.cpp11
-rw-r--r--source/Host/posix/PipePosix.cpp16
-rw-r--r--source/Host/posix/ProcessLauncherPosixFork.cpp16
-rw-r--r--source/Initialization/SystemInitializer.cpp7
-rw-r--r--source/Initialization/SystemInitializerCommon.cpp81
-rw-r--r--source/Initialization/SystemLifetimeManager.cpp11
-rw-r--r--source/Interpreter/CommandAlias.cpp9
-rw-r--r--source/Interpreter/CommandHistory.cpp7
-rw-r--r--source/Interpreter/CommandInterpreter.cpp714
-rw-r--r--source/Interpreter/CommandObject.cpp28
-rw-r--r--source/Interpreter/CommandObjectRegexCommand.cpp11
-rw-r--r--source/Interpreter/CommandObjectScript.cpp11
-rw-r--r--source/Interpreter/CommandObjectScript.h9
-rw-r--r--source/Interpreter/CommandOptionValidators.cpp7
-rw-r--r--source/Interpreter/CommandReturnObject.cpp7
-rw-r--r--source/Interpreter/OptionArgParser.cpp7
-rw-r--r--source/Interpreter/OptionGroupArchitecture.cpp7
-rw-r--r--source/Interpreter/OptionGroupBoolean.cpp7
-rw-r--r--source/Interpreter/OptionGroupFile.cpp7
-rw-r--r--source/Interpreter/OptionGroupFormat.cpp7
-rw-r--r--source/Interpreter/OptionGroupOutputFile.cpp7
-rw-r--r--source/Interpreter/OptionGroupPlatform.cpp7
-rw-r--r--source/Interpreter/OptionGroupString.cpp7
-rw-r--r--source/Interpreter/OptionGroupUInt64.cpp7
-rw-r--r--source/Interpreter/OptionGroupUUID.cpp7
-rw-r--r--source/Interpreter/OptionGroupValueObjectDisplay.cpp7
-rw-r--r--source/Interpreter/OptionGroupVariable.cpp7
-rw-r--r--source/Interpreter/OptionGroupWatchpoint.cpp7
-rw-r--r--source/Interpreter/OptionValue.cpp15
-rw-r--r--source/Interpreter/OptionValueArch.cpp7
-rw-r--r--source/Interpreter/OptionValueArgs.cpp7
-rw-r--r--source/Interpreter/OptionValueArray.cpp7
-rw-r--r--source/Interpreter/OptionValueBoolean.cpp7
-rw-r--r--source/Interpreter/OptionValueChar.cpp7
-rw-r--r--source/Interpreter/OptionValueDictionary.cpp13
-rw-r--r--source/Interpreter/OptionValueEnumeration.cpp7
-rw-r--r--source/Interpreter/OptionValueFileSpec.cpp7
-rw-r--r--source/Interpreter/OptionValueFileSpecLIst.cpp12
-rw-r--r--source/Interpreter/OptionValueFormat.cpp7
-rw-r--r--source/Interpreter/OptionValueFormatEntity.cpp7
-rw-r--r--source/Interpreter/OptionValueLanguage.cpp7
-rw-r--r--source/Interpreter/OptionValuePathMappings.cpp7
-rw-r--r--source/Interpreter/OptionValueProperties.cpp24
-rw-r--r--source/Interpreter/OptionValueRegex.cpp7
-rw-r--r--source/Interpreter/OptionValueSInt64.cpp7
-rw-r--r--source/Interpreter/OptionValueString.cpp7
-rw-r--r--source/Interpreter/OptionValueUInt64.cpp7
-rw-r--r--source/Interpreter/OptionValueUUID.cpp7
-rw-r--r--source/Interpreter/Options.cpp129
-rw-r--r--source/Interpreter/Property.cpp64
-rw-r--r--source/Interpreter/ScriptInterpreter.cpp15
-rw-r--r--source/Interpreter/embedded_interpreter.py1
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp23
-rw-r--r--source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h11
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp45
-rw-r--r--source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h11
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp11
-rw-r--r--source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h11
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp17
-rw-r--r--source/Plugins/ABI/SysV-arm/ABISysV_arm.h11
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp45
-rw-r--r--source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h11
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp13
-rw-r--r--source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h11
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp43
-rw-r--r--source/Plugins/ABI/SysV-i386/ABISysV_i386.h11
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp11
-rw-r--r--source/Plugins/ABI/SysV-mips/ABISysV_mips.h11
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp46
-rw-r--r--source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h11
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp19
-rw-r--r--source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h11
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp32
-rw-r--r--source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h11
-rw-r--r--source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp11
-rw-r--r--source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h11
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp1233
-rw-r--r--source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h11
-rw-r--r--source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp1805
-rw-r--r--source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h99
-rw-r--r--source/Plugins/Architecture/Arm/ArchitectureArm.cpp7
-rw-r--r--source/Plugins/Architecture/Arm/ArchitectureArm.h7
-rw-r--r--source/Plugins/Architecture/Mips/ArchitectureMips.cpp7
-rw-r--r--source/Plugins/Architecture/Mips/ArchitectureMips.h7
-rw-r--r--source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp16
-rw-r--r--source/Plugins/Architecture/PPC64/ArchitecturePPC64.h9
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp54
-rw-r--r--source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h11
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp24
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h23
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp7
-rw-r--r--source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h47
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp142
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h109
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp12
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h47
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp61
-rw-r--r--source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h24
-rw-r--r--source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp21
-rw-r--r--source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h13
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp111
-rw-r--r--source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h19
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTDumper.cpp9
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTDumper.h7
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp27
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h77
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp19
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h53
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTUtils.cpp26
-rw-r--r--source/Plugins/ExpressionParser/Clang/ASTUtils.h579
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp168
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangASTSource.h199
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h9
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp117
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h271
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h17
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp385
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h80
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp (renamed from source/Expression/ExpressionSourceCode.cpp)172
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h71
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp11
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h57
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp11
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h46
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangHost.cpp101
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangHost.h13
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp115
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h47
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp33
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h22
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp195
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUserExpression.h78
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp34
-rw-r--r--source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h28
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp (renamed from source/Expression/IRDynamicChecks.cpp)141
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h131
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.cpp96
-rw-r--r--source/Plugins/ExpressionParser/Clang/IRForTarget.h278
-rw-r--r--source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h38
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp75
-rw-r--r--source/Plugins/Instruction/ARM/EmulateInstructionARM.h15
-rw-r--r--source/Plugins/Instruction/ARM/EmulationStateARM.cpp21
-rw-r--r--source/Plugins/Instruction/ARM/EmulationStateARM.h9
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp19
-rw-r--r--source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h55
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp31
-rw-r--r--source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h12
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp25
-rw-r--r--source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h7
-rw-r--r--source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp21
-rw-r--r--source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h7
-rw-r--r--source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp12
-rw-r--r--source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h9
-rw-r--r--source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp18
-rw-r--r--source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h7
-rw-r--r--source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp21
-rw-r--r--source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h9
-rw-r--r--source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp18
-rw-r--r--source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h9
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp80
-rw-r--r--source/Plugins/JITLoader/GDB/JITLoaderGDB.h15
-rw-r--r--source/Plugins/Language/CPlusPlus/BlockPointer.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/BlockPointer.h7
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp203
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h15
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h7
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp7
-rw-r--r--source/Plugins/Language/CPlusPlus/CxxStringTypes.h7
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.cpp26
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxx.h11
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp78
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxAtomic.h10
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp11
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxList.cpp13
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxMap.cpp11
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp11
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp9
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVariant.h7
-rw-r--r--source/Plugins/Language/CPlusPlus/LibCxxVector.cpp17
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.cpp25
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcpp.h7
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp11
-rw-r--r--source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp18
-rw-r--r--source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp7
-rw-r--r--source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h7
-rw-r--r--source/Plugins/Language/ClangCommon/ClangHighlighter.cpp11
-rw-r--r--source/Plugins/Language/ClangCommon/ClangHighlighter.h7
-rw-r--r--source/Plugins/Language/ObjC/CF.cpp28
-rw-r--r--source/Plugins/Language/ObjC/CF.h7
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.cpp107
-rw-r--r--source/Plugins/Language/ObjC/Cocoa.h10
-rw-r--r--source/Plugins/Language/ObjC/CoreMedia.cpp7
-rw-r--r--source/Plugins/Language/ObjC/CoreMedia.h7
-rw-r--r--source/Plugins/Language/ObjC/NSArray.cpp40
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.cpp66
-rw-r--r--source/Plugins/Language/ObjC/NSDictionary.h15
-rw-r--r--source/Plugins/Language/ObjC/NSError.cpp15
-rw-r--r--source/Plugins/Language/ObjC/NSException.cpp15
-rw-r--r--source/Plugins/Language/ObjC/NSIndexPath.cpp15
-rw-r--r--source/Plugins/Language/ObjC/NSSet.cpp48
-rw-r--r--source/Plugins/Language/ObjC/NSSet.h7
-rw-r--r--source/Plugins/Language/ObjC/NSString.cpp11
-rw-r--r--source/Plugins/Language/ObjC/NSString.h10
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.cpp146
-rw-r--r--source/Plugins/Language/ObjC/ObjCLanguage.h45
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp11
-rw-r--r--source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h11
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp (renamed from source/Target/CPPLanguageRuntime.cpp)47
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h (renamed from include/lldb/Target/CPPLanguageRuntime.h)34
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp48
-rw-r--r--source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h29
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp11
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h10
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp47
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h12
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp52
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h30
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp25
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h31
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp218
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h39
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp56
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h16
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp25
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h10
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp28
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h7
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp (renamed from source/Target/ObjCLanguageRuntime.cpp)80
-rw-r--r--source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h (renamed from include/lldb/Target/ObjCLanguageRuntime.h)66
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp7
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h9
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp93
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h40
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp7
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h7
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp12
-rw-r--r--source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h7
-rw-r--r--source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp16
-rw-r--r--source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h7
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp127
-rw-r--r--source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h62
-rw-r--r--source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp411
-rw-r--r--source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h163
-rw-r--r--source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp197
-rw-r--r--source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h16
-rw-r--r--source/Plugins/ObjectFile/ELF/ELFHeader.cpp47
-rw-r--r--source/Plugins/ObjectFile/ELF/ELFHeader.h99
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp410
-rw-r--r--source/Plugins/ObjectFile/ELF/ObjectFileELF.h36
-rw-r--r--source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp61
-rw-r--r--source/Plugins/ObjectFile/JIT/ObjectFileJIT.h17
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp59
-rw-r--r--source/Plugins/OperatingSystem/Python/OperatingSystemPython.h17
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp14
-rw-r--r--source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h11
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp14
-rw-r--r--source/Plugins/Platform/NetBSD/PlatformNetBSD.h11
-rw-r--r--source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp10
-rw-r--r--source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h11
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.cpp351
-rw-r--r--source/Plugins/Platform/POSIX/PlatformPOSIX.h111
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp60
-rw-r--r--source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h22
-rw-r--r--source/Plugins/Process/Darwin/CFBundle.cpp17
-rw-r--r--source/Plugins/Process/Darwin/CFBundle.h9
-rw-r--r--source/Plugins/Process/Darwin/CFString.cpp15
-rw-r--r--source/Plugins/Process/Darwin/CFString.h9
-rw-r--r--source/Plugins/Process/Darwin/CFUtils.h9
-rw-r--r--source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp13
-rw-r--r--source/Plugins/Process/Darwin/DarwinProcessLauncher.h13
-rw-r--r--source/Plugins/Process/Darwin/LaunchFlavor.h7
-rw-r--r--source/Plugins/Process/Darwin/MachException.cpp7
-rw-r--r--source/Plugins/Process/Darwin/MachException.h7
-rw-r--r--source/Plugins/Process/Darwin/NativeProcessDarwin.cpp25
-rw-r--r--source/Plugins/Process/Darwin/NativeProcessDarwin.h35
-rw-r--r--source/Plugins/Process/Darwin/NativeThreadDarwin.cpp13
-rw-r--r--source/Plugins/Process/Darwin/NativeThreadDarwin.h25
-rw-r--r--source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp9
-rw-r--r--source/Plugins/Process/Darwin/NativeThreadListDarwin.h7
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.cpp15
-rw-r--r--source/Plugins/Process/FreeBSD/FreeBSDThread.h16
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp7
-rw-r--r--source/Plugins/Process/FreeBSD/POSIXStopInfo.h13
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp42
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessFreeBSD.h18
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.cpp108
-rw-r--r--source/Plugins/Process/FreeBSD/ProcessMonitor.h25
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h12
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp9
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h7
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp9
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h7
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp9
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h7
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp9
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h7
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp9
-rw-r--r--source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h7
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp53
-rw-r--r--source/Plugins/Process/NetBSD/NativeProcessNetBSD.h15
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp84
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h37
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp233
-rw-r--r--source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h26
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp7
-rw-r--r--source/Plugins/Process/NetBSD/NativeThreadNetBSD.h13
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.cpp7
-rw-r--r--source/Plugins/Process/POSIX/CrashReason.h7
-rw-r--r--source/Plugins/Process/POSIX/NativeProcessELF.cpp110
-rw-r--r--source/Plugins/Process/POSIX/NativeProcessELF.h46
-rw-r--r--source/Plugins/Process/POSIX/ProcessMessage.cpp9
-rw-r--r--source/Plugins/Process/POSIX/ProcessMessage.h29
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp7
-rw-r--r--source/Plugins/Process/POSIX/ProcessPOSIXLog.h7
-rw-r--r--source/Plugins/Process/Utility/ARMDefines.h18
-rw-r--r--source/Plugins/Process/Utility/ARMUtils.h7
-rw-r--r--source/Plugins/Process/Utility/AuxVector.cpp96
-rw-r--r--source/Plugins/Process/Utility/AuxVector.h73
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.cpp29
-rw-r--r--source/Plugins/Process/Utility/DynamicRegisterInfo.h11
-rw-r--r--source/Plugins/Process/Utility/FreeBSDSignals.cpp7
-rw-r--r--source/Plugins/Process/Utility/FreeBSDSignals.h7
-rw-r--r--source/Plugins/Process/Utility/GDBRemoteSignals.cpp7
-rw-r--r--source/Plugins/Process/Utility/GDBRemoteSignals.h7
-rw-r--r--source/Plugins/Process/Utility/HistoryThread.cpp29
-rw-r--r--source/Plugins/Process/Utility/HistoryThread.h19
-rw-r--r--source/Plugins/Process/Utility/HistoryUnwind.cpp19
-rw-r--r--source/Plugins/Process/Utility/HistoryUnwind.h11
-rw-r--r--source/Plugins/Process/Utility/InferiorCallPOSIX.cpp19
-rw-r--r--source/Plugins/Process/Utility/InferiorCallPOSIX.h7
-rw-r--r--source/Plugins/Process/Utility/InstructionUtils.h7
-rw-r--r--source/Plugins/Process/Utility/LinuxProcMaps.cpp7
-rw-r--r--source/Plugins/Process/Utility/LinuxProcMaps.h7
-rw-r--r--source/Plugins/Process/Utility/LinuxSignals.cpp7
-rw-r--r--source/Plugins/Process/Utility/LinuxSignals.h7
-rw-r--r--source/Plugins/Process/Utility/MipsLinuxSignals.cpp7
-rw-r--r--source/Plugins/Process/Utility/MipsLinuxSignals.h7
-rw-r--r--source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp7
-rw-r--r--source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h7
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.cpp7
-rw-r--r--source/Plugins/Process/Utility/NetBSDSignals.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwinConstants.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp117
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp30
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp50
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_i386.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp54
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.cpp15
-rw-r--r--source/Plugins/Process/Utility/RegisterContextDummy.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.cpp15
-rw-r--r--source/Plugins/Process/Utility/RegisterContextHistory.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.cpp132
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLLDB.h19
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp15
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_i386.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_mips64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_s390x.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp15
-rw-r--r--source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_arm.cpp7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_arm.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_i386.cpp7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_i386.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMach_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextMemory.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp21
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp21
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp45
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp17
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp17
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp19
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp57
-rw-r--r--source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h11
-rw-r--r--source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp13
-rw-r--r--source/Plugins/Process/Utility/RegisterContextThreadMemory.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_mips.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_powerpc.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_s390x.h9
-rw-r--r--source/Plugins/Process/Utility/RegisterContext_x86.h33
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoInterface.h11
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp11
-rw-r--r--source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_arm.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_arm64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_i386.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_mips.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_mips64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_powerpc.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_ppc64.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_ppc64le.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_s390x.h7
-rw-r--r--source/Plugins/Process/Utility/RegisterInfos_x86_64.h7
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.cpp15
-rw-r--r--source/Plugins/Process/Utility/StopInfoMachException.h9
-rw-r--r--source/Plugins/Process/Utility/ThreadMemory.cpp14
-rw-r--r--source/Plugins/Process/Utility/ThreadMemory.h7
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.cpp19
-rw-r--r--source/Plugins/Process/Utility/UnwindLLDB.h15
-rw-r--r--source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp21
-rw-r--r--source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-arm-register-enums.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-arm64-register-enums.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h11
-rw-r--r--source/Plugins/Process/Utility/lldb-ppc64-register-enums.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-s390x-register-enums.h9
-rw-r--r--source/Plugins/Process/Utility/lldb-x86-register-enums.h11
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.cpp255
-rw-r--r--source/Plugins/Process/elf-core/ProcessElfCore.h27
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp13
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp14
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp19
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp21
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp25
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp17
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp7
-rw-r--r--source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h7
-rw-r--r--source/Plugins/Process/elf-core/RegisterUtilities.cpp7
-rw-r--r--source/Plugins/Process/elf-core/RegisterUtilities.h49
-rw-r--r--source/Plugins/Process/elf-core/ThreadElfCore.cpp62
-rw-r--r--source/Plugins/Process/elf-core/ThreadElfCore.h11
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp12
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h9
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp176
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h22
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp79
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h86
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp11
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h7
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp134
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h7
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp27
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h24
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp122
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h13
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp210
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h30
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp41
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h9
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp66
-rw-r--r--source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h7
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp404
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemote.h44
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp7
-rw-r--r--source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h7
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp17
-rw-r--r--source/Plugins/Process/gdb-remote/ThreadGDBRemote.h10
-rw-r--r--source/Plugins/Process/minidump/MinidumpParser.cpp435
-rw-r--r--source/Plugins/Process/minidump/MinidumpParser.h50
-rw-r--r--source/Plugins/Process/minidump/MinidumpTypes.cpp146
-rw-r--r--source/Plugins/Process/minidump/MinidumpTypes.h296
-rw-r--r--source/Plugins/Process/minidump/NtStructures.h7
-rw-r--r--source/Plugins/Process/minidump/ProcessMinidump.cpp469
-rw-r--r--source/Plugins/Process/minidump/ProcessMinidump.h14
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp21
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h7
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp31
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h7
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp7
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h7
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp7
-rw-r--r--source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h7
-rw-r--r--source/Plugins/Process/minidump/ThreadMinidump.cpp34
-rw-r--r--source/Plugins/Process/minidump/ThreadMinidump.h9
-rw-r--r--source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp20
-rw-r--r--source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h16
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp99
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h43
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp7
-rw-r--r--source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h7
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp1257
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h573
-rw-r--r--source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h473
-rw-r--r--source/Plugins/ScriptInterpreter/Python/lldb-python.h13
-rw-r--r--source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp72
-rw-r--r--source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h39
-rw-r--r--source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp558
-rw-r--r--source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h116
-rw-r--r--source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp22
-rw-r--r--source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h12
-rw-r--r--source/Plugins/SymbolFile/DWARF/DIERef.cpp69
-rw-r--r--source/Plugins/SymbolFile/DWARF/DIERef.h83
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParser.h7
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp3095
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h27
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp88
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h33
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp37
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFAttribute.h15
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp78
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h40
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp171
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h40
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFContext.cpp138
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFContext.h74
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp272
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIE.h92
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp35
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h38
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp21
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h20
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp107
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h27
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp297
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h28
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp112
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h27
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp287
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h62
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp1097
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h200
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp375
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h44
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp39
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h26
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp111
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h42
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp7
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h7
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp37
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h24
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp11
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h11
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp243
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFDefines.h44
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp374
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFFormValue.h54
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp18
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFIndex.h15
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp23
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h37
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp631
-rw-r--r--source/Plugins/SymbolFile/DWARF/DWARFUnit.h209
-rw-r--r--source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp58
-rw-r--r--source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h14
-rw-r--r--source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp98
-rw-r--r--source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h32
-rw-r--r--source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp16
-rw-r--r--source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h16
-rw-r--r--source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp162
-rw-r--r--source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h25
-rw-r--r--source/Plugins/SymbolFile/DWARF/NameToDIE.cpp31
-rw-r--r--source/Plugins/SymbolFile/DWARF/NameToDIE.h17
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp1404
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h155
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp108
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h73
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp139
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h31
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp9
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h9
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp9
-rw-r--r--source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h9
-rw-r--r--source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp11
-rw-r--r--source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h13
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp457
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h24
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp20
-rw-r--r--source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h7
-rw-r--r--source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp491
-rw-r--r--source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h10
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp58
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h20
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp137
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h28
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp14
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbIndex.h8
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp7
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbSymUid.h7
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp151
-rw-r--r--source/Plugins/SymbolFile/NativePDB/PdbUtil.h9
-rw-r--r--source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp41
-rw-r--r--source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h30
-rw-r--r--source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp61
-rw-r--r--source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h23
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBASTParser.cpp29
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBASTParser.h7
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp556
-rw-r--r--source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h22
-rw-r--r--source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp65
-rw-r--r--source/Plugins/SymbolFile/PDB/SymbolFilePDB.h24
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp32
-rw-r--r--source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h17
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp38
-rw-r--r--source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h13
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp47
-rw-r--r--source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h21
-rw-r--r--source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp13
-rw-r--r--source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h9
-rw-r--r--source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp287
-rw-r--r--source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h19
-rw-r--r--source/Symbol/ArmUnwindInfo.cpp9
-rw-r--r--source/Symbol/Block.cpp28
-rw-r--r--source/Symbol/ClangASTContext.cpp391
-rw-r--r--source/Symbol/ClangASTImporter.cpp250
-rw-r--r--source/Symbol/ClangExternalASTSourceCallbacks.cpp7
-rw-r--r--source/Symbol/ClangExternalASTSourceCommon.cpp7
-rw-r--r--source/Symbol/ClangUtil.cpp7
-rw-r--r--source/Symbol/CompactUnwindInfo.cpp21
-rw-r--r--source/Symbol/CompileUnit.cpp29
-rw-r--r--source/Symbol/CompilerDecl.cpp7
-rw-r--r--source/Symbol/CompilerDeclContext.cpp20
-rw-r--r--source/Symbol/CompilerType.cpp40
-rw-r--r--source/Symbol/CxxModuleHandler.cpp283
-rw-r--r--source/Symbol/DWARFCallFrameInfo.cpp107
-rw-r--r--source/Symbol/DebugMacros.cpp7
-rw-r--r--source/Symbol/DeclVendor.cpp29
-rw-r--r--source/Symbol/Declaration.cpp12
-rw-r--r--source/Symbol/FuncUnwinders.cpp164
-rw-r--r--source/Symbol/Function.cpp29
-rw-r--r--source/Symbol/LineEntry.cpp73
-rw-r--r--source/Symbol/LineTable.cpp24
-rw-r--r--source/Symbol/LocateSymbolFile.cpp (renamed from source/Host/common/Symbols.cpp)58
-rw-r--r--source/Symbol/LocateSymbolFileMacOSX.cpp657
-rw-r--r--source/Symbol/ObjectFile.cpp52
-rw-r--r--source/Symbol/PostfixExpression.cpp227
-rw-r--r--source/Symbol/Symbol.cpp26
-rw-r--r--source/Symbol/SymbolContext.cpp56
-rw-r--r--source/Symbol/SymbolFile.cpp31
-rw-r--r--source/Symbol/SymbolVendor.cpp174
-rw-r--r--source/Symbol/Symtab.cpp127
-rw-r--r--source/Symbol/Type.cpp214
-rw-r--r--source/Symbol/TypeList.cpp15
-rw-r--r--source/Symbol/TypeMap.cpp15
-rw-r--r--source/Symbol/TypeSystem.cpp9
-rw-r--r--source/Symbol/UnwindPlan.cpp46
-rw-r--r--source/Symbol/UnwindTable.cpp40
-rw-r--r--source/Symbol/Variable.cpp13
-rw-r--r--source/Symbol/VariableList.cpp15
-rw-r--r--source/Symbol/VerifyDecl.cpp12
-rw-r--r--source/Target/ABI.cpp35
-rw-r--r--source/Target/ExecutionContext.cpp15
-rw-r--r--source/Target/InstrumentationRuntime.cpp7
-rw-r--r--source/Target/InstrumentationRuntimeStopInfo.cpp7
-rw-r--r--source/Target/JITLoader.cpp7
-rw-r--r--source/Target/JITLoaderList.cpp7
-rw-r--r--source/Target/Language.cpp40
-rw-r--r--source/Target/LanguageRuntime.cpp59
-rw-r--r--source/Target/Memory.cpp33
-rw-r--r--source/Target/MemoryHistory.cpp7
-rw-r--r--source/Target/ModuleCache.cpp7
-rw-r--r--source/Target/OperatingSystem.cpp19
-rw-r--r--source/Target/PathMappingList.cpp92
-rw-r--r--source/Target/Platform.cpp68
-rw-r--r--source/Target/Process.cpp850
-rw-r--r--source/Target/ProcessInfo.cpp114
-rw-r--r--source/Target/Queue.cpp7
-rw-r--r--source/Target/QueueItem.cpp7
-rw-r--r--source/Target/QueueList.cpp7
-rw-r--r--source/Target/RegisterContext.cpp7
-rw-r--r--source/Target/RegisterNumber.cpp7
-rw-r--r--source/Target/RemoteAwarePlatform.cpp284
-rw-r--r--source/Target/SectionLoadHistory.cpp11
-rw-r--r--source/Target/SectionLoadList.cpp12
-rw-r--r--source/Target/StackFrame.cpp38
-rw-r--r--source/Target/StackFrameList.cpp53
-rw-r--r--source/Target/StackFrameRecognizer.cpp25
-rw-r--r--source/Target/StackID.cpp7
-rw-r--r--source/Target/StopInfo.cpp23
-rw-r--r--source/Target/StructuredDataPlugin.cpp11
-rw-r--r--source/Target/SystemRuntime.cpp15
-rw-r--r--source/Target/Target.cpp293
-rw-r--r--source/Target/TargetList.cpp13
-rw-r--r--source/Target/Thread.cpp109
-rw-r--r--source/Target/ThreadCollection.cpp7
-rw-r--r--source/Target/ThreadList.cpp13
-rw-r--r--source/Target/ThreadPlan.cpp13
-rw-r--r--source/Target/ThreadPlanBase.cpp9
-rw-r--r--source/Target/ThreadPlanCallFunction.cpp15
-rw-r--r--source/Target/ThreadPlanCallFunctionUsingABI.cpp9
-rw-r--r--source/Target/ThreadPlanCallOnFunctionExit.cpp9
-rw-r--r--source/Target/ThreadPlanCallUserExpression.cpp11
-rw-r--r--source/Target/ThreadPlanPython.cpp14
-rw-r--r--source/Target/ThreadPlanRunToAddress.cpp9
-rw-r--r--source/Target/ThreadPlanShouldStopHere.cpp11
-rw-r--r--source/Target/ThreadPlanStepInRange.cpp17
-rw-r--r--source/Target/ThreadPlanStepInstruction.cpp9
-rw-r--r--source/Target/ThreadPlanStepOut.cpp25
-rw-r--r--source/Target/ThreadPlanStepOverBreakpoint.cpp9
-rw-r--r--source/Target/ThreadPlanStepOverRange.cpp9
-rw-r--r--source/Target/ThreadPlanStepRange.cpp28
-rw-r--r--source/Target/ThreadPlanStepThrough.cpp35
-rw-r--r--source/Target/ThreadPlanStepUntil.cpp9
-rw-r--r--source/Target/ThreadPlanTracer.cpp9
-rw-r--r--source/Target/ThreadSpec.cpp19
-rw-r--r--source/Target/UnixSignals.cpp16
-rw-r--r--source/Target/UnwindAssembly.cpp13
-rw-r--r--source/Utility/ARM64_DWARF_Registers.h7
-rw-r--r--source/Utility/ARM64_ehframe_Registers.h7
-rw-r--r--source/Utility/ARM_DWARF_Registers.h7
-rw-r--r--source/Utility/ARM_ehframe_Registers.h7
-rw-r--r--source/Utility/ArchSpec.cpp79
-rw-r--r--source/Utility/Args.cpp25
-rw-r--r--source/Utility/Baton.cpp7
-rw-r--r--source/Utility/Broadcaster.cpp103
-rw-r--r--source/Utility/CompletionRequest.cpp7
-rw-r--r--source/Utility/Connection.cpp7
-rw-r--r--source/Utility/ConstString.cpp25
-rw-r--r--source/Utility/DataBufferHeap.cpp29
-rw-r--r--source/Utility/DataBufferLLVM.cpp7
-rw-r--r--source/Utility/DataEncoder.cpp32
-rw-r--r--source/Utility/DataExtractor.cpp149
-rw-r--r--source/Utility/Environment.cpp7
-rw-r--r--source/Utility/Event.cpp29
-rw-r--r--source/Utility/FileCollector.cpp182
-rw-r--r--source/Utility/FileSpec.cpp92
-rw-r--r--source/Utility/IOObject.cpp7
-rw-r--r--source/Utility/JSON.cpp27
-rw-r--r--source/Utility/LLDBAssert.cpp14
-rw-r--r--source/Utility/Listener.cpp19
-rw-r--r--source/Utility/Log.cpp17
-rw-r--r--source/Utility/Logging.cpp8
-rw-r--r--source/Utility/NameMatches.cpp7
-rw-r--r--source/Utility/PPC64LE_DWARF_Registers.h7
-rw-r--r--source/Utility/PPC64LE_ehframe_Registers.h7
-rw-r--r--source/Utility/PPC64_DWARF_Registers.h7
-rw-r--r--source/Utility/ProcessInfo.cpp310
-rw-r--r--source/Utility/RegisterValue.cpp31
-rw-r--r--source/Utility/RegularExpression.cpp30
-rw-r--r--source/Utility/Reproducer.cpp92
-rw-r--r--source/Utility/ReproducerInstrumentation.cpp122
-rw-r--r--source/Utility/Scalar.cpp528
-rw-r--r--source/Utility/SelectHelper.cpp17
-rw-r--r--source/Utility/SharingPtr.cpp7
-rw-r--r--source/Utility/State.cpp7
-rw-r--r--source/Utility/Status.cpp37
-rw-r--r--source/Utility/Stream.cpp111
-rw-r--r--source/Utility/StreamCallback.cpp7
-rw-r--r--source/Utility/StreamGDBRemote.cpp9
-rw-r--r--source/Utility/StreamString.cpp7
-rw-r--r--source/Utility/StringExtractor.cpp54
-rw-r--r--source/Utility/StringExtractorGDBRemote.cpp15
-rw-r--r--source/Utility/StringLexer.cpp10
-rw-r--r--source/Utility/StringList.cpp7
-rw-r--r--source/Utility/StructuredData.cpp13
-rw-r--r--source/Utility/TildeExpressionResolver.cpp7
-rw-r--r--source/Utility/Timer.cpp52
-rw-r--r--source/Utility/UUID.cpp19
-rw-r--r--source/Utility/UriParser.cpp9
-rw-r--r--source/Utility/UserID.cpp7
-rw-r--r--source/Utility/UserIDResolver.cpp44
-rw-r--r--source/Utility/UuidCompatibility.h7
-rw-r--r--source/Utility/VASprintf.cpp9
-rw-r--r--source/Utility/VMRange.cpp7
-rw-r--r--source/lldb.cpp15
-rw-r--r--tools/argdumper/argdumper.cpp7
-rw-r--r--tools/driver/Driver.cpp533
-rw-r--r--tools/driver/Driver.h34
-rw-r--r--tools/driver/Options.td9
-rw-r--r--tools/driver/Platform.cpp7
-rw-r--r--tools/driver/Platform.h7
-rw-r--r--tools/lldb-instr/Instrument.cpp356
-rw-r--r--tools/lldb-mi/MICmdArgContext.cpp17
-rw-r--r--tools/lldb-mi/MICmdArgContext.h7
-rw-r--r--tools/lldb-mi/MICmdArgSet.cpp21
-rw-r--r--tools/lldb-mi/MICmdArgSet.h7
-rw-r--r--tools/lldb-mi/MICmdArgValBase.cpp16
-rw-r--r--tools/lldb-mi/MICmdArgValBase.h9
-rw-r--r--tools/lldb-mi/MICmdArgValConsume.cpp12
-rw-r--r--tools/lldb-mi/MICmdArgValConsume.h7
-rw-r--r--tools/lldb-mi/MICmdArgValFile.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValFile.h7
-rw-r--r--tools/lldb-mi/MICmdArgValListBase.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValListBase.h8
-rw-r--r--tools/lldb-mi/MICmdArgValListOfN.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValListOfN.h8
-rw-r--r--tools/lldb-mi/MICmdArgValNumber.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValNumber.h8
-rw-r--r--tools/lldb-mi/MICmdArgValOptionLong.cpp18
-rw-r--r--tools/lldb-mi/MICmdArgValOptionLong.h8
-rw-r--r--tools/lldb-mi/MICmdArgValOptionShort.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValOptionShort.h7
-rw-r--r--tools/lldb-mi/MICmdArgValPrintValues.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValPrintValues.h7
-rw-r--r--tools/lldb-mi/MICmdArgValString.cpp21
-rw-r--r--tools/lldb-mi/MICmdArgValString.h7
-rw-r--r--tools/lldb-mi/MICmdArgValThreadGrp.cpp14
-rw-r--r--tools/lldb-mi/MICmdArgValThreadGrp.h7
-rw-r--r--tools/lldb-mi/MICmdBase.cpp27
-rw-r--r--tools/lldb-mi/MICmdBase.h9
-rw-r--r--tools/lldb-mi/MICmdCmd.cpp20
-rw-r--r--tools/lldb-mi/MICmdCmd.h7
-rw-r--r--tools/lldb-mi/MICmdCmdBreak.cpp60
-rw-r--r--tools/lldb-mi/MICmdCmdBreak.h7
-rw-r--r--tools/lldb-mi/MICmdCmdData.cpp107
-rw-r--r--tools/lldb-mi/MICmdCmdData.h7
-rw-r--r--tools/lldb-mi/MICmdCmdEnviro.cpp13
-rw-r--r--tools/lldb-mi/MICmdCmdEnviro.h7
-rw-r--r--tools/lldb-mi/MICmdCmdExec.cpp95
-rw-r--r--tools/lldb-mi/MICmdCmdExec.h7
-rw-r--r--tools/lldb-mi/MICmdCmdFile.cpp14
-rw-r--r--tools/lldb-mi/MICmdCmdFile.h7
-rw-r--r--tools/lldb-mi/MICmdCmdGdbInfo.cpp15
-rw-r--r--tools/lldb-mi/MICmdCmdGdbInfo.h7
-rw-r--r--tools/lldb-mi/MICmdCmdGdbSet.cpp21
-rw-r--r--tools/lldb-mi/MICmdCmdGdbSet.h7
-rw-r--r--tools/lldb-mi/MICmdCmdGdbShow.cpp20
-rw-r--r--tools/lldb-mi/MICmdCmdGdbShow.h7
-rw-r--r--tools/lldb-mi/MICmdCmdGdbThread.cpp12
-rw-r--r--tools/lldb-mi/MICmdCmdGdbThread.h7
-rw-r--r--tools/lldb-mi/MICmdCmdMiscellanous.cpp45
-rw-r--r--tools/lldb-mi/MICmdCmdMiscellanous.h7
-rw-r--r--tools/lldb-mi/MICmdCmdStack.cpp67
-rw-r--r--tools/lldb-mi/MICmdCmdStack.h7
-rw-r--r--tools/lldb-mi/MICmdCmdSupportInfo.cpp15
-rw-r--r--tools/lldb-mi/MICmdCmdSupportInfo.h7
-rw-r--r--tools/lldb-mi/MICmdCmdSupportList.cpp12
-rw-r--r--tools/lldb-mi/MICmdCmdSupportList.h7
-rw-r--r--tools/lldb-mi/MICmdCmdSymbol.cpp13
-rw-r--r--tools/lldb-mi/MICmdCmdSymbol.h7
-rw-r--r--tools/lldb-mi/MICmdCmdTarget.cpp27
-rw-r--r--tools/lldb-mi/MICmdCmdTarget.h7
-rw-r--r--tools/lldb-mi/MICmdCmdThread.cpp13
-rw-r--r--tools/lldb-mi/MICmdCmdThread.h7
-rw-r--r--tools/lldb-mi/MICmdCmdTrace.cpp12
-rw-r--r--tools/lldb-mi/MICmdCmdTrace.h7
-rw-r--r--tools/lldb-mi/MICmdCmdVar.cpp88
-rw-r--r--tools/lldb-mi/MICmdCmdVar.h7
-rw-r--r--tools/lldb-mi/MICmdCommands.cpp9
-rw-r--r--tools/lldb-mi/MICmdCommands.h7
-rw-r--r--tools/lldb-mi/MICmdData.cpp7
-rw-r--r--tools/lldb-mi/MICmdData.h7
-rw-r--r--tools/lldb-mi/MICmdFactory.cpp16
-rw-r--r--tools/lldb-mi/MICmdFactory.h7
-rw-r--r--tools/lldb-mi/MICmdInterpreter.cpp18
-rw-r--r--tools/lldb-mi/MICmdInterpreter.h7
-rw-r--r--tools/lldb-mi/MICmdInvoker.cpp19
-rw-r--r--tools/lldb-mi/MICmdInvoker.h7
-rw-r--r--tools/lldb-mi/MICmdMgr.cpp16
-rw-r--r--tools/lldb-mi/MICmdMgr.h7
-rw-r--r--tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp12
-rw-r--r--tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h7
-rw-r--r--tools/lldb-mi/MICmnBase.cpp17
-rw-r--r--tools/lldb-mi/MICmnBase.h7
-rw-r--r--tools/lldb-mi/MICmnConfig.h7
-rw-r--r--tools/lldb-mi/MICmnLLDBBroadcaster.cpp11
-rw-r--r--tools/lldb-mi/MICmnLLDBBroadcaster.h7
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp39
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfo.h9
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp40
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h7
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugger.cpp46
-rw-r--r--tools/lldb-mi/MICmnLLDBDebugger.h7
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp47
-rw-r--r--tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h7
-rw-r--r--tools/lldb-mi/MICmnLLDBProxySBValue.cpp10
-rw-r--r--tools/lldb-mi/MICmnLLDBProxySBValue.h7
-rw-r--r--tools/lldb-mi/MICmnLLDBUtilSBValue.cpp27
-rw-r--r--tools/lldb-mi/MICmnLLDBUtilSBValue.h7
-rw-r--r--tools/lldb-mi/MICmnLog.cpp22
-rw-r--r--tools/lldb-mi/MICmnLog.h7
-rw-r--r--tools/lldb-mi/MICmnLogMediumFile.cpp30
-rw-r--r--tools/lldb-mi/MICmnLogMediumFile.h7
-rw-r--r--tools/lldb-mi/MICmnMIOutOfBandRecord.cpp25
-rw-r--r--tools/lldb-mi/MICmnMIOutOfBandRecord.h7
-rw-r--r--tools/lldb-mi/MICmnMIResultRecord.cpp20
-rw-r--r--tools/lldb-mi/MICmnMIResultRecord.h7
-rw-r--r--tools/lldb-mi/MICmnMIValue.cpp10
-rw-r--r--tools/lldb-mi/MICmnMIValue.h7
-rw-r--r--tools/lldb-mi/MICmnMIValueConst.cpp11
-rw-r--r--tools/lldb-mi/MICmnMIValueConst.h7
-rw-r--r--tools/lldb-mi/MICmnMIValueList.cpp17
-rw-r--r--tools/lldb-mi/MICmnMIValueList.h7
-rw-r--r--tools/lldb-mi/MICmnMIValueResult.cpp14
-rw-r--r--tools/lldb-mi/MICmnMIValueResult.h9
-rw-r--r--tools/lldb-mi/MICmnMIValueTuple.cpp18
-rw-r--r--tools/lldb-mi/MICmnMIValueTuple.h7
-rw-r--r--tools/lldb-mi/MICmnResources.cpp15
-rw-r--r--tools/lldb-mi/MICmnResources.h7
-rw-r--r--tools/lldb-mi/MICmnStreamStderr.cpp18
-rw-r--r--tools/lldb-mi/MICmnStreamStderr.h7
-rw-r--r--tools/lldb-mi/MICmnStreamStdin.cpp16
-rw-r--r--tools/lldb-mi/MICmnStreamStdin.h7
-rw-r--r--tools/lldb-mi/MICmnStreamStdout.cpp18
-rw-r--r--tools/lldb-mi/MICmnStreamStdout.h7
-rw-r--r--tools/lldb-mi/MICmnThreadMgrStd.cpp13
-rw-r--r--tools/lldb-mi/MICmnThreadMgrStd.h8
-rw-r--r--tools/lldb-mi/MIDataTypes.h10
-rw-r--r--tools/lldb-mi/MIDriver.cpp61
-rw-r--r--tools/lldb-mi/MIDriver.h7
-rw-r--r--tools/lldb-mi/MIDriverBase.cpp20
-rw-r--r--tools/lldb-mi/MIDriverBase.h7
-rw-r--r--tools/lldb-mi/MIDriverMain.cpp11
-rw-r--r--tools/lldb-mi/MIDriverMgr.cpp34
-rw-r--r--tools/lldb-mi/MIDriverMgr.h7
-rw-r--r--tools/lldb-mi/MIUtilDateTimeStd.cpp12
-rw-r--r--tools/lldb-mi/MIUtilDateTimeStd.h7
-rw-r--r--tools/lldb-mi/MIUtilDebug.cpp15
-rw-r--r--tools/lldb-mi/MIUtilDebug.h7
-rw-r--r--tools/lldb-mi/MIUtilFileStd.cpp25
-rw-r--r--tools/lldb-mi/MIUtilFileStd.h7
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.cpp14
-rw-r--r--tools/lldb-mi/MIUtilMapIdToVariant.h9
-rw-r--r--tools/lldb-mi/MIUtilSingletonBase.h7
-rw-r--r--tools/lldb-mi/MIUtilSingletonHelper.h7
-rw-r--r--tools/lldb-mi/MIUtilString.cpp63
-rw-r--r--tools/lldb-mi/MIUtilString.h10
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.cpp31
-rw-r--r--tools/lldb-mi/MIUtilThreadBaseStd.h7
-rw-r--r--tools/lldb-mi/MIUtilVariant.cpp38
-rw-r--r--tools/lldb-mi/MIUtilVariant.h23
-rw-r--r--tools/lldb-mi/Platform.h7
-rw-r--r--tools/lldb-server/Acceptor.cpp7
-rw-r--r--tools/lldb-server/Acceptor.h7
-rw-r--r--tools/lldb-server/Darwin/resources/lldb-server-entitlements.plist2
-rw-r--r--tools/lldb-server/Darwin/resources/lldb-server-macos-entitlements.plist2
-rw-r--r--tools/lldb-server/LLDBServerUtilities.cpp8
-rw-r--r--tools/lldb-server/LLDBServerUtilities.h7
-rw-r--r--tools/lldb-server/SystemInitializerLLGS.cpp55
-rw-r--r--tools/lldb-server/SystemInitializerLLGS.h10
-rw-r--r--tools/lldb-server/lldb-gdbserver.cpp42
-rw-r--r--tools/lldb-server/lldb-platform.cpp37
-rw-r--r--tools/lldb-server/lldb-server.cpp23
1714 files changed, 48380 insertions, 46824 deletions
diff --git a/LICENSE.TXT b/LICENSE.TXT
index 1f0309419d78f..029b1d9aae1d9 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -1,3 +1,241 @@
+==============================================================================
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
+==============================================================================
University of Illinois/NCSA
Open Source License
diff --git a/include/lldb/API/LLDB.h b/include/lldb/API/LLDB.h
index 2b3dd96aef0e5..0806ab700a949 100644
--- a/include/lldb/API/LLDB.h
+++ b/include/lldb/API/LLDB.h
@@ -1,9 +1,8 @@
//===-- LLDB.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -49,6 +48,7 @@
#include "lldb/API/SBProcessInfo.h"
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBQueueItem.h"
+#include "lldb/API/SBReproducer.h"
#include "lldb/API/SBSection.h"
#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBStream.h"
diff --git a/include/lldb/API/SBAddress.h b/include/lldb/API/SBAddress.h
index 891324254cd62..2874a3602af2d 100644
--- a/include/lldb/API/SBAddress.h
+++ b/include/lldb/API/SBAddress.h
@@ -1,9 +1,8 @@
//===-- SBAddress.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,6 +29,12 @@ public:
const lldb::SBAddress &operator=(const lldb::SBAddress &rhs);
+ explicit operator bool() const;
+
+ // operator== is a free function
+
+ bool operator!=(const SBAddress &rhs) const;
+
bool IsValid() const;
void Clear();
@@ -115,7 +120,7 @@ protected:
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_up;
};
bool LLDB_API operator==(const SBAddress &lhs, const SBAddress &rhs);
diff --git a/include/lldb/API/SBAttachInfo.h b/include/lldb/API/SBAttachInfo.h
index 7ae006908cccb..3c20a08cb4a94 100644
--- a/include/lldb/API/SBAttachInfo.h
+++ b/include/lldb/API/SBAttachInfo.h
@@ -1,9 +1,8 @@
//===-- SBAttachInfo.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,35 +21,32 @@ public:
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
+ /// \param[in] path
/// A full or partial name for the process to attach to.
///
- /// @param[in] wait_for
+ /// \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
+ /// \param[in] path
/// A full or partial name for the process to attach to.
///
- /// @param[in] wait_for
+ /// \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
+ /// \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.
@@ -60,7 +56,6 @@ public:
/// 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);
@@ -79,31 +74,28 @@ public:
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] b
+ /// \param[in] b
/// 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] b
+ /// \param[in] b
/// 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
+ /// \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.
@@ -113,7 +105,6 @@ public:
/// 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();
@@ -158,23 +149,19 @@ public:
bool ParentProcessIDIsValid();
- //----------------------------------------------------------------------
/// Get the listener that will be used to receive process events.
///
/// If no listener has been set via a call to
/// SBAttachInfo::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:
diff --git a/include/lldb/API/SBBlock.h b/include/lldb/API/SBBlock.h
index 112de96734237..0ca92ff0c6ac9 100644
--- a/include/lldb/API/SBBlock.h
+++ b/include/lldb/API/SBBlock.h
@@ -1,9 +1,8 @@
//===-- SBBlock.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,6 +28,8 @@ public:
bool IsInlined() const;
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetInlinedName() const;
@@ -59,16 +60,14 @@ public:
lldb::SBValueList GetVariables(lldb::SBTarget &target, bool arguments,
bool locals, bool statics);
- //------------------------------------------------------------------
/// Get the inlined block that contains this block.
///
- /// @return
+ /// \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);
diff --git a/include/lldb/API/SBBreakpoint.h b/include/lldb/API/SBBreakpoint.h
index 2c93bf103e3eb..75c0e69a4821e 100644
--- a/include/lldb/API/SBBreakpoint.h
+++ b/include/lldb/API/SBBreakpoint.h
@@ -1,9 +1,8 @@
//===-- SBBreakpoint.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,6 +36,8 @@ public:
break_id_t GetID() const;
+ explicit operator bool() const;
+
bool IsValid() const;
void ClearAllBreakpointSites();
diff --git a/include/lldb/API/SBBreakpointLocation.h b/include/lldb/API/SBBreakpointLocation.h
index 4b34bcbf1f28b..085bed9399b98 100644
--- a/include/lldb/API/SBBreakpointLocation.h
+++ b/include/lldb/API/SBBreakpointLocation.h
@@ -1,9 +1,8 @@
//===-- SBBreakpointLocation.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,6 +27,8 @@ public:
break_id_t GetID();
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBAddress GetAddress();
diff --git a/include/lldb/API/SBBreakpointName.h b/include/lldb/API/SBBreakpointName.h
index 321f0d784d6f7..018238bcd074f 100644
--- a/include/lldb/API/SBBreakpointName.h
+++ b/include/lldb/API/SBBreakpointName.h
@@ -1,9 +1,8 @@
//===-- SBBreakpointName.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,6 +39,8 @@ public:
bool operator!=(const lldb::SBBreakpointName &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName() const;
diff --git a/include/lldb/API/SBBroadcaster.h b/include/lldb/API/SBBroadcaster.h
index dc6c50ec0a8a5..fc5e8880e9f2b 100644
--- a/include/lldb/API/SBBroadcaster.h
+++ b/include/lldb/API/SBBroadcaster.h
@@ -1,9 +1,8 @@
//===-- SBBroadcaster.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,8 @@ public:
~SBBroadcaster();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
diff --git a/include/lldb/API/SBCommandInterpreter.h b/include/lldb/API/SBCommandInterpreter.h
index f988944788111..6c80e8eb26dc8 100644
--- a/include/lldb/API/SBCommandInterpreter.h
+++ b/include/lldb/API/SBCommandInterpreter.h
@@ -1,9 +1,8 @@
//===-- SBCommandInterpreter.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -88,6 +87,8 @@ public:
static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event);
+ explicit operator bool() const;
+
bool IsValid() const;
bool CommandExists(const char *cmd);
@@ -189,16 +190,13 @@ public:
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.
///
@@ -207,43 +205,34 @@ public:
/// terminal, so this function allows GUI programs to emulate this
/// functionality.
///
- /// @param[in] ch
+ /// \param[in] ch
/// The character that was typed along with the control key
///
- /// @return
+ /// \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);
- //----------------------------------------------------------------------
/// Sets whether the command interpreter should allow custom exit codes
/// for the 'quit' command.
- //----------------------------------------------------------------------
void AllowExitCodeOnQuit(bool allow);
- //----------------------------------------------------------------------
/// Returns true if the user has called the 'quit' command with a custom exit
/// code.
- //----------------------------------------------------------------------
bool HasCustomQuitExitCode();
- //----------------------------------------------------------------------
/// Returns the exit code that the user has specified when running the
/// 'quit' command. Returns 0 if the user hasn't called 'quit' at all or
/// without a custom exit code.
- //----------------------------------------------------------------------
int GetQuitStatus();
- //----------------------------------------------------------------------
/// 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:
@@ -256,8 +245,6 @@ protected:
private:
friend class SBDebugger;
- static void InitializeSWIG();
-
lldb_private::CommandInterpreter *m_opaque_ptr;
};
@@ -275,6 +262,8 @@ class SBCommand {
public:
SBCommand();
+ explicit operator bool() const;
+
bool IsValid();
const char *GetName();
diff --git a/include/lldb/API/SBCommandReturnObject.h b/include/lldb/API/SBCommandReturnObject.h
index 798aa92a7ef25..2877afb9b8b05 100644
--- a/include/lldb/API/SBCommandReturnObject.h
+++ b/include/lldb/API/SBCommandReturnObject.h
@@ -1,9 +1,8 @@
//===-- SBCommandReturnObject.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,6 +32,8 @@ public:
lldb_private::CommandReturnObject *Release();
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetOutput();
@@ -100,7 +101,7 @@ protected:
void SetLLDBObjectPtr(lldb_private::CommandReturnObject *ptr);
private:
- std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap;
+ std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBCommunication.h b/include/lldb/API/SBCommunication.h
index f0016275b634a..5b803fc6017c6 100644
--- a/include/lldb/API/SBCommunication.h
+++ b/include/lldb/API/SBCommunication.h
@@ -1,9 +1,8 @@
//===-- SBCommunication.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,6 +37,8 @@ public:
SBCommunication(const char *broadcaster_name);
~SBCommunication();
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBBroadcaster GetBroadcaster();
diff --git a/include/lldb/API/SBCompileUnit.h b/include/lldb/API/SBCompileUnit.h
index 4d5f9f36f246e..b6b138207d600 100644
--- a/include/lldb/API/SBCompileUnit.h
+++ b/include/lldb/API/SBCompileUnit.h
@@ -1,9 +1,8 @@
//===-- SBCompileUnit.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,6 +24,8 @@ public:
const lldb::SBCompileUnit &operator=(const lldb::SBCompileUnit &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBFileSpec GetFileSpec() const;
@@ -47,11 +48,10 @@ public:
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
+ /// \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
@@ -59,9 +59,8 @@ public:
/// all types found in the debug information for this compile
/// unit.
///
- /// @return
+ /// \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();
diff --git a/include/lldb/API/SBData.h b/include/lldb/API/SBData.h
index 7ff619e68667b..886fe829a4699 100644
--- a/include/lldb/API/SBData.h
+++ b/include/lldb/API/SBData.h
@@ -1,9 +1,8 @@
//===-- SBData.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,6 +29,8 @@ public:
void Clear();
+ explicit operator bool() const;
+
bool IsValid();
size_t GetByteSize();
diff --git a/include/lldb/API/SBDebugger.h b/include/lldb/API/SBDebugger.h
index 3f31bf16da8dd..417cead24a8c6 100644
--- a/include/lldb/API/SBDebugger.h
+++ b/include/lldb/API/SBDebugger.h
@@ -1,9 +1,8 @@
//===-- SBDebugger.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,7 +12,6 @@
#include <stdio.h>
#include "lldb/API/SBDefines.h"
-#include "lldb/API/SBInitializerOptions.h"
#include "lldb/API/SBPlatform.h"
namespace lldb {
@@ -23,12 +21,12 @@ 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);
+ SBError Initialize(lldb::SBDebugger &sb_debugger,
+ unsigned long (*callback)(void *, lldb::SBInputReader *,
+ lldb::InputReaderAction,
+ char const *, unsigned long),
+ void *a, lldb::InputReaderGranularity b, char const *c,
+ char const *d, bool e);
void SetIsDone(bool);
bool IsActive() const;
};
@@ -46,7 +44,8 @@ public:
lldb::SBDebugger &operator=(const lldb::SBDebugger &rhs);
static void Initialize();
- static lldb::SBError Initialize(SBInitializerOptions &options);
+
+ static lldb::SBError InitializeWithErrorHandling();
static void Terminate();
@@ -63,6 +62,8 @@ public:
static void MemoryPressureDetected();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
@@ -150,7 +151,7 @@ public:
/// Get the name and description of one of the available platforms.
///
- /// @param[in] idx
+ /// \param[in] idx
/// Zero-based index of the platform for which info should be retrieved,
/// must be less than the value returned by GetNumAvailablePlatforms().
lldb::SBStructuredData GetAvailablePlatformInfoAtIndex(uint32_t idx);
@@ -254,15 +255,11 @@ public:
SBTypeFormat GetFormatForType(SBTypeNameSpecifier);
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSummary GetSummaryForType(SBTypeNameSpecifier);
-#endif
SBTypeFilter GetFilterForType(SBTypeNameSpecifier);
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
-#endif
void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread);
diff --git a/include/lldb/API/SBDeclaration.h b/include/lldb/API/SBDeclaration.h
index 42cf769638477..d2b423e40fec6 100644
--- a/include/lldb/API/SBDeclaration.h
+++ b/include/lldb/API/SBDeclaration.h
@@ -1,10 +1,9 @@
//===-- SBDeclaration.h -------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,8 @@ public:
const lldb::SBDeclaration &operator=(const lldb::SBDeclaration &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBFileSpec GetFileSpec() const;
@@ -62,7 +63,7 @@ private:
void SetDeclaration(const lldb_private::Declaration &lldb_object_ref);
- std::unique_ptr<lldb_private::Declaration> m_opaque_ap;
+ std::unique_ptr<lldb_private::Declaration> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBDefines.h b/include/lldb/API/SBDefines.h
index c5c9851272f2c..838c84cece6de 100644
--- a/include/lldb/API/SBDefines.h
+++ b/include/lldb/API/SBDefines.h
@@ -1,9 +1,8 @@
//===-- SBDefines.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,10 +16,6 @@
#include "lldb/lldb-types.h"
#include "lldb/lldb-versioning.h"
-#ifdef SWIG
-#define LLDB_API
-#endif
-
// Forward Declarations
namespace lldb {
@@ -51,7 +46,6 @@ class LLDB_API SBFileSpecList;
class LLDB_API SBFrame;
class LLDB_API SBFunction;
class LLDB_API SBHostOS;
-class LLDB_API SBInitializerOptions;
class LLDB_API SBInstruction;
class LLDB_API SBInstructionList;
class LLDB_API SBLanguageRuntime;
diff --git a/include/lldb/API/SBError.h b/include/lldb/API/SBError.h
index a27d2d0426907..b076f87b7669a 100644
--- a/include/lldb/API/SBError.h
+++ b/include/lldb/API/SBError.h
@@ -1,9 +1,8 @@
//===-- SBError.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,27 +46,30 @@ public:
int SetErrorStringWithFormat(const char *format, ...)
__attribute__((format(printf, 2, 3)));
+ explicit operator bool() const;
+
bool IsValid() const;
bool GetDescription(lldb::SBStream &description);
protected:
+ friend class SBBreakpoint;
+ friend class SBBreakpointLocation;
+ friend class SBBreakpointName;
friend class SBCommandReturnObject;
+ friend class SBCommunication;
friend class SBData;
friend class SBDebugger;
- friend class SBCommunication;
friend class SBHostOS;
friend class SBPlatform;
friend class SBProcess;
+ friend class SBReproducer;
friend class SBStructuredData;
+ friend class SBTarget;
friend class SBThread;
friend class SBTrace;
- friend class SBTarget;
friend class SBValue;
friend class SBWatchpoint;
- friend class SBBreakpoint;
- friend class SBBreakpointLocation;
- friend class SBBreakpointName;
lldb_private::Status *get();
@@ -80,7 +82,7 @@ protected:
void SetError(const lldb_private::Status &lldb_error);
private:
- std::unique_ptr<lldb_private::Status> m_opaque_ap;
+ std::unique_ptr<lldb_private::Status> m_opaque_up;
void CreateIfNeeded();
};
diff --git a/include/lldb/API/SBEvent.h b/include/lldb/API/SBEvent.h
index ff15716d853ed..d297cbeff671f 100644
--- a/include/lldb/API/SBEvent.h
+++ b/include/lldb/API/SBEvent.h
@@ -1,9 +1,8 @@
//===-- SBEvent.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,6 +35,8 @@ public:
const SBEvent &operator=(const lldb::SBEvent &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetDataFlavor();
diff --git a/include/lldb/API/SBExecutionContext.h b/include/lldb/API/SBExecutionContext.h
index c19d539bc80a9..45c0b1b7f97b6 100644
--- a/include/lldb/API/SBExecutionContext.h
+++ b/include/lldb/API/SBExecutionContext.h
@@ -1,10 +1,9 @@
//===-- SBExecutionContext.h -----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,8 +50,6 @@ public:
SBFrame GetFrame() const;
protected:
- ExecutionContextRefSP &GetSP() const;
-
void reset(lldb::ExecutionContextRefSP &event_sp);
lldb_private::ExecutionContextRef *get() const;
diff --git a/include/lldb/API/SBExpressionOptions.h b/include/lldb/API/SBExpressionOptions.h
index b861436caf988..04cd74f730f21 100644
--- a/include/lldb/API/SBExpressionOptions.h
+++ b/include/lldb/API/SBExpressionOptions.h
@@ -1,9 +1,8 @@
-//===-- SBEvent.h -----------------------------------------------*- C++ -*-===//
+//===-- SBExpressionOptions.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -90,17 +89,14 @@ public:
bool GetTopLevel();
void SetTopLevel(bool b = true);
-
+
// Gets whether we will JIT an expression if it cannot be interpreted
bool GetAllowJIT();
-
+
// Sets whether we will JIT an expression if it cannot be interpreted
void SetAllowJIT(bool allow);
protected:
- SBExpressionOptions(
- lldb_private::EvaluateExpressionOptions &expression_options);
-
lldb_private::EvaluateExpressionOptions *get() const;
lldb_private::EvaluateExpressionOptions &ref() const;
@@ -111,7 +107,7 @@ protected:
private:
// This auto_pointer is made in the constructor and is always valid.
- mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_ap;
+ mutable std::unique_ptr<lldb_private::EvaluateExpressionOptions> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBFileSpec.h b/include/lldb/API/SBFileSpec.h
index 9ad1a5df0cfa6..27149775901e8 100644
--- a/include/lldb/API/SBFileSpec.h
+++ b/include/lldb/API/SBFileSpec.h
@@ -1,9 +1,8 @@
//===-- SBFileSpec.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,6 +28,12 @@ public:
const SBFileSpec &operator=(const lldb::SBFileSpec &rhs);
+ explicit operator bool() const;
+
+ bool operator==(const SBFileSpec &rhs) const;
+
+ bool operator!=(const SBFileSpec &rhs) const;
+
bool IsValid() const;
bool Exists() const;
@@ -59,7 +64,6 @@ private:
friend class SBDeclaration;
friend class SBFileSpecList;
friend class SBHostOS;
- friend class SBInitializerOptions;
friend class SBLaunchInfo;
friend class SBLineEntry;
friend class SBModule;
@@ -83,7 +87,7 @@ private:
const lldb_private::FileSpec &ref() const;
- std::unique_ptr<lldb_private::FileSpec> m_opaque_ap;
+ std::unique_ptr<lldb_private::FileSpec> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBFileSpecList.h b/include/lldb/API/SBFileSpecList.h
index 97f843adbb5ff..5a131509d2699 100644
--- a/include/lldb/API/SBFileSpecList.h
+++ b/include/lldb/API/SBFileSpecList.h
@@ -1,10 +1,9 @@
//===-- SBFileSpecList.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,7 +49,7 @@ private:
const lldb_private::FileSpecList &ref() const;
- std::unique_ptr<lldb_private::FileSpecList> m_opaque_ap;
+ std::unique_ptr<lldb_private::FileSpecList> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBFrame.h b/include/lldb/API/SBFrame.h
index 1123dade5de26..b213f89855109 100644
--- a/include/lldb/API/SBFrame.h
+++ b/include/lldb/API/SBFrame.h
@@ -1,9 +1,8 @@
//===-- SBFrame.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,6 +26,8 @@ public:
bool IsEqual(const lldb::SBFrame &that) const;
+ explicit operator bool() const;
+
bool IsValid() const;
uint32_t GetFrameID() const;
diff --git a/include/lldb/API/SBFunction.h b/include/lldb/API/SBFunction.h
index 23da02102cfb4..43f01d7e57dee 100644
--- a/include/lldb/API/SBFunction.h
+++ b/include/lldb/API/SBFunction.h
@@ -1,9 +1,8 @@
//===-- SBFunction.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,8 @@ public:
~SBFunction();
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName() const;
diff --git a/include/lldb/API/SBHostOS.h b/include/lldb/API/SBHostOS.h
index 1671917f865c1..ecd7920f2c14a 100644
--- a/include/lldb/API/SBHostOS.h
+++ b/include/lldb/API/SBHostOS.h
@@ -1,9 +1,8 @@
//===-- SBHostOS.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/API/SBInitializerOptions.h b/include/lldb/API/SBInitializerOptions.h
deleted file mode 100644
index 184c82df4f869..0000000000000
--- a/include/lldb/API/SBInitializerOptions.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- SBInitializerOptions.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_SBInitializerOptuions_h_
-#define LLDB_SBInitializerOptuions_h_
-
-#include "lldb/API/SBDefines.h"
-#include "lldb/API/SBFileSpec.h"
-
-namespace lldb_private {
-struct InitializerOptions;
-}
-
-namespace lldb {
-
-class LLDB_API SBInitializerOptions {
-public:
- SBInitializerOptions();
- SBInitializerOptions(const lldb::SBInitializerOptions &rhs);
- ~SBInitializerOptions();
- const SBInitializerOptions &operator=(const lldb::SBInitializerOptions &rhs);
-
- void SetCaptureReproducer(bool b);
- void SetReplayReproducer(bool b);
- void SetReproducerPath(const char *path);
-
- lldb_private::InitializerOptions &ref() const;
-
-private:
- friend class SBDebugger;
-
- std::unique_ptr<lldb_private::InitializerOptions> m_opaque_up;
-};
-
-} // namespace lldb
-
-#endif // LLDB_SBInitializerOptuions_h_
diff --git a/include/lldb/API/SBInstruction.h b/include/lldb/API/SBInstruction.h
index 5ef02b8f696ad..0bb5877956074 100644
--- a/include/lldb/API/SBInstruction.h
+++ b/include/lldb/API/SBInstruction.h
@@ -1,9 +1,8 @@
//===-- SBInstruction.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,6 +31,8 @@ public:
~SBInstruction();
+ explicit operator bool() const;
+
bool IsValid();
SBAddress GetAddress();
diff --git a/include/lldb/API/SBInstructionList.h b/include/lldb/API/SBInstructionList.h
index c8fed5c83192b..4434d50f471f4 100644
--- a/include/lldb/API/SBInstructionList.h
+++ b/include/lldb/API/SBInstructionList.h
@@ -1,9 +1,8 @@
//===-- SBInstructionList.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,17 +25,17 @@ public:
~SBInstructionList();
+ explicit operator bool() const;
+
bool IsValid() const;
size_t GetSize();
lldb::SBInstruction GetInstructionAtIndex(uint32_t idx);
- // ----------------------------------------------------------------------
// Returns the number of instructions between the start and end address. If
// canSetBreakpoint is true then the count will be the number of
// instructions on which a breakpoint can be set.
- // ----------------------------------------------------------------------
size_t GetInstructionsCount(const SBAddress &start,
const SBAddress &end,
bool canSetBreakpoint = false);
diff --git a/include/lldb/API/SBLanguageRuntime.h b/include/lldb/API/SBLanguageRuntime.h
index 3912f352491bf..d28c441593eae 100644
--- a/include/lldb/API/SBLanguageRuntime.h
+++ b/include/lldb/API/SBLanguageRuntime.h
@@ -1,9 +1,8 @@
//===-- SBLanguageRuntime.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/API/SBLaunchInfo.h b/include/lldb/API/SBLaunchInfo.h
index 80eea7e429212..c7b381ffdf972 100644
--- a/include/lldb/API/SBLaunchInfo.h
+++ b/include/lldb/API/SBLaunchInfo.h
@@ -1,9 +1,8 @@
//===-- SBLaunchInfo.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,7 +42,6 @@ public:
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.
///
@@ -58,33 +56,28 @@ public:
/// SBTarget::Launch(...), the target will use the resolved executable
/// path that was used to create the target.
///
- /// @param[in] exe_file
+ /// \param[in] exe_file
/// The override path to use when launching the executable.
///
- /// @param[in] add_as_first_arg
+ /// \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();
diff --git a/include/lldb/API/SBLineEntry.h b/include/lldb/API/SBLineEntry.h
index 3d58ea8278ea0..855c28d14b83a 100644
--- a/include/lldb/API/SBLineEntry.h
+++ b/include/lldb/API/SBLineEntry.h
@@ -1,9 +1,8 @@
//===-- SBLineEntry.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,6 +29,8 @@ public:
lldb::SBAddress GetEndAddress() const;
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBFileSpec GetFileSpec() const;
@@ -69,7 +70,7 @@ private:
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_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBListener.h b/include/lldb/API/SBListener.h
index a2f82a83c3edd..21aface97bd1c 100644
--- a/include/lldb/API/SBListener.h
+++ b/include/lldb/API/SBListener.h
@@ -1,9 +1,8 @@
//===-- SBListener.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,6 +29,8 @@ public:
void Clear();
+ explicit operator bool() const;
+
bool IsValid() const;
uint32_t StartListeningForEventClass(SBDebugger &debugger,
diff --git a/include/lldb/API/SBMemoryRegionInfo.h b/include/lldb/API/SBMemoryRegionInfo.h
index 5675d93b8eaf6..2a9ae94218f2e 100644
--- a/include/lldb/API/SBMemoryRegionInfo.h
+++ b/include/lldb/API/SBMemoryRegionInfo.h
@@ -1,9 +1,8 @@
//===-- SBMemoryRegionInfo.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,64 +27,50 @@ public:
void Clear();
- //------------------------------------------------------------------
/// Get the base address of this memory range.
///
- /// @return
+ /// \return
/// The base address of this memory range.
- //------------------------------------------------------------------
lldb::addr_t GetRegionBase();
- //------------------------------------------------------------------
/// Get the end address of this memory range.
///
- /// @return
+ /// \return
/// The base address of this memory range.
- //------------------------------------------------------------------
lldb::addr_t GetRegionEnd();
- //------------------------------------------------------------------
/// Check if this memory address is marked readable to the process.
///
- /// @return
+ /// \return
/// true if this memory address is marked readable
- //------------------------------------------------------------------
bool IsReadable();
- //------------------------------------------------------------------
/// Check if this memory address is marked writable to the process.
///
- /// @return
+ /// \return
/// true if this memory address is marked writable
- //------------------------------------------------------------------
bool IsWritable();
- //------------------------------------------------------------------
/// Check if this memory address is marked executable to the process.
///
- /// @return
+ /// \return
/// true if this memory address is marked executable
- //------------------------------------------------------------------
bool IsExecutable();
- //------------------------------------------------------------------
/// Check if this memory address is mapped into the process address
/// space.
///
- /// @return
+ /// \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
+ /// \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;
@@ -105,7 +90,7 @@ private:
// Unused.
SBMemoryRegionInfo(const lldb_private::MemoryRegionInfo *lldb_object_ptr);
- lldb::MemoryRegionInfoUP m_opaque_ap;
+ lldb::MemoryRegionInfoUP m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBMemoryRegionInfoList.h b/include/lldb/API/SBMemoryRegionInfoList.h
index 1e67997cdaf10..5592efef4851e 100644
--- a/include/lldb/API/SBMemoryRegionInfoList.h
+++ b/include/lldb/API/SBMemoryRegionInfoList.h
@@ -1,9 +1,8 @@
//===-- SBMemoryRegionInfoList.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -48,7 +47,7 @@ private:
const lldb_private::MemoryRegionInfos &ref() const;
- std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_ap;
+ std::unique_ptr<MemoryRegionInfoListImpl> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBModule.h b/include/lldb/API/SBModule.h
index 7a10e9fc96b36..d2b6a18db84d3 100644
--- a/include/lldb/API/SBModule.h
+++ b/include/lldb/API/SBModule.h
@@ -1,9 +1,8 @@
//===-- SBModule.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,23 +31,22 @@ public:
~SBModule();
+ explicit operator bool() const;
+
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
+ /// \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
@@ -60,14 +58,12 @@ public:
/// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
/// The file could also be cached in a local developer kit directory.
///
- /// @return
+ /// \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
@@ -76,12 +72,10 @@ public:
/// the target will install this module on the remote platform prior
/// to launching.
///
- /// @return
+ /// \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
@@ -96,9 +90,8 @@ public:
/// or "./usr/lib", then the install path will be resolved using
/// the platform's current working directory as the base path.
///
- /// @param[in] file
+ /// \param[in] file
/// A file specification object.
- //------------------------------------------------------------------
bool SetRemoteInstallFileSpec(lldb::SBFileSpec &file);
lldb::ByteOrder GetByteOrder();
@@ -129,18 +122,16 @@ public:
lldb::SBCompileUnit GetCompileUnitAtIndex(uint32_t);
- //------------------------------------------------------------------
/// Find compile units related to *this module and passed source
/// file.
///
- /// @param[in] sb_file_spec
+ /// \param[in] sb_file_spec
/// A lldb::SBFileSpec object that contains source file
/// specification.
///
- /// @return
+ /// \return
/// A lldb::SBSymbolContextList that gets filled in with all of
/// the symbol contexts for all the matches.
- //------------------------------------------------------------------
lldb::SBSymbolContextList
FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
@@ -157,59 +148,53 @@ public:
size_t GetNumSections();
lldb::SBSection GetSectionAtIndex(size_t idx);
- //------------------------------------------------------------------
/// Find functions by name.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the function we are looking for.
///
- /// @param[in] name_type_mask
+ /// \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
+ /// \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
+ /// \param[in] target
/// A valid SBTarget instance representing the debuggee.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the global or static variable we are looking
/// for.
///
- /// @param[in] max_matches
+ /// \param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
- /// @return
+ /// \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
+ /// \param[in] target
/// A valid SBTarget instance representing the debuggee.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the global or static variable we are looking
/// for.
///
- /// @return
+ /// \return
/// An SBValue that gets filled in with the found variable (if any).
- //------------------------------------------------------------------
lldb::SBValue FindFirstGlobalVariable(lldb::SBTarget &target,
const char *name);
@@ -217,7 +202,6 @@ public:
lldb::SBTypeList FindTypes(const char *type);
- //------------------------------------------------------------------
/// Get a type using its type ID.
///
/// Each symbol file reader will assign different user IDs to their
@@ -226,34 +210,30 @@ public:
///
/// For DWARF debug info, the type ID is the DIE offset.
///
- /// @param[in] uid
+ /// \param[in] uid
/// The type user ID.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
@@ -267,7 +247,7 @@ public:
/// 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
+ /// \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
@@ -278,7 +258,7 @@ public:
/// will be filled with \a num_versions UINT32_MAX values
/// and zero will be returned.
///
- /// @param[in] num_versions
+ /// \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
@@ -288,14 +268,12 @@ public:
/// numbers in this object file, only \a num_versions will be
/// filled into \a versions (if \a versions is non-NULL).
///
- /// @return
+ /// \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
@@ -303,9 +281,8 @@ public:
/// like '/usr/lib/liba.dylib' then debug information can be located
/// in folder like '/usr/lib/liba.dylib.dSYM/'.
///
- /// @return
+ /// \return
/// A const reference to the file specification object.
- //------------------------------------------------------------------
lldb::SBFileSpec GetSymbolFileSpec() const;
lldb::SBAddress GetObjectFileHeaderAddress() const;
diff --git a/include/lldb/API/SBModuleSpec.h b/include/lldb/API/SBModuleSpec.h
index 1a862703a702f..29b3117a261d9 100644
--- a/include/lldb/API/SBModuleSpec.h
+++ b/include/lldb/API/SBModuleSpec.h
@@ -1,9 +1,8 @@
//===-- SBModuleSpec.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,25 +24,24 @@ public:
const SBModuleSpec &operator=(const SBModuleSpec &rhs);
+ explicit operator bool() const;
+
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
+ /// \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
@@ -55,9 +53,8 @@ public:
/// '/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib'
/// The file could also be cached in a local developer kit directory.
///
- /// @return
+ /// \return
/// A const reference to the file specification object.
- //------------------------------------------------------------------
lldb::SBFileSpec GetPlatformFileSpec();
void SetPlatformFileSpec(const lldb::SBFileSpec &fspec);
@@ -87,7 +84,7 @@ private:
friend class SBModule;
friend class SBTarget;
- std::unique_ptr<lldb_private::ModuleSpec> m_opaque_ap;
+ std::unique_ptr<lldb_private::ModuleSpec> m_opaque_up;
};
class SBModuleSpecList {
@@ -117,7 +114,7 @@ public:
bool GetDescription(lldb::SBStream &description);
private:
- std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_ap;
+ std::unique_ptr<lldb_private::ModuleSpecList> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBPlatform.h b/include/lldb/API/SBPlatform.h
index 952e310663190..7207b2e2a78d8 100644
--- a/include/lldb/API/SBPlatform.h
+++ b/include/lldb/API/SBPlatform.h
@@ -1,9 +1,8 @@
//===-- SBPlatform.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -92,6 +91,8 @@ public:
~SBPlatform();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
@@ -108,9 +109,7 @@ public:
bool IsConnected();
- //----------------------------------------------------------------------
// The following functions will work if the platform is connected
- //----------------------------------------------------------------------
const char *GetTriple();
const char *GetHostname();
diff --git a/include/lldb/API/SBProcess.h b/include/lldb/API/SBProcess.h
index 69cf8b4ce8544..863cb3ced6743 100644
--- a/include/lldb/API/SBProcess.h
+++ b/include/lldb/API/SBProcess.h
@@ -1,9 +1,8 @@
//===-- SBProcess.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,9 +22,7 @@ class SBEvent;
class LLDB_API SBProcess {
public:
- //------------------------------------------------------------------
/// Broadcaster event bits definitions.
- //------------------------------------------------------------------
FLAGS_ANONYMOUS_ENUM(){eBroadcastBitStateChanged = (1 << 0),
eBroadcastBitInterrupt = (1 << 1),
eBroadcastBitSTDOUT = (1 << 2),
@@ -52,6 +49,8 @@ public:
void Clear();
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBTarget GetTarget() const;
@@ -71,11 +70,9 @@ public:
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,
@@ -84,9 +81,7 @@ public:
uint32_t launch_flags, bool stop_at_entry,
lldb::SBError &error);
- //------------------------------------------------------------------
// Thread related functions
- //------------------------------------------------------------------
uint32_t GetNumThreads();
lldb::SBThread GetThreadAtIndex(size_t index);
@@ -97,12 +92,10 @@ public:
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);
@@ -111,16 +104,12 @@ public:
bool SetSelectedThreadByIndexID(uint32_t index_id);
- //------------------------------------------------------------------
// Queue related functions
- //------------------------------------------------------------------
uint32_t GetNumQueues();
lldb::SBQueue GetQueueAtIndex(size_t index);
- //------------------------------------------------------------------
// Stepping related functions
- //------------------------------------------------------------------
lldb::StateType GetState();
@@ -128,7 +117,6 @@ public:
const char *GetExitDescription();
- //------------------------------------------------------------------
/// Gets the process ID
///
/// Returns the process identifier for the process as it is known
@@ -136,15 +124,13 @@ public:
/// this is typically the same as if you called "getpid()" in the
/// process.
///
- /// @return
+ /// \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
@@ -152,11 +138,10 @@ public:
/// create a process with the same process ID, there needs to be a
/// way to tell two process instances apart.
///
- /// @return
+ /// \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;
@@ -181,18 +166,16 @@ public:
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
+ /// \param [in] stop_id
/// The ID of the stop event to return.
///
- /// @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);
@@ -235,10 +218,9 @@ public:
bool GetDescription(lldb::SBStream &description);
- //------------------------------------------------------------------
/// Start Tracing with the given SBTraceOptions.
///
- /// @param[in] options
+ /// \param[in] options
/// Class containing trace options like trace buffer size, meta
/// data buffer size, TraceType and any custom parameters
/// {formatted as a JSON Dictionary}. In case of errors in
@@ -253,95 +235,88 @@ public:
/// parameters, only the parameters recognized by the target
/// would be used and others would be ignored.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong.
///
- /// @return
+ /// \return
/// A SBTrace instance, which should be used
/// to get the trace data or other trace related operations.
- //------------------------------------------------------------------
lldb::SBTrace StartTrace(SBTraceOptions &options, lldb::SBError &error);
uint32_t GetNumSupportedHardwareWatchpoints(lldb::SBError &error) const;
- //------------------------------------------------------------------
/// Load a shared library into this process.
///
- /// @param[in] remote_image_spec
+ /// \param[in] remote_image_spec
/// The path for the shared library on the target what you want
/// to load.
///
- /// @param[out] error
+ /// \param[out] error
/// An error object that gets filled in with any errors that
/// might occur when trying to load the shared library.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \param[out] error
/// An error object that gets filled in with any errors that
/// might occur when trying to load the shared library.
///
- /// @return
+ /// \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);
- //------------------------------------------------------------------
/// Load a shared library into this process, starting with a
/// library name and a list of paths, searching along the list of
/// paths till you find a matching library.
///
- /// @param[in] image_spec
+ /// \param[in] image_spec
/// The name of the shared library that you want to load.
/// If image_spec is a relative path, the relative path will be
/// appended to the search paths.
/// If the image_spec is an absolute path, just the basename is used.
///
- /// @param[in] paths
+ /// \param[in] paths
/// A list of paths to search for the library whose basename is
/// local_spec.
///
- /// @param[out] loaded_path
+ /// \param[out] loaded_path
/// If the library was found along the paths, this will store the
/// full path to the found library.
///
- /// @param[out] error
+ /// \param[out] error
/// An error object that gets filled in with any errors that
/// might occur when trying to search for the shared library.
///
- /// @return
+ /// \return
/// A token that represents the shared library that can be
/// later passed to UnloadImage. A value of
/// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
/// library can't be opened.
- //------------------------------------------------------------------
uint32_t LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
SBStringList &paths,
lldb::SBFileSpec &loaded_path,
@@ -351,7 +326,6 @@ public:
lldb::SBError SendEventData(const char *data);
- //------------------------------------------------------------------
/// Return the number of different thread-origin extended backtraces
/// this process can support.
///
@@ -360,25 +334,22 @@ public:
/// or the work item was enqueued to it (in the case of a libdispatch
/// queue).
///
- /// @return
+ /// \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
+ /// \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
+ /// \return
/// The name at that index.
- //------------------------------------------------------------------
const char *GetExtendedBacktraceTypeAtIndex(uint32_t idx);
lldb::SBThreadCollection GetHistoryThreads(addr_t addr);
@@ -388,40 +359,34 @@ public:
/// 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
+ /// \param[in] load_addr
/// The address to be queried.
///
- /// @param[out] region_info
+ /// \param[out] region_info
/// A reference to an SBMemoryRegionInfo object that will contain
/// the details of the memory region containing load_addr.
///
- /// @return
+ /// \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
+ /// \return
/// A list of all witin the process memory regions.
- //------------------------------------------------------------------
lldb::SBMemoryRegionInfoList GetMemoryRegions();
- //------------------------------------------------------------------
/// Return information about the process.
///
/// Valid process info will only be returned when the process is
/// alive, use SBProcessInfo::IsValid() to check returned info is
/// valid.
- //------------------------------------------------------------------
lldb::SBProcessInfo GetProcessInfo();
protected:
diff --git a/include/lldb/API/SBProcessInfo.h b/include/lldb/API/SBProcessInfo.h
index 421227f82c2d9..86dba9a8e116b 100644
--- a/include/lldb/API/SBProcessInfo.h
+++ b/include/lldb/API/SBProcessInfo.h
@@ -1,9 +1,8 @@
//===-- SBProcessInfo.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,6 +22,8 @@ public:
SBProcessInfo &operator=(const SBProcessInfo &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName();
@@ -56,7 +57,7 @@ private:
void SetProcessInfo(const lldb_private::ProcessInstanceInfo &proc_info_ref);
- std::unique_ptr<lldb_private::ProcessInstanceInfo> m_opaque_ap;
+ std::unique_ptr<lldb_private::ProcessInstanceInfo> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBQueue.h b/include/lldb/API/SBQueue.h
index 53612c0a125f0..0124c1c90dd27 100644
--- a/include/lldb/API/SBQueue.h
+++ b/include/lldb/API/SBQueue.h
@@ -1,9 +1,8 @@
//===-- SBQueue.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,6 +28,8 @@ public:
~SBQueue();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
@@ -59,10 +60,6 @@ protected:
void SetQueue(const lldb::QueueSP &queue_sp);
- void FetchThreads();
-
- void FetchItems();
-
private:
std::shared_ptr<lldb_private::QueueImpl> m_opaque_sp;
};
diff --git a/include/lldb/API/SBQueueItem.h b/include/lldb/API/SBQueueItem.h
index 78ca3ba02db1b..455a1f98379a8 100644
--- a/include/lldb/API/SBQueueItem.h
+++ b/include/lldb/API/SBQueueItem.h
@@ -1,9 +1,8 @@
//===-- SBQueueItem.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,6 +22,8 @@ public:
~SBQueueItem();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
diff --git a/include/lldb/API/SBReproducer.h b/include/lldb/API/SBReproducer.h
new file mode 100644
index 0000000000000..0f1739d0c5bda
--- /dev/null
+++ b/include/lldb/API/SBReproducer.h
@@ -0,0 +1,28 @@
+//===-- SBReproducer.h ------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBREPRODUCER_H
+#define LLDB_API_SBREPRODUCER_H
+
+#include "lldb/API/SBDefines.h"
+
+namespace lldb {
+
+/// The SBReproducer class is special because it bootstraps the capture and
+/// replay of SB API calls. As a result we cannot rely on any other SB objects
+/// in the interface or implementation of this class.
+class LLDB_API SBReproducer {
+public:
+ static const char *Capture();
+ static const char *Capture(const char *path);
+ static const char *Replay(const char *path);
+};
+
+} // namespace lldb
+
+#endif
diff --git a/include/lldb/API/SBSection.h b/include/lldb/API/SBSection.h
index ffd8bf7c979bd..06a195ee78df0 100644
--- a/include/lldb/API/SBSection.h
+++ b/include/lldb/API/SBSection.h
@@ -1,9 +1,8 @@
//===-- SBSection.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,6 +24,8 @@ public:
const lldb::SBSection &operator=(const lldb::SBSection &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName();
@@ -53,7 +54,6 @@ public:
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.
@@ -62,21 +62,18 @@ public:
/// i.e. for a section having read and execute permissions, the value
/// returned is 6
///
- /// @return
+ /// \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
+ /// \return
/// The number of host (8-bit) bytes needed to hold a target byte
- //------------------------------------------------------------------
uint32_t GetTargetByteSize();
bool operator==(const lldb::SBSection &rhs);
diff --git a/include/lldb/API/SBSourceManager.h b/include/lldb/API/SBSourceManager.h
index 6f1c49504d52f..3d69aa25a9342 100644
--- a/include/lldb/API/SBSourceManager.h
+++ b/include/lldb/API/SBSourceManager.h
@@ -1,9 +1,8 @@
//===-- SBSourceManager.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,10 +38,8 @@ protected:
friend class SBCommandInterpreter;
friend class SBDebugger;
- SBSourceManager(lldb_private::SourceManager *source_manager);
-
private:
- std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::SourceManagerImpl> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h
index 7364ca7797f89..8afbf4575621a 100644
--- a/include/lldb/API/SBStream.h
+++ b/include/lldb/API/SBStream.h
@@ -1,9 +1,8 @@
//===-- SBStream.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@ public:
~SBStream();
+ explicit operator bool() const;
+
bool IsValid() const;
// If this stream is not redirected to a file, it will maintain a local cache
@@ -95,7 +96,7 @@ protected:
private:
DISALLOW_COPY_AND_ASSIGN(SBStream);
- std::unique_ptr<lldb_private::Stream> m_opaque_ap;
+ std::unique_ptr<lldb_private::Stream> m_opaque_up;
bool m_is_file;
};
diff --git a/include/lldb/API/SBStringList.h b/include/lldb/API/SBStringList.h
index 943384e544cd1..1df1e45f96fea 100644
--- a/include/lldb/API/SBStringList.h
+++ b/include/lldb/API/SBStringList.h
@@ -1,9 +1,8 @@
//===-- SBStringList.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@ public:
~SBStringList();
+ explicit operator bool() const;
+
bool IsValid() const;
void AppendString(const char *str);
@@ -56,7 +57,7 @@ protected:
const lldb_private::StringList &operator*() const;
private:
- std::unique_ptr<lldb_private::StringList> m_opaque_ap;
+ std::unique_ptr<lldb_private::StringList> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBStructuredData.h b/include/lldb/API/SBStructuredData.h
index 629d4f3e35ee3..5b10133500ef1 100644
--- a/include/lldb/API/SBStructuredData.h
+++ b/include/lldb/API/SBStructuredData.h
@@ -1,9 +1,8 @@
//===-- SBStructuredData.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,6 +28,8 @@ public:
lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::SBError SetFromJSON(lldb::SBStream &stream);
@@ -39,69 +40,51 @@ public:
lldb::SBError GetDescription(lldb::SBStream &stream) const;
- //------------------------------------------------------------------
/// Return the type of data in this data structure
- //------------------------------------------------------------------
lldb::StructuredDataType GetType() const;
- //------------------------------------------------------------------
/// Return the size (i.e. number of elements) in this data structure
/// if it is an array or dictionary type. For other types, 0 will be
// returned.
- //------------------------------------------------------------------
size_t GetSize() const;
- //------------------------------------------------------------------
/// Fill keys with the keys in this object and return true if this data
/// structure is a dictionary. Returns false otherwise.
- //------------------------------------------------------------------
bool GetKeys(lldb::SBStringList &keys) const;
- //------------------------------------------------------------------
/// Return the value corresponding to a key if this data structure
/// is a dictionary type.
- //------------------------------------------------------------------
lldb::SBStructuredData GetValueForKey(const char *key) const;
- //------------------------------------------------------------------
/// Return the value corresponding to an index if this data structure
/// is array.
- //------------------------------------------------------------------
lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
- //------------------------------------------------------------------
/// Return the integer value if this data structure is an integer type.
- //------------------------------------------------------------------
uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
- //------------------------------------------------------------------
/// Return the floating point value if this data structure is a floating
/// type.
- //------------------------------------------------------------------
double GetFloatValue(double fail_value = 0.0) const;
- //------------------------------------------------------------------
/// Return the boolean value if this data structure is a boolean type.
- //------------------------------------------------------------------
bool GetBooleanValue(bool fail_value = false) const;
- //------------------------------------------------------------------
/// Provides the string value if this data structure is a string type.
///
- /// @param[out] dst
+ /// \param[out] dst
/// pointer where the string value will be written. In case it is null,
- /// nothing will be written at @dst.
+ /// nothing will be written at \a dst.
///
- /// @param[in] dst_len
- /// max number of characters that can be written at @dst. In case it is
- /// zero, nothing will be written at @dst. If this length is not enough
- /// to write the complete string value, (dst_len-1) bytes of the string
- /// value will be written at @dst followed by a null character.
+ /// \param[in] dst_len
+ /// max number of characters that can be written at \a dst. In case it is
+ /// zero, nothing will be written at \a dst. If this length is not enough
+ /// to write the complete string value, (\a dst_len - 1) bytes of the
+ /// string value will be written at \a dst followed by a null character.
///
- /// @return
+ /// \return
/// Returns the byte size needed to completely write the string value at
- /// @dst in all cases.
- //------------------------------------------------------------------
+ /// \a dst in all cases.
size_t GetStringValue(char *dst, size_t dst_len) const;
protected:
diff --git a/include/lldb/API/SBSymbol.h b/include/lldb/API/SBSymbol.h
index a29ac61d2912b..52486b83d1a74 100644
--- a/include/lldb/API/SBSymbol.h
+++ b/include/lldb/API/SBSymbol.h
@@ -1,9 +1,8 @@
//===-- SBSymbol.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,6 +26,8 @@ public:
const lldb::SBSymbol &operator=(const lldb::SBSymbol &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName() const;
@@ -54,16 +55,12 @@ public:
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 was synthetically generated from something
// other than the actual symbol table itself in the object file.
- //----------------------------------------------------------------------
bool IsSynthetic();
protected:
diff --git a/include/lldb/API/SBSymbolContext.h b/include/lldb/API/SBSymbolContext.h
index 9078b5b789e08..3d16d0989ca11 100644
--- a/include/lldb/API/SBSymbolContext.h
+++ b/include/lldb/API/SBSymbolContext.h
@@ -1,9 +1,8 @@
//===-- SBSymbolContext.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,6 +29,8 @@ public:
~SBSymbolContext();
+ explicit operator bool() const;
+
bool IsValid() const;
const lldb::SBSymbolContext &operator=(const lldb::SBSymbolContext &rhs);
@@ -74,7 +75,7 @@ protected:
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_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBSymbolContextList.h b/include/lldb/API/SBSymbolContextList.h
index e7299dd5330c9..577993ce96ddb 100644
--- a/include/lldb/API/SBSymbolContextList.h
+++ b/include/lldb/API/SBSymbolContextList.h
@@ -1,9 +1,8 @@
//===-- SBSymbolContextList.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,8 @@ public:
const lldb::SBSymbolContextList &
operator=(const lldb::SBSymbolContextList &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
uint32_t GetSize() const;
@@ -49,7 +50,7 @@ protected:
lldb_private::SymbolContextList &operator*() const;
private:
- std::unique_ptr<lldb_private::SymbolContextList> m_opaque_ap;
+ std::unique_ptr<lldb_private::SymbolContextList> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBTarget.h b/include/lldb/API/SBTarget.h
index 18de267fee00a..80a7fa00dbc51 100644
--- a/include/lldb/API/SBTarget.h
+++ b/include/lldb/API/SBTarget.h
@@ -1,9 +1,8 @@
//===-- SBTarget.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,9 +28,7 @@ class SBPlatform;
class LLDB_API SBTarget {
public:
- //------------------------------------------------------------------
// Broadcaster bits.
- //------------------------------------------------------------------
enum {
eBroadcastBitBreakpointChanged = (1 << 0),
eBroadcastBitModulesLoaded = (1 << 1),
@@ -40,22 +37,20 @@ public:
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);
+ explicit operator bool() const;
+
bool IsValid() const;
static bool EventIsTargetEvent(const lldb::SBEvent &event);
@@ -71,45 +66,34 @@ public:
lldb::SBProcess GetProcess();
- //------------------------------------------------------------------
/// Sets whether we should collect statistics on lldb or not.
///
- /// @param[in] v
+ /// \param[in] v
/// A boolean to control the collection.
- /// @return
- /// void
- //------------------------------------------------------------------
void SetCollectingStats(bool v);
- //------------------------------------------------------------------
/// Returns whether statistics collection are enabled.
///
- /// @return
+ /// \return
/// true if statistics are currently being collected, false
/// otherwise.
- //------------------------------------------------------------------
bool GetCollectingStats();
- //------------------------------------------------------------------
/// Returns a dump of the collected statistics.
///
- /// @return
+ /// \return
/// A SBStructuredData with the statistics collected.
- //------------------------------------------------------------------
lldb::SBStructuredData GetStatistics();
- //------------------------------------------------------------------
/// Return the platform object associated with the target.
///
/// After return, the platform object should be checked for
/// validity.
///
- /// @return
+ /// \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.
@@ -119,13 +103,11 @@ public:
/// have an install location set, it will be installed in the remote
/// platform's working directory.
///
- /// @return
+ /// \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
@@ -135,49 +117,48 @@ public:
/// optionally re-directed to \a stdin_path, \a stdout_path, and
/// \a stderr_path.
///
- /// @param[in] listener
+ /// \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
+ /// \param[in] argv
/// The argument array.
///
- /// @param[in] envp
+ /// \param[in] envp
/// The environment array.
///
- /// @param[in] stdin_path
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] working_directory
/// The working directory to have the child process run in
///
- /// @param[in] launch_flags
+ /// \param[in] launch_flags
/// Some launch options specified by logical OR'ing
/// lldb::LaunchFlags enumeration values together.
///
- /// @param[in] stop_at_entry
+ /// \param[in] stop_at_entry
/// If false do not stop the inferior at the entry point.
///
- /// @param[out] error
+ /// \param[out] error
/// An error object. Contains the reason if there is some failure.
///
- /// @return
+ /// \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,
@@ -188,16 +169,15 @@ public:
SBProcess LoadCore(const char *core_file);
SBProcess LoadCore(const char *core_file, lldb::SBError &error);
- //------------------------------------------------------------------
/// Launch a new process with sensible defaults.
///
- /// @param[in] argv
+ /// \param[in] argv
/// The argument array.
///
- /// @param[in] envp
+ /// \param[in] envp
/// The environment array.
///
- /// @param[in] working_directory
+ /// \param[in] working_directory
/// The working directory to have the child process run in
///
/// Default: listener
@@ -211,9 +191,8 @@ public:
/// Default: stderr_path
/// A pseudo terminal will be used.
///
- /// @return
+ /// \return
/// A process object for the newly created process.
- //------------------------------------------------------------------
SBProcess LaunchSimple(const char **argv, const char **envp,
const char *working_directory);
@@ -221,73 +200,67 @@ public:
SBProcess Attach(SBAttachInfo &attach_info, SBError &error);
- //------------------------------------------------------------------
/// Attach to process with pid.
///
- /// @param[in] listener
+ /// \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
+ /// \param[in] pid
/// The process ID to attach to.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong if attach fails.
///
- /// @return
+ /// \return
/// A process object for the attached process.
- //------------------------------------------------------------------
lldb::SBProcess AttachToProcessWithID(SBListener &listener, lldb::pid_t pid,
lldb::SBError &error);
- //------------------------------------------------------------------
/// Attach to process with name.
///
- /// @param[in] listener
+ /// \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
+ /// \param[in] name
/// Basename of process to attach to.
///
- /// @param[in] wait_for
+ /// \param[in] wait_for
/// If true wait for a new instance of 'name' to be launched.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong if attach fails.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] url
/// The url to connect to, e.g., 'connect://localhost:12345'.
///
- /// @param[in] plugin_name
+ /// \param[in] plugin_name
/// The plugin name to be used; can be nullptr.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong if the connect fails.
///
- /// @return
+ /// \return
/// A process object for the connected process.
- //------------------------------------------------------------------
lldb::SBProcess ConnectRemote(SBListener &listener, const char *url,
const char *plugin_name, SBError &error);
@@ -317,18 +290,16 @@ public:
lldb::SBModule FindModule(const lldb::SBFileSpec &file_spec);
- //------------------------------------------------------------------
/// Find compile units related to *this target and passed source
/// file.
///
- /// @param[in] sb_file_spec
+ /// \param[in] sb_file_spec
/// A lldb::SBFileSpec object that contains source file
/// specification.
///
- /// @return
+ /// \return
/// A lldb::SBSymbolContextList that gets filled in with all of
/// the symbol contexts for all the matches.
- //------------------------------------------------------------------
lldb::SBSymbolContextList
FindCompileUnits(const lldb::SBFileSpec &sb_file_spec);
@@ -338,55 +309,46 @@ public:
const char *GetTriple();
- //------------------------------------------------------------------
/// Architecture data byte width accessor
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] section
/// The section whose base load address will be set within this
/// target.
///
- /// @param[in] section_base_addr
+ /// \param[in] section_base_addr
/// The base address for the section.
///
- /// @return
+ /// \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
+ /// \param[in] section
/// The section whose base load address will be cleared within
/// this target.
///
- /// @return
+ /// \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.
///
@@ -395,150 +357,132 @@ public:
/// this function will allow you to easily and quickly slide all
/// module sections.
///
- /// @param[in] module
+ /// \param[in] module
/// The module to load.
///
- /// @param[in] sections_offset
+ /// \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
+ /// \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
+ /// \param[in] module
/// The module to unload.
///
- /// @return
+ /// \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
+ /// \param[in] name
/// The name of the function we are looking for.
///
- /// @param[in] name_type_mask
+ /// \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
+ /// \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
+ /// \param[in] name
/// The name of the global or static variable we are looking
/// for.
///
- /// @param[in] max_matches
+ /// \param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
- /// @return
+ /// \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
+ /// \param[in] name
/// The name of the global or static variable we are looking
/// for.
///
- /// @return
+ /// \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
+ /// \param[in] name
/// The pattern to search for global or static variables
///
- /// @param[in] max_matches
+ /// \param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
- /// @param[in] matchtype
+ /// \param[in] matchtype
/// The match type to use.
///
- /// @return
+ /// \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
+ /// \param[in] name
/// The pattern to search for global or static variables
///
- /// @param[in] max_matches
+ /// \param[in] max_matches
/// Allow the number of matches to be limited to \a max_matches.
///
- /// @param[in] matchtype
+ /// \param[in] matchtype
/// The match type to use.
///
- /// @return
+ /// \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
+ /// \param[in] file_addr
/// The file address to resolve.
///
- /// @return
+ /// \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
+ /// \param[in] vm_addr
/// A virtual address from the current process state that is to
/// be translated into a section offset address.
///
- /// @return
+ /// \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
+ /// \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
@@ -546,44 +490,41 @@ public:
/// UINT32_MAX will always resolve the address using the
/// currently loaded sections.
///
- /// @param[in] vm_addr
+ /// \param[in] vm_addr
/// A virtual address from the current process state that is to
/// be translated into a section offset address.
///
- /// @return
+ /// \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
+ /// \param[in] addr
/// A target address to read from.
///
- /// @param[out] buf
+ /// \param[out] buf
/// The buffer to read memory into.
///
- /// @param[in] size
+ /// \param[in] size
/// The maximum number of host bytes to read in the buffer passed
/// into this call
///
- /// @param[out] error
+ /// \param[out] error
/// Status information is written here if the memory read fails.
///
- /// @return
+ /// \return
/// The amount of data read in host bytes.
- //------------------------------------------------------------------
size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
lldb::SBError &error);
@@ -684,30 +625,28 @@ public:
lldb::SBBreakpoint BreakpointCreateBySBAddress(SBAddress &address);
- //------------------------------------------------------------------
/// Create a breakpoint using a scripted resolver.
///
- /// @param[in] class_name
+ /// \param[in] class_name
/// This is the name of the class that implements a scripted resolver.
///
- /// @param[in] extra_args
+ /// \param[in] extra_args
/// This is an SBStructuredData object that will get passed to the
/// constructor of the class in class_name. You can use this to
/// reuse the same class, parametrizing with entries from this
/// dictionary.
///
- /// @param module_list
+ /// \param module_list
/// If this is non-empty, this will be used as the module filter in the
/// SearchFilter created for this breakpoint.
///
- /// @param file_list
+ /// \param file_list
/// If this is non-empty, this will be used as the comp unit filter in the
/// SearchFilter created for this breakpoint.
///
- /// @return
+ /// \return
/// An SBBreakpoint that will set locations based on the logic in the
/// resolver's search callback.
- //------------------------------------------------------------------
lldb::SBBreakpoint BreakpointCreateFromScript(
const char *class_name,
SBStructuredData &extra_args,
@@ -715,71 +654,63 @@ public:
const SBFileSpecList &file_list,
bool request_hardware = false);
- //------------------------------------------------------------------
/// Read breakpoints from source_file and return the newly created
/// breakpoints in bkpt_list.
///
- /// @param[in] source_file
+ /// \param[in] source_file
/// The file from which to read the breakpoints.
///
- /// @param[out] new_bps
+ /// \param[out] new_bps
/// A list of the newly created breakpoints.
///
- /// @return
+ /// \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
+ /// \param[in] source_file
/// The file from which to read the breakpoints.
///
- /// @param[in] matching_names
+ /// \param[in] matching_names
/// Only read in breakpoints whose names match one of the names in this
/// list.
///
- /// @param[out] new_bps
+ /// \param[out] new_bps
/// A list of the newly created breakpoints.
///
- /// @return
+ /// \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
+ /// \param[in] dest_file
/// The file to which to write the breakpoints.
///
- /// @return
+ /// \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
+ /// \param[in] dest_file
/// The file to which to write the breakpoints.
///
- /// @param[in] bkpt_list
+ /// \param[in] bkpt_list
/// Only write breakpoints from this list.
///
- /// @param[in] append
- /// If \btrue, append the breakpoints in bkpt_list to the others
+ /// \param[in] append
+ /// If \b true, 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
+ /// \return
/// An SBError detailing any errors in writing in the breakpoints.
- //------------------------------------------------------------------
lldb::SBError BreakpointsWriteToFile(SBFileSpec &dest_file,
SBBreakpointList &bkpt_list,
bool append = false);
@@ -905,10 +836,8 @@ protected:
friend class SBValue;
friend class SBVariablesOptions;
- //------------------------------------------------------------------
// Constructors are private, use static Target::Create function to create an
// instance of this class.
- //------------------------------------------------------------------
lldb::TargetSP GetSP() const;
diff --git a/include/lldb/API/SBThread.h b/include/lldb/API/SBThread.h
index 63816eef51b7d..da8726a2a9b2d 100644
--- a/include/lldb/API/SBThread.h
+++ b/include/lldb/API/SBThread.h
@@ -1,9 +1,8 @@
//===-- SBThread.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,6 +39,8 @@ public:
lldb::SBQueue GetQueue() const;
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
@@ -50,7 +51,6 @@ public:
/// See also GetStopReasonDataAtIndex().
size_t GetStopReasonDataCount();
- //--------------------------------------------------------------------------
/// Get information associated with a stop reason.
///
/// Breakpoint stop reasons will have data that consists of pairs of
@@ -67,7 +67,6 @@ public:
/// eStopReasonException N exception data
/// eStopReasonExec 0
/// eStopReasonPlanComplete 0
- //--------------------------------------------------------------------------
uint64_t GetStopReasonDataAtIndex(uint32_t idx);
bool GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream);
@@ -133,7 +132,6 @@ public:
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
@@ -153,7 +151,6 @@ public:
/// 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 Suspend(SBError &error);
@@ -204,14 +201,7 @@ public:
bool SafeToCallFunctions();
-#ifndef SWIG
- lldb_private::Thread *operator->();
-
- lldb_private::Thread *get();
-
-#endif
-
-protected:
+private:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
friend class SBBreakpointCallbackBaton;
@@ -222,16 +212,18 @@ protected:
friend class SBValue;
friend class lldb_private::QueueImpl;
friend class SBQueueItem;
+ friend class SBThreadPlan;
void SetThread(const lldb::ThreadSP &lldb_object_sp);
-#ifndef SWIG
SBError ResumeNewPlan(lldb_private::ExecutionContext &exe_ctx,
lldb_private::ThreadPlan *new_plan);
-#endif
-private:
lldb::ExecutionContextRefSP m_opaque_sp;
+
+ lldb_private::Thread *operator->();
+
+ lldb_private::Thread *get();
};
} // namespace lldb
diff --git a/include/lldb/API/SBThreadCollection.h b/include/lldb/API/SBThreadCollection.h
index 715b0826b9620..1c6b4639c6ef0 100644
--- a/include/lldb/API/SBThreadCollection.h
+++ b/include/lldb/API/SBThreadCollection.h
@@ -1,9 +1,8 @@
//===-- SBThreadCollection.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@ public:
~SBThreadCollection();
+ explicit operator bool() const;
+
bool IsValid() const;
size_t GetSize();
diff --git a/include/lldb/API/SBThreadPlan.h b/include/lldb/API/SBThreadPlan.h
index 5084a427e1b8f..007e9e2de21a4 100644
--- a/include/lldb/API/SBThreadPlan.h
+++ b/include/lldb/API/SBThreadPlan.h
@@ -1,9 +1,8 @@
-//===-- SBThread.h ----------------------------------------------*- C++ -*-===//
+//===-- SBThreadPlan.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,6 +30,8 @@ public:
~SBThreadPlan();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
@@ -41,7 +42,6 @@ public:
/// See also GetStopReasonDataAtIndex().
size_t GetStopReasonDataCount();
- //--------------------------------------------------------------------------
/// Get information associated with a stop reason.
///
/// Breakpoint stop reasons will have data that consists of pairs of
@@ -58,7 +58,6 @@ public:
/// eStopReasonException N exception data
/// eStopReasonExec 0
/// eStopReasonPlanComplete 0
- //--------------------------------------------------------------------------
uint64_t GetStopReasonDataAtIndex(uint32_t idx);
SBThread GetThread() const;
@@ -102,11 +101,7 @@ public:
SBThreadPlan QueueThreadPlanForStepScripted(const char *script_class_name,
SBError &error);
-#ifndef SWIG
- lldb_private::ThreadPlan *get();
-#endif
-
-protected:
+private:
friend class SBBreakpoint;
friend class SBBreakpointLocation;
friend class SBFrame;
@@ -116,11 +111,9 @@ protected:
friend class lldb_private::QueueImpl;
friend class SBQueueItem;
-#ifndef SWIG
+ lldb_private::ThreadPlan *get();
void SetThreadPlan(const lldb::ThreadPlanSP &lldb_object_sp);
-#endif
-private:
lldb::ThreadPlanSP m_opaque_sp;
};
diff --git a/include/lldb/API/SBTrace.h b/include/lldb/API/SBTrace.h
index 244a01e5ce110..87c67adac75b6 100644
--- a/include/lldb/API/SBTrace.h
+++ b/include/lldb/API/SBTrace.h
@@ -1,9 +1,8 @@
//===-- SBTrace.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,25 +19,24 @@ namespace lldb {
class LLDB_API SBTrace {
public:
SBTrace();
- //------------------------------------------------------------------
/// Obtain the trace data as raw bytes.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong.
///
- /// @param[in] buf
+ /// \param[in] buf
/// Buffer to write the trace data to.
///
- /// @param[in] size
+ /// \param[in] size
/// The size of the buffer used to read the data. This is
/// also the size of the data intended to read. It is also
/// possible to partially read the trace data for some trace
/// technologies by specifying a smaller buffer.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The start offset to begin reading the trace data.
///
- /// @param[in] thread_id
+ /// \param[in] thread_id
/// Tracing could be started for the complete process or a
/// single thread, in the first case the traceid obtained would
/// map to all the threads existing within the process and the
@@ -46,28 +44,24 @@ public:
/// such a scenario to select the trace data for a specific
/// thread.
///
- /// @return
+ /// \return
/// The size of the trace data effectively read by the API call.
- //------------------------------------------------------------------
size_t GetTraceData(SBError &error, void *buf, size_t size, size_t offset = 0,
lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
- //------------------------------------------------------------------
/// Obtain any meta data as raw bytes for the tracing instance.
/// The input parameter definition is similar to the previous
/// function.
- //------------------------------------------------------------------
size_t GetMetaData(SBError &error, void *buf, size_t size, size_t offset = 0,
lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
- //------------------------------------------------------------------
/// Stop the tracing instance. Stopping the trace will also
/// lead to deletion of any gathered trace data.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong.
///
- /// @param[in] thread_id
+ /// \param[in] thread_id
/// The trace id could map to a tracing instance for a thread
/// or could also map to a group of threads being traced with
/// the same trace options. A thread_id is normally optional
@@ -81,26 +75,25 @@ public:
/// trace id of the process.
/// Now if the StopTrace API is called for the whole process,
/// thread A will not be stopped and must be stopped separately.
- //------------------------------------------------------------------
void StopTrace(SBError &error,
lldb::tid_t thread_id = LLDB_INVALID_THREAD_ID);
- //------------------------------------------------------------------
/// Get the trace configuration being used for the trace instance.
/// The threadid in the SBTraceOptions needs to be set when the
/// configuration used by a specific thread is being requested.
///
- /// @param[out] options
+ /// \param[out] options
/// The trace options actually used by the trace instance
/// would be filled by the API.
///
- /// @param[out] error
+ /// \param[out] error
/// An error explaining what went wrong.
- //------------------------------------------------------------------
void GetTraceConfig(SBTraceOptions &options, SBError &error);
lldb::user_id_t GetTraceUID();
+ explicit operator bool() const;
+
bool IsValid();
protected:
diff --git a/include/lldb/API/SBTraceOptions.h b/include/lldb/API/SBTraceOptions.h
index c9735e1ca2467..4c586bfd55c47 100644
--- a/include/lldb/API/SBTraceOptions.h
+++ b/include/lldb/API/SBTraceOptions.h
@@ -1,9 +1,8 @@
//===-- SBTraceOptions ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -45,6 +44,8 @@ public:
lldb::tid_t getThreadID();
+ explicit operator bool() const;
+
bool IsValid();
protected:
diff --git a/include/lldb/API/SBType.h b/include/lldb/API/SBType.h
index 0dde0257909fc..b3f92b7bcd042 100644
--- a/include/lldb/API/SBType.h
+++ b/include/lldb/API/SBType.h
@@ -1,9 +1,8 @@
//===-- SBType.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,8 @@ public:
lldb::SBTypeMember &operator=(const lldb::SBTypeMember &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName();
@@ -52,7 +53,7 @@ protected:
const lldb_private::TypeMemberImpl &ref() const;
- std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_up;
};
class SBTypeMemberFunction {
@@ -65,6 +66,8 @@ public:
lldb::SBTypeMemberFunction &operator=(const lldb::SBTypeMemberFunction &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName();
@@ -106,6 +109,8 @@ public:
~SBType();
+ explicit operator bool() const;
+
bool IsValid() const;
uint64_t GetByteSize();
@@ -236,6 +241,8 @@ public:
lldb::SBTypeList &operator=(const lldb::SBTypeList &rhs);
+ explicit operator bool() const;
+
bool IsValid();
void Append(lldb::SBType type);
@@ -245,7 +252,7 @@ public:
uint32_t GetSize();
private:
- std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::TypeListImpl> m_opaque_up;
friend class SBModule;
friend class SBCompileUnit;
};
diff --git a/include/lldb/API/SBTypeCategory.h b/include/lldb/API/SBTypeCategory.h
index f44dfc451e44d..c0f4cee1d268f 100644
--- a/include/lldb/API/SBTypeCategory.h
+++ b/include/lldb/API/SBTypeCategory.h
@@ -1,10 +1,9 @@
//===-- SBTypeCategory.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,6 +22,8 @@ public:
~SBTypeCategory();
+ explicit operator bool() const;
+
bool IsValid() const;
bool GetEnabled();
@@ -46,9 +47,7 @@ public:
uint32_t GetNumFilters();
-#ifndef LLDB_DISABLE_PYTHON
uint32_t GetNumSynthetics();
-#endif
SBTypeNameSpecifier GetTypeNameSpecifierForFilterAtIndex(uint32_t);
@@ -56,43 +55,29 @@ public:
SBTypeNameSpecifier GetTypeNameSpecifierForSummaryAtIndex(uint32_t);
-#ifndef LLDB_DISABLE_PYTHON
SBTypeNameSpecifier GetTypeNameSpecifierForSyntheticAtIndex(uint32_t);
-#endif
SBTypeFilter GetFilterForType(SBTypeNameSpecifier);
SBTypeFormat GetFormatForType(SBTypeNameSpecifier);
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSummary GetSummaryForType(SBTypeNameSpecifier);
-#endif
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
-#endif
-#ifndef LLDB_DISABLE_PYTHON
SBTypeFilter GetFilterAtIndex(uint32_t);
-#endif
SBTypeFormat GetFormatAtIndex(uint32_t);
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSummary GetSummaryAtIndex(uint32_t);
-#endif
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSynthetic GetSyntheticAtIndex(uint32_t);
-#endif
bool AddTypeFormat(SBTypeNameSpecifier, SBTypeFormat);
bool DeleteTypeFormat(SBTypeNameSpecifier);
-#ifndef LLDB_DISABLE_PYTHON
bool AddTypeSummary(SBTypeNameSpecifier, SBTypeSummary);
-#endif
bool DeleteTypeSummary(SBTypeNameSpecifier);
@@ -100,11 +85,9 @@ public:
bool DeleteTypeFilter(SBTypeNameSpecifier);
-#ifndef LLDB_DISABLE_PYTHON
bool AddTypeSynthetic(SBTypeNameSpecifier, SBTypeSynthetic);
bool DeleteTypeSynthetic(SBTypeNameSpecifier);
-#endif
lldb::SBTypeCategory &operator=(const lldb::SBTypeCategory &rhs);
diff --git a/include/lldb/API/SBTypeEnumMember.h b/include/lldb/API/SBTypeEnumMember.h
index f45c234d2c777..2410dbcc21255 100644
--- a/include/lldb/API/SBTypeEnumMember.h
+++ b/include/lldb/API/SBTypeEnumMember.h
@@ -1,10 +1,9 @@
//===-- SBTypeEnumMember.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,6 +24,8 @@ public:
SBTypeEnumMember &operator=(const SBTypeEnumMember &rhs);
+ explicit operator bool() const;
+
bool IsValid() const;
int64_t GetValueAsSigned();
@@ -63,6 +64,8 @@ public:
SBTypeEnumMemberList &operator=(const SBTypeEnumMemberList &rhs);
+ explicit operator bool() const;
+
bool IsValid();
void Append(SBTypeEnumMember entry);
@@ -72,7 +75,7 @@ public:
uint32_t GetSize();
private:
- std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_ap;
+ std::unique_ptr<lldb_private::TypeEnumMemberListImpl> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBTypeFilter.h b/include/lldb/API/SBTypeFilter.h
index 19888ba7cfb69..4a0de11d19c43 100644
--- a/include/lldb/API/SBTypeFilter.h
+++ b/include/lldb/API/SBTypeFilter.h
@@ -1,10 +1,9 @@
//===-- SBTypeFilter.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,6 +24,8 @@ public:
~SBTypeFilter();
+ explicit operator bool() const;
+
bool IsValid() const;
uint32_t GetNumberOfExpressionPaths();
diff --git a/include/lldb/API/SBTypeFormat.h b/include/lldb/API/SBTypeFormat.h
index d0429e97ff9c3..8a0ac77a1e9d0 100644
--- a/include/lldb/API/SBTypeFormat.h
+++ b/include/lldb/API/SBTypeFormat.h
@@ -1,10 +1,9 @@
//===-- SBTypeFormat.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,6 +28,8 @@ public:
~SBTypeFormat();
+ explicit operator bool() const;
+
bool IsValid() const;
lldb::Format GetFormat();
diff --git a/include/lldb/API/SBTypeNameSpecifier.h b/include/lldb/API/SBTypeNameSpecifier.h
index 2a4f09c2068b3..9fe449d029c6a 100644
--- a/include/lldb/API/SBTypeNameSpecifier.h
+++ b/include/lldb/API/SBTypeNameSpecifier.h
@@ -1,10 +1,9 @@
//===-- SBTypeNameSpecifier.h --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,6 +26,8 @@ public:
~SBTypeNameSpecifier();
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetName();
diff --git a/include/lldb/API/SBTypeSummary.h b/include/lldb/API/SBTypeSummary.h
index c9ccdff834ce9..bb7121f8ae40b 100644
--- a/include/lldb/API/SBTypeSummary.h
+++ b/include/lldb/API/SBTypeSummary.h
@@ -1,10 +1,9 @@
//===-- SBTypeSummary.h -------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@ public:
~SBTypeSummaryOptions();
+ explicit operator bool() const;
+
bool IsValid();
lldb::LanguageType GetLanguage();
@@ -50,7 +51,7 @@ protected:
void SetOptions(const lldb_private::TypeSummaryOptions *lldb_object_ptr);
private:
- std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_ap;
+ std::unique_ptr<lldb_private::TypeSummaryOptions> m_opaque_up;
};
class SBTypeSummary {
@@ -80,6 +81,8 @@ public:
~SBTypeSummary();
+ explicit operator bool() const;
+
bool IsValid() const;
bool IsFunctionCode();
diff --git a/include/lldb/API/SBTypeSynthetic.h b/include/lldb/API/SBTypeSynthetic.h
index 2099df3161949..c190643c1ebba 100644
--- a/include/lldb/API/SBTypeSynthetic.h
+++ b/include/lldb/API/SBTypeSynthetic.h
@@ -1,10 +1,9 @@
//===-- SBTypeSynthetic.h -----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,8 +12,6 @@
#include "lldb/API/SBDefines.h"
-#ifndef LLDB_DISABLE_PYTHON
-
namespace lldb {
class LLDB_API SBTypeSynthetic {
@@ -33,6 +30,8 @@ public:
~SBTypeSynthetic();
+ explicit operator bool() const;
+
bool IsValid() const;
bool IsClassCode();
@@ -78,6 +77,4 @@ protected:
} // namespace lldb
-#endif // LLDB_DISABLE_PYTHON
-
#endif // LLDB_SBTypeSynthetic_h_
diff --git a/include/lldb/API/SBUnixSignals.h b/include/lldb/API/SBUnixSignals.h
index d44a508fbb425..c7e99d1f63d18 100644
--- a/include/lldb/API/SBUnixSignals.h
+++ b/include/lldb/API/SBUnixSignals.h
@@ -1,10 +1,9 @@
//===-- SBUnixSignals.h -----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,6 +26,8 @@ public:
void Clear();
+ explicit operator bool() const;
+
bool IsValid() const;
const char *GetSignalAsCString(int32_t signo) const;
diff --git a/include/lldb/API/SBValue.h b/include/lldb/API/SBValue.h
index ab5bdfea993dd..c36ba20297f04 100644
--- a/include/lldb/API/SBValue.h
+++ b/include/lldb/API/SBValue.h
@@ -1,9 +1,8 @@
//===-- SBValue.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,6 +28,8 @@ public:
~SBValue();
+ explicit operator bool() const;
+
bool IsValid();
void Clear();
@@ -111,9 +112,7 @@ public:
lldb::SBTypeFilter GetTypeFilter();
-#ifndef LLDB_DISABLE_PYTHON
lldb::SBTypeSynthetic GetTypeSynthetic();
-#endif
lldb::SBValue GetChildAtIndex(uint32_t idx);
@@ -138,7 +137,6 @@ public:
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
@@ -176,22 +174,21 @@ public:
/// that aren't in the array bounds using positive or negative
/// indexes.
///
- /// @param[in] idx
+ /// \param[in] idx
/// The index of the child value to get
///
- /// @param[in] use_dynamic
+ /// \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
+ /// \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
+ /// \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);
@@ -218,46 +215,41 @@ public:
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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
@@ -269,10 +261,9 @@ public:
/// pointers, references, arrays and more. Again, it does so without
/// doing any expensive type completion.
///
- /// @return
+ /// \return
/// Returns \b true if the SBValue might have children, or \b
/// false otherwise.
- //------------------------------------------------------------------
bool MightHaveChildren();
bool IsRuntimeSupportValue();
@@ -307,70 +298,72 @@ public:
bool GetExpressionPath(lldb::SBStream &description,
bool qualify_cxx_base_classes);
+ lldb::SBValue EvaluateExpression(const char *expr) const;
+ lldb::SBValue EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options) const;
+ lldb::SBValue EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options,
+ const char *name) const;
+
SBValue(const lldb::ValueObjectSP &value_sp);
- //------------------------------------------------------------------
/// Watch this value if it resides in memory.
///
/// Sets a watchpoint on the value.
///
- /// @param[in] resolve_location
+ /// \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
+ /// \param[in] read
/// Stop when this value is accessed.
///
- /// @param[in] write
+ /// \param[in] write
/// Stop when this value is modified
///
- /// @param[out] error
+ /// \param[out] error
/// An error object. Contains the reason if there is some failure.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] read
/// Stop when this value is accessed.
///
- /// @param[in] write
+ /// \param[in] write
/// Stop when this value is modified
///
- /// @param[out] error
+ /// \param[out] error
/// An error object. Contains the reason if there is some failure.
///
- /// @return
+ /// \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,
@@ -379,10 +372,9 @@ public:
/// already
/// holding the two above-mentioned locks.
///
- /// @return
+ /// \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:
@@ -392,7 +384,6 @@ protected:
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,
@@ -407,16 +398,15 @@ protected:
/// ValueObject.h/cpp or somewhere else convenient. We haven't needed to so
/// far.
///
- /// @param[in] value_locker
+ /// \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
+ /// \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
diff --git a/include/lldb/API/SBValueList.h b/include/lldb/API/SBValueList.h
index 0242dd7f71a27..d305b3564c2bf 100644
--- a/include/lldb/API/SBValueList.h
+++ b/include/lldb/API/SBValueList.h
@@ -1,9 +1,8 @@
//===-- SBValueList.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@ public:
~SBValueList();
+ explicit operator bool() const;
+
bool IsValid() const;
void Clear();
@@ -66,7 +67,7 @@ private:
ValueListImpl &ref();
- std::unique_ptr<ValueListImpl> m_opaque_ap;
+ std::unique_ptr<ValueListImpl> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBVariablesOptions.h b/include/lldb/API/SBVariablesOptions.h
index 0059a41129c50..e226ce4ae13b6 100644
--- a/include/lldb/API/SBVariablesOptions.h
+++ b/include/lldb/API/SBVariablesOptions.h
@@ -1,10 +1,9 @@
//===-- SBVariablesOptions.h ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,6 +26,8 @@ public:
~SBVariablesOptions();
+ explicit operator bool() const;
+
bool IsValid() const;
bool GetIncludeArguments() const;
@@ -73,7 +74,7 @@ protected:
void SetOptions(VariablesOptionsImpl *lldb_object_ptr);
private:
- std::unique_ptr<VariablesOptionsImpl> m_opaque_ap;
+ std::unique_ptr<VariablesOptionsImpl> m_opaque_up;
};
} // namespace lldb
diff --git a/include/lldb/API/SBWatchpoint.h b/include/lldb/API/SBWatchpoint.h
index 92d4851fc14d6..05ff0ca7e443e 100644
--- a/include/lldb/API/SBWatchpoint.h
+++ b/include/lldb/API/SBWatchpoint.h
@@ -1,9 +1,8 @@
//===-- SBWatchpoint.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,12 @@ public:
const lldb::SBWatchpoint &operator=(const lldb::SBWatchpoint &rhs);
+ explicit operator bool() const;
+
+ bool operator==(const SBWatchpoint &rhs) const;
+
+ bool operator!=(const SBWatchpoint &rhs) const;
+
bool IsValid() const;
SBError GetError();
diff --git a/include/lldb/Breakpoint/Breakpoint.h b/include/lldb/Breakpoint/Breakpoint.h
index 5861a3be36e1c..f561b6d900a19 100644
--- a/include/lldb/Breakpoint/Breakpoint.h
+++ b/include/lldb/Breakpoint/Breakpoint.h
@@ -1,9 +1,8 @@
//===-- Breakpoint.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,12 +27,9 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" Class that
+/// \class Breakpoint Breakpoint.h "lldb/Breakpoint/Breakpoint.h" Class that
/// manages logical breakpoint setting.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// General Outline:
/// A breakpoint has four main parts, a filter, a resolver, the list of
/// breakpoint
@@ -79,17 +75,14 @@ namespace lldb_private {
/// 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 {
public:
- static const ConstString &GetEventIdentifier();
+ static 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;
+ enum MatchType { Exact, Regexp, Glob };
private:
enum class OptionNames : uint32_t { Names = 0, Hardware, LastOptionName };
@@ -109,9 +102,9 @@ public:
~BreakpointEventData() override;
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
- const ConstString &GetFlavor() const override;
+ ConstString GetFlavor() const override;
lldb::BreakpointEventType GetBreakpointEventType() const;
@@ -147,19 +140,6 @@ public:
DISALLOW_COPY_AND_ASSIGN(BreakpointEventData);
};
- class BreakpointPrecondition {
- public:
- virtual ~BreakpointPrecondition() = default;
-
- virtual bool EvaluatePrecondition(StoppointCallbackContext &context);
-
- virtual Status 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, Status &error);
@@ -171,173 +151,138 @@ public:
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
+ /// 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
+ /// \param[in] module_list
/// The list of modules to look in for new locations.
///
- /// @param[in] send_event
+ /// \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
+ /// \param[in] changed_modules
/// The list of modules to look in for new locations.
///
- /// @param[in] 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
+ /// \param[in] changedModules
/// The list of modules to look in for new locations.
- /// @param[in] load_event
+ /// \param[in] load_event
/// If \b true then the modules were loaded, if \b false, unloaded.
- /// @param[in] delete_locations
+ /// \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
+ /// \param[in] old_module_sp
/// The old module that is going away.
- /// @param[in] new_module_sp
+ /// \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
+ /// \param[in] addr
/// The Address specifying the new location.
- /// @param[out] 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
+ /// \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
+ /// \param[in] addr
/// The Address specifying the location.
- /// @return
+ /// \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
+ /// \param[in] addr
/// The Address specifying the location.
- /// @return
+ /// \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
+ /// \param[in] bp_loc_id
/// The ID specifying the location.
- /// @return
+ /// \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
+ /// \param[in] index
/// The location index.
///
- /// @return
+ /// \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
@@ -348,86 +293,61 @@ public:
/// This is typically used after the process calls exec, or anytime the
/// architecture of the target changes.
///
- /// @param[in] arch
+ /// \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
+ /// \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
+ /// \param[in] count
/// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
void SetIgnoreCount(uint32_t count);
- //------------------------------------------------------------------
/// Return the current ignore count/
- /// @return
+ /// \return
/// The number of breakpoint hits to be ignored.
- //------------------------------------------------------------------
uint32_t GetIgnoreCount() const;
- //------------------------------------------------------------------
- /// Return the current hit count for all locations. @return
+ /// 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
+ /// \return
/// \b true if the breakpoint is one shot, \b false otherwise.
- //------------------------------------------------------------------
bool IsOneShot() const;
- //------------------------------------------------------------------
/// If \a auto_continue is \b true, breakpoint will auto-continue when on
/// hit.
- //------------------------------------------------------------------
void SetAutoContinue(bool auto_continue);
- //------------------------------------------------------------------
/// Check the AutoContinue state.
- /// @return
+ /// \return
/// \b true if the breakpoint is set to auto-continue, \b false otherwise.
- //------------------------------------------------------------------
bool IsAutoContinue() const;
- //------------------------------------------------------------------
/// Set the valid thread to be checked when the breakpoint is hit.
- /// @param[in] thread_id
+ /// \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
+ /// \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);
@@ -442,22 +362,20 @@ public:
const char *GetQueueName() const;
- //------------------------------------------------------------------
/// Set the callback action invoked when the breakpoint is hit.
///
- /// @param[in] callback
+ /// \param[in] callback
/// The method that will get called when the breakpoint is hit.
- /// @param[in] baton
+ /// \param[in] baton
/// A void * pointer that will get passed back to the callback function.
- /// @param[in] is_synchronous
+ /// \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
+ /// \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);
@@ -467,92 +385,72 @@ public:
void ClearCallback();
- //------------------------------------------------------------------
/// Set the breakpoint's condition.
///
- /// @param[in] 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
+ /// \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
+ /// \return
/// The number locations resolved breakpoint sites.
- //------------------------------------------------------------------
size_t GetNumResolvedLocations() const;
- //------------------------------------------------------------------
/// Return whether this breakpoint has any resolved locations.
///
- /// @return
+ /// \return
/// True if GetNumResolvedLocations > 0
- //------------------------------------------------------------------
bool HasResolvedLocations() const;
- //------------------------------------------------------------------
/// Return the number of breakpoint locations.
///
- /// @return
+ /// \return
/// The number breakpoint locations.
- //------------------------------------------------------------------
size_t GetNumLocations() const;
- //------------------------------------------------------------------
/// Put a description of this breakpoint into the stream \a s.
///
- /// @param[in] s
+ /// \param[in] s
/// Stream into which to dump the description.
///
- /// @param[in] level
+ /// \param[in] level
/// The description level that indicates the detail level to
/// provide.
///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] kind
/// New "kind" description.
- //------------------------------------------------------------------
void SetBreakpointKind(const char *kind) { m_kind_description.assign(kind); }
- //------------------------------------------------------------------
/// Return the "kind" description for a breakpoint.
///
- /// @return
+ /// \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
+ /// \return
/// This breakpoint's Target.
- //------------------------------------------------------------------
Target &GetTarget() { return m_target; }
const Target &GetTarget() const { return m_target; }
@@ -561,13 +459,12 @@ public:
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
+ /// \return
/// True if there is a match
///
/// The locations which match the filename and line_number in loc_coll.
@@ -575,46 +472,39 @@ public:
/// size is 0 and true is returned, it means the breakpoint fully matches
/// the
/// description.
- //------------------------------------------------------------------
- bool GetMatchingFileLine(const ConstString &filename, uint32_t line_number,
+ bool GetMatchingFileLine(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
+ /// \return
/// A pointer to this breakpoint's BreakpointOptions.
- //------------------------------------------------------------------
BreakpointOptions *GetOptions();
- //------------------------------------------------------------------
/// Returns the BreakpointOptions structure set at the breakpoint level.
///
/// Meant to be used by the BreakpointLocation class.
///
- /// @return
+ /// \return
/// A pointer to this breakpoint's BreakpointOptions.
- //------------------------------------------------------------------
const BreakpointOptions *GetOptions() const;
- //------------------------------------------------------------------
/// Invoke the callback action when the breakpoint is hit.
///
/// Meant to be used by the BreakpointLocation class.
///
- /// @param[in] context
+ /// \param[in] context
/// Described the breakpoint event.
///
- /// @param[in] bp_loc_id
+ /// \param[in] bp_loc_id
/// Which breakpoint location hit this breakpoint.
///
- /// @return
+ /// \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);
@@ -645,7 +535,6 @@ public:
}
}
- //------------------------------------------------------------------
/// Set a pre-condition filter that overrides all user provided
/// filters/callbacks etc.
///
@@ -656,15 +545,14 @@ public:
/// 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) {
+ void SetPrecondition(lldb::BreakpointPreconditionSP precondition_sp) {
m_precondition_sp = precondition_sp;
}
bool EvaluatePrecondition(StoppointCallbackContext &context);
- BreakpointPreconditionSP GetPrecondition() { return m_precondition_sp; }
-
+ lldb::BreakpointPreconditionSP GetPrecondition() { return m_precondition_sp; }
+
// Produces the OR'ed values for all the names assigned to this breakpoint.
const BreakpointName::Permissions &GetPermissions() const {
return m_permissions;
@@ -686,39 +574,35 @@ public:
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
+ /// \param[in] target
/// The target in which the breakpoint will be set.
///
- /// @param[in] filter_sp
+ /// \param[in] filter_sp
/// Shared pointer to the search filter that restricts the search domain of
/// the breakpoint.
///
- /// @param[in] resolver_sp
+ /// \param[in] resolver_sp
/// Shared pointer to the resolver object that will determine breakpoint
/// matches.
///
- /// @param hardware
+ /// \param hardware
/// If true, request a hardware breakpoint to be used to implement the
/// breakpoint locations.
///
- /// @param resolve_indirect_symbols
+ /// \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,
@@ -749,9 +633,7 @@ private:
// 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
@@ -764,9 +646,9 @@ private:
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
+ lldb::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.
diff --git a/include/lldb/Breakpoint/BreakpointID.h b/include/lldb/Breakpoint/BreakpointID.h
index 5acb942ed2adb..095132988eb22 100644
--- a/include/lldb/Breakpoint/BreakpointID.h
+++ b/include/lldb/Breakpoint/BreakpointID.h
@@ -1,9 +1,8 @@
//===-- BreakpointID.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
// class BreakpointID
-//----------------------------------------------------------------------
class BreakpointID {
public:
@@ -51,49 +48,43 @@ public:
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 a BreakpointID filled out with
/// the proper id and location.
///
- /// @param[in] input
+ /// \param[in] input
/// A string containing JUST the breakpoint description.
- /// @return
+ /// \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
+ /// \param[in] input
/// A string containing JUST the breakpoint description.
- /// @param[out] error
+ /// \param[out] error
/// If the name is a well-formed breakpoint name, set to success,
/// otherwise set to an error.
- /// @return
+ /// \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, Status &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
+ /// \param[out] break_id
/// This is the break id.
///
- /// @param[out] break_loc_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);
diff --git a/include/lldb/Breakpoint/BreakpointIDList.h b/include/lldb/Breakpoint/BreakpointIDList.h
index 2820b9fdcaa5f..c6429220c7ff8 100644
--- a/include/lldb/Breakpoint/BreakpointIDList.h
+++ b/include/lldb/Breakpoint/BreakpointIDList.h
@@ -1,9 +1,8 @@
//===-- BreakpointIDList.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,9 +20,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
// class BreakpointIDList
-//----------------------------------------------------------------------
class BreakpointIDList {
public:
diff --git a/include/lldb/Breakpoint/BreakpointList.h b/include/lldb/Breakpoint/BreakpointList.h
index c4fc650a29f00..fe10adbda8a6d 100644
--- a/include/lldb/Breakpoint/BreakpointList.h
+++ b/include/lldb/Breakpoint/BreakpointList.h
@@ -1,9 +1,8 @@
//===-- BreakpointList.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,15 +16,11 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h"
+/// \class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h"
/// This class manages a list of breakpoints.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// General Outline:
/// Allows adding and removing breakpoints and find by ID and index.
-//----------------------------------------------------------------------
class BreakpointList {
public:
@@ -33,81 +28,66 @@ public:
~BreakpointList();
- //------------------------------------------------------------------
/// Add the breakpoint \a bp_sp to the list.
///
- /// @param[in] bp_sp
+ /// \param[in] bp_sp
/// Shared pointer to the breakpoint that will get added to the list.
///
- /// @result
+ /// \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. Const
/// version.
///
- /// @param[in] breakID
+ /// \param[in] breakID
/// The breakpoint ID to seek for.
///
- /// @result
+ /// \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) const;
- //------------------------------------------------------------------
/// Returns a shared pointer to the breakpoint with index \a i.
///
- /// @param[in] i
+ /// \param[in] i
/// The breakpoint index to seek for.
///
- /// @result
+ /// \result
/// A shared pointer to the breakpoint. May contain a NULL pointer if the
/// breakpoint doesn't exist.
- //------------------------------------------------------------------
lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const;
- //------------------------------------------------------------------
/// Find all the breakpoints with a given name
///
- /// @param[in] name
+ /// \param[in] name
/// The breakpoint name for which to search.
///
- /// @result
+ /// \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
+ /// \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
+ /// \param[in] breakID
/// The breakpoint index to remove.
///
- /// @result
+ /// \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
@@ -118,43 +98,36 @@ public:
/// This is typically used after the process calls exec, or anytime the
/// architecture of the target changes.
///
- /// @param[in] arch
+ /// \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);
void SetEnabledAllowed(bool enabled);
- //------------------------------------------------------------------
/// Removes all the breakpoints from this list.
- //------------------------------------------------------------------
void RemoveAll(bool notify);
- //------------------------------------------------------------------
/// Removes all the breakpoints from this list - first checking the
/// ePermDelete on the breakpoints. This call should be used unless you are
/// shutting down and need to actually clear them all.
- //------------------------------------------------------------------
void RemoveAllowed(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
+ /// \param[in] module_list
/// The module list that has changed.
///
- /// @param[in] load
+ /// \param[in] load
/// \b true if the modules are loaded, \b false if unloaded.
///
- /// @param[in] delete_locations
+ /// \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);
@@ -163,12 +136,10 @@ public:
void ClearAllBreakpointSites();
- //------------------------------------------------------------------
/// Sets the passed in Locker to hold the Breakpoint List mutex.
///
- /// @param[in] locker
+ /// \param[in] locker
/// The locker object that is set.
- //------------------------------------------------------------------
void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
diff --git a/include/lldb/Breakpoint/BreakpointLocation.h b/include/lldb/Breakpoint/BreakpointLocation.h
index 6448cb16e9272..7b27160563a08 100644
--- a/include/lldb/Breakpoint/BreakpointLocation.h
+++ b/include/lldb/Breakpoint/BreakpointLocation.h
@@ -1,9 +1,8 @@
//===-- BreakpointLocation.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,13 +20,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointLocation BreakpointLocation.h
+/// \class BreakpointLocation BreakpointLocation.h
/// "lldb/Breakpoint/BreakpointLocation.h" Class that manages one unique (by
/// address) instance of a logical breakpoint.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// General Outline:
/// A breakpoint location is defined by the breakpoint that produces it,
/// and the address that resulted in this particular instantiation. Each
@@ -37,7 +33,6 @@ namespace lldb_private {
/// FIXME: Should we also store some fingerprint for the location, so
/// we can map one location to the "equivalent location" on rerun? This would
/// be useful if you've set options on the locations.
-//----------------------------------------------------------------------
class BreakpointLocation
: public std::enable_shared_from_this<BreakpointLocation>,
@@ -45,100 +40,76 @@ class BreakpointLocation
public:
~BreakpointLocation() override;
- //------------------------------------------------------------------
- /// Gets the load address for this breakpoint location @return
+ /// 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
+ /// Gets the Address for this breakpoint location \return
/// Returns breakpoint location Address.
- //------------------------------------------------------------------
Address &GetAddress();
- //------------------------------------------------------------------
- /// Gets the Breakpoint that created this breakpoint location @return
+ /// 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
+ /// \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
+ /// \return
/// \b true if the breakpoint is enabled, \b false if disabled.
- //------------------------------------------------------------------
bool IsEnabled() const;
- //------------------------------------------------------------------
/// If \a auto_continue is \b true, set the breakpoint to continue when hit.
- //------------------------------------------------------------------
void SetAutoContinue(bool auto_continue);
- //------------------------------------------------------------------
/// Check the AutoContinue state.
///
- /// @return
+ /// \return
/// \b true if the breakpoint is set to auto-continue, \b false if not.
- //------------------------------------------------------------------
bool IsAutoContinue() const;
- //------------------------------------------------------------------
/// Return the current Ignore Count.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] callback
/// The method that will get called when the breakpoint is hit.
///
- /// @param[in] callback_baton_sp
+ /// \param[in] callback_baton_sp
/// A shared pointer to a Baton that provides the void * needed
/// for the callback.
///
- /// @see lldb_private::Baton
- //------------------------------------------------------------------
+ /// \see lldb_private::Baton
void SetCallback(BreakpointHitCallback callback,
const lldb::BatonSP &callback_baton_sp, bool is_synchronous);
@@ -147,31 +118,25 @@ public:
void ClearCallback();
- //------------------------------------------------------------------
/// Set the breakpoint location's condition.
///
- /// @param[in] 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
+ /// \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, Status &error);
- //------------------------------------------------------------------
/// Set the valid thread to be checked when the breakpoint is hit.
///
- /// @param[in] thread_id
+ /// \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();
@@ -188,150 +153,122 @@ public:
const char *GetQueueName() const;
- //------------------------------------------------------------------
// The next section deals with this location's breakpoint sites.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Try to resolve the breakpoint site for this location.
///
- /// @return
+ /// \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
+ /// \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
+ /// 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
+ /// \param[in] s
/// The stream to which to print the description.
///
- /// @param[in] level
+ /// \param[in] level
/// The description level that indicates the detail level to
/// provide.
///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
+ /// \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
+ /// \return
/// A pointer to the breakpoint options.
- //------------------------------------------------------------------
BreakpointOptions *GetLocationOptions();
- //------------------------------------------------------------------
/// Use this to access breakpoint options from this breakpoint location.
/// This will return the options that have a setting for the specified
/// BreakpointOptions kind.
///
- /// @param[in] kind
+ /// \param[in] kind
/// The particular option you are looking up.
- /// @return
+ /// \return
/// A pointer to the containing breakpoint's options if this
/// location doesn't have its own copy.
- //------------------------------------------------------------------
const BreakpointOptions *GetOptionsSpecifyingKind(
BreakpointOptions::OptionKind kind) 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
+ /// \param[in] context
/// Described the breakpoint event.
///
- /// @param[in] bp_loc_id
+ /// \param[in] bp_loc_id
/// Which breakpoint location hit this breakpoint.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] location
/// The location to compare against.
///
- /// @return
+ /// \return
/// \b true or \b false as given in the description above.
- //------------------------------------------------------------------
bool EquivalentToLocation(BreakpointLocation &location);
protected:
@@ -340,16 +277,14 @@ protected:
friend class Process;
friend class StopInfoBreakpoint;
- //------------------------------------------------------------------
/// Set the breakpoint site for this location to \a bp_site_sp.
///
- /// @param[in] bp_site_sp
+ /// \param[in] bp_site_sp
/// The breakpoint site we are setting for this location.
///
- /// @return
+ /// \return
/// \b true if we were successful at setting the breakpoint site,
/// \b false otherwise.
- //------------------------------------------------------------------
bool SetBreakpointSite(lldb::BreakpointSiteSP &bp_site_sp);
void DecrementIgnoreCount();
@@ -363,46 +298,40 @@ private:
void UndoBumpHitCount();
- //------------------------------------------------------------------
// Constructors and Destructors
//
// Only the Breakpoint can make breakpoint locations, and it owns them.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Constructor.
///
- /// @param[in] owner
+ /// \param[in] owner
/// A back pointer to the breakpoint that owns this location.
///
- /// @param[in] addr
+ /// \param[in] addr
/// The Address defining this location.
///
- /// @param[in] tid
+ /// \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
+ /// \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.
+ std::unique_ptr<BreakpointOptions> m_options_up; ///< 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
diff --git a/include/lldb/Breakpoint/BreakpointLocationCollection.h b/include/lldb/Breakpoint/BreakpointLocationCollection.h
index 5a188539622bf..3da52eb7962a8 100644
--- a/include/lldb/Breakpoint/BreakpointLocationCollection.h
+++ b/include/lldb/Breakpoint/BreakpointLocationCollection.h
@@ -1,9 +1,8 @@
//===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,165 +22,141 @@ public:
BreakpointLocationCollection();
~BreakpointLocationCollection();
+
+ BreakpointLocationCollection &operator=(const BreakpointLocationCollection &rhs);
- //------------------------------------------------------------------
/// Add the breakpoint \a bp_loc_sp to the list.
///
- /// @param[in] bp_sp
+ /// \param[in] bp_sp
/// Shared pointer to the breakpoint location that will get added
/// to the list.
///
- /// @result
+ /// \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
+ /// \param[in] break_id
/// The breakpoint index to remove.
///
- /// @param[in] break_loc_id
+ /// \param[in] break_loc_id
/// The breakpoint location index in break_id to remove.
///
- /// @result
+ /// \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
+ /// \param[in] break_id
/// The breakpoint ID to seek for.
///
- /// @param[in] break_loc_id
+ /// \param[in] break_loc_id
/// The breakpoint location ID in \a break_id to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] breakID
/// The breakpoint location ID to seek for.
///
- /// @param[in] break_loc_id
+ /// \param[in] break_loc_id
/// The breakpoint location ID in \a break_id to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] i
/// The breakpoint location index to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] i
/// The breakpoint location index to seek for.
///
- /// @result
+ /// \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
+ /// \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
+ /// \param[in] context
/// This contains the information about this stop.
///
- /// @param[in] breakID
+ /// \param[in] breakID
/// This break ID that we hit.
///
- /// @return
+ /// \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
+ /// \param[in] s
/// The stream to which to print the description.
///
- /// @param[in] level
+ /// \param[in] level
/// The description level that indicates the detail level to
/// provide.
///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \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
- //------------------------------------------------------------------
private:
- //------------------------------------------------------------------
// For BreakpointLocationCollection only
- //------------------------------------------------------------------
typedef std::vector<lldb::BreakpointLocationSP> collection;
diff --git a/include/lldb/Breakpoint/BreakpointLocationList.h b/include/lldb/Breakpoint/BreakpointLocationList.h
index 01ee5b5dcce9d..b7e0e49cff83a 100644
--- a/include/lldb/Breakpoint/BreakpointLocationList.h
+++ b/include/lldb/Breakpoint/BreakpointLocationList.h
@@ -1,9 +1,8 @@
//===-- BreakpointLocationList.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,12 +19,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointLocationList BreakpointLocationList.h
+/// \class BreakpointLocationList BreakpointLocationList.h
/// "lldb/Breakpoint/BreakpointLocationList.h" 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
@@ -37,178 +34,146 @@ class BreakpointLocationList {
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
+ /// \param[in] addr
/// The address to look for.
///
- /// @result
+ /// \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
+ /// \param[in] breakID
/// The breakpoint location ID to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] addr
/// The address to match.
///
- /// @result
+ /// \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
+ /// \param[in] module
/// The module to seek in.
///
- /// @param[in]
+ /// \param[in]
/// A breakpoint collection that gets any breakpoint locations
/// that match \a module appended to.
///
- /// @result
+ /// \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
+ /// \param[in] i
/// The breakpoint location index to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] i
/// The breakpoint location index to seek for.
///
- /// @result
+ /// \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
+ /// \result
/// Number of qualifying breakpoint locations.
- //------------------------------------------------------------------
size_t GetNumResolvedLocations() const;
- //------------------------------------------------------------------
/// Returns the number hit count of all locations in this list.
///
- /// @result
+ /// \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
+ /// \param[in] context
/// This contains the information about this stop.
///
- /// @param[in] breakID
+ /// \param[in] breakID
/// This break ID that we hit.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] s
/// The stream to which to print the description.
///
- /// @param[in] level
+ /// \param[in] level
/// The description level that indicates the detail level to
/// provide.
///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] bp_sp
/// Shared pointer to the breakpoint location that will get
/// added to the list.
///
- /// @result
+ /// \result
/// Returns breakpoint location id.
- //------------------------------------------------------------------
lldb::BreakpointLocationSP Create(const Address &addr,
bool resolve_indirect_symbols);
diff --git a/include/lldb/Breakpoint/BreakpointName.h b/include/lldb/Breakpoint/BreakpointName.h
index 5e5a04fe9117f..61020a6280707 100644
--- a/include/lldb/Breakpoint/BreakpointName.h
+++ b/include/lldb/Breakpoint/BreakpointName.h
@@ -1,9 +1,8 @@
//===-- BreakpointName.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -137,13 +136,13 @@ public:
}
};
- BreakpointName(const ConstString &name, const char *help = nullptr) :
+ BreakpointName(ConstString name, const char *help = nullptr) :
m_name(name), m_options(false)
{
SetHelp(help);
}
- BreakpointName(const ConstString &name,
+ BreakpointName(ConstString name,
BreakpointOptions &options,
const Permissions &permissions = Permissions(),
const char *help = nullptr) :
@@ -157,10 +156,10 @@ public:
m_permissions(rhs.m_permissions), m_help(rhs.m_help)
{}
- BreakpointName(const ConstString &name, const Breakpoint &bkpt,
+ BreakpointName(ConstString name, const Breakpoint &bkpt,
const char *help);
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
BreakpointOptions &GetOptions() { return m_options; }
const BreakpointOptions &GetOptions() const { return m_options; }
diff --git a/include/lldb/Breakpoint/BreakpointOptions.h b/include/lldb/Breakpoint/BreakpointOptions.h
index e91df20ed3055..cdac5d3dbd75d 100644
--- a/include/lldb/Breakpoint/BreakpointOptions.h
+++ b/include/lldb/Breakpoint/BreakpointOptions.h
@@ -1,9 +1,8 @@
//===-- BreakpointOptions.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,11 +20,9 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointOptions BreakpointOptions.h
+/// \class BreakpointOptions BreakpointOptions.h
/// "lldb/Breakpoint/BreakpointOptions.h" Class that manages the options on a
/// breakpoint or breakpoint location.
-//----------------------------------------------------------------------
class BreakpointOptions {
friend class BreakpointLocation;
@@ -96,32 +93,26 @@ public:
typedef std::shared_ptr<CommandBaton> CommandBatonSP;
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// 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
+ /// \param[in] condition
/// The expression which if it evaluates to \b true if we are to stop
///
- /// @param[in] enabled
+ /// \param[in] enabled
/// Is this breakpoint enabled.
///
- /// @param[in] ignore
+ /// \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,
bool auto_continue = false);
- //------------------------------------------------------------------
/// Breakpoints make options with all flags set. Locations and Names make
/// options with no flags set.
- //------------------------------------------------------------------
BreakpointOptions(bool all_flags_set);
BreakpointOptions(const BreakpointOptions &rhs);
@@ -136,17 +127,12 @@ public:
static const char *GetSerializationKey() { return "BKPTOptions"; }
- //------------------------------------------------------------------
// Operators
- //------------------------------------------------------------------
const BreakpointOptions &operator=(const BreakpointOptions &rhs);
- //------------------------------------------------------------------
/// Copy over only the options set in the incoming BreakpointOptions.
- //------------------------------------------------------------------
void CopyOverSetOptions(const BreakpointOptions &rhs);
- //------------------------------------------------------------------
// Callbacks
//
// Breakpoint callbacks come in two forms, synchronous and asynchronous.
@@ -178,21 +164,18 @@ public:
// 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
+ /// \param[in] callback
/// The function to be called when the breakpoint gets hit.
///
- /// @param[in] baton_sp
+ /// \param[in] baton_sp
/// A baton which will get passed back to the callback when it is invoked.
///
- /// @param[in] synchronous
+ /// \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);
@@ -200,30 +183,25 @@ public:
const BreakpointOptions::CommandBatonSP &command_baton_sp,
bool synchronous = false);
- //------------------------------------------------------------------
/// Returns the command line commands for the callback on this breakpoint.
///
- /// @param[out] command_list
+ /// \param[out] command_list
/// The commands will be appended to this list.
///
- /// @return
+ /// \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
+ /// \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
@@ -231,169 +209,128 @@ public:
/// whether we are currently executing synchronous or asynchronous
/// callbacks.
///
- /// @param[in] break_id
+ /// \param[in] break_id
/// The breakpoint ID that owns this option set.
///
- /// @param[in] break_loc_id
+ /// \param[in] break_loc_id
/// The breakpoint location ID that owns this option set.
///
- /// @return
+ /// \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
+ /// \return
/// The synchronicity of our callback.
- //------------------------------------------------------------------
bool IsCallbackSynchronous() const { return m_callback_is_synchronous; }
- //------------------------------------------------------------------
/// Fetch the baton from the callback.
///
- /// @return
+ /// \return
/// The baton.
- //------------------------------------------------------------------
Baton *GetBaton();
- //------------------------------------------------------------------
/// Fetch a const version of the baton from the callback.
///
- /// @return
+ /// \return
/// The baton.
- //------------------------------------------------------------------
const Baton *GetBaton() const;
- //------------------------------------------------------------------
// Condition
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Set the breakpoint option's condition.
///
- /// @param[in] 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
+ /// \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
+ /// \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;
m_set_flags.Set(eEnabled);
}
- //------------------------------------------------------------------
/// Check the auto-continue state.
- /// @return
+ /// \return
/// \b true if the breakpoint is set to auto-continue, \b false otherwise.
- //------------------------------------------------------------------
bool IsAutoContinue() const { return m_auto_continue; }
- //------------------------------------------------------------------
/// Set the auto-continue state.
- //------------------------------------------------------------------
void SetAutoContinue(bool auto_continue) {
m_auto_continue = auto_continue;
m_set_flags.Set(eAutoContinue);
}
- //------------------------------------------------------------------
/// Check the One-shot state.
- /// @return
+ /// \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;
m_set_flags.Set(eOneShot);
}
- //------------------------------------------------------------------
/// Set the breakpoint to ignore the next \a count breakpoint hits.
- /// @param[in] count
+ /// \param[in] count
/// The number of breakpoint hits to ignore.
- //------------------------------------------------------------------
void SetIgnoreCount(uint32_t n) {
m_ignore_count = n;
m_set_flags.Set(eIgnoreCount);
}
- //------------------------------------------------------------------
/// Return the current Ignore Count.
- /// @return
+ /// \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
+ /// \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]
+ /// 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);
void Clear();
@@ -403,9 +340,7 @@ public:
}
protected:
-//------------------------------------------------------------------
// Classes that inherit from BreakpointOptions can see and modify these
- //------------------------------------------------------------------
bool IsOptionSet(OptionKind kind)
{
return m_set_flags.Test(kind);
@@ -432,9 +367,7 @@ protected:
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_baton_is_command_baton;
@@ -443,7 +376,7 @@ private:
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
+ m_thread_spec_up; // 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.
diff --git a/include/lldb/Breakpoint/BreakpointPrecondition.h b/include/lldb/Breakpoint/BreakpointPrecondition.h
new file mode 100644
index 0000000000000..2a9461b52fab2
--- /dev/null
+++ b/include/lldb/Breakpoint/BreakpointPrecondition.h
@@ -0,0 +1,30 @@
+//===-- BreakpointPrecondition.h --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_BreakpointPrecondition_h_
+#define liblldb_BreakpointPrecondition_h_
+
+#include "lldb/lldb-enumerations.h"
+
+namespace lldb_private {
+
+class Args;
+class Status;
+class StoppointCallbackContext;
+class Stream;
+
+class BreakpointPrecondition {
+public:
+ virtual ~BreakpointPrecondition() = default;
+ virtual bool EvaluatePrecondition(StoppointCallbackContext &context);
+ virtual Status ConfigurePrecondition(Args &args);
+ virtual void GetDescription(Stream &stream, lldb::DescriptionLevel level);
+};
+} // namespace lldb_private
+
+#endif
diff --git a/include/lldb/Breakpoint/BreakpointResolver.h b/include/lldb/Breakpoint/BreakpointResolver.h
index 32008f3dd96f7..11e183b33482d 100644
--- a/include/lldb/Breakpoint/BreakpointResolver.h
+++ b/include/lldb/Breakpoint/BreakpointResolver.h
@@ -1,9 +1,8 @@
//===-- BreakpointResolver.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,13 +19,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointResolver BreakpointResolver.h
+/// \class BreakpointResolver BreakpointResolver.h
/// "lldb/Breakpoint/BreakpointResolver.h" This class works with SearchFilter
/// to resolve logical breakpoints to their of concrete breakpoint locations.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// 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
@@ -35,92 +31,73 @@ namespace lldb_private {
/// 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;
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
+ /// \param[in] bkpt
/// The breakpoint that owns this resolver.
- /// @param[in] resolverType
+ /// \param[in] resolverType
/// The concrete breakpoint resolver type for this breakpoint.
///
- /// @result
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
@@ -143,8 +120,6 @@ public:
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
@@ -164,7 +139,6 @@ public:
// 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.
@@ -221,7 +195,6 @@ public:
}
protected:
- //------------------------------------------------------------------
/// 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
@@ -236,7 +209,7 @@ protected:
const char *) = delete;
lldb::BreakpointLocationSP AddLocation(Address loc_addr,
- bool *new_location = NULL);
+ bool *new_location = nullptr);
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
diff --git a/include/lldb/Breakpoint/BreakpointResolverAddress.h b/include/lldb/Breakpoint/BreakpointResolverAddress.h
index 5d8c0b6b75301..949a788282b96 100644
--- a/include/lldb/Breakpoint/BreakpointResolverAddress.h
+++ b/include/lldb/Breakpoint/BreakpointResolverAddress.h
@@ -1,9 +1,8 @@
//===-- BreakpointResolverAddress.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,12 +14,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointResolverAddress BreakpointResolverAddress.h
+/// \class BreakpointResolverAddress BreakpointResolverAddress.h
/// "lldb/Breakpoint/BreakpointResolverAddress.h" 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 {
public:
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileLine.h b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
index 8671cd2e55620..f146a704ca54e 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileLine.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileLine.h
@@ -1,9 +1,8 @@
//===-- BreakpointResolverFileLine.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,12 +13,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointResolverFileLine BreakpointResolverFileLine.h
+/// \class BreakpointResolverFileLine BreakpointResolverFileLine.h
/// "lldb/Breakpoint/BreakpointResolverFileLine.h" 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 {
public:
diff --git a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
index db4f67cf39511..963145722e39a 100644
--- a/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
+++ b/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
@@ -1,10 +1,9 @@
//===-- BreakpointResolverFileRegex.h ----------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,12 +16,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointResolverFileRegex BreakpointResolverFileRegex.h
+/// \class BreakpointResolverFileRegex BreakpointResolverFileRegex.h
/// "lldb/Breakpoint/BreakpointResolverFileRegex.h" 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 {
public:
diff --git a/include/lldb/Breakpoint/BreakpointResolverName.h b/include/lldb/Breakpoint/BreakpointResolverName.h
index 416e1aa301b1c..85a41b6007f0b 100644
--- a/include/lldb/Breakpoint/BreakpointResolverName.h
+++ b/include/lldb/Breakpoint/BreakpointResolverName.h
@@ -1,9 +1,8 @@
//===-- BreakpointResolverName.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,11 +17,9 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointResolverName BreakpointResolverName.h
+/// \class BreakpointResolverName BreakpointResolverName.h
/// "lldb/Breakpoint/BreakpointResolverName.h" This class sets breakpoints on
/// a given function name, either by exact match or by regular expression.
-//----------------------------------------------------------------------
class BreakpointResolverName : public BreakpointResolver {
public:
@@ -88,7 +85,7 @@ protected:
lldb::LanguageType m_language;
bool m_skip_prologue;
- void AddNameLookup(const ConstString &name,
+ void AddNameLookup(ConstString name,
lldb::FunctionNameType name_type_mask);
};
diff --git a/include/lldb/Breakpoint/BreakpointResolverScripted.h b/include/lldb/Breakpoint/BreakpointResolverScripted.h
index aaa9cbe4d3549..980bb4693d033 100644
--- a/include/lldb/Breakpoint/BreakpointResolverScripted.h
+++ b/include/lldb/Breakpoint/BreakpointResolverScripted.h
@@ -1,9 +1,8 @@
//===-- BreakpointResolverScripted.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,12 +16,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointResolverScripted BreakpointResolverScripted.h
+/// \class BreakpointResolverScripted BreakpointResolverScripted.h
/// "lldb/Breakpoint/BreakpointResolverScripted.h" This class sets breakpoints
/// on a given Address. This breakpoint only takes once, and then it won't
/// attempt to reset itself.
-//----------------------------------------------------------------------
class BreakpointResolverScripted : public BreakpointResolver {
public:
diff --git a/include/lldb/Breakpoint/BreakpointSite.h b/include/lldb/Breakpoint/BreakpointSite.h
index 8d1d69076b1cb..51ed84f7bf2dd 100644
--- a/include/lldb/Breakpoint/BreakpointSite.h
+++ b/include/lldb/Breakpoint/BreakpointSite.h
@@ -1,9 +1,8 @@
//===-- BreakpointSite.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,8 +21,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointSite BreakpointSite.h "lldb/Breakpoint/BreakpointSite.h"
+/// \class BreakpointSite BreakpointSite.h "lldb/Breakpoint/BreakpointSite.h"
/// Class that manages the actual breakpoint that will be inserted into the
/// running program.
///
@@ -33,7 +31,6 @@ namespace lldb_private {
/// that share this physical site. When the breakpoint is hit, all the
/// locations are informed by the breakpoint site. Breakpoint sites are owned
/// by the process.
-//----------------------------------------------------------------------
class BreakpointSite : public std::enable_shared_from_this<BreakpointSite>,
public StoppointLocation {
@@ -50,182 +47,142 @@ public:
~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
+ /// \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
+ /// \param[in] context
/// This contains the information about this stop.
///
- /// @return
+ /// \return
/// \b true if we should stop, \b false otherwise.
- //------------------------------------------------------------------
bool ShouldStop(StoppointCallbackContext *context) override;
- //------------------------------------------------------------------
/// Standard Dump method
///
- /// @param[in] context
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] index
/// The index in the list of owners for which you wish the owner location.
- /// @return
+ /// \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
+ /// \param[out] out_collection
/// The BreakpointLocationCollection into which to put the owners
/// of this breakpoint site.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] s
/// The stream to which to print the description.
///
- /// @param[in] level
+ /// \param[in] level
/// The description level that indicates the detail level to
/// provide.
///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
+ /// \see lldb::DescriptionLevel
void GetDescription(Stream *s, lldb::DescriptionLevel level);
- //------------------------------------------------------------------
/// Tell whether a breakpoint has a location at this site.
///
- /// @param[in] bp_id
+ /// \param[in] bp_id
/// The breakpoint id to query.
///
- /// @result
+ /// \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
+ /// \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; }
@@ -242,13 +199,11 @@ private:
void BumpHitCounts();
- //------------------------------------------------------------------
/// The method removes the owner at \a break_loc_id from this breakpoint
/// list.
///
- /// @param[in] context
+ /// \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.
diff --git a/include/lldb/Breakpoint/BreakpointSiteList.h b/include/lldb/Breakpoint/BreakpointSiteList.h
index 2f2e31cd31269..b10d119fcce63 100644
--- a/include/lldb/Breakpoint/BreakpointSiteList.h
+++ b/include/lldb/Breakpoint/BreakpointSiteList.h
@@ -1,9 +1,8 @@
//===-- BreakpointSiteList.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,11 +17,9 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class BreakpointSiteList BreakpointSiteList.h
+/// \class BreakpointSiteList BreakpointSiteList.h
/// "lldb/Breakpoint/BreakpointSiteList.h" 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).
@@ -30,123 +27,101 @@ class BreakpointSiteList {
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
+ /// \param[in] bp_site_sp
/// A shared pointer to a breakpoint site being added to the list.
///
- /// @return
+ /// \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
+ /// 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
+ /// \param[in] addr
/// The address to look for.
///
- /// @result
+ /// \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
+ /// \param[in] breakID
/// The breakpoint site ID to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] breakID
/// The breakpoint site ID to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] addr
/// The address to match.
///
- /// @result
+ /// \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
+ /// \param[in] bp_site_id
/// The breakpoint site id to query.
///
- /// @param[in] bp_id
+ /// \param[in] bp_id
/// The breakpoint id to look for in \a bp_site_id.
///
- /// @result
+ /// \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
+ /// \param[in] breakID
/// The breakpoint site index to remove.
///
- /// @result
+ /// \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
+ /// \param[in] addr
/// The address from which to remove a breakpoint site.
///
- /// @result
+ /// \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,
@@ -155,27 +130,23 @@ public:
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
+ /// \param[in] context
/// This contains the information about this stop.
///
- /// @param[in] breakID
+ /// \param[in] breakID
/// This break ID that we hit.
///
- /// @return
+ /// \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
+ /// \result
/// The number of elements.
- //------------------------------------------------------------------
size_t GetSize() const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_bp_site_list.size();
diff --git a/include/lldb/Breakpoint/Stoppoint.h b/include/lldb/Breakpoint/Stoppoint.h
index 78baa6ce6cbb1..f20b100740510 100644
--- a/include/lldb/Breakpoint/Stoppoint.h
+++ b/include/lldb/Breakpoint/Stoppoint.h
@@ -1,9 +1,8 @@
//===-- Stoppoint.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,16 +16,12 @@ namespace lldb_private {
class Stoppoint {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
Stoppoint();
virtual ~Stoppoint();
- //------------------------------------------------------------------
// Methods
- //------------------------------------------------------------------
virtual void Dump(Stream *) = 0;
virtual bool IsEnabled() = 0;
@@ -41,9 +36,7 @@ protected:
lldb::break_id_t m_bid;
private:
- //------------------------------------------------------------------
// For Stoppoint only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(Stoppoint);
};
diff --git a/include/lldb/Breakpoint/StoppointCallbackContext.h b/include/lldb/Breakpoint/StoppointCallbackContext.h
index 1dac342d33255..c1724a6b276f8 100644
--- a/include/lldb/Breakpoint/StoppointCallbackContext.h
+++ b/include/lldb/Breakpoint/StoppointCallbackContext.h
@@ -1,9 +1,8 @@
//===-- StoppointCallbackContext.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,18 +14,14 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class StoppointCallbackContext StoppointCallbackContext.h
+/// \class StoppointCallbackContext StoppointCallbackContext.h
/// "lldb/Breakpoint/StoppointCallbackContext.h" 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 that information.
-//----------------------------------------------------------------------
class StoppointCallbackContext {
public:
@@ -35,17 +30,13 @@ public:
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
diff --git a/include/lldb/Breakpoint/StoppointLocation.h b/include/lldb/Breakpoint/StoppointLocation.h
index 5c78d2e3d659b..3926f452e564c 100644
--- a/include/lldb/Breakpoint/StoppointLocation.h
+++ b/include/lldb/Breakpoint/StoppointLocation.h
@@ -1,9 +1,8 @@
//===-- StoppointLocation.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@ namespace lldb_private {
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,
@@ -28,13 +25,9 @@ public:
virtual ~StoppointLocation();
- //------------------------------------------------------------------
// Operators
- //------------------------------------------------------------------
- //------------------------------------------------------------------
// Methods
- //------------------------------------------------------------------
virtual lldb::addr_t GetLoadAddress() const { return m_addr; }
virtual void SetLoadAddress(lldb::addr_t addr) { m_addr = addr; }
@@ -60,9 +53,7 @@ public:
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
@@ -85,11 +76,9 @@ protected:
void DecrementHitCount();
private:
- //------------------------------------------------------------------
// For StoppointLocation only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(StoppointLocation);
- StoppointLocation(); // Disallow default constructor
+ StoppointLocation() = delete;
};
} // namespace lldb_private
diff --git a/include/lldb/Breakpoint/Watchpoint.h b/include/lldb/Breakpoint/Watchpoint.h
index 2aaae37eb095e..e71f89b3e384e 100644
--- a/include/lldb/Breakpoint/Watchpoint.h
+++ b/include/lldb/Breakpoint/Watchpoint.h
@@ -1,9 +1,8 @@
//===-- Watchpoint.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,9 @@ public:
~WatchpointEventData() override;
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
- const ConstString &GetFlavor() const override;
+ ConstString GetFlavor() const override;
lldb::WatchpointEventType GetWatchpointEventType() const;
@@ -98,30 +97,26 @@ public:
Target &GetTarget() { return m_target; }
const Status &GetError() { return m_error; }
- //------------------------------------------------------------------
/// Returns the WatchpointOptions structure set for this watchpoint.
///
- /// @return
+ /// \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
+ /// \param[in] callback
/// The method that will get called when the watchpoint is hit.
- /// @param[in] callback_baton
+ /// \param[in] callback_baton
/// A void * pointer that will get passed back to the callback function.
- /// @param[in] is_synchronous
+ /// \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
+ /// \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);
@@ -131,36 +126,28 @@ public:
void ClearCallback();
- //------------------------------------------------------------------
/// Invoke the callback action when the watchpoint is hit.
///
- /// @param[in] context
+ /// \param[in] context
/// Described the watchpoint event.
///
- /// @return
+ /// \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
+ /// \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
+ /// \return
/// A pointer to the condition expression text, or nullptr if no
// condition has been set.
- //------------------------------------------------------------------
const char *GetConditionText() const;
void TurnOnEphemeralMode();
@@ -214,7 +201,7 @@ private:
// the callback machinery.
bool m_being_created;
- std::unique_ptr<UserExpression> m_condition_ap; // The condition to test.
+ std::unique_ptr<UserExpression> m_condition_up; // The condition to test.
void SetID(lldb::watch_id_t id) { m_loc_id = id; }
diff --git a/include/lldb/Breakpoint/WatchpointList.h b/include/lldb/Breakpoint/WatchpointList.h
index 9bfa817456bc8..98c64832d46dc 100644
--- a/include/lldb/Breakpoint/WatchpointList.h
+++ b/include/lldb/Breakpoint/WatchpointList.h
@@ -1,9 +1,8 @@
//===-- WatchpointList.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,12 +18,10 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class WatchpointList WatchpointList.h "lldb/Breakpoint/WatchpointList.h"
+/// \class WatchpointList WatchpointList.h "lldb/Breakpoint/WatchpointList.h"
/// This class is used by Watchpoint to manage a list of watchpoints,
// each watchpoint in the list has a unique ID, and is unique by Address as
// well.
-//----------------------------------------------------------------------
class WatchpointList {
// Only Target can make the watchpoint list, or add elements to it. This is
@@ -34,193 +31,157 @@ class WatchpointList {
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
+ /// \param[in] wp_sp
/// A shared pointer to a watchpoint being added to the list.
///
- /// @return
+ /// \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
+ /// \param[in] addr
/// The address to look for.
///
- /// @result
+ /// \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
+ /// \param[in] spec
/// The watchpoint spec to look for.
///
- /// @result
+ /// \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
+ /// \param[in] watchID
/// The watchpoint location ID to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] addr
/// The address to match.
///
- /// @result
+ /// \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
+ /// \param[in] spec
/// The watchpoint spec to match.
///
- /// @result
+ /// \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
+ /// \param[in] i
/// The watchpoint index to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] i
/// The watchpoint index to seek for.
///
- /// @result
+ /// \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
+ /// \param[in] watchID
/// The watchpoint ID to remove.
///
- /// @result
+ /// \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
+ /// \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
+ /// \param[in] context
/// This contains the information about this stop.
///
- /// @param[in] watchID
+ /// \param[in] watchID
/// This watch ID that we hit.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] s
/// The stream to which to print the description.
///
- /// @param[in] level
+ /// \param[in] level
/// The description level that indicates the detail level to
/// provide.
///
- /// @see lldb::DescriptionLevel
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] locker
/// The locker object that is set.
- //------------------------------------------------------------------
void GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
protected:
diff --git a/include/lldb/Breakpoint/WatchpointOptions.h b/include/lldb/Breakpoint/WatchpointOptions.h
index 0f4f399b5e4de..b395dde21901e 100644
--- a/include/lldb/Breakpoint/WatchpointOptions.h
+++ b/include/lldb/Breakpoint/WatchpointOptions.h
@@ -1,9 +1,8 @@
//===-- WatchpointOptions.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,49 +18,38 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class WatchpointOptions WatchpointOptions.h
+/// \class WatchpointOptions WatchpointOptions.h
/// "lldb/Breakpoint/WatchpointOptions.h" Class that manages the options on a
/// watchpoint.
-//----------------------------------------------------------------------
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
+ /// \param[in] callback
/// This is the plugin for some code that gets run, returns \b true if we
/// are to stop.
///
- /// @param[in] baton
+ /// \param[in] baton
/// Client data that will get passed to the callback.
///
- /// @param[in] thread_id
+ /// \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.
@@ -89,36 +77,30 @@ public:
// take a bit of plumbing to get
// that to work.
//
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Adds a callback to the watchpoint option set.
///
- /// @param[in] callback
+ /// \param[in] callback
/// The function to be called when the watchpoint gets hit.
///
- /// @param[in] baton_sp
+ /// \param[in] baton_sp
/// A baton which will get passed back to the callback when it is invoked.
///
- /// @param[in] synchronous
+ /// \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
+ /// \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
@@ -126,77 +108,60 @@ public:
/// whether we are currently executing synchronous or asynchronous
/// callbacks.
///
- /// @param[in] watch_id
+ /// \param[in] watch_id
/// The watchpoint ID that owns this option set.
///
- /// @return
+ /// \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
+ /// \return
/// The synchronicity of our callback.
- //------------------------------------------------------------------
bool IsCallbackSynchronous() { return m_callback_is_synchronous; }
- //------------------------------------------------------------------
/// Fetch the baton from the callback.
///
- /// @return
+ /// \return
/// The baton.
- //------------------------------------------------------------------
Baton *GetBaton();
- //------------------------------------------------------------------
/// Fetch a const version of the baton from the callback.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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);
@@ -219,19 +184,15 @@ public:
};
protected:
- //------------------------------------------------------------------
// 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
+ m_thread_spec_up; // 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 a02a0d45a0821..080c00e76328e 100644
--- a/include/lldb/Core/Address.h
+++ b/include/lldb/Core/Address.h
@@ -1,9 +1,8 @@
//===-- Address.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,39 +19,17 @@
namespace lldb_private {
class Block;
-}
-namespace lldb_private {
class CompileUnit;
-}
-namespace lldb_private {
class ExecutionContextScope;
-}
-namespace lldb_private {
class Function;
-}
-namespace lldb_private {
class SectionList;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class Symbol;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class Target;
-}
-namespace lldb_private {
struct LineEntry;
-}
-namespace lldb_private {
-
-//----------------------------------------------------------------------
-/// @class Address Address.h "lldb/Core/Address.h"
+/// \class Address Address.h "lldb/Core/Address.h"
/// A section + offset based address class.
///
/// The Address class allows addresses to be relative to a section that can
@@ -60,8 +37,8 @@ namespace lldb_private {
/// frameworks) being loaded at different addresses than the addresses found
/// in the object file that represents them on disk. There are currently two
/// types of addresses for a section:
-/// @li file addresses
-/// @li load addresses
+/// \li file addresses
+/// \li load addresses
///
/// File addresses represent the virtual addresses that are in the "on disk"
/// object files. These virtual addresses are converted to be relative to
@@ -79,14 +56,11 @@ namespace lldb_private {
/// load addresses of the main executable and any images (shared libraries)
/// will be resolved/unresolved. When this happens, breakpoints that are in
/// one of these sections can be set/cleared.
-//----------------------------------------------------------------------
class Address {
public:
- //------------------------------------------------------------------
/// Dump styles allow the Address::Dump(Stream *,DumpStyle) const function
/// to display Address contents in a variety of ways.
- //------------------------------------------------------------------
- typedef enum {
+ enum DumpStyle {
DumpStyleInvalid, ///< Invalid dump style
DumpStyleSectionNameOffset, ///< Display as the section name + offset.
///< \code
@@ -102,7 +76,7 @@ public:
/// // 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).
+ /// module name prepended (if any).
///< \code
/// // address for printf in libSystem.B.dylib as a file address
/// libSystem.B.dylib[0x000000000005dcff] \endcode
@@ -111,54 +85,48 @@ public:
/// // 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
+ /// 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.
+ /// into the current function.
///< Used primarily in disassembly symbolication
DumpStyleDetailedSymbolContext, ///< Detailed symbol context information for
- ///an address for all symbol
+ /// an address for all symbol
///< context members.
DumpStyleResolvedPointerDescription ///< Dereference a pointer at the
- ///current address and then lookup 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
+ /// \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
+ /// \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
+ /// \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)
@@ -167,63 +135,53 @@ public:
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
+ /// \param[in] file_addr
/// A virtual file address.
///
- /// @param[in] section_list
+ /// \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
+/// \param[in] rhs
/// A const Address object reference to copy.
///
-/// @return
+/// \return
/// A const Address object reference to \a this.
-//------------------------------------------------------------------
-#ifndef SWIG
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;
}
- //------------------------------------------------------------------
/// Compare two Address objects.
///
- /// @param[in] lhs
+ /// \param[in] lhs
/// The Left Hand Side const Address object reference.
///
- /// @param[in] rhs
+ /// \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
- //------------------------------------------------------------------
+ /// \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,
@@ -242,51 +200,46 @@ public:
}
};
- //------------------------------------------------------------------
/// 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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] style
+ /// \param[in] style
/// The display style for the address.
///
- /// @param[in] fallback_style
+ /// \param[in] fallback_style
/// The display style for the address.
///
- /// @return
+ /// \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
- //------------------------------------------------------------------
+ /// \see Address::DumpStyle
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style,
DumpStyle fallback_style = DumpStyleInvalid,
uint32_t addr_byte_size = UINT32_MAX) const;
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
+ /// \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
@@ -296,13 +249,11 @@ public:
/// loaded/unloaded. If a section is loaded, then the load address can be
/// resolved.
///
- /// @return
+ /// \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
@@ -312,14 +263,12 @@ public:
/// target) that are required when changing the program counter to setting a
/// return address.
///
- /// @return
+ /// \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
@@ -331,25 +280,21 @@ public:
/// special purposes. The result of this function can be used to safely
/// write a software breakpoint trap to memory.
///
- /// @return
+ /// \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,
AddressClass addr_class = AddressClass::eInvalid) const;
- //------------------------------------------------------------------
/// Get the section relative offset value.
///
- /// @return
+ /// \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
@@ -358,49 +303,41 @@ public:
/// returns true if the current value contained in this object is section
/// offset based.
///
- /// @return
+ /// \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
/// offset (for section offset based addresses), or just a valid offset
/// (for absolute addresses that have no section).
///
- /// @return
+ /// \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
+ /// \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 an offset into
/// one of the file sections.
///
- /// @return
+ /// \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
@@ -408,25 +345,24 @@ public:
/// 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
+ /// \param[in] load_addr
/// A load address from a current process.
///
- /// @param[in] target
+ /// \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.
///
- /// @param[in] allow_section_end
+ /// \param[in] allow_section_end
/// If true, treat an address pointing to the end of the module as
/// belonging to that module.
///
- /// @return
+ /// \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
+ /// address to 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 allow_section_end = false);
@@ -437,34 +373,28 @@ public:
bool SetCallableLoadAddress(lldb::addr_t load_addr, Target *target);
- //------------------------------------------------------------------
/// Get accessor for the module for this address.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] offset
/// A new offset value for this object.
///
- /// @return
+ /// \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;
@@ -484,21 +414,18 @@ public:
return false;
}
- //------------------------------------------------------------------
/// Set accessor for the section.
///
- /// @param[in] 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
@@ -506,8 +433,7 @@ public:
/// can reconstruct their symbol context by looking up the address in the
/// module found in the section.
///
- /// @see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
- //------------------------------------------------------------------
+ /// \see SymbolContextScope::CalculateSymbolContext(SymbolContext*)
uint32_t CalculateSymbolContext(SymbolContext *sc,
lldb::SymbolContextItem resolve_scope =
lldb::eSymbolContextEverything) const;
@@ -524,33 +450,26 @@ public:
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.
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 addresses
// from different modules in any meaningful way, but it will compare the module
@@ -562,7 +481,6 @@ protected:
// address results to make much sense
//
// 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);
diff --git a/include/lldb/Core/AddressRange.h b/include/lldb/Core/AddressRange.h
index e3c820782aafa..4a019bfcfc3f4 100644
--- a/include/lldb/Core/AddressRange.h
+++ b/include/lldb/Core/AddressRange.h
@@ -1,9 +1,8 @@
//===-- AddressRange.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,179 +17,159 @@
namespace lldb_private {
class SectionList;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class Target;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class AddressRange AddressRange.h "lldb/Core/AddressRange.h"
+/// \class AddressRange AddressRange.h "lldb/Core/AddressRange.h"
/// A section + offset based address range class.
-//----------------------------------------------------------------------
class AddressRange {
public:
- //------------------------------------------------------------------
/// 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
+ /// \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
+ /// \param[in] offset
/// The offset in bytes into \a section.
///
- /// @param[in] byte_size
+ /// \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
+ /// \param[in] file_addr
/// A virtual address.
///
- /// @param[in] byte_size
+ /// \param[in] byte_size
/// The size in bytes of the address range.
///
- /// @param[in] section_list
+ /// \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
+ /// \param[in] so_addr
/// A section offset address object.
///
- /// @param[in] byte_size
+ /// \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();
- //------------------------------------------------------------------
/// 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
+ /// \param[in] so_addr
/// A section offset address object reference.
///
- /// @return
+ /// \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
+ /// \param[in] so_addr_ptr
/// A section offset address object pointer.
///
- /// @return
+ /// \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
+ /// \param[in] so_addr
/// A section offset address object reference.
///
- /// @return
+ /// \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
+ /// \param[in] so_addr
/// A section offset address object reference.
///
- /// @return
+ /// \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
+ /// \param[in] so_addr
/// A section offset address object reference.
///
- /// @return
+ /// \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
+ /// \param[in] so_addr
/// A section offset address object reference.
///
- /// @return
+ /// \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;
//------------------------------------------------------------------
+ /// Extends this range with \b rhs_range if it overlaps this range on the
+ /// right side. The range overlaps on the right side if the base address
+ /// of \b rhs_range lies within this range or if it's contiguous on its
+ /// right side.
+ ///
+ /// @param[in] rhs_range
+ /// The range to extend at the right side.
+ ///
+ /// @return
+ /// Returns \b true if this range was extended, \b false otherwise.
+ //------------------------------------------------------------------
+ bool Extend(const AddressRange &rhs_range);
+
/// Dump a description of this object to a Stream.
///
/// Dump a description of the contents of this object to the supplied stream
@@ -198,25 +177,23 @@ public:
/// range, and \a style lets the user choose how the base address gets
/// displayed.
///
- /// @param[in] s
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] style
+ /// \param[in] style
/// The display style for the address.
///
- /// @return
+ /// \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
- //------------------------------------------------------------------
+ /// \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
@@ -225,59 +202,46 @@ public:
/// The debug description contains verbose internal state such and pointer
/// values, reference counts, etc.
///
- /// @param[in] s
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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.
};
diff --git a/include/lldb/Core/AddressResolver.h b/include/lldb/Core/AddressResolver.h
index 32751d64d6b4a..cd95c7c31cd60 100644
--- a/include/lldb/Core/AddressResolver.h
+++ b/include/lldb/Core/AddressResolver.h
@@ -1,9 +1,8 @@
//===-- AddressResolver.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,29 +18,21 @@
namespace lldb_private {
class ModuleList;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h"
+/// \class AddressResolver AddressResolver.h "lldb/Core/AddressResolver.h"
/// This class works with SearchFilter to resolve function names and source
/// file locations to their concrete addresses.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// 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.
-//----------------------------------------------------------------------
class AddressResolver : public Searcher {
public:
- typedef enum { Exact, Regexp, Glob } MatchType;
+ enum MatchType { Exact, Regexp, Glob };
AddressResolver();
diff --git a/include/lldb/Core/AddressResolverFileLine.h b/include/lldb/Core/AddressResolverFileLine.h
index bee72245ee6b2..b98e7d4c63380 100644
--- a/include/lldb/Core/AddressResolverFileLine.h
+++ b/include/lldb/Core/AddressResolverFileLine.h
@@ -1,9 +1,8 @@
//===-- AddressResolverFileLine.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,22 +18,13 @@
namespace lldb_private {
class Address;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContext;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class AddressResolverFileLine AddressResolverFileLine.h
+/// \class AddressResolverFileLine AddressResolverFileLine.h
/// "lldb/Core/AddressResolverFileLine.h" 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 {
public:
diff --git a/include/lldb/Core/AddressResolverName.h b/include/lldb/Core/AddressResolverName.h
index b4291938b290b..ad14ef6daeb1d 100644
--- a/include/lldb/Core/AddressResolverName.h
+++ b/include/lldb/Core/AddressResolverName.h
@@ -1,9 +1,8 @@
//===-- AddressResolverName.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,21 +17,12 @@
namespace lldb_private {
class Address;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContext;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class AddressResolverName AddressResolverName.h
+/// \class AddressResolverName AddressResolverName.h
/// "lldb/Core/AddressResolverName.h" This class finds addresses for a given
/// function name, either by exact match or by regular expression.
-//----------------------------------------------------------------------
class AddressResolverName : public AddressResolver {
public:
diff --git a/include/lldb/Core/Architecture.h b/include/lldb/Core/Architecture.h
index 20537d67b02c7..d8dbbb4f540fa 100644
--- a/include/lldb/Core/Architecture.h
+++ b/include/lldb/Core/Architecture.h
@@ -1,9 +1,8 @@
//===-- Architecture.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,8 @@ namespace lldb_private {
class Architecture : public PluginInterface {
public:
Architecture() = default;
- virtual ~Architecture() = default;
+ ~Architecture() override = default;
- //------------------------------------------------------------------
/// This is currently intended to handle cases where a
/// program stops at an instruction that won't get executed and it
/// allows the stop reason, like "breakpoint hit", to be replaced
@@ -30,10 +28,8 @@ public:
/// 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.
- //------------------------------------------------------------------
virtual void OverrideStopInfo(Thread &thread) const = 0;
- //------------------------------------------------------------------
/// This method is used to get the number of bytes that should be
/// skipped, from function start address, to reach the first
/// instruction after the prologue. If overrode, it must return
@@ -49,12 +45,10 @@ public:
/// be compared with current address, in order to find out the
/// number of bytes that should be skipped, in case we are stopped
/// at either function entry point.
- //------------------------------------------------------------------
virtual size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const {
return 0;
}
- //------------------------------------------------------------------
/// Adjust function breakpoint address, if needed. In some cases,
/// the function start address is not the right place to set the
/// breakpoint, specially in functions with multiple entry points.
@@ -63,12 +57,10 @@ public:
/// both a global and a local entry point. In this case, the
/// breakpoint is adjusted to the first function address reached
/// by both entry points.
- //------------------------------------------------------------------
virtual void AdjustBreakpointAddress(const Symbol &func,
Address &addr) const {}
- //------------------------------------------------------------------
/// 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
@@ -78,13 +70,11 @@ public:
/// 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.
- //------------------------------------------------------------------
virtual lldb::addr_t GetCallableLoadAddress(
lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
return addr;
}
- //------------------------------------------------------------------
/// Get \a load_addr as an opcode for this target.
///
/// Take \a load_addr and potentially strip any address bits that are
@@ -95,7 +85,6 @@ public:
/// 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.
- //------------------------------------------------------------------
virtual lldb::addr_t GetOpcodeLoadAddress(
lldb::addr_t addr, AddressClass addr_class = AddressClass::eInvalid) const {
diff --git a/include/lldb/Core/ClangForward.h b/include/lldb/Core/ClangForward.h
index 3fc12a555301c..6b24b47c8a964 100644
--- a/include/lldb/Core/ClangForward.h
+++ b/include/lldb/Core/ClangForward.h
@@ -1,9 +1,8 @@
//===-- ClangForward.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/Communication.h b/include/lldb/Core/Communication.h
index f129b8f879d0e..901b8fdb8c8bc 100644
--- a/include/lldb/Core/Communication.h
+++ b/include/lldb/Core/Communication.h
@@ -1,9 +1,8 @@
//===-- Communication.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,18 +27,10 @@
namespace lldb_private {
class Connection;
-}
-namespace lldb_private {
class ConstString;
-}
-namespace lldb_private {
class Status;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Communication Communication.h "lldb/Core/Communication.h" An
+/// \class Communication Communication.h "lldb/Core/Communication.h" An
/// abstract communications class.
///
/// Communication is an class that handles data communication between two data
@@ -60,8 +51,8 @@ namespace lldb_private {
/// "eBroadcastBit" below).
///
/// There are two modes in which communications can occur:
-/// @li single-threaded
-/// @li multi-threaded
+/// \li single-threaded
+/// \li multi-threaded
///
/// In single-threaded mode, all reads and writes happen synchronously on the
/// calling thread.
@@ -90,7 +81,6 @@ namespace lldb_private {
/// eBroadcastBitReadThreadDidExit event will be broadcast. Clients can also
/// post a \b eBroadcastBitReadThreadShouldExit event to this object which
/// will cause the read thread to exit.
-//----------------------------------------------------------------------
class Communication : public Broadcaster {
public:
FLAGS_ANONYMOUS_ENUM(){
@@ -116,72 +106,61 @@ public:
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
+ /// \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
+ /// \param[in] url
/// A string that contains all information needed by the
/// subclass to connect to another client.
///
- /// @return
+ /// \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 Status& Communication::GetError ();
- /// @see bool Connection::Connect (const char *url);
- //------------------------------------------------------------------
+ /// \see Status& Communication::GetError ();
+ /// \see bool Connection::Connect (const char *url);
lldb::ConnectionStatus Connect(const char *url, Status *error_ptr);
- //------------------------------------------------------------------
/// Disconnect the communications connection if one is currently connected.
///
- /// @return
+ /// \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 Status& Communication::GetError ();
- /// @see bool Connection::Disconnect ();
- //------------------------------------------------------------------
+ /// \see Status& Communication::GetError ();
+ /// \see bool Connection::Disconnect ();
lldb::ConnectionStatus Disconnect(Status *error_ptr = nullptr);
- //------------------------------------------------------------------
/// Check if the connection is valid.
///
- /// @return
+ /// \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
@@ -194,46 +173,42 @@ public:
/// event. If this function consumes all of the bytes in the cache, it will
/// reset the \a eBroadcastBitReadThreadGotBytes event bit.
///
- /// @param[in] dst
+ /// \param[in] dst
/// A destination buffer that must be at least \a dst_len bytes
/// long.
///
- /// @param[in] dst_len
+ /// \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
+ /// \param[in] timeout
/// A timeout value or llvm::None for no timeout.
///
- /// @return
+ /// \return
/// The number of bytes actually read.
///
- /// @see size_t Connection::Read (void *, size_t);
- //------------------------------------------------------------------
+ /// \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, Status *error_ptr);
- //------------------------------------------------------------------
/// The actual write function that attempts to write to the communications
/// protocol.
///
/// Subclasses must override this function.
///
- /// @param[in] src
+ /// \param[in] src
/// A source buffer that must be at least \a src_len bytes
/// long.
///
- /// @param[in] src_len
+ /// \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
+ /// \return
/// The number of bytes actually Written.
- //------------------------------------------------------------------
size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
Status *error_ptr);
- //------------------------------------------------------------------
/// Sets the connection that it to be used by this class.
///
/// By making a communication class that uses different connections it
@@ -241,15 +216,13 @@ public:
/// connection without any interruption to the client. It also allows the
/// Communication class to be subclassed for packet based communication.
///
- /// @param[in] connection
+ /// \param[in] connection
/// A connection that this class will own and destroy.
///
- /// @see
+ /// \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:
///
@@ -265,60 +238,51 @@ public:
/// default action of caching the bytes and broadcasting a \b
/// eBroadcastBitReadThreadGotBytes event.
///
- /// @return
+ /// \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,
+ /// \see size_t Connection::Read (void *, size_t);
+ /// \see void Communication::AppendBytesToCache (const uint8_t * bytes,
/// size_t len, bool broadcast);
- //------------------------------------------------------------------
virtual bool StartReadThread(Status *error_ptr = nullptr);
- //------------------------------------------------------------------
/// Stops the read thread by cancelling it.
///
- /// @return
+ /// \return
/// \b True if the read thread was successfully canceled, \b
/// false otherwise.
- //------------------------------------------------------------------
virtual bool StopReadThread(Status *error_ptr = nullptr);
virtual bool JoinReadThread(Status *error_ptr = nullptr);
- //------------------------------------------------------------------
/// Checks if there is a currently running read thread.
///
- /// @return
+ /// \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
+ /// \param[in] comm_ptr
/// A pointer to an instance of this class.
///
- /// @return
+ /// \return
/// \b NULL.
///
- /// @see void Communication::ReadThreadGotBytes (const uint8_t *, size_t);
- //------------------------------------------------------------------
+ /// \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);
@@ -355,7 +319,6 @@ protected:
const Timeout<std::micro> &timeout,
lldb::ConnectionStatus &status, Status *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.
@@ -368,34 +331,31 @@ protected:
/// of the \a eBroadcastBitReadThreadGotBytes event by setting \a broadcast
/// to false.
///
- /// @param[in] src
+ /// \param[in] src
/// A source buffer that must be at least \a src_len bytes
/// long.
///
- /// @param[in] src_len
+ /// \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
+ /// \param[in] dst
/// A destination buffer that must be at least \a dst_len bytes
/// long.
///
- /// @param[in] dst_len
+ /// \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
+ /// \return
/// The number of bytes extracted from the data cache.
- //------------------------------------------------------------------
size_t GetCachedBytes(void *dst, size_t dst_len);
private:
diff --git a/include/lldb/Core/Debugger.h b/include/lldb/Core/Debugger.h
index 09f75ef0f8c68..8e608717a801b 100644
--- a/include/lldb/Core/Debugger.h
+++ b/include/lldb/Core/Debugger.h
@@ -1,9 +1,8 @@
//===-- Debugger.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -46,36 +45,26 @@
#include <stddef.h>
#include <stdio.h>
-namespace lldb_private {
-class Address;
+namespace llvm {
+class raw_ostream;
}
+
namespace lldb_private {
+class Address;
class CommandInterpreter;
-}
-namespace lldb_private {
class Process;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class Target;
-}
-namespace llvm {
-class raw_ostream;
-}
-namespace lldb_private {
+namespace repro {
+class DataRecorder;
+}
-//----------------------------------------------------------------------
-/// @class Debugger Debugger.h "lldb/Core/Debugger.h"
+/// \class Debugger Debugger.h "lldb/Core/Debugger.h"
/// A class to manage flag bits.
///
/// Provides a global root objects for the debugger core.
-//----------------------------------------------------------------------
class Debugger : public std::enable_shared_from_this<Debugger>,
public UserID,
@@ -106,7 +95,7 @@ public:
static lldb::DebuggerSP FindDebuggerWithID(lldb::user_id_t id);
static lldb::DebuggerSP
- FindDebuggerWithInstanceName(const ConstString &instance_name);
+ FindDebuggerWithInstanceName(ConstString instance_name);
static size_t GetNumDebuggers();
@@ -130,7 +119,10 @@ public:
lldb::StreamFileSP GetErrorFile() { return m_error_file_sp; }
- void SetInputFileHandle(FILE *fh, bool tranfer_ownership);
+ repro::DataRecorder *GetInputRecorder();
+
+ void SetInputFileHandle(FILE *fh, bool tranfer_ownership,
+ repro::DataRecorder *recorder = nullptr);
void SetOutputFileHandle(FILE *fh, bool tranfer_ownership);
@@ -145,10 +137,12 @@ public:
lldb::StreamSP GetAsyncErrorStream();
CommandInterpreter &GetCommandInterpreter() {
- assert(m_command_interpreter_ap.get());
- return *m_command_interpreter_ap;
+ assert(m_command_interpreter_up.get());
+ return *m_command_interpreter_up;
}
+ ScriptInterpreter *GetScriptInterpreter(bool can_create = true);
+
lldb::ListenerSP GetListener() { return m_listener_sp; }
// This returns the Debugger's scratch source manager. It won't be able to
@@ -162,16 +156,14 @@ public:
}
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
+ /// \return
/// A global shared target list.
- //------------------------------------------------------------------
TargetList &GetTargetList() { return m_target_list; }
PlatformList &GetPlatformList() { return m_platform_list; }
@@ -180,10 +172,8 @@ public:
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);
@@ -222,9 +212,7 @@ public:
void SetLoggingCallback(lldb::LogOutputCallback log_callback, void *baton);
- //----------------------------------------------------------------------
// Properties Functions
- //----------------------------------------------------------------------
enum StopDisassemblyType {
eStopDisassemblyTypeNever = 0,
eStopDisassemblyTypeNoDebugInfo,
@@ -303,7 +291,7 @@ public:
bool GetNotifyVoid() const;
- const ConstString &GetInstanceName() { return m_instance_name; }
+ ConstString GetInstanceName() { return m_instance_name; }
bool LoadPlugin(const FileSpec &spec, Status &error);
@@ -371,6 +359,9 @@ protected:
lldb::StreamFileSP m_output_file_sp;
lldb::StreamFileSP m_error_file_sp;
+ /// Used for shadowing the input file when capturing a reproducer.
+ repro::DataRecorder *m_input_recorder;
+
lldb::BroadcasterManagerSP m_broadcaster_manager_sp; // The debugger acts as a
// broadcaster manager of
// last resort.
@@ -382,7 +373,7 @@ protected:
PlatformList m_platform_list;
lldb::ListenerSP m_listener_sp;
- std::unique_ptr<SourceManager> m_source_manager_ap; // This is a scratch
+ std::unique_ptr<SourceManager> m_source_manager_up; // This is a scratch
// source manager that we
// return if we have no
// targets.
@@ -391,7 +382,10 @@ protected:
// this debugger used this
// shared
// source file cache.
- std::unique_ptr<CommandInterpreter> m_command_interpreter_ap;
+ std::unique_ptr<CommandInterpreter> m_command_interpreter_up;
+
+ lldb::ScriptInterpreterSP m_script_interpreter_sp;
+ std::recursive_mutex m_script_interpreter_mutex;
IOHandlerStack m_input_reader_stack;
llvm::StringMap<std::weak_ptr<llvm::raw_ostream>> m_log_streams;
@@ -406,9 +400,7 @@ protected:
lldb::ListenerSP m_forward_listener_sp;
llvm::once_flag m_clear_once;
- //----------------------------------------------------------------------
// Events for m_sync_broadcaster
- //----------------------------------------------------------------------
enum {
eBroadcastBitEventThreadIsListening = (1 << 0),
};
diff --git a/include/lldb/Core/Disassembler.h b/include/lldb/Core/Disassembler.h
index 7cec837e71f8b..ba9ca87832f6f 100644
--- a/include/lldb/Core/Disassembler.h
+++ b/include/lldb/Core/Disassembler.h
@@ -1,9 +1,8 @@
//===-- Disassembler.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,41 +38,21 @@
#include <stdint.h>
#include <stdio.h>
-namespace lldb_private {
-class AddressRange;
+namespace llvm {
+template <typename T> class SmallVectorImpl;
}
+
namespace lldb_private {
+class AddressRange;
class DataExtractor;
-}
-namespace lldb_private {
class Debugger;
-}
-namespace lldb_private {
class Disassembler;
-}
-namespace lldb_private {
class Module;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class SymbolContextList;
-}
-namespace lldb_private {
class Target;
-}
-namespace lldb_private {
struct RegisterInfo;
-}
-namespace llvm {
-template <typename T> class SmallVectorImpl;
-}
-
-namespace lldb_private {
class Instruction {
public:
@@ -110,38 +89,37 @@ public:
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
+ /// \param[in] s
/// The Stream to add the text to.
///
- /// @param[in] show_address
+ /// \param[in] show_address
/// Whether the address (using disassembly_addr_format_spec formatting)
/// should be printed.
///
- /// @param[in] show_bytes
+ /// \param[in] show_bytes
/// Whether the bytes of the assembly instruction should be printed.
///
- /// @param[in] max_opcode_byte_size
+ /// \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
+ /// \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
+ /// \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
+ /// \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
@@ -150,17 +128,16 @@ public:
/// the InstructionList.
/// Only needed if show_address is true.
///
- /// @param[in] disassembly_addr_format
+ /// \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
+ /// \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,
@@ -293,8 +270,32 @@ public:
lldb::InstructionSP GetInstructionAtIndex(size_t idx) const;
+ //------------------------------------------------------------------
+ /// Get the index of the next branch instruction.
+ ///
+ /// Given a list of instructions, find the next branch instruction
+ /// in the list by returning an index.
+ ///
+ /// @param[in] start
+ /// The instruction index of the first instruction to check.
+ ///
+ /// @param[in] target
+ /// A LLDB target object that is used to resolve addresses.
+ ///
+ /// @param[in] ignore_calls
+ /// It true, then fine the first branch instruction that isn't
+ /// a function call (a branch that calls and returns to the next
+ /// instruction). If false, find the instruction index of any
+ /// branch in the list.
+ ///
+ /// @return
+ /// The instruction index of the first branch that is at or past
+ /// \a start. Returns UINT32_MAX if no matching branches are
+ /// found.
+ //------------------------------------------------------------------
uint32_t GetIndexOfNextBranchInstruction(uint32_t start,
- Target &target) const;
+ Target &target,
+ bool ignore_calls) const;
uint32_t GetIndexOfInstructionAtLoadAddress(lldb::addr_t load_addr,
Target &target);
@@ -414,7 +415,7 @@ public:
static bool
Disassemble(Debugger &debugger, const ArchSpec &arch, const char *plugin_name,
const char *flavor, const ExecutionContext &exe_ctx,
- const ConstString &name, Module *module,
+ ConstString name, Module *module,
uint32_t num_instructions, bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines, uint32_t options, Stream &strm);
@@ -424,9 +425,7 @@ public:
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;
@@ -536,18 +535,14 @@ protected:
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);
};
diff --git a/include/lldb/Core/DumpDataExtractor.h b/include/lldb/Core/DumpDataExtractor.h
index 88446d48fa646..2a9d778e0a6a8 100644
--- a/include/lldb/Core/DumpDataExtractor.h
+++ b/include/lldb/Core/DumpDataExtractor.h
@@ -1,9 +1,8 @@
//===-- DumpDataExtractor.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,6 @@ class DataExtractor;
class ExecutionContextScope;
class Stream;
-//------------------------------------------------------------------
/// Dumps \a item_count objects into the stream \a s.
///
/// Dumps \a item_count objects using \a item_format, each of which
@@ -35,31 +33,31 @@ class Stream;
/// same start offset, format and size, yet differing \a
/// item_bit_size and \a item_bit_offset values.
///
-/// @param[in] s
+/// \param[in] s
/// The stream to dump the output to. This value can not be nullptr.
///
-/// @param[in] offset
+/// \param[in] offset
/// The offset into the data at which to start dumping.
///
-/// @param[in] item_format
+/// \param[in] item_format
/// The format to use when dumping each item.
///
-/// @param[in] item_byte_size
+/// \param[in] item_byte_size
/// The byte size of each item.
///
-/// @param[in] item_count
+/// \param[in] item_count
/// The number of items to dump.
///
-/// @param[in] num_per_line
+/// \param[in] num_per_line
/// The number of items to display on each line.
///
-/// @param[in] base_addr
+/// \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
+/// \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
@@ -68,7 +66,7 @@ class Stream;
/// exist within the same integer value. If the items being
/// displayed are not bitfields, this value should be zero.
///
-/// @param[in] item_bit_offset
+/// \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.
@@ -78,9 +76,8 @@ class Stream;
/// same integer value. If the items being displayed are not
/// bitfields, this value should be zero.
///
-/// @return
+/// \return
/// The offset at which dumping ended.
-//------------------------------------------------------------------
lldb::offset_t
DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset,
lldb::Format item_format, size_t item_byte_size,
diff --git a/include/lldb/Core/DumpRegisterValue.h b/include/lldb/Core/DumpRegisterValue.h
index bc4860fbc0e5a..443fdb34266ae 100644
--- a/include/lldb/Core/DumpRegisterValue.h
+++ b/include/lldb/Core/DumpRegisterValue.h
@@ -1,9 +1,8 @@
//===-- DumpRegisterValue.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/EmulateInstruction.h b/include/lldb/Core/EmulateInstruction.h
index 5198f3eac9221..6b19c17e5491c 100644
--- a/include/lldb/Core/EmulateInstruction.h
+++ b/include/lldb/Core/EmulateInstruction.h
@@ -1,9 +1,8 @@
//===-- EmulateInstruction.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,29 +23,16 @@
#include <stddef.h>
#include <stdint.h>
+
namespace lldb_private {
class OptionValueDictionary;
-}
-namespace lldb_private {
class RegisterContext;
-}
-namespace lldb_private {
class RegisterValue;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class Target;
-}
-namespace lldb_private {
class UnwindPlan;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class EmulateInstruction EmulateInstruction.h
+/// \class EmulateInstruction EmulateInstruction.h
/// "lldb/Core/EmulateInstruction.h"
/// A class that allows emulation of CPU opcodes.
///
@@ -103,7 +89,6 @@ namespace lldb_private {
/// 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 {
public:
@@ -368,9 +353,7 @@ public:
~EmulateInstruction() override = default;
- //----------------------------------------------------------------------
// Mandatory overrides
- //----------------------------------------------------------------------
virtual bool
SupportsEmulatingInstructionsOfType(InstructionType inst_type) = 0;
@@ -390,9 +373,7 @@ public:
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);
@@ -401,9 +382,7 @@ public:
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,
@@ -415,9 +394,7 @@ public:
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);
@@ -512,18 +489,16 @@ public:
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;
+ void *m_baton = nullptr;
+ ReadMemoryCallback m_read_mem_callback = &ReadMemoryDefault;
+ WriteMemoryCallback m_write_mem_callback = &WriteMemoryDefault;
+ ReadRegisterCallback m_read_reg_callback = &ReadRegisterDefault;
+ WriteRegisterCallback m_write_reg_callback = &WriteRegisterDefault;
+ lldb::addr_t m_addr = LLDB_INVALID_ADDRESS;
Opcode m_opcode;
private:
- //------------------------------------------------------------------
// For EmulateInstruction only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(EmulateInstruction);
};
diff --git a/include/lldb/Core/FileLineResolver.h b/include/lldb/Core/FileLineResolver.h
index 6de99bc0c4dc9..1967ed58cd3b3 100644
--- a/include/lldb/Core/FileLineResolver.h
+++ b/include/lldb/Core/FileLineResolver.h
@@ -1,9 +1,8 @@
//===-- FileLineResolver.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,18 +18,11 @@
namespace lldb_private {
class Address;
-}
-namespace lldb_private {
class Stream;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h"
+/// \class FileLineResolver FileLineResolver.h "lldb/Core/FileLineResolver.h"
/// 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 {
public:
diff --git a/include/lldb/Core/FileSpecList.h b/include/lldb/Core/FileSpecList.h
index db6490ef71339..79623ef1fdca3 100644
--- a/include/lldb/Core/FileSpecList.h
+++ b/include/lldb/Core/FileSpecList.h
@@ -1,9 +1,8 @@
//===-- FileSpecList.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,165 +18,138 @@
namespace lldb_private {
class Stream;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h"
+/// \class FileSpecList FileSpecList.h "lldb/Core/FileSpecList.h"
/// A file collection class.
///
/// A class that contains a mutable list of FileSpec objects.
-//----------------------------------------------------------------------
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);
+ FileSpecList(const FileSpecList &rhs) = default;
+
+ /// Move constructor
+ FileSpecList(FileSpecList &&rhs) = default;
+
+ /// Initialize this object from a vector of FileSpecs
+ FileSpecList(std::vector<FileSpec> &&rhs) : m_files(std::move(rhs)) {}
- //------------------------------------------------------------------
/// Destructor.
- //------------------------------------------------------------------
~FileSpecList();
- //------------------------------------------------------------------
/// Assignment operator.
///
/// Replace the file list in this object with the file list from \a rhs.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// A file list object to copy.
///
- /// @return
+ /// \return
/// A const reference to this object.
- //------------------------------------------------------------------
- const FileSpecList &operator=(const FileSpecList &rhs);
+ FileSpecList &operator=(const FileSpecList &rhs) = default;
+
+ /// Move-assignment operator.
+ FileSpecList &operator=(FileSpecList &&rhs) = default;
- //------------------------------------------------------------------
/// Append a FileSpec object to the list.
///
/// Appends \a file to the end of the file list.
///
- /// @param[in] file
+ /// \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
+ /// \param[in] file
/// A new file to append to this file list.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] idx
/// An index into the file list.
///
- /// @param[in] file
+ /// \param[in] file
/// The file specification to search for.
///
- /// @param[in] full
+ /// \param[in] full
/// Should FileSpec::Equal be called with "full" true or false.
///
- /// @return
+ /// \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) 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
+ /// \param[in] idx
/// An index into the file list.
///
- /// @return
+ /// \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
+ /// \param[in] idx
/// An index into the file list.
///
- /// @return
+ /// \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
+ /// \return
/// The number of bytes that this object occupies in memory.
///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
+ /// \see ConstString::StaticMemorySize ()
size_t MemorySize() const;
bool IsEmpty() const { return m_files.empty(); }
- //------------------------------------------------------------------
/// Get the number of files in the file list.
///
- /// @return
+ /// \return
/// The number of files in the file spec list.
- //------------------------------------------------------------------
size_t GetSize() const;
bool Insert(size_t idx, const FileSpec &file) {
diff --git a/include/lldb/Core/FormatEntity.h b/include/lldb/Core/FormatEntity.h
index b58f3b104e46f..634d9df2ad839 100644
--- a/include/lldb/Core/FormatEntity.h
+++ b/include/lldb/Core/FormatEntity.h
@@ -1,9 +1,8 @@
//===-- FormatEntity.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,20 +23,10 @@
namespace lldb_private {
class Address;
-}
-namespace lldb_private {
class ExecutionContext;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class StringList;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class ValueObject;
}
namespace llvm {
@@ -52,7 +41,7 @@ public:
Invalid,
ParentNumber,
ParentString,
- InsertString,
+ EscapeCode,
Root,
String,
Scope,
@@ -111,14 +100,10 @@ public:
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,
@@ -216,14 +201,12 @@ public:
static size_t AutoComplete(lldb_private::CompletionRequest &request);
- //----------------------------------------------------------------------
// 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);
diff --git a/include/lldb/Core/Highlighter.h b/include/lldb/Core/Highlighter.h
index 220557c1f032b..88d3bb3a3cd1a 100644
--- a/include/lldb/Core/Highlighter.h
+++ b/include/lldb/Core/Highlighter.h
@@ -1,9 +1,8 @@
//===-- Highlighter.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,17 +18,13 @@
namespace lldb_private {
-//----------------------------------------------------------------------
/// Represents style that the highlighter should apply to the given source code.
/// Stores information about how every kind of token should be annotated.
-//----------------------------------------------------------------------
struct HighlightStyle {
- //----------------------------------------------------------------------
/// A pair of strings that should be placed around a certain token. Usually
/// stores color codes in these strings (the suffix string is often used for
/// resetting the terminal attributes back to normal).
- //----------------------------------------------------------------------
class ColorStyle {
std::string m_prefix;
std::string m_suffix;
@@ -48,8 +43,8 @@ struct HighlightStyle {
void Apply(Stream &s, llvm::StringRef value) const;
/// Sets the prefix and suffix strings.
- /// @param prefix
- /// @param suffix
+ /// \param prefix
+ /// \param suffix
void Set(llvm::StringRef prefix, llvm::StringRef suffix);
};
@@ -84,9 +79,7 @@ struct HighlightStyle {
/// Matches '(' or ')'
ColorStyle parentheses;
- //-----------------------------------------------------------------------
// C language specific options
- //-----------------------------------------------------------------------
/// Matches directives to a preprocessor (if the language has any).
ColorStyle pp_directive;
@@ -95,9 +88,7 @@ struct HighlightStyle {
static HighlightStyle MakeVimStyle();
};
-//----------------------------------------------------------------------
/// Annotates source code with color attributes.
-//----------------------------------------------------------------------
class Highlighter {
public:
Highlighter() = default;
diff --git a/include/lldb/Core/IOHandler.h b/include/lldb/Core/IOHandler.h
index 4bd577390b2ca..b7180675cf4e4 100644
--- a/include/lldb/Core/IOHandler.h
+++ b/include/lldb/Core/IOHandler.h
@@ -1,9 +1,8 @@
//===-- IOHandler.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Flags.h"
#include "lldb/Utility/Predicate.h"
+#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StringList.h"
#include "lldb/lldb-defines.h"
@@ -59,7 +59,8 @@ public:
IOHandler(Debugger &debugger, IOHandler::Type type,
const lldb::StreamFileSP &input_sp,
const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp, uint32_t flags);
+ const lldb::StreamFileSP &error_sp, uint32_t flags,
+ repro::DataRecorder *data_recorder);
virtual ~IOHandler();
@@ -137,23 +138,19 @@ public:
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);
@@ -170,6 +167,7 @@ protected:
lldb::StreamFileSP m_input_sp;
lldb::StreamFileSP m_output_sp;
lldb::StreamFileSP m_error_sp;
+ repro::DataRecorder *m_data_recorder;
Predicate<bool> m_popped;
Flags m_flags;
Type m_type;
@@ -181,14 +179,12 @@ 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 };
@@ -198,7 +194,7 @@ public:
virtual ~IOHandlerDelegate() = default;
- virtual void IOHandlerActivated(IOHandler &io_handler) {}
+ virtual void IOHandlerActivated(IOHandler &io_handler, bool interactive) {}
virtual void IOHandlerDeactivated(IOHandler &io_handler) {}
@@ -209,37 +205,34 @@ public:
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
+ /// \param[in] io_handler
/// The IOHandler that responsible for input.
///
- /// @param[in] lines
+ /// \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
+ /// \param[in] cursor_position
/// The number of characters preceding the cursor on the final
/// line at the time.
///
- /// @return
+ /// \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
@@ -247,29 +240,26 @@ public:
/// "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
+ /// \param[in] io_handler
/// The IOHandler that responsible for updating the lines.
///
- /// @param[in] lines
+ /// \param[in] lines
/// The current multi-line content. May be altered to provide
/// alternative input when complete.
///
- /// @return
+ /// \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
@@ -285,24 +275,20 @@ public:
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
};
-//----------------------------------------------------------------------
// 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,
@@ -344,7 +330,8 @@ public:
uint32_t line_number_start, // If non-zero show line numbers
// starting at
// 'line_number_start'
- IOHandlerDelegate &delegate);
+ IOHandlerDelegate &delegate,
+ repro::DataRecorder *data_recorder);
IOHandlerEditline(Debugger &debugger, IOHandler::Type type,
const lldb::StreamFileSP &input_sp,
@@ -356,7 +343,8 @@ public:
uint32_t line_number_start, // If non-zero show line numbers
// starting at
// 'line_number_start'
- IOHandlerDelegate &delegate);
+ IOHandlerDelegate &delegate,
+ repro::DataRecorder *data_recorder);
IOHandlerEditline(Debugger &, IOHandler::Type, const char *, const char *,
const char *, bool, bool, uint32_t,
@@ -436,7 +424,7 @@ private:
protected:
#ifndef LLDB_DISABLE_LIBEDIT
- std::unique_ptr<Editline> m_editline_ap;
+ std::unique_ptr<Editline> m_editline_up;
#endif
IOHandlerDelegate &m_delegate;
std::string m_prompt;
diff --git a/include/lldb/Core/IOStreamMacros.h b/include/lldb/Core/IOStreamMacros.h
index 2562f179ca5d7..45bde88f94410 100644
--- a/include/lldb/Core/IOStreamMacros.h
+++ b/include/lldb/Core/IOStreamMacros.h
@@ -1,9 +1,8 @@
//===-- IOStreamMacros.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/LoadedModuleInfoList.h b/include/lldb/Core/LoadedModuleInfoList.h
index 5ef0f8929b890..f7f83604fc1a8 100644
--- a/include/lldb/Core/LoadedModuleInfoList.h
+++ b/include/lldb/Core/LoadedModuleInfoList.h
@@ -1,9 +1,8 @@
//===-- LoadedModuleInfoList.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/Mangled.h b/include/lldb/Core/Mangled.h
index 12edf8200e436..fb52afd6ed346 100644
--- a/include/lldb/Core/Mangled.h
+++ b/include/lldb/Core/Mangled.h
@@ -1,9 +1,8 @@
//===-- Mangled.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,8 +22,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Mangled Mangled.h "lldb/Core/Mangled.h"
+/// \class Mangled Mangled.h "lldb/Core/Mangled.h"
/// A class that handles mangled names.
///
/// Designed to handle mangled names. The demangled version of any names will
@@ -34,7 +32,6 @@ namespace lldb_private {
/// class for their mangled names. Uniqued string pools are used for the
/// mangled, demangled, and token string values to allow for faster
/// comparisons and for efficient memory use.
-//----------------------------------------------------------------------
class Mangled {
public:
enum NamePreference {
@@ -49,188 +46,156 @@ public:
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
+ /// \param[in] name
/// The already const name to copy into this object.
///
- /// @param[in] is_mangled
+ /// \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(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
+ /// \param[in] name
/// The already const name to copy into this object.
- //----------------------------------------------------------------------
- explicit Mangled(const ConstString &name);
+ explicit Mangled(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
+ /// \code
/// Mangled mangled(...);
/// if (mangled)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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
+ /// \code
/// Mangled mangled(...);
/// if (!mangled)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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
+ /// \param[in] lhs
/// A const reference to the Left Hand Side object to compare.
///
- /// @param[in] rhs
+ /// \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
- //----------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \param[in] s
/// The stream to which to dump the object description.
- //----------------------------------------------------------------------
void DumpDebug(Stream *s) const;
- //----------------------------------------------------------------------
/// Demangled name get accessor.
///
- /// @return
+ /// \return
/// A const reference to the demangled name string object.
- //----------------------------------------------------------------------
- const ConstString &GetDemangledName(lldb::LanguageType language) const;
+ ConstString GetDemangledName(lldb::LanguageType language) const;
- //----------------------------------------------------------------------
/// Display demangled name get accessor.
///
- /// @return
+ /// \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 SetDemangledName(ConstString name) { m_demangled = name; }
- void SetMangledName(const ConstString &name) { m_mangled = name; }
+ void SetMangledName(ConstString name) { m_mangled = name; }
- //----------------------------------------------------------------------
/// Mangled name get accessor.
///
- /// @return
+ /// \return
/// A reference to the mangled name string object.
- //----------------------------------------------------------------------
ConstString &GetMangledName() { return m_mangled; }
- //----------------------------------------------------------------------
/// Mangled name get accessor.
///
- /// @return
+ /// \return
/// A const reference to the mangled name string object.
- //----------------------------------------------------------------------
- const ConstString &GetMangledName() const { return m_mangled; }
+ ConstString GetMangledName() const { return m_mangled; }
- //----------------------------------------------------------------------
/// Best name get accessor.
///
- /// @param[in] preference
+ /// \param[in] preference
/// Which name would you prefer to get?
///
- /// @return
+ /// \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
+ /// \param[in] name
/// A name to match against both strings.
///
- /// @return
+ /// \return
/// \b True if \a name matches either name, \b false otherwise.
- //----------------------------------------------------------------------
- bool NameMatches(const ConstString &name, lldb::LanguageType language) const {
+ bool NameMatches(ConstString name, lldb::LanguageType language) const {
if (m_mangled == name)
return true;
return GetDemangledName(language) == name;
@@ -238,47 +203,40 @@ public:
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
+ /// \return
/// The number of bytes that this object occupies in memory.
///
- /// @see ConstString::StaticMemorySize ()
- //----------------------------------------------------------------------
+ /// \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
+ /// \param[in] name
/// The already const version of the name for this object.
///
- /// @param[in] is_mangled
+ /// \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);
+ void SetValue(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
+ /// \param[in] name
/// The already const version of the name for this object.
- //----------------------------------------------------------------------
- void SetValue(const ConstString &name);
+ void SetValue(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
@@ -290,16 +248,14 @@ public:
/// aren't mangled and it isn't clear what language the name represents
/// (there will be no mangled name).
///
- /// @return
+ /// \return
/// The language for the mangled/demangled name, eLanguageTypeUnknown
/// if there is no mangled or demangled counterpart.
- //----------------------------------------------------------------------
lldb::LanguageType GuessLanguage() const;
/// Function signature for filtering mangled names.
using SkipMangledNameFn = bool(llvm::StringRef, ManglingScheme);
- //----------------------------------------------------------------------
/// Trigger explicit demangling to obtain rich mangling information. This is
/// optimized for batch processing while populating a name index. To get the
/// pure demangled name string for a single entity, use GetDemangledName()
@@ -312,24 +268,21 @@ public:
/// This function is thread-safe when used with different \a context
/// instances in different threads.
///
- /// @param[in] context
+ /// \param[in] context
/// The context for this function. A single instance can be stack-
/// allocated in the caller's frame and used for multiple calls.
///
- /// @param[in] skip_mangled_name
+ /// \param[in] skip_mangled_name
/// A filtering function for skipping entities based on name and mangling
/// scheme. This can be null if unused.
///
- /// @return
+ /// \return
/// True on success, false otherwise.
- //----------------------------------------------------------------------
bool DemangleWithRichManglingInfo(RichManglingContext &context,
SkipMangledNameFn *skip_mangled_name);
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
diff --git a/include/lldb/Core/MappedHash.h b/include/lldb/Core/MappedHash.h
index 8d9a91e690793..7dc9b5be34657 100644
--- a/include/lldb/Core/MappedHash.h
+++ b/include/lldb/Core/MappedHash.h
@@ -1,9 +1,8 @@
//===-- MappedHash.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/Module.h b/include/lldb/Core/Module.h
index 270a401172fac..544895ea89e9e 100644
--- a/include/lldb/Core/Module.h
+++ b/include/lldb/Core/Module.h
@@ -1,9 +1,8 @@
//===-- Module.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,60 +39,24 @@
namespace lldb_private {
class CompilerDeclContext;
-}
-namespace lldb_private {
class Function;
-}
-namespace lldb_private {
class Log;
-}
-namespace lldb_private {
class ObjectFile;
-}
-namespace lldb_private {
class RegularExpression;
-}
-namespace lldb_private {
class SectionList;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class Symbol;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class SymbolContextList;
-}
-namespace lldb_private {
class SymbolFile;
-}
-namespace lldb_private {
class SymbolVendor;
-}
-namespace lldb_private {
class Symtab;
-}
-namespace lldb_private {
class Target;
-}
-namespace lldb_private {
class TypeList;
-}
-namespace lldb_private {
class TypeMap;
-}
-namespace lldb_private {
class VariableList;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Module Module.h "lldb/Core/Module.h"
+/// \class Module Module.h "lldb/Core/Module.h"
/// A class that describes an executable image and its associated
/// object and symbol files.
///
@@ -108,7 +71,6 @@ namespace lldb_private {
/// Module::GetSymbolVendor() is called.
///
/// The module will parse more detailed information as more queries are made.
-//----------------------------------------------------------------------
class Module : public std::enable_shared_from_this<Module>,
public SymbolContextScope {
public:
@@ -124,30 +86,28 @@ public:
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
+ /// \param[in] file_spec
/// The file specification for the on disk representation of
/// this executable image.
///
- /// @param[in] arch
+ /// \param[in] arch
/// The architecture to set as the current architecture in
/// this module.
///
- /// @param[in] object_name
+ /// \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
+ /// \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,
@@ -164,25 +124,26 @@ public:
lldb::ModuleSP module_sp(new Module());
module_sp->m_objfile_sp =
std::make_shared<ObjFilePlugin>(module_sp, std::forward<Args>(args)...);
-
- // Once we get the object file, update our module with the object file's
- // architecture since it might differ in vendor/os if some parts were
- // unknown.
- if (ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture()) {
- module_sp->m_arch = arch;
- return module_sp;
- }
- return nullptr;
+ module_sp->m_did_load_objfile.store(true, std::memory_order_relaxed);
+
+ // Once we get the object file, set module ArchSpec to the one we get from
+ // the object file. If the object file does not have an architecture, we
+ // consider the creation a failure.
+ ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture();
+ if (!arch)
+ return nullptr;
+ module_sp->m_arch = arch;
+
+ // Also copy the object file's FileSpec.
+ module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec();
+ return module_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.
///
@@ -191,23 +152,23 @@ public:
/// address for all top level sections to be the section file address +
/// offset.
///
- /// @param[in] target
+ /// \param[in] target
/// The target in which to apply the section load addresses.
///
- /// @param[in] value
+ /// \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
+ /// \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
+ /// \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
@@ -216,18 +177,15 @@ public:
/// be false and no module updated notification will need to
/// be sent out.
///
- /// @return
+ /// \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*)
+ /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void CalculateSymbolContext(SymbolContext *sc) override;
lldb::ModuleSP CalculateSymbolContextModule() override;
@@ -236,7 +194,6 @@ public:
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
@@ -252,12 +209,10 @@ public:
/// There are many places where logging wants to log this fully qualified
/// specification, so we centralize this functionality here.
///
- /// @return
+ /// \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
@@ -265,39 +220,34 @@ public:
/// 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
+ /// \param[in] s
/// The stream to which to dump the object description.
- //------------------------------------------------------------------
void Dump(Stream *s);
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void DumpSymbolContext(Stream *s) override;
- //------------------------------------------------------------------
/// Find a symbol in the object file's symbol table.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the symbol that we are looking for.
///
- /// @param[in] symbol_type
+ /// \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
+ /// \return
/// Returns a valid symbol pointer if a symbol was found,
/// nullptr otherwise.
- //------------------------------------------------------------------
const Symbol *FindFirstSymbolWithNameAndType(
- const ConstString &name,
+ ConstString name,
lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
- size_t FindSymbolsWithNameAndType(const ConstString &name,
+ size_t FindSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list);
@@ -305,132 +255,123 @@ public:
lldb::SymbolType symbol_type,
SymbolContextList &sc_list);
- //------------------------------------------------------------------
/// Find a function symbols in the object file's symbol table.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the symbol that we are looking for.
///
- /// @param[in] name_type_mask
+ /// \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
+ /// \param[out] sc_list
/// A list to append any matching symbol contexts to.
///
- /// @return
+ /// \return
/// The number of symbol contexts that were added to \a sc_list
- //------------------------------------------------------------------
- size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
+ size_t FindFunctionSymbols(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
+ /// \param[in] path
/// The name of the function we are looking for.
///
- /// @param[in] append
+ /// \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
+ /// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
- /// @return
+ /// \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
+ /// \param[in] name
/// The name of the compile unit we are looking for.
///
- /// @param[in] namespace_decl
+ /// \param[in] namespace_decl
/// If valid, a namespace to search in.
///
- /// @param[in] name_type_mask
+ /// \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
+ /// \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
+ /// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
- /// @return
+ /// \return
/// The number of matches added to \a sc_list.
- //------------------------------------------------------------------
- size_t FindFunctions(const ConstString &name,
+ size_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType 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
+ /// \param[in] regex
/// A regular expression to use when matching the name.
///
- /// @param[in] append
+ /// \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
+ /// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
- /// @return
+ /// \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
+ /// \param[in] target_sp
/// The target the addresses are desired for.
///
- /// @param[in] file
+ /// \param[in] file
/// Source file to locate.
///
- /// @param[in] line
+ /// \param[in] line
/// Source line to locate.
///
- /// @param[in] function
+ /// \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
+ /// \param[out] output_local
/// All matching addresses within 'function'
///
- /// @param[out] output_extern
+ /// \param[out] output_extern
/// All matching addresses not within 'function'
void FindAddressesForLine(const lldb::TargetSP target_sp,
const FileSpec &file, uint32_t line,
@@ -438,50 +379,45 @@ public:
std::vector<Address> &output_local,
std::vector<Address> &output_extern);
- //------------------------------------------------------------------
/// Find global and static variables by name.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the global or static variable we are looking
/// for.
///
- /// @param[in] parent_decl_ctx
+ /// \param[in] parent_decl_ctx
/// If valid, a decl context that results must exist within
///
- /// @param[in] max_matches
+ /// \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
+ /// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
- /// @return
+ /// \return
/// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t FindGlobalVariables(const ConstString &name,
+ size_t FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, VariableList &variable_list);
- //------------------------------------------------------------------
/// Find global and static variables by regular expression.
///
- /// @param[in] regex
+ /// \param[in] regex
/// A regular expression to use when matching the name.
///
- /// @param[in] max_matches
+ /// \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
+ /// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
- /// @return
+ /// \return
/// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
size_t FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
VariableList &variable_list);
- //------------------------------------------------------------------
/// Find types by name.
///
/// Type lookups in modules go through the SymbolVendor (which will use one
@@ -499,74 +435,66 @@ public:
/// have to specify complete scoping on all expressions, but it also allows
/// for exact matching when required.
///
- /// @param[in] type_name
+ /// \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
+ /// \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
+ /// \param[out] type_list
/// A type list gets populated with any matches.
///
- /// @return
+ /// \return
/// The number of matches added to \a type_list.
- //------------------------------------------------------------------
size_t
- FindTypes(const ConstString &type_name, bool exact_match, size_t max_matches,
+ FindTypes(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);
+ 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] type_name
+ /// \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
+ /// \param[in] namespace_decl
/// The namespace declaration that this type must exist in.
///
- /// @param[out] type_list
+ /// \param[out] type_list
/// A type list gets populated with any matches.
///
- /// @return
+ /// \return
/// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t FindTypesInNamespace(const ConstString &type_name,
+ size_t FindTypesInNamespace(ConstString type_name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, TypeList &type_list);
- //------------------------------------------------------------------
/// Get const accessor for the module architecture.
///
- /// @return
+ /// \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
+ /// \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
@@ -577,9 +505,8 @@ public:
/// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib" The
/// file could also be cached in a local developer kit directory.
///
- /// @return
+ /// \return
/// A const reference to the file specification object.
- //------------------------------------------------------------------
const FileSpec &GetPlatformFileSpec() const {
if (m_platform_file)
return m_platform_file;
@@ -614,63 +541,54 @@ public:
m_mod_time = mod_time;
}
- //------------------------------------------------------------------
/// Tells whether this module is capable of being the main executable for a
/// process.
///
- /// @return
+ /// \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
+ /// \param[in] target
/// The target to check whether this is loaded in.
///
- /// @return
+ /// \return
/// \b true if it is, \b false otherwise.
- //------------------------------------------------------------------
bool IsLoadedInTarget(Target *target);
bool LoadScriptingResourceInTarget(Target *target, Status &error,
Stream *feedback_stream = nullptr);
- //------------------------------------------------------------------
/// Get the number of compile units for this module.
///
- /// @return
+ /// \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;
+ 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
+ /// \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.
@@ -678,12 +596,10 @@ public:
/// If the symbol vendor has not been loaded yet, this function will return
/// the section list for the object file.
///
- /// @return
+ /// \return
/// Unified module section list.
- //------------------------------------------------------------------
virtual SectionList *GetSectionList();
- //------------------------------------------------------------------
/// Notify the module that the file addresses for the Sections have been
/// updated.
///
@@ -691,12 +607,23 @@ public:
/// 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();
+ /// Returns a reference to the UnwindTable for this Module
+ ///
+ /// The UnwindTable contains FuncUnwinders objects for any function in this
+ /// Module. 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 module. If this object has no
+ /// associated object file, an empty UnwindTable is returned.
+ UnwindTable &GetUnwindTable();
+
llvm::VersionTuple GetVersion();
- //------------------------------------------------------------------
/// Load an object file from memory.
///
/// If available, the size of the object file in memory may be passed to
@@ -705,54 +632,46 @@ public:
/// enable the ObjectFile plugins to read the header of the object file
/// without going back to the process.
///
- /// @return
+ /// \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, Status &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
+ /// \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
+ /// \return
/// A valid type list pointer, or nullptr if there is no valid
/// symbol vendor for this module.
- //------------------------------------------------------------------
TypeList *GetTypeList();
- //------------------------------------------------------------------
/// Get a reference 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
+ /// \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.
///
@@ -763,12 +682,10 @@ public:
/// 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
@@ -782,10 +699,10 @@ public:
/// line entry. Use the return value to determine which of these properties
/// have been modified.
///
- /// @param[in] so_addr
+ /// \param[in] so_addr
/// A load address to resolve.
///
- /// @param[in] resolve_scope
+ /// \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
@@ -794,24 +711,22 @@ public:
/// eSymbolContextModule, and eSymbolContextFunction requires
/// eSymbolContextSymbol.
///
- /// @param[out] sc
+ /// \param[out] sc
/// The SymbolContext that is modified based on symbol resolution.
///
- /// @param[in] resolve_tail_call_address
+ /// \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
+ /// \return
/// The scope that has been resolved (see SymbolContext::Scope).
///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
+ /// \see SymbolContext::Scope
uint32_t ResolveSymbolContextForAddress(
const Address &so_addr, lldb::SymbolContextItem 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
@@ -823,40 +738,38 @@ public:
/// to only what is needed -- typically the module, compile unit, line table
/// and line table entry are sufficient.
///
- /// @param[in] file_path
+ /// \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
+ /// \param[in] line
/// The source line to match, or zero if just the compile unit
/// should be resolved.
///
- /// @param[in] check_inlines
+ /// \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
+ /// \param[in] resolve_scope
/// The scope that should be resolved (see
/// SymbolContext::Scope).
///
- /// @param[out] sc_list
+ /// \param[out] sc_list
/// A symbol context list that gets matching symbols contexts
/// appended to.
///
- /// @return
+ /// \return
/// The number of matches that were added to \a sc_list.
///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
+ /// \see SymbolContext::Scope
uint32_t ResolveSymbolContextForFilePath(
const char *file_path, uint32_t line, bool check_inlines,
lldb::SymbolContextItem 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
@@ -868,42 +781,41 @@ public:
/// to only what is needed -- typically the module, compile unit, line table
/// and line table entry are sufficient.
///
- /// @param[in] file_spec
+ /// \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
+ /// \param[in] line
/// The source line to match, or zero if just the compile unit
/// should be resolved.
///
- /// @param[in] check_inlines
+ /// \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
+ /// \param[in] resolve_scope
/// The scope that should be resolved (see
/// SymbolContext::Scope).
///
- /// @param[out] sc_list
+ /// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
- /// @return
+ /// \return
/// A integer that contains SymbolContext::Scope bits set for
/// each item that was successfully resolved.
///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
+ /// \see SymbolContext::Scope
uint32_t ResolveSymbolContextsForFileSpec(
const FileSpec &file_spec, uint32_t line, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
void SetFileSpecAndObjectName(const FileSpec &file,
- const ConstString &object_name);
+ ConstString object_name);
bool GetIsDynamicLinkEditor();
@@ -931,17 +843,13 @@ public:
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; }
@@ -950,7 +858,6 @@ public:
return m_source_mappings;
}
- //------------------------------------------------------------------
/// Finds a source file given a file spec using the module source path
/// remappings (if any).
///
@@ -959,41 +866,37 @@ public:
/// 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
+ /// \param[in] orig_spec
/// The original source file path to try and remap.
///
- /// @param[out] new_spec
+ /// \param[out] new_spec
/// The newly remapped filespec that is guaranteed to exist.
///
- /// @return
+ /// \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
+ /// \param[in] path
/// The original source file path to try and remap.
///
- /// @param[out] new_path
+ /// \param[out] new_path
/// The newly remapped filespec that is may or may not exist.
///
- /// @return
+ /// \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"
+ /// \class LookupInfo Module.h "lldb/Core/Module.h"
/// A class that encapsulates name lookup information.
///
/// Users can type a wide variety of partial names when setting breakpoints
@@ -1014,7 +917,6 @@ public:
/// 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()
@@ -1022,16 +924,16 @@ public:
m_name_type_mask(lldb::eFunctionNameTypeNone),
m_match_name_after_lookup(false) {}
- LookupInfo(const ConstString &name, lldb::FunctionNameType name_type_mask,
+ LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask,
lldb::LanguageType language);
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
- void SetName(const ConstString &name) { m_name = name; }
+ void SetName(ConstString name) { m_name = name; }
- const ConstString &GetLookupName() const { return m_lookup_name; }
+ ConstString GetLookupName() const { return m_lookup_name; }
- void SetLookupName(const ConstString &name) { m_lookup_name = name; }
+ void SetLookupName(ConstString name) { m_lookup_name = name; }
lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; }
@@ -1061,9 +963,7 @@ public:
};
protected:
- //------------------------------------------------------------------
// Member Variables
- //------------------------------------------------------------------
mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
///in multi-threaded environments.
@@ -1091,8 +991,11 @@ protected:
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
+ llvm::Optional<UnwindTable> m_unwind_table; ///< Table of FuncUnwinders
+ /// objects created for this
+ /// Module's functions
lldb::SymbolVendorUP
- m_symfile_ap; ///< A pointer to the symbol vendor for this module.
+ m_symfile_up; ///< 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,
@@ -1104,9 +1007,9 @@ protected:
///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
+ lldb::SectionListUP m_sections_up; ///< 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};
@@ -1115,7 +1018,6 @@ protected:
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
@@ -1124,31 +1026,30 @@ protected:
/// indicates what clients wish to resolve and can be used to limit the
/// scope of what is parsed.
///
- /// @param[in] vm_addr
+ /// \param[in] vm_addr
/// The load virtual address to resolve.
///
- /// @param[in] vm_addr_is_file_addr
+ /// \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
+ /// \param[in] resolve_scope
/// The scope that should be resolved (see
/// SymbolContext::Scope).
///
- /// @param[out] so_addr
+ /// \param[out] so_addr
/// The section offset based address that got resolved if
/// any bits are returned.
///
- /// @param[out] sc
+ /// \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
+ /// \return
/// A integer that contains SymbolContext::Scope bits set for
/// each item that was successfully resolved.
///
- /// @see SymbolContext::Scope
- //------------------------------------------------------------------
+ /// \see SymbolContext::Scope
uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr,
bool vm_addr_is_file_addr,
lldb::SymbolContextItem resolve_scope,
@@ -1172,7 +1073,7 @@ private:
Module(); // Only used internally by CreateJITModule ()
size_t FindTypes_Impl(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
diff --git a/include/lldb/Core/ModuleChild.h b/include/lldb/Core/ModuleChild.h
index 73438040c3595..8a81c1a6cf8a6 100644
--- a/include/lldb/Core/ModuleChild.h
+++ b/include/lldb/Core/ModuleChild.h
@@ -1,9 +1,8 @@
//===-- ModuleChild.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,68 +13,46 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ModuleChild ModuleChild.h "lldb/Core/ModuleChild.h"
+/// \class ModuleChild ModuleChild.h "lldb/Core/ModuleChild.h"
/// A mix in class that contains a pointer back to the module
/// that owns the object which inherits from it.
-//----------------------------------------------------------------------
class ModuleChild {
public:
- //------------------------------------------------------------------
/// Construct with owning module.
///
- /// @param[in] 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);
-
- //------------------------------------------------------------------
/// Destructor.
- //------------------------------------------------------------------
~ModuleChild();
- //------------------------------------------------------------------
/// Assignment operator.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// A const ModuleChild class reference to copy.
///
- /// @return
+ /// \return
/// A const reference to this object.
- //------------------------------------------------------------------
const ModuleChild &operator=(const ModuleChild &rhs);
- //------------------------------------------------------------------
/// Get const accessor for the module pointer.
///
- /// @return
+ /// \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
+ /// \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.
};
diff --git a/include/lldb/Core/ModuleList.h b/include/lldb/Core/ModuleList.h
index a28d97113d63e..1e26c35e4c157 100644
--- a/include/lldb/Core/ModuleList.h
+++ b/include/lldb/Core/ModuleList.h
@@ -1,9 +1,8 @@
//===-- ModuleList.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,48 +31,19 @@
namespace lldb_private {
class ConstString;
-}
-namespace lldb_private {
class FileSpecList;
-}
-namespace lldb_private {
class Function;
-}
-namespace lldb_private {
class Log;
-}
-namespace lldb_private {
class Module;
-}
-namespace lldb_private {
class RegularExpression;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class SymbolContextList;
-}
-namespace lldb_private {
class SymbolFile;
-}
-namespace lldb_private {
class Target;
-}
-namespace lldb_private {
class TypeList;
-}
-namespace lldb_private {
class UUID;
-}
-namespace lldb_private {
class VariableList;
-}
-
-namespace lldb_private {
class ModuleListProperties : public Properties {
public:
@@ -82,91 +52,101 @@ public:
FileSpec GetClangModulesCachePath() const;
bool SetClangModulesCachePath(llvm::StringRef path);
bool GetEnableExternalLookup() const;
+ bool SetEnableExternalLookup(bool new_value);
};
-//----------------------------------------------------------------------
-/// @class ModuleList ModuleList.h "lldb/Core/ModuleList.h"
+/// \class ModuleList ModuleList.h "lldb/Core/ModuleList.h"
/// A collection class for Module objects.
///
/// Modules in the module collection class are stored as reference counted
/// shared pointers to Module objects.
-//----------------------------------------------------------------------
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;
+ virtual void NotifyModuleAdded(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) = 0;
+ virtual void NotifyModuleRemoved(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) = 0;
+ virtual void NotifyModuleUpdated(const ModuleList &module_list,
+ const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp) = 0;
+ virtual void NotifyWillClearList(const ModuleList &module_list) = 0;
+
+ virtual void NotifyModulesRemoved(lldb_private::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
+ /// \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
+ /// \param[in] rhs
/// Another module list object.
///
- /// @return
+ /// \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
+ /// \param[in] module_sp
/// A shared pointer to a module to add to this collection.
- //------------------------------------------------------------------
- void Append(const lldb::ModuleSP &module_sp);
+ ///
+ /// \param[in] notify
+ /// If true, and a notifier function is set, the notifier function
+ /// will be called. Defaults to true.
+ ///
+ /// When this ModuleList is the Target's ModuleList, the notifier
+ /// function is Target::ModulesDidLoad -- the call to
+ /// ModulesDidLoad may be deferred when adding multiple Modules
+ /// to the Target, but it must be called at the end,
+ /// before resuming execution.
+ void Append(const lldb::ModuleSP &module_sp, bool notify = true);
- //------------------------------------------------------------------
/// 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
+ /// \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);
+ /// Append a module to the module list, if it is not already there.
+ ///
+ /// \param[in] module_sp
+ ///
+ /// \param[in] notify
+ /// If true, and a notifier function is set, the notifier function
+ /// will be called. Defaults to true.
+ ///
+ /// When this ModuleList is the Target's ModuleList, the notifier
+ /// function is Target::ModulesDidLoad -- the call to
+ /// ModulesDidLoad may be deferred when adding multiple Modules
+ /// to the Target, but it must be called at the end,
+ /// before resuming execution.
+ bool AppendIfNeeded(const lldb::ModuleSP &module_sp, bool notify = true);
void Append(const ModuleList &module_list);
@@ -175,36 +155,30 @@ public:
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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @see Module::Dump(Stream *) const
- //------------------------------------------------------------------
+ /// \see Module::Dump(Stream *) const
void Dump(Stream *s) const;
void LogUUIDAndPaths(Log *log, const char *prefix_cstr);
@@ -213,155 +187,134 @@ public:
size_t GetIndexForModule(const Module *module) const;
- //------------------------------------------------------------------
/// Get the module shared pointer for the module at index \a idx.
///
- /// @param[in] idx
+ /// \param[in] idx
/// An index into this module collection.
///
- /// @return
+ /// \return
/// A shared pointer to a Module which can contain NULL if
/// \a idx is out of range.
///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] idx
/// An index into this module collection.
///
- /// @return
+ /// \return
/// A shared pointer to a Module which can contain NULL if
/// \a idx is out of range.
///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
+ /// \see ModuleList::GetSize()
lldb::ModuleSP GetModuleAtIndexUnlocked(size_t idx) const;
- //------------------------------------------------------------------
/// Get the module pointer for the module at index \a idx.
///
- /// @param[in] idx
+ /// \param[in] idx
/// An index into this module collection.
///
- /// @return
+ /// \return
/// A pointer to a Module which can by nullptr if \a idx is out
/// of range.
///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] idx
/// An index into this module collection.
///
- /// @return
+ /// \return
/// A pointer to a Module which can by nullptr if \a idx is out
/// of range.
///
- /// @see ModuleList::GetSize()
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] path
/// The name of the compile unit we are looking for.
///
- /// @param[in] append
+ /// \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
+ /// \param[out] sc_list
/// A symbol context list that gets filled in with all of the
/// matches.
///
- /// @return
+ /// \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,
+ /// \see Module::FindFunctions ()
+ size_t FindFunctions(ConstString name,
lldb::FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines, bool append,
SymbolContextList &sc_list) const;
- //------------------------------------------------------------------
- /// @see Module::FindFunctionSymbols ()
- //------------------------------------------------------------------
- size_t FindFunctionSymbols(const ConstString &name,
+ /// \see Module::FindFunctionSymbols ()
+ size_t FindFunctionSymbols(ConstString name,
lldb::FunctionNameType name_type_mask,
SymbolContextList &sc_list);
- //------------------------------------------------------------------
- /// @see Module::FindFunctions ()
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] name
/// The name of the global or static variable we are looking
/// for.
///
- /// @param[in] max_matches
+ /// \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
+ /// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
- /// @return
+ /// \return
/// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
- size_t FindGlobalVariables(const ConstString &name, size_t max_matches,
+ size_t FindGlobalVariables(ConstString name, size_t max_matches,
VariableList &variable_list) const;
- //------------------------------------------------------------------
/// Find global and static variables by regular expression.
///
- /// @param[in] regex
+ /// \param[in] regex
/// A regular expression to use when matching the name.
///
- /// @param[in] max_matches
+ /// \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
+ /// \param[in] variable_list
/// A list of variables that gets the matches appended to.
///
- /// @return
+ /// \return
/// The number of matches added to \a variable_list.
- //------------------------------------------------------------------
size_t FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
VariableList &variable_list) const;
- //------------------------------------------------------------------
/// Finds the first module whose file specification matches \a file_spec.
///
- /// @param[in] file_spec_ptr
+ /// \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
@@ -369,42 +322,39 @@ public:
/// NULL, then file specifications won't be compared when
/// searching for matching modules.
///
- /// @param[in] arch_ptr
+ /// \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
+ /// \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
+ /// \param[in] object_name
/// An optional object name that must match as well. This value
/// can be NULL.
///
- /// @param[out] matching_module_list
+ /// \param[out] matching_module_list
/// A module list that gets filled in with any modules that
/// match the search criteria.
///
- /// @return
+ /// \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,
+ size_t FindSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
SymbolContextList &sc_list,
bool append = false) const;
@@ -414,67 +364,64 @@ public:
SymbolContextList &sc_list,
bool append = false) const;
- //------------------------------------------------------------------
/// Find types by name.
///
- /// @param[in] search_first
+ /// \param[in] search_first
/// If non-null, this module will be searched before any other
/// modules.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the type we are looking for.
///
- /// @param[in] append
+ /// \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
+ /// \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
+ /// \param[in] encoding
/// Limit the search to specific types, or get all types if
/// set to Type::invalid.
///
- /// @param[in] udt_name
+ /// \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
+ /// \param[out] type_list
/// A type list gets populated with any matches.
///
- /// @return
+ /// \return
/// The number of matches added to \a type_list.
- //------------------------------------------------------------------
- size_t FindTypes(Module *search_first, const ConstString &name,
+ size_t FindTypes(Module *search_first, 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
+ /// \param[in] target_sp
/// The target the addresses are desired for.
///
- /// @param[in] file
+ /// \param[in] file
/// Source file to locate.
///
- /// @param[in] line
+ /// \param[in] line
/// Source line to locate.
///
- /// @param[in] function
+ /// \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
+ /// \param[out] output_local
/// All matching addresses within 'function'
///
- /// @param[out] output_extern
+ /// \param[out] output_extern
/// All matching addresses not within 'function'
void FindAddressesForLine(const lldb::TargetSP target_sp,
const FileSpec &file, uint32_t line,
@@ -482,7 +429,21 @@ public:
std::vector<Address> &output_local,
std::vector<Address> &output_extern);
- bool Remove(const lldb::ModuleSP &module_sp);
+ /// Remove a module from the module list.
+ ///
+ /// \param[in] module_sp
+ /// A shared pointer to a module to remove from this collection.
+ ///
+ /// \param[in] notify
+ /// If true, and a notifier function is set, the notifier function
+ /// will be called. Defaults to true.
+ ///
+ /// When this ModuleList is the Target's ModuleList, the notifier
+ /// function is Target::ModulesDidUnload -- the call to
+ /// ModulesDidUnload may be deferred when removing multiple Modules
+ /// from the Target, but it must be called at the end,
+ /// before resuming execution.
+ bool Remove(const lldb::ModuleSP &module_sp, bool notify = true);
size_t Remove(ModuleList &module_list);
@@ -492,36 +453,28 @@ public:
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr) const;
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextForAddress (const Address
+ /// \copydoc Module::ResolveSymbolContextForAddress (const Address
/// &,uint32_t,SymbolContext&)
- //------------------------------------------------------------------
uint32_t ResolveSymbolContextForAddress(const Address &so_addr,
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) const;
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextForFilePath (const char
+ /// \copydoc Module::ResolveSymbolContextForFilePath (const char
/// *,uint32_t,bool,uint32_t,SymbolContextList&)
- //------------------------------------------------------------------
uint32_t ResolveSymbolContextForFilePath(
const char *file_path, uint32_t line, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const;
- //------------------------------------------------------------------
- /// @copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec
+ /// \copydoc Module::ResolveSymbolContextsForFileSpec (const FileSpec
/// &,uint32_t,bool,uint32_t,SymbolContextList&)
- //------------------------------------------------------------------
uint32_t ResolveSymbolContextsForFileSpec(
const FileSpec &file_spec, uint32_t line, bool check_inlines,
lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) const;
- //------------------------------------------------------------------
/// Gets the size of the module list.
///
- /// @return
+ /// \return
/// The number of modules in the module list.
- //------------------------------------------------------------------
size_t GetSize() const;
bool LoadScriptingResourcesInTarget(Target *target, std::list<Status> &errors,
@@ -552,9 +505,7 @@ public:
&callback) const;
protected:
- //------------------------------------------------------------------
// Class typedefs.
- //------------------------------------------------------------------
typedef std::vector<lldb::ModuleSP>
collection; ///< The module collection type.
@@ -567,9 +518,7 @@ protected:
void ClearImpl(bool use_notifier = true);
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
collection m_modules; ///< The collection of modules.
mutable std::recursive_mutex m_modules_mutex;
diff --git a/include/lldb/Core/ModuleSpec.h b/include/lldb/Core/ModuleSpec.h
index ae772c2a1efe0..ab0f4e9912a8d 100644
--- a/include/lldb/Core/ModuleSpec.h
+++ b/include/lldb/Core/ModuleSpec.h
@@ -1,9 +1,8 @@
//===-- ModuleSpec.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -125,7 +124,7 @@ public:
ConstString &GetObjectName() { return m_object_name; }
- const ConstString &GetObjectName() const { return m_object_name; }
+ ConstString GetObjectName() const { return m_object_name; }
uint64_t GetObjectOffset() const { return m_object_offset; }
@@ -312,8 +311,10 @@ public:
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);
+ std::lock(m_mutex, rhs.m_mutex);
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex, std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex,
+ std::adopt_lock);
m_specs = rhs.m_specs;
}
return *this;
diff --git a/include/lldb/Core/Opcode.h b/include/lldb/Core/Opcode.h
index fb6cc825abd26..1a30ce4834ac0 100644
--- a/include/lldb/Core/Opcode.h
+++ b/include/lldb/Core/Opcode.h
@@ -1,9 +1,8 @@
//===-- Opcode.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,18 +18,13 @@
#include <stdint.h>
#include <string.h>
-namespace lldb_private {
-class DataExtractor;
-}
-namespace lldb_private {
-class Stream;
-}
-
namespace lldb {
class SBInstruction;
}
namespace lldb_private {
+class DataExtractor;
+class Stream;
class Opcode {
public:
diff --git a/include/lldb/Core/PluginInterface.h b/include/lldb/Core/PluginInterface.h
index 24f53c62ab095..6e625a605917d 100644
--- a/include/lldb/Core/PluginInterface.h
+++ b/include/lldb/Core/PluginInterface.h
@@ -1,9 +1,8 @@
//===-- PluginInterface.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/PluginManager.h b/include/lldb/Core/PluginManager.h
index 598ee9a8d8e35..1bac1e5df6940 100644
--- a/include/lldb/Core/PluginManager.h
+++ b/include/lldb/Core/PluginManager.h
@@ -1,9 +1,8 @@
//===-- PluginManager.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,17 +22,9 @@
namespace lldb_private {
class CommandInterpreter;
-}
-namespace lldb_private {
class ConstString;
-}
-namespace lldb_private {
class Debugger;
-}
-namespace lldb_private {
class StringList;
-}
-namespace lldb_private {
class PluginManager {
public:
@@ -41,10 +32,8 @@ public:
static void Terminate();
- //------------------------------------------------------------------
// ABI
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
ABICreateInstance create_callback);
static bool UnregisterPlugin(ABICreateInstance create_callback);
@@ -52,15 +41,13 @@ public:
static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
static ABICreateInstance
- GetABICreateCallbackForPluginName(const ConstString &name);
+ GetABICreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// Architecture
- //------------------------------------------------------------------
using ArchitectureCreateInstance =
std::unique_ptr<Architecture> (*)(const ArchSpec &);
- static void RegisterPlugin(const ConstString &name,
+ static void RegisterPlugin(ConstString name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback);
@@ -69,10 +56,8 @@ public:
static std::unique_ptr<Architecture>
CreateArchitectureInstance(const ArchSpec &arch);
- //------------------------------------------------------------------
// Disassembler
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
DisassemblerCreateInstance create_callback);
static bool UnregisterPlugin(DisassemblerCreateInstance create_callback);
@@ -81,13 +66,11 @@ public:
GetDisassemblerCreateCallbackAtIndex(uint32_t idx);
static DisassemblerCreateInstance
- GetDisassemblerCreateCallbackForPluginName(const ConstString &name);
+ GetDisassemblerCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// DynamicLoader
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
DynamicLoaderCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr);
@@ -97,13 +80,11 @@ public:
GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx);
static DynamicLoaderCreateInstance
- GetDynamicLoaderCreateCallbackForPluginName(const ConstString &name);
+ GetDynamicLoaderCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// JITLoader
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
JITLoaderCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr);
@@ -113,12 +94,10 @@ public:
GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
static JITLoaderCreateInstance
- GetJITLoaderCreateCallbackForPluginName(const ConstString &name);
+ GetJITLoaderCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// EmulateInstruction
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
EmulateInstructionCreateInstance create_callback);
static bool
@@ -128,12 +107,10 @@ public:
GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx);
static EmulateInstructionCreateInstance
- GetEmulateInstructionCreateCallbackForPluginName(const ConstString &name);
+ GetEmulateInstructionCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// OperatingSystem
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
OperatingSystemCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback);
@@ -143,12 +120,10 @@ public:
GetOperatingSystemCreateCallbackAtIndex(uint32_t idx);
static OperatingSystemCreateInstance
- GetOperatingSystemCreateCallbackForPluginName(const ConstString &name);
+ GetOperatingSystemCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// Language
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
LanguageCreateInstance create_callback);
static bool UnregisterPlugin(LanguageCreateInstance create_callback);
@@ -156,15 +131,14 @@ public:
static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
static LanguageCreateInstance
- GetLanguageCreateCallbackForPluginName(const ConstString &name);
+ GetLanguageCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// LanguageRuntime
- //------------------------------------------------------------------
- static bool
- RegisterPlugin(const ConstString &name, const char *description,
- LanguageRuntimeCreateInstance create_callback,
- LanguageRuntimeGetCommandObject command_callback = nullptr);
+ static bool RegisterPlugin(
+ ConstString name, const char *description,
+ LanguageRuntimeCreateInstance create_callback,
+ LanguageRuntimeGetCommandObject command_callback = nullptr,
+ LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr);
static bool UnregisterPlugin(LanguageRuntimeCreateInstance create_callback);
@@ -174,13 +148,14 @@ public:
static LanguageRuntimeGetCommandObject
GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx);
+ static LanguageRuntimeGetExceptionPrecondition
+ GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
+
static LanguageRuntimeCreateInstance
- GetLanguageRuntimeCreateCallbackForPluginName(const ConstString &name);
+ GetLanguageRuntimeCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// SystemRuntime
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
SystemRuntimeCreateInstance create_callback);
static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
@@ -189,13 +164,11 @@ public:
GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
static SystemRuntimeCreateInstance
- GetSystemRuntimeCreateCallbackForPluginName(const ConstString &name);
+ GetSystemRuntimeCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// ObjectFile
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
ObjectFileCreateInstance create_callback,
ObjectFileCreateMemoryInstance create_memory_callback,
ObjectFileGetModuleSpecifications get_module_specifications,
@@ -213,19 +186,17 @@ public:
GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
static ObjectFileCreateInstance
- GetObjectFileCreateCallbackForPluginName(const ConstString &name);
+ GetObjectFileCreateCallbackForPluginName(ConstString name);
static ObjectFileCreateMemoryInstance
- GetObjectFileCreateMemoryCallbackForPluginName(const ConstString &name);
+ GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
static Status SaveCore(const lldb::ProcessSP &process_sp,
const FileSpec &outfile);
- //------------------------------------------------------------------
// ObjectContainer
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
ObjectContainerCreateInstance create_callback,
ObjectFileGetModuleSpecifications get_module_specifications);
@@ -235,16 +206,14 @@ public:
GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
static ObjectContainerCreateInstance
- GetObjectContainerCreateCallbackForPluginName(const ConstString &name);
+ GetObjectContainerCreateCallbackForPluginName(ConstString name);
static ObjectFileGetModuleSpecifications
GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
- //------------------------------------------------------------------
// Platform
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
PlatformCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr);
@@ -253,7 +222,7 @@ public:
static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
static PlatformCreateInstance
- GetPlatformCreateCallbackForPluginName(const ConstString &name);
+ GetPlatformCreateCallbackForPluginName(ConstString name);
static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
@@ -261,11 +230,9 @@ public:
static size_t AutoCompletePlatformName(llvm::StringRef partial_name,
StringList &matches);
- //------------------------------------------------------------------
// Process
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
ProcessCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr);
@@ -274,16 +241,14 @@ public:
static ProcessCreateInstance GetProcessCreateCallbackAtIndex(uint32_t idx);
static ProcessCreateInstance
- GetProcessCreateCallbackForPluginName(const ConstString &name);
+ GetProcessCreateCallbackForPluginName(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,
+ static bool RegisterPlugin(ConstString name, const char *description,
lldb::ScriptLanguage script_lang,
ScriptInterpreterCreateInstance create_callback);
@@ -294,32 +259,29 @@ public:
static lldb::ScriptInterpreterSP
GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
- CommandInterpreter &interpreter);
+ Debugger &debugger);
- //------------------------------------------------------------------
// StructuredDataPlugin
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Register a StructuredDataPlugin class along with optional
/// callbacks for debugger initialization and Process launch info
/// filtering and manipulation.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the plugin.
///
- /// @param[in] description
+ /// \param[in] description
/// A description string for the plugin.
///
- /// @param[in] create_callback
+ /// \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
+ /// \param[in] debugger_init_callback
/// An optional callback that will be made when a Debugger
/// instance is initialized.
///
- /// @param[in] filter_callback
+ /// \param[in] filter_callback
/// An optional callback that will be invoked before LLDB
/// launches a process for debugging. The callback must
/// do the following:
@@ -331,11 +293,10 @@ public:
/// plugin if, for instance, additional environment variables
/// are needed to support the feature when enabled.
///
- /// @return
+ /// \return
/// Returns true upon success; otherwise, false.
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
StructuredDataPluginCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr,
StructuredDataFilterLaunchInfo filter_callback = nullptr);
@@ -347,17 +308,15 @@ public:
GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
static StructuredDataPluginCreateInstance
- GetStructuredDataPluginCreateCallbackForPluginName(const ConstString &name);
+ GetStructuredDataPluginCreateCallbackForPluginName(ConstString name);
static StructuredDataFilterLaunchInfo
GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
bool &iteration_complete);
- //------------------------------------------------------------------
// SymbolFile
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
SymbolFileCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback = nullptr);
@@ -367,12 +326,10 @@ public:
GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
static SymbolFileCreateInstance
- GetSymbolFileCreateCallbackForPluginName(const ConstString &name);
+ GetSymbolFileCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// SymbolVendor
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
SymbolVendorCreateInstance create_callback);
static bool UnregisterPlugin(SymbolVendorCreateInstance create_callback);
@@ -381,12 +338,10 @@ public:
GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
static SymbolVendorCreateInstance
- GetSymbolVendorCreateCallbackForPluginName(const ConstString &name);
+ GetSymbolVendorCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// UnwindAssembly
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
UnwindAssemblyCreateInstance create_callback);
static bool UnregisterPlugin(UnwindAssemblyCreateInstance create_callback);
@@ -395,12 +350,10 @@ public:
GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
static UnwindAssemblyCreateInstance
- GetUnwindAssemblyCreateCallbackForPluginName(const ConstString &name);
+ GetUnwindAssemblyCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// MemoryHistory
- //------------------------------------------------------------------
- static bool RegisterPlugin(const ConstString &name, const char *description,
+ static bool RegisterPlugin(ConstString name, const char *description,
MemoryHistoryCreateInstance create_callback);
static bool UnregisterPlugin(MemoryHistoryCreateInstance create_callback);
@@ -409,13 +362,11 @@ public:
GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx);
static MemoryHistoryCreateInstance
- GetMemoryHistoryCreateCallbackForPluginName(const ConstString &name);
+ GetMemoryHistoryCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// InstrumentationRuntime
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
InstrumentationRuntimeCreateInstance create_callback,
InstrumentationRuntimeGetType get_type_callback);
@@ -429,13 +380,11 @@ public:
GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx);
static InstrumentationRuntimeCreateInstance
- GetInstrumentationRuntimeCreateCallbackForPluginName(const ConstString &name);
+ GetInstrumentationRuntimeCreateCallbackForPluginName(ConstString name);
- //------------------------------------------------------------------
// TypeSystem
- //------------------------------------------------------------------
static bool RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
TypeSystemCreateInstance create_callback,
TypeSystemEnumerateSupportedLanguages enumerate_languages_callback);
@@ -445,20 +394,18 @@ public:
GetTypeSystemCreateCallbackAtIndex(uint32_t idx);
static TypeSystemCreateInstance
- GetTypeSystemCreateCallbackForPluginName(const ConstString &name);
+ GetTypeSystemCreateCallbackForPluginName(ConstString name);
static TypeSystemEnumerateSupportedLanguages
GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
static TypeSystemEnumerateSupportedLanguages
GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
- const ConstString &name);
+ ConstString name);
- //------------------------------------------------------------------
// REPL
- //------------------------------------------------------------------
static bool
- RegisterPlugin(const ConstString &name, const char *description,
+ RegisterPlugin(ConstString name, const char *description,
REPLCreateInstance create_callback,
REPLEnumerateSupportedLanguages enumerate_languages_callback);
@@ -467,79 +414,77 @@ public:
static REPLCreateInstance GetREPLCreateCallbackAtIndex(uint32_t idx);
static REPLCreateInstance
- GetREPLCreateCallbackForPluginName(const ConstString &name);
+ GetREPLCreateCallbackForPluginName(ConstString name);
static REPLEnumerateSupportedLanguages
GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx);
static REPLEnumerateSupportedLanguages
GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
- const ConstString &name);
+ 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);
+ ConstString setting_name);
static bool CreateSettingForDynamicLoaderPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
GetSettingForPlatformPlugin(Debugger &debugger,
- const ConstString &setting_name);
+ ConstString setting_name);
static bool CreateSettingForPlatformPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
GetSettingForProcessPlugin(Debugger &debugger,
- const ConstString &setting_name);
+ ConstString setting_name);
static bool CreateSettingForProcessPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
GetSettingForSymbolFilePlugin(Debugger &debugger,
- const ConstString &setting_name);
+ ConstString setting_name);
static bool CreateSettingForSymbolFilePlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
GetSettingForJITLoaderPlugin(Debugger &debugger,
- const ConstString &setting_name);
+ ConstString setting_name);
static bool CreateSettingForJITLoaderPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
GetSettingForOperatingSystemPlugin(Debugger &debugger,
- const ConstString &setting_name);
+ ConstString setting_name);
static bool CreateSettingForOperatingSystemPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
static lldb::OptionValuePropertiesSP
GetSettingForStructuredDataPlugin(Debugger &debugger,
- const ConstString &setting_name);
+ ConstString setting_name);
static bool CreateSettingForStructuredDataPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property);
+ ConstString description, bool is_global_property);
};
} // namespace lldb_private
diff --git a/include/lldb/Core/RichManglingContext.h b/include/lldb/Core/RichManglingContext.h
index 30841bfb2668c..e6fa2599e55a2 100644
--- a/include/lldb/Core/RichManglingContext.h
+++ b/include/lldb/Core/RichManglingContext.h
@@ -1,9 +1,8 @@
//===-- RichManglingContext.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,11 +33,11 @@ public:
/// Use the ItaniumPartialDemangler to obtain rich mangling information from
/// the given mangled name.
- bool FromItaniumName(const ConstString &mangled);
+ bool FromItaniumName(ConstString mangled);
/// Use the legacy language parser implementation to obtain rich mangling
/// information from the given demangled name.
- bool FromCxxMethodName(const ConstString &demangled);
+ bool FromCxxMethodName(ConstString demangled);
/// If this symbol describes a constructor or destructor.
bool IsCtorOrDtor() const;
diff --git a/include/lldb/Core/STLUtils.h b/include/lldb/Core/STLUtils.h
index 0ed354fa4e32f..830aca36a1165 100644
--- a/include/lldb/Core/STLUtils.h
+++ b/include/lldb/Core/STLUtils.h
@@ -1,9 +1,8 @@
//===-- STLUtils.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,28 +16,22 @@
#include <vector>
-//----------------------------------------------------------------------
// C string less than compare function object
-//----------------------------------------------------------------------
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;
}
};
-//----------------------------------------------------------------------
// 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 {
public:
ValueEquals(const S &val) : second_value(val) {}
diff --git a/include/lldb/Core/SearchFilter.h b/include/lldb/Core/SearchFilter.h
index f53ef658fd3ff..f38690c95f523 100644
--- a/include/lldb/Core/SearchFilter.h
+++ b/include/lldb/Core/SearchFilter.h
@@ -1,9 +1,8 @@
//===-- SearchFilter.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,55 +19,33 @@
namespace lldb_private {
class Address;
-}
-namespace lldb_private {
class Breakpoint;
-}
-namespace lldb_private {
class CompileUnit;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class Function;
-}
-namespace lldb_private {
class ModuleList;
-}
-namespace lldb_private {
class SearchFilter;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class Target;
}
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Searcher SearchFilter.h "lldb/Core/SearchFilter.h" Class that is
+/// \class Searcher SearchFilter.h "lldb/Core/SearchFilter.h" Class that is
/// driven by the SearchFilter to search the SymbolContext space of the target
/// program.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// General Outline:
/// Provides the callback and search depth for the SearchFilter search.
-//----------------------------------------------------------------------
class Searcher {
public:
- typedef enum {
+ enum CallbackReturn {
eCallbackReturnStop = 0, // Stop the iteration
eCallbackReturnContinue, // Continue the iteration
eCallbackReturnPop // Pop one level up and continue iterating
- } CallbackReturn;
+ };
Searcher();
@@ -80,23 +57,18 @@ public:
virtual lldb::SearchDepth GetDepth() = 0;
- //------------------------------------------------------------------
/// Prints a canonical description for the searcher to the stream \a s.
///
- /// @param[in] s
+ /// \param[in] s
/// Stream to which the output is copied.
- //------------------------------------------------------------------
virtual void GetDescription(Stream *s);
};
-//----------------------------------------------------------------------
-/// @class SearchFilter SearchFilter.h "lldb/Core/SearchFilter.h" Class
+/// \class SearchFilter SearchFilter.h "lldb/Core/SearchFilter.h" Class
/// descends through the SymbolContext space of the target, applying a filter
/// at each stage till it reaches the depth specified by the GetDepth method
/// of the searcher, and calls its callback at that point.
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
/// General Outline:
/// Provides the callback and search depth for the SearchFilter search.
///
@@ -107,141 +79,112 @@ public:
/// 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 {
public:
- //------------------------------------------------------------------
/// The basic constructor takes a Target, which gives the space to search.
///
- /// @param[in] target
+ /// \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
+ /// \param[in] spec
/// The file spec to check against the filter.
- /// @return
+ /// \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
+ /// \param[in] module
/// The Module to check against the filter.
///
- /// @return
+ /// \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
+ /// \param[in] addr
/// The address to check against the filter.
///
- /// @return
+ /// \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
+ /// \param[in] fileSpec
/// The file spec to check against the filter.
///
- /// @return
+ /// \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
+ /// \param[in] compUnit
/// The CompileUnit to check against the filter.
///
- /// @return
+ /// \return
/// \b true if \a Comp Unit passes, and \b false otherwise.
- //------------------------------------------------------------------
virtual bool CompUnitPasses(CompileUnit &compUnit);
- //------------------------------------------------------------------
/// Call this method with a Function to see if \a function passes the
/// filter.
///
- /// @param[in] function
+ /// \param[in] function
/// The Functions to check against the filter.
///
- /// @return
+ /// \return
/// \b true if \a function passes, and \b false otherwise.
- //------------------------------------------------------------------
virtual bool FunctionPasses(Function &function);
- //------------------------------------------------------------------
/// Call this method to do the search using the Searcher.
///
- /// @param[in] 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
+ /// \param[in] searcher
/// The searcher to drive with this search.
///
- /// @param[in] modules
+ /// \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
+ /// \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
+ /// \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);
@@ -329,12 +272,10 @@ private:
unsigned char SubclassID;
};
-//----------------------------------------------------------------------
-/// @class SearchFilterForUnconstrainedSearches SearchFilter.h
+/// \class SearchFilterForUnconstrainedSearches SearchFilter.h
/// "lldb/Core/SearchFilter.h" This is a SearchFilter that searches through
/// all modules. It also consults the
/// Target::ModuleIsExcludedForUnconstrainedSearches.
-//----------------------------------------------------------------------
class SearchFilterForUnconstrainedSearches : public SearchFilter {
public:
SearchFilterForUnconstrainedSearches(const lldb::TargetSP &target_sp)
@@ -357,31 +298,23 @@ protected:
lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
};
-//----------------------------------------------------------------------
-/// @class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This
+/// \class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This
/// is a SearchFilter that restricts the search to a given module.
-//----------------------------------------------------------------------
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
+ /// \param[in] target
/// The Target that provides the module list to search.
///
- /// @param[in] module
+ /// \param[in] module
/// The Module that limits the search.
- //------------------------------------------------------------------
SearchFilterByModule(const lldb::TargetSP &targetSP, const FileSpec &module);
- SearchFilterByModule(const SearchFilterByModule &rhs);
-
~SearchFilterByModule() override;
- SearchFilterByModule &operator=(const SearchFilterByModule &rhs);
-
bool ModulePasses(const lldb::ModuleSP &module_sp) override;
bool ModulePasses(const FileSpec &spec) override;
@@ -416,16 +349,14 @@ private:
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
+ /// \param[in] target
/// The Target that provides the module list to search.
///
- /// @param[in] module
+ /// \param[in] module
/// The Module that limits the search.
- //------------------------------------------------------------------
SearchFilterByModuleList(const lldb::TargetSP &targetSP,
const FileSpecList &module_list);
@@ -433,8 +364,6 @@ public:
const FileSpecList &module_list,
enum FilterTy filter_ty);
- SearchFilterByModuleList(const SearchFilterByModuleList &rhs);
-
~SearchFilterByModuleList() override;
SearchFilterByModuleList &operator=(const SearchFilterByModuleList &rhs);
@@ -475,16 +404,14 @@ protected:
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
+ /// \param[in] target
/// The Target that provides the module list to search.
///
- /// @param[in] module
+ /// \param[in] module
/// The Module that limits the search.
- //------------------------------------------------------------------
SearchFilterByModuleListAndCU(const lldb::TargetSP &targetSP,
const FileSpecList &module_list,
const FileSpecList &cu_list);
diff --git a/include/lldb/Core/Section.h b/include/lldb/Core/Section.h
index 4157bb877b4cc..881d43702ceee 100644
--- a/include/lldb/Core/Section.h
+++ b/include/lldb/Core/Section.h
@@ -1,9 +1,8 @@
//===-- Section.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,24 +26,11 @@
namespace lldb_private {
class Address;
-}
-namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class ObjectFile;
-}
-namespace lldb_private {
class Section;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class Target;
-}
-
-namespace lldb_private {
class SectionList {
public:
@@ -52,6 +38,11 @@ public:
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
+ const_iterator begin() const { return m_sections.begin(); }
+ const_iterator end() const { return m_sections.end(); }
+ const_iterator begin() { return m_sections.begin(); }
+ const_iterator end() { return m_sections.end(); }
+
SectionList();
~SectionList();
@@ -68,7 +59,7 @@ public:
void Dump(Stream *s, Target *target, bool show_header, uint32_t depth) const;
- lldb::SectionSP FindSectionByName(const ConstString &section_dstr) const;
+ lldb::SectionSP FindSectionByName(ConstString section_dstr) const;
lldb::SectionSP FindSectionByID(lldb::user_id_t sect_id) const;
@@ -110,7 +101,7 @@ class Section : public std::enable_shared_from_this<Section>,
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::user_id_t sect_id, 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,
@@ -121,7 +112,7 @@ public:
// sections, non-NULL for
// child sections
const lldb::ModuleSP &module_sp, ObjectFile *obj_file,
- lldb::user_id_t sect_id, const ConstString &name,
+ lldb::user_id_t sect_id, 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,
@@ -176,7 +167,7 @@ public:
bool IsDescendant(const Section *section);
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
bool Slide(lldb::addr_t slide_amount, bool slide_children);
@@ -190,56 +181,48 @@ public:
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
+ /// \param[in] dst
/// Where to place the data
///
- /// @param[in] dst_len
+ /// \param[in] dst_len
/// How many bytes of section data to read
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset in bytes within this section's data at which to
/// start copying data from.
///
- /// @return
+ /// \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
+ /// \param[in] data
/// Where to place the data, address byte size, and byte order
///
- /// @return
+ /// \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);
uint32_t GetLog2Align() { return m_log2align; }
diff --git a/include/lldb/Core/SourceManager.h b/include/lldb/Core/SourceManager.h
index d31ba037c5d6c..bca817750d8da 100644
--- a/include/lldb/Core/SourceManager.h
+++ b/include/lldb/Core/SourceManager.h
@@ -1,9 +1,8 @@
//===-- SourceManager.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,22 +24,12 @@
namespace lldb_private {
class RegularExpression;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContextList;
-}
-namespace lldb_private {
class Target;
-}
-
-namespace lldb_private {
class SourceManager {
public:
-#ifndef SWIG
class File {
friend bool operator==(const SourceManager::File &lhs,
const SourceManager::File &rhs);
@@ -100,11 +89,9 @@ public:
private:
void CommonInitializer(const FileSpec &file_spec, Target *target);
};
-#endif // SWIG
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.
@@ -120,11 +107,8 @@ public:
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
diff --git a/include/lldb/Core/StreamAsynchronousIO.h b/include/lldb/Core/StreamAsynchronousIO.h
index 89667be058781..6237e12b7d1ea 100644
--- a/include/lldb/Core/StreamAsynchronousIO.h
+++ b/include/lldb/Core/StreamAsynchronousIO.h
@@ -1,9 +1,8 @@
//===-- StreamAsynchronousIO.h -----------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,6 @@
namespace lldb_private {
class Debugger;
-}
-
-namespace lldb_private {
class StreamAsynchronousIO : public Stream {
public:
diff --git a/include/lldb/Core/StreamBuffer.h b/include/lldb/Core/StreamBuffer.h
index 7b2468330ad22..6c516519781ff 100644
--- a/include/lldb/Core/StreamBuffer.h
+++ b/include/lldb/Core/StreamBuffer.h
@@ -1,9 +1,8 @@
//===-- StreamBuffer.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,9 @@ public:
StreamBuffer(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order)
: Stream(flags, addr_size, byte_order), m_packet() {}
- virtual ~StreamBuffer() {}
+ ~StreamBuffer() override {}
- virtual void Flush() {
+ void Flush() override {
// Nothing to do when flushing a buffer based stream...
}
@@ -43,7 +42,7 @@ public:
protected:
llvm::SmallVector<char, N> m_packet;
- virtual size_t WriteImpl(const void *s, size_t length) {
+ size_t WriteImpl(const void *s, size_t length) override {
if (s && length)
m_packet.append((const char *)s, ((const char *)s) + length);
return length;
diff --git a/include/lldb/Core/StreamFile.h b/include/lldb/Core/StreamFile.h
index 86db3e4ae4877..54aeab16b3f1a 100644
--- a/include/lldb/Core/StreamFile.h
+++ b/include/lldb/Core/StreamFile.h
@@ -1,9 +1,8 @@
//===-- StreamFile.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ namespace lldb_private {
class StreamFile : public Stream {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
StreamFile();
StreamFile(uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order);
@@ -48,9 +45,7 @@ public:
protected:
- //------------------------------------------------------------------
// Classes that inherit from StreamFile can see and modify these
- //------------------------------------------------------------------
File m_file;
size_t WriteImpl(const void *s, size_t length) override;
diff --git a/include/lldb/Core/StructuredDataImpl.h b/include/lldb/Core/StructuredDataImpl.h
index 2912f4ec7de0b..79a709af7ca31 100644
--- a/include/lldb/Core/StructuredDataImpl.h
+++ b/include/lldb/Core/StructuredDataImpl.h
@@ -1,9 +1,8 @@
//===-- StructuredDataImpl.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/ThreadSafeDenseMap.h b/include/lldb/Core/ThreadSafeDenseMap.h
index 2fc428c4f7d43..c485b91acb47a 100644
--- a/include/lldb/Core/ThreadSafeDenseMap.h
+++ b/include/lldb/Core/ThreadSafeDenseMap.h
@@ -1,10 +1,9 @@
//===-- ThreadSafeDenseMap.h ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/ThreadSafeDenseSet.h b/include/lldb/Core/ThreadSafeDenseSet.h
index 74a010544705f..fbc8d3fb02f84 100644
--- a/include/lldb/Core/ThreadSafeDenseSet.h
+++ b/include/lldb/Core/ThreadSafeDenseSet.h
@@ -1,10 +1,9 @@
//===-- ThreadSafeDenseSet.h ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Core/ThreadSafeSTLMap.h b/include/lldb/Core/ThreadSafeSTLMap.h
index 4058fdfe15a88..df0208cd49b31 100644
--- a/include/lldb/Core/ThreadSafeSTLMap.h
+++ b/include/lldb/Core/ThreadSafeSTLMap.h
@@ -1,9 +1,8 @@
//===-- ThreadSafeSTLMap.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ 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() {}
@@ -122,9 +119,7 @@ private:
collection m_collection;
mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
// For ThreadSafeSTLMap only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLMap);
};
diff --git a/include/lldb/Core/ThreadSafeSTLVector.h b/include/lldb/Core/ThreadSafeSTLVector.h
index b65936f81fec1..e1666a69ef7ea 100644
--- a/include/lldb/Core/ThreadSafeSTLVector.h
+++ b/include/lldb/Core/ThreadSafeSTLVector.h
@@ -1,10 +1,9 @@
//===-- ThreadSafeSTLVector.h ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,9 +22,7 @@ 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;
@@ -66,9 +63,7 @@ private:
collection m_collection;
mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
// For ThreadSafeSTLVector only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ThreadSafeSTLVector);
};
diff --git a/include/lldb/Core/ThreadSafeValue.h b/include/lldb/Core/ThreadSafeValue.h
index 35424a1791e67..91f96814363f2 100644
--- a/include/lldb/Core/ThreadSafeValue.h
+++ b/include/lldb/Core/ThreadSafeValue.h
@@ -1,9 +1,8 @@
//===-- ThreadSafeValue.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@ namespace lldb_private {
template <class T> class ThreadSafeValue {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
ThreadSafeValue() : m_value(), m_mutex() {}
ThreadSafeValue(const T &value) : m_value(value), m_mutex() {}
@@ -56,9 +53,7 @@ private:
T m_value;
mutable std::recursive_mutex m_mutex;
- //------------------------------------------------------------------
// For ThreadSafeValue only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ThreadSafeValue);
};
diff --git a/include/lldb/Core/UniqueCStringMap.h b/include/lldb/Core/UniqueCStringMap.h
index cfb84b4c2160f..9949bd45f4fa9 100644
--- a/include/lldb/Core/UniqueCStringMap.h
+++ b/include/lldb/Core/UniqueCStringMap.h
@@ -1,9 +1,8 @@
//===-- UniqueCStringMap.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,38 +17,24 @@
namespace lldb_private {
-//----------------------------------------------------------------------
// Templatized uniqued string map.
//
// This map is useful for mapping unique C string names to values of type T.
// Each "const char *" name added must be unique for a given
// C string value. ConstString::GetCString() can provide such strings.
// Any other string table that has guaranteed unique values can also be used.
-//----------------------------------------------------------------------
template <typename T> class UniqueCStringMap {
public:
struct Entry {
- Entry() {}
-
- Entry(ConstString cstr) : cstring(cstr), value() {}
-
Entry(ConstString cstr, const T &v) : cstring(cstr), value(v) {}
- // This is only for uniqueness, not lexicographical ordering, so we can
- // just compare pointers.
- bool operator<(const Entry &rhs) const {
- return cstring.GetCString() < rhs.cstring.GetCString();
- }
-
ConstString 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(ConstString unique_cstr, const T &value) {
m_map.push_back(typename UniqueCStringMap<T>::Entry(unique_cstr, value));
}
@@ -58,25 +43,10 @@ public:
void Clear() { m_map.clear(); }
- //------------------------------------------------------------------
- // Call this function to always keep the map sorted when putting entries into
- // the map.
- //------------------------------------------------------------------
- void Insert(ConstString 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;
@@ -103,49 +73,37 @@ public:
return ((idx < m_map.size()) ? m_map[idx].cstring : ConstString());
}
- //------------------------------------------------------------------
// 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(ConstString 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;
- }
+ auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
+ if (pos != m_map.end() && pos->cstring == unique_cstr)
+ return pos->value;
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(ConstString 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 && pos->cstring == unique_cstr)
+ auto pos = llvm::lower_bound(m_map, unique_cstr, Compare());
+ if (pos != m_map.end() && pos->cstring == unique_cstr)
return &(*pos);
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];
@@ -162,15 +120,9 @@ public:
size_t GetValues(ConstString 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;
- }
+ for (const Entry &entry : llvm::make_range(std::equal_range(
+ m_map.begin(), m_map.end(), unique_cstr, Compare())))
+ values.push_back(entry.value);
return values.size() - start_size;
}
@@ -188,25 +140,18 @@ public:
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;
@@ -216,16 +161,13 @@ public:
// my_map.Append (UniqueCStringMap::Entry(GetName(...), GetValue(...)));
// }
// my_map.Sort();
- //------------------------------------------------------------------
- void Sort() { llvm::sort(m_map.begin(), m_map.end()); }
+ void Sort() { llvm::sort(m_map.begin(), m_map.end(), Compare()); }
- //------------------------------------------------------------------
// 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());
@@ -233,28 +175,27 @@ public:
}
}
- size_t Erase(ConstString 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);
- }
- }
+protected:
+ struct Compare {
+ bool operator()(const Entry &lhs, const Entry &rhs) {
+ return operator()(lhs.cstring, rhs.cstring);
}
- return num_removed;
- }
-protected:
+ bool operator()(const Entry &lhs, ConstString rhs) {
+ return operator()(lhs.cstring, rhs);
+ }
+
+ bool operator()(ConstString lhs, const Entry &rhs) {
+ return operator()(lhs, rhs.cstring);
+ }
+
+ // This is only for uniqueness, not lexicographical ordering, so we can
+ // just compare pointers. *However*, comparing pointers from different
+ // allocations is UB, so we need compare their integral values instead.
+ bool operator()(ConstString lhs, ConstString rhs) {
+ return uintptr_t(lhs.GetCString()) < uintptr_t(rhs.GetCString());
+ }
+ };
typedef std::vector<Entry> collection;
typedef typename collection::iterator iterator;
typedef typename collection::const_iterator const_iterator;
diff --git a/include/lldb/Core/UserSettingsController.h b/include/lldb/Core/UserSettingsController.h
index 350b5babb47bf..6ae3bdec16650 100644
--- a/include/lldb/Core/UserSettingsController.h
+++ b/include/lldb/Core/UserSettingsController.h
@@ -1,9 +1,8 @@
//====-- UserSettingsController.h --------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,17 +22,9 @@
namespace lldb_private {
class CommandInterpreter;
-}
-namespace lldb_private {
class ConstString;
-}
-namespace lldb_private {
class ExecutionContext;
-}
-namespace lldb_private {
class Property;
-}
-namespace lldb_private {
class Stream;
}
@@ -78,7 +69,7 @@ public:
std::vector<const Property *> &matching_properties) const;
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
- const ConstString &name);
+ 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
diff --git a/include/lldb/Core/Value.h b/include/lldb/Core/Value.h
index 249adb24fbc9a..b786e4866f6c1 100644
--- a/include/lldb/Core/Value.h
+++ b/include/lldb/Core/Value.h
@@ -1,9 +1,8 @@
//===-- Value.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,20 +26,10 @@
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class ExecutionContext;
-}
-namespace lldb_private {
class Module;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class Type;
-}
-namespace lldb_private {
class Variable;
}
diff --git a/include/lldb/Core/ValueObject.h b/include/lldb/Core/ValueObject.h
index cb6de7b418073..0808b86c67a1c 100644
--- a/include/lldb/Core/ValueObject.h
+++ b/include/lldb/Core/ValueObject.h
@@ -1,9 +1,8 @@
//===-- ValueObject.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,40 +39,19 @@
#include <stddef.h>
#include <stdint.h>
+
namespace lldb_private {
class Declaration;
-}
-namespace lldb_private {
class DumpValueObjectOptions;
-}
-namespace lldb_private {
class EvaluateExpressionOptions;
-}
-namespace lldb_private {
class ExecutionContextScope;
-}
-namespace lldb_private {
class Log;
-}
-namespace lldb_private {
class Scalar;
-}
-namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class SymbolContextScope;
-}
-namespace lldb_private {
class TypeFormatImpl;
-}
-namespace lldb_private {
class TypeSummaryImpl;
-}
-namespace lldb_private {
class TypeSummaryOptions;
-}
-namespace lldb_private {
/// ValueObject:
///
@@ -380,16 +358,12 @@ public:
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();
@@ -479,12 +453,10 @@ public:
virtual bool GetDeclaration(Declaration &decl);
- //------------------------------------------------------------------
// The functions below should NOT be modified by subclasses
- //------------------------------------------------------------------
const Status &GetError();
- const ConstString &GetName() const;
+ ConstString GetName() const;
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create);
@@ -504,10 +476,10 @@ public:
GetChildAtNamePath(llvm::ArrayRef<std::pair<ConstString, bool>> names,
ConstString *name_of_error = nullptr);
- virtual lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ virtual lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
bool can_create);
- virtual size_t GetIndexOfChildWithName(const ConstString &name);
+ virtual size_t GetIndexOfChildWithName(ConstString name);
size_t GetNumChildren(uint32_t max = UINT32_MAX);
@@ -574,14 +546,14 @@ public:
// Change the name of the current ValueObject. Should *not* be used from a
// synthetic child provider as it would change the name of the non synthetic
// child as well.
- void SetName(const ConstString &name);
+ void SetName(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 GetSyntheticChild(ConstString key) const;
lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
@@ -618,7 +590,7 @@ public:
GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue,
bool synthValue);
- virtual lldb::ValueObjectSP CreateConstantValue(const ConstString &name);
+ virtual lldb::ValueObjectSP CreateConstantValue(ConstString name);
virtual lldb::ValueObjectSP Dereference(Status &error);
@@ -626,7 +598,7 @@ public:
// ValueObject as its parent. It should be used when we want to change the
// name of a ValueObject without modifying the actual ValueObject itself
// (e.g. sythetic child provider).
- virtual lldb::ValueObjectSP Clone(const ConstString &new_name);
+ virtual lldb::ValueObjectSP Clone(ConstString new_name);
virtual lldb::ValueObjectSP AddressOf(Status &error);
@@ -789,7 +761,6 @@ public:
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
@@ -801,10 +772,9 @@ public:
/// pointers, references, arrays and more. Again, it does so without
/// doing any expensive type completion.
///
- /// @return
+ /// \return
/// Returns \b true if the ValueObject might have children, or \b
/// false otherwise.
- //------------------------------------------------------------------
virtual bool MightHaveChildren();
virtual lldb::VariableSP GetVariable() { return nullptr; }
@@ -859,9 +829,7 @@ protected:
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
@@ -944,9 +912,7 @@ protected:
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.)
@@ -1000,15 +966,13 @@ protected:
void ClearUserVisibleData(
uint32_t items = ValueObject::eClearUserVisibleDataItemsAllStrings);
- void AddSyntheticChild(const ConstString &key, ValueObject *valobj);
+ void AddSyntheticChild(ConstString key, ValueObject *valobj);
DataExtractor &GetDataExtractor();
void ClearDynamicTypeInformation();
- //------------------------------------------------------------------
// Subclasses must implement the functions below.
- //------------------------------------------------------------------
virtual CompilerType GetCompilerTypeImpl() = 0;
@@ -1032,14 +996,12 @@ private:
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;
diff --git a/include/lldb/Core/ValueObjectCast.h b/include/lldb/Core/ValueObjectCast.h
index 34814d9b17bb8..feee493dfafbc 100644
--- a/include/lldb/Core/ValueObjectCast.h
+++ b/include/lldb/Core/ValueObjectCast.h
@@ -1,9 +1,8 @@
-//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===//
+//===-- ValueObjectCast.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,19 +20,14 @@
namespace lldb_private {
class ConstString;
-}
-
-namespace lldb_private {
-//---------------------------------------------------------------------------------
// A ValueObject that represents a given value represented as a different type.
-//---------------------------------------------------------------------------------
class ValueObjectCast : public ValueObject {
public:
~ValueObjectCast() override;
static lldb::ValueObjectSP Create(ValueObject &parent,
- const ConstString &name,
+ ConstString name,
const CompilerType &cast_type);
uint64_t GetByteSize() override;
@@ -53,7 +47,7 @@ public:
}
protected:
- ValueObjectCast(ValueObject &parent, const ConstString &name,
+ ValueObjectCast(ValueObject &parent, ConstString name,
const CompilerType &cast_type);
bool UpdateValue() override;
diff --git a/include/lldb/Core/ValueObjectChild.h b/include/lldb/Core/ValueObjectChild.h
index 6800775dc8f9d..76209a22ec204 100644
--- a/include/lldb/Core/ValueObjectChild.h
+++ b/include/lldb/Core/ValueObjectChild.h
@@ -1,9 +1,8 @@
//===-- ValueObjectChild.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,9 +25,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
// A child of another ValueObject.
-//----------------------------------------------------------------------
class ValueObjectChild : public ValueObject {
public:
~ValueObjectChild() override;
@@ -84,7 +81,7 @@ protected:
friend class ValueObjectConstResultImpl;
ValueObjectChild(ValueObject &parent, const CompilerType &compiler_type,
- const ConstString &name, uint64_t byte_size,
+ 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,
diff --git a/include/lldb/Core/ValueObjectConstResult.h b/include/lldb/Core/ValueObjectConstResult.h
index c1c56d8dcb223..3bc957ef2b849 100644
--- a/include/lldb/Core/ValueObjectConstResult.h
+++ b/include/lldb/Core/ValueObjectConstResult.h
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResult.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,18 +26,10 @@
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class ExecutionContextScope;
-}
-namespace lldb_private {
class Module;
-}
-namespace lldb_private {
-//----------------------------------------------------------------------
// A frozen ValueObject copied into host memory
-//----------------------------------------------------------------------
class ValueObjectConstResult : public ValueObject {
public:
~ValueObjectConstResult() override;
@@ -49,22 +40,22 @@ public:
static lldb::ValueObjectSP
Create(ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- const ConstString &name, const DataExtractor &data,
+ 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,
+ 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,
+ 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,
+ Value &value, ConstString name,
Module *module = nullptr);
// When an expression fails to evaluate, we return an error
@@ -135,23 +126,23 @@ private:
ValueObjectConstResult(ExecutionContextScope *exe_scope,
const CompilerType &compiler_type,
- const ConstString &name, const DataExtractor &data,
+ ConstString name, const DataExtractor &data,
lldb::addr_t address);
ValueObjectConstResult(ExecutionContextScope *exe_scope,
const CompilerType &compiler_type,
- const ConstString &name,
+ 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,
+ 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);
+ ConstString name, Module *module = nullptr);
ValueObjectConstResult(ExecutionContextScope *exe_scope, const Status &error);
diff --git a/include/lldb/Core/ValueObjectConstResultCast.h b/include/lldb/Core/ValueObjectConstResultCast.h
index bb2b4e6f092fb..be9b12b4b57cb 100644
--- a/include/lldb/Core/ValueObjectConstResultCast.h
+++ b/include/lldb/Core/ValueObjectConstResultCast.h
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResultCast.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,19 +22,12 @@
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class ValueObject;
-}
-
-namespace lldb_private {
class ValueObjectConstResultCast : public ValueObjectCast {
public:
- ValueObjectConstResultCast(ValueObject &parent, const ConstString &name,
+ ValueObjectConstResultCast(ValueObject &parent, ConstString name,
const CompilerType &cast_type,
lldb::addr_t live_address = LLDB_INVALID_ADDRESS);
diff --git a/include/lldb/Core/ValueObjectConstResultChild.h b/include/lldb/Core/ValueObjectConstResultChild.h
index f14fb75640e65..16fa74f71ed57 100644
--- a/include/lldb/Core/ValueObjectConstResultChild.h
+++ b/include/lldb/Core/ValueObjectConstResultChild.h
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResultChild.h ----------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,26 +19,18 @@
#include <stddef.h>
#include <stdint.h>
+
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class ValueObject;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
// A child of a ValueObjectConstResult.
-//----------------------------------------------------------------------
class ValueObjectConstResultChild : public ValueObjectChild {
public:
ValueObjectConstResultChild(ValueObject &parent,
const CompilerType &compiler_type,
- const ConstString &name, uint32_t byte_size,
+ 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,
diff --git a/include/lldb/Core/ValueObjectConstResultImpl.h b/include/lldb/Core/ValueObjectConstResultImpl.h
index 5ea47bb3b3fa3..ffac98e12e611 100644
--- a/include/lldb/Core/ValueObjectConstResultImpl.h
+++ b/include/lldb/Core/ValueObjectConstResultImpl.h
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResultImpl.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,24 +19,16 @@
#include <stdint.h>
namespace lldb_private {
class CompilerType;
-}
-namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class ValueObject;
}
namespace lldb_private {
-//----------------------------------------------------------------------
// A class wrapping common implementation details for operations in
// ValueObjectConstResult ( & Child ) that may need to jump from the host
// memory space into the target's memory space
-//----------------------------------------------------------------------
class ValueObjectConstResultImpl {
public:
ValueObjectConstResultImpl(ValueObject *valobj,
diff --git a/include/lldb/Core/ValueObjectDynamicValue.h b/include/lldb/Core/ValueObjectDynamicValue.h
index 0c9ec8cce06ef..f656d42e9a970 100644
--- a/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/include/lldb/Core/ValueObjectDynamicValue.h
@@ -1,9 +1,8 @@
//===-- ValueObjectDynamicValue.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,19 +26,11 @@
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class Declaration;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
-//----------------------------------------------------------------------
// A ValueObject that represents memory at a given address, viewed as some
// set lldb type.
-//----------------------------------------------------------------------
class ValueObjectDynamicValue : public ValueObject {
public:
~ValueObjectDynamicValue() override;
diff --git a/include/lldb/Core/ValueObjectList.h b/include/lldb/Core/ValueObjectList.h
index d17510f7f581e..42d19676d5d35 100644
--- a/include/lldb/Core/ValueObjectList.h
+++ b/include/lldb/Core/ValueObjectList.h
@@ -1,9 +1,8 @@
//===-- ValueObjectList.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,24 +18,10 @@
namespace lldb_private {
class ValueObject;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
// A collection of ValueObject values that
-//----------------------------------------------------------------------
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);
@@ -68,9 +53,7 @@ public:
}
protected:
typedef std::vector<lldb::ValueObjectSP> collection;
- //------------------------------------------------------------------
// Classes that inherit from ValueObjectList can see and modify these
- //------------------------------------------------------------------
collection m_value_objects;
};
diff --git a/include/lldb/Core/ValueObjectMemory.h b/include/lldb/Core/ValueObjectMemory.h
index c4b946af98ce3..df3557f149891 100644
--- a/include/lldb/Core/ValueObjectMemory.h
+++ b/include/lldb/Core/ValueObjectMemory.h
@@ -1,9 +1,8 @@
//===-- ValueObjectMemory.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,14 +23,9 @@
namespace lldb_private {
class ExecutionContextScope;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
// A ValueObject that represents memory at a given address, viewed as some
// set lldb type.
-//----------------------------------------------------------------------
class ValueObjectMemory : public ValueObject {
public:
~ValueObjectMemory() override;
@@ -75,9 +69,7 @@ private:
ValueObjectMemory(ExecutionContextScope *exe_scope, llvm::StringRef name,
const Address &address, const CompilerType &ast_type);
- //------------------------------------------------------------------
// For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ValueObjectMemory);
};
diff --git a/include/lldb/Core/ValueObjectRegister.h b/include/lldb/Core/ValueObjectRegister.h
index fb10c259e7d02..e584be6e60572 100644
--- a/include/lldb/Core/ValueObjectRegister.h
+++ b/include/lldb/Core/ValueObjectRegister.h
@@ -1,9 +1,8 @@
//===-- ValueObjectRegister.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,26 +23,13 @@
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class ExecutionContextScope;
-}
-namespace lldb_private {
class Scalar;
-}
-namespace lldb_private {
class Stream;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
// A ValueObject that contains a root variable that may or may not
// have children.
-//----------------------------------------------------------------------
class ValueObjectRegisterContext : public ValueObject {
public:
~ValueObjectRegisterContext() override;
@@ -75,9 +61,7 @@ protected:
private:
ValueObjectRegisterContext(ValueObject &parent,
lldb::RegisterContextSP &reg_ctx_sp);
- //------------------------------------------------------------------
// For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterContext);
};
@@ -104,10 +88,10 @@ public:
ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
- lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
bool can_create) override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
protected:
bool UpdateValue() override;
@@ -124,9 +108,7 @@ private:
ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx);
- //------------------------------------------------------------------
// For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ValueObjectRegisterSet);
};
@@ -180,9 +162,7 @@ private:
ValueObjectRegister(ExecutionContextScope *exe_scope,
lldb::RegisterContextSP &reg_ctx_sp, uint32_t reg_num);
- //------------------------------------------------------------------
// For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ValueObjectRegister);
};
diff --git a/include/lldb/Core/ValueObjectSyntheticFilter.h b/include/lldb/Core/ValueObjectSyntheticFilter.h
index 9495d4ca5e250..3b14a3e9f3885 100644
--- a/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -1,9 +1,8 @@
//===-- ValueObjectSyntheticFilter.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,22 +26,14 @@
namespace lldb_private {
class Declaration;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class SyntheticChildrenFrontEnd;
-}
-namespace lldb_private {
-//----------------------------------------------------------------------
// A ValueObject that obtains its children from some source other than
// real information
// This is currently used to implement Python-based children and filters but
// you can bind it to any source of synthetic information and have it behave
// accordingly
-//----------------------------------------------------------------------
class ValueObjectSynthetic : public ValueObject {
public:
~ValueObjectSynthetic() override;
@@ -63,10 +54,10 @@ public:
lldb::ValueObjectSP GetChildAtIndex(size_t idx, bool can_create) override;
- lldb::ValueObjectSP GetChildMemberWithName(const ConstString &name,
+ lldb::ValueObjectSP GetChildMemberWithName(ConstString name,
bool can_create) override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
lldb::ValueObjectSP
GetDynamicValue(lldb::DynamicValueType valueType) override;
@@ -142,7 +133,7 @@ protected:
// 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;
+ std::unique_ptr<SyntheticChildrenFrontEnd> m_synth_filter_up;
typedef ThreadSafeSTLMap<uint32_t, ValueObject *> ByIndexMap;
typedef ThreadSafeSTLMap<const char *, uint32_t> NameToIndexMap;
diff --git a/include/lldb/Core/ValueObjectVariable.h b/include/lldb/Core/ValueObjectVariable.h
index 81a8eabdacbb0..86bb8ef90070b 100644
--- a/include/lldb/Core/ValueObjectVariable.h
+++ b/include/lldb/Core/ValueObjectVariable.h
@@ -1,9 +1,8 @@
//===-- ValueObjectVariable.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,26 +23,13 @@
namespace lldb_private {
class DataExtractor;
-}
-namespace lldb_private {
class Declaration;
-}
-namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class ExecutionContextScope;
-}
-namespace lldb_private {
class SymbolContextScope;
-}
-
-namespace lldb_private {
-//----------------------------------------------------------------------
// A ValueObject that contains a root variable that may or may not
// have children.
-//----------------------------------------------------------------------
class ValueObjectVariable : public ValueObject {
public:
~ValueObjectVariable() override;
@@ -77,7 +63,7 @@ public:
bool SetData(DataExtractor &data, Status &error) override;
- virtual lldb::VariableSP GetVariable() override { return m_variable_sp; }
+ lldb::VariableSP GetVariable() override { return m_variable_sp; }
protected:
bool UpdateValue() override;
@@ -92,9 +78,7 @@ protected:
private:
ValueObjectVariable(ExecutionContextScope *exe_scope,
const lldb::VariableSP &var_sp);
- //------------------------------------------------------------------
// For ValueObject only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ValueObjectVariable);
};
diff --git a/include/lldb/Core/dwarf.h b/include/lldb/Core/dwarf.h
index 651a2bc294755..afe62e09fe168 100644
--- a/include/lldb/Core/dwarf.h
+++ b/include/lldb/Core/dwarf.h
@@ -1,22 +1,20 @@
//===-- dwarf.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef DebugBase_dwarf_h_
#define DebugBase_dwarf_h_
+#include "lldb/Utility/RangeMap.h"
#include <stdint.h>
// Get the DWARF constant definitions from llvm
#include "llvm/BinaryFormat/Dwarf.h"
-#include "lldb/Core/RangeMap.h"
-
// and stuff them in our default namespace
using namespace llvm::dwarf;
@@ -29,15 +27,8 @@ 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
-#else
-#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)
diff --git a/include/lldb/DataFormatters/CXXFunctionPointer.h b/include/lldb/DataFormatters/CXXFunctionPointer.h
index 13af2fd9da1c8..b5417895f7bf8 100644
--- a/include/lldb/DataFormatters/CXXFunctionPointer.h
+++ b/include/lldb/DataFormatters/CXXFunctionPointer.h
@@ -1,9 +1,8 @@
//===-- CXXFunctionPointer.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/DataVisualization.h b/include/lldb/DataFormatters/DataVisualization.h
index 9ca2e95cd9cb6..cdb2eab995fce 100644
--- a/include/lldb/DataFormatters/DataVisualization.h
+++ b/include/lldb/DataFormatters/DataVisualization.h
@@ -1,9 +1,8 @@
//===-- DataVisualization.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,23 +42,14 @@ public:
static lldb::TypeSummaryImplSP
GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp);
-#ifndef LLDB_DISABLE_PYTHON
- static lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-
static lldb::TypeFilterImplSP
GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
-#ifndef LLDB_DISABLE_PYTHON
static lldb::ScriptedSyntheticChildrenSP
GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-#ifndef LLDB_DISABLE_PYTHON
static lldb::SyntheticChildrenSP
GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
-#endif
static lldb::TypeValidatorImplSP
GetValidator(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
@@ -76,13 +66,13 @@ public:
class NamedSummaryFormats {
public:
- static bool GetSummaryFormat(const ConstString &type,
+ static bool GetSummaryFormat(ConstString type,
lldb::TypeSummaryImplSP &entry);
- static void Add(const ConstString &type,
+ static void Add(ConstString type,
const lldb::TypeSummaryImplSP &entry);
- static bool Delete(const ConstString &type);
+ static bool Delete(ConstString type);
static void Clear();
@@ -95,27 +85,27 @@ public:
class Categories {
public:
- static bool GetCategory(const ConstString &category,
+ static bool GetCategory(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 void Add(ConstString category);
- static bool Delete(const ConstString &category);
+ static bool Delete(ConstString category);
static void Clear();
- static void Clear(const ConstString &category);
+ static void Clear(ConstString category);
- static void Enable(const ConstString &category,
+ static void Enable(ConstString category,
TypeCategoryMap::Position = TypeCategoryMap::Default);
static void Enable(lldb::LanguageType lang_type);
- static void Disable(const ConstString &category);
+ static void Disable(ConstString category);
static void Disable(lldb::LanguageType lang_type);
diff --git a/include/lldb/DataFormatters/DumpValueObjectOptions.h b/include/lldb/DataFormatters/DumpValueObjectOptions.h
index 113c48afa6f87..c37411539de63 100644
--- a/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -1,9 +1,8 @@
//===-- DumpValueObjectOptions.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/FormatCache.h b/include/lldb/DataFormatters/FormatCache.h
index 2c09b65a420a8..7a6774b7f8378 100644
--- a/include/lldb/DataFormatters/FormatCache.h
+++ b/include/lldb/DataFormatters/FormatCache.h
@@ -1,10 +1,9 @@
//===-- FormatCache.h ---------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -72,29 +71,29 @@ private:
uint64_t m_cache_hits;
uint64_t m_cache_misses;
- Entry &GetEntry(const ConstString &type);
+ Entry &GetEntry(ConstString type);
public:
FormatCache();
- bool GetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
+ bool GetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
- bool GetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
+ bool GetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
- bool GetSynthetic(const ConstString &type,
+ bool GetSynthetic(ConstString type,
lldb::SyntheticChildrenSP &synthetic_sp);
- bool GetValidator(const ConstString &type,
+ bool GetValidator(ConstString type,
lldb::TypeValidatorImplSP &summary_sp);
- void SetFormat(const ConstString &type, lldb::TypeFormatImplSP &format_sp);
+ void SetFormat(ConstString type, lldb::TypeFormatImplSP &format_sp);
- void SetSummary(const ConstString &type, lldb::TypeSummaryImplSP &summary_sp);
+ void SetSummary(ConstString type, lldb::TypeSummaryImplSP &summary_sp);
- void SetSynthetic(const ConstString &type,
+ void SetSynthetic(ConstString type,
lldb::SyntheticChildrenSP &synthetic_sp);
- void SetValidator(const ConstString &type,
+ void SetValidator(ConstString type,
lldb::TypeValidatorImplSP &synthetic_sp);
void Clear();
diff --git a/include/lldb/DataFormatters/FormatClasses.h b/include/lldb/DataFormatters/FormatClasses.h
index 1f08485d02927..5144bc6079a9c 100644
--- a/include/lldb/DataFormatters/FormatClasses.h
+++ b/include/lldb/DataFormatters/FormatClasses.h
@@ -1,9 +1,8 @@
//===-- FormatClasses.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -123,14 +122,14 @@ public:
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);
+ m_type.m_compiler_type = type->GetForwardCompilerType();
}
}
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);
+ m_type.m_compiler_type = type;
}
}
@@ -140,15 +139,9 @@ public:
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();
+ if (m_type.m_compiler_type.IsValid())
+ return m_type.m_compiler_type;
return CompilerType();
}
@@ -156,11 +149,10 @@ public:
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
+ // TODO: Replace this with TypeAndOrName.
struct TypeOrName {
std::string m_type_name;
- TypePair m_type_pair;
+ CompilerType m_compiler_type;
};
TypeOrName m_type;
diff --git a/include/lldb/DataFormatters/FormatManager.h b/include/lldb/DataFormatters/FormatManager.h
index 9046ccf2e0bbf..afaafda47e761 100644
--- a/include/lldb/DataFormatters/FormatManager.h
+++ b/include/lldb/DataFormatters/FormatManager.h
@@ -1,9 +1,8 @@
//===-- FormatManager.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,19 +50,19 @@ public:
}
void
- EnableCategory(const ConstString &category_name,
+ EnableCategory(ConstString category_name,
TypeCategoryMap::Position pos = TypeCategoryMap::Default) {
EnableCategory(category_name, pos,
std::initializer_list<lldb::LanguageType>());
}
- void EnableCategory(const ConstString &category_name,
+ void EnableCategory(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,
+ void EnableCategory(ConstString category_name,
TypeCategoryMap::Position pos = TypeCategoryMap::Default,
std::initializer_list<lldb::LanguageType> langs = {}) {
TypeCategoryMap::ValueSP category_sp;
@@ -74,7 +73,7 @@ public:
}
}
- void DisableCategory(const ConstString &category_name) {
+ void DisableCategory(ConstString category_name) {
m_categories_map.Disable(category_name);
}
@@ -92,7 +91,7 @@ public:
void DisableAllCategories();
- bool DeleteCategory(const ConstString &category_name) {
+ bool DeleteCategory(ConstString category_name) {
return m_categories_map.Delete(category_name);
}
@@ -113,7 +112,7 @@ public:
return GetCategory(ConstString(category_name));
}
- lldb::TypeCategoryImplSP GetCategory(const ConstString &category_name,
+ lldb::TypeCategoryImplSP GetCategory(ConstString category_name,
bool can_create = true);
lldb::TypeFormatImplSP
@@ -125,15 +124,8 @@ public:
lldb::TypeFilterImplSP
GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
-#ifndef LLDB_DISABLE_PYTHON
lldb::ScriptedSyntheticChildrenSP
GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
- lldb::SyntheticChildrenSP
- GetSyntheticChildrenForType(lldb::TypeNameSpecifierImplSP type_sp);
-#endif
lldb::TypeValidatorImplSP
GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
@@ -144,10 +136,8 @@ public:
lldb::TypeSummaryImplSP GetSummaryFormat(ValueObject &valobj,
lldb::DynamicValueType use_dynamic);
-#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
GetSyntheticChildren(ValueObject &valobj, lldb::DynamicValueType use_dynamic);
-#endif
lldb::TypeValidatorImplSP GetValidator(ValueObject &valobj,
lldb::DynamicValueType use_dynamic);
@@ -174,7 +164,7 @@ public:
// 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);
+ static ConstString GetValidTypeName(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
diff --git a/include/lldb/DataFormatters/FormattersContainer.h b/include/lldb/DataFormatters/FormattersContainer.h
index dd8995d81132e..9d7d37343ac25 100644
--- a/include/lldb/DataFormatters/FormattersContainer.h
+++ b/include/lldb/DataFormatters/FormattersContainer.h
@@ -1,9 +1,8 @@
//===-- FormattersContainer.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,7 +42,7 @@ public:
// 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) {
+static inline ConstString GetValidTypeName_Impl(ConstString type) {
if (type.IsEmpty())
return type;
@@ -239,7 +238,7 @@ protected:
m_format_map.Add(type, entry);
}
- void Add_Impl(const ConstString &type, const MapValueType &entry,
+ void Add_Impl(ConstString type, const MapValueType &entry,
ConstString *dummy) {
m_format_map.Add(GetValidTypeName_Impl(type), entry);
}
diff --git a/include/lldb/DataFormatters/FormattersHelpers.h b/include/lldb/DataFormatters/FormattersHelpers.h
index 028d5cc27688f..79bd376c76eb6 100644
--- a/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/include/lldb/DataFormatters/FormattersHelpers.h
@@ -1,10 +1,9 @@
//===-- FormattersHelpers.h --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,7 +36,6 @@ void AddOneLineSummary(TypeCategoryImpl::SharedPointer category_sp,
ConstString type_name, TypeSummaryImpl::Flags flags,
bool regex = false);
-#ifndef LLDB_DISABLE_PYTHON
void AddCXXSummary(TypeCategoryImpl::SharedPointer category_sp,
CXXFunctionSummaryFormat::Callback funct,
const char *description, ConstString type_name,
@@ -53,7 +51,6 @@ 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);
diff --git a/include/lldb/DataFormatters/LanguageCategory.h b/include/lldb/DataFormatters/LanguageCategory.h
index f2ac628636d43..f109d46194ad9 100644
--- a/include/lldb/DataFormatters/LanguageCategory.h
+++ b/include/lldb/DataFormatters/LanguageCategory.h
@@ -1,10 +1,9 @@
//===-- LanguageCategory.h----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/StringPrinter.h b/include/lldb/DataFormatters/StringPrinter.h
index 38033f915bf96..41d5edd880216 100644
--- a/include/lldb/DataFormatters/StringPrinter.h
+++ b/include/lldb/DataFormatters/StringPrinter.h
@@ -1,9 +1,8 @@
//===-- StringPrinter.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/TypeCategory.h b/include/lldb/DataFormatters/TypeCategory.h
index 177e602e6ec33..bdb393abd848c 100644
--- a/include/lldb/DataFormatters/TypeCategory.h
+++ b/include/lldb/DataFormatters/TypeCategory.h
@@ -1,9 +1,8 @@
//===-- TypeCategory.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -69,10 +68,7 @@ private:
typedef FormatterContainerPair<TypeSummaryImpl> SummaryContainer;
typedef FormatterContainerPair<TypeFilterImpl> FilterContainer;
typedef FormatterContainerPair<TypeValidatorImpl> ValidatorContainer;
-
-#ifndef LLDB_DISABLE_PYTHON
typedef FormatterContainerPair<SyntheticChildren> SynthContainer;
-#endif // LLDB_DISABLE_PYTHON
public:
typedef uint16_t FormatCategoryItems;
@@ -86,10 +82,9 @@ public:
typedef FilterContainer::ExactMatchContainerSP FilterContainerSP;
typedef FilterContainer::RegexMatchContainerSP RegexFilterContainerSP;
-#ifndef LLDB_DISABLE_PYTHON
+
typedef SynthContainer::ExactMatchContainerSP SynthContainerSP;
typedef SynthContainer::RegexMatchContainerSP RegexSynthContainerSP;
-#endif // LLDB_DISABLE_PYTHON
typedef ValidatorContainer::ExactMatchContainerSP ValidatorContainerSP;
typedef ValidatorContainer::RegexMatchContainerSP RegexValidatorContainerSP;
@@ -138,7 +133,6 @@ public:
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) {
@@ -151,7 +145,6 @@ public:
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) {
@@ -188,14 +181,12 @@ public:
return m_filter_regex;
}
-#ifndef LLDB_DISABLE_PYTHON
SynthContainer::ExactMatchForEachCallback GetSynthExactCallback() const {
return m_synth_exact;
}
SynthContainer::RegexMatchForEachCallback GetSynthRegexCallback() const {
return m_synth_regex;
}
-#endif // LLDB_DISABLE_PYTHON
ValidatorContainer::ExactMatchForEachCallback
GetValidatorExactCallback() const {
@@ -216,10 +207,8 @@ public:
FilterContainer::ExactMatchForEachCallback m_filter_exact;
FilterContainer::RegexMatchForEachCallback m_filter_regex;
-#ifndef LLDB_DISABLE_PYTHON
SynthContainer::ExactMatchForEachCallback m_synth_exact;
SynthContainer::RegexMatchForEachCallback m_synth_regex;
-#endif // LLDB_DISABLE_PYTHON
ValidatorContainer::ExactMatchForEachCallback m_validator_exact;
ValidatorContainer::RegexMatchForEachCallback m_validator_regex;
@@ -239,10 +228,8 @@ public:
GetTypeFiltersContainer()->ForEach(foreach.GetFilterExactCallback());
GetRegexTypeFiltersContainer()->ForEach(foreach.GetFilterRegexCallback());
-#ifndef LLDB_DISABLE_PYTHON
GetTypeSyntheticsContainer()->ForEach(foreach.GetSynthExactCallback());
GetRegexTypeSyntheticsContainer()->ForEach(foreach.GetSynthRegexCallback());
-#endif // LLDB_DISABLE_PYTHON
GetTypeValidatorsContainer()->ForEach(foreach.GetValidatorExactCallback());
GetRegexTypeValidatorsContainer()->ForEach(
@@ -288,10 +275,8 @@ public:
FilterContainer::MapValueType
GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp);
-#ifndef LLDB_DISABLE_PYTHON
SynthContainer::MapValueType
GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp);
-#endif
ValidatorContainer::MapValueType
GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp);
@@ -311,7 +296,6 @@ public:
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForFilterAtIndex(size_t index);
-#ifndef LLDB_DISABLE_PYTHON
SynthContainerSP GetTypeSyntheticsContainer() {
return m_synth_cont.GetExactMatch();
}
@@ -326,7 +310,6 @@ public:
lldb::TypeNameSpecifierImplSP
GetTypeNameSpecifierForSyntheticAtIndex(size_t index);
-#endif // LLDB_DISABLE_PYTHON
ValidatorContainerSP GetTypeValidatorsContainer() {
return m_validator_cont.GetExactMatch();
@@ -392,9 +375,7 @@ private:
FormatContainer m_format_cont;
SummaryContainer m_summary_cont;
FilterContainer m_filter_cont;
-#ifndef LLDB_DISABLE_PYTHON
SynthContainer m_synth_cont;
-#endif // LLDB_DISABLE_PYTHON
ValidatorContainer m_validator_cont;
bool m_enabled;
@@ -432,11 +413,9 @@ private:
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>;
-#endif // LLDB_DISABLE_PYTHON
friend class FormattersContainer<ConstString, TypeValidatorImpl>;
friend class FormattersContainer<lldb::RegularExpressionSP,
diff --git a/include/lldb/DataFormatters/TypeCategoryMap.h b/include/lldb/DataFormatters/TypeCategoryMap.h
index 0ff078edf51b1..753b58cb465ea 100644
--- a/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -1,9 +1,8 @@
//===-- TypeCategoryMap.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -82,10 +81,8 @@ public:
lldb::TypeSummaryImplSP GetSummaryFormat(FormattersMatchData &match_data);
-#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
GetSyntheticChildren(FormattersMatchData &match_data);
-#endif
lldb::TypeValidatorImplSP GetValidator(FormattersMatchData &match_data);
diff --git a/include/lldb/DataFormatters/TypeFormat.h b/include/lldb/DataFormatters/TypeFormat.h
index 57ef0cf942cb6..77e8c0efc7069 100644
--- a/include/lldb/DataFormatters/TypeFormat.h
+++ b/include/lldb/DataFormatters/TypeFormat.h
@@ -1,10 +1,9 @@
//===-- TypeFormat.h ----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/TypeSummary.h b/include/lldb/DataFormatters/TypeSummary.h
index 78947728be293..9c97b3606f25b 100644
--- a/include/lldb/DataFormatters/TypeSummary.h
+++ b/include/lldb/DataFormatters/TypeSummary.h
@@ -1,9 +1,8 @@
//===-- TypeSummary.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,12 +26,9 @@ 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;
diff --git a/include/lldb/DataFormatters/TypeSynthetic.h b/include/lldb/DataFormatters/TypeSynthetic.h
index a9025fdb53977..93443cf7e84b7 100644
--- a/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/include/lldb/DataFormatters/TypeSynthetic.h
@@ -1,9 +1,8 @@
//===-- TypeSynthetic.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -48,7 +47,7 @@ public:
virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx) = 0;
- virtual size_t GetIndexOfChildWithName(const ConstString &name) = 0;
+ virtual size_t GetIndexOfChildWithName(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
@@ -111,7 +110,7 @@ public:
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override { return nullptr; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return UINT32_MAX;
}
@@ -327,7 +326,7 @@ public:
bool MightHaveChildren() override { return filter->GetCount() > 0; }
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
@@ -376,8 +375,6 @@ private:
DISALLOW_COPY_AND_ASSIGN(CXXSyntheticChildren);
};
-#ifndef LLDB_DISABLE_PYTHON
-
class ScriptedSyntheticChildren : public SyntheticChildren {
std::string m_python_class;
std::string m_python_code;
@@ -425,7 +422,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
lldb::ValueObjectSP GetSyntheticValue() override;
@@ -453,7 +450,6 @@ public:
private:
DISALLOW_COPY_AND_ASSIGN(ScriptedSyntheticChildren);
};
-#endif
} // namespace lldb_private
#endif // lldb_TypeSynthetic_h_
diff --git a/include/lldb/DataFormatters/TypeValidator.h b/include/lldb/DataFormatters/TypeValidator.h
index a50949cf22fe0..531812eeb0568 100644
--- a/include/lldb/DataFormatters/TypeValidator.h
+++ b/include/lldb/DataFormatters/TypeValidator.h
@@ -1,10 +1,9 @@
//===-- TypeValidator.h ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/ValueObjectPrinter.h b/include/lldb/DataFormatters/ValueObjectPrinter.h
index 13124c9210c8f..41adc2d2b5b22 100644
--- a/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -1,10 +1,9 @@
//===-- ValueObjectPrinter.h ---------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/DataFormatters/VectorIterator.h b/include/lldb/DataFormatters/VectorIterator.h
index f695d22905024..cde4be498b0f4 100644
--- a/include/lldb/DataFormatters/VectorIterator.h
+++ b/include/lldb/DataFormatters/VectorIterator.h
@@ -1,10 +1,9 @@
//===-- VectorIterator.h ----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,7 +31,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
ExecutionContextRef m_exe_ctx_ref;
diff --git a/include/lldb/DataFormatters/VectorType.h b/include/lldb/DataFormatters/VectorType.h
index 4ca0c4519f9f3..b757f758e77fe 100644
--- a/include/lldb/DataFormatters/VectorType.h
+++ b/include/lldb/DataFormatters/VectorType.h
@@ -1,9 +1,8 @@
//===-- VectorType.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Expression/DWARFExpression.h b/include/lldb/Expression/DWARFExpression.h
index cdede56d86d9d..21830a5628004 100644
--- a/include/lldb/Expression/DWARFExpression.h
+++ b/include/lldb/Expression/DWARFExpression.h
@@ -1,9 +1,8 @@
//===-- DWARFExpression.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,8 +21,7 @@ class DWARFUnit;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class DWARFExpression DWARFExpression.h
+/// \class DWARFExpression DWARFExpression.h
/// "lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location
/// expression and interprets it.
///
@@ -34,7 +32,6 @@ namespace lldb_private {
/// overhead from copying JIT-compiled code into the target is too high or
/// where the target cannot be run. This class encapsulates a single DWARF
/// location expression or a location list and interprets it.
-//----------------------------------------------------------------------
class DWARFExpression {
public:
enum LocationListFormat : uint8_t {
@@ -46,84 +43,64 @@ public:
// (.debug_loclists/.debug_loclists.dwo).
};
- //------------------------------------------------------------------
- /// Constructor
- //------------------------------------------------------------------
- explicit DWARFExpression(DWARFUnit *dwarf_cu);
+ DWARFExpression();
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] data
+ /// \param[in] data
/// A data extractor configured to read the DWARF location expression's
/// bytecode.
///
- /// @param[in] data_offset
+ /// \param[in] data_offset
/// The offset of the location expression in the extractor.
///
- /// @param[in] data_length
+ /// \param[in] data_length
/// The byte length of the location expression.
- //------------------------------------------------------------------
DWARFExpression(lldb::ModuleSP module, const DataExtractor &data,
- DWARFUnit *dwarf_cu, lldb::offset_t data_offset,
+ const DWARFUnit *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
+ /// \param[in] s
/// The stream to print to.
///
- /// @param[in] level
+ /// \param[in] level
/// The level of verbosity to use.
///
- /// @param[in] location_list_base_addr
+ /// \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
+ /// \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
+ /// \param[in] process
/// The process to use when resolving the load address
///
- /// @param[in] addr
+ /// \param[in] addr
/// The address to resolve
///
- /// @return
+ /// \return
/// True if IsLocationList() is true and the address was found;
/// false otherwise.
- //------------------------------------------------------------------
// bool
// LocationListContainsLoadAddress (Process* process, const Address &addr)
// const;
@@ -131,7 +108,6 @@ public:
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
@@ -140,22 +116,24 @@ public:
/// static variable since there is no other indication from DWARF debug
/// info.
///
- /// @param[in] op_addr_idx
+ /// \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
+ /// \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
+ /// \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);
+ void UpdateValue(uint64_t const_value, lldb::offset_t const_value_byte_size,
+ uint8_t addr_byte_size);
+
void SetModule(const lldb::ModuleSP &module) { m_module_wp = module; }
bool ContainsThreadLocalStorage() const;
@@ -165,178 +143,100 @@ public:
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
+ /// \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
+ /// \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,
lldb::addr_t loclist_base_load_addr,
const Value *initial_value_ptr, const Value *object_address_ptr,
Value &result, Status *error_ptr) const;
- //------------------------------------------------------------------
/// Wrapper for the static evaluate function that uses member variables to
/// populate many operands
- //------------------------------------------------------------------
bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::addr_t loclist_base_load_addr,
const Value *initial_value_ptr, const Value *object_address_ptr,
Value &result, Status *error_ptr) const;
- //------------------------------------------------------------------
/// Evaluate a DWARF location expression in a particular context
///
- /// @param[in] exe_ctx
+ /// \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
+ /// \param[in] opcode_ctx
/// The module which defined the expression.
///
- /// @param[in] opcodes
+ /// \param[in] opcodes
/// This is a static method so the opcodes need to be provided
/// explicitly.
///
- /// @param[in] expr_locals
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] offset
/// The offset of the location expression in the data extractor.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of the location expression.
///
- /// @param[in] reg_set
+ /// \param[in] reg_set
/// The call-frame-info style register kind.
///
- /// @param[in] initial_value_ptr
+ /// \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
+ /// \param[in] result
/// A value into which the result of evaluating the expression is
/// to be placed.
///
- /// @param[in] error_ptr
+ /// \param[in] error_ptr
/// If non-NULL, used to report errors in expression evaluation.
///
- /// @return
+ /// \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, RegisterContext *reg_ctx,
lldb::ModuleSP opcode_ctx, const DataExtractor &opcodes,
- DWARFUnit *dwarf_cu, const lldb::offset_t offset,
+ const DWARFUnit *dwarf_cu, const lldb::offset_t offset,
const lldb::offset_t length,
const lldb::RegisterKind reg_set,
const Value *initial_value_ptr,
@@ -366,26 +266,24 @@ public:
bool MatchesOperand(StackFrame &frame, const Instruction::Operand &op);
-protected:
- //------------------------------------------------------------------
+private:
/// Pretty-prints the location expression to a stream
///
- /// @param[in] stream
+ /// \param[in] stream
/// The stream to use for pretty-printing.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into the data buffer of the opcodes to be printed.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of the opcodes to be printed.
///
- /// @param[in] level
+ /// \param[in] level
/// The level of detail to use in pretty-printing.
///
- /// @param[in] abi
+ /// \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;
@@ -399,22 +297,24 @@ protected:
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
- DWARFUnit *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)
+ /// Module which defined this expression.
+ lldb::ModuleWP m_module_wp;
+
+ /// A data extractor capable of reading opcode bytes
+ DataExtractor m_data;
+
+ /// 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)
+ const DWARFUnit *m_dwarf_cu;
+
+ /// One of the defines that starts with LLDB_REGKIND_
+ lldb::RegisterKind m_reg_kind;
+
+ /// A value used to slide the location list offsets so that m_c they are
+ /// relative to the object that owns the location list (the function for
+ /// frame base and variable location lists)
+ lldb::addr_t m_loclist_slide;
};
} // namespace lldb_private
diff --git a/include/lldb/Expression/DiagnosticManager.h b/include/lldb/Expression/DiagnosticManager.h
index 83e67df2649ab..7e3e2bb8606a1 100644
--- a/include/lldb/Expression/DiagnosticManager.h
+++ b/include/lldb/Expression/DiagnosticManager.h
@@ -1,9 +1,8 @@
//===-- DiagnosticManager.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Expression/DynamicCheckerFunctions.h b/include/lldb/Expression/DynamicCheckerFunctions.h
new file mode 100644
index 0000000000000..7be24b6ea962b
--- /dev/null
+++ b/include/lldb/Expression/DynamicCheckerFunctions.h
@@ -0,0 +1,62 @@
+//===-- DynamicCheckerFunctions.h -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_DynamicCheckerFunctions_h_
+#define liblldb_DynamicCheckerFunctions_h_
+
+#include "lldb/lldb-types.h"
+
+namespace lldb_private {
+
+class DiagnosticManager;
+class ExecutionContext;
+
+/// Encapsulates dynamic check functions used by expressions.
+///
+/// Each of the utility functions encapsulated in this class is responsible
+/// for validating some data that an expression is about to use. Examples
+/// are:
+///
+/// a = *b; // check that b is a valid pointer
+/// [b init]; // check that b is a valid object to send "init" to
+///
+/// The class installs each checker function into the target process and makes
+/// it available to IRDynamicChecks to use.
+class DynamicCheckerFunctions {
+public:
+ enum DynamicCheckerFunctionsKind {
+ DCF_Clang,
+ };
+
+ DynamicCheckerFunctions(DynamicCheckerFunctionsKind kind) : m_kind(kind) {}
+ virtual ~DynamicCheckerFunctions() = default;
+
+ /// 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.
+ virtual bool Install(DiagnosticManager &diagnostic_manager,
+ ExecutionContext &exe_ctx) = 0;
+ virtual bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message) = 0;
+
+ DynamicCheckerFunctionsKind GetKind() const { return m_kind; }
+
+private:
+ const DynamicCheckerFunctionsKind m_kind;
+};
+} // namespace lldb_private
+
+#endif // liblldb_DynamicCheckerFunctions_h_
diff --git a/include/lldb/Expression/Expression.h b/include/lldb/Expression/Expression.h
index 162dcd3e4672e..2f0183cf269b7 100644
--- a/include/lldb/Expression/Expression.h
+++ b/include/lldb/Expression/Expression.h
@@ -1,9 +1,8 @@
//===-- Expression.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,8 +22,7 @@ namespace lldb_private {
class RecordingMemoryManager;
-//----------------------------------------------------------------------
-/// @class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates
+/// \class Expression Expression.h "lldb/Expression/Expression.h" Encapsulates
/// a single expression for use in lldb
///
/// LLDB uses expressions for various purposes, notably to call functions
@@ -32,78 +30,72 @@ class RecordingMemoryManager;
/// objects needed to parse and interpret or JIT an expression. It uses the
/// expression parser appropriate to the language of the expression to produce
/// LLVM IR from the expression.
-//----------------------------------------------------------------------
class Expression {
public:
+ /// Discriminator for LLVM-style RTTI (dyn_cast<> et al.)
+ enum ExpressionKind {
+ eKindFunctionCaller,
+ eKindClangFunctionCaller,
+ eKindUserExpression,
+ eKindLLVMUserExpression,
+ eKindClangUserExpression,
+ eKindUtilityFunction,
+ eKindClangUtilityFunction,
+ };
+
enum ResultType { eResultTypeAny, eResultTypeId };
- Expression(Target &target);
+ Expression(Target &target, ExpressionKind kind);
- Expression(ExecutionContextScope &exe_scope);
+ Expression(ExecutionContextScope &exe_scope, ExpressionKind kind);
- //------------------------------------------------------------------
/// 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; }
- //------------------------------------------------------------------
/// Called to notify the expression that it is about to be executed.
- //------------------------------------------------------------------
virtual void WillStartExecuting() {}
- //------------------------------------------------------------------
/// Called to notify the expression that its execution has finished.
- //------------------------------------------------------------------
virtual void DidFinishExecuting() {}
virtual ExpressionTypeSystemHelper *GetTypeSystemHelper() { return nullptr; }
+ /// LLVM-style RTTI support.
+ ExpressionKind getKind() const { return m_kind; }
+
+private:
+ /// LLVM-style RTTI support.
+ const ExpressionKind m_kind;
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
diff --git a/include/lldb/Expression/ExpressionParser.h b/include/lldb/Expression/ExpressionParser.h
index 7d337bd00ca63..59f7c1592e83d 100644
--- a/include/lldb/Expression/ExpressionParser.h
+++ b/include/lldb/Expression/ExpressionParser.h
@@ -1,9 +1,8 @@
//===-- ExpressionParser.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,58 +18,51 @@ namespace lldb_private {
class IRExecutionUnit;
-//----------------------------------------------------------------------
-/// @class ExpressionParser ExpressionParser.h
+/// \class ExpressionParser ExpressionParser.h
/// "lldb/Expression/ExpressionParser.h" Encapsulates an instance of a
/// compiler that can parse expressions.
///
/// ExpressionParser is the base class for llvm based Expression parsers.
-//----------------------------------------------------------------------
class ExpressionParser {
public:
- //------------------------------------------------------------------
/// Constructor
///
/// Initializes class variables.
///
- /// @param[in] exe_scope,
+ /// \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
+ /// \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(){};
- //------------------------------------------------------------------
/// Attempts to find possible command line completions for the given
/// expression.
///
- /// @param[out] request
+ /// \param[out] request
/// The completion request to fill out. The completion should be a string
/// that would complete the current token at the cursor position.
/// Note that the string in the list replaces the current token
/// in the command line.
///
- /// @param[in] line
+ /// \param[in] line
/// The line with the completion cursor inside the expression as a string.
/// The first line in the expression has the number 0.
///
- /// @param[in] pos
+ /// \param[in] pos
/// The character position in the line with the completion cursor.
/// If the value is 0, then the cursor is on top of the first character
/// in the line (i.e. the user has requested completion from the start of
/// the expression).
///
- /// @param[in] typed_pos
+ /// \param[in] typed_pos
/// The cursor position in the line as typed by the user. If the user
/// expression has not been transformed in some form (e.g. wrapping it
/// in a function body for C languages), then this is equal to the
@@ -78,73 +70,66 @@ public:
/// 'pos' (e.g. a value of 0 means the cursor is at start of the
/// expression).
///
- /// @return
+ /// \return
/// True if we added any completion results to the output;
/// false otherwise.
- //------------------------------------------------------------------
virtual bool Complete(CompletionRequest &request, unsigned line, unsigned pos,
unsigned typed_pos) = 0;
- //------------------------------------------------------------------
/// Parse a single expression and convert it to IR using Clang. Don't wrap
/// the expression in anything at all.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager in which to store the errors and warnings.
///
- /// @return
+ /// \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
+ /// \param[in] diagnostic_manager
/// The diagnostic manager containing fixit's to apply.
///
- /// @return
+ /// \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
+ /// \param[out] func_addr
/// The address to which the function has been written.
///
- /// @param[out] func_end
+ /// \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
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to write the function into.
///
- /// @param[out] can_interpret
+ /// \param[out] can_interpret
/// Set to true if the expression could be interpreted statically;
/// untouched otherwise.
///
- /// @param[in] execution_policy
+ /// \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
+ /// \return
/// An error code indicating the success or failure of the operation.
/// Test with Success().
- //------------------------------------------------------------------
virtual Status
PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end,
std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
diff --git a/include/lldb/Expression/ExpressionSourceCode.h b/include/lldb/Expression/ExpressionSourceCode.h
index b5a6187bf3c5f..d0d01b5f9b596 100644
--- a/include/lldb/Expression/ExpressionSourceCode.h
+++ b/include/lldb/Expression/ExpressionSourceCode.h
@@ -1,9 +1,8 @@
//===-- ExpressionSourceCode.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,42 +10,19 @@
#define liblldb_ExpressionSourceCode_h
#include "lldb/lldb-enumerations.h"
+#include "llvm/ADT/ArrayRef.h"
#include <string>
namespace lldb_private {
-class ExecutionContext;
-
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);
-
-private:
+protected:
ExpressionSourceCode(const char *name, const char *prefix, const char *body,
bool wrap)
: m_name(name), m_prefix(prefix), m_body(body), m_wrap(wrap) {}
diff --git a/include/lldb/Expression/ExpressionTypeSystemHelper.h b/include/lldb/Expression/ExpressionTypeSystemHelper.h
index ffcad54fb9f9b..9c645532cdc19 100644
--- a/include/lldb/Expression/ExpressionTypeSystemHelper.h
+++ b/include/lldb/Expression/ExpressionTypeSystemHelper.h
@@ -1,10 +1,9 @@
//===-- ExpressionTypeSystemHelper.h ---------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,8 +14,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h
+/// \class ExpressionTypeSystemHelper ExpressionTypeSystemHelper.h
/// "lldb/Expression/ExpressionTypeSystemHelper.h"
/// A helper object that the Expression can pass to its ExpressionParser
/// to provide generic information that
@@ -24,7 +22,6 @@ namespace lldb_private {
/// dyn_cast so that the expression parser can cast it back to the requisite
/// specific type.
///
-//----------------------------------------------------------------------
class ExpressionTypeSystemHelper {
public:
diff --git a/include/lldb/Expression/ExpressionVariable.h b/include/lldb/Expression/ExpressionVariable.h
index 01e9c416e7c01..08c987270bfe7 100644
--- a/include/lldb/Expression/ExpressionVariable.h
+++ b/include/lldb/Expression/ExpressionVariable.h
@@ -1,9 +1,8 @@
//===-- ExpressionVariable.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,14 +20,10 @@
namespace lldb_private {
-class ClangExpressionVariable;
-
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; }
@@ -39,7 +34,7 @@ public:
size_t GetByteSize() { return m_frozen_sp->GetByteSize(); }
- const ConstString &GetName() { return m_frozen_sp->GetName(); }
+ ConstString GetName() { return m_frozen_sp->GetName(); }
lldb::ValueObjectSP GetValueObject() { return m_frozen_sp; }
@@ -62,7 +57,7 @@ public:
m_frozen_sp->GetValue().SetCompilerType(compiler_type);
}
- void SetName(const ConstString &name) { m_frozen_sp->SetName(name); }
+ void SetName(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-
@@ -119,18 +114,14 @@ public:
LLVMCastKind m_kind;
};
-//----------------------------------------------------------------------
-/// @class ExpressionVariableList ExpressionVariable.h
+/// \class ExpressionVariableList ExpressionVariable.h
/// "lldb/Expression/ExpressionVariable.h"
/// A list of variable references.
///
/// This class stores variables internally, acting as the permanent store.
-//----------------------------------------------------------------------
class ExpressionVariableList {
public:
- //----------------------------------------------------------------------
/// Implementation of methods in ExpressionVariableListBase
- //----------------------------------------------------------------------
size_t GetSize() { return m_variables.size(); }
lldb::ExpressionVariableSP GetVariableAtIndex(size_t index) {
@@ -161,17 +152,15 @@ public:
return false;
}
- //----------------------------------------------------------------------
/// Finds a variable by name in the list.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the requested variable.
///
- /// @return
+ /// \return
/// The variable requested, or nullptr if that variable is not in the
/// list.
- //----------------------------------------------------------------------
- lldb::ExpressionVariableSP GetVariable(const ConstString &name) {
+ lldb::ExpressionVariableSP GetVariable(ConstString name) {
lldb::ExpressionVariableSP var_sp;
for (size_t index = 0, size = GetSize(); index < size; ++index) {
var_sp = GetVariableAtIndex(index);
@@ -215,9 +204,7 @@ private:
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; }
@@ -231,7 +218,7 @@ public:
virtual lldb::ExpressionVariableSP
CreatePersistentVariable(ExecutionContextScope *exe_scope,
- const ConstString &name, const CompilerType &type,
+ ConstString name, const CompilerType &type,
lldb::ByteOrder byte_order,
uint32_t addr_byte_size) = 0;
@@ -245,7 +232,10 @@ public:
virtual void
RemovePersistentVariable(lldb::ExpressionVariableSP variable) = 0;
- virtual lldb::addr_t LookupSymbol(const ConstString &name);
+ virtual llvm::Optional<CompilerType>
+ GetCompilerTypeFromPersistentDecl(ConstString type_name) = 0;
+
+ virtual lldb::addr_t LookupSymbol(ConstString name);
void RegisterExecutionUnit(lldb::IRExecutionUnitSP &execution_unit_sp);
diff --git a/include/lldb/Expression/FunctionCaller.h b/include/lldb/Expression/FunctionCaller.h
index 0ec7e202dac9b..ea9d0205bf867 100644
--- a/include/lldb/Expression/FunctionCaller.h
+++ b/include/lldb/Expression/FunctionCaller.h
@@ -1,9 +1,8 @@
//===-- FunctionCaller.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,8 +22,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h"
+/// \class FunctionCaller FunctionCaller.h "lldb/Expression/FunctionCaller.h"
/// Encapsulates a function that can be called.
///
/// A given FunctionCaller object can handle a single function signature.
@@ -55,152 +53,141 @@ namespace lldb_private {
///
/// 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 {
public:
- //------------------------------------------------------------------
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindFunctionCaller;
+ }
+
/// Constructor
///
- /// @param[in] exe_scope
+ /// \param[in] exe_scope
/// An execution context scope that gets us at least a target and
/// process.
///
- /// @param[in] ast_context
+ /// \param[in] ast_context
/// The AST context to evaluate argument types in.
///
- /// @param[in] return_qualtype
+ /// \param[in] return_qualtype
/// An opaque Clang QualType for the function result. Should be
/// defined in ast_context.
///
- /// @param[in] function_address
+ /// \param[in] function_address
/// The address of the function to call.
///
- /// @param[in] arg_value_list
+ /// \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
+ /// \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
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report parser errors to.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to insert the function and its arguments
/// into.
///
- /// @param[in,out] args_addr_ref
+ /// \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
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to insert the function and its arguments
/// into.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
bool WriteFunctionWrapper(ExecutionContext &exe_ctx,
DiagnosticManager &diagnostic_manager);
- //------------------------------------------------------------------
/// Insert the default function argument struct
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to insert the function and its arguments
/// into.
///
- /// @param[in,out] args_addr_ref
+ /// \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
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to insert the function and its arguments
/// into.
///
- /// @param[in,out] args_addr_ref
+ /// \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
+ /// \param[in] arg_values
/// The values of the function's arguments.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The thread & process in which this function will run.
///
- /// @param[in] args_addr_ptr
+ /// \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
@@ -212,118 +199,99 @@ public:
/// this should point to an already allocated structure with the values
/// already written.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @param[in] options
+ /// \param[in] options
/// The options for this expression execution.
///
- /// @param[out] results
+ /// \param[out] results
/// The result value will be put here after running the function.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to insert the function and its arguments
/// into.
///
- /// @param[in] func_addr
+ /// \param[in] func_addr
/// The address of the function in the target process.
///
- /// @param[in] args_addr
+ /// \param[in] args_addr
/// The address of the argument struct.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @param[in] stop_others
+ /// \param[in] stop_others
/// True if other threads should pause during execution.
///
- /// @param[in] unwind_on_error
+ /// \param[in] unwind_on_error
/// True if the thread plan may simply be discarded if an error occurs.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to retrieve the result from.
///
- /// @param[in] args_addr
+ /// \param[in] args_addr
/// The address of the argument struct.
///
- /// @param[out] ret_value
+ /// \param[out] ret_value
/// The value returned by the function.
///
- /// @return
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to insert the function and its arguments
/// into.
///
- /// @param[in] args_addr
+ /// \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; }
@@ -362,7 +330,6 @@ protected:
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>
@@ -370,7 +337,6 @@ protected:
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.
diff --git a/include/lldb/Expression/IRDynamicChecks.h b/include/lldb/Expression/IRDynamicChecks.h
deleted file mode 100644
index f31c03cfb9efa..0000000000000
--- a/include/lldb/Expression/IRDynamicChecks.h
+++ /dev/null
@@ -1,171 +0,0 @@
-//===-- IRDynamicChecks.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_IRDynamicChecks_h_
-#define liblldb_IRDynamicChecks_h_
-
-#include "lldb/lldb-types.h"
-#include "llvm/Pass.h"
-
-namespace llvm {
-class BasicBlock;
-class CallInst;
-class Constant;
-class Function;
-class Instruction;
-class Module;
-class DataLayout;
-class Value;
-}
-
-namespace lldb_private {
-
-class ClangExpressionDeclMap;
-class ExecutionContext;
-class Stream;
-
-//----------------------------------------------------------------------
-/// @class DynamicCheckerFunctions IRDynamicChecks.h
-/// "lldb/Expression/IRDynamicChecks.h" Encapsulates dynamic check functions
-/// used by expressions.
-///
-/// Each of the utility functions encapsulated in this class is responsible
-/// for validating some data that an expression is about to use. Examples
-/// are:
-///
-/// a = *b; // check that b is a valid pointer [b init]; // check that b
-/// is a valid object to send "init" to
-///
-/// The class installs each checker function into the target process and makes
-/// it available to IRDynamicChecks to use.
-//----------------------------------------------------------------------
-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;
-};
-
-//----------------------------------------------------------------------
-/// @class IRDynamicChecks IRDynamicChecks.h
-/// "lldb/Expression/IRDynamicChecks.h" 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 methods on objects that do not respond to them, and so forth.
-///
-/// IRDynamicChecks adds calls to the functions in DynamicCheckerFunctions to
-/// appropriate locations in an expression's IR.
-//----------------------------------------------------------------------
-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;
-
-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
-};
-
-} // namespace lldb_private
-
-#endif // liblldb_IRDynamicChecks_h_
diff --git a/include/lldb/Expression/IRExecutionUnit.h b/include/lldb/Expression/IRExecutionUnit.h
index b966d135deabc..beff44db9d5ed 100644
--- a/include/lldb/Expression/IRExecutionUnit.h
+++ b/include/lldb/Expression/IRExecutionUnit.h
@@ -1,9 +1,8 @@
//===-- IRExecutionUnit.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,8 +36,7 @@ namespace lldb_private {
class Status;
-//----------------------------------------------------------------------
-/// @class IRExecutionUnit IRExecutionUnit.h
+/// \class IRExecutionUnit IRExecutionUnit.h
/// "lldb/Expression/IRExecutionUnit.h" Contains the IR and, optionally, JIT-
/// compiled code for a module.
///
@@ -55,22 +53,17 @@ class Status;
/// 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 {
public:
- //------------------------------------------------------------------
/// Constructor
- //------------------------------------------------------------------
- IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_ap,
- std::unique_ptr<llvm::Module> &module_ap, ConstString &name,
+ IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_up,
+ std::unique_ptr<llvm::Module> &module_up, 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; }
@@ -85,19 +78,15 @@ public:
void GetRunnableInfo(Status &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, Status &error);
void FreeNow(lldb::addr_t allocation);
- //------------------------------------------------------------------
/// ObjectFileJITDelegate overrides
- //------------------------------------------------------------------
lldb::ByteOrder GetByteOrder() const override;
uint32_t GetAddressByteSize() const override;
@@ -112,41 +101,37 @@ public:
lldb::ModuleSP GetJITModule();
- lldb::addr_t FindSymbol(const ConstString &name);
+ lldb::addr_t FindSymbol(ConstString name, bool &missing_weak);
void GetStaticInitializers(std::vector<lldb::addr_t> &static_initializers);
- //----------------------------------------------------------------------
- /// @class JittedFunction IRExecutionUnit.h
+ /// \class JittedFunction IRExecutionUnit.h
/// "lldb/Expression/IRExecutionUnit.h"
/// 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
m_remote_addr; ///< The address of the function in the target's memory
- //------------------------------------------------------------------
/// Constructor
///
/// Initializes class variabes.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the function.
///
- /// @param[in] local_addr
+ /// \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
+ /// \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)
@@ -177,63 +162,53 @@ public:
}
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
+ /// \param[in] local_address
/// The address in the debugger.
///
- /// @return
+ /// \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
+ /// \param[in] local_address
/// The address in the debugger.
///
- /// @return
+ /// \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
+ /// \param[in] process
/// The process to allocate memory in.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] local_address
/// The process containing the allocations.
///
- /// @return
+ /// \return
/// True <=> all allocations were performed successfully.
- //------------------------------------------------------------------
bool WriteData(lldb::ProcessSP &process_sp);
Status DisassembleFunction(Stream &stream, lldb::ProcessSP &process_sp);
@@ -241,7 +216,7 @@ private:
struct SearchSpec;
void CollectCandidateCNames(std::vector<SearchSpec> &C_specs,
- const ConstString &name);
+ ConstString name);
void CollectCandidateCPlusPlusNames(std::vector<SearchSpec> &CPP_specs,
const std::vector<SearchSpec> &C_specs,
@@ -251,7 +226,8 @@ private:
const std::vector<SearchSpec> &C_specs);
lldb::addr_t FindInSymbols(const std::vector<SearchSpec> &specs,
- const lldb_private::SymbolContext &sc);
+ const lldb_private::SymbolContext &sc,
+ bool &symbol_was_missing_weak);
lldb::addr_t FindInRuntimes(const std::vector<SearchSpec> &specs,
const lldb_private::SymbolContext &sc);
@@ -259,7 +235,7 @@ private:
lldb::addr_t FindInUserDefinedSymbols(const std::vector<SearchSpec> &specs,
const lldb_private::SymbolContext &sc);
- void ReportSymbolLookupError(const ConstString &name);
+ void ReportSymbolLookupError(ConstString name);
class MemoryManager : public llvm::SectionMemoryManager {
public:
@@ -267,59 +243,53 @@ private:
~MemoryManager() override;
- //------------------------------------------------------------------
/// Allocate space for executable code, and add it to the m_spaceBlocks
/// map
///
- /// @param[in] Size
+ /// \param[in] Size
/// The size of the area.
///
- /// @param[in] Alignment
+ /// \param[in] Alignment
/// The required alignment of the area.
///
- /// @param[in] SectionID
+ /// \param[in] SectionID
/// A unique identifier for the section.
///
- /// @return
+ /// \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
+ /// \param[in] Size
/// The size of the area.
///
- /// @param[in] Alignment
+ /// \param[in] Alignment
/// The required alignment of the area.
///
- /// @param[in] SectionID
+ /// \param[in] SectionID
/// A unique identifier for the section.
///
- /// @param[in] IsReadOnly
+ /// \param[in] IsReadOnly
/// Flag indicating the section is read-only.
///
- /// @return
+ /// \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
+ /// \param[out] ErrMsg
/// The error that prevented the page protection from succeeding.
///
- /// @return
+ /// \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:
@@ -332,31 +302,36 @@ private:
size_t Size) override {}
uint64_t getSymbolAddress(const std::string &Name) override;
+
+ // Find the address of the symbol Name. If Name is a missing weak symbol
+ // then missing_weak will be true.
+ uint64_t GetSymbolAddressAndPresence(const std::string &Name,
+ bool &missing_weak);
+
+ llvm::JITSymbol findSymbol(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.
+ std::unique_ptr<SectionMemoryManager> m_default_mm_up; ///< 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
+ /// \class AllocationRecord IRExecutionUnit.h
/// "lldb/Expression/IRExecutionUnit.h" 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
@@ -393,11 +368,11 @@ private:
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::LLVMContext> m_context_up;
+ std::unique_ptr<llvm::ExecutionEngine> m_execution_engine_up;
+ std::unique_ptr<llvm::ObjectCache> m_object_cache_up;
std::unique_ptr<llvm::Module>
- m_module_ap; ///< Holder for the module until it's been handed off
+ m_module_up; ///< 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
diff --git a/include/lldb/Expression/IRInterpreter.h b/include/lldb/Expression/IRInterpreter.h
index 2d87346b70663..6148093e718ff 100644
--- a/include/lldb/Expression/IRInterpreter.h
+++ b/include/lldb/Expression/IRInterpreter.h
@@ -1,9 +1,8 @@
//===-- IRInterpreter.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,15 +26,13 @@ class ClangExpressionDeclMap;
class IRMemoryMap;
}
-//----------------------------------------------------------------------
-/// @class IRInterpreter IRInterpreter.h "lldb/Expression/IRInterpreter.h"
+/// \class IRInterpreter IRInterpreter.h "lldb/Expression/IRInterpreter.h"
/// Attempt to interpret the function's code if it does not require
/// running the target.
///
/// In some cases, the IR for an expression can be evaluated entirely in the
/// debugger, manipulating variables but not executing any code in the target.
/// The IRInterpreter attempts to do this.
-//----------------------------------------------------------------------
class IRInterpreter {
public:
static bool CanInterpret(llvm::Module &module, llvm::Function &function,
diff --git a/include/lldb/Expression/IRMemoryMap.h b/include/lldb/Expression/IRMemoryMap.h
index 026ca6b981106..d6a17a9848fb6 100644
--- a/include/lldb/Expression/IRMemoryMap.h
+++ b/include/lldb/Expression/IRMemoryMap.h
@@ -1,9 +1,8 @@
-//===-- IRExecutionUnit.h ---------------------------------------*- C++ -*-===//
+//===-- IRMemoryMap.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,8 +17,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class IRMemoryMap IRMemoryMap.h "lldb/Expression/IRMemoryMap.h"
+/// \class IRMemoryMap IRMemoryMap.h "lldb/Expression/IRMemoryMap.h"
/// Encapsulates memory that may exist in the process but must
/// also be available in the host process.
///
@@ -33,7 +31,6 @@ namespace lldb_private {
/// address in the tar at which they reside. If the inferior does not exist,
/// allocations still get made-up addresses. If an inferior appears at some
/// point, then those addresses need to be re-mapped.
-//----------------------------------------------------------------------
class IRMemoryMap {
public:
IRMemoryMap(lldb::TargetSP target_sp);
diff --git a/include/lldb/Expression/LLVMUserExpression.h b/include/lldb/Expression/LLVMUserExpression.h
index 1ba822265fcaa..c2af7239951b5 100644
--- a/include/lldb/Expression/LLVMUserExpression.h
+++ b/include/lldb/Expression/LLVMUserExpression.h
@@ -1,9 +1,8 @@
//===-- LLVMUserExpression.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,8 +19,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class LLVMUserExpression LLVMUserExpression.h
+/// \class LLVMUserExpression LLVMUserExpression.h
/// "lldb/Expression/LLVMUserExpression.h" Encapsulates a one-time expression
/// for use in lldb.
///
@@ -31,9 +29,13 @@ namespace lldb_private {
/// expression. The actual parsing part will be provided by the specific
/// implementations of LLVMUserExpression - which will be vended through the
/// appropriate TypeSystem.
-//----------------------------------------------------------------------
class LLVMUserExpression : public UserExpression {
public:
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindLLVMUserExpression;
+ }
+
// 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
@@ -49,7 +51,8 @@ public:
LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
- const EvaluateExpressionOptions &options);
+ const EvaluateExpressionOptions &options,
+ ExpressionKind kind);
~LLVMUserExpression() override;
bool FinalizeJITExecution(
@@ -60,10 +63,8 @@ public:
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;
@@ -98,9 +99,9 @@ protected:
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.
+ std::unique_ptr<Materializer> m_materializer_up; ///< 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
diff --git a/include/lldb/Expression/Materializer.h b/include/lldb/Expression/Materializer.h
index 0bdfd372e9214..603b4e0066cd4 100644
--- a/include/lldb/Expression/Materializer.h
+++ b/include/lldb/Expression/Materializer.h
@@ -1,9 +1,8 @@
//===-- Materializer.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Expression/REPL.h b/include/lldb/Expression/REPL.h
index f7780772cbeac..850d2f6f961a9 100644
--- a/include/lldb/Expression/REPL.h
+++ b/include/lldb/Expression/REPL.h
@@ -1,9 +1,8 @@
//===-- REPL.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,17 +11,16 @@
#include <string>
-#include "lldb/../../source/Commands/CommandObjectExpression.h"
+#include "lldb/Core/IOHandler.h"
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
+#include "lldb/Target/Target.h"
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; }
@@ -31,31 +29,29 @@ public:
~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
+ /// \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
+ /// \param[in] language
/// The language to create a REPL for.
///
- /// @param[in] debugger
+ /// \param[in] debugger
/// If provided, and target is nullptr, the debugger to use when setting
/// up a top-level REPL.
///
- /// @param[in] target
+ /// \param[in] target
/// If provided, the target to put the REPL inside.
///
- /// @param[in] repl_options
+ /// \param[in] repl_options
/// If provided, additional options for the compiler when parsing REPL
/// expressions.
///
- /// @return
+ /// \return
/// The range of the containing object in the target process.
- //------------------------------------------------------------------
static lldb::REPLSP Create(Status &Status, lldb::LanguageType language,
Debugger *debugger, Target *target,
const char *repl_options);
@@ -69,9 +65,8 @@ public:
m_varobj_options = options;
}
- void
- SetCommandOptions(const CommandObjectExpression::CommandOptions &options) {
- m_command_options = options;
+ void SetEvaluateOptions(const EvaluateExpressionOptions &options) {
+ m_expr_options = options;
}
void SetCompilerOptions(const char *options) {
@@ -83,10 +78,8 @@ public:
Status RunLoop();
- //------------------------------------------------------------------
// IOHandler::Delegate functions
- //------------------------------------------------------------------
- void IOHandlerActivated(IOHandler &io_handler) override;
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override;
bool IOHandlerInterrupt(IOHandler &io_handler) override;
@@ -118,9 +111,7 @@ public:
protected:
static int CalculateActualIndentation(const StringList &lines);
- //----------------------------------------------------------------------
// Subclasses should override these functions to implement a functional REPL.
- //----------------------------------------------------------------------
virtual Status DoInitialization() = 0;
@@ -146,7 +137,7 @@ protected:
OptionGroupFormat m_format_options = OptionGroupFormat(lldb::eFormatDefault);
OptionGroupValueObjectDisplay m_varobj_options;
- CommandObjectExpression::CommandOptions m_command_options;
+ EvaluateExpressionOptions m_expr_options;
std::string m_compiler_options;
bool m_enable_auto_indent = true;
diff --git a/include/lldb/Expression/UserExpression.h b/include/lldb/Expression/UserExpression.h
index 812d7e9a0eacc..b1d52f8ddd55d 100644
--- a/include/lldb/Expression/UserExpression.h
+++ b/include/lldb/Expression/UserExpression.h
@@ -1,9 +1,8 @@
//===-- UserExpression.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,8 +23,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class UserExpression UserExpression.h "lldb/Expression/UserExpression.h"
+/// \class UserExpression UserExpression.h "lldb/Expression/UserExpression.h"
/// Encapsulates a one-time expression for use in lldb.
///
/// LLDB uses expressions for various purposes, notably to call functions
@@ -34,89 +32,86 @@ namespace lldb_private {
/// JIT an expression. The actual parsing part will be provided by the specific
/// implementations of UserExpression - which will be vended through the
/// appropriate TypeSystem.
-//----------------------------------------------------------------------
class UserExpression : public Expression {
public:
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindUserExpression;
+ }
+
enum { kDefaultTimeout = 500000u };
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] expr
+ /// \param[in] expr
/// The expression to parse.
///
- /// @param[in] expr_prefix
+ /// \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
+ /// \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
+ /// \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);
+ const EvaluateExpressionOptions &options,
+ ExpressionKind kind);
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
~UserExpression() override;
- //------------------------------------------------------------------
/// Parse the expression
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// A diagnostic manager to report parse errors and warnings to.
///
- /// @param[in] exe_ctx
+ /// \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
+ /// \param[in] execution_policy
/// Determines whether interpretation is possible or mandatory.
///
- /// @param[in] keep_result_in_memory
+ /// \param[in] keep_result_in_memory
/// True if the resulting persistent variable should reside in
/// target memory, if applicable.
///
- /// @return
+ /// \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;
- //------------------------------------------------------------------
/// Attempts to find possible command line completions for the given
/// (possible incomplete) user expression.
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to use when looking up entities that
/// are needed for parsing and completing (locations of functions, types
/// of variables, persistent variables, etc.)
///
- /// @param[out] request
+ /// \param[out] request
/// The completion request to fill out. The completion should be a string
/// that would complete the current token at the cursor position.
/// Note that the string in the list replaces the current token
/// in the command line.
///
- /// @param[in] complete_pos
+ /// \param[in] complete_pos
/// The position of the cursor inside the user expression string.
/// The completion process starts on the token that the cursor is in.
///
- /// @return
+ /// \return
/// True if we added any completion results to the output;
/// false otherwise.
- //------------------------------------------------------------------
virtual bool Complete(ExecutionContext &exe_ctx, CompletionRequest &request,
unsigned complete_pos) {
return false;
@@ -126,105 +121,87 @@ public:
bool MatchesContext(ExecutionContext &exe_ctx);
- //------------------------------------------------------------------
/// Execute the parsed expression by callinng the derived class's DoExecute
/// method.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// A diagnostic manager to report errors to.
///
- /// @param[in] exe_ctx
+ /// \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
+ /// \param[in] options
/// Expression evaluation options.
///
- /// @param[in] shared_ptr_to_me
+ /// \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
+ /// \param[in] result
/// A pointer to direct at the persistent variable in which the
/// expression's result is stored.
///
- /// @return
+ /// \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
+ /// \param[in] diagnostic_manager
/// A diagnostic manager to report errors to.
///
- /// @param[in] exe_ctx
+ /// \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
+ /// \param[in] result
/// A pointer to direct at the persistent variable in which the
/// expression's result is stored.
///
- /// @param[in] function_stack_pointer
+ /// \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
+ /// \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; }
@@ -236,53 +213,58 @@ public:
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
+ /// \param[in] exe_ctx
/// The execution context to use when evaluating the expression.
///
- /// @param[in] options
+ /// \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
+ /// \param[in] expr_cstr
/// A C string containing the expression to be evaluated.
///
- /// @param[in] expr_prefix
+ /// \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
+ /// \param[in,out] result_valobj_sp
/// If execution is successful, the result valobj is placed here.
///
- /// @param[out] error
+ /// \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
+ /// \param[out] fixed_expression
/// If non-nullptr, the fixed expression is copied into the provided
/// string.
///
- /// @param[out] jit_module_sp_ptr
+ /// \param[out] jit_module_sp_ptr
/// If non-nullptr, used to persist the generated IR module.
///
- /// @result
+ /// \param[in] ctx_obj
+ /// If specified, then the expression will be evaluated in the context of
+ /// this object. It means that the context object's address will be
+ /// treated as `this` for the expression (the expression will be
+ /// evaluated as if it was inside of a method of the context object's
+ /// class, and its `this` parameter were pointing to the context object).
+ /// The parameter makes sense for class and union types only.
+ /// Currently there is a limitation: the context object must be located
+ /// in the debuggee process' memory (and have the load address).
+ ///
+ /// \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, Status &error,
- uint32_t line_offset = 0, std::string *fixed_expression = nullptr,
- lldb::ModuleSP *jit_module_sp_ptr = nullptr);
+ std::string *fixed_expression = nullptr,
+ lldb::ModuleSP *jit_module_sp_ptr = nullptr,
+ ValueObject *ctx_obj = nullptr);
static const Status::ValueType kNoResult =
0x1001; ///< ValueObject::GetError() returns this if there is no result
@@ -304,10 +286,8 @@ protected:
static lldb::addr_t GetObjectPointer(lldb::StackFrameSP frame_sp,
ConstString &object_name, Status &err);
- //------------------------------------------------------------------
/// Populate m_in_cplusplus_method and m_in_objectivec_method based on the
/// environment.
- //------------------------------------------------------------------
void InstallContext(ExecutionContext &exe_ctx);
diff --git a/include/lldb/Expression/UtilityFunction.h b/include/lldb/Expression/UtilityFunction.h
index 4c87f4d104796..26da081ddced0 100644
--- a/include/lldb/Expression/UtilityFunction.h
+++ b/include/lldb/Expression/UtilityFunction.h
@@ -1,10 +1,9 @@
//===-- UtilityFunction.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,8 +19,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class UtilityFunction UtilityFunction.h
+/// \class UtilityFunction UtilityFunction.h
/// "lldb/Expression/UtilityFunction.h" Encapsulates a bit of source code that
/// provides a function that is callable
///
@@ -29,83 +27,71 @@ namespace lldb_private {
/// 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,
-//----------------------------------------------------------------------
class UtilityFunction : public Expression {
public:
- //------------------------------------------------------------------
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindUtilityFunction;
+ }
+
/// Constructor
///
- /// @param[in] text
+ /// \param[in] text
/// The text of the function. Must be a full translation unit.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the function, as used in the text.
- //------------------------------------------------------------------
UtilityFunction(ExecutionContextScope &exe_scope, const char *text,
- const char *name);
+ const char *name, ExpressionKind kind);
~UtilityFunction() override;
- //------------------------------------------------------------------
/// Install the utility function into a process
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// A diagnostic manager to print parse errors and warnings to.
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to install the utility function to.
///
- /// @return
+ /// \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
+ /// \param[in] pc
/// The program counter to check.
///
- /// @return
+ /// \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
diff --git a/include/lldb/Host/Config.h.cmake b/include/lldb/Host/Config.h.cmake
index 02a57ad8ca921..b8fb9e9de868d 100644
--- a/include/lldb/Host/Config.h.cmake
+++ b/include/lldb/Host/Config.h.cmake
@@ -1,9 +1,8 @@
//===-- Config.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/ConnectionFileDescriptor.h b/include/lldb/Host/ConnectionFileDescriptor.h
index 0d486a34c8d0a..00444d011af30 100644
--- a/include/lldb/Host/ConnectionFileDescriptor.h
+++ b/include/lldb/Host/ConnectionFileDescriptor.h
@@ -1,9 +1,8 @@
//===-- ConnectionFileDescriptor.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/Debug.h b/include/lldb/Host/Debug.h
index d88725cf4e2e0..036ce1ebccd59 100644
--- a/include/lldb/Host/Debug.h
+++ b/include/lldb/Host/Debug.h
@@ -1,9 +1,8 @@
//===-- Debug.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
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
@@ -29,12 +26,10 @@ struct ResumeAction {
// 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() {}
diff --git a/include/lldb/Host/Editline.h b/include/lldb/Host/Editline.h
index 51d6e58c1e7a4..a942ede05ce59 100644
--- a/include/lldb/Host/Editline.h
+++ b/include/lldb/Host/Editline.h
@@ -1,9 +1,8 @@
//===-- Editline.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/File.h b/include/lldb/Host/File.h
index 69ae2004e4222..eb28c4ada0e71 100644
--- a/include/lldb/Host/File.h
+++ b/include/lldb/Host/File.h
@@ -1,9 +1,8 @@
//===-- File.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,19 +14,18 @@
#include "lldb/Utility/Status.h"
#include "lldb/lldb-private.h"
+#include <mutex>
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class File File.h "lldb/Host/File.h"
+/// \class File File.h "lldb/Host/File.h"
/// A file class.
///
/// A file class that divides abstracts the LLDB core from host file
/// functionality.
-//----------------------------------------------------------------------
class File : public IOObject {
public:
static int kInvalidDescriptor;
@@ -72,59 +70,51 @@ public:
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
+ /// \code
/// File file(...);
/// if (file)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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
+ /// \code
/// File file(...);
/// if (!file)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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
+ /// \return
/// A reference to the file specification object.
- //------------------------------------------------------------------
Status GetFileSpec(FileSpec &file_spec) const;
Status Close() override;
@@ -141,172 +131,157 @@ public:
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
+ /// \param[in] buf
/// A buffer where to put the bytes that are read.
///
- /// @param[in,out] num_bytes
+ /// \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
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status 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
+ /// \param[in] buf
/// A buffer where to put the bytes that are read.
///
- /// @param[in,out] num_bytes
+ /// \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
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status 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 *,
+ /// File::Read (void *, size_t, off_t &) \see File::Write (const void *,
/// size_t, off_t &)
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset to seek to within the file relative to the
/// beginning of the file.
///
- /// @param[in] error_ptr
+ /// \param[in] error_ptr
/// A pointer to a lldb_private::Status object that will be
/// filled in if non-nullptr.
///
- /// @return
+ /// \return
/// The resulting seek offset, or -1 on error.
- //------------------------------------------------------------------
off_t SeekFromStart(off_t offset, Status *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 *,
+ /// File::Read (void *, size_t, off_t &) \see File::Write (const void *,
/// size_t, off_t &)
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset to seek to within the file relative to the
/// current file position.
///
- /// @param[in] error_ptr
+ /// \param[in] error_ptr
/// A pointer to a lldb_private::Status object that will be
/// filled in if non-nullptr.
///
- /// @return
+ /// \return
/// The resulting seek offset, or -1 on error.
- //------------------------------------------------------------------
off_t SeekFromCurrent(off_t offset, Status *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 *,
+ /// File::Read (void *, size_t, off_t &) \see File::Write (const void *,
/// size_t, off_t &)
///
- /// @param[in,out] offset
+ /// \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
+ /// \param[in] error_ptr
/// A pointer to a lldb_private::Status object that will be
/// filled in if non-nullptr.
///
- /// @return
+ /// \return
/// The resulting seek offset, or -1 on error.
- //------------------------------------------------------------------
off_t SeekFromEnd(off_t offset, Status *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
+ /// \param[in] dst
/// A buffer where to put the bytes that are read.
///
- /// @param[in,out] num_bytes
+ /// \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
+ /// \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
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status 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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status 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
@@ -314,88 +289,75 @@ public:
/// own locking externally to avoid multiple people writing to the file at
/// the same time.
///
- /// @param[in] src
+ /// \param[in] src
/// A buffer containing the bytes to write.
///
- /// @param[in,out] num_bytes
+ /// \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
+ /// \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
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status Write(const void *src, size_t &num_bytes, off_t &offset);
- //------------------------------------------------------------------
/// Flush the current stream
///
- /// @return
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status Flush();
- //------------------------------------------------------------------
/// Sync to disk.
///
- /// @return
+ /// \return
/// An error object that indicates success or the reason for
/// failure.
- //------------------------------------------------------------------
Status Sync();
- //------------------------------------------------------------------
/// Get the permissions for a this file.
///
- /// @return
+ /// \return
/// Bits logical OR'ed together from the permission bits defined
/// in lldb_private::File::Permissions.
- //------------------------------------------------------------------
uint32_t GetPermissions(Status &error) const;
- //------------------------------------------------------------------
/// Return true if this file is interactive.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] format
/// A printf style format string.
///
- /// @param[in] ...
+ /// \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);
@@ -411,9 +373,7 @@ protected:
void CalculateInteractiveAndTerminal();
- //------------------------------------------------------------------
// Member variables
- //------------------------------------------------------------------
int m_descriptor;
FILE *m_stream;
uint32_t m_options;
@@ -421,6 +381,7 @@ protected:
LazyBool m_is_interactive;
LazyBool m_is_real_terminal;
LazyBool m_supports_colors;
+ std::mutex offset_access_mutex;
private:
DISALLOW_COPY_AND_ASSIGN(File);
diff --git a/include/lldb/Target/FileAction.h b/include/lldb/Host/FileAction.h
index f80f57ac588b5..4d333bb327a54 100644
--- a/include/lldb/Target/FileAction.h
+++ b/include/lldb/Host/FileAction.h
@@ -1,14 +1,13 @@
//===-- FileAction.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_Target_FileAction_h
-#define liblldb_Target_FileAction_h
+#ifndef LLDB_HOST_FILEACTION_H
+#define LLDB_HOST_FILEACTION_H
#include "lldb/Utility/FileSpec.h"
#include <string>
diff --git a/include/lldb/Host/FileCache.h b/include/lldb/Host/FileCache.h
index 1c03540c1eb37..0c1ef1961645a 100644
--- a/include/lldb/Host/FileCache.h
+++ b/include/lldb/Host/FileCache.h
@@ -1,9 +1,8 @@
//===-- FileCache.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Host_FileCache_h
diff --git a/include/lldb/Host/FileSystem.h b/include/lldb/Host/FileSystem.h
index 9e36649b00468..865b09b231030 100644
--- a/include/lldb/Host/FileSystem.h
+++ b/include/lldb/Host/FileSystem.h
@@ -1,9 +1,8 @@
//===-- FileSystem.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#include "lldb/Host/File.h"
#include "lldb/Utility/DataBufferLLVM.h"
+#include "lldb/Utility/FileCollector.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Status.h"
@@ -31,8 +31,15 @@ public:
static const char *DEV_NULL;
static const char *PATH_CONVERSION_ERROR;
- FileSystem() : m_fs(llvm::vfs::getRealFileSystem()) {}
- FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs) : m_fs(fs) {}
+ FileSystem()
+ : m_fs(llvm::vfs::getRealFileSystem()), m_collector(nullptr),
+ m_mapped(false) {}
+ FileSystem(FileCollector &collector)
+ : m_fs(llvm::vfs::getRealFileSystem()), m_collector(&collector),
+ m_mapped(false) {}
+ FileSystem(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
+ bool mapped = false)
+ : m_fs(fs), m_collector(nullptr), m_mapped(mapped) {}
FileSystem(const FileSystem &fs) = delete;
FileSystem &operator=(const FileSystem &fs) = delete;
@@ -40,6 +47,8 @@ public:
static FileSystem &Instance();
static void Initialize();
+ static void Initialize(FileCollector &collector);
+ static llvm::Error Initialize(const FileSpec &mapping);
static void Initialize(llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs);
static void Terminate();
@@ -55,90 +64,91 @@ public:
int Open(const char *path, int flags, int mode);
Status Open(File &File, const FileSpec &file_spec, uint32_t options,
- uint32_t permissions = lldb::eFilePermissionsFileDefault);
+ uint32_t permissions = lldb::eFilePermissionsFileDefault,
+ bool should_close_fd = true);
/// Get a directory iterator.
- /// @{
+ /// \{
llvm::vfs::directory_iterator DirBegin(const FileSpec &file_spec,
std::error_code &ec);
llvm::vfs::directory_iterator DirBegin(const llvm::Twine &dir,
std::error_code &ec);
- /// @}
+ /// \}
/// Returns the Status object for the given file.
- /// @{
+ /// \{
llvm::ErrorOr<llvm::vfs::Status> GetStatus(const FileSpec &file_spec) const;
llvm::ErrorOr<llvm::vfs::Status> GetStatus(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Returns the modification time of the given file.
- /// @{
+ /// \{
llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const;
llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Returns the on-disk size of the given file in bytes.
- /// @{
+ /// \{
uint64_t GetByteSize(const FileSpec &file_spec) const;
uint64_t GetByteSize(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Return the current permissions of the given file.
///
/// Returns a bitmask for the current permissions of the file (zero or more
/// of the permission bits defined in File::Permissions).
- /// @{
+ /// \{
uint32_t GetPermissions(const FileSpec &file_spec) const;
uint32_t GetPermissions(const llvm::Twine &path) const;
uint32_t GetPermissions(const FileSpec &file_spec, std::error_code &ec) const;
uint32_t GetPermissions(const llvm::Twine &path, std::error_code &ec) const;
- /// @}
+ /// \}
/// Returns whether the given file exists.
- /// @{
+ /// \{
bool Exists(const FileSpec &file_spec) const;
bool Exists(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Returns whether the given file is readable.
- /// @{
+ /// \{
bool Readable(const FileSpec &file_spec) const;
bool Readable(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Returns whether the given path is a directory.
- /// @{
+ /// \{
bool IsDirectory(const FileSpec &file_spec) const;
bool IsDirectory(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Returns whether the given path is local to the file system.
- /// @{
+ /// \{
bool IsLocal(const FileSpec &file_spec) const;
bool IsLocal(const llvm::Twine &path) const;
- /// @}
+ /// \}
/// Make the given file path absolute.
- /// @{
+ /// \{
std::error_code MakeAbsolute(llvm::SmallVectorImpl<char> &path) const;
std::error_code MakeAbsolute(FileSpec &file_spec) const;
- /// @}
+ /// \}
/// Resolve path to make it canonical.
- /// @{
+ /// \{
void Resolve(llvm::SmallVectorImpl<char> &path);
void Resolve(FileSpec &file_spec);
- /// @}
+ /// \}
//// Create memory buffer from path.
- /// @{
+ /// \{
std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const llvm::Twine &path,
uint64_t size = 0,
uint64_t offset = 0);
std::shared_ptr<DataBufferLLVM> CreateDataBuffer(const FileSpec &file_spec,
uint64_t size = 0,
uint64_t offset = 0);
- /// @}
+ /// \}
/// Call into the Host to see if it can help find the file.
bool ResolveExecutableLocation(FileSpec &file_spec);
@@ -168,9 +178,18 @@ public:
std::error_code GetRealPath(const llvm::Twine &path,
llvm::SmallVectorImpl<char> &output) const;
+ llvm::ErrorOr<std::string> GetExternalPath(const llvm::Twine &path);
+ llvm::ErrorOr<std::string> GetExternalPath(const FileSpec &file_spec);
+
+ llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> GetVirtualFileSystem() {
+ return m_fs;
+ }
+
private:
static llvm::Optional<FileSystem> &InstanceImpl();
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> m_fs;
+ FileCollector *m_collector;
+ bool m_mapped;
};
} // namespace lldb_private
diff --git a/include/lldb/Host/Host.h b/include/lldb/Host/Host.h
index 459e9f563d1ee..884c5cf632134 100644
--- a/include/lldb/Host/Host.h
+++ b/include/lldb/Host/Host.h
@@ -1,9 +1,8 @@
//===-- Host.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,10 +26,11 @@ namespace lldb_private {
class FileAction;
class ProcessLaunchInfo;
+class ProcessInstanceInfo;
+class ProcessInstanceInfoList;
+class ProcessInstanceInfoMatch;
-//----------------------------------------------------------------------
// Exit Type for inferior processes
-//----------------------------------------------------------------------
struct WaitStatus {
enum Type : uint8_t {
Exit, // The status represents the return code from normal
@@ -55,12 +55,10 @@ inline bool operator==(WaitStatus a, WaitStatus b) {
inline bool operator!=(WaitStatus a, WaitStatus b) { return !(a == b); }
-//----------------------------------------------------------------------
-/// @class Host Host.h "lldb/Host/Host.h"
+/// \class Host Host.h "lldb/Host/Host.h"
/// A class that provides host computer information.
///
/// Host is a class that answers information about the host operating system.
-//----------------------------------------------------------------------
class Host {
public:
typedef std::function<bool(
@@ -69,7 +67,6 @@ public:
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
@@ -84,26 +81,25 @@ public:
/// If the child process exits, the monitoring will automatically stop after
/// the callback returned regardless of the callback return value.
///
- /// @param[in] callback
+ /// \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
+ /// \param[in] pid
/// The process ID of a child process to monitor, -1 for all
/// processes.
///
- /// @param[in] monitor_signals
+ /// \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
+ /// \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
+ /// \see static void Host::StopMonitoringChildProcess (uint32_t)
+ static llvm::Expected<HostThread>
StartMonitoringChildProcess(const MonitorChildProcessCallback &callback,
lldb::pid_t pid, bool monitor_signals);
@@ -114,78 +110,68 @@ public:
static void SystemLog(SystemLogType type, const char *format, va_list args);
- //------------------------------------------------------------------
/// Get the process ID for the calling process.
///
- /// @return
+ /// \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 token (the one returned by ThreadCreate when the thread
/// was created) for the calling thread in the current process.
///
- /// @return
+ /// \return
/// The thread token for the calling thread in the current process.
- //------------------------------------------------------------------
static lldb::thread_t GetCurrentThread();
static const char *GetSignalAsCString(int signo);
- //------------------------------------------------------------------
/// 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
+ /// \param[in] host_addr
/// The pointer to some code in the current process.
///
- /// @return
+ /// \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
+ /// \param[in] file
/// A file spec that might point to a file in a bundle.
///
- /// @param[out] bundle_directory
+ /// \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
+ /// \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
+ /// \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
+ /// \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,
@@ -197,44 +183,47 @@ public:
static bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info);
- static const lldb::UnixSignalsSP &GetUnixSignals();
-
/// Launch the process specified in launch_info. The monitoring callback in
/// launch_info must be set, and it will be called when the process
/// terminates.
static Status 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
- //------------------------------------------------------------------
+ /// environment variable replacement, and whatever other
+ /// argument magic the platform defines as part of its typical
+ /// user experience
static Status ShellExpandArguments(ProcessLaunchInfo &launch_info);
- // TODO: Convert this function to take a StringRef.
- static Status 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
- const Timeout<std::micro> &timeout, bool run_in_default_shell = true);
-
- static Status 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
- const Timeout<std::micro> &timeout, bool run_in_default_shell = true);
+ /// Run a shell command.
+ /// \arg command shouldn't be NULL
+ /// \arg working_dir Pass empty FileSpec to use the current working directory
+ /// \arg status_ptr Pass NULL if you don't want the process exit status
+ /// \arg signo_ptr Pass NULL if you don't want the signal that caused the
+ /// process to exit
+ /// \arg command_output Pass NULL if you don't want the command output
+ /// \arg hide_stderr if this is false, redirect stderr to stdout
+ /// TODO: Convert this function to take a StringRef.
+ static Status RunShellCommand(const char *command,
+ const FileSpec &working_dir, int *status_ptr,
+ int *signo_ptr, std::string *command_output,
+ const Timeout<std::micro> &timeout,
+ bool run_in_default_shell = true,
+ bool hide_stderr = false);
+
+ /// Run a shell command.
+ /// \arg working_dir Pass empty FileSpec to use the current working directory
+ /// \arg status_ptr Pass NULL if you don't want the process exit status
+ /// \arg signo_ptr Pass NULL if you don't want the signal that caused the
+ /// process to exit
+ /// \arg command_output Pass NULL if you don't want the command output
+ /// \arg hide_stderr if this is false, redirect stderr to stdout
+ static Status RunShellCommand(const Args &args, const FileSpec &working_dir,
+ int *status_ptr, int *signo_ptr,
+ std::string *command_output,
+ const Timeout<std::micro> &timeout,
+ bool run_in_default_shell = true,
+ bool hide_stderr = false);
static bool OpenFileInExternalEditor(const FileSpec &file_spec,
uint32_t line_no);
diff --git a/include/lldb/Host/HostGetOpt.h b/include/lldb/Host/HostGetOpt.h
index d37a2526ff049..dedeb2e2fcc3e 100644
--- a/include/lldb/Host/HostGetOpt.h
+++ b/include/lldb/Host/HostGetOpt.h
@@ -1,9 +1,8 @@
-//===-- GetOpt.h ------------------------------------------------*- C++ -*-===//
+//===-- HostGetOpt.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#pragma once
diff --git a/include/lldb/Host/HostInfo.h b/include/lldb/Host/HostInfo.h
index df762d7160e05..196127d407635 100644
--- a/include/lldb/Host/HostInfo.h
+++ b/include/lldb/Host/HostInfo.h
@@ -1,17 +1,15 @@
-//===-- HostInfoBase.h ------------------------------------------*- C++ -*-===//
+//===-- HostInfo.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef lldb_Host_HostInfo_h_
#define lldb_Host_HostInfo_h_
-//----------------------------------------------------------------------
-/// @class HostInfo HostInfo.h "lldb/Host/HostInfo.h"
+/// \class HostInfo HostInfo.h "lldb/Host/HostInfo.h"
/// A class that provides host computer information.
///
/// HostInfo is a class that answers information about the host operating
@@ -33,7 +31,6 @@
/// method and if used in a context where the method doesn't make sense, will
/// generate a compiler error.
///
-//----------------------------------------------------------------------
#if defined(_WIN32)
#include "lldb/Host/windows/HostInfoWindows.h"
diff --git a/include/lldb/Host/HostInfoBase.h b/include/lldb/Host/HostInfoBase.h
index f3e49c8f25d72..6f6688941ac7a 100644
--- a/include/lldb/Host/HostInfoBase.h
+++ b/include/lldb/Host/HostInfoBase.h
@@ -1,9 +1,8 @@
//===-- HostInfoBase.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,8 +11,8 @@
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UserIDResolver.h"
#include "lldb/lldb-enumerations.h"
-
#include "llvm/ADT/StringRef.h"
#include <stdint.h>
@@ -34,21 +33,17 @@ public:
static void Initialize();
static void Terminate();
- //------------------------------------------------------------------
/// Gets the host target triple as a const string.
///
- /// @return
+ /// \return
/// A const string object containing the host target triple.
- //------------------------------------------------------------------
static llvm::StringRef GetTargetTriple();
- //------------------------------------------------------------------
/// Gets the host architecture.
///
- /// @return
+ /// \return
/// A const architecture object that represents the host
/// architecture.
- //------------------------------------------------------------------
enum ArchitectureKind {
eArchKindDefault, // The overall default architecture that applications will
// run on this host
@@ -93,13 +88,14 @@ public:
/// FileSpec is filled in.
static FileSpec GetGlobalTempDir();
- //---------------------------------------------------------------------------
/// If the triple does not specify the vendor, os, and environment parts, we
/// "augment" these using information from the host and return the resulting
/// ArchSpec object.
- //---------------------------------------------------------------------------
static ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
+ static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
+ llvm::StringRef dir);
+
protected:
static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
diff --git a/include/lldb/Host/HostNativeProcess.h b/include/lldb/Host/HostNativeProcess.h
index 0aabfe197385a..c86a2aef38fce 100644
--- a/include/lldb/Host/HostNativeProcess.h
+++ b/include/lldb/Host/HostNativeProcess.h
@@ -1,9 +1,8 @@
//===-- HostNativeProcess.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/HostNativeProcessBase.h b/include/lldb/Host/HostNativeProcessBase.h
index 07f98c24776c2..aaa517d532172 100644
--- a/include/lldb/Host/HostNativeProcessBase.h
+++ b/include/lldb/Host/HostNativeProcessBase.h
@@ -1,9 +1,8 @@
//===-- HostNativeProcessBase.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,7 +35,7 @@ public:
lldb::process_t GetSystemHandle() const { return m_process; }
- virtual HostThread
+ virtual llvm::Expected<HostThread>
StartMonitoring(const Host::MonitorChildProcessCallback &callback,
bool monitor_signals) = 0;
diff --git a/include/lldb/Host/HostNativeThread.h b/include/lldb/Host/HostNativeThread.h
index e33d978d5ae43..8bf65849d880f 100644
--- a/include/lldb/Host/HostNativeThread.h
+++ b/include/lldb/Host/HostNativeThread.h
@@ -1,9 +1,8 @@
//===-- HostNativeThread.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/HostNativeThreadBase.h b/include/lldb/Host/HostNativeThreadBase.h
index 326a9c6c793f3..a196f0bc82ca2 100644
--- a/include/lldb/Host/HostNativeThreadBase.h
+++ b/include/lldb/Host/HostNativeThreadBase.h
@@ -1,9 +1,8 @@
//===-- HostNativeThreadBase.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/HostNativeThreadForward.h b/include/lldb/Host/HostNativeThreadForward.h
index 4691a22ac8440..261d3c7a836e2 100644
--- a/include/lldb/Host/HostNativeThreadForward.h
+++ b/include/lldb/Host/HostNativeThreadForward.h
@@ -1,9 +1,8 @@
//===-- HostNativeThreadForward.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/HostProcess.h b/include/lldb/Host/HostProcess.h
index 626ebab7ce686..d48ff1fc90eef 100644
--- a/include/lldb/Host/HostProcess.h
+++ b/include/lldb/Host/HostProcess.h
@@ -1,9 +1,8 @@
//===-- HostProcess.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,8 +12,7 @@
#include "lldb/Host/Host.h"
#include "lldb/lldb-types.h"
-//----------------------------------------------------------------------
-/// @class HostInfo HostInfo.h "lldb/Host/HostProcess.h"
+/// \class HostInfo HostInfo.h "lldb/Host/HostProcess.h"
/// A class that represents a running process on the host machine.
///
/// HostProcess allows querying and manipulation of processes running on the
@@ -27,7 +25,6 @@
/// statically to the concrete Process implementation for that platform. See
/// HostInfo for more details.
///
-//----------------------------------------------------------------------
namespace lldb_private {
@@ -46,8 +43,9 @@ public:
lldb::pid_t GetProcessId() const;
bool IsRunning() const;
- HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback,
- bool monitor_signals);
+ llvm::Expected<HostThread>
+ StartMonitoring(const Host::MonitorChildProcessCallback &callback,
+ bool monitor_signals);
HostNativeProcessBase &GetNativeProcess();
const HostNativeProcessBase &GetNativeProcess() const;
diff --git a/include/lldb/Host/HostThread.h b/include/lldb/Host/HostThread.h
index 120776283aa42..7bf2a1dc2db94 100644
--- a/include/lldb/Host/HostThread.h
+++ b/include/lldb/Host/HostThread.h
@@ -1,9 +1,8 @@
//===-- HostThread.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,15 +19,13 @@ namespace lldb_private {
class HostNativeThreadBase;
-//----------------------------------------------------------------------
-/// @class HostInfo HostInfo.h "lldb/Host/HostThread.h"
+/// \class HostInfo HostInfo.h "lldb/Host/HostThread.h"
/// A class that represents a thread running inside of a process on the
/// local machine.
///
/// HostThread allows querying and manipulation of threads running on the host
/// machine.
///
-//----------------------------------------------------------------------
class HostThread {
public:
HostThread();
diff --git a/include/lldb/Host/LockFile.h b/include/lldb/Host/LockFile.h
index 81cb10c7fbcb4..2a1cd3dbb8f73 100644
--- a/include/lldb/Host/LockFile.h
+++ b/include/lldb/Host/LockFile.h
@@ -1,9 +1,8 @@
//===-- LockFile.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/LockFileBase.h b/include/lldb/Host/LockFileBase.h
index 4eda1916c72e9..be9e258c5c2d6 100644
--- a/include/lldb/Host/LockFileBase.h
+++ b/include/lldb/Host/LockFileBase.h
@@ -1,9 +1,8 @@
//===-- LockFileBase.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/MainLoop.h b/include/lldb/Host/MainLoop.h
index 13d1ff0212fa4..d59aa28ccb0ed 100644
--- a/include/lldb/Host/MainLoop.h
+++ b/include/lldb/Host/MainLoop.h
@@ -1,9 +1,8 @@
//===-- MainLoop.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/MainLoopBase.h b/include/lldb/Host/MainLoopBase.h
index bf01ba16db0ec..3fee2b2c09d8c 100644
--- a/include/lldb/Host/MainLoopBase.h
+++ b/include/lldb/Host/MainLoopBase.h
@@ -1,9 +1,8 @@
//===-- MainLoopBase.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/MonitoringProcessLauncher.h b/include/lldb/Host/MonitoringProcessLauncher.h
index 179823efb966f..59111a04fc98f 100644
--- a/include/lldb/Host/MonitoringProcessLauncher.h
+++ b/include/lldb/Host/MonitoringProcessLauncher.h
@@ -1,9 +1,8 @@
//===-- MonitoringProcessLauncher.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/OptionParser.h b/include/lldb/Host/OptionParser.h
index 1b0dc4ae19e00..b03eeb74ec4e0 100644
--- a/include/lldb/Host/OptionParser.h
+++ b/include/lldb/Host/OptionParser.h
@@ -1,9 +1,8 @@
//===-- OptionParser.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include <string>
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ArrayRef.h"
struct option;
@@ -38,8 +38,11 @@ public:
static void EnableError(bool error);
- static int Parse(int argc, char *const argv[], llvm::StringRef optstring,
- const Option *longopts, int *longindex);
+ /// Argv must be an argument vector "as passed to main", i.e. terminated with
+ /// a nullptr.
+ static int Parse(llvm::MutableArrayRef<char *> argv,
+ llvm::StringRef optstring, const Option *longopts,
+ int *longindex);
static char *GetOptionArgument();
static int GetOptionIndex();
diff --git a/include/lldb/Host/Pipe.h b/include/lldb/Host/Pipe.h
index 283fb1b83c250..ea75342e54270 100644
--- a/include/lldb/Host/Pipe.h
+++ b/include/lldb/Host/Pipe.h
@@ -1,9 +1,8 @@
//===-- Pipe.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/PipeBase.h b/include/lldb/Host/PipeBase.h
index 88bd703960c41..1aa4db339b29e 100644
--- a/include/lldb/Host/PipeBase.h
+++ b/include/lldb/Host/PipeBase.h
@@ -1,10 +1,9 @@
//===-- PipeBase.h -----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/PosixApi.h b/include/lldb/Host/PosixApi.h
index dae2bb4800916..04ca3a84983b9 100644
--- a/include/lldb/Host/PosixApi.h
+++ b/include/lldb/Host/PosixApi.h
@@ -1,9 +1,8 @@
//===-- PosixApi.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ProcessLaunchInfo.h b/include/lldb/Host/ProcessLaunchInfo.h
index ef1d63035b18c..d068aa636bc7f 100644
--- a/include/lldb/Target/ProcessLaunchInfo.h
+++ b/include/lldb/Host/ProcessLaunchInfo.h
@@ -1,9 +1,8 @@
//===-- ProcessLaunchInfo.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,19 +15,17 @@
// LLDB Headers
#include "lldb/Utility/Flags.h"
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/PseudoTerminal.h"
-#include "lldb/Target/FileAction.h"
-#include "lldb/Target/ProcessInfo.h"
#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/ProcessInfo.h"
namespace lldb_private {
-//----------------------------------------------------------------------
// ProcessLaunchInfo
//
// Describes any information that is required to launch a process.
-//----------------------------------------------------------------------
class ProcessLaunchInfo : public ProcessInfo {
public:
diff --git a/include/lldb/Host/ProcessLauncher.h b/include/lldb/Host/ProcessLauncher.h
index 49fa84113f6c3..a5b6a6c76bbad 100644
--- a/include/lldb/Host/ProcessLauncher.h
+++ b/include/lldb/Host/ProcessLauncher.h
@@ -1,9 +1,8 @@
//===-- ProcessLauncher.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/ProcessRunLock.h b/include/lldb/Host/ProcessRunLock.h
index 272772fedce1a..4927fbbf78215 100644
--- a/include/lldb/Host/ProcessRunLock.h
+++ b/include/lldb/Host/ProcessRunLock.h
@@ -1,9 +1,8 @@
//===-- ProcessRunLock.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,17 +14,13 @@
#include "lldb/lldb-defines.h"
-//----------------------------------------------------------------------
/// Enumerations for broadcasting.
-//----------------------------------------------------------------------
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ProcessRunLock ProcessRunLock.h "lldb/Host/ProcessRunLock.h"
+/// \class ProcessRunLock ProcessRunLock.h "lldb/Host/ProcessRunLock.h"
/// A class used to prevent the process from starting while other
/// threads are accessing its data, and prevent access to its data while it is
/// running.
-//----------------------------------------------------------------------
class ProcessRunLock {
public:
diff --git a/include/lldb/Host/PseudoTerminal.h b/include/lldb/Host/PseudoTerminal.h
index 858bd35f73a6a..8b27890ddeebb 100644
--- a/include/lldb/Host/PseudoTerminal.h
+++ b/include/lldb/Host/PseudoTerminal.h
@@ -1,9 +1,8 @@
//===-- PseudoTerminal.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,47 +16,36 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h"
+/// \class PseudoTerminal PseudoTerminal.h "lldb/Host/PseudoTerminal.h"
/// A pseudo terminal helper class.
///
/// The pseudo terminal class abstracts the use of pseudo terminals on the
/// host system.
-//----------------------------------------------------------------------
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
@@ -73,18 +61,16 @@ public:
/// PseudoTerminal::ReleaseMasterFileDescriptor() @li
/// PseudoTerminal::ReleaseSaveFileDescriptor()
///
- /// @param[out] error
+ /// \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
+ /// \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.
- //------------------------------------------------------------------
+ /// \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
@@ -92,15 +78,13 @@ public:
/// PseudoTerminal::ReleaseMasterFileDescriptor() if this object should
/// release ownership of the slave file descriptor.
///
- /// @return
+ /// \return
/// The master file descriptor, or PseudoTerminal::invalid_fd
/// if the master file descriptor is not currently valid.
///
- /// @see PseudoTerminal::ReleaseMasterFileDescriptor()
- //------------------------------------------------------------------
+ /// \see PseudoTerminal::ReleaseMasterFileDescriptor()
int GetMasterFileDescriptor() const;
- //------------------------------------------------------------------
/// The slave file descriptor accessor.
///
/// This object retains ownership of the slave file descriptor when this
@@ -108,25 +92,23 @@ public:
/// PseudoTerminal::ReleaseSlaveFileDescriptor() if this object should
/// release ownership of the slave file descriptor.
///
- /// @return
+ /// \return
/// The slave file descriptor, or PseudoTerminal::invalid_fd
/// if the slave file descriptor is not currently valid.
///
- /// @see PseudoTerminal::ReleaseSlaveFileDescriptor()
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \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
@@ -134,11 +116,9 @@ public:
/// a valid master pseudo terminal opened or if the call to
/// \c ptsname() fails.
///
- /// @see PseudoTerminal::OpenFirstAvailableMaster()
- //------------------------------------------------------------------
+ /// \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
@@ -152,25 +132,23 @@ public:
/// If this object still has a valid master file descriptor when its
/// destructor is called, it will close it.
///
- /// @param[in] oflag
+ /// \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
+ /// \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
+ /// \return
+ /// \li \b true when the master files descriptor is
/// successfully opened.
- /// @li \b false if anything goes wrong.
+ /// \li \b false if anything goes wrong.
///
- /// @see PseudoTerminal::GetMasterFileDescriptor() @see
+ /// \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
@@ -184,25 +162,23 @@ public:
/// If this object still has a valid slave file descriptor when its
/// destructor is called, it will close it.
///
- /// @param[in] oflag
+ /// \param[in] oflag
/// Flags to use when calling \c open(\a oflag).
///
- /// @param[out] error
+ /// \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
+ /// \return
+ /// \li \b true when the master files descriptor is
/// successfully opened.
- /// @li \b false if anything goes wrong.
+ /// \li \b false if anything goes wrong.
///
- /// @see PseudoTerminal::OpenFirstAvailableMaster() @see
+ /// \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
@@ -210,13 +186,11 @@ public:
/// descriptor if the ownership isn't released using this call and the
/// master file descriptor has been opened.
///
- /// @return
+ /// \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
@@ -224,16 +198,13 @@ public:
/// descriptor if the ownership isn't released using this call and the slave
/// file descriptor has been opened.
///
- /// @return
+ /// \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.
diff --git a/include/lldb/Host/SafeMachO.h b/include/lldb/Host/SafeMachO.h
index 1565b313f42b6..ec9887ececd5a 100644
--- a/include/lldb/Host/SafeMachO.h
+++ b/include/lldb/Host/SafeMachO.h
@@ -1,9 +1,8 @@
//===-- SafeMachO.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_SafeMachO_h_
diff --git a/include/lldb/Host/Socket.h b/include/lldb/Host/Socket.h
index 8b7f9fa4ed933..6f96bd73e753e 100644
--- a/include/lldb/Host/Socket.h
+++ b/include/lldb/Host/Socket.h
@@ -1,9 +1,8 @@
//===-- Socket.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,17 +39,20 @@ typedef int NativeSocket;
class Socket : public IOObject {
public:
- typedef enum {
+ enum SocketProtocol {
ProtocolTcp,
ProtocolUdp,
ProtocolUnixDomain,
ProtocolUnixAbstract
- } SocketProtocol;
+ };
static const NativeSocket kInvalidSocketValue;
~Socket() override;
+ static llvm::Error Initialize();
+ static void Terminate();
+
static std::unique_ptr<Socket> Create(const SocketProtocol protocol,
bool child_processes_inherit,
Status &error);
@@ -100,6 +102,9 @@ public:
std::string &host_str, std::string &port_str,
int32_t &port, Status *error_ptr);
+ // If this Socket is connected then return the URI used to connect.
+ virtual std::string GetRemoteConnectionURI() const { return ""; };
+
protected:
Socket(SocketProtocol protocol, bool should_close,
bool m_child_process_inherit);
diff --git a/include/lldb/Host/SocketAddress.h b/include/lldb/Host/SocketAddress.h
index 5e54ef1d8e0ce..620827ff6eb10 100644
--- a/include/lldb/Host/SocketAddress.h
+++ b/include/lldb/Host/SocketAddress.h
@@ -1,9 +1,8 @@
//===-- SocketAddress.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,28 +33,21 @@ namespace lldb_private {
class SocketAddress {
public:
- //----------------------------------------------------------------------------
// Static method to get all address information for a host and/or service
- //----------------------------------------------------------------------------
static std::vector<SocketAddress>
GetAddressInfo(const char *hostname, const char *servname, int ai_family,
int ai_socktype, int ai_protocol, int ai_flags = 0);
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SocketAddress();
SocketAddress(const struct addrinfo *addr_info);
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);
@@ -71,53 +63,35 @@ public:
bool operator==(const SocketAddress &rhs) const;
bool operator!=(const SocketAddress &rhs) const;
- //------------------------------------------------------------------
// 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
@@ -127,33 +101,23 @@ public:
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;
- //------------------------------------------------------------------
// Returns true if the socket is INADDR_ANY
- //------------------------------------------------------------------
bool IsAnyAddr() const;
- //------------------------------------------------------------------
// Returns true if the socket is INADDR_LOOPBACK
- //------------------------------------------------------------------
bool IsLocalhost() const;
- //------------------------------------------------------------------
// Direct access to all of the sockaddr structures
- //------------------------------------------------------------------
struct sockaddr &sockaddr() {
return m_socket_addr.sa;
}
@@ -184,12 +148,10 @@ public:
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; }
@@ -219,9 +181,7 @@ protected:
struct sockaddr_storage sa_storage;
} sockaddr_t;
- //------------------------------------------------------------------
// Classes that inherit from SocketAddress can see and modify these
- //------------------------------------------------------------------
sockaddr_t m_socket_addr;
};
diff --git a/include/lldb/Host/StringConvert.h b/include/lldb/Host/StringConvert.h
index 1a85471a20c22..4b2c6901a96b0 100644
--- a/include/lldb/Host/StringConvert.h
+++ b/include/lldb/Host/StringConvert.h
@@ -1,9 +1,8 @@
//===-- StringConvert.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,10 +17,8 @@ namespace lldb_private {
namespace StringConvert {
-//----------------------------------------------------------------------
-/// @namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h"
+/// \namespace StringConvert StringConvert.h "lldb/Host/StringConvert.h"
/// 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);
diff --git a/include/lldb/Host/TaskPool.h b/include/lldb/Host/TaskPool.h
index 4001d187a2a9d..49805ce193ed0 100644
--- a/include/lldb/Host/TaskPool.h
+++ b/include/lldb/Host/TaskPool.h
@@ -1,9 +1,8 @@
//===--------------------- TaskPool.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/Terminal.h b/include/lldb/Host/Terminal.h
index 193b6d21d51e5..e5e96eeda3fe7 100644
--- a/include/lldb/Host/Terminal.h
+++ b/include/lldb/Host/Terminal.h
@@ -1,9 +1,8 @@
//===-- Terminal.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,170 +41,136 @@ protected:
int m_fd; // This may or may not be a terminal file descriptor
};
-//----------------------------------------------------------------------
-/// @class State Terminal.h "lldb/Host/Terminal.h"
+/// \class State Terminal.h "lldb/Host/Terminal.h"
/// A terminal state saving/restoring class.
///
/// 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 {
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
+ /// \param[in] fd
/// The file descriptor to save the state of.
///
- /// @param[in] save_process_group
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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.
+ m_termios_up; ///< Cached terminal state information.
#endif
lldb::pid_t m_process_group; ///< Cached process group information.
};
-//----------------------------------------------------------------------
-/// @class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h"
+/// \class TerminalStateSwitcher Terminal.h "lldb/Host/Terminal.h"
/// A TTY state switching class.
///
/// This class can be used to remember 2 TTY states for a given file
/// descriptor and switch between the two states.
-//----------------------------------------------------------------------
class TerminalStateSwitcher {
public:
- //------------------------------------------------------------------
/// Constructor
- //------------------------------------------------------------------
TerminalStateSwitcher();
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
~TerminalStateSwitcher();
- //------------------------------------------------------------------
/// Get the number of possible states to save.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] idx
/// The index into the state array where the state should be
/// saved.
///
- /// @param[in] fd
+ /// \param[in] fd
/// The file descriptor for which to save the settings.
///
- /// @param[in] save_process_group
+ /// \param[in] save_process_group
/// If \b true, save the process group information for the TTY.
///
- /// @return
+ /// \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.
diff --git a/include/lldb/Host/ThreadLauncher.h b/include/lldb/Host/ThreadLauncher.h
index b50f0e2c2c433..e45ffa9df7571 100644
--- a/include/lldb/Host/ThreadLauncher.h
+++ b/include/lldb/Host/ThreadLauncher.h
@@ -1,10 +1,8 @@
-//===-- ThreadLauncher.h -----------------------------------------*- C++
-//-*-===//
+//===-- ThreadLauncher.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,18 +10,18 @@
#define lldb_Host_ThreadLauncher_h_
#include "lldb/Host/HostThread.h"
-#include "lldb/Utility/Status.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
namespace lldb_private {
class ThreadLauncher {
public:
- static HostThread
+ static llvm::Expected<HostThread>
LaunchThread(llvm::StringRef name, lldb::thread_func_t thread_function,
- lldb::thread_arg_t thread_arg, Status *error_ptr,
+ lldb::thread_arg_t thread_arg,
size_t min_stack_byte_size = 0); // Minimum stack size in bytes,
// set stack size to zero for
// default platform thread stack
diff --git a/include/lldb/Host/Time.h b/include/lldb/Host/Time.h
index 3be30dd03375d..b27eb082167e1 100644
--- a/include/lldb/Host/Time.h
+++ b/include/lldb/Host/Time.h
@@ -1,9 +1,8 @@
//===-- Time.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/XML.h b/include/lldb/Host/XML.h
index 57e300752003f..625cf4381286c 100644
--- a/include/lldb/Host/XML.h
+++ b/include/lldb/Host/XML.h
@@ -1,9 +1,8 @@
//===-- XML.h ---------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -85,20 +84,14 @@ public:
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;
@@ -132,10 +125,8 @@ public:
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;
diff --git a/include/lldb/Host/common/NativeBreakpointList.h b/include/lldb/Host/common/NativeBreakpointList.h
index b57174e51564e..c2725b2df959b 100644
--- a/include/lldb/Host/common/NativeBreakpointList.h
+++ b/include/lldb/Host/common/NativeBreakpointList.h
@@ -1,9 +1,8 @@
//===-- NativeBreakpointList.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/common/NativeProcessProtocol.h b/include/lldb/Host/common/NativeProcessProtocol.h
index cb3b18eb0a3df..f05b8d01a1c9f 100644
--- a/include/lldb/Host/common/NativeProcessProtocol.h
+++ b/include/lldb/Host/common/NativeProcessProtocol.h
@@ -1,9 +1,8 @@
//===-- NativeProcessProtocol.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,9 +32,7 @@ namespace lldb_private {
class MemoryRegionInfo;
class ResumeActionList;
-//------------------------------------------------------------------
// NativeProcessProtocol
-//------------------------------------------------------------------
class NativeProcessProtocol {
public:
virtual ~NativeProcessProtocol() {}
@@ -46,37 +43,29 @@ public:
virtual Status Detach() = 0;
- //------------------------------------------------------------------
/// Sends a process a UNIX signal \a signal.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status 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
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status Interrupt();
virtual Status Kill() = 0;
- //------------------------------------------------------------------
// Tells a process not to stop the inferior on given signals and just
// reinject them back.
- //------------------------------------------------------------------
virtual Status IgnoreSignals(llvm::ArrayRef<int> signals);
- //----------------------------------------------------------------------
// Memory and memory region functions
- //----------------------------------------------------------------------
virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info);
@@ -103,26 +92,20 @@ public:
virtual const ArchSpec &GetArchitecture() const = 0;
- //----------------------------------------------------------------------
// Breakpoint functions
- //----------------------------------------------------------------------
virtual Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
bool hardware) = 0;
virtual Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false);
- //----------------------------------------------------------------------
// Hardware Breakpoint functions
- //----------------------------------------------------------------------
virtual const HardwareBreakpointMap &GetHardwareBreakpointMap() const;
virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size);
virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr);
- //----------------------------------------------------------------------
// Watchpoint functions
- //----------------------------------------------------------------------
virtual const NativeWatchpointList::WatchpointMap &GetWatchpointMap() const;
virtual llvm::Optional<std::pair<uint32_t, uint32_t>>
@@ -133,9 +116,7 @@ public:
virtual Status RemoveWatchpoint(lldb::addr_t addr);
- //----------------------------------------------------------------------
// Accessors
- //----------------------------------------------------------------------
lldb::pid_t GetID() const { return m_pid; }
lldb::StateType GetState() const;
@@ -152,19 +133,19 @@ public:
return GetArchitecture().GetByteOrder();
}
+ uint32_t GetAddressByteSize() const {
+ return GetArchitecture().GetAddressByteSize();
+ }
+
virtual llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
GetAuxvData() const = 0;
- //----------------------------------------------------------------------
// Exit Status
- //----------------------------------------------------------------------
virtual llvm::Optional<WaitStatus> GetExitStatus();
virtual bool SetExitStatus(WaitStatus status, bool bNotifyStateChange);
- //----------------------------------------------------------------------
// Access to threads
- //----------------------------------------------------------------------
NativeThreadProtocol *GetThreadAtIndex(uint32_t idx);
NativeThreadProtocol *GetThreadByID(lldb::tid_t tid);
@@ -177,20 +158,14 @@ public:
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() {}
@@ -203,7 +178,6 @@ public:
virtual void DidExec(NativeProcessProtocol *process) = 0;
};
- //------------------------------------------------------------------
/// Register a native delegate.
///
/// Clients can register nofication callbacks by passing in a
@@ -212,29 +186,26 @@ public:
/// Note: it is required that the lifetime of the
/// native_delegate outlive the NativeProcessProtocol.
///
- /// @param[in] native_delegate
+ /// \param[in] native_delegate
/// A NativeDelegate impl to be called when certain events
/// happen within the NativeProcessProtocol or related threads.
///
- /// @return
+ /// \return
/// true if the delegate was registered successfully;
/// false if the delegate was already registered.
///
- /// @see NativeProcessProtocol::NativeDelegate.
- //------------------------------------------------------------------
+ /// \see NativeProcessProtocol::NativeDelegate.
bool RegisterNativeDelegate(NativeDelegate &native_delegate);
- //------------------------------------------------------------------
/// Unregister a native delegate previously registered.
///
- /// @param[in] native_delegate
+ /// \param[in] native_delegate
/// A NativeDelegate impl previously registered with this process.
///
- /// @return Returns \b true if the NativeDelegate was
+ /// \return Returns \b true if the NativeDelegate was
/// successfully removed from the process, \b false otherwise.
///
- /// @see NativeProcessProtocol::NativeDelegate
- //------------------------------------------------------------------
+ /// \see NativeProcessProtocol::NativeDelegate
bool UnregisterNativeDelegate(NativeDelegate &native_delegate);
virtual Status GetLoadedModuleFileSpec(const char *module_path,
@@ -246,153 +217,139 @@ public:
class Factory {
public:
virtual ~Factory();
- //------------------------------------------------------------------
/// Launch a process for debugging.
///
- /// @param[in] launch_info
+ /// \param[in] launch_info
/// Information required to launch the process.
///
- /// @param[in] native_delegate
+ /// \param[in] native_delegate
/// The delegate that will receive messages regarding the
/// inferior. Must outlive the NativeProcessProtocol
/// instance.
///
- /// @param[in] mainloop
+ /// \param[in] mainloop
/// The mainloop instance with which the process can register
/// callbacks. Must outlive the NativeProcessProtocol
/// instance.
///
- /// @return
+ /// \return
/// A NativeProcessProtocol shared pointer if the operation succeeded or
/// an error object if it failed.
- //------------------------------------------------------------------
virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Launch(ProcessLaunchInfo &launch_info, NativeDelegate &native_delegate,
MainLoop &mainloop) const = 0;
- //------------------------------------------------------------------
/// Attach to an existing process.
///
- /// @param[in] pid
+ /// \param[in] pid
/// pid of the process locatable
///
- /// @param[in] native_delegate
+ /// \param[in] native_delegate
/// The delegate that will receive messages regarding the
/// inferior. Must outlive the NativeProcessProtocol
/// instance.
///
- /// @param[in] mainloop
+ /// \param[in] mainloop
/// The mainloop instance with which the process can register
/// callbacks. Must outlive the NativeProcessProtocol
/// instance.
///
- /// @return
+ /// \return
/// A NativeProcessProtocol shared pointer if the operation succeeded or
/// an error object if it failed.
- //------------------------------------------------------------------
virtual llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
Attach(lldb::pid_t pid, NativeDelegate &native_delegate,
MainLoop &mainloop) const = 0;
};
- //------------------------------------------------------------------
/// StartTracing API for starting a tracing instance with the
/// TraceOptions on a specific thread or process.
///
- /// @param[in] config
+ /// \param[in] config
/// The configuration to use when starting tracing.
///
- /// @param[out] error
+ /// \param[out] error
/// Status indicates what went wrong.
///
- /// @return
+ /// \return
/// The API returns a user_id which can be used to get trace
/// data, trace configuration or stopping the trace instance.
/// The user_id is a key to identify and operate with a tracing
/// instance. It may refer to the complete process or a single
/// thread.
- //------------------------------------------------------------------
virtual lldb::user_id_t StartTrace(const TraceOptions &config,
Status &error) {
error.SetErrorString("Not implemented");
return LLDB_INVALID_UID;
}
- //------------------------------------------------------------------
/// StopTracing API as the name suggests stops a tracing instance.
///
- /// @param[in] traceid
+ /// \param[in] traceid
/// The user id of the trace intended to be stopped. Now a
/// user_id may map to multiple threads in which case this API
/// could be used to stop the tracing for a specific thread by
/// supplying its thread id.
///
- /// @param[in] thread
+ /// \param[in] thread
/// Thread is needed when the complete process is being traced
/// and the user wishes to stop tracing on a particular thread.
///
- /// @return
+ /// \return
/// Status indicating what went wrong.
- //------------------------------------------------------------------
virtual Status StopTrace(lldb::user_id_t traceid,
lldb::tid_t thread = LLDB_INVALID_THREAD_ID) {
return Status("Not implemented");
}
- //------------------------------------------------------------------
/// This API provides the trace data collected in the form of raw
/// data.
///
- /// @param[in] traceid thread
+ /// \param[in] traceid thread
/// The traceid and thread provide the context for the trace
/// instance.
///
- /// @param[in] buffer
+ /// \param[in] buffer
/// The buffer provides the destination buffer where the trace
/// data would be read to. The buffer should be truncated to the
/// filled length by this function.
///
- /// @param[in] offset
+ /// \param[in] offset
/// There is possibility to read partially the trace data from
/// a specified offset where in such cases the buffer provided
/// may be smaller than the internal trace collection container.
///
- /// @return
+ /// \return
/// The size of the data actually read.
- //------------------------------------------------------------------
virtual Status GetData(lldb::user_id_t traceid, lldb::tid_t thread,
llvm::MutableArrayRef<uint8_t> &buffer,
size_t offset = 0) {
return Status("Not implemented");
}
- //------------------------------------------------------------------
/// Similar API as above except it aims to provide any extra data
/// useful for decoding the actual trace data.
- //------------------------------------------------------------------
virtual Status GetMetaData(lldb::user_id_t traceid, lldb::tid_t thread,
llvm::MutableArrayRef<uint8_t> &buffer,
size_t offset = 0) {
return Status("Not implemented");
}
- //------------------------------------------------------------------
/// API to query the TraceOptions for a given user id
///
- /// @param[in] traceid
+ /// \param[in] traceid
/// The user id of the tracing instance.
///
- /// @param[in] config
+ /// \param[in] config
/// The thread id of the tracing instance, in case configuration
/// for a specific thread is needed should be specified in the
/// config.
///
- /// @param[out] error
+ /// \param[out] error
/// Status indicates what went wrong.
///
- /// @param[out] config
+ /// \param[out] config
/// The actual configuration being used for tracing.
- //------------------------------------------------------------------
virtual Status GetTraceConfig(lldb::user_id_t traceid, TraceOptions &config) {
return Status("Not implemented");
}
@@ -434,9 +391,7 @@ protected:
NativeProcessProtocol(lldb::pid_t pid, int terminal_fd,
NativeDelegate &delegate);
- // ----------------------------------------------------------- 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
@@ -445,9 +400,7 @@ protected:
// Note this function is called with the state mutex obtained by the caller.
virtual void DoStopIDBumped(uint32_t newBumpId);
- // ----------------------------------------------------------- Internal
// interface for software breakpoints
- // -----------------------------------------------------------
Status SetSoftwareBreakpoint(lldb::addr_t addr, uint32_t size_hint);
Status RemoveSoftwareBreakpoint(lldb::addr_t addr);
@@ -466,12 +419,10 @@ protected:
// resets it to point to the breakpoint itself.
void FixupBreakpointPCAsNeeded(NativeThreadProtocol &thread);
- // -----------------------------------------------------------
/// Notify the delegate that an exec occurred.
///
/// Provide a mechanism for a delegate to clear out any exec-
/// sensitive data.
- // -----------------------------------------------------------
void NotifyDidExec();
NativeThreadProtocol *GetThreadByIDUnlocked(lldb::tid_t tid);
diff --git a/include/lldb/Host/common/NativeRegisterContext.h b/include/lldb/Host/common/NativeRegisterContext.h
index 268e0f2473fd4..6bba8f2a5d29a 100644
--- a/include/lldb/Host/common/NativeRegisterContext.h
+++ b/include/lldb/Host/common/NativeRegisterContext.h
@@ -1,9 +1,8 @@
//===-- NativeRegisterContext.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@ class NativeThreadProtocol;
class NativeRegisterContext
: public std::enable_shared_from_this<NativeRegisterContext> {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
NativeRegisterContext(NativeThreadProtocol &thread);
virtual ~NativeRegisterContext();
@@ -30,9 +27,7 @@ public:
// void
// InvalidateIfNeeded (bool force);
- //------------------------------------------------------------------
// Subclasses must override these functions
- //------------------------------------------------------------------
// virtual void
// InvalidateAllRegisters () = 0;
@@ -61,9 +56,7 @@ public:
uint32_t ConvertRegisterKindToRegisterNumber(uint32_t kind,
uint32_t num) const;
- //------------------------------------------------------------------
// Subclasses can override these functions if desired
- //------------------------------------------------------------------
virtual uint32_t NumSupportedHardwareBreakpoints();
virtual uint32_t SetHardwareBreakpoint(lldb::addr_t addr, size_t size);
@@ -116,9 +109,7 @@ public:
lldb::addr_t dst_addr, size_t dst_len,
const RegisterValue &reg_value);
- //------------------------------------------------------------------
// Subclasses should not override these
- //------------------------------------------------------------------
virtual lldb::tid_t GetThreadID() const;
virtual NativeThreadProtocol &GetThread() { return m_thread; }
@@ -171,18 +162,14 @@ public:
// }
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_stop_id; // The stop ID that any data in this
// context is valid for
private:
- //------------------------------------------------------------------
// For RegisterContext only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(NativeRegisterContext);
};
diff --git a/include/lldb/Host/common/NativeThreadProtocol.h b/include/lldb/Host/common/NativeThreadProtocol.h
index 6f4452c688e71..36ae67933f53d 100644
--- a/include/lldb/Host/common/NativeThreadProtocol.h
+++ b/include/lldb/Host/common/NativeThreadProtocol.h
@@ -1,9 +1,8 @@
//===-- NativeThreadProtocol.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
#include "lldb/lldb-types.h"
namespace lldb_private {
-//------------------------------------------------------------------
// NativeThreadProtocol
-//------------------------------------------------------------------
class NativeThreadProtocol {
public:
NativeThreadProtocol(NativeProcessProtocol &process, lldb::tid_t tid);
@@ -39,17 +36,13 @@ public:
NativeProcessProtocol &GetProcess() { return m_process; }
- // ---------------------------------------------------------------------
// Thread-specific watchpoints
- // ---------------------------------------------------------------------
virtual Status SetWatchpoint(lldb::addr_t addr, size_t size,
uint32_t watch_flags, bool hardware) = 0;
virtual Status RemoveWatchpoint(lldb::addr_t addr) = 0;
- // ---------------------------------------------------------------------
// Thread-specific Hardware Breakpoint routines
- // ---------------------------------------------------------------------
virtual Status SetHardwareBreakpoint(lldb::addr_t addr, size_t size) = 0;
virtual Status RemoveHardwareBreakpoint(lldb::addr_t addr) = 0;
diff --git a/include/lldb/Host/common/NativeWatchpointList.h b/include/lldb/Host/common/NativeWatchpointList.h
index 02920e6faacb1..c83ba1eaadca3 100644
--- a/include/lldb/Host/common/NativeWatchpointList.h
+++ b/include/lldb/Host/common/NativeWatchpointList.h
@@ -1,9 +1,8 @@
//===-- NativeWatchpointList.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/common/TCPSocket.h b/include/lldb/Host/common/TCPSocket.h
index 0d32a70fd3817..faf3bb693c325 100644
--- a/include/lldb/Host/common/TCPSocket.h
+++ b/include/lldb/Host/common/TCPSocket.h
@@ -1,9 +1,8 @@
//===-- TCPSocket.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,6 +46,8 @@ public:
bool IsValid() const override;
+ std::string GetRemoteConnectionURI() const override;
+
private:
TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
diff --git a/include/lldb/Host/common/UDPSocket.h b/include/lldb/Host/common/UDPSocket.h
index 27b2d1dc98349..b7b6db67d10d9 100644
--- a/include/lldb/Host/common/UDPSocket.h
+++ b/include/lldb/Host/common/UDPSocket.h
@@ -1,9 +1,8 @@
//===-- UDPSocket.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,6 +19,8 @@ public:
static Status Connect(llvm::StringRef name, bool child_processes_inherit,
Socket *&socket);
+ std::string GetRemoteConnectionURI() const override;
+
private:
UDPSocket(NativeSocket socket);
diff --git a/include/lldb/Host/freebsd/HostInfoFreeBSD.h b/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index 5b3a18d21079a..56f20bbd23d3b 100644
--- a/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -1,9 +1,8 @@
//===-- HostInfoFreeBSD.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/netbsd/HostInfoNetBSD.h b/include/lldb/Host/netbsd/HostInfoNetBSD.h
index 0d4de79d03b1f..f9ad66eb2b2af 100644
--- a/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -1,9 +1,8 @@
//===-- HostInfoNetBSD.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/openbsd/HostInfoOpenBSD.h b/include/lldb/Host/openbsd/HostInfoOpenBSD.h
index 5a0388ffdd977..7ec1d5fc3606d 100644
--- a/include/lldb/Host/openbsd/HostInfoOpenBSD.h
+++ b/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -1,9 +1,8 @@
//===-- HostInfoOpenBSD.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,12 +11,13 @@
#include "lldb/Host/posix/HostInfoPosix.h"
#include "lldb/Utility/FileSpec.h"
+#include "llvm/Support/VersionTuple.h"
namespace lldb_private {
class HostInfoOpenBSD : public HostInfoPosix {
public:
- static bool GetOSVersion(uint32_t &major, uint32_t &minor, uint32_t &update);
+ static llvm::VersionTuple GetOSVersion();
static bool GetOSBuildString(std::string &s);
static bool GetOSKernelDescription(std::string &s);
static FileSpec GetProgramFileSpec();
diff --git a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index e44737e481e62..b25fc47c56b6a 100644
--- a/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -1,9 +1,8 @@
//===-- ConnectionFileDescriptorPosix.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/posix/DomainSocket.h b/include/lldb/Host/posix/DomainSocket.h
index e66b3f971fafb..e407ce16bbcbb 100644
--- a/include/lldb/Host/posix/DomainSocket.h
+++ b/include/lldb/Host/posix/DomainSocket.h
@@ -1,9 +1,8 @@
//===-- DomainSocket.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,11 +20,14 @@ public:
Status Listen(llvm::StringRef name, int backlog) override;
Status Accept(Socket *&socket) override;
+ std::string GetRemoteConnectionURI() const override;
+
protected:
DomainSocket(SocketProtocol protocol, bool child_processes_inherit);
virtual size_t GetNameOffset() const;
virtual void DeleteSocketFile(llvm::StringRef name);
+ std::string GetSocketName() const;
private:
DomainSocket(NativeSocket socket, const DomainSocket &listen_socket);
diff --git a/include/lldb/Host/posix/Fcntl.h b/include/lldb/Host/posix/Fcntl.h
index 833a905841412..31cc293dd37a6 100644
--- a/include/lldb/Host/posix/Fcntl.h
+++ b/include/lldb/Host/posix/Fcntl.h
@@ -1,9 +1,8 @@
//===-- Fcntl.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/posix/HostInfoPosix.h b/include/lldb/Host/posix/HostInfoPosix.h
index dda70f9f5a96a..26910132f3c83 100644
--- a/include/lldb/Host/posix/HostInfoPosix.h
+++ b/include/lldb/Host/posix/HostInfoPosix.h
@@ -1,9 +1,8 @@
//===-- HostInfoPosix.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,14 +14,14 @@
namespace lldb_private {
+class UserIDResolver;
+
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);
static uint32_t GetUserID();
static uint32_t GetGroupID();
@@ -33,8 +32,7 @@ public:
static bool GetEnvironmentVar(const std::string &var_name, std::string &var);
- static bool ComputePathRelativeToLibrary(FileSpec &file_spec,
- llvm::StringRef dir);
+ static UserIDResolver &GetUserIDResolver();
protected:
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
diff --git a/include/lldb/Host/posix/HostProcessPosix.h b/include/lldb/Host/posix/HostProcessPosix.h
index 2cbd4871dd6a2..a313358631b5e 100644
--- a/include/lldb/Host/posix/HostProcessPosix.h
+++ b/include/lldb/Host/posix/HostProcessPosix.h
@@ -1,9 +1,8 @@
//===-- HostProcessPosix.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,8 +32,9 @@ public:
lldb::pid_t GetProcessId() const override;
bool IsRunning() const override;
- HostThread StartMonitoring(const Host::MonitorChildProcessCallback &callback,
- bool monitor_signals) override;
+ llvm::Expected<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 c230a61bc5752..54012e15ad992 100644
--- a/include/lldb/Host/posix/HostThreadPosix.h
+++ b/include/lldb/Host/posix/HostThreadPosix.h
@@ -1,9 +1,8 @@
//===-- HostThreadPosix.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/posix/LockFilePosix.h b/include/lldb/Host/posix/LockFilePosix.h
index a59a7fe3e7290..63333bff4cd3f 100644
--- a/include/lldb/Host/posix/LockFilePosix.h
+++ b/include/lldb/Host/posix/LockFilePosix.h
@@ -1,9 +1,8 @@
//===-- LockFilePosix.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Host/posix/PipePosix.h b/include/lldb/Host/posix/PipePosix.h
index 30d19d97152b3..df341f2fc8951 100644
--- a/include/lldb/Host/posix/PipePosix.h
+++ b/include/lldb/Host/posix/PipePosix.h
@@ -1,9 +1,8 @@
//===-- PipePosix.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,13 +14,11 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h"
+/// \class PipePosix PipePosix.h "lldb/Host/posix/PipePosix.h"
/// A posix-based implementation of Pipe, a class that abtracts
/// unix style pipes.
///
/// A class that abstracts the LLDB core from host pipe functionality.
-//----------------------------------------------------------------------
class PipePosix : public PipeBase {
public:
static int kInvalidDescriptor;
diff --git a/include/lldb/Host/posix/ProcessLauncherPosixFork.h b/include/lldb/Host/posix/ProcessLauncherPosixFork.h
index 1193a20b4d36b..15e2d6d23b8ea 100644
--- a/include/lldb/Host/posix/ProcessLauncherPosixFork.h
+++ b/include/lldb/Host/posix/ProcessLauncherPosixFork.h
@@ -1,9 +1,8 @@
//===-- ProcessLauncherPosixFork.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Initialization/SystemInitializer.h b/include/lldb/Initialization/SystemInitializer.h
index b665b99972144..e616ad1ee811d 100644
--- a/include/lldb/Initialization/SystemInitializer.h
+++ b/include/lldb/Initialization/SystemInitializer.h
@@ -1,9 +1,8 @@
//===-- SystemInitializer.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,18 +15,12 @@
namespace lldb_private {
-struct InitializerOptions {
- bool reproducer_capture = false;
- bool reproducer_replay = false;
- std::string reproducer_path;
-};
-
class SystemInitializer {
public:
SystemInitializer();
virtual ~SystemInitializer();
- virtual llvm::Error Initialize(const InitializerOptions &options) = 0;
+ virtual llvm::Error Initialize() = 0;
virtual void Terminate() = 0;
};
}
diff --git a/include/lldb/Initialization/SystemInitializerCommon.h b/include/lldb/Initialization/SystemInitializerCommon.h
index f33acaf404663..ad7e58e50bbe5 100644
--- a/include/lldb/Initialization/SystemInitializerCommon.h
+++ b/include/lldb/Initialization/SystemInitializerCommon.h
@@ -1,9 +1,8 @@
//===-- SystemInitializerCommon.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,7 +12,6 @@
#include "SystemInitializer.h"
namespace lldb_private {
-//------------------------------------------------------------------
/// Initializes common lldb functionality.
///
/// This class is responsible for initializing a subset of lldb
@@ -22,13 +20,12 @@ namespace lldb_private {
/// functionality is separate. This class is used by constructing
/// an instance of SystemLifetimeManager with this class passed to
/// the constructor.
-//------------------------------------------------------------------
class SystemInitializerCommon : public SystemInitializer {
public:
SystemInitializerCommon();
~SystemInitializerCommon() override;
- llvm::Error Initialize(const InitializerOptions &options) override;
+ llvm::Error Initialize() override;
void Terminate() override;
};
diff --git a/include/lldb/Initialization/SystemLifetimeManager.h b/include/lldb/Initialization/SystemLifetimeManager.h
index 0839856f21e25..2e99b86dbdbd0 100644
--- a/include/lldb/Initialization/SystemLifetimeManager.h
+++ b/include/lldb/Initialization/SystemLifetimeManager.h
@@ -1,9 +1,8 @@
//===-- SystemLifetimeManager.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,7 +24,6 @@ public:
~SystemLifetimeManager();
llvm::Error Initialize(std::unique_ptr<SystemInitializer> initializer,
- const InitializerOptions &options,
LoadPluginCallbackType plugin_callback);
void Terminate();
diff --git a/include/lldb/Interpreter/CommandAlias.h b/include/lldb/Interpreter/CommandAlias.h
index c865ad7ff2c92..c2a7a383f35a2 100644
--- a/include/lldb/Interpreter/CommandAlias.h
+++ b/include/lldb/Interpreter/CommandAlias.h
@@ -1,9 +1,8 @@
//===-- CommandAlias.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/CommandCompletions.h b/include/lldb/Interpreter/CommandCompletions.h
index 71b0af3295b62..3d09db5ce5e79 100644
--- a/include/lldb/Interpreter/CommandCompletions.h
+++ b/include/lldb/Interpreter/CommandCompletions.h
@@ -1,9 +1,8 @@
//===-- CommandCompletions.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,16 +23,14 @@ namespace lldb_private {
class TildeExpressionResolver;
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,
CompletionRequest &request,
// A search filter to limit the search...
lldb_private::SearchFilter *searcher);
- typedef enum {
+ enum CommonCompletionTypes {
eNoCompletion = 0u,
eSourceFileCompletion = (1u << 0),
eDiskFileCompletion = (1u << 1),
@@ -48,7 +45,7 @@ public:
// 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;
@@ -59,9 +56,7 @@ public:
CommandInterpreter &interpreter, uint32_t completion_mask,
lldb_private::CompletionRequest &request, SearchFilter *searcher);
- //----------------------------------------------------------------------
// These are the generic completer functions:
- //----------------------------------------------------------------------
static int DiskFiles(CommandInterpreter &interpreter,
CompletionRequest &request, SearchFilter *searcher);
@@ -99,10 +94,8 @@ public:
static int VariablePath(CommandInterpreter &interpreter,
CompletionRequest &request, SearchFilter *searcher);
- //----------------------------------------------------------------------
// 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, CompletionRequest &request);
@@ -124,9 +117,7 @@ public:
DISALLOW_COPY_AND_ASSIGN(Completer);
};
- //----------------------------------------------------------------------
// SourceFileCompleter implements the source file completer
- //----------------------------------------------------------------------
class SourceFileCompleter : public Completer {
public:
SourceFileCompleter(CommandInterpreter &interpreter,
@@ -150,9 +141,7 @@ public:
DISALLOW_COPY_AND_ASSIGN(SourceFileCompleter);
};
- //----------------------------------------------------------------------
// ModuleCompleter implements the module completer
- //----------------------------------------------------------------------
class ModuleCompleter : public Completer {
public:
ModuleCompleter(CommandInterpreter &interpreter,
@@ -174,9 +163,7 @@ public:
DISALLOW_COPY_AND_ASSIGN(ModuleCompleter);
};
- //----------------------------------------------------------------------
// SymbolCompleter implements the symbol completer
- //----------------------------------------------------------------------
class SymbolCompleter : public Completer {
public:
SymbolCompleter(CommandInterpreter &interpreter,
diff --git a/include/lldb/Interpreter/CommandHistory.h b/include/lldb/Interpreter/CommandHistory.h
index f414c55e2d64c..c1386f84fe2e1 100644
--- a/include/lldb/Interpreter/CommandHistory.h
+++ b/include/lldb/Interpreter/CommandHistory.h
@@ -1,9 +1,8 @@
//===-- CommandHistory.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/CommandInterpreter.h b/include/lldb/Interpreter/CommandInterpreter.h
index 558246037ad08..c3dd6606e0db9 100644
--- a/include/lldb/Interpreter/CommandInterpreter.h
+++ b/include/lldb/Interpreter/CommandInterpreter.h
@@ -1,9 +1,8 @@
//===-- CommandInterpreter.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,45 +29,47 @@ namespace lldb_private {
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
+ /// \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 \b false, we won't
/// check the execution status.
- /// @param[in] stop_on_error
+ /// \param[in] stop_on_error
/// If \b true, execution will end on the first command that causes an
/// error.
- /// @param[in] stop_on_crash
+ /// \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
+ /// \param[in] echo_commands
/// If \b true, echo the command before executing it. If \b false, execute
/// silently.
- /// @param[in] echo_comments
+ /// \param[in] echo_comments
/// If \b true, echo command even if it is a pure comment line. If
/// \b false, print no ouput in this case. This setting has an effect only
/// if \param echo_commands is \b true.
- /// @param[in] print_results
- /// If \b true print the results of the command after executing it. If
- /// \b false, execute silently.
- /// @param[in] add_to_history
+ /// \param[in] print_results
+ /// If \b true and the command succeeds, print the results of the command
+ /// after executing it. If \b false, execute silently.
+ /// \param[in] print_errors
+ /// If \b true and the command fails, print the results of the command
+ /// after executing it. If \b false, execute silently.
+ /// \param[in] add_to_history
/// If \b true add the commands to the command history. If \b false, don't
/// add them.
- //------------------------------------------------------------------
CommandInterpreterRunOptions(LazyBool stop_on_continue,
LazyBool stop_on_error, LazyBool stop_on_crash,
LazyBool echo_commands, LazyBool echo_comments,
- LazyBool print_results, LazyBool add_to_history)
+ LazyBool print_results, LazyBool print_errors,
+ 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_echo_comment_commands(echo_comments), m_print_results(print_results),
- m_add_to_history(add_to_history) {}
+ m_print_errors(print_errors), m_add_to_history(add_to_history) {}
CommandInterpreterRunOptions()
: m_stop_on_continue(eLazyBoolCalculate),
@@ -76,13 +77,14 @@ public:
m_stop_on_crash(eLazyBoolCalculate),
m_echo_commands(eLazyBoolCalculate),
m_echo_comment_commands(eLazyBoolCalculate),
- m_print_results(eLazyBoolCalculate),
+ m_print_results(eLazyBoolCalculate), m_print_errors(eLazyBoolCalculate),
m_add_to_history(eLazyBoolCalculate) {}
void SetSilent(bool silent) {
LazyBool value = silent ? eLazyBoolNo : eLazyBoolYes;
m_print_results = value;
+ m_print_errors = value;
m_echo_commands = value;
m_echo_comment_commands = value;
m_add_to_history = value;
@@ -130,6 +132,12 @@ public:
m_print_results = print_results ? eLazyBoolYes : eLazyBoolNo;
}
+ bool GetPrintErrors() const { return DefaultToYes(m_print_errors); }
+
+ void SetPrintErrors(bool print_errors) {
+ m_print_errors = print_errors ? eLazyBoolYes : eLazyBoolNo;
+ }
+
bool GetAddToHistory() const { return DefaultToYes(m_add_to_history); }
void SetAddToHistory(bool add_to_history) {
@@ -142,6 +150,7 @@ public:
LazyBool m_echo_commands;
LazyBool m_echo_comment_commands;
LazyBool m_print_results;
+ LazyBool m_print_errors;
LazyBool m_add_to_history;
private:
@@ -191,8 +200,7 @@ public:
eCommandTypesAllThem = 0xFFFF // all commands
};
- CommandInterpreter(Debugger &debugger, lldb::ScriptLanguage script_language,
- bool synchronous_execution);
+ CommandInterpreter(Debugger &debugger, bool synchronous_execution);
~CommandInterpreter() override;
@@ -204,7 +212,8 @@ public:
return GetStaticBroadcasterClass();
}
- void SourceInitFile(bool in_cwd, CommandReturnObject &result);
+ void SourceInitFileCwd(CommandReturnObject &result);
+ void SourceInitFileHome(CommandReturnObject &result);
bool AddCommand(llvm::StringRef name, const lldb::CommandObjectSP &cmd_sp,
bool can_replace);
@@ -255,48 +264,44 @@ public:
bool WasInterrupted() const;
- //------------------------------------------------------------------
/// Execute a list of commands in sequence.
///
- /// @param[in] commands
+ /// \param[in] commands
/// The list of commands to execute.
- /// @param[in,out] context
+ /// \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
+ /// \param[in] options
/// This object holds the options used to control when to stop, whether to
/// execute commands,
/// etc.
- /// @param[out] result
+ /// \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
+ /// \param[in] file
/// The file from which to read in commands.
- /// @param[in,out] context
+ /// \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
+ /// \param[in] options
/// This object holds the options used to control when to stop, whether to
/// execute commands,
/// etc.
- /// @param[out] result
+ /// \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);
@@ -379,8 +384,6 @@ public:
void Clear();
- void SetScriptLanguage(lldb::ScriptLanguage lang);
-
bool HasCommands() const;
bool HasAliases() const;
@@ -396,16 +399,12 @@ public:
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;
+ m_skip_app_init_files = skip_app_init_files;
}
bool GetSynchronous();
@@ -442,8 +441,6 @@ public:
"the target.max-children-count setting.\n";
}
- const CommandHistory &GetCommandHistory() const { return m_command_history; }
-
CommandHistory &GetCommandHistory() { return m_command_history; }
bool IsActive();
@@ -460,9 +457,7 @@ public:
const char *GetCommandPrefix();
- //------------------------------------------------------------------
// Properties
- //------------------------------------------------------------------
bool GetExpandRegexAliases() const;
bool GetPromptOnQuit() const;
@@ -475,28 +470,22 @@ public:
bool GetEchoCommentCommands() const;
void SetEchoCommentCommands(bool b);
- //------------------------------------------------------------------
/// Specify if the command interpreter should allow that the user can
/// specify a custom exit code when calling 'quit'.
- //------------------------------------------------------------------
void AllowExitCodeOnQuit(bool allow);
- //------------------------------------------------------------------
/// Sets the exit code for the quit command.
- /// @param[in] exit_code
+ /// \param[in] exit_code
/// The exit code that the driver should return on exit.
- /// @return True if the exit code was successfully set; false if the
+ /// \return True if the exit code was successfully set; false if the
/// interpreter doesn't allow custom exit codes.
- /// @see AllowExitCodeOnQuit
- //------------------------------------------------------------------
+ /// \see AllowExitCodeOnQuit
LLVM_NODISCARD bool SetQuitExitCode(int exit_code);
- //------------------------------------------------------------------
/// Returns the exit code that the user has specified when running the
/// 'quit' command.
- /// @param[out] exited
+ /// \param[out] exited
/// Set to true if the user has called quit with a custom exit code.
- //------------------------------------------------------------------
int GetQuitExitCode(bool &exited) const;
void ResolveCommand(const char *command_line, CommandReturnObject &result);
@@ -518,9 +507,7 @@ public:
protected:
friend class Debugger;
- //------------------------------------------------------------------
// IOHandlerDelegate functions
- //------------------------------------------------------------------
void IOHandlerInputComplete(IOHandler &io_handler,
std::string &line) override;
@@ -545,6 +532,8 @@ protected:
private:
Status PreprocessCommand(std::string &command);
+ void SourceInitFile(FileSpec file, CommandReturnObject &result);
+
// Completely resolves aliases and abbreviations, returning a pointer to the
// final command object and updating command_line to the fully substituted
// and translated command.
@@ -593,8 +582,6 @@ private:
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::recursive_mutex m_script_interpreter_mutex;
lldb::IOHandlerSP m_command_io_handler_sp;
char m_comment_char;
bool m_batch_command_mode;
diff --git a/include/lldb/Interpreter/CommandObject.h b/include/lldb/Interpreter/CommandObject.h
index f72628b8a643c..31f7f126a9feb 100644
--- a/include/lldb/Interpreter/CommandObject.h
+++ b/include/lldb/Interpreter/CommandObject.h
@@ -1,9 +1,8 @@
//===-- CommandObject.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -122,6 +121,7 @@ public:
GetArgumentDescriptionAsCString(const lldb::CommandArgumentType arg_type);
CommandInterpreter &GetCommandInterpreter() { return m_interpreter; }
+ Debugger &GetDebugger();
virtual llvm::StringRef GetHelp();
@@ -221,25 +221,22 @@ public:
void SetCommandName(llvm::StringRef name);
- //------------------------------------------------------------------
/// 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/out] request
+ /// \param[in/out] request
/// The completion request that needs to be answered.
///
/// 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
+ /// \return
/// \btrue if we were in an option, \bfalse otherwise.
- //------------------------------------------------------------------
virtual int HandleCompletion(CompletionRequest &request);
- //------------------------------------------------------------------
/// 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
@@ -247,16 +244,15 @@ public:
/// We've constructed the map of options and their arguments as well if that
/// is helpful for the completion.
///
- /// @param[in/out] request
+ /// \param[in/out] request
/// The completion request that needs to be answered.
///
/// 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
+ /// \return
/// The number of completions.
- //------------------------------------------------------------------
virtual int
HandleArgumentCompletion(CompletionRequest &request,
OptionElementVector &opt_element_vector) {
@@ -269,35 +265,29 @@ public:
bool search_syntax = true,
bool search_options = true);
- //------------------------------------------------------------------
/// The flags accessor.
///
- /// @return
+ /// \return
/// A reference to the Flags member variable.
- //------------------------------------------------------------------
Flags &GetFlags() { return m_flags; }
- //------------------------------------------------------------------
/// The flags const accessor.
///
- /// @return
+ /// \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
+ /// \param[in] current_command_line
/// The complete current command line.
///
- /// @return
+ /// \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;
@@ -368,17 +358,15 @@ protected:
// 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
+ /// \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
+ /// \return
/// \b true if it is okay to run this command, \b false otherwise.
- //------------------------------------------------------------------
bool CheckRequirements(CommandReturnObject &result);
void Cleanup();
diff --git a/include/lldb/Interpreter/CommandObjectMultiword.h b/include/lldb/Interpreter/CommandObjectMultiword.h
index e1ea39f7ec34d..660e9d49d977f 100644
--- a/include/lldb/Interpreter/CommandObjectMultiword.h
+++ b/include/lldb/Interpreter/CommandObjectMultiword.h
@@ -1,9 +1,8 @@
//===-- CommandObjectMultiword.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiword
-//-------------------------------------------------------------------------
class CommandObjectMultiword : public CommandObject {
// These two want to iterate over the subcommand dictionary.
diff --git a/include/lldb/Interpreter/CommandObjectRegexCommand.h b/include/lldb/Interpreter/CommandObjectRegexCommand.h
index d50bc3ba9141c..7f06e269d64f7 100644
--- a/include/lldb/Interpreter/CommandObjectRegexCommand.h
+++ b/include/lldb/Interpreter/CommandObjectRegexCommand.h
@@ -1,9 +1,8 @@
//===-- CommandObjectRegexCommand.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectRegexCommand
-//-------------------------------------------------------------------------
class CommandObjectRegexCommand : public CommandObjectRaw {
public:
diff --git a/include/lldb/Interpreter/CommandOptionValidators.h b/include/lldb/Interpreter/CommandOptionValidators.h
index e0c8ddde6ecbd..5483c1509556b 100644
--- a/include/lldb/Interpreter/CommandOptionValidators.h
+++ b/include/lldb/Interpreter/CommandOptionValidators.h
@@ -1,9 +1,8 @@
//===-- CommandOptionValidators.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/CommandReturnObject.h b/include/lldb/Interpreter/CommandReturnObject.h
index 53a908f97ccb9..a5f61261455ee 100644
--- a/include/lldb/Interpreter/CommandReturnObject.h
+++ b/include/lldb/Interpreter/CommandReturnObject.h
@@ -1,9 +1,8 @@
//===-- CommandReturnObject.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/OptionArgParser.h b/include/lldb/Interpreter/OptionArgParser.h
index b5a083929067c..ce901b0483b41 100644
--- a/include/lldb/Interpreter/OptionArgParser.h
+++ b/include/lldb/Interpreter/OptionArgParser.h
@@ -1,9 +1,8 @@
//===-- OptionArgParser.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/OptionGroupArchitecture.h b/include/lldb/Interpreter/OptionGroupArchitecture.h
index 2cecaa65a0fdc..4b7f9fe92e359 100644
--- a/include/lldb/Interpreter/OptionGroupArchitecture.h
+++ b/include/lldb/Interpreter/OptionGroupArchitecture.h
@@ -1,9 +1,8 @@
//===-- OptionGroupArchitecture.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupArchitecture
-//-------------------------------------------------------------------------
class OptionGroupArchitecture : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupBoolean.h b/include/lldb/Interpreter/OptionGroupBoolean.h
index 161c12a41f9f8..77490457528a9 100644
--- a/include/lldb/Interpreter/OptionGroupBoolean.h
+++ b/include/lldb/Interpreter/OptionGroupBoolean.h
@@ -1,9 +1,8 @@
//===-- OptionGroupBoolean.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
#include "lldb/Interpreter/Options.h"
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupBoolean
-//-------------------------------------------------------------------------
class OptionGroupBoolean : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupFile.h b/include/lldb/Interpreter/OptionGroupFile.h
index 4a56e4c742fdd..cce3714e98b93 100644
--- a/include/lldb/Interpreter/OptionGroupFile.h
+++ b/include/lldb/Interpreter/OptionGroupFile.h
@@ -1,9 +1,8 @@
//===-- OptionGroupFile.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupFile
-//-------------------------------------------------------------------------
class OptionGroupFile : public OptionGroup {
public:
@@ -48,9 +45,7 @@ protected:
OptionDefinition m_option_definition;
};
-//-------------------------------------------------------------------------
// OptionGroupFileList
-//-------------------------------------------------------------------------
class OptionGroupFileList : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupFormat.h b/include/lldb/Interpreter/OptionGroupFormat.h
index 52113d8777f50..1b5020a392c5f 100644
--- a/include/lldb/Interpreter/OptionGroupFormat.h
+++ b/include/lldb/Interpreter/OptionGroupFormat.h
@@ -1,9 +1,8 @@
//===-- OptionGroupFormat.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupFormat
-//-------------------------------------------------------------------------
class OptionGroupFormat : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupOutputFile.h b/include/lldb/Interpreter/OptionGroupOutputFile.h
index 88d45797358d3..82d68b7c164e4 100644
--- a/include/lldb/Interpreter/OptionGroupOutputFile.h
+++ b/include/lldb/Interpreter/OptionGroupOutputFile.h
@@ -1,9 +1,8 @@
//===-- OptionGroupOutputFile.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
#include "lldb/Interpreter/Options.h"
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupOutputFile
-//-------------------------------------------------------------------------
class OptionGroupOutputFile : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupPlatform.h b/include/lldb/Interpreter/OptionGroupPlatform.h
index 9bc9588deab3c..ea5a3f39ef837 100644
--- a/include/lldb/Interpreter/OptionGroupPlatform.h
+++ b/include/lldb/Interpreter/OptionGroupPlatform.h
@@ -1,9 +1,8 @@
//===-- OptionGroupPlatform.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,11 +15,9 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// PlatformOptionGroup
//
// Make platform options available to any commands that need the settings.
-//-------------------------------------------------------------------------
class OptionGroupPlatform : public OptionGroup {
public:
OptionGroupPlatform(bool include_platform_option)
@@ -51,15 +48,15 @@ public:
m_platform_name.clear();
}
- const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; }
+ ConstString GetSDKRootDirectory() const { return m_sdk_sysroot; }
- void SetSDKRootDirectory(const ConstString &sdk_root_directory) {
+ void SetSDKRootDirectory(ConstString sdk_root_directory) {
m_sdk_sysroot = sdk_root_directory;
}
- const ConstString &GetSDKBuild() const { return m_sdk_build; }
+ ConstString GetSDKBuild() const { return m_sdk_build; }
- void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; }
+ void SetSDKBuild(ConstString sdk_build) { m_sdk_build = sdk_build; }
bool PlatformMatches(const lldb::PlatformSP &platform_sp) const;
diff --git a/include/lldb/Interpreter/OptionGroupString.h b/include/lldb/Interpreter/OptionGroupString.h
index 41889fe57d779..ce1058954054c 100644
--- a/include/lldb/Interpreter/OptionGroupString.h
+++ b/include/lldb/Interpreter/OptionGroupString.h
@@ -1,9 +1,8 @@
//===-- OptionGroupString.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
#include "lldb/Interpreter/Options.h"
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupString
-//-------------------------------------------------------------------------
class OptionGroupString : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupUInt64.h b/include/lldb/Interpreter/OptionGroupUInt64.h
index d6b06066b9641..12f08a38c5331 100644
--- a/include/lldb/Interpreter/OptionGroupUInt64.h
+++ b/include/lldb/Interpreter/OptionGroupUInt64.h
@@ -1,9 +1,8 @@
//===-- OptionGroupUInt64.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupUInt64
-//-------------------------------------------------------------------------
class OptionGroupUInt64 : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupUUID.h b/include/lldb/Interpreter/OptionGroupUUID.h
index 390f128a86184..22fc3a100c757 100644
--- a/include/lldb/Interpreter/OptionGroupUUID.h
+++ b/include/lldb/Interpreter/OptionGroupUUID.h
@@ -1,9 +1,8 @@
//===-- OptionGroupUUID.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupUUID
-//-------------------------------------------------------------------------
class OptionGroupUUID : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
index 8684453d89c61..5a1bbc9e7b667 100644
--- a/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
+++ b/include/lldb/Interpreter/OptionGroupValueObjectDisplay.h
@@ -1,9 +1,8 @@
//===-- OptionGroupValueObjectDisplay.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupValueObjectDisplay
-//-------------------------------------------------------------------------
class OptionGroupValueObjectDisplay : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupVariable.h b/include/lldb/Interpreter/OptionGroupVariable.h
index 663705acebbcc..0c042f4c1cdb3 100644
--- a/include/lldb/Interpreter/OptionGroupVariable.h
+++ b/include/lldb/Interpreter/OptionGroupVariable.h
@@ -1,9 +1,8 @@
//===-- OptionGroupVariable.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupVariable
-//-------------------------------------------------------------------------
class OptionGroupVariable : public OptionGroup {
public:
diff --git a/include/lldb/Interpreter/OptionGroupWatchpoint.h b/include/lldb/Interpreter/OptionGroupWatchpoint.h
index 2d4456ef31a9b..3729c000b8e07 100644
--- a/include/lldb/Interpreter/OptionGroupWatchpoint.h
+++ b/include/lldb/Interpreter/OptionGroupWatchpoint.h
@@ -1,9 +1,8 @@
//===-- OptionGroupWatchpoint.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// OptionGroupWatchpoint
-//-------------------------------------------------------------------------
class OptionGroupWatchpoint : public OptionGroup {
public:
@@ -37,12 +34,12 @@ public:
// Note:
// eWatchRead == LLDB_WATCH_TYPE_READ; and
// eWatchWrite == LLDB_WATCH_TYPE_WRITE
- typedef enum WatchType {
+ enum WatchType {
eWatchInvalid = 0,
eWatchRead,
eWatchWrite,
eWatchReadWrite
- } WatchType;
+ };
WatchType watch_type;
uint32_t watch_size;
diff --git a/include/lldb/Interpreter/OptionValue.h b/include/lldb/Interpreter/OptionValue.h
index e90d7ed6d8ebd..0b85bc19dd2a5 100644
--- a/include/lldb/Interpreter/OptionValue.h
+++ b/include/lldb/Interpreter/OptionValue.h
@@ -1,9 +1,8 @@
//===-- OptionValue.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,12 +19,10 @@
namespace lldb_private {
-//---------------------------------------------------------------------
// OptionValue
-//---------------------------------------------------------------------
class OptionValue {
public:
- typedef enum {
+ enum Type {
eTypeInvalid = 0,
eTypeArch,
eTypeArgs,
@@ -46,7 +43,7 @@ public:
eTypeUInt64,
eTypeUUID,
eTypeFormatEntity
- } Type;
+ };
enum {
eDumpOptionName = (1u << 0),
@@ -70,9 +67,7 @@ public:
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,
@@ -101,9 +96,7 @@ public:
virtual size_t AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request);
- //-----------------------------------------------------------------
// Subclasses can override these functions
- //-----------------------------------------------------------------
virtual lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
llvm::StringRef name,
bool will_modify,
@@ -122,10 +115,8 @@ public:
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) {
diff --git a/include/lldb/Interpreter/OptionValueArch.h b/include/lldb/Interpreter/OptionValueArch.h
index 15b74ad178930..f8f406890841a 100644
--- a/include/lldb/Interpreter/OptionValueArch.h
+++ b/include/lldb/Interpreter/OptionValueArch.h
@@ -1,9 +1,8 @@
//===-- OptionValueArch.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,9 +33,7 @@ public:
~OptionValueArch() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeArch; }
@@ -61,9 +58,7 @@ public:
size_t AutoComplete(CommandInterpreter &interpreter,
lldb_private::CompletionRequest &request) override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
ArchSpec &GetCurrentValue() { return m_current_value; }
diff --git a/include/lldb/Interpreter/OptionValueArgs.h b/include/lldb/Interpreter/OptionValueArgs.h
index 41af1298c2cb4..0254b9aa7e141 100644
--- a/include/lldb/Interpreter/OptionValueArgs.h
+++ b/include/lldb/Interpreter/OptionValueArgs.h
@@ -1,9 +1,8 @@
//===-- OptionValueArgs.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/OptionValueArray.h b/include/lldb/Interpreter/OptionValueArray.h
index 06c4828402600..10f3bf5f729f8 100644
--- a/include/lldb/Interpreter/OptionValueArray.h
+++ b/include/lldb/Interpreter/OptionValueArray.h
@@ -1,9 +1,8 @@
//===-- OptionValueArray.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,9 +22,7 @@ public:
~OptionValueArray() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeArray; }
@@ -53,9 +50,7 @@ public:
llvm::StringRef name, bool will_modify,
Status &error) const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
size_t GetSize() const { return m_values.size(); }
diff --git a/include/lldb/Interpreter/OptionValueBoolean.h b/include/lldb/Interpreter/OptionValueBoolean.h
index 572e6b1861fb1..2fc97d4949886 100644
--- a/include/lldb/Interpreter/OptionValueBoolean.h
+++ b/include/lldb/Interpreter/OptionValueBoolean.h
@@ -1,9 +1,8 @@
//===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@ public:
~OptionValueBoolean() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeBoolean; }
@@ -49,25 +46,21 @@ public:
size_t AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
- //------------------------------------------------------------------
/// Convert to bool operator.
///
/// This allows code to check a OptionValueBoolean in conditions.
///
- /// @code
+ /// \code
/// OptionValueBoolean bool_value(...);
/// if (bool_value)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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) {
diff --git a/include/lldb/Interpreter/OptionValueChar.h b/include/lldb/Interpreter/OptionValueChar.h
index e73976fefccc1..d8661363751be 100644
--- a/include/lldb/Interpreter/OptionValueChar.h
+++ b/include/lldb/Interpreter/OptionValueChar.h
@@ -1,9 +1,8 @@
-//===-- OptionValueBoolean.h ------------------------------------*- C++ -*-===//
+//===-- OptionValueChar.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ public:
~OptionValueChar() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeChar; }
@@ -47,9 +44,7 @@ public:
return true;
}
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
const char &operator=(char c) {
m_current_value = c;
diff --git a/include/lldb/Interpreter/OptionValueDictionary.h b/include/lldb/Interpreter/OptionValueDictionary.h
index b6163e7a9a25b..8785d38f5423c 100644
--- a/include/lldb/Interpreter/OptionValueDictionary.h
+++ b/include/lldb/Interpreter/OptionValueDictionary.h
@@ -1,9 +1,8 @@
//===-- OptionValueDictionary.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ public:
~OptionValueDictionary() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeDictionary; }
@@ -52,13 +49,11 @@ public:
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 GetValueForKey(ConstString key) const;
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
llvm::StringRef name, bool will_modify,
@@ -67,11 +62,11 @@ public:
Status SetSubValue(const ExecutionContext *exe_ctx, VarSetOperationType op,
llvm::StringRef name, llvm::StringRef value) override;
- bool SetValueForKey(const ConstString &key,
+ bool SetValueForKey(ConstString key,
const lldb::OptionValueSP &value_sp,
bool can_replace = true);
- bool DeleteValueForKey(const ConstString &key);
+ bool DeleteValueForKey(ConstString key);
size_t GetArgs(Args &args) const;
diff --git a/include/lldb/Interpreter/OptionValueEnumeration.h b/include/lldb/Interpreter/OptionValueEnumeration.h
index 16c09c589a277..71f3ab53b2ff3 100644
--- a/include/lldb/Interpreter/OptionValueEnumeration.h
+++ b/include/lldb/Interpreter/OptionValueEnumeration.h
@@ -1,9 +1,8 @@
//===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,9 +33,7 @@ public:
~OptionValueEnumeration() override;
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeEnum; }
@@ -61,9 +58,7 @@ public:
size_t AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
enum_type operator=(enum_type value) {
m_current_value = value;
diff --git a/include/lldb/Interpreter/OptionValueFileSpec.h b/include/lldb/Interpreter/OptionValueFileSpec.h
index 41a479e2fc9e4..aa1022a4fe2c1 100644
--- a/include/lldb/Interpreter/OptionValueFileSpec.h
+++ b/include/lldb/Interpreter/OptionValueFileSpec.h
@@ -1,9 +1,8 @@
//===-- OptionValueFileSpec.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,9 +27,7 @@ public:
~OptionValueFileSpec() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeFileSpec; }
@@ -57,9 +54,7 @@ public:
size_t AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
FileSpec &GetCurrentValue() { return m_current_value; }
diff --git a/include/lldb/Interpreter/OptionValueFileSpecList.h b/include/lldb/Interpreter/OptionValueFileSpecList.h
index 5c43b85bcea7b..5607437fd0dca 100644
--- a/include/lldb/Interpreter/OptionValueFileSpecList.h
+++ b/include/lldb/Interpreter/OptionValueFileSpecList.h
@@ -1,15 +1,16 @@
//===-- OptionValueFileSpecList.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_OptionValueFileSpecList_h_
#define liblldb_OptionValueFileSpecList_h_
+#include <mutex>
+
#include "lldb/Core/FileSpecList.h"
#include "lldb/Interpreter/OptionValue.h"
@@ -24,9 +25,7 @@ public:
~OptionValueFileSpecList() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeFileSpecList; }
@@ -41,6 +40,7 @@ public:
VarSetOperationType = eVarSetOperationAssign) = delete;
bool Clear() override {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
m_current_value.Clear();
m_value_was_set = false;
return true;
@@ -50,17 +50,25 @@ public:
bool IsAggregateValue() const override { return true; }
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
- FileSpecList &GetCurrentValue() { return m_current_value; }
+ FileSpecList GetCurrentValue() const {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ return m_current_value;
+ }
- const FileSpecList &GetCurrentValue() const { return m_current_value; }
+ void SetCurrentValue(const FileSpecList &value) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ m_current_value = value;
+ }
- void SetCurrentValue(const FileSpecList &value) { m_current_value = value; }
+ void AppendCurrentValue(const FileSpec &value) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ m_current_value.Append(value);
+ }
protected:
+ mutable std::recursive_mutex m_mutex;
FileSpecList m_current_value;
};
diff --git a/include/lldb/Interpreter/OptionValueFormat.h b/include/lldb/Interpreter/OptionValueFormat.h
index 6d46957d26f76..020f4aeda17a7 100644
--- a/include/lldb/Interpreter/OptionValueFormat.h
+++ b/include/lldb/Interpreter/OptionValueFormat.h
@@ -1,9 +1,8 @@
//===-- OptionValueFormat.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ public:
~OptionValueFormat() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeFormat; }
@@ -49,9 +46,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
lldb::Format GetCurrentValue() const { return m_current_value; }
diff --git a/include/lldb/Interpreter/OptionValueFormatEntity.h b/include/lldb/Interpreter/OptionValueFormatEntity.h
index 5d5a8ca02c970..b05be959f3d4e 100644
--- a/include/lldb/Interpreter/OptionValueFormatEntity.h
+++ b/include/lldb/Interpreter/OptionValueFormatEntity.h
@@ -1,9 +1,8 @@
//===-- OptionValueFormatEntity.h --------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,9 +20,7 @@ public:
~OptionValueFormatEntity() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeFormatEntity; }
@@ -44,9 +41,7 @@ public:
size_t AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
FormatEntity::Entry &GetCurrentValue() { return m_current_entry; }
diff --git a/include/lldb/Interpreter/OptionValueLanguage.h b/include/lldb/Interpreter/OptionValueLanguage.h
index 9d4956c6d7896..505dc89e92082 100644
--- a/include/lldb/Interpreter/OptionValueLanguage.h
+++ b/include/lldb/Interpreter/OptionValueLanguage.h
@@ -1,10 +1,9 @@
//===-- OptionValueLanguage.h -------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,9 +27,7 @@ public:
~OptionValueLanguage() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeLanguage; }
@@ -52,9 +49,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
lldb::LanguageType GetCurrentValue() const { return m_current_value; }
diff --git a/include/lldb/Interpreter/OptionValuePathMappings.h b/include/lldb/Interpreter/OptionValuePathMappings.h
index 85f9926b21f80..35c2af45bc974 100644
--- a/include/lldb/Interpreter/OptionValuePathMappings.h
+++ b/include/lldb/Interpreter/OptionValuePathMappings.h
@@ -1,9 +1,8 @@
//===-- OptionValuePathMappings.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ public:
~OptionValuePathMappings() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypePathMap; }
@@ -48,9 +45,7 @@ public:
bool IsAggregateValue() const override { return true; }
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
PathMappingList &GetCurrentValue() { return m_path_mappings; }
diff --git a/include/lldb/Interpreter/OptionValueProperties.h b/include/lldb/Interpreter/OptionValueProperties.h
index 941e48561f77f..bea2b3c91e009 100644
--- a/include/lldb/Interpreter/OptionValueProperties.h
+++ b/include/lldb/Interpreter/OptionValueProperties.h
@@ -1,9 +1,8 @@
//===-- OptionValueProperties.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,7 +26,7 @@ public:
OptionValueProperties()
: OptionValue(), m_name(), m_properties(), m_name_to_index() {}
- OptionValueProperties(const ConstString &name);
+ OptionValueProperties(ConstString name);
OptionValueProperties(const OptionValueProperties &global_properties);
@@ -63,36 +62,28 @@ public:
// 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;
+ virtual uint32_t GetPropertyIndex(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;
+ 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;
@@ -102,7 +93,7 @@ public:
uint32_t idx) const;
virtual lldb::OptionValueSP GetValueForKey(const ExecutionContext *exe_ctx,
- const ConstString &key,
+ ConstString key,
bool value_will_be_modified) const;
lldb::OptionValueSP GetSubValue(const ExecutionContext *exe_ctx,
@@ -200,11 +191,11 @@ public:
OptionValueFileSpecList *GetPropertyAtIndexAsOptionValueFileSpecList(
const ExecutionContext *exe_ctx, bool will_modify, uint32_t idx) const;
- void AppendProperty(const ConstString &name, const ConstString &desc,
+ void AppendProperty(ConstString name, ConstString desc,
bool is_global, const lldb::OptionValueSP &value_sp);
lldb::OptionValuePropertiesSP GetSubProperty(const ExecutionContext *exe_ctx,
- const ConstString &name);
+ ConstString name);
void SetValueChangedCallback(uint32_t property_idx,
OptionValueChangedCallback callback,
diff --git a/include/lldb/Interpreter/OptionValueRegex.h b/include/lldb/Interpreter/OptionValueRegex.h
index a77eb5323f23d..f5b2557634dfb 100644
--- a/include/lldb/Interpreter/OptionValueRegex.h
+++ b/include/lldb/Interpreter/OptionValueRegex.h
@@ -1,9 +1,8 @@
//===-- OptionValueRegex.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ public:
~OptionValueRegex() override = default;
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeRegex; }
@@ -46,9 +43,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
const RegularExpression *GetCurrentValue() const {
return (m_regex.IsValid() ? &m_regex : nullptr);
}
diff --git a/include/lldb/Interpreter/OptionValueSInt64.h b/include/lldb/Interpreter/OptionValueSInt64.h
index f630cbb8e2837..c2e8ff43a99a0 100644
--- a/include/lldb/Interpreter/OptionValueSInt64.h
+++ b/include/lldb/Interpreter/OptionValueSInt64.h
@@ -1,10 +1,9 @@
//===-- OptionValueSInt64.h --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,9 +36,7 @@ public:
~OptionValueSInt64() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeSInt64; }
@@ -61,9 +58,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
const int64_t &operator=(int64_t value) {
m_current_value = value;
diff --git a/include/lldb/Interpreter/OptionValueString.h b/include/lldb/Interpreter/OptionValueString.h
index ab15595a08b4d..d9e76d8b58fea 100644
--- a/include/lldb/Interpreter/OptionValueString.h
+++ b/include/lldb/Interpreter/OptionValueString.h
@@ -1,9 +1,8 @@
//===-- OptionValueString.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -72,9 +71,7 @@ public:
~OptionValueString() override = default;
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeString; }
@@ -96,9 +93,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
Flags &GetOptions() { return m_options; }
diff --git a/include/lldb/Interpreter/OptionValueUInt64.h b/include/lldb/Interpreter/OptionValueUInt64.h
index 5cbcafdb6e58c..5978cdb4434f0 100644
--- a/include/lldb/Interpreter/OptionValueUInt64.h
+++ b/include/lldb/Interpreter/OptionValueUInt64.h
@@ -1,10 +1,9 @@
//===-- OptionValueUInt64.h --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,17 +27,13 @@ public:
~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 *, Status &) = delete;
static lldb::OptionValueSP Create(llvm::StringRef value_str, Status &error);
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeUInt64; }
@@ -60,9 +55,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
const uint64_t &operator=(uint64_t value) {
m_current_value = value;
diff --git a/include/lldb/Interpreter/OptionValueUUID.h b/include/lldb/Interpreter/OptionValueUUID.h
index c2ee48962b42f..7273e35bd75b7 100644
--- a/include/lldb/Interpreter/OptionValueUUID.h
+++ b/include/lldb/Interpreter/OptionValueUUID.h
@@ -1,9 +1,8 @@
//===-- OptionValueUUID.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,9 +22,7 @@ public:
~OptionValueUUID() override {}
- //---------------------------------------------------------------------
// Virtual subclass pure virtual overrides
- //---------------------------------------------------------------------
OptionValue::Type GetType() const override { return eTypeUUID; }
@@ -47,9 +44,7 @@ public:
lldb::OptionValueSP DeepCopy() const override;
- //---------------------------------------------------------------------
// Subclass specific functions
- //---------------------------------------------------------------------
UUID &GetCurrentValue() { return m_uuid; }
diff --git a/include/lldb/Interpreter/OptionValues.h b/include/lldb/Interpreter/OptionValues.h
index e177d743ff185..d90b2867a4b07 100644
--- a/include/lldb/Interpreter/OptionValues.h
+++ b/include/lldb/Interpreter/OptionValues.h
@@ -1,9 +1,8 @@
//===-- OptionValues.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Interpreter/Options.h b/include/lldb/Interpreter/Options.h
index aa9e564083a90..a008d51d721ee 100644
--- a/include/lldb/Interpreter/Options.h
+++ b/include/lldb/Interpreter/Options.h
@@ -1,9 +1,8 @@
//===-- Options.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,8 +46,7 @@ static inline bool isprint8(int ch) {
return isprint(ch);
}
-//----------------------------------------------------------------------
-/// @class Options Options.h "lldb/Interpreter/Options.h"
+/// \class Options Options.h "lldb/Interpreter/Options.h"
/// A command line option parsing protocol class.
///
/// Options is designed to be subclassed to contain all needed options for a
@@ -61,7 +59,6 @@ static inline bool isprint8(int ch) {
/// *optstring, const struct option *longopts, int *longindex);
/// \endcode
///
-//----------------------------------------------------------------------
class Options {
public:
Options();
@@ -74,12 +71,10 @@ public:
uint32_t NumCommandOptions();
- //------------------------------------------------------------------
/// Get the option definitions to use when parsing Args options.
///
- /// @see Args::ParseOptions (Options&)
- /// @see man getopt_long_only
- //------------------------------------------------------------------
+ /// \see Args::ParseOptions (Options&)
+ /// \see man getopt_long_only
Option *GetLongOptions();
// This gets passed the short option as an integer...
@@ -115,7 +110,6 @@ public:
// and subclasses shouldn't have to do it.
void NotifyOptionParsingStarting(ExecutionContext *execution_context);
- //------------------------------------------------------------------
/// Parse the provided arguments.
///
/// The parsed options are set via calls to SetOptionValue. In case of a
@@ -132,7 +126,6 @@ public:
/// param[in] require_validation
/// When true, it will fail option parsing if validation could
/// not occur due to not having a platform.
- //------------------------------------------------------------------
llvm::Expected<Args> Parse(const Args &args,
ExecutionContext *execution_context,
lldb::PlatformSP platform_sp,
@@ -147,66 +140,60 @@ public:
Status NotifyOptionParsingFinished(ExecutionContext *execution_context);
- //------------------------------------------------------------------
/// Set the value of an option.
///
- /// @param[in] option_idx
+ /// \param[in] option_idx
/// The index into the "struct option" array that was returned
/// by Options::GetLongOptions().
///
- /// @param[in] option_arg
+ /// \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
+ /// \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
- //------------------------------------------------------------------
+ /// \see Args::ParseOptions (Options&)
+ /// \see man getopt_long_only
virtual Status 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/out] request
+ /// \param[in/out] request
/// The completion request that we need to act upon.
///
- /// @param[in] interpreter
+ /// \param[in] interpreter
/// The interpreter that's doing the completing.
///
/// 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
+ /// \return
/// \btrue if we were in an option, \bfalse otherwise.
- //------------------------------------------------------------------
bool HandleOptionCompletion(lldb_private::CompletionRequest &request,
OptionElementVector &option_map,
CommandInterpreter &interpreter);
- //------------------------------------------------------------------
/// Handles the generic bits of figuring out whether we are in an option,
/// and if so completing it.
///
- /// @param[in/out] request
+ /// \param[in/out] request
/// The completion request that we need to act upon.
///
- /// @param[in] interpreter
+ /// \param[in] interpreter
/// The command interpreter doing the completion.
///
/// 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
+ /// \return
/// \btrue if we were in an option, \bfalse otherwise.
- //------------------------------------------------------------------
virtual bool
HandleOptionArgumentCompletion(lldb_private::CompletionRequest &request,
OptionElementVector &opt_element_vector,
@@ -284,40 +271,36 @@ public:
~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
+ /// \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
+ /// \param[in] group
/// A group of options to take option values from and copy their
/// definitions into this class.
///
- /// @param[in] src_mask
+ /// \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
+ /// \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();
diff --git a/include/lldb/Interpreter/Property.h b/include/lldb/Interpreter/Property.h
index a7515e9903a49..797aee4be8159 100644
--- a/include/lldb/Interpreter/Property.h
+++ b/include/lldb/Interpreter/Property.h
@@ -1,9 +1,8 @@
//===-- Property.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,7 +37,7 @@ class Property {
public:
Property(const PropertyDefinition &definition);
- Property(const ConstString &name, const ConstString &desc, bool is_global,
+ Property(ConstString name, ConstString desc, bool is_global,
const lldb::OptionValueSP &value_sp);
llvm::StringRef GetName() const { return m_name.GetStringRef(); }
diff --git a/include/lldb/Interpreter/ScriptInterpreter.h b/include/lldb/Interpreter/ScriptInterpreter.h
index 640d9d34c617d..c8fa3901350d7 100644
--- a/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/include/lldb/Interpreter/ScriptInterpreter.h
@@ -1,9 +1,8 @@
//===-- ScriptInterpreter.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,7 @@ private:
class ScriptInterpreter : public PluginInterface {
public:
- typedef enum {
+ enum ScriptReturnType {
eScriptReturnTypeCharPtr,
eScriptReturnTypeBool,
eScriptReturnTypeShortInt,
@@ -51,10 +50,9 @@ public:
eScriptReturnTypeChar,
eScriptReturnTypeCharStrOrNone,
eScriptReturnTypeOpaqueObject
- } ScriptReturnType;
+ };
- ScriptInterpreter(CommandInterpreter &interpreter,
- lldb::ScriptLanguage script_lang);
+ ScriptInterpreter(Debugger &debugger, lldb::ScriptLanguage script_lang);
~ScriptInterpreter() override;
@@ -248,7 +246,7 @@ public:
lldb::BreakpointSP &bkpt_sp) {
return StructuredData::GenericSP();
}
-
+
virtual bool
ScriptedBreakpointResolverSearchCallback(StructuredData::GenericSP implementor_sp,
SymbolContext *sym_ctx)
@@ -461,8 +459,6 @@ public:
int GetMasterFileDescriptor();
- CommandInterpreter &GetCommandInterpreter();
-
static std::string LanguageToString(lldb::ScriptLanguage language);
static lldb::ScriptLanguage StringToLanguage(const llvm::StringRef &string);
@@ -472,7 +468,7 @@ public:
lldb::ScriptLanguage GetLanguage() { return m_script_lang; }
protected:
- CommandInterpreter &m_interpreter;
+ Debugger &m_debugger;
lldb::ScriptLanguage m_script_lang;
};
diff --git a/include/lldb/Symbol/ArmUnwindInfo.h b/include/lldb/Symbol/ArmUnwindInfo.h
index 422408b034c6e..a74b4442df144 100644
--- a/include/lldb/Symbol/ArmUnwindInfo.h
+++ b/include/lldb/Symbol/ArmUnwindInfo.h
@@ -1,21 +1,19 @@
//===-- ArmUnwindInfo.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_ArmUnwindInfo_h_
#define liblldb_ArmUnwindInfo_h_
-#include <vector>
-
-#include "lldb/Core/RangeMap.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"
+#include <vector>
/*
* Unwind information reader and parser for the ARM exception handling ABI
diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h
index 2428a1d3ffca0..36d0944f12b04 100644
--- a/include/lldb/Symbol/Block.h
+++ b/include/lldb/Symbol/Block.h
@@ -1,31 +1,28 @@
//===-- Block.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Block_h_
#define liblldb_Block_h_
-#include <vector>
-
#include "lldb/Core/AddressRange.h"
-#include "lldb/Core/RangeMap.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolContextScope.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-private.h"
+#include <vector>
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Block Block.h "lldb/Symbol/Block.h"
+/// \class Block Block.h "lldb/Symbol/Block.h"
/// A class that describes a single lexical block.
///
/// A Function object owns a BlockList object which owns one or more
@@ -41,20 +38,18 @@ namespace lldb_private {
/// Inlined functions are represented by attaching a InlineFunctionInfo shared
/// pointer object to a block. Inlined functions are represented as named
/// blocks.
-//----------------------------------------------------------------------
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
+ /// \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
@@ -62,50 +57,41 @@ public:
/// depth parsing. Common values would be the index into a
/// table, or an offset into the debug information.
///
- /// @param[in] depth
+ /// \param[in] depth
/// The integer depth of this block in the block list hierarchy.
///
- /// @param[in] block_list
+ /// \param[in] block_list
/// The block list that this object belongs to.
///
- /// @see BlockList
- //------------------------------------------------------------------
+ /// \see BlockList
Block(lldb::user_id_t uid);
- //------------------------------------------------------------------
/// Destructor.
- //------------------------------------------------------------------
~Block() override;
- //------------------------------------------------------------------
/// Add a child to this object.
///
- /// @param[in] child_block_sp
+ /// \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
+ /// \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
+ /// \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*)
+ /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void CalculateSymbolContext(SymbolContext *sc) override;
lldb::ModuleSP CalculateSymbolContextModule() override;
@@ -116,69 +102,59 @@ public:
Block *CalculateSymbolContextBlock() override;
- //------------------------------------------------------------------
/// Check if an offset is in one of the block offset ranges.
///
- /// @param[in] range_offset
+ /// \param[in] range_offset
/// An offset into the Function's address range.
///
- /// @return
+ /// \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
+ /// \param[in] range
/// An offset range into the Function's address range.
///
- /// @return
+ /// \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
+ /// \param[in] block
/// A potential child block.
///
- /// @return
+ /// \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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] base_addr
+ /// \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
+ /// \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
+ /// \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*)
+ /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void DumpSymbolContext(Stream *s) override;
void DumpAddressRanges(Stream *s, lldb::addr_t base_addr);
@@ -186,185 +162,177 @@ public:
void GetDescription(Stream *s, Function *function,
lldb::DescriptionLevel level, Target *target) const;
- //------------------------------------------------------------------
/// Get the parent block.
///
- /// @return
+ /// \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
+ /// \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
+ /// \return
/// The parent block pointer, or nullptr if this block has no
/// parent.
- //------------------------------------------------------------------
Block *GetInlinedParent();
//------------------------------------------------------------------
- /// Get the sibling block for this block.
+ /// Get the inlined block at the given call site that contains this block.
+ ///
+ /// @param[in] find_call_site
+ /// a declaration with the file and line of the call site to find.
///
/// @return
+ /// If this block contains inlined function info and is at the call
+ /// site given by the file and line at the given \b declaration, then
+ /// it will return this block, otherwise the parent blocks will be
+ /// searched to see if any is at the call site. nullptr will be returned
+ /// if no block is found at the call site.
+ //------------------------------------------------------------------
+ Block *
+ GetContainingInlinedBlockWithCallSite(const Declaration &find_call_site);
+
+ /// 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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in,out] variable_list
/// All variables in this block, and optionally all parent
/// blocks will be added to this list.
///
- /// @return
+ /// \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
+ /// \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();
}
- //------------------------------------------------------------------
/// Get the symbol file which contains debug info for this block's
/// symbol context module.
///
- /// @return A pointer to the symbol file or nullptr.
- //------------------------------------------------------------------
+ /// \return A pointer to the symbol file or nullptr.
SymbolFile *GetSymbolFile();
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
+ /// \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
+ /// \param[in] name
/// The method name for the inlined function. This value should
/// not be nullptr.
///
- /// @param[in] mangled
+ /// \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
+ /// \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
+ /// \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);
@@ -373,15 +341,13 @@ public:
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
+ /// \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;
}
@@ -403,10 +369,8 @@ public:
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);
@@ -415,9 +379,7 @@ public:
protected:
typedef std::vector<lldb::BlockSP> collection;
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
SymbolContextScope *m_parent_scope;
collection m_children;
RangeList m_ranges;
diff --git a/include/lldb/Symbol/ClangASTContext.h b/include/lldb/Symbol/ClangASTContext.h
index 4cff9b2565709..d0a834e01f3aa 100644
--- a/include/lldb/Symbol/ClangASTContext.h
+++ b/include/lldb/Symbol/ClangASTContext.h
@@ -1,9 +1,8 @@
//===-- ClangASTContext.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,25 +46,19 @@ public:
typedef void (*CompleteObjCInterfaceDeclCallback)(void *baton,
clang::ObjCInterfaceDecl *);
- //------------------------------------------------------------------
// llvm casting support
- //------------------------------------------------------------------
static bool classof(const TypeSystem *ts) {
return ts->getKind() == TypeSystem::eKindClang;
}
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
ClangASTContext(const char *triple = nullptr);
~ClangASTContext() override;
void Finalize() override;
- //------------------------------------------------------------------
// PluginInterface functions
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -111,6 +104,9 @@ public:
clang::TargetInfo *getTargetInfo();
+ void setSema(clang::Sema *s);
+ clang::Sema *getSema() { return m_sema; }
+
void Clear();
const char *GetTargetTriple();
@@ -122,7 +118,7 @@ public:
bool HasExternalSource();
void SetExternalSource(
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_ap);
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> &ast_source_up);
void RemoveExternalSource();
@@ -154,9 +150,7 @@ public:
static ClangASTMetadata *GetMetadata(clang::ASTContext *ast,
const void *object);
- //------------------------------------------------------------------
// Basic Types
- //------------------------------------------------------------------
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding,
size_t bit_size) override;
@@ -169,9 +163,9 @@ public:
lldb::BasicType type);
static CompilerType GetBasicType(clang::ASTContext *ast,
- const ConstString &name);
+ ConstString name);
- static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name);
+ static lldb::BasicType GetBasicTypeEnumeration(ConstString name);
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(const char *type_name,
uint32_t dw_ate,
@@ -212,7 +206,7 @@ public:
template <typename RecordDeclType>
CompilerType
- GetTypeForIdentifier(const ConstString &type_name,
+ GetTypeForIdentifier(ConstString type_name,
clang::DeclContext *decl_context = nullptr) {
CompilerType compiler_type;
@@ -244,13 +238,13 @@ public:
}
CompilerType CreateStructForIdentifier(
- const ConstString &type_name,
+ ConstString type_name,
const std::initializer_list<std::pair<const char *, CompilerType>>
&type_fields,
bool packed = false);
CompilerType GetOrCreateStructForIdentifier(
- const ConstString &type_name,
+ ConstString type_name,
const std::initializer_list<std::pair<const char *, CompilerType>>
&type_fields,
bool packed = false);
@@ -258,9 +252,7 @@ public:
static bool IsOperator(const char *name,
clang::OverloadedOperatorKind &op_kind);
- //------------------------------------------------------------------
// Structure, Unions, Classes
- //------------------------------------------------------------------
static clang::AccessSpecifier
ConvertAccessTypeToAccessSpecifier(lldb::AccessType access);
@@ -350,20 +342,18 @@ public:
// Returns a mask containing bits from the ClangASTContext::eTypeXXX
// enumerations
- //------------------------------------------------------------------
// Namespace Declarations
- //------------------------------------------------------------------
clang::NamespaceDecl *
- GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx);
+ GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx,
+ bool is_inline = false);
static clang::NamespaceDecl *
GetUniqueNamespaceDeclaration(clang::ASTContext *ast, const char *name,
- clang::DeclContext *decl_ctx);
+ clang::DeclContext *decl_ctx,
+ bool is_inline = false);
- //------------------------------------------------------------------
// Function Types
- //------------------------------------------------------------------
clang::FunctionDecl *
CreateFunctionDeclaration(clang::DeclContext *decl_ctx, const char *name,
@@ -412,25 +402,19 @@ public:
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,
bool is_scoped);
- //------------------------------------------------------------------
// Integer type functions
- //------------------------------------------------------------------
static CompilerType GetIntTypeFromBitSize(clang::ASTContext *ast,
size_t bit_size, bool is_signed);
@@ -442,22 +426,16 @@ public:
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();
+ PDBASTParser *GetPDBParser() override;
- //------------------------------------------------------------------
// ClangASTContext callbacks for external source lookups.
- //------------------------------------------------------------------
static void CompleteTagDecl(void *baton, clang::TagDecl *);
static void CompleteObjCInterfaceDecl(void *baton,
@@ -472,9 +450,7 @@ public:
llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
&vbase_offsets);
- //----------------------------------------------------------------------
// CompilerDecl override functions
- //----------------------------------------------------------------------
ConstString DeclGetName(void *opaque_decl) override;
ConstString DeclGetMangledName(void *opaque_decl) override;
@@ -488,9 +464,7 @@ public:
CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
size_t arg_idx) override;
- //----------------------------------------------------------------------
// CompilerDeclContext override functions
- //----------------------------------------------------------------------
std::vector<CompilerDecl>
DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
@@ -507,9 +481,10 @@ public:
bool *is_instance_method_ptr,
ConstString *language_object_name_ptr) override;
- //----------------------------------------------------------------------
+ bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
+ void *other_opaque_decl_ctx) override;
+
// Clang specific clang::DeclContext functions
- //----------------------------------------------------------------------
static clang::DeclContext *
DeclContextGetAsDeclContext(const CompilerDeclContext &dc);
@@ -532,9 +507,7 @@ public:
static clang::ASTContext *
DeclContextGetClangASTContext(const CompilerDeclContext &dc);
- //----------------------------------------------------------------------
// Tests
- //----------------------------------------------------------------------
bool IsArrayType(lldb::opaque_compiler_type_t type,
CompilerType *element_type, uint64_t *size,
@@ -625,6 +598,8 @@ public:
bool IsVoidType(lldb::opaque_compiler_type_t type) override;
+ bool CanPassInRegisters(const CompilerType &type) override;
+
bool SupportsLanguage(lldb::LanguageType language) override;
static bool GetCXXClassName(const CompilerType &type,
@@ -633,15 +608,11 @@ public:
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;
@@ -655,9 +626,7 @@ public:
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.
@@ -717,22 +686,21 @@ public:
// 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,
+ llvm::Optional<uint64_t> GetByteSize(lldb::opaque_compiler_type_t type,
ExecutionContextScope *exe_scope) {
- return (GetBitSize(type, exe_scope) + 7) / 8;
+ if (llvm::Optional<uint64_t> bit_size = GetBitSize(type, exe_scope))
+ return (*bit_size + 7) / 8;
+ return llvm::None;
}
- uint64_t GetBitSize(lldb::opaque_compiler_type_t type,
- ExecutionContextScope *exe_scope) override;
+ llvm::Optional<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;
@@ -745,19 +713,19 @@ public:
bool omit_empty_base_classes,
const ExecutionContext *exe_ctx) override;
- CompilerType GetBuiltinTypeByName(const ConstString &name) override;
+ CompilerType GetBuiltinTypeByName(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);
+ ConstString name);
void ForEachEnumerator(
lldb::opaque_compiler_type_t type,
std::function<bool(const CompilerType &integer_type,
- const ConstString &name,
+ ConstString name,
const llvm::APSInt &value)> const &callback) override;
uint32_t GetNumFields(lldb::opaque_compiler_type_t type) override;
@@ -828,9 +796,7 @@ public:
ConstString *child_name = nullptr,
CompilerType *child_type = nullptr);
- //----------------------------------------------------------------------
// Modifying RecordType
- //----------------------------------------------------------------------
static clang::FieldDecl *AddFieldToRecordType(const CompilerType &type,
llvm::StringRef name,
const CompilerType &field_type,
@@ -890,16 +856,12 @@ public:
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
- //----------------------------------------------------------------------
clang::EnumConstantDecl *AddEnumerationValueToEnumerationType(
const CompilerType &enum_type, const Declaration &decl, const char *name,
int64_t enum_value, uint32_t enum_value_bit_size);
@@ -909,9 +871,7 @@ public:
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.
@@ -924,9 +884,14 @@ public:
const char *s, uint8_t *dst,
size_t dst_size) override;
- //----------------------------------------------------------------------
// Dumping types
- //----------------------------------------------------------------------
+#ifndef NDEBUG
+ /// Convenience LLVM-style dump method for use in the debugger only.
+ /// In contrast to the other \p Dump() methods this directly invokes
+ /// \p clang::QualType::dump().
+ LLVM_DUMP_METHOD void dump(lldb::opaque_compiler_type_t type) const override;
+#endif
+
void Dump(Stream &s);
void DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx,
@@ -1011,39 +976,37 @@ protected:
const clang::ClassTemplateSpecializationDecl *
GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
- //------------------------------------------------------------------
// 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;
- std::unique_ptr<clang::FileManager> m_file_manager_ap;
- std::unique_ptr<clang::FileSystemOptions> m_file_system_options_ap;
- std::unique_ptr<clang::SourceManager> m_source_manager_ap;
- std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_ap;
- std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_ap;
+ std::unique_ptr<clang::ASTContext> m_ast_up;
+ std::unique_ptr<clang::LangOptions> m_language_options_up;
+ std::unique_ptr<clang::FileManager> m_file_manager_up;
+ std::unique_ptr<clang::SourceManager> m_source_manager_up;
+ std::unique_ptr<clang::DiagnosticsEngine> m_diagnostics_engine_up;
+ std::unique_ptr<clang::DiagnosticConsumer> m_diagnostic_consumer_up;
std::shared_ptr<clang::TargetOptions> m_target_options_rp;
- std::unique_ptr<clang::TargetInfo> m_target_info_ap;
- std::unique_ptr<clang::IdentifierTable> m_identifier_table_ap;
- std::unique_ptr<clang::SelectorTable> m_selector_table_ap;
- std::unique_ptr<clang::Builtin::Context> m_builtins_ap;
- std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_ap;
- std::unique_ptr<PDBASTParser> m_pdb_ast_parser_ap;
- std::unique_ptr<ClangASTSource> m_scratch_ast_source_ap;
- std::unique_ptr<clang::MangleContext> m_mangle_ctx_ap;
+ std::unique_ptr<clang::TargetInfo> m_target_info_up;
+ std::unique_ptr<clang::IdentifierTable> m_identifier_table_up;
+ std::unique_ptr<clang::SelectorTable> m_selector_table_up;
+ std::unique_ptr<clang::Builtin::Context> m_builtins_up;
+ std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
+ std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
+ std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
+ std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
CompleteTagDeclCallback m_callback_tag_decl;
CompleteObjCInterfaceDeclCallback m_callback_objc_decl;
void * m_callback_baton;
clang::ExternalASTMerger::OriginMap m_origins;
uint32_t m_pointer_byte_size;
bool m_ast_owned;
- bool m_can_evaluate_expressions;
+ /// The sema associated that is currently used to build this ASTContext.
+ /// May be null if we are already done parsing this ASTContext or the
+ /// ASTContext wasn't created by parsing source code.
+ clang::Sema * m_sema = nullptr;
// clang-format on
private:
- //------------------------------------------------------------------
// For ClangASTContext only
- //------------------------------------------------------------------
ClangASTContext(const ClangASTContext &);
const ClangASTContext &operator=(const ClangASTContext &);
};
@@ -1058,7 +1021,8 @@ public:
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options) override;
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj) override;
FunctionCaller *GetFunctionCaller(const CompilerType &return_type,
const Address &function_address,
diff --git a/include/lldb/Symbol/ClangASTImporter.h b/include/lldb/Symbol/ClangASTImporter.h
index 465d7e24a1e71..353b1232d9404 100644
--- a/include/lldb/Symbol/ClangASTImporter.h
+++ b/include/lldb/Symbol/ClangASTImporter.h
@@ -1,9 +1,8 @@
//===-- ClangASTImporter.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,9 @@
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/CompilerDeclContext.h"
+#include "lldb/Symbol/CxxModuleHandler.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/DenseMap.h"
@@ -94,7 +95,9 @@ public:
vbase_offsets;
};
- ClangASTImporter() : m_file_manager(clang::FileSystemOptions()) {}
+ ClangASTImporter()
+ : m_file_manager(clang::FileSystemOptions(),
+ FileSystem::Instance().GetVirtualFileSystem()) {}
clang::QualType CopyType(clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx, clang::QualType type);
@@ -185,7 +188,7 @@ public:
virtual ~MapCompleter();
virtual void CompleteNamespaceMap(NamespaceMapSP &namespace_map,
- const ConstString &name,
+ ConstString name,
NamespaceMapSP &parent_map) const = 0;
};
@@ -232,16 +235,61 @@ private:
typedef std::map<const clang::Decl *, DeclOrigin> OriginMap;
- class Minion : public clang::ASTImporter {
+ /// ASTImporter that intercepts and records the import process of the
+ /// underlying ASTImporter.
+ ///
+ /// This class updates the map from declarations to their original
+ /// declarations and can record and complete declarations that have been
+ /// imported in a certain interval.
+ ///
+ /// When intercepting a declaration import, the ASTImporterDelegate uses the
+ /// CxxModuleHandler to replace any missing or malformed declarations with
+ /// their counterpart from a C++ module.
+ class ASTImporterDelegate : public clang::ASTImporter {
public:
- Minion(ClangASTImporter &master, clang::ASTContext *target_ctx,
- clang::ASTContext *source_ctx)
+ ASTImporterDelegate(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.
+ /// Scope guard that attaches a CxxModuleHandler to an ASTImporterDelegate
+ /// and deattaches it at the end of the scope. Supports being used multiple
+ /// times on the same ASTImporterDelegate instance in nested scopes.
+ class CxxModuleScope {
+ /// The handler we attach to the ASTImporterDelegate.
+ CxxModuleHandler m_handler;
+ /// The ASTImporterDelegate we are supposed to attach the handler to.
+ ASTImporterDelegate &m_delegate;
+ /// True iff we attached the handler to the ASTImporterDelegate.
+ bool m_valid = false;
+
+ public:
+ CxxModuleScope(ASTImporterDelegate &delegate, clang::ASTContext *dst_ctx)
+ : m_delegate(delegate) {
+ // If the delegate doesn't have a CxxModuleHandler yet, create one
+ // and attach it.
+ if (!delegate.m_std_handler) {
+ m_handler = CxxModuleHandler(delegate, dst_ctx);
+ m_valid = true;
+ delegate.m_std_handler = &m_handler;
+ }
+ }
+ ~CxxModuleScope() {
+ if (m_valid) {
+ // Make sure no one messed with the handler we placed.
+ assert(m_delegate.m_std_handler == &m_handler);
+ m_delegate.m_std_handler = nullptr;
+ }
+ }
+ };
+
+ protected:
+ llvm::Expected<clang::Decl *> ImportImpl(clang::Decl *From) override;
+
+ public:
+ // A call to "InitDeportWorkQueues" puts the delegate into deport mode.
// In deport mode, every copied Decl that could require completion is
// recorded and placed into the decls_to_deport set.
//
@@ -249,8 +297,8 @@ private:
// 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
+ // These calls must be paired. Leaving a delegate in deport mode or trying
+ // to start deport delegate with a new pair of queues will result in an
// assertion failure.
void
@@ -260,28 +308,34 @@ private:
void ImportDefinitionTo(clang::Decl *to, clang::Decl *from);
- clang::Decl *Imported(clang::Decl *from, clang::Decl *to) override;
+ void Imported(clang::Decl *from, clang::Decl *to) override;
clang::Decl *GetOriginalDecl(clang::Decl *To) override;
+ /// Decls we should ignore when mapping decls back to their original
+ /// ASTContext. Used by the CxxModuleHandler to mark declarations that
+ /// were created from the 'std' C++ module to prevent that the Importer
+ /// tries to sync them with the broken equivalent in the debug info AST.
+ std::set<clang::Decl *> m_decls_to_ignore;
std::set<clang::NamedDecl *> *m_decls_to_deport;
std::set<clang::NamedDecl *> *m_decls_already_deported;
ClangASTImporter &m_master;
clang::ASTContext *m_source_ctx;
+ CxxModuleHandler *m_std_handler = nullptr;
};
- typedef std::shared_ptr<Minion> MinionSP;
- typedef std::map<clang::ASTContext *, MinionSP> MinionMap;
+ typedef std::shared_ptr<ASTImporterDelegate> ImporterDelegateSP;
+ typedef std::map<clang::ASTContext *, ImporterDelegateSP> DelegateMap;
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_dst_ctx(dst_ctx), m_delegates(), m_origins(), m_namespace_maps(),
m_map_completer(nullptr) {}
clang::ASTContext *m_dst_ctx;
- MinionMap m_minions;
+ DelegateMap m_delegates;
OriginMap m_origins;
NamespaceMetaMap m_namespace_maps;
@@ -316,18 +370,20 @@ private:
return ASTContextMetadataSP();
}
- MinionSP GetMinion(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) {
+ ImporterDelegateSP GetDelegate(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);
+ DelegateMap &delegates = context_md->m_delegates;
+ DelegateMap::iterator delegate_iter = delegates.find(src_ctx);
- if (minion_iter == minions.end()) {
- MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx));
- minions[src_ctx] = minion;
- return minion;
+ if (delegate_iter == delegates.end()) {
+ ImporterDelegateSP delegate =
+ ImporterDelegateSP(new ASTImporterDelegate(*this, dst_ctx, src_ctx));
+ delegates[src_ctx] = delegate;
+ return delegate;
} else {
- return minion_iter->second;
+ return delegate_iter->second;
}
}
diff --git a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
index c077665e51eeb..a2d4f8137a054 100644
--- a/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
+++ b/include/lldb/Symbol/ClangExternalASTSourceCallbacks.h
@@ -1,9 +1,8 @@
//===-- ClangExternalASTSourceCallbacks.h -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,9 +50,7 @@ public:
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
@@ -127,10 +124,8 @@ public:
}
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;
diff --git a/include/lldb/Symbol/ClangExternalASTSourceCommon.h b/include/lldb/Symbol/ClangExternalASTSourceCommon.h
index 894c91f157da3..8e69f6d3e4eb2 100644
--- a/include/lldb/Symbol/ClangExternalASTSourceCommon.h
+++ b/include/lldb/Symbol/ClangExternalASTSourceCommon.h
@@ -1,9 +1,8 @@
//===-- ClangExternalASTSourceCommon.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Symbol/ClangUtil.h b/include/lldb/Symbol/ClangUtil.h
index c8638f782548d..d6106032190cc 100644
--- a/include/lldb/Symbol/ClangUtil.h
+++ b/include/lldb/Symbol/ClangUtil.h
@@ -1,9 +1,8 @@
//===-- ClangUtil.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// A collection of helper methods and data structures for manipulating clang
// types and decls.
diff --git a/include/lldb/Symbol/CompactUnwindInfo.h b/include/lldb/Symbol/CompactUnwindInfo.h
index 711420f66a465..2646661ec2375 100644
--- a/include/lldb/Symbol/CompactUnwindInfo.h
+++ b/include/lldb/Symbol/CompactUnwindInfo.h
@@ -1,23 +1,21 @@
//===-- CompactUnwindInfo.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_CompactUnwindInfo_h_
#define liblldb_CompactUnwindInfo_h_
-#include <mutex>
-#include <vector>
-
-#include "lldb/Core/RangeMap.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"
+#include <mutex>
+#include <vector>
namespace lldb_private {
diff --git a/include/lldb/Symbol/CompileUnit.h b/include/lldb/Symbol/CompileUnit.h
index a4d19cd3d8ae9..c3ba2e2176e7a 100644
--- a/include/lldb/Symbol/CompileUnit.h
+++ b/include/lldb/Symbol/CompileUnit.h
@@ -1,9 +1,8 @@
//===-- CompileUnit.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include "lldb/Core/ModuleChild.h"
#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SourceModule.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-enumerations.h"
@@ -21,8 +21,7 @@
#include "llvm/ADT/DenseMap.h"
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
+/// \class CompileUnit CompileUnit.h "lldb/Symbol/CompileUnit.h"
/// A class that describes a compilation unit.
///
/// A representation of a compilation unit, or compiled source file.
@@ -33,126 +32,113 @@ namespace lldb_private {
/// Each compile unit has a list of functions, global and static 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 {
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
+ /// \param[in] module
/// The parent module that owns this compile unit. This value
/// must be a valid pointer value.
///
- /// @param[in] user_data
+ /// \param[in] user_data
/// User data where the SymbolFile parser can store data.
///
- /// @param[in] pathname
+ /// \param[in] pathname
/// The path to the source file for this compile unit.
///
- /// @param[in] uid
+ /// \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
+ /// \param[in] language
/// A language enumeration type that describes the main language
/// of this compile unit.
///
- /// @param[in] is_optimized
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] module
/// The parent module that owns this compile unit. This value
/// must be a valid pointer value.
///
- /// @param[in] user_data
+ /// \param[in] user_data
/// User data where the SymbolFile parser can store data.
///
- /// @param[in] file_spec
+ /// \param[in] file_spec
/// The file specification for the source file of this compile
/// unit.
///
- /// @param[in] uid
+ /// \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
+ /// \param[in] language
/// A language enumeration type that describes the main language
/// of this compile unit.
///
- /// @param[in] is_optimized
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] function_sp
/// A shared pointer to the Function object.
- //------------------------------------------------------------------
void AddFunction(lldb::FunctionSP &function_sp);
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void CalculateSymbolContext(SymbolContext *sc) override;
lldb::ModuleSP CalculateSymbolContextModule() override;
CompileUnit *CalculateSymbolContextCompileUnit() override;
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void DumpSymbolContext(Stream *s) override;
lldb::LanguageType GetLanguage();
@@ -164,34 +150,29 @@ public:
void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
- //------------------------------------------------------------------
/// Apply a lambda to each function in this compile unit.
///
/// This provides raw access to the function shared pointer list and will not
/// cause the SymbolFile plug-in to parse any unparsed functions.
///
- /// @note Prefer using FindFunctionByUID over this if possible.
+ /// \note Prefer using FindFunctionByUID over this if possible.
///
- /// @param[in] lambda
+ /// \param[in] lambda
/// The lambda that should be applied to every function. The lambda can
/// return true if the iteration should be aborted earlier.
- //------------------------------------------------------------------
void ForeachFunction(
llvm::function_ref<bool(const lldb::FunctionSP &)> lambda) const;
- //------------------------------------------------------------------
/// Dump the compile unit contents to the stream \a s.
///
- /// @param[in] s
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] show_context
+ /// \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
@@ -204,175 +185,157 @@ public:
/// 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
+ /// \param[in] start_idx
/// The zero based index at which to start looking for matches.
///
- /// @param[in] line
+ /// \param[in] line
/// The line number to search for.
///
- /// @param[in] file_spec_ptr
+ /// \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
+ /// \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
+ /// \param[out] line_entry
/// If non-NULL, a copy of the line entry that was found.
///
- /// @return
+ /// \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
+ /// \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
+ /// \return
/// A support file list object.
- //------------------------------------------------------------------
- FileSpecList &GetSupportFiles();
+ const 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();
+ /// \return
+ /// A list of imported modules.
+ const std::vector<SourceModule> &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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] line
/// The line number to match against the compile unit's line
/// tables.
///
- /// @param[in] check_inlines
+ /// \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
+ /// \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
+ /// \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
@@ -380,21 +343,19 @@ public:
/// resolved. Only SymbolContext entries that can be resolved
/// using a LineEntry base address will be able to be resolved.
///
- /// @param[out] sc_list
+ /// \param[out] sc_list
/// A SymbolContext list class that will get any matching
/// entries appended to.
///
- /// @return
+ /// \return
/// The number of new matches that were added to \a sc_list.
///
- /// @see enum SymbolContext::Scope
- //------------------------------------------------------------------
+ /// \see enum SymbolContext::Scope
uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
bool check_inlines, bool exact,
lldb::SymbolContextItem 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
@@ -402,41 +363,39 @@ public:
/// would expect them, stepping through the source lines in the function may
/// appear strange, etc.
///
- /// @return
+ /// \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();
- //------------------------------------------------------------------
/// Returns the number of functions in this compile unit
- //------------------------------------------------------------------
size_t GetNumFunctions() const { return m_functions_by_uid.size(); }
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.
-
+ /// User data for the SymbolFile parser to store information into.
+ void *m_user_data;
+ /// The programming language enumeration value.
+ lldb::LanguageType m_language;
+ /// Compile unit flags that help with partial parsing.
+ Flags m_flags;
/// Maps UIDs to functions.
llvm::DenseMap<lldb::user_id_t, lldb::FunctionSP> m_functions_by_uid;
- 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.
+ /// All modules, including the current module, imported by this
+ /// compile unit.
+ std::vector<SourceModule> m_imported_modules;
+ /// Files associated with this compile unit's line table and
+ /// declarations.
+ FileSpecList m_support_files;
+ /// Line table that will get parsed on demand.
+ std::unique_ptr<LineTable> m_line_table_up;
+ /// Debug macros that will get parsed on demand.
+ DebugMacrosSP m_debug_macros_sp;
+ /// Global and static variable list that will get parsed on demand.
+ lldb::VariableListSP m_variables;
+ /// eLazyBoolYes if this compile unit was compiled with
+ /// optimization.
+ lldb_private::LazyBool m_is_optimized;
private:
enum {
diff --git a/include/lldb/Symbol/CompilerDecl.h b/include/lldb/Symbol/CompilerDecl.h
index 5d744d999bea9..4817ec4b22670 100644
--- a/include/lldb/Symbol/CompilerDecl.h
+++ b/include/lldb/Symbol/CompilerDecl.h
@@ -1,9 +1,8 @@
//===-- CompilerDecl.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@ namespace lldb_private {
class CompilerDecl {
public:
- //----------------------------------------------------------------------
// Constructors and Destructors
- //----------------------------------------------------------------------
CompilerDecl() : m_type_system(nullptr), m_opaque_decl(nullptr) {}
CompilerDecl(TypeSystem *type_system, void *decl)
@@ -28,9 +25,7 @@ public:
~CompilerDecl() {}
- //----------------------------------------------------------------------
// Tests
- //----------------------------------------------------------------------
explicit operator bool() const { return IsValid(); }
@@ -46,9 +41,7 @@ public:
bool IsClang() const;
- //----------------------------------------------------------------------
// Accessors
- //----------------------------------------------------------------------
TypeSystem *GetTypeSystem() const { return m_type_system; }
diff --git a/include/lldb/Symbol/CompilerDeclContext.h b/include/lldb/Symbol/CompilerDeclContext.h
index 179a1be0248b9..e7958c08d8334 100644
--- a/include/lldb/Symbol/CompilerDeclContext.h
+++ b/include/lldb/Symbol/CompilerDeclContext.h
@@ -1,9 +1,8 @@
//===-- CompilerDeclContext.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@ namespace lldb_private {
class CompilerDeclContext {
public:
- //----------------------------------------------------------------------
// Constructors and Destructors
- //----------------------------------------------------------------------
CompilerDeclContext() : m_type_system(nullptr), m_opaque_decl_ctx(nullptr) {}
CompilerDeclContext(TypeSystem *type_system, void *decl_ctx)
@@ -29,9 +26,7 @@ public:
~CompilerDeclContext() {}
- //----------------------------------------------------------------------
// Tests
- //----------------------------------------------------------------------
explicit operator bool() const { return IsValid(); }
@@ -50,35 +45,44 @@ public:
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
+ /// \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
+ /// \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
+ /// \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
+ /// \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);
- //----------------------------------------------------------------------
+ /// Check if the given other decl context is contained in the lookup
+ /// of this decl context (for example because the other context is a nested
+ /// inline namespace).
+ ///
+ /// @param[in] other
+ /// The other decl context for which we should check if it is contained
+ /// in the lookoup of this context.
+ ///
+ /// @return
+ /// Returns true iff the other decl context is contained in the lookup
+ /// of this decl context.
+ bool IsContainedInLookup(CompilerDeclContext other) const;
+
// Accessors
- //----------------------------------------------------------------------
TypeSystem *GetTypeSystem() const { return m_type_system; }
diff --git a/include/lldb/Symbol/CompilerType.h b/include/lldb/Symbol/CompilerType.h
index 353313d8e2a38..98d916597f42c 100644
--- a/include/lldb/Symbol/CompilerType.h
+++ b/include/lldb/Symbol/CompilerType.h
@@ -1,9 +1,8 @@
//===-- CompilerType.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,6 @@ namespace lldb_private {
class DataExtractor;
-//----------------------------------------------------------------------
// 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 various type related
@@ -30,12 +28,9 @@ class DataExtractor;
// 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 {
public:
- //----------------------------------------------------------------------
// Constructors and Destructors
- //----------------------------------------------------------------------
CompilerType(TypeSystem *type_system, lldb::opaque_compiler_type_t type);
CompilerType(clang::ASTContext *ast_context, clang::QualType qual_type);
@@ -46,9 +41,7 @@ public:
~CompilerType();
- //----------------------------------------------------------------------
// Operators
- //----------------------------------------------------------------------
const CompilerType &operator=(const CompilerType &rhs) {
m_type = rhs.m_type;
@@ -56,9 +49,7 @@ public:
return *this;
}
- //----------------------------------------------------------------------
// Tests
- //----------------------------------------------------------------------
explicit operator bool() const {
return m_type != nullptr && m_type_system != nullptr;
@@ -146,21 +137,15 @@ public:
bool IsVoidType() const;
- //----------------------------------------------------------------------
// Type Completion
- //----------------------------------------------------------------------
bool GetCompleteType() const;
- //----------------------------------------------------------------------
// AST related queries
- //----------------------------------------------------------------------
size_t GetPointerByteSize() const;
- //----------------------------------------------------------------------
// Accessors
- //----------------------------------------------------------------------
TypeSystem *GetTypeSystem() const { return m_type_system; }
@@ -188,9 +173,7 @@ public:
unsigned GetTypeQualifiers() const;
- //----------------------------------------------------------------------
// Creating related types
- //----------------------------------------------------------------------
CompilerType GetArrayElementType(uint64_t *stride = nullptr) const;
@@ -212,78 +195,56 @@ public:
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
- //----------------------------------------------------------------------
struct IntegralTemplateArgument;
@@ -303,16 +264,14 @@ public:
lldb::BasicType GetBasicTypeEnumeration() const;
- static lldb::BasicType GetBasicTypeEnumeration(const ConstString &name);
+ static lldb::BasicType GetBasicTypeEnumeration(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,
+ ConstString name,
const llvm::APSInt &value)> const &callback) const;
uint32_t GetNumFields() const;
@@ -377,18 +336,21 @@ public:
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
- //----------------------------------------------------------------------
+
+#ifndef NDEBUG
+ /// Convenience LLVM-style dump method for use in the debugger only.
+ /// Don't call this function from actual code.
+ LLVM_DUMP_METHOD void dump() const;
+#endif
+
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,
diff --git a/include/lldb/Symbol/CxxModuleHandler.h b/include/lldb/Symbol/CxxModuleHandler.h
new file mode 100644
index 0000000000000..f4aef3666ece7
--- /dev/null
+++ b/include/lldb/Symbol/CxxModuleHandler.h
@@ -0,0 +1,65 @@
+//===-- CxxModuleHandler.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_CxxModuleHandler_h_
+#define liblldb_CxxModuleHandler_h_
+
+#include "clang/AST/ASTImporter.h"
+#include "clang/Sema/Sema.h"
+#include "llvm/ADT/StringSet.h"
+
+namespace lldb_private {
+
+/// Handles importing decls into an ASTContext with an attached C++ module.
+///
+/// This class searches a C++ module (which must be attached to the target
+/// ASTContext) for an equivalent decl to the one that should be imported.
+/// If the decl that is found in the module is a suitable replacement
+/// for the decl that should be imported, the module decl will be treated as
+/// the result of the import process.
+///
+/// If the Decl that should be imported is a template specialization
+/// that doesn't exist yet in the target ASTContext (e.g. `std::vector<int>`),
+/// then this class tries to create the template specialization in the target
+/// ASTContext. This is only possible if the CxxModuleHandler can determine
+/// that instantiating this template is safe to do, e.g. because the target
+/// decl is a container class from the STL.
+class CxxModuleHandler {
+ /// The ASTImporter that should be used to import any Decls which aren't
+ /// directly handled by this class itself.
+ clang::ASTImporter *m_importer = nullptr;
+
+ /// The Sema instance of the target ASTContext.
+ clang::Sema *m_sema = nullptr;
+
+ /// List of template names this class currently supports. These are the
+ /// template names inside the 'std' namespace such as 'vector' or 'list'.
+ llvm::StringSet<> m_supported_templates;
+
+ /// Tries to manually instantiate the given foreign template in the target
+ /// context (designated by m_sema).
+ llvm::Optional<clang::Decl *> tryInstantiateStdTemplate(clang::Decl *d);
+
+public:
+ CxxModuleHandler() = default;
+ CxxModuleHandler(clang::ASTImporter &importer, clang::ASTContext *target);
+
+ /// Attempts to import the given decl into the target ASTContext by
+ /// deserializing it from the 'std' module. This function returns a Decl if a
+ /// Decl has been deserialized from the 'std' module. Otherwise this function
+ /// returns nothing.
+ llvm::Optional<clang::Decl *> Import(clang::Decl *d);
+
+ /// Returns true iff this instance is capable of importing any declarations
+ /// in the target ASTContext.
+ bool isValid() const { return m_sema != nullptr; }
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_CxxModuleHandler_h_
diff --git a/include/lldb/Symbol/DWARFCallFrameInfo.h b/include/lldb/Symbol/DWARFCallFrameInfo.h
index 133c66d4ae4f0..104075f28df39 100644
--- a/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -1,9 +1,8 @@
//===-- DWARFCallFrameInfo.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,12 +13,11 @@
#include <mutex>
#include "lldb/Core/AddressRange.h"
-#include "lldb/Utility/Flags.h"
-
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/VMRange.h"
#include "lldb/lldb-private.h"
@@ -45,13 +43,18 @@ public:
// 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);
+ /// Return an UnwindPlan based on the call frame information encoded in the
+ /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
+ /// (at least) for the given address.
+ bool GetUnwindPlan(const Address &addr, UnwindPlan &unwind_plan);
+
+ /// Return an UnwindPlan based on the call frame information encoded in the
+ /// FDE of this DWARFCallFrameInfo section. The returned plan will be valid
+ /// (at least) for some address in the given range.
+ bool GetUnwindPlan(const AddressRange &range, 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.
//
@@ -61,7 +64,7 @@ public:
// functions in the Module. But the eh_frame can help to give the addresses
// of these stripped symbols, at least.
//
- // @param[out] function_info
+ // \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.
@@ -118,8 +121,8 @@ private:
bool IsEHFrame() const;
- bool GetFDEEntryByFileAddress(lldb::addr_t file_offset,
- FDEEntryMap::Entry &fde_entry);
+ llvm::Optional<FDEEntryMap::Entry>
+ GetFirstFDEEntryInRange(const AddressRange &range);
void GetFDEIndex();
diff --git a/include/lldb/Symbol/DebugMacros.h b/include/lldb/Symbol/DebugMacros.h
index 86700994fbcce..d364299ef4902 100644
--- a/include/lldb/Symbol/DebugMacros.h
+++ b/include/lldb/Symbol/DebugMacros.h
@@ -1,9 +1,8 @@
//===-- DebugMacros.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Symbol/DeclVendor.h b/include/lldb/Symbol/DeclVendor.h
index d1ccb4191cbc6..9c10fe1177fba 100644
--- a/include/lldb/Symbol/DeclVendor.h
+++ b/include/lldb/Symbol/DeclVendor.h
@@ -1,9 +1,8 @@
//===-- DeclVendor.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,54 +18,57 @@
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 {
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
+ /// \param[in] name
/// The name to look for.
///
- /// @param[in] append
+ /// \param[in] append
/// If true, FindDecls will clear "decls" when it starts.
///
- /// @param[in] max_matches
+ /// \param[in] max_matches
/// The maximum number of Decls to return. UINT32_MAX means "as
/// many as possible."
///
- /// @return
+ /// \return
/// The number of Decls added to decls; will not exceed
/// max_matches.
- //------------------------------------------------------------------
- virtual uint32_t FindDecls(const ConstString &name, bool append,
+ virtual uint32_t FindDecls(ConstString name, bool append,
uint32_t max_matches,
std::vector<clang::NamedDecl *> &decls) = 0;
- //------------------------------------------------------------------
+ /// Look up the types that the DeclVendor currently knows about matching a
+ /// given name.
+ ///
+ /// \param[in] name
+ /// The name to look for.
+ ///
+ /// \param[in] max_matches
+ // The maximum number of matches. UINT32_MAX means "as many as possible".
+ ///
+ /// \return
+ /// The vector of CompilerTypes that was found.
+ std::vector<CompilerType> FindTypes(ConstString name, uint32_t max_matches);
+
/// Interface for ExternalASTMerger. Returns an ImporterSource
/// allowing type completion.
///
- /// @return
+ /// \return
/// An ImporterSource for this DeclVendor.
- //------------------------------------------------------------------
virtual clang::ExternalASTMerger::ImporterSource GetImporterSource() = 0;
private:
- //------------------------------------------------------------------
// For DeclVendor only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(DeclVendor);
};
diff --git a/include/lldb/Symbol/Declaration.h b/include/lldb/Symbol/Declaration.h
index b654988bccd28..63798f883e5f5 100644
--- a/include/lldb/Symbol/Declaration.h
+++ b/include/lldb/Symbol/Declaration.h
@@ -1,9 +1,8 @@
//===-- Declaration.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,20 +14,16 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Declaration Declaration.h "lldb/Symbol/Declaration.h"
+/// \class Declaration Declaration.h "lldb/Symbol/Declaration.h"
/// A class that describes the declaration location of a
/// lldb object.
///
/// The declarations include the file specification, line number, and the
/// column info and can help track where functions, blocks, inlined functions,
/// types, variables, any many other debug core objects were declared.
-//----------------------------------------------------------------------
class Declaration {
public:
- //------------------------------------------------------------------
/// Default constructor.
- //------------------------------------------------------------------
Declaration()
: m_file(), m_line(0)
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
@@ -38,21 +33,19 @@ public:
{
}
- //------------------------------------------------------------------
/// Construct with file specification, and optional line and column.
///
- /// @param[in] file_spec
+ /// \param[in] file_spec
/// The file specification that describes where this was
/// declared.
///
- /// @param[in] line
+ /// \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
+ /// \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
@@ -62,9 +55,7 @@ public:
{
}
- //------------------------------------------------------------------
/// 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
@@ -74,9 +65,7 @@ public:
{
}
- //------------------------------------------------------------------
/// Construct with a pointer to another Declaration object.
- //------------------------------------------------------------------
Declaration(const Declaration *decl_ptr)
: m_file(), m_line(0)
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
@@ -88,12 +77,10 @@ public:
*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;
@@ -102,45 +89,50 @@ public:
#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
+ /// \param[in] lhs
/// The Left Hand Side const Declaration object reference.
///
- /// @param[in] rhs
+ /// \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
- //------------------------------------------------------------------
+ /// \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);
- //------------------------------------------------------------------
+ /// Checks if this object has the same file and line as another declaration
+ /// object.
+ ///
+ /// \param[in] declaration
+ /// The const Declaration object to compare with.
+ ///
+ /// \return
+ /// Returns \b true if \b declaration is at the same file and
+ /// line, \b false otherwise.
+ bool FileAndLineEqual(const Declaration &declaration) 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.
///
- /// @param[in] 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
+ /// \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;
@@ -149,79 +141,63 @@ public:
#endif
}
- //------------------------------------------------------------------
/// Get accessor for file specification.
///
- /// @return
+ /// \return
/// A reference to the file specification object.
- //------------------------------------------------------------------
FileSpec &GetFile() { return m_file; }
- //------------------------------------------------------------------
/// Get const accessor for file specification.
///
- /// @return
+ /// \return
/// A const reference to the file specification object.
- //------------------------------------------------------------------
const FileSpec &GetFile() const { return m_file; }
- //------------------------------------------------------------------
/// Get accessor for the declaration line number.
///
- /// @return
+ /// \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
+ /// \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 ()
- //------------------------------------------------------------------
+ /// \see ConstString::StaticMemorySize ()
size_t MemorySize() const;
- //------------------------------------------------------------------
/// Set accessor for the declaration column number.
///
- /// @param[in] column
+ /// \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;
#endif
}
- //------------------------------------------------------------------
/// Set accessor for the declaration file specification.
///
- /// @param[in] file_spec
+ /// \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
+ /// \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,
diff --git a/include/lldb/Symbol/FuncUnwinders.h b/include/lldb/Symbol/FuncUnwinders.h
index ae8bcc892ce43..cc767d4e1e82f 100644
--- a/include/lldb/Symbol/FuncUnwinders.h
+++ b/include/lldb/Symbol/FuncUnwinders.h
@@ -35,17 +35,10 @@ public:
~FuncUnwinders();
- // 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 GetUnwindPlanAtCallSite(Target &target, Thread &thread);
lldb::UnwindPlanSP GetUnwindPlanAtNonCallSite(Target &target,
- lldb_private::Thread &thread,
- int current_offset);
+ lldb_private::Thread &thread);
lldb::UnwindPlanSP GetUnwindPlanFastUnwind(Target &target,
lldb_private::Thread &thread);
@@ -81,26 +74,23 @@ public:
// 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);
- lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target, int current_offset);
+ lldb::UnwindPlanSP GetEHFrameUnwindPlan(Target &target);
lldb::UnwindPlanSP GetEHFrameAugmentedUnwindPlan(Target &target,
- Thread &thread,
- int current_offset);
+ Thread &thread);
- lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target,
- int current_offset);
+ lldb::UnwindPlanSP GetDebugFrameUnwindPlan(Target &target);
lldb::UnwindPlanSP GetDebugFrameAugmentedUnwindPlan(Target &target,
- Thread &thread,
- int current_offset);
+ Thread &thread);
- lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target,
- int current_offset);
+ lldb::UnwindPlanSP GetCompactUnwindUnwindPlan(Target &target);
- lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target, int current_offset);
+ lldb::UnwindPlanSP GetArmUnwindUnwindPlan(Target &target);
+
+ lldb::UnwindPlanSP GetSymbolFileUnwindPlan(Thread &thread);
lldb::UnwindPlanSP GetArchDefaultUnwindPlan(Thread &thread);
@@ -132,6 +122,7 @@ private:
std::vector<lldb::UnwindPlanSP> m_unwind_plan_compact_unwind;
lldb::UnwindPlanSP m_unwind_plan_arm_unwind_sp;
+ lldb::UnwindPlanSP m_unwind_plan_symbol_file_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;
@@ -143,8 +134,8 @@ private:
m_tried_unwind_plan_eh_frame_augmented : 1,
m_tried_unwind_plan_debug_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_plan_arm_unwind : 1, m_tried_unwind_plan_symbol_file : 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;
diff --git a/include/lldb/Symbol/Function.h b/include/lldb/Symbol/Function.h
index 447abd2e6f78c..f68a16705d935 100644
--- a/include/lldb/Symbol/Function.h
+++ b/include/lldb/Symbol/Function.h
@@ -1,9 +1,8 @@
//===-- Function.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,216 +19,182 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class FunctionInfo Function.h "lldb/Symbol/Function.h"
+/// \class FunctionInfo Function.h "lldb/Symbol/Function.h"
/// A class that contains generic function information.
///
/// This provides generic function information that gets reused between inline
/// functions and function types.
-//----------------------------------------------------------------------
class FunctionInfo {
public:
- //------------------------------------------------------------------
/// Construct with the function method name and optional declaration
/// information.
///
- /// @param[in] name
+ /// \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
+ /// \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
+ /// \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
+ /// \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);
+ FunctionInfo(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
+ /// \param[in] lhs
/// The Left Hand Side const FunctionInfo object reference.
///
- /// @param[in] rhs
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \return
/// A reference to the declaration object.
- //------------------------------------------------------------------
Declaration &GetDeclaration();
- //------------------------------------------------------------------
/// Get const accessor for the declaration information.
///
- /// @return
+ /// \return
/// A const reference to the declaration object.
- //------------------------------------------------------------------
const Declaration &GetDeclaration() const;
- //------------------------------------------------------------------
/// Get accessor for the method name.
///
- /// @return
+ /// \return
/// A const reference to the method name object.
- //------------------------------------------------------------------
ConstString GetName() const;
- //------------------------------------------------------------------
/// Get the memory cost of this object.
///
- /// @return
+ /// \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 ()
- //------------------------------------------------------------------
+ /// \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.
};
-//----------------------------------------------------------------------
-/// @class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
+/// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
/// A class that describes information for an inlined function.
-//----------------------------------------------------------------------
class InlineFunctionInfo : public FunctionInfo {
public:
- //------------------------------------------------------------------
/// Construct with the function method name, mangled name, and optional
/// declaration information.
///
- /// @param[in] name
+ /// \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
+ /// \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
+ /// \param[in] decl_ptr
/// Optional declaration information that describes where the
/// function was declared. This can be NULL.
///
- /// @param[in] call_decl_ptr
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] decl_ptr
/// Optional declaration information that describes where the
/// function was declared. This can be NULL.
///
- /// @param[in] call_decl_ptr
+ /// \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,
+ InlineFunctionInfo(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
+ /// \param[in] lhs
/// The Left Hand Side const InlineFunctionInfo object
/// reference.
///
- /// @param[in] rhs
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \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;
@@ -238,54 +203,42 @@ public:
ConstString GetDisplayName(lldb::LanguageType language) const;
- //------------------------------------------------------------------
/// Get accessor for the call site declaration information.
///
- /// @return
+ /// \return
/// A reference to the declaration object.
- //------------------------------------------------------------------
Declaration &GetCallSite();
- //------------------------------------------------------------------
/// Get const accessor for the call site declaration information.
///
- /// @return
+ /// \return
/// A const reference to the declaration object.
- //------------------------------------------------------------------
const Declaration &GetCallSite() const;
- //------------------------------------------------------------------
/// Get accessor for the mangled name object.
///
- /// @return
+ /// \return
/// A reference to the mangled name object.
- //------------------------------------------------------------------
Mangled &GetMangled();
- //------------------------------------------------------------------
/// Get const accessor for the mangled name object.
///
- /// @return
+ /// \return
/// A const reference to the mangled name object.
- //------------------------------------------------------------------
const Mangled &GetMangled() const;
- //------------------------------------------------------------------
/// Get the memory cost of this object.
///
- /// @return
+ /// \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 ()
- //------------------------------------------------------------------
+ /// \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;
@@ -293,12 +246,10 @@ private:
class Function;
-//----------------------------------------------------------------------
-/// @class CallEdge Function.h "lldb/Symbol/Function.h"
+/// \class CallEdge Function.h "lldb/Symbol/Function.h"
///
/// Represent a call made within a Function. This can be used to find a path
/// in the call graph between two functions.
-//----------------------------------------------------------------------
class CallEdge {
public:
/// Construct a call edge using a symbol name to identify the calling
@@ -349,8 +300,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(CallEdge);
};
-//----------------------------------------------------------------------
-/// @class Function Function.h "lldb/Symbol/Function.h"
+/// \class Function Function.h "lldb/Symbol/Function.h"
/// A class that describes a function.
///
/// Functions belong to CompileUnit objects (Function::m_comp_unit), have
@@ -362,61 +312,54 @@ private:
/// (Function::m_type), and contains lexical blocks (Function::m_blocks).
///
/// The function information is split into a few pieces:
-/// @li The concrete instance information
-/// @li The abstract information
+/// \li The concrete instance information
+/// \li The abstract information
///
/// The abstract information is found in the function type (Type) that
/// describes a function information, return type and parameter types.
///
/// The concrete information is the address range information and specific
/// locations for an instance of this function.
-//----------------------------------------------------------------------
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
+ /// \param[in] comp_unit
/// The compile unit to which this function belongs.
///
- /// @param[in] func_uid
+ /// \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
+ /// \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
+ /// \param[in] mangled
/// The optional mangled name for this function. If empty, there
/// is no mangled information.
///
- /// @param[in] func_type
+ /// \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
+ /// \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);
- //------------------------------------------------------------------
/// Destructor.
- //------------------------------------------------------------------
~Function() override;
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void CalculateSymbolContext(SymbolContext *sc) override;
lldb::ModuleSP CalculateSymbolContextModule() override;
@@ -428,89 +371,71 @@ public:
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
+ /// \param[out] source_file
/// The source file.
///
- /// @param[out] line_no
+ /// \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
+ /// \param[out] source_file
/// The source file.
///
- /// @param[out] line_no
+ /// \param[out] line_no
/// The line number.
- //------------------------------------------------------------------
void GetEndLineSourceInfo(FileSpec &source_file, uint32_t &line_no);
- //------------------------------------------------------------------
/// Get the outgoing call edges from this function, sorted by their return
/// PC addresses (in increasing order).
- //------------------------------------------------------------------
llvm::MutableArrayRef<CallEdge> GetCallEdges();
- //------------------------------------------------------------------
/// Get the outgoing tail-calling edges from this function. If none exist,
/// return None.
- //------------------------------------------------------------------
llvm::MutableArrayRef<CallEdge> GetTailCallingEdges();
- //------------------------------------------------------------------
/// Get accessor for the block list.
///
- /// @return
+ /// \return
/// The block list object that describes all lexical blocks
/// in the function.
///
- /// @see BlockList
- //------------------------------------------------------------------
+ /// \see BlockList
Block &GetBlock(bool can_create);
- //------------------------------------------------------------------
/// Get accessor for the compile unit that owns this function.
///
- /// @return
+ /// \return
/// A compile unit object pointer.
- //------------------------------------------------------------------
CompileUnit *GetCompileUnit();
- //------------------------------------------------------------------
/// Get const accessor for the compile unit that owns this function.
///
- /// @return
+ /// \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
+ /// \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
+ /// \return
/// A const compile unit object pointer.
- //------------------------------------------------------------------
const DWARFExpression &GetFrameBaseExpression() const { return m_frame_base; }
ConstString GetName() const;
@@ -521,79 +446,64 @@ public:
const Mangled &GetMangled() const { return m_mangled; }
- //------------------------------------------------------------------
/// Get the DeclContext for this function, if available.
///
- /// @return
+ /// \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
+ /// \return
/// A type object pointer.
- //------------------------------------------------------------------
Type *GetType();
- //------------------------------------------------------------------
/// Get const accessor for the type that describes the function return value
/// type, and parameter types.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] show_context
+ /// \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*)
+ /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void DumpSymbolContext(Stream *s) override;
- //------------------------------------------------------------------
/// Get the memory cost of this object.
///
- /// @return
+ /// \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 ()
- //------------------------------------------------------------------
+ /// \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
@@ -603,14 +513,12 @@ public:
/// would expect them, stepping through the source lines in the function may
/// appear strange, etc.
///
- /// @return
+ /// \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
@@ -621,10 +529,9 @@ public:
/// If stopped in a top-level function, LLDB will expose global variables
/// as-if locals in the 'frame variable' command
///
- /// @return
+ /// \return
/// Returns 'true' if this function is a top-level function,
/// 'false' otherwise.
- //------------------------------------------------------------------
bool IsTopLevelFunction();
lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx,
@@ -640,9 +547,7 @@ protected:
(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.
diff --git a/include/lldb/Symbol/LineEntry.h b/include/lldb/Symbol/LineEntry.h
index c1ce614609c11..fe97a78e3ed4a 100644
--- a/include/lldb/Symbol/LineEntry.h
+++ b/include/lldb/Symbol/LineEntry.h
@@ -1,9 +1,8 @@
//===-- LineEntry.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,16 +15,12 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
+/// \class LineEntry LineEntry.h "lldb/Symbol/LineEntry.h"
/// 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,
@@ -34,95 +29,84 @@ struct LineEntry {
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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] comp_unit
+ /// \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
+ /// \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
+ /// \param[in] style
/// The display style for the section offset address.
///
- /// @return
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] comp_unit
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] lhs
/// The Left Hand Side const LineEntry object reference.
///
- /// @param[in] rhs
+ /// \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
- //------------------------------------------------------------------
+ /// \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.
///
@@ -139,27 +123,30 @@ struct LineEntry {
/// LineEntry (and it will include the range of the following LineEntries
/// that match either 32 or 0.)
///
+ /// When \b include_inlined_functions is \b true inlined functions with
+ /// a call site at this LineEntry will also be included in the complete
+ /// range.
+ ///
/// 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
+ /// @param[in] include_inlined_functions
+ /// Whether to include inlined functions at the same line or not.
+ ///
+ /// \return
/// The contiguous AddressRange for this source line.
- //------------------------------------------------------------------
- AddressRange GetSameLineContiguousAddressRange() const;
+ AddressRange
+ GetSameLineContiguousAddressRange(bool include_inlined_functions) const;
- //------------------------------------------------------------------
/// Apply file mappings from target.source-map to the LineEntry's file.
///
- /// @param[in] target_sp
+ /// \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
@@ -183,18 +170,16 @@ struct LineEntry {
///instructions.
};
-//------------------------------------------------------------------
/// Less than operator.
///
-/// @param[in] lhs
+/// \param[in] lhs
/// The Left Hand Side const LineEntry object reference.
///
-/// @param[in] rhs
+/// \param[in] rhs
/// The Right Hand Side const LineEntry object reference.
///
-/// @return
+/// \return
/// Returns \b true if lhs < rhs, false otherwise.
-//------------------------------------------------------------------
bool operator<(const LineEntry &lhs, const LineEntry &rhs);
} // namespace lldb_private
diff --git a/include/lldb/Symbol/LineTable.h b/include/lldb/Symbol/LineTable.h
index 684972d507893..d24cc35e10f36 100644
--- a/include/lldb/Symbol/LineTable.h
+++ b/include/lldb/Symbol/LineTable.h
@@ -1,29 +1,25 @@
//===-- LineTable.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_LineTable_h_
#define liblldb_LineTable_h_
-#include <vector>
-
#include "lldb/Core/ModuleChild.h"
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/Section.h"
#include "lldb/Symbol/LineEntry.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"
+#include <vector>
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base
+/// \class LineSequence LineTable.h "lldb/Symbol/LineTable.h" An abstract base
/// class used during symbol table creation.
-//----------------------------------------------------------------------
class LineSequence {
public:
LineSequence();
@@ -36,36 +32,28 @@ private:
DISALLOW_COPY_AND_ASSIGN(LineSequence);
};
-//----------------------------------------------------------------------
-/// @class LineTable LineTable.h "lldb/Symbol/LineTable.h"
+/// \class LineTable LineTable.h "lldb/Symbol/LineTable.h"
/// A line table class.
-//----------------------------------------------------------------------
class LineTable {
public:
- //------------------------------------------------------------------
/// Construct with compile unit.
///
- /// @param[in] comp_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
+ /// \param[in] line_entry
/// A const reference to a new line_entry to add to this line
/// table.
///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
+ /// \see Address::DumpStyle
// void
// AddLineEntry (const LineEntry& line_entry);
@@ -90,45 +78,40 @@ public:
// 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
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] style
+ /// \param[in] style
/// The display style for the address.
///
- /// @see Address::DumpStyle
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] so_addr
/// A section offset address object containing the address we
/// are searching for.
///
- /// @param[out] line_entry
+ /// \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
+ /// \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
+ /// \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.
///
@@ -136,34 +119,33 @@ public:
/// line number \a line starting at the \a start_idx entries into the line
/// entry collection.
///
- /// @param[in] start_idx
+ /// \param[in] start_idx
/// The number of entries to skip when starting the search.
///
- /// @param[out] file_idx
+ /// \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
+ /// \param[in] line
/// The source line to match.
///
- /// @param[in] exact
+ /// \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
+ /// \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
+ /// \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
- //------------------------------------------------------------------
+ /// \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);
@@ -175,61 +157,53 @@ public:
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
+ /// \param[in] idx
/// An index into the line table entry collection.
///
- /// @return
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \param[out] file_ranges
/// A collection of file address ranges that will be filled in
/// by this function.
///
- /// @param[out] append
+ /// \param[out] append
/// If \b true, then append to \a file_ranges, otherwise clear
/// \a file_ranges prior to adding any ranges.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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;
@@ -304,9 +278,7 @@ protected:
return lhs.file_addr < rhs.file_addr;
}
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
/// The file address for this line entry.
lldb::addr_t file_addr;
/// The source line number, or zero if there is no line number
@@ -339,24 +311,18 @@ protected:
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;
diff --git a/include/lldb/Host/Symbols.h b/include/lldb/Symbol/LocateSymbolFile.h
index 8b00900d33215..0ff834df9c409 100644
--- a/include/lldb/Host/Symbols.h
+++ b/include/lldb/Symbol/LocateSymbolFile.h
@@ -1,9 +1,8 @@
-//===-- Symbols.h -----------------------------------------------*- C++ -*-===//
+//===-- LocateSymbolFile.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#include <stdint.h>
+#include "lldb/Core/FileSpecList.h"
#include "lldb/Utility/FileSpec.h"
namespace lldb_private {
@@ -22,27 +22,24 @@ class UUID;
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
+ LocateExecutableSymbolFile(const ModuleSpec &module_spec,
+ const FileSpecList &default_search_paths);
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
@@ -52,7 +49,6 @@ public:
// 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);
};
diff --git a/include/lldb/Symbol/ObjectContainer.h b/include/lldb/Symbol/ObjectContainer.h
index 1e14856ea6ea6..9310fdc18d904 100644
--- a/include/lldb/Symbol/ObjectContainer.h
+++ b/include/lldb/Symbol/ObjectContainer.h
@@ -1,9 +1,8 @@
//===-- ObjectContainer.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,8 +18,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h"
+/// \class ObjectContainer ObjectContainer.h "lldb/Symbol/ObjectContainer.h"
/// A plug-in interface definition class for object containers.
///
/// Object containers contain object files from one or more architectures, and
@@ -29,16 +27,13 @@ namespace lldb_private {
/// Typical object containers are static libraries (.a files) that contain
/// multiple named object files, and universal files that contain multiple
/// architectures.
-//----------------------------------------------------------------------
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)
@@ -51,72 +46,61 @@ public:
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
+ /// \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
+ /// \param[in] idx
/// The architecture index to extract.
///
- /// @param[out] arch
+ /// \param[out] arch
/// A architecture object that will be filled in if \a idx is a
/// architecture valid index.
///
- /// @return
+ /// \return
/// Returns \b true if \a idx is valid and \a arch has been
/// filled in, \b false otherwise.
///
- /// @see ObjectContainer::GetNumArchitectures() const
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \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
@@ -124,12 +108,10 @@ public:
/// one architecture should override this function and return an appropriate
/// value.
///
- /// @return
+ /// \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
@@ -138,13 +120,11 @@ public:
/// false should be returned and the next plug-in can attempt to parse an
/// object file.
///
- /// @return
+ /// \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
@@ -156,11 +136,10 @@ public:
/// state from any previously selected architecture and prepare to return
/// information for the new architecture.
///
- /// @return
+ /// \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; }
@@ -178,9 +157,7 @@ public:
}
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
diff --git a/include/lldb/Symbol/ObjectFile.h b/include/lldb/Symbol/ObjectFile.h
index c6bafcecb6f6d..84683e3f2a3f5 100644
--- a/include/lldb/Symbol/ObjectFile.h
+++ b/include/lldb/Symbol/ObjectFile.h
@@ -1,9 +1,8 @@
//===-- ObjectFile.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,8 +42,7 @@ public:
virtual ArchSpec GetArchitecture() = 0;
};
-//----------------------------------------------------------------------
-/// @class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h"
+/// \class ObjectFile ObjectFile.h "lldb/Symbol/ObjectFile.h"
/// A plug-in interface definition class for object file parsers.
///
/// Object files belong to Module objects and know how to extract information
@@ -57,14 +55,13 @@ 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;
public:
- typedef enum {
+ enum Type {
eTypeInvalid = 0,
eTypeCoreFile, /// A core file that has a checkpoint of a program's
/// execution state
@@ -77,29 +74,27 @@ public:
/// execution
eTypeJIT, /// JIT code that has symbols, sections and possibly debug info
eTypeUnknown
- } Type;
+ };
- typedef enum {
+ enum Strata {
eStrataInvalid = 0,
eStrataUnknown,
eStrataUser,
eStrataKernel,
eStrataRawImage,
eStrataJIT
- } Strata;
+ };
struct LoadableData {
lldb::addr_t Dest;
llvm::ArrayRef<uint8_t> Contents;
};
- //------------------------------------------------------------------
/// 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);
@@ -107,73 +102,65 @@ public:
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
+ /// \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
+ /// \param[in] module
/// The parent module that owns this object file.
///
- /// @param[in] file_spec
+ /// \param[in] file_spec
/// A file specification that indicates which file to use as the
/// object file.
///
- /// @param[in] file_offset
+ /// \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
+ /// \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()
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] module
/// The parent module that owns this object file.
///
- /// @param[in] process_sp
+ /// \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
+ /// \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,
@@ -190,60 +177,53 @@ public:
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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// 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 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
@@ -252,106 +232,86 @@ public:
/// 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
+ /// \param[out] file_list
/// A list of file specification objects that gets dependent
/// files appended to.
///
- /// @return
+ /// \return
/// The number of new files that were appended to \a file_list.
///
- /// @see FileSpecList::AppendIfUnique(const FileSpec &)
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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 ArchSpec for this object file.
///
- /// @return
+ /// \return
/// The ArchSpec of this object file. In case of error, an invalid
/// ArchSpec object is returned.
- //------------------------------------------------------------------
virtual ArchSpec GetArchitecture() = 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
+ /// \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
+ /// \return
/// The symbol table for this object file.
- //------------------------------------------------------------------
virtual Symtab *GetSymtab() = 0;
- //------------------------------------------------------------------
/// Perform relocations on the section if necessary.
///
- //------------------------------------------------------------------
virtual void RelocateSection(lldb_private::Section *section);
- //------------------------------------------------------------------
/// 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
@@ -360,10 +320,9 @@ public:
/// the first match in the SymbolTable and appends a Symbol only if
/// required/found.
///
- /// @return
+ /// \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
@@ -376,94 +335,78 @@ public:
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
/// 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
+ /// \param[in] flags
/// eSymtabFromUnifiedSectionList: Whether to clear symbol table
/// for unified module section list, or object file.
///
- /// @return
+ /// \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;
+ /// \return
+ /// The object file's UUID. In case of an error, an empty UUID is
+ /// returned.
+ virtual UUID GetUUID() = 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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
@@ -472,27 +415,11 @@ public:
/// false should be returned and the next plug-in can attempt to parse an
/// object file.
///
- /// @return
+ /// \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.
///
@@ -509,15 +436,13 @@ public:
/// that symbol start addresses are unavailable before false is returned.
/// If it is unclear, this should return true.
///
- /// @return
+ /// \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
@@ -527,24 +452,21 @@ public:
/// runtime linker so that a debugger may monitor the loading and unloading
/// of shared libraries.
///
- /// @return
+ /// \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
+ /// \return
/// Returns the entry address for this module.
- //------------------------------------------------------------------
virtual lldb_private::Address GetEntryPointAddress() { return Address(); }
- //------------------------------------------------------------------
/// Returns base address of this object file.
///
/// This also sometimes referred to as the "preferred load address" or the
@@ -553,46 +475,41 @@ public:
/// (usually the first byte of the first section) then the returned address
/// will have this section set. Otherwise, the address will just have the
/// offset member filled in, indicating that this represents a file address.
- //------------------------------------------------------------------
virtual lldb_private::Address GetBaseAddress() {
return Address(m_memory_addr);
}
virtual uint32_t GetNumThreadContexts() { return 0; }
- //------------------------------------------------------------------
/// Some object files may have an identifier string embedded in them, e.g.
/// in a Mach-O core file using the LC_IDENT load command (which is
/// obsolete, but can still be found in some old files)
///
- /// @return
+ /// \return
/// Returns the identifier string if one exists, else an empty
/// string.
- //------------------------------------------------------------------
virtual std::string GetIdentifierString () {
return std::string();
}
- //------------------------------------------------------------------
/// When the ObjectFile is a core file, lldb needs to locate the "binary" in
/// the core file. lldb can iterate over the pages looking for a valid
/// binary, but some core files may have metadata describing where the main
/// binary is exactly which removes ambiguity when there are multiple
/// binaries present in the captured memory pages.
///
- /// @param[out] address
+ /// \param[out] address
/// If the address of the binary is specified, this will be set.
/// This is an address is the virtual address space of the core file
/// memory segments; it is not an offset into the object file.
/// If no address is available, will be set to LLDB_INVALID_ADDRESS.
///
- /// @param[out] uuid
+ /// \param[out] uuid
/// If the uuid of the binary is specified, this will be set.
/// If no UUID is available, will be cleared.
///
- /// @return
+ /// \return
/// Returns true if either address or uuid has been set.
- //------------------------------------------------------------------
virtual bool GetCorefileMainBinaryInfo (lldb::addr_t &address, UUID &uuid) {
address = LLDB_INVALID_ADDRESS;
uuid.Clear();
@@ -604,7 +521,6 @@ public:
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-
@@ -612,18 +528,15 @@ public:
/// eTypeXXX definitions do not match up with the type of file you are
/// loading, please feel free to add a new enumeration value.
///
- /// @return
+ /// \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.
///
@@ -632,13 +545,11 @@ public:
/// out, it will help with debugger plug-in selection when it comes time to
/// debug.
///
- /// @return
+ /// \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
@@ -646,43 +557,33 @@ public:
/// minor and build, but there may be more. This function will extract the
/// versions from object files if they are available.
///
- /// @return
+ /// \return
/// This function returns extracted version numbers as a
/// llvm::VersionTuple. In case of error an empty VersionTuple is
/// returned.
- //------------------------------------------------------------------
virtual llvm::VersionTuple GetVersion() { return llvm::VersionTuple(); }
- //------------------------------------------------------------------
/// 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.
///
- /// @return
+ /// \return
/// This function returns extracted version numbers as a
/// llvm::VersionTuple. In case of error an empty VersionTuple is
/// returned.
- //------------------------------------------------------------------
virtual llvm::VersionTuple GetMinimumOSVersion() {
return llvm::VersionTuple();
}
- //------------------------------------------------------------------
/// 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
+ /// This function returns extracted version numbers as a
+ /// llvm::VersionTuple. In case of error an empty VersionTuple is
+ /// returned.
+ virtual llvm::VersionTuple GetSDKVersion() { return llvm::VersionTuple(); }
- //------------------------------------------------------------------
/// Return true if this file is a dynamic link editor (dyld)
///
/// Often times dyld has symbols that mirror symbols in libc and other
@@ -690,12 +591,9 @@ public:
/// 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();
@@ -747,24 +645,20 @@ public:
llvm::StringRef name,
lldb::SymbolType symbol_type_hint = lldb::eSymbolTypeUndefined);
- //------------------------------------------------------------------
/// Loads this objfile to memory.
///
/// Loads the bits needed to create an executable image to the memory. It is
/// useful with bare-metal targets where target does not have the ability to
/// start a process itself.
///
- /// @param[in] target
+ /// \param[in] target
/// Target where to load.
///
- /// @return
- //------------------------------------------------------------------
+ /// \return
virtual std::vector<LoadableData> GetLoadableData(Target &target);
protected:
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
FileSpec m_file;
Type m_type;
Strata m_strata;
@@ -775,27 +669,22 @@ protected:
///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;
+ std::unique_ptr<lldb_private::SectionList> m_sections_up;
+ std::unique_ptr<lldb_private::Symtab> m_symtab_up;
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
+ /// \param[in] new_arch
/// The architecture this module will be set to.
///
- /// @return
+ /// \return
/// Returns \b true if the architecture was changed, \b
/// false otherwise.
- //------------------------------------------------------------------
bool SetModulesArchitecture(const ArchSpec &new_arch);
ConstString GetNextSyntheticSymbolName();
diff --git a/include/lldb/Symbol/PostfixExpression.h b/include/lldb/Symbol/PostfixExpression.h
new file mode 100644
index 0000000000000..e3a8587a5f849
--- /dev/null
+++ b/include/lldb/Symbol/PostfixExpression.h
@@ -0,0 +1,226 @@
+//===-- PostfixExpression.h -------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements support for postfix expressions found in several symbol
+// file formats, and their conversion to DWARF.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SYMBOL_POSTFIXEXPRESSION_H
+#define LLDB_SYMBOL_POSTFIXEXPRESSION_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
+#include "llvm/Support/Casting.h"
+
+namespace lldb_private {
+
+class Stream;
+
+namespace postfix {
+
+/// The base class for all nodes in the parsed postfix tree.
+class Node {
+public:
+ enum Kind {
+ BinaryOp,
+ InitialValue,
+ Integer,
+ Register,
+ Symbol,
+ UnaryOp,
+ };
+
+protected:
+ Node(Kind kind) : m_kind(kind) {}
+
+public:
+ Kind GetKind() const { return m_kind; }
+
+private:
+ Kind m_kind;
+};
+
+/// A node representing a binary expression.
+class BinaryOpNode : public Node {
+public:
+ enum OpType {
+ Align, // alignDown(a, b)
+ Minus, // a - b
+ Plus, // a + b
+ };
+
+ BinaryOpNode(OpType op_type, Node &left, Node &right)
+ : Node(BinaryOp), m_op_type(op_type), m_left(&left), m_right(&right) {}
+
+ OpType GetOpType() const { return m_op_type; }
+
+ const Node *Left() const { return m_left; }
+ Node *&Left() { return m_left; }
+
+ const Node *Right() const { return m_right; }
+ Node *&Right() { return m_right; }
+
+ static bool classof(const Node *node) { return node->GetKind() == BinaryOp; }
+
+private:
+ OpType m_op_type;
+ Node *m_left;
+ Node *m_right;
+};
+
+/// A node representing the canonical frame address.
+class InitialValueNode: public Node {
+public:
+ InitialValueNode() : Node(InitialValue) {}
+
+ static bool classof(const Node *node) {
+ return node->GetKind() == InitialValue;
+ }
+};
+
+/// A node representing an integer literal.
+class IntegerNode : public Node {
+public:
+ IntegerNode(int64_t value) : Node(Integer), m_value(value) {}
+
+ int64_t GetValue() const { return m_value; }
+
+ static bool classof(const Node *node) { return node->GetKind() == Integer; }
+
+private:
+ int64_t m_value;
+};
+
+/// A node representing the value of a register with the given register number.
+/// The register kind (RegisterKind enum) used for the specifying the register
+/// number is implicit and assumed to be the same for all Register nodes in a
+/// given tree.
+class RegisterNode : public Node {
+public:
+ RegisterNode(uint32_t reg_num) : Node(Register), m_reg_num(reg_num) {}
+
+ uint32_t GetRegNum() const { return m_reg_num; }
+
+ static bool classof(const Node *node) { return node->GetKind() == Register; }
+
+private:
+ uint32_t m_reg_num;
+};
+
+/// A node representing a symbolic reference to a named entity. This may be a
+/// register, which hasn't yet been resolved to a RegisterNode.
+class SymbolNode : public Node {
+public:
+ SymbolNode(llvm::StringRef name) : Node(Symbol), m_name(name) {}
+
+ llvm::StringRef GetName() const { return m_name; }
+
+ static bool classof(const Node *node) { return node->GetKind() == Symbol; }
+
+private:
+ llvm::StringRef m_name;
+};
+
+/// A node representing a unary operation.
+class UnaryOpNode : public Node {
+public:
+ enum OpType {
+ Deref, // *a
+ };
+
+ UnaryOpNode(OpType op_type, Node &operand)
+ : Node(UnaryOp), m_op_type(op_type), m_operand(&operand) {}
+
+ OpType GetOpType() const { return m_op_type; }
+
+ const Node *Operand() const { return m_operand; }
+ Node *&Operand() { return m_operand; }
+
+ static bool classof(const Node *node) { return node->GetKind() == UnaryOp; }
+
+private:
+ OpType m_op_type;
+ Node *m_operand;
+};
+
+/// A template class implementing a visitor pattern, but with a couple of
+/// twists:
+/// - It uses type switch instead of virtual double dispatch. This allows the
+// node classes to be vtable-free and trivially destructible.
+/// - The Visit functions get an extra Node *& parameter, which refers to the
+/// child pointer of the parent of the node we are currently visiting. This
+/// allows mutating algorithms, which replace the currently visited node with
+/// a different one.
+/// - The class is templatized on the return type of the Visit functions, which
+/// means it's possible to return values from them.
+template <typename ResultT = void> class Visitor {
+protected:
+ virtual ~Visitor() = default;
+
+ virtual ResultT Visit(BinaryOpNode &binary, Node *&ref) = 0;
+ virtual ResultT Visit(InitialValueNode &val, Node *&ref) = 0;
+ virtual ResultT Visit(IntegerNode &integer, Node *&) = 0;
+ virtual ResultT Visit(RegisterNode &reg, Node *&) = 0;
+ virtual ResultT Visit(SymbolNode &symbol, Node *&ref) = 0;
+ virtual ResultT Visit(UnaryOpNode &unary, Node *&ref) = 0;
+
+ /// Invoke the correct Visit function based on the dynamic type of the given
+ /// node.
+ ResultT Dispatch(Node *&node) {
+ switch (node->GetKind()) {
+ case Node::BinaryOp:
+ return Visit(llvm::cast<BinaryOpNode>(*node), node);
+ case Node::InitialValue:
+ return Visit(llvm::cast<InitialValueNode>(*node), node);
+ case Node::Integer:
+ return Visit(llvm::cast<IntegerNode>(*node), node);
+ case Node::Register:
+ return Visit(llvm::cast<RegisterNode>(*node), node);
+ case Node::Symbol:
+ return Visit(llvm::cast<SymbolNode>(*node), node);
+ case Node::UnaryOp:
+ return Visit(llvm::cast<UnaryOpNode>(*node), node);
+ }
+ llvm_unreachable("Fully covered switch!");
+ }
+};
+
+/// A utility function for "resolving" SymbolNodes. It traverses a tree and
+/// calls the callback function for all SymbolNodes it encountered. The
+/// replacement function should return the node it wished to replace the current
+/// SymbolNode with (this can also be the original node), or nullptr in case of
+/// an error. The nodes returned by the callback are inspected and replaced
+/// recursively, *except* for the case when the function returns the exact same
+/// node as the input one. It returns true if all SymbolNodes were replaced
+/// successfully.
+bool ResolveSymbols(Node *&node,
+ llvm::function_ref<Node *(SymbolNode &symbol)> replacer);
+
+template <typename T, typename... Args>
+inline T *MakeNode(llvm::BumpPtrAllocator &alloc, Args &&... args) {
+ static_assert(std::is_trivially_destructible<T>::value,
+ "This object will not be destroyed!");
+ return new (alloc.Allocate<T>()) T(std::forward<Args>(args)...);
+}
+
+/// Parse the given postfix expression. The parsed nodes are placed into the
+/// provided allocator.
+Node *Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc);
+
+/// Serialize the given expression tree as DWARF. The result is written into the
+/// given stream. The AST should not contain any SymbolNodes. If the expression
+/// contains InitialValueNodes, the generated expression will assume that their
+/// value will be provided as the top value of the initial evaluation stack (as
+/// is the case with the CFA value in register eh_unwind rules).
+void ToDWARF(Node &node, Stream &stream);
+
+} // namespace postfix
+} // namespace lldb_private
+
+#endif // LLDB_SYMBOL_POSTFIXEXPRESSION_H
diff --git a/include/lldb/Symbol/SourceModule.h b/include/lldb/Symbol/SourceModule.h
new file mode 100644
index 0000000000000..b12ff01a5198d
--- /dev/null
+++ b/include/lldb/Symbol/SourceModule.h
@@ -0,0 +1,27 @@
+//===-- SourceModule.h ------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_SourceModule_h_
+#define liblldb_SourceModule_h_
+
+#include "lldb/Utility/ConstString.h"
+#include <vector>
+
+namespace lldb_private {
+
+/// Information needed to import a source-language module.
+struct SourceModule {
+ /// Something like "Module.Submodule".
+ std::vector<ConstString> path;
+ ConstString search_path;
+ ConstString sysroot;
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/include/lldb/Symbol/Symbol.h b/include/lldb/Symbol/Symbol.h
index 9523158e0780d..1cbc2f5492f4e 100644
--- a/include/lldb/Symbol/Symbol.h
+++ b/include/lldb/Symbol/Symbol.h
@@ -1,9 +1,8 @@
//===-- Symbol.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,41 +42,33 @@ public:
void Clear();
- bool Compare(const ConstString &name, lldb::SymbolType type) const;
+ bool Compare(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
@@ -134,7 +125,7 @@ public:
FileSpec GetReExportedSymbolSharedLibrary() const;
- void SetReExportedSymbolName(const ConstString &name);
+ void SetReExportedSymbolName(ConstString name);
bool SetReExportedSymbolSharedLibrary(const FileSpec &fspec);
@@ -174,6 +165,10 @@ public:
bool IsTrampoline() const;
bool IsIndirect() const;
+
+ bool IsWeak() const { return m_is_weak; }
+
+ void SetIsWeak (bool b) { m_is_weak = b; }
bool GetByteSizeIsValid() const { return m_size_is_valid; }
@@ -204,22 +199,18 @@ public:
void SetContainsLinkerAnnotations(bool b) {
m_contains_linker_annotations = b;
}
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
+ /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void CalculateSymbolContext(SymbolContext *sc) override;
lldb::ModuleSP CalculateSymbolContextModule() override;
Symbol *CalculateSymbolContextSymbol() override;
- //------------------------------------------------------------------
- /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
+ /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
///
- /// @see SymbolContextScope
- //------------------------------------------------------------------
+ /// \see SymbolContextScope
void DumpSymbolContext(Stream *s) override;
lldb::DisassemblerSP GetInstructions(const ExecutionContext &exe_ctx,
@@ -263,7 +254,8 @@ protected:
m_contains_linker_annotations : 1, // The symbol name contains linker
// annotations, which are optional when
// doing name lookups
- m_type : 7;
+ m_is_weak : 1,
+ m_type : 6; // Values from the lldb::SymbolType enum.
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
diff --git a/include/lldb/Symbol/SymbolContext.h b/include/lldb/Symbol/SymbolContext.h
index a7afffb705d2b..55a3454893581 100644
--- a/include/lldb/Symbol/SymbolContext.h
+++ b/include/lldb/Symbol/SymbolContext.h
@@ -1,9 +1,8 @@
//===-- SymbolContext.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,59 +23,51 @@ namespace lldb_private {
class SymbolContextScope;
-//----------------------------------------------------------------------
-/// @class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" Defines
+/// \class SymbolContext SymbolContext.h "lldb/Symbol/SymbolContext.h" Defines
/// a symbol context baton that can be handed other debug core functions.
///
/// Many debugger functions require a context when doing lookups. This class
/// provides a common structure that can be used as the result of a query that
/// can contain a single result. Examples of such queries include
-/// @li Looking up a load address.
-//----------------------------------------------------------------------
+/// \li Looking up a load address.
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
+ /// \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
+ /// \param[in] module
/// A Module pointer to the module for this context.
///
- /// @param[in] comp_unit
+ /// \param[in] comp_unit
/// A CompileUnit pointer to the compile unit for this context.
///
- /// @param[in] function
+ /// \param[in] function
/// A Function pointer to the function for this context.
///
- /// @param[in] block
+ /// \param[in] block
/// A Block pointer to the deepest block for this context.
///
- /// @param[in] line_entry
+ /// \param[in] line_entry
/// A LineEntry pointer to the line entry for this context.
///
- /// @param[in] symbol
+ /// \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,
@@ -91,52 +82,35 @@ public:
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
+ /// \param[in] rhs
/// A const SymbolContext object reference to copy.
///
- /// @return
+ /// \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
+ /// \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
@@ -146,45 +120,43 @@ public:
/// is available, that will be output. Else just the address at which the
/// target was stopped will be displayed.
///
- /// @param[in] s
+ /// \param[in] s
/// The stream to which to dump the object description.
///
- /// @param[in] so_addr
+ /// \param[in] so_addr
/// The resolved section offset address.
///
- /// @param[in] show_fullpaths
+ /// \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
+ /// \param[in] show_module
/// Whether the module name should be printed followed by a
/// grave accent "`" character.
///
- /// @param[in] show_inlined_frames
+ /// \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
+ /// \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
+ /// \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:
@@ -197,17 +169,17 @@ public:
/// - symbol address range if symbol is not nullptr and
/// eSymbolContextSymbol is set in \a scope
///
- /// @param[in] 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
+ /// \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
+ /// \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
@@ -215,21 +187,19 @@ public:
/// for the address range of the inlined function block, not
/// the deepest lexical block.
///
- /// @param[out] range
+ /// \param[out] range
/// An address range object that will be filled in if \b true
/// is returned.
///
- /// @return
+ /// \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,
Status &error);
- //------------------------------------------------------------------
/// Find the best global data symbol visible from this context.
///
/// Symbol priority is:
@@ -239,18 +209,17 @@ public:
/// - non-extern symbol in the target
/// It is an error if the highest-priority result is ambiguous.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the symbol to search for.
///
- /// @param[out] error
+ /// \param[out] error
/// An error that will be populated with a message if there was an
/// ambiguous result. The error will not be populated if no result
/// was found.
///
- /// @return
+ /// \return
/// The symbol that was found, or \b nullptr if none was found.
- //------------------------------------------------------------------
- const Symbol *FindBestGlobalDataSymbol(const ConstString &name, Status &error);
+ const Symbol *FindBestGlobalDataSymbol(ConstString name, Status &error);
void GetDescription(Stream *s, lldb::DescriptionLevel level,
Target *target) const;
@@ -259,7 +228,6 @@ public:
lldb::LanguageType GetLanguage() const;
- //------------------------------------------------------------------
/// Find a block that defines the function represented by this symbol
/// context.
///
@@ -276,59 +244,51 @@ public:
/// represented by this symbol context (whether the function is an inline
/// function or not).
///
- /// @return
+ /// \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
+ /// \param[out] language
/// If \b true is returned, the language for the method.
///
- /// @param[out] is_instance_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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
@@ -339,43 +299,38 @@ public:
/// table information for the symbol context. it will return the inlined
/// function name.
///
- /// @param[in] prefer_mangled
+ /// \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
+ /// \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
+ /// \param[in] curr_frame_pc
/// The address within the block of this object.
///
- /// @param[out] next_frame_sc
+ /// \param[out] next_frame_sc
/// A new symbol context that does what the title says it does.
///
- /// @param[out] next_frame_addr
+ /// \param[out] next_frame_addr
/// This is what you should report as the PC in \a next_frame_sc.
///
- /// @return
+ /// \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
@@ -388,7 +343,7 @@ public:
class SymbolContextSpecifier {
public:
- typedef enum SpecificationType {
+ enum SpecificationType {
eNothingSpecified = 0,
eModuleSpecified = 1 << 0,
eFileSpecified = 1 << 1,
@@ -397,7 +352,7 @@ public:
eFunctionSpecified = 1 << 4,
eClassOrNamespaceSpecified = 1 << 5,
eAddressRangeSpecified = 1 << 6
- } SpecificationType;
+ };
// This one produces a specifier that matches everything...
SymbolContextSpecifier(const lldb::TargetSP &target_sp);
@@ -420,45 +375,37 @@ private:
lldb::TargetSP m_target_sp;
std::string m_module_spec;
lldb::ModuleSP m_module_sp;
- std::unique_ptr<FileSpec> m_file_spec_ap;
+ std::unique_ptr<FileSpec> m_file_spec_up;
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;
+ std::unique_ptr<AddressRange> m_address_range_up;
uint32_t m_type; // Or'ed bits from SpecificationType
};
-//----------------------------------------------------------------------
-/// @class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h"
+/// \class SymbolContextList SymbolContext.h "lldb/Symbol/SymbolContext.h"
/// Defines a list of symbol context objects.
///
/// This class provides a common structure that can be used to contain the
/// result of a query that can contain a multiple results. Examples of such
/// queries include:
-/// @li Looking up a function by name.
-/// @li Finding all addresses for a specified file and line number.
-//----------------------------------------------------------------------
+/// \li Looking up a function by name.
+/// \li Finding all addresses for a specified file and line number.
class SymbolContextList {
public:
- //------------------------------------------------------------------
/// Default constructor.
///
/// Initialize with an empty list.
- //------------------------------------------------------------------
SymbolContextList();
- //------------------------------------------------------------------
/// Destructor.
- //------------------------------------------------------------------
~SymbolContextList();
- //------------------------------------------------------------------
/// Append a new symbol context to the list.
///
- /// @param[in] sc
+ /// \param[in] sc
/// A symbol context to append to the list.
- //------------------------------------------------------------------
void Append(const SymbolContext &sc);
void Append(const SymbolContextList &sc_list);
@@ -468,55 +415,47 @@ public:
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
+ /// \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
+ /// \param[in] idx
/// The zero based index into the symbol context list.
///
- /// @param[out] sc
+ /// \param[out] sc
/// A reference to the symbol context to fill in.
///
- /// @return
+ /// \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
+ /// \param[in] idx
/// The zero based index into the symbol context list.
///
- /// @return
+ /// \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 {
@@ -525,12 +464,10 @@ public:
bool RemoveContextAtIndex(size_t idx);
- //------------------------------------------------------------------
/// Get accessor for a symbol context list size.
///
- /// @return
+ /// \return
/// Returns the number of symbol context objects in the list.
- //------------------------------------------------------------------
uint32_t GetSize() const;
uint32_t NumLineEntriesWithLine(uint32_t line) const;
@@ -542,9 +479,7 @@ protected:
typedef std::vector<SymbolContext>
collection; ///< The collection type for the list.
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
collection m_symbol_contexts; ///< The list of symbol contexts.
public:
diff --git a/include/lldb/Symbol/SymbolContextScope.h b/include/lldb/Symbol/SymbolContextScope.h
index 85718b9bba4f1..a626302053df1 100644
--- a/include/lldb/Symbol/SymbolContextScope.h
+++ b/include/lldb/Symbol/SymbolContextScope.h
@@ -1,9 +1,8 @@
//===-- SymbolContextScope.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,8 +13,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class SymbolContextScope SymbolContextScope.h
+/// \class SymbolContextScope SymbolContextScope.h
/// "lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is
/// part of a symbol context
/// and can reconstruct its symbol context.
@@ -27,11 +25,11 @@ namespace lldb_private {
/// complete SymbolContext object in the object.
///
/// Examples of these objects include:
-/// @li Module
-/// @li CompileUnit
-/// @li Function
-/// @li Block
-/// @li Symbol
+/// \li Module
+/// \li CompileUnit
+/// \li Function
+/// \li Block
+/// \li Symbol
///
/// Other objects can store a "SymbolContextScope *" using any pointers to one
/// of the above objects. This allows clients to hold onto a pointer that
@@ -41,7 +39,7 @@ namespace lldb_private {
///
/// Example objects include that currently use "SymbolContextScope *" objects
/// include:
-/// @li Variable objects that can reconstruct where they are scoped
+/// \li Variable objects that can reconstruct where they are scoped
/// by making sure the SymbolContextScope * comes from the scope
/// in which the variable was declared. If a variable is a global,
/// the appropriate CompileUnit * will be used when creating the
@@ -49,9 +47,9 @@ 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
+/// \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
@@ -63,21 +61,18 @@ namespace lldb_private {
/// can also be created using a SymbolContextScope* and and object pairs that
/// allow large collections of objects to be passed around with minimal
/// overhead.
-//----------------------------------------------------------------------
class SymbolContextScope {
public:
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
+ /// \param[out] sc
/// A symbol context object pointer that gets filled in.
- //------------------------------------------------------------------
virtual void CalculateSymbolContext(SymbolContext *sc) = 0;
virtual lldb::ModuleSP CalculateSymbolContextModule() {
@@ -92,16 +87,14 @@ public:
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
+ /// \param[in] s
/// The stream to which to dump the object's symbol context.
- //------------------------------------------------------------------
virtual void DumpSymbolContext(Stream *s) = 0;
};
diff --git a/include/lldb/Symbol/SymbolFile.h b/include/lldb/Symbol/SymbolFile.h
index 433c20da99e2e..dbb723e9d3693 100644
--- a/include/lldb/Symbol/SymbolFile.h
+++ b/include/lldb/Symbol/SymbolFile.h
@@ -1,9 +1,8 @@
//===-- SymbolFile.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,6 +14,7 @@
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/SourceModule.h"
#include "lldb/Symbol/Type.h"
#include "lldb/lldb-private.h"
@@ -32,14 +32,12 @@ namespace lldb_private {
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),
@@ -53,15 +51,12 @@ public:
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.
///
@@ -85,11 +80,10 @@ public:
/// for "void SymbolFile::InitializeObject()" which will get called
/// on the SymbolFile object with the best set of abilities.
///
- /// @return
+ /// \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();
@@ -101,13 +95,10 @@ public:
virtual uint32_t CalculateAbilities() = 0;
- //------------------------------------------------------------------
/// Symbols file subclasses should override this to return the Module that
/// owns the TypeSystem that this symbol file modifies type information in.
- //------------------------------------------------------------------
virtual std::recursive_mutex &GetModuleMutex() const;
- //------------------------------------------------------------------
/// Initialize the SymbolFile object.
///
/// The SymbolFile object with the best set of abilities (detected
@@ -115,12 +106,9 @@ public:
/// 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;
@@ -136,7 +124,7 @@ public:
virtual bool
ParseImportedModules(const SymbolContext &sc,
- std::vector<ConstString> &imported_modules) = 0;
+ std::vector<SourceModule> &imported_modules) = 0;
virtual size_t ParseBlocksRecursive(Function &func) = 0;
virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0;
virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0;
@@ -144,10 +132,10 @@ public:
/// The characteristics of an array type.
struct ArrayInfo {
- int64_t first_index;
+ int64_t first_index = 0;
llvm::SmallVector<uint64_t, 1> element_orders;
- uint32_t byte_stride;
- uint32_t bit_stride;
+ uint32_t byte_stride = 0;
+ uint32_t bit_stride = 0;
};
/// If \c type_uid points to an array type, return its characteristics.
/// To support variable-length array types, this function takes an
@@ -178,13 +166,13 @@ public:
virtual void DumpClangAST(Stream &s) {}
virtual uint32_t
- FindGlobalVariables(const ConstString &name,
+ FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables);
virtual uint32_t FindGlobalVariables(const RegularExpression &regex,
uint32_t max_matches,
VariableList &variables);
- virtual uint32_t FindFunctions(const ConstString &name,
+ virtual uint32_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -193,7 +181,7 @@ public:
bool include_inlines, bool append,
SymbolContextList &sc_list);
virtual uint32_t
- FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
@@ -217,7 +205,7 @@ public:
GetTypeSystemForLanguage(lldb::LanguageType language);
virtual CompilerDeclContext
- FindNamespace(const ConstString &name,
+ FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
return CompilerDeclContext();
}
@@ -231,12 +219,22 @@ public:
virtual void AddSymbols(Symtab &symtab) {}
- //------------------------------------------------------------------
/// Notify the SymbolFile that the file addresses in the Sections
/// for this module have been changed.
- //------------------------------------------------------------------
virtual void SectionFileAddressesChanged() {}
+ struct RegisterInfoResolver {
+ virtual ~RegisterInfoResolver(); // anchor
+
+ virtual const RegisterInfo *ResolveName(llvm::StringRef name) const = 0;
+ virtual const RegisterInfo *ResolveNumber(lldb::RegisterKind kind,
+ uint32_t number) const = 0;
+ };
+ virtual lldb::UnwindPlanSP
+ GetUnwindPlan(const Address &address, const RegisterInfoResolver &resolver) {
+ return nullptr;
+ }
+
virtual void Dump(Stream &s) {}
protected:
diff --git a/include/lldb/Symbol/SymbolVendor.h b/include/lldb/Symbol/SymbolVendor.h
index d48f646d52cd5..c4015ff034927 100644
--- a/include/lldb/Symbol/SymbolVendor.h
+++ b/include/lldb/Symbol/SymbolVendor.h
@@ -1,9 +1,8 @@
//===-- SymbolVendor.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/SourceModule.h"
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/TypeMap.h"
#include "lldb/lldb-private.h"
@@ -21,7 +21,6 @@
namespace lldb_private {
-//----------------------------------------------------------------------
// The symbol vendor class is designed to abstract the process of searching for
// debug information for a given module. Platforms can subclass this class and
// provide extra ways to find debug information. Examples would be a subclass
@@ -29,15 +28,12 @@ namespace lldb_private {
// or runtime data in the object files. A symbol vendor can use multiple
// sources (SymbolFile 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 {
public:
static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
Stream *feedback_strm);
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolVendor(const lldb::ModuleSP &module_sp);
~SymbolVendor() override;
@@ -61,8 +57,9 @@ public:
virtual size_t ParseTypes(CompileUnit &comp_unit);
- virtual bool ParseImportedModules(const SymbolContext &sc,
- std::vector<ConstString> &imported_modules);
+ virtual bool
+ ParseImportedModules(const SymbolContext &sc,
+ std::vector<SourceModule> &imported_modules);
virtual size_t ParseBlocksRecursive(Function &func);
@@ -79,7 +76,7 @@ public:
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list);
- virtual size_t FindGlobalVariables(const ConstString &name,
+ virtual size_t FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
VariableList &variables);
@@ -88,7 +85,7 @@ public:
size_t max_matches,
VariableList &variables);
- virtual size_t FindFunctions(const ConstString &name,
+ virtual size_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -99,7 +96,7 @@ public:
SymbolContextList &sc_list);
virtual size_t
- FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
@@ -108,7 +105,7 @@ public:
bool append, TypeMap &types);
virtual CompilerDeclContext
- FindNamespace(const ConstString &name,
+ FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx);
virtual size_t GetNumCompileUnits();
@@ -125,7 +122,7 @@ public:
virtual size_t GetTypes(SymbolContextScope *sc_scope,
lldb::TypeClass type_mask, TypeList &type_list);
- SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
+ SymbolFile *GetSymbolFile() { return m_sym_file_up.get(); }
FileSpec GetMainFileSpec() const;
@@ -135,23 +132,17 @@ public:
// 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;
@@ -162,15 +153,13 @@ protected:
// 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
+ std::unique_ptr<SymbolFile> m_sym_file_up; // A single symbol file. Subclasses
// can add more of these if needed.
Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of
// the symbol file each time when it is needed
private:
- //------------------------------------------------------------------
// For SymbolVendor only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
};
diff --git a/include/lldb/Symbol/Symtab.h b/include/lldb/Symbol/Symtab.h
index 286e4f48c2e8c..868edcdc9290e 100644
--- a/include/lldb/Symbol/Symtab.h
+++ b/include/lldb/Symbol/Symtab.h
@@ -1,22 +1,20 @@
//===-- Symtab.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Symtab_h_
#define liblldb_Symtab_h_
-#include <mutex>
-#include <vector>
-
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Symbol/Symbol.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"
+#include <mutex>
+#include <vector>
namespace lldb_private {
@@ -25,17 +23,13 @@ public:
typedef std::vector<uint32_t> IndexCollection;
typedef UniqueCStringMap<uint32_t> NameToIndexMap;
- typedef enum Debug {
+ enum Debug {
eDebugNo, // Not a debug symbol
eDebugYes, // A debug symbol
eDebugAny
- } Debug;
+ };
- typedef enum Visibility {
- eVisibilityAny,
- eVisibilityExtern,
- eVisibilityPrivate
- } Visibility;
+ enum Visibility { eVisibilityAny, eVisibilityExtern, eVisibilityPrivate };
Symtab(ObjectFile *objfile);
~Symtab();
@@ -56,13 +50,11 @@ public:
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,
@@ -78,16 +70,16 @@ public:
std::vector<uint32_t> &matches,
uint32_t start_idx = 0,
uint32_t end_index = UINT32_MAX) const;
- uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name,
+ uint32_t AppendSymbolIndexesWithName(ConstString symbol_name,
std::vector<uint32_t> &matches);
- uint32_t AppendSymbolIndexesWithName(const ConstString &symbol_name,
+ uint32_t AppendSymbolIndexesWithName(ConstString symbol_name,
Debug symbol_debug_type,
Visibility symbol_visibility,
std::vector<uint32_t> &matches);
- uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name,
+ uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name,
lldb::SymbolType symbol_type,
std::vector<uint32_t> &matches);
- uint32_t AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name,
+ uint32_t AppendSymbolIndexesWithNameAndType(ConstString symbol_name,
lldb::SymbolType symbol_type,
Debug symbol_debug_type,
Visibility symbol_visibility,
@@ -100,10 +92,10 @@ public:
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,
+ size_t FindAllSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
std::vector<uint32_t> &symbol_indexes);
- size_t FindAllSymbolsWithNameAndType(const ConstString &name,
+ size_t FindAllSymbolsWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
Debug symbol_debug_type,
Visibility symbol_visibility,
@@ -112,7 +104,7 @@ public:
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,
+ Symbol *FindFirstSymbolWithNameAndType(ConstString name,
lldb::SymbolType symbol_type,
Debug symbol_debug_type,
Visibility symbol_visibility);
@@ -120,7 +112,7 @@ public:
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,
+ size_t FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
SymbolContextList &sc_list);
void CalculateSymbolSizes();
@@ -198,7 +190,7 @@ private:
SymbolContextList &sc_list);
void RegisterMangledNameEntry(
- NameToIndexMap::Entry &entry, std::set<const char *> &class_contexts,
+ uint32_t value, std::set<const char *> &class_contexts,
std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog,
RichManglingContext &rmc);
diff --git a/include/lldb/Symbol/TaggedASTType.h b/include/lldb/Symbol/TaggedASTType.h
index eabd41ebbf293..043a9138e07b0 100644
--- a/include/lldb/Symbol/TaggedASTType.h
+++ b/include/lldb/Symbol/TaggedASTType.h
@@ -1,9 +1,8 @@
//===-- TaggedASTType.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Symbol/Type.h b/include/lldb/Symbol/Type.h
index fec2578c9fec7..efc9bf049a35a 100644
--- a/include/lldb/Symbol/Type.h
+++ b/include/lldb/Symbol/Type.h
@@ -1,9 +1,8 @@
//===-- Type.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,12 +22,10 @@
#include <set>
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)
+ CompilerContext(CompilerContextKind t, ConstString n)
: type(t), name(n) {}
bool operator==(const CompilerContext &rhs) const {
@@ -62,25 +59,25 @@ protected:
class Type : public std::enable_shared_from_this<Type>, public UserID {
public:
- typedef enum EncodingDataTypeTag {
+ enum EncodingDataType {
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
+ /// with the const qualifier added
eEncodingIsRestrictUID, ///< This type is the type whose UID is
- ///m_encoding_uid with the restrict qualifier added
+ /// 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
+ /// m_encoding_uid with the volatile qualifier added
eEncodingIsTypedefUID, ///< This type is pointer to a type whose UID is
- ///m_encoding_uid
+ /// m_encoding_uid
eEncodingIsPointerUID, ///< This type is pointer to a type whose UID is
- ///m_encoding_uid
+ /// m_encoding_uid
eEncodingIsLValueReferenceUID, ///< This type is L value reference to a type
- ///whose UID is m_encoding_uid
+ /// whose UID is m_encoding_uid
eEncodingIsRValueReferenceUID, ///< This type is R value reference to a type
- ///whose UID is m_encoding_uid
+ /// 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
@@ -95,8 +92,8 @@ public:
eResolveStateFull = 3
} ResolveState;
- Type(lldb::user_id_t uid, SymbolFile *symbol_file, const ConstString &name,
- uint64_t byte_size, SymbolContextScope *context,
+ Type(lldb::user_id_t uid, SymbolFile *symbol_file, ConstString name,
+ llvm::Optional<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);
@@ -105,10 +102,6 @@ public:
// 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);
@@ -126,9 +119,9 @@ public:
TypeList *GetTypeList();
- const ConstString &GetName();
+ ConstString GetName();
- uint64_t GetByteSize();
+ llvm::Optional<uint64_t> GetByteSize();
uint32_t GetNumChildren(bool omit_empty_base_classes);
@@ -140,7 +133,7 @@ public:
lldb::TypeSP GetTypedefType();
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
ConstString GetQualifiedName();
@@ -218,7 +211,8 @@ protected:
Type *m_encoding_type;
lldb::user_id_t m_encoding_uid;
EncodingDataType m_encoding_uid_type;
- uint64_t m_byte_size;
+ uint64_t m_byte_size : 63;
+ uint64_t m_byte_size_has_value : 1;
Declaration m_decl;
CompilerType m_compiler_type;
@@ -237,142 +231,15 @@ protected:
bool ResolveClangType(ResolveState compiler_type_resolve_state);
};
-// these classes are used to back the SBType* objects
-
-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();
- }
-
-protected:
- 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 {
public:
- TypeImpl();
+ TypeImpl() = default;
~TypeImpl() {}
- TypeImpl(const TypeImpl &rhs);
-
TypeImpl(const lldb::TypeSP &type_sp);
TypeImpl(const CompilerType &compiler_type);
@@ -381,8 +248,6 @@ public:
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);
@@ -391,10 +256,6 @@ public:
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;
@@ -434,7 +295,7 @@ private:
bool CheckModule(lldb::ModuleSP &module_sp) const;
lldb::ModuleWP m_module_wp;
- TypePair m_static_type;
+ CompilerType m_static_type;
CompilerType m_dynamic_type;
};
@@ -478,7 +339,7 @@ public:
{}
TypeMemberImpl(const lldb::TypeImplSP &type_impl_sp, uint64_t bit_offset,
- const ConstString &name, uint32_t bitfield_bit_size = 0,
+ 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) {}
@@ -492,7 +353,7 @@ public:
const lldb::TypeImplSP &GetTypeImpl() { return m_type_impl_sp; }
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
uint64_t GetBitOffset() const { return m_bit_offset; }
@@ -526,26 +387,21 @@ protected:
class TypeAndOrName {
public:
- TypeAndOrName();
+ TypeAndOrName() = default;
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_compiler_type; }
- CompilerType GetCompilerType() const { return m_type_pair.GetCompilerType(); }
-
- void SetName(const ConstString &type_name);
+ void SetName(ConstString type_name);
void SetName(const char *type_name_cstr);
@@ -557,18 +413,16 @@ public:
bool HasName() const;
- bool HasTypeSP() const;
-
bool HasCompilerType() const;
- bool HasType() const { return HasTypeSP() || HasCompilerType(); }
+ bool HasType() const { return HasCompilerType(); }
void Clear();
explicit operator bool() { return !IsEmpty(); }
private:
- TypePair m_type_pair;
+ CompilerType m_compiler_type;
ConstString m_type_name;
};
@@ -617,17 +471,15 @@ public:
: 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);
+ 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(const TypeEnumMemberImpl &rhs) = default;
TypeEnumMemberImpl &operator=(const TypeEnumMemberImpl &rhs);
bool IsValid() { return m_valid; }
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
const lldb::TypeImplSP &GetIntegerType() const { return m_integer_type_sp; }
diff --git a/include/lldb/Symbol/TypeList.h b/include/lldb/Symbol/TypeList.h
index b6a4e41ff3015..982f673fff6e6 100644
--- a/include/lldb/Symbol/TypeList.h
+++ b/include/lldb/Symbol/TypeList.h
@@ -1,9 +1,8 @@
//===-- TypeList.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@ namespace lldb_private {
class TypeList {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
TypeList();
virtual ~TypeList();
@@ -34,7 +31,7 @@ public:
// lldb::TypeSP
// FindType(lldb::user_id_t uid);
- TypeList FindTypes(const ConstString &name);
+ TypeList FindTypes(ConstString name);
void Insert(const lldb::TypeSP &type);
diff --git a/include/lldb/Symbol/TypeMap.h b/include/lldb/Symbol/TypeMap.h
index 6bf9831c1389b..e7d2b254cbf32 100644
--- a/include/lldb/Symbol/TypeMap.h
+++ b/include/lldb/Symbol/TypeMap.h
@@ -1,9 +1,8 @@
//===-- TypeMap.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@ namespace lldb_private {
class TypeMap {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
TypeMap();
virtual ~TypeMap();
@@ -31,7 +28,7 @@ public:
void Dump(Stream *s, bool show_context);
- TypeMap FindTypes(const ConstString &name);
+ TypeMap FindTypes(ConstString name);
void Insert(const lldb::TypeSP &type);
diff --git a/include/lldb/Symbol/TypeSystem.h b/include/lldb/Symbol/TypeSystem.h
index 6afbd188a2342..4bef2a4446ebd 100644
--- a/include/lldb/Symbol/TypeSystem.h
+++ b/include/lldb/Symbol/TypeSystem.h
@@ -1,9 +1,8 @@
//===-- TypeSystem.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,15 +25,13 @@
class DWARFDIE;
class DWARFASTParser;
+class PDBASTParser;
namespace lldb_private {
-//----------------------------------------------------------------------
// Interface for representing the Type Systems in different languages.
-//----------------------------------------------------------------------
class TypeSystem : public PluginInterface {
public:
- //----------------------------------------------------------------------
// Intrusive type system that allows us to use llvm casting.
//
// To add a new type system:
@@ -64,7 +61,6 @@ public:
//
// Then you can use the llvm casting on any "TypeSystem *" to get an instance
// of your subclass.
- //----------------------------------------------------------------------
enum LLVMCastKind {
eKindClang,
eKindSwift,
@@ -72,9 +68,7 @@ public:
kNumKinds
};
- //----------------------------------------------------------------------
// Constructors and Destructors
- //----------------------------------------------------------------------
TypeSystem(LLVMCastKind kind);
~TypeSystem() override;
@@ -92,15 +86,14 @@ public:
virtual void Finalize() {}
virtual DWARFASTParser *GetDWARFParser() { return nullptr; }
+ virtual PDBASTParser *GetPDBParser() { 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);
@@ -114,9 +107,7 @@ public:
virtual CompilerType DeclGetFunctionArgumentType(void *opaque_decl,
size_t arg_idx);
- //----------------------------------------------------------------------
// CompilerDeclContext functions
- //----------------------------------------------------------------------
virtual std::vector<CompilerDecl>
DeclContextFindDeclByName(void *opaque_decl_ctx, ConstString name,
@@ -133,9 +124,10 @@ public:
void *opaque_decl_ctx, lldb::LanguageType *language_ptr,
bool *is_instance_method_ptr, ConstString *language_object_name_ptr) = 0;
- //----------------------------------------------------------------------
+ virtual bool DeclContextIsContainedInLookup(void *opaque_decl_ctx,
+ void *other_opaque_decl_ctx) = 0;
+
// Tests
- //----------------------------------------------------------------------
virtual bool IsArrayType(lldb::opaque_compiler_type_t type,
CompilerType *element_type, uint64_t *size,
@@ -189,24 +181,20 @@ public:
virtual bool IsVoidType(lldb::opaque_compiler_type_t type) = 0;
+ virtual bool CanPassInRegisters(const CompilerType &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;
@@ -219,9 +207,7 @@ public:
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;
@@ -267,12 +253,11 @@ public:
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 llvm::Optional<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;
@@ -283,7 +268,7 @@ public:
bool omit_empty_base_classes,
const ExecutionContext *exe_ctx) = 0;
- virtual CompilerType GetBuiltinTypeByName(const ConstString &name);
+ virtual CompilerType GetBuiltinTypeByName(ConstString name);
virtual lldb::BasicType
GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) = 0;
@@ -291,7 +276,7 @@ public:
virtual void ForEachEnumerator(
lldb::opaque_compiler_type_t type,
std::function<bool(const CompilerType &integer_type,
- const ConstString &name,
+ ConstString name,
const llvm::APSInt &value)> const &callback) {}
virtual uint32_t GetNumFields(lldb::opaque_compiler_type_t type) = 0;
@@ -351,10 +336,14 @@ public:
virtual llvm::Optional<CompilerType::IntegralTemplateArgument>
GetIntegralTemplateArgument(lldb::opaque_compiler_type_t type, size_t idx);
- //----------------------------------------------------------------------
// Dumping types
- //----------------------------------------------------------------------
+#ifndef NDEBUG
+ /// Convenience LLVM-style dump method for use in the debugger only.
+ LLVM_DUMP_METHOD virtual void
+ dump(lldb::opaque_compiler_type_t type) const = 0;
+#endif
+
virtual void DumpValue(lldb::opaque_compiler_type_t type,
ExecutionContext *exe_ctx, Stream *s,
lldb::Format format, const DataExtractor &data,
@@ -376,9 +365,7 @@ public:
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;
@@ -394,9 +381,7 @@ public:
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;
@@ -449,7 +434,8 @@ public:
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options) {
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj) {
return nullptr;
}
diff --git a/include/lldb/Symbol/UnwindPlan.h b/include/lldb/Symbol/UnwindPlan.h
index 7a5cf7f02a675..2b49acaafa041 100644
--- a/include/lldb/Symbol/UnwindPlan.h
+++ b/include/lldb/Symbol/UnwindPlan.h
@@ -1,9 +1,8 @@
//===-- UnwindPlan.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Symbol/UnwindTable.h b/include/lldb/Symbol/UnwindTable.h
index 061e7ddc0f99a..b4d7f0661d5b1 100644
--- a/include/lldb/Symbol/UnwindTable.h
+++ b/include/lldb/Symbol/UnwindTable.h
@@ -1,9 +1,8 @@
-//===-- Symtab.h ------------------------------------------------*- C++ -*-===//
+//===-- UnwindTable.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,7 +22,9 @@ namespace lldb_private {
class UnwindTable {
public:
- UnwindTable(ObjectFile &objfile);
+ /// Create an Unwind table using the data in the given module.
+ explicit UnwindTable(Module &module);
+
~UnwindTable();
lldb_private::DWARFCallFrameInfo *GetEHFrameInfo();
@@ -32,6 +33,7 @@ public:
lldb_private::CompactUnwindInfo *GetCompactUnwindInfo();
ArmUnwindInfo *GetArmUnwindInfo();
+ SymbolFile *GetSymbolFile();
lldb::FuncUnwindersSP GetFuncUnwindersContainingAddress(const Address &addr,
SymbolContext &sc);
@@ -63,7 +65,7 @@ private:
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
- ObjectFile &m_object_file;
+ Module &m_module;
collection m_unwinds;
bool m_initialized; // delay some initialization until ObjectFile is set up
diff --git a/include/lldb/Symbol/Variable.h b/include/lldb/Symbol/Variable.h
index 531312e635915..12daecfc04e63 100644
--- a/include/lldb/Symbol/Variable.h
+++ b/include/lldb/Symbol/Variable.h
@@ -1,26 +1,24 @@
//===-- Variable.h -----------------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Variable_h_
#define liblldb_Variable_h_
-#include <memory>
-#include <vector>
-
#include "lldb/Core/Mangled.h"
-#include "lldb/Core/RangeMap.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Utility/CompletionRequest.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/UserID.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private.h"
+#include <memory>
+#include <vector>
namespace lldb_private {
@@ -28,9 +26,7 @@ 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.
@@ -59,7 +55,7 @@ public:
// 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(ConstString name) const;
bool NameMatches(const RegularExpression &regex) const;
@@ -132,8 +128,8 @@ protected:
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) = delete;
+ Variable &operator=(const Variable &rhs) = delete;
};
} // namespace lldb_private
diff --git a/include/lldb/Symbol/VariableList.h b/include/lldb/Symbol/VariableList.h
index 6729a9c108a9b..54d27583cd7b2 100644
--- a/include/lldb/Symbol/VariableList.h
+++ b/include/lldb/Symbol/VariableList.h
@@ -1,9 +1,8 @@
//===-- VariableList.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@ namespace lldb_private {
class VariableList {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
// VariableList(const SymbolContext &symbol_context);
VariableList();
virtual ~VariableList();
@@ -39,10 +36,10 @@ public:
lldb::VariableSP RemoveVariableAtIndex(size_t idx);
- lldb::VariableSP FindVariable(const ConstString &name,
+ lldb::VariableSP FindVariable(ConstString name,
bool include_static_members = true);
- lldb::VariableSP FindVariable(const ConstString &name,
+ lldb::VariableSP FindVariable(ConstString name,
lldb::ValueType value_type,
bool include_static_members = true);
@@ -76,9 +73,7 @@ protected:
collection m_variables;
private:
- //------------------------------------------------------------------
// For VariableList only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(VariableList);
};
diff --git a/include/lldb/Symbol/VerifyDecl.h b/include/lldb/Symbol/VerifyDecl.h
index f4b61e6355ced..f412b94a7859a 100644
--- a/include/lldb/Symbol/VerifyDecl.h
+++ b/include/lldb/Symbol/VerifyDecl.h
@@ -1,9 +1,8 @@
//===-- VerifyDecl.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ABI.h b/include/lldb/Target/ABI.h
index 24fff1caf6c48..f254839fc975a 100644
--- a/include/lldb/Target/ABI.h
+++ b/include/lldb/Target/ABI.h
@@ -1,9 +1,8 @@
//===-- ABI.h ---------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,7 @@ public:
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 */
+ std::unique_ptr<uint8_t[]> data_up; /* host data pointer */
};
~ABI() override;
@@ -87,14 +86,12 @@ protected:
virtual lldb::ValueObjectSP
GetReturnValueObjectImpl(Thread &thread, llvm::Type &ir_type) const;
- //------------------------------------------------------------------
/// Request to get a Process shared pointer.
///
/// This ABI object may not have been created with a Process object,
/// or the Process object may no longer be alive. Be sure to handle
/// the case where the shared pointer returned does not have an
/// object inside it.
- //------------------------------------------------------------------
lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); }
public:
@@ -129,7 +126,7 @@ public:
virtual const RegisterInfo *GetRegisterInfoArray(uint32_t &count) = 0;
- bool GetRegisterInfoByName(const ConstString &name, RegisterInfo &info);
+ bool GetRegisterInfoByName(ConstString name, RegisterInfo &info);
bool GetRegisterInfoByKind(lldb::RegisterKind reg_kind, uint32_t reg_num,
RegisterInfo &info);
@@ -139,9 +136,7 @@ public:
static lldb::ABISP FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch);
protected:
- //------------------------------------------------------------------
// Classes that inherit from ABI can see and modify these
- //------------------------------------------------------------------
ABI(lldb::ProcessSP process_sp) {
if (process_sp.get())
m_process_wp = process_sp;
diff --git a/include/lldb/Target/DynamicLoader.h b/include/lldb/Target/DynamicLoader.h
index fe04f94aa31be..2bf3f32b5eef2 100644
--- a/include/lldb/Target/DynamicLoader.h
+++ b/include/lldb/Target/DynamicLoader.h
@@ -1,9 +1,8 @@
//===-- DynamicLoader.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,30 +22,17 @@
#include <stdint.h>
namespace lldb_private {
class ModuleList;
-}
-namespace lldb_private {
class Process;
-}
-namespace lldb_private {
class SectionList;
-}
-namespace lldb_private {
class Symbol;
-}
-namespace lldb_private {
class SymbolContext;
-}
-namespace lldb_private {
class SymbolContextList;
-}
-namespace lldb_private {
class Thread;
}
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h"
+/// \class DynamicLoader DynamicLoader.h "lldb/Target/DynamicLoader.h"
/// A plug-in interface definition class for dynamic loaders.
///
/// Dynamic loader plug-ins track image (shared library) loading and
@@ -63,64 +49,50 @@ namespace lldb_private {
/// 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 {
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
+ /// \param[in] process
/// The process for which to try and locate a dynamic loader
/// plug-in instance.
///
- /// @param[in] plugin_name
+ /// \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);
- //------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be inherited
/// from by the plug-in instance.
- //------------------------------------------------------------------
- virtual ~DynamicLoader() override;
+ ~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 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,
@@ -129,13 +101,11 @@ public:
/// DynamicLoader plug-in instances should return this value to ensure
/// consistent debug session behaviour.
///
- /// @return
+ /// \return
/// Returns \b true if the process should stop when images
/// change, \b false if the process should resume.
- //------------------------------------------------------------------
bool GetStopWhenImagesChange() const;
- //------------------------------------------------------------------
/// Set whether the process should stop when images change.
///
/// When images (executables and shared libraries) get loaded or unloaded,
@@ -144,54 +114,48 @@ public:
/// process stops when images change, but this can be overridden using this
/// function callback.
///
- /// @param[in] stop
+ /// \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
+ /// \param[in] stop_others
/// Whether the plan should be set to stop other threads.
///
- /// @return
+ /// \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
+ /// \param[in] original_symbol
/// The symbol for which we are finding equivalences.
///
- /// @param[in] module_list
+ /// \param[in] module_list
/// The set of modules in which to search.
///
- /// @param[out] equivalent_symbols
+ /// \param[out] equivalent_symbols
/// The equivalent symbol list - any equivalent symbols found are appended
/// to this list.
///
- /// @return
+ /// \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
@@ -199,13 +163,11 @@ public:
/// plug-ins to check any current dyld state to make sure it is an ok time
/// to load a shared library.
///
- /// @return
+ /// \return
/// \b true if it is currently ok to try and load a shared
/// library into the process, \b false otherwise.
- //------------------------------------------------------------------
virtual Status 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.
///
@@ -221,44 +183,40 @@ public:
/// not reliable enough -- we need to consult those function's hand-written
/// eh_frame information.
///
- /// @return
+ /// \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
+ /// \param[in] module
/// The module to query TLS data for.
///
- /// @param[in] thread
+ /// \param[in] thread
/// The specific thread to query TLS data for.
///
- /// @return
+ /// \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.
+ /// 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
@@ -273,27 +231,26 @@ public:
/// of the cache - or it may be able to return additional information about
/// the cache.
///
- /// @param[out] base_address
+ /// \param[out] base_address
/// The base address (load address) of the shared cache.
/// LLDB_INVALID_ADDRESS if it cannot be determined.
///
- /// @param[out] uuid
+ /// \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
+ /// \param[out] using_shared_cache
/// If this process is using a shared cache.
/// If unknown, eLazyBoolCalculate is returned.
///
- /// @param[out] private_shared_cache
+ /// \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
+ /// \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) {
@@ -305,22 +262,20 @@ public:
}
protected:
- //------------------------------------------------------------------
// 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();
- /// Updates the load address of every allocatable section in @p module.
+ /// Updates the load address of every allocatable section in \p module.
///
- /// @param module The module to traverse.
+ /// \param module The module to traverse.
///
- /// @param link_map_addr The virtual address of the link map for the @p
+ /// \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.
+ /// \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,
@@ -331,9 +286,9 @@ protected:
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.
+ /// Removes the loaded sections from the target in \p module.
///
- /// @param module The module to traverse.
+ /// \param module The module to traverse.
virtual void UnloadSections(const lldb::ModuleSP module);
// Utility method so base classes can share implementation of UnloadSections
@@ -354,9 +309,7 @@ protected:
void LoadOperatingSystemPlugin(bool flush);
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
Process
*m_process; ///< The process that this dynamic loader plug-in is tracking.
diff --git a/include/lldb/Target/ExecutionContext.h b/include/lldb/Target/ExecutionContext.h
index 167189c3a8375..0819357fab32d 100644
--- a/include/lldb/Target/ExecutionContext.h
+++ b/include/lldb/Target/ExecutionContext.h
@@ -1,9 +1,8 @@
//===-- ExecutionContext.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -41,8 +40,7 @@ namespace lldb_private {
/// a wide variety of functions that require execution contexts.
//===----------------------------------------------------------------------===//
-//----------------------------------------------------------------------
-/// @class ExecutionContextRef ExecutionContext.h
+/// \class ExecutionContextRef ExecutionContext.h
/// "lldb/Target/ExecutionContext.h"
/// A class that holds a weak reference to an execution context.
///
@@ -71,44 +69,32 @@ namespace lldb_private {
/// 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 references to these objects.
-//----------------------------------------------------------------------
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
@@ -119,10 +105,8 @@ public:
/// 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
@@ -132,34 +116,26 @@ public:
/// 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.
///
@@ -172,11 +148,9 @@ public:
/// a weak reference to the target's process, use the
/// ExecutionContextRef::SetContext() functions.
///
- /// @see ExecutionContextRef::SetContext(const lldb::TargetSP &, bool)
- //------------------------------------------------------------------
+ /// \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.
///
@@ -189,11 +163,9 @@ public:
/// a weak reference to the target, use the
/// ExecutionContextRef::SetContext() functions.
///
- /// @see ExecutionContextRef::SetContext(const lldb::ProcessSP &)
- //------------------------------------------------------------------
+ /// \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.
///
@@ -206,11 +178,9 @@ public:
/// a weak reference to the thread's process and target, use the
/// ExecutionContextRef::SetContext() functions.
///
- /// @see ExecutionContextRef::SetContext(const lldb::ThreadSP &)
- //------------------------------------------------------------------
+ /// \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.
///
@@ -223,8 +193,7 @@ public:
/// a weak reference to the frame's thread, process and target, use the
/// ExecutionContextRef::SetContext() functions.
///
- /// @see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
- //------------------------------------------------------------------
+ /// \see ExecutionContextRef::SetContext(const lldb::StackFrameSP &)
void SetFrameSP(const lldb::StackFrameSP &frame_sp);
void SetTargetPtr(Target *target, bool adopt_selected);
@@ -235,65 +204,51 @@ public:
void SetFramePtr(StackFrame *frame);
- //------------------------------------------------------------------
/// Get accessor that creates a strong reference from the weak target
/// reference contained in this object.
///
- /// @returns
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// 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() {
@@ -304,9 +259,7 @@ public:
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
@@ -316,8 +269,7 @@ protected:
///backing object changes
};
-//----------------------------------------------------------------------
-/// @class ExecutionContext ExecutionContext.h
+/// \class ExecutionContext ExecutionContext.h
/// "lldb/Target/ExecutionContext.h"
/// A class that contains an execution context.
///
@@ -336,35 +288,24 @@ protected:
/// for passing down to other functions that also require specific contexts.
/// They should NOT be used for long term storage, for long term storage use
/// ExecutionContextRef objects.
-//----------------------------------------------------------------------
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);
@@ -379,26 +320,22 @@ public:
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
+ /// \param[in] process
/// The process for this execution context.
///
- /// @param[in] thread
+ /// \param[in] thread
/// The thread for this execution context.
///
- /// @param[in] frame
+ /// \param[in] frame
/// The frame index for this execution context.
- //------------------------------------------------------------------
ExecutionContext(Process *process, Thread *thread = nullptr,
StackFrame *frame = nullptr);
@@ -410,12 +347,10 @@ public:
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;
@@ -426,7 +361,6 @@ public:
lldb::ByteOrder GetByteOrder() const;
- //------------------------------------------------------------------
/// Returns a pointer to the target object.
///
/// The returned pointer might be nullptr. Calling HasTargetScope(),
@@ -434,14 +368,12 @@ public:
/// validate this pointer so that this accessor can freely be used without
/// having to check for nullptr each time.
///
- /// @see ExecutionContext::HasTargetScope() const @see
+ /// \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(),
@@ -449,13 +381,11 @@ public:
/// pointer so that this accessor can freely be used without having to check
/// for nullptr each time.
///
- /// @see ExecutionContext::HasProcessScope() const @see
+ /// \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
@@ -463,187 +393,141 @@ public:
/// accessor can freely be used without having to check for nullptr each
/// time.
///
- /// @see ExecutionContext::HasThreadScope() const @see
+ /// \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
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \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
+ /// \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
- //------------------------------------------------------------------
+ /// \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.
///
@@ -651,10 +535,8 @@ public:
/// 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.
///
@@ -662,10 +544,8 @@ public:
/// 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.
///
@@ -673,13 +553,10 @@ public:
/// 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
diff --git a/include/lldb/Target/ExecutionContextScope.h b/include/lldb/Target/ExecutionContextScope.h
index 3e787584be0b0..0121ce61a1d77 100644
--- a/include/lldb/Target/ExecutionContextScope.h
+++ b/include/lldb/Target/ExecutionContextScope.h
@@ -1,9 +1,8 @@
//===-- ExecutionContextScope.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,8 @@
namespace lldb_private {
-//----------------------------------------------------------------------
/// @class ExecutionContextScope ExecutionContextScope.h
-/// "lldb/Symbol/ExecutionContextScope.h" Inherit from this if your object can
+/// "lldb/Target/ExecutionContextScope.h" Inherit from this if your object can
/// reconstruct its
/// execution context.
///
@@ -31,7 +29,6 @@ namespace lldb_private {
///
/// Objects that adhere to this protocol can reconstruct enough of a execution
/// context to allow functions that take a execution contexts to be called.
-//----------------------------------------------------------------------
class ExecutionContextScope {
public:
virtual ~ExecutionContextScope() {}
@@ -44,17 +41,15 @@ public:
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
+ /// \param[out] exe_ctx
/// A reference to an execution context object that gets filled
/// in.
- //------------------------------------------------------------------
virtual void CalculateExecutionContext(ExecutionContext &exe_ctx) = 0;
};
diff --git a/include/lldb/Target/InstrumentationRuntime.h b/include/lldb/Target/InstrumentationRuntime.h
index ba905cb8535df..4cee76d657bb8 100644
--- a/include/lldb/Target/InstrumentationRuntime.h
+++ b/include/lldb/Target/InstrumentationRuntime.h
@@ -1,9 +1,8 @@
//===-- InstrumentationRuntime.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/InstrumentationRuntimeStopInfo.h b/include/lldb/Target/InstrumentationRuntimeStopInfo.h
index 7c72c9524ecac..6c2a8ad87418a 100644
--- a/include/lldb/Target/InstrumentationRuntimeStopInfo.h
+++ b/include/lldb/Target/InstrumentationRuntimeStopInfo.h
@@ -1,9 +1,8 @@
//===-- InstrumentationRuntimeStopInfo.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/JITLoader.h b/include/lldb/Target/JITLoader.h
index 56f1417eddb0e..1bafd828f78e4 100644
--- a/include/lldb/Target/JITLoader.h
+++ b/include/lldb/Target/JITLoader.h
@@ -1,9 +1,8 @@
//===-- JITLoader.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,8 +16,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class JITLoader JITLoader.h "lldb/Target/JITLoader.h"
+/// \class JITLoader JITLoader.h "lldb/Target/JITLoader.h"
/// A plug-in interface definition class for JIT loaders.
///
/// Plugins of this kind listen for code generated at runtime in the target.
@@ -26,55 +24,42 @@ namespace lldb_private {
/// 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.
-//----------------------------------------------------------------------
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
+ /// \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);
~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 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;
protected:
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
Process *m_process;
};
diff --git a/include/lldb/Target/JITLoaderList.h b/include/lldb/Target/JITLoaderList.h
index 4b9d79bbfcabb..4cc3a9ecb91d1 100644
--- a/include/lldb/Target/JITLoaderList.h
+++ b/include/lldb/Target/JITLoaderList.h
@@ -1,9 +1,8 @@
//===-- JITLoaderList.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,11 +16,9 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class JITLoaderList JITLoaderList.h "lldb/Target/JITLoaderList.h"
+/// \class JITLoaderList JITLoaderList.h "lldb/Target/JITLoaderList.h"
///
/// Class used by the Process to hold a list of its JITLoaders.
-//----------------------------------------------------------------------
class JITLoaderList {
public:
JITLoaderList();
diff --git a/include/lldb/Target/Language.h b/include/lldb/Target/Language.h
index 27f40fd1ba837..6ea6029bdace0 100644
--- a/include/lldb/Target/Language.h
+++ b/include/lldb/Target/Language.h
@@ -1,10 +1,9 @@
//===-- Language.h ---------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -191,6 +190,14 @@ public:
virtual const char *GetLanguageSpecificTypeLookupHelp();
+ // If a language can have more than one possible name for a method, this
+ // function can be used to enumerate them. This is useful when doing name
+ // lookups.
+ virtual std::vector<ConstString>
+ GetMethodNameVariants(ConstString method_name) const {
+ return std::vector<ConstString>();
+ };
+
// 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
@@ -248,12 +255,17 @@ public:
static bool LanguageIsC(lldb::LanguageType language);
+ /// Equivalent to \c LanguageIsC||LanguageIsObjC||LanguageIsCPlusPlus.
+ static bool LanguageIsCFamily(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 std::set<lldb::LanguageType> GetSupportedLanguages();
+
static void GetLanguagesSupportingTypeSystems(
std::set<lldb::LanguageType> &languages,
std::set<lldb::LanguageType> &languages_for_expressions);
@@ -262,9 +274,7 @@ public:
GetLanguagesSupportingREPLs(std::set<lldb::LanguageType> &languages);
protected:
- //------------------------------------------------------------------
// Classes that inherit from Language can see and modify these
- //------------------------------------------------------------------
Language();
diff --git a/include/lldb/Target/LanguageRuntime.h b/include/lldb/Target/LanguageRuntime.h
index 2a2f47b853591..73c8dfa3874db 100644
--- a/include/lldb/Target/LanguageRuntime.h
+++ b/include/lldb/Target/LanguageRuntime.h
@@ -1,10 +1,9 @@
//===-- LanguageRuntime.h ---------------------------------------------------*-
// C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,6 +16,7 @@
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObject.h"
#include "lldb/Expression/LLVMUserExpression.h"
+#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/lldb-private.h"
#include "lldb/lldb-public.h"
@@ -116,9 +116,8 @@ public:
bool catch_bp, bool throw_bp,
bool is_internal = false);
- static Breakpoint::BreakpointPreconditionSP
- CreateExceptionPrecondition(lldb::LanguageType language, bool catch_bp,
- bool throw_bp);
+ static lldb::BreakpointPreconditionSP
+ GetExceptionPrecondition(lldb::LanguageType language, bool throw_bp);
virtual lldb::ValueObjectSP GetExceptionObjectForThread(
lldb::ThreadSP thread_sp) {
@@ -134,17 +133,32 @@ public:
Target &GetTargetRef() { return m_process->GetTarget(); }
+ virtual DeclVendor *GetDeclVendor() { return nullptr; }
+
virtual lldb::BreakpointResolverSP
CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp, bool throw_bp) = 0;
- virtual lldb::SearchFilterSP CreateExceptionSearchFilter();
+ virtual lldb::SearchFilterSP CreateExceptionSearchFilter() {
+ return m_process->GetTarget().GetSearchFilterForModule(nullptr);
+ }
virtual bool GetTypeBitSize(const CompilerType &compiler_type,
uint64_t &size) {
return false;
}
- virtual bool IsRuntimeSupportValue(ValueObject &valobj) { return false; }
+ virtual void SymbolsDidLoad(const ModuleList &module_list) { return; }
+
+ virtual lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
+ bool stop_others) = 0;
+
+ /// Identify whether a name is a runtime value that should not be hidden by
+ /// from the user interface.
+ virtual bool IsWhitelistedRuntimeValue(ConstString name) { return false; }
+
+ virtual llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) {
+ return llvm::None;
+ }
virtual void ModulesDidLoad(const ModuleList &module_list) {}
@@ -162,10 +176,18 @@ public:
return false;
}
+ // Given the name of a runtime symbol (e.g. in Objective-C, an 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(ConstString name) {
+ return LLDB_INVALID_ADDRESS;
+ }
+
+ virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
+ static char ID;
+
protected:
- //------------------------------------------------------------------
// Classes that inherit from LanguageRuntime can see and modify these
- //------------------------------------------------------------------
LanguageRuntime(Process *process);
Process *m_process;
diff --git a/include/lldb/Target/Memory.h b/include/lldb/Target/Memory.h
index d5e6c105f76d3..e62b8ef9c773e 100644
--- a/include/lldb/Target/Memory.h
+++ b/include/lldb/Target/Memory.h
@@ -1,33 +1,26 @@
//===-- Memory.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_Memory_h_
#define liblldb_Memory_h_
+#include "lldb/Utility/RangeMap.h"
+#include "lldb/lldb-private.h"
#include <map>
#include <mutex>
#include <vector>
-
-#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();
@@ -54,9 +47,7 @@ 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
@@ -114,16 +105,12 @@ protected:
RangeVector<lldb::addr_t, uint32_t> m_reserved_blocks;
};
-//----------------------------------------------------------------------
// 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();
@@ -141,9 +128,7 @@ protected:
AllocatedBlockSP AllocatePage(uint32_t byte_size, uint32_t permissions,
uint32_t chunk_size, Status &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;
diff --git a/include/lldb/Target/MemoryHistory.h b/include/lldb/Target/MemoryHistory.h
index cb3e900533576..501751c55e80a 100644
--- a/include/lldb/Target/MemoryHistory.h
+++ b/include/lldb/Target/MemoryHistory.h
@@ -1,10 +1,9 @@
//===-- MemoryHistory.h ---------------------------------------------------*-
//C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/MemoryRegionInfo.h b/include/lldb/Target/MemoryRegionInfo.h
index a57c4678bb370..5cab2efea77c9 100644
--- a/include/lldb/Target/MemoryRegionInfo.h
+++ b/include/lldb/Target/MemoryRegionInfo.h
@@ -1,19 +1,18 @@
//===-- MemoryRegionInfo.h ---------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef lldb_MemoryRegionInfo_h
#define lldb_MemoryRegionInfo_h
-#include "lldb/Core/RangeMap.h"
-#include "llvm/Support/FormatProviders.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/RangeMap.h"
+#include "llvm/Support/FormatProviders.h"
namespace lldb_private {
class MemoryRegionInfo {
@@ -45,7 +44,7 @@ public:
OptionalBool GetMapped() const { return m_mapped; }
- const ConstString &GetName() const { return m_name; }
+ ConstString GetName() const { return m_name; }
void SetReadable(OptionalBool val) { m_read = val; }
@@ -65,10 +64,8 @@ public:
void SetBlocksize(lldb::offset_t blocksize) { m_blocksize = blocksize; }
- //----------------------------------------------------------------------
// 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)
@@ -80,10 +77,8 @@ public:
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;
diff --git a/include/lldb/Target/ModuleCache.h b/include/lldb/Target/ModuleCache.h
index a060937e0614a..1196169113936 100644
--- a/include/lldb/Target/ModuleCache.h
+++ b/include/lldb/Target/ModuleCache.h
@@ -1,9 +1,8 @@
//===-- ModuleCache.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,8 +25,7 @@ namespace lldb_private {
class Module;
class UUID;
-//----------------------------------------------------------------------
-/// @class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h"
+/// \class ModuleCache ModuleCache.h "lldb/Target/ModuleCache.h"
/// A module cache class.
///
/// Caches locally modules that are downloaded from remote targets. Each
@@ -45,7 +43,6 @@ class UUID;
/// /tmp/lldb/remote-
/// linux/.cache/30C94DC6-6A1F-E951-80C3-D68D2B89E576-D5AE213C/libc.so.6
/// Sysroot view: /tmp/lldb/remote-linux/ubuntu/lib/x86_64-linux-gnu/libc.so.6
-//----------------------------------------------------------------------
class ModuleCache {
public:
diff --git a/include/lldb/Target/OperatingSystem.h b/include/lldb/Target/OperatingSystem.h
index 4d73bb3906ee6..c75d1ca2e5f48 100644
--- a/include/lldb/Target/OperatingSystem.h
+++ b/include/lldb/Target/OperatingSystem.h
@@ -1,10 +1,9 @@
//===-- OperatingSystem.h ----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,8 +16,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h"
+/// \class OperatingSystem OperatingSystem.h "lldb/Target/OperatingSystem.h"
/// A plug-in interface definition class for halted OS helpers.
///
/// Halted OS plug-ins can be used by any process to locate and create
@@ -26,36 +24,29 @@ namespace lldb_private {
/// 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 {
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
+ /// \param[in] process
/// The process for which to try and locate a halted OS
/// plug-in instance.
///
- /// @param[in] plugin_name
+ /// \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;
@@ -75,9 +66,7 @@ public:
virtual bool IsOperatingSystemPluginThread(const lldb::ThreadSP &thread_sp);
protected:
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
Process
*m_process; ///< The process that this dynamic loader plug-in is tracking.
private:
diff --git a/include/lldb/Target/PathMappingList.h b/include/lldb/Target/PathMappingList.h
index 29e6ef191e275..d1759667f1f5d 100644
--- a/include/lldb/Target/PathMappingList.h
+++ b/include/lldb/Target/PathMappingList.h
@@ -1,9 +1,8 @@
//===-- PathMappingList.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ public:
typedef void (*ChangedCallback)(const PathMappingList &path_list,
void *baton);
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
PathMappingList();
PathMappingList(ChangedCallback callback, void *callback_baton);
@@ -35,7 +32,7 @@ public:
const PathMappingList &operator=(const PathMappingList &rhs);
- void Append(const ConstString &path, const ConstString &replacement,
+ void Append(ConstString path, ConstString replacement,
bool notify);
void Append(const PathMappingList &rhs, bool notify);
@@ -52,43 +49,40 @@ public:
bool GetPathsAtIndex(uint32_t idx, ConstString &path,
ConstString &new_path) const;
- void Insert(const ConstString &path, const ConstString &replacement,
+ void Insert(ConstString path, ConstString replacement,
uint32_t insert_idx, bool notify);
bool Remove(size_t index, bool notify);
- bool Remove(const ConstString &path, bool notify);
+ bool Remove(ConstString path, bool notify);
- bool Replace(const ConstString &path, const ConstString &replacement,
+ bool Replace(ConstString path, ConstString replacement,
bool notify);
- bool Replace(const ConstString &path, const ConstString &replacement,
+ bool Replace(ConstString path, ConstString replacement,
uint32_t index, bool notify);
- bool RemapPath(const ConstString &path, ConstString &new_path) const;
+ bool RemapPath(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
+ /// \param[in] path
/// The original source file path to try and remap.
///
- /// @param[out] new_path
+ /// \param[out] new_path
/// The newly remapped filespec that is may or may not exist.
///
- /// @return
+ /// \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 FileSpec &file, FileSpec &fixed) const;
- //------------------------------------------------------------------
/// Finds a source file given a file spec using the path remappings.
///
/// Tries to resolve \a orig_spec by checking the path remappings.
@@ -97,20 +91,19 @@ public:
/// 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
+ /// \param[in] orig_spec
/// The original source file path to try and remap.
///
- /// @param[out] new_spec
+ /// \param[out] new_spec
/// The newly remapped filespec that is guaranteed to exist.
///
- /// @return
+ /// \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 FindIndexForPath(ConstString path) const;
uint32_t GetModificationID() const { return m_mod_id; }
@@ -120,9 +113,9 @@ protected:
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
- iterator FindIteratorForPath(const ConstString &path);
+ iterator FindIteratorForPath(ConstString path);
- const_iterator FindIteratorForPath(const ConstString &path) const;
+ const_iterator FindIteratorForPath(ConstString path) const;
collection m_pairs;
ChangedCallback m_callback;
diff --git a/include/lldb/Target/Platform.h b/include/lldb/Target/Platform.h
index 3dbeef73f0aba..3ba58c0ec741e 100644
--- a/include/lldb/Target/Platform.h
+++ b/include/lldb/Target/Platform.h
@@ -1,9 +1,8 @@
//===-- Platform.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,12 +23,17 @@
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Timeout.h"
+#include "lldb/Utility/UserIDResolver.h"
#include "lldb/lldb-private-forward.h"
#include "lldb/lldb-public.h"
#include "llvm/Support/VersionTuple.h"
namespace lldb_private {
+class ProcessInstanceInfo;
+class ProcessInstanceInfoList;
+class ProcessInstanceInfoMatch;
+
class ModuleCache;
enum MmapFlags { eMmapFlagsPrivate = 1, eMmapFlagsAnon = 2 };
@@ -49,32 +53,26 @@ public:
typedef std::shared_ptr<PlatformProperties> PlatformPropertiesSP;
typedef llvm::SmallVector<lldb::addr_t, 6> MmapArgList;
-//----------------------------------------------------------------------
-/// @class Platform Platform.h "lldb/Target/Platform.h"
+/// \class Platform Platform.h "lldb/Target/Platform.h"
/// A plug-in interface definition class for debug platform that
/// includes many platform abilities such as:
-/// @li getting platform information such as supported architectures,
+/// \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
-//----------------------------------------------------------------------
+/// \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();
@@ -83,7 +81,6 @@ public:
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
@@ -93,7 +90,6 @@ public:
///
/// 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
@@ -104,38 +100,33 @@ public:
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 Find(ConstString name);
- static lldb::PlatformSP Create(const ConstString &name, Status &error);
+ static lldb::PlatformSP Create(ConstString name, Status &error);
static lldb::PlatformSP Create(const ArchSpec &arch,
ArchSpec *platform_arch_ptr, Status &error);
- //------------------------------------------------------------------------
/// Augments the triple either with information from platform or the host
/// system (if platform is null).
- //------------------------------------------------------------------------
static ArchSpec GetAugmentedArchSpec(Platform *platform,
llvm::StringRef triple);
- //------------------------------------------------------------------
/// 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
+ /// \param[in] process
/// The process for which to try and locate a platform
/// plug-in instance.
///
- /// @param[in] plugin_name
+ /// \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);
+ // FindPlugin (Process *process, 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.
///
@@ -148,15 +139,13 @@ public:
/// application bundles or executable wrappers can also be inspected for the
/// actual application binary within the bundle that should be used.
///
- /// @return
+ /// \return
/// Returns \b true if this Platform plug-in was able to find
/// a suitable executable, \b false otherwise.
- //------------------------------------------------------------------
virtual Status 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
@@ -164,7 +153,7 @@ public:
/// support symbol files that are bundles and know how to extract the right
/// symbol file given a bundle.
///
- /// @param[in] target
+ /// \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
@@ -177,7 +166,7 @@ public:
/// 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
+ /// \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:
@@ -196,24 +185,20 @@ public:
/// a symbol file, or resolve an symbol file in a
/// symbol file bundle.
///
- /// @param[out] sym_file
+ /// \param[out] sym_file
/// The resolved symbol file spec if the returned error
/// indicates success.
///
- /// @return
+ /// \return
/// Returns an error that describes success or failure.
- //------------------------------------------------------------------
virtual Status 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
@@ -221,7 +206,6 @@ public:
/// 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 llvm::VersionTuple GetOSVersion(Process *process = nullptr);
bool SetOSVersion(llvm::VersionTuple os_version);
@@ -239,23 +223,19 @@ public:
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) {
@@ -277,20 +257,30 @@ public:
virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir);
- virtual const char *GetUserName(uint32_t uid);
+ /// Retrieve the system include directories on this platform for the
+ /// given language.
+ ///
+ /// \param[in] lang
+ /// The language for which the include directories should be queried.
+ ///
+ /// \param[out] directories
+ /// The include directories for this system.
+ virtual std::vector<std::string>
+ GetSystemIncludeDirectories(lldb::LanguageType lang) {
+ return {};
+ }
- virtual const char *GetGroupName(uint32_t gid);
+ virtual UserIDResolver &GetUserIDResolver() = 0;
- //------------------------------------------------------------------
/// 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
+ /// \param[in] platform_file
/// The platform file path to locate and cache locally.
///
- /// @param[in] uuid_ptr
+ /// \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
@@ -299,25 +289,22 @@ public:
/// file queries to ensure we are finding the correct file, not
/// just a file at the correct path.
///
- /// @param[out] local_file
+ /// \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
+ /// \return
/// An error object.
- //------------------------------------------------------------------
virtual Status 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);
@@ -335,70 +322,56 @@ public:
virtual Status DisconnectRemote();
- //------------------------------------------------------------------
/// Get the platform's supported architectures in the order in which they
/// should be searched.
///
- /// @param[in] idx
+ /// \param[in] idx
/// A zero based architecture index
///
- /// @param[out] arch
+ /// \param[out] arch
/// A copy of the architecture at index if the return value is
/// \b true.
///
- /// @return
+ /// \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 Status 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
- //------------------------------------------------------------------
+ /// environment variable replacement, and whatever other
+ /// argument magic the platform defines as part of its typical
+ /// user experience
virtual Status ShellExpandArguments(ProcessLaunchInfo &launch_info);
- //------------------------------------------------------------------
/// Kill process on a platform.
- //------------------------------------------------------------------
virtual Status 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
@@ -411,7 +384,6 @@ public:
lldb_private::Target *target,
lldb_private::Status &error);
- //------------------------------------------------------------------
/// Attach to an existing process using a process ID.
///
/// Each platform subclass needs to implement this function and attempt to
@@ -420,15 +392,14 @@ public:
/// attached to the process, or an empty shared pointer with an appropriate
/// error.
///
- /// @param[in] pid
+ /// \param[in] pid
/// The process ID that we should attempt to attach to.
///
- /// @return
+ /// \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
@@ -436,7 +407,6 @@ public:
// use existing one
Status &error) = 0;
- //------------------------------------------------------------------
/// Attach to an existing process by process name.
///
/// This function is not meant to be overridden by Process subclasses. It
@@ -445,38 +415,31 @@ public:
/// the attach. If DoAttach returns \b true, then Process::DidAttach() will
/// be called.
///
- /// @param[in] process_name
+ /// \param[in] process_name
/// A process name to match against the current process list.
///
- /// @return
+ /// \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,
// Status &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();
@@ -503,11 +466,9 @@ public:
m_os_version_set_while_connected = m_system_arch.IsValid();
}
- //---------------------------------------------------------------------------
/// If the triple contains not specify the vendor, os, and environment
/// parts, we "augment" these using information from the platform and return
/// the resulting ArchSpec object.
- //---------------------------------------------------------------------------
ArchSpec GetAugmentedArchSpec(llvm::StringRef triple);
// Used for column widths
@@ -516,13 +477,13 @@ public:
// Used for column widths
size_t GetMaxGroupIDNameLength() const { return m_max_gid_name_len; }
- const ConstString &GetSDKRootDirectory() const { return m_sdk_sysroot; }
+ ConstString GetSDKRootDirectory() const { return m_sdk_sysroot; }
- void SetSDKRootDirectory(const ConstString &dir) { m_sdk_sysroot = dir; }
+ void SetSDKRootDirectory(ConstString dir) { m_sdk_sysroot = dir; }
- const ConstString &GetSDKBuild() const { return m_sdk_build; }
+ ConstString GetSDKBuild() const { return m_sdk_build; }
- void SetSDKBuild(const ConstString &sdk_build) { m_sdk_build = sdk_build; }
+ void SetSDKBuild(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
@@ -579,7 +540,7 @@ public:
virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset,
const void *src, uint64_t src_len, Status &error) {
error.SetErrorStringWithFormat(
- "Platform::ReadFile() is not supported in the %s platform",
+ "Platform::WriteFile() is not supported in the %s platform",
GetName().GetCString());
return -1;
}
@@ -593,7 +554,6 @@ public:
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
@@ -602,10 +562,10 @@ public:
/// application/framework/shared library, then this extra registration can
/// be done.
///
- /// @param[in] src
+ /// \param[in] src
/// The source file/directory to install on the remote system.
///
- /// @param[in] dst
+ /// \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
@@ -614,9 +574,8 @@ public:
/// platform working directory will be prepended to the relative
/// directory.
///
- /// @return
+ /// \return
/// An error object that describes anything that went wrong.
- //----------------------------------------------------------------------
virtual Status Install(const FileSpec &src, const FileSpec &dst);
virtual Environment GetEnvironment();
@@ -690,9 +649,8 @@ public:
virtual const lldb::UnixSignalsSP &GetRemoteUnixSignals();
- const lldb::UnixSignalsSP &GetUnixSignals();
+ lldb::UnixSignalsSP GetUnixSignals();
- //------------------------------------------------------------------
/// Locate a queue name given a thread's qaddr
///
/// On a system using libdispatch ("Grand Central Dispatch") style queues, a
@@ -702,23 +660,21 @@ public:
/// dispatch_qaddr this Platform method will locate the queue name and
/// provide that.
///
- /// @param[in] process
+ /// \param[in] process
/// A process is required for reading memory.
///
- /// @param[in] dispatch_qaddr
+ /// \param[in] dispatch_qaddr
/// The dispatch_qaddr for this thread.
///
- /// @return
+ /// \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
@@ -728,22 +684,20 @@ public:
/// dispatch_qaddr this Platform method will locate the queue ID and provide
/// that.
///
- /// @param[in] process
+ /// \param[in] process
/// A process is required for reading memory.
///
- /// @param[in] dispatch_qaddr
+ /// \param[in] dispatch_qaddr
/// The dispatch_qaddr for this thread.
///
- /// @return
+ /// \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
@@ -761,105 +715,96 @@ public:
/// signal handler routines as needed. For most Unix platforms, add
/// _sigtramp.
///
- /// @return
+ /// \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
+ /// \param[in] basename
/// The basename of the executable to locate in the current
/// platform.
///
- /// @return
+ /// \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
+ /// \param[in] process
/// The process to load the image.
///
- /// @param[in] local_file
+ /// \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
+ /// \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
+ /// \param[out] error
/// An error object that gets filled in with any errors that
/// might occur when trying to load the shared library.
///
- /// @return
+ /// \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::Status &error);
- //------------------------------------------------------------------
/// Load a shared library specified by base name into this process,
/// looking by hand along a set of paths.
///
- /// @param[in] process
+ /// \param[in] process
/// The process to load the image.
///
- /// @param[in] library_name
+ /// \param[in] library_name
/// The name of the library to look for. If library_name is an
/// absolute path, the basename will be extracted and searched for
/// along the paths. This emulates the behavior of the loader when
/// given an install name and a set (e.g. DYLD_LIBRARY_PATH provided) of
/// alternate paths.
///
- /// @param[in] path_list
+ /// \param[in] path_list
/// The list of paths to use to search for the library. First
/// match wins.
///
- /// @param[out] error
+ /// \param[out] error
/// An error object that gets filled in with any errors that
/// might occur when trying to load the shared library.
///
- /// @param[out] loaded_path
+ /// \param[out] loaded_path
/// If non-null, the path to the dylib that was successfully loaded
/// is stored in this path.
///
- /// @return
+ /// \return
/// A token that represents the shared library which can be
/// passed to UnloadImage. A value of
/// LLDB_INVALID_IMAGE_TOKEN will be returned if the shared
/// library can't be opened.
- //------------------------------------------------------------------
uint32_t LoadImageUsingPaths(lldb_private::Process *process,
const lldb_private::FileSpec &library_name,
const std::vector<std::string> &paths,
@@ -875,22 +820,20 @@ public:
virtual Status 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
+ /// \param[in] debugger
/// The debugger used for the connect.
///
- /// @param[out] error
+ /// \param[out] error
/// If an error occurred during the connect then this object will
/// contain the error message.
///
- /// @return
+ /// \return
/// The number of processes we are successfully connected to.
- //------------------------------------------------------------------
virtual size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Status &error);
@@ -917,8 +860,6 @@ protected:
// 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;
@@ -932,7 +873,6 @@ protected:
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
@@ -944,71 +884,8 @@ protected:
/// 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();
- }
-
Status GetCachedExecutable(ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr,
Platform &remote_platform);
@@ -1072,14 +949,12 @@ public:
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())
diff --git a/include/lldb/Target/Process.h b/include/lldb/Target/Process.h
index be72b9a9c747a..f85069ea09067 100644
--- a/include/lldb/Target/Process.h
+++ b/include/lldb/Target/Process.h
@@ -1,9 +1,8 @@
//===-- Process.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,14 +28,13 @@
#include "lldb/Core/ThreadSafeValue.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Host/HostThread.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Host/ProcessRunLock.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Symbol/ObjectFile.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/Utility/ArchSpec.h"
@@ -44,9 +42,11 @@
#include "lldb/Utility/Event.h"
#include "lldb/Utility/Listener.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StructuredData.h"
#include "lldb/Utility/TraceOptions.h"
+#include "lldb/Utility/UserIDResolver.h"
#include "lldb/lldb-private.h"
#include "llvm/ADT/ArrayRef.h"
@@ -56,9 +56,7 @@ namespace lldb_private {
template <typename B, typename S> struct Range;
-//----------------------------------------------------------------------
// ProcessProperties
-//----------------------------------------------------------------------
class ProcessProperties : public Properties {
public:
// Pass nullptr for "process" if the ProcessProperties are to be the global
@@ -68,36 +66,22 @@ public:
~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;
-
bool GetStopOnExec() const;
+ std::chrono::seconds GetUtilityExpressionTimeout() const;
protected:
static void OptionValueChangedCallback(void *baton,
@@ -108,68 +92,9 @@ protected:
typedef std::shared_ptr<ProcessProperties> ProcessPropertiesSP;
-//----------------------------------------------------------------------
-// ProcessInstanceInfo
-//
-// Describes an existing process and any discoverable information that pertains
-// to that process.
-//----------------------------------------------------------------------
-class ProcessInstanceInfo : public ProcessInfo {
-public:
- 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; }
-
- uint32_t GetEffectiveGroupID() const { return m_egid; }
-
- 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; }
-
- 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;
-
-protected:
- uint32_t m_euid;
- uint32_t m_egid;
- lldb::pid_t m_parent_pid;
-};
-
-//----------------------------------------------------------------------
// ProcessAttachInfo
//
// Describes any information that is required to attach to a process.
-//----------------------------------------------------------------------
class ProcessAttachInfo : public ProcessInstanceInfo {
public:
@@ -299,94 +224,6 @@ public:
lldb_private::LazyBool disable_aslr;
};
-//----------------------------------------------------------------------
-// ProcessInstanceInfoMatch
-//
-// A class to help matching one ProcessInstanceInfo to another.
-//----------------------------------------------------------------------
-
-class ProcessInstanceInfoMatch {
-public:
- ProcessInstanceInfoMatch()
- : m_match_info(), m_name_match_type(NameMatch::Ignore),
- m_match_all_users(false) {}
-
- ProcessInstanceInfoMatch(const char *process_name,
- NameMatch 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,
- FileSpec::Style::native);
- }
-
- ProcessInstanceInfo &GetProcessInfo() { return m_match_info; }
-
- const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; }
-
- bool GetMatchAllUsers() const { return m_match_all_users; }
-
- void SetMatchAllUsers(bool b) { m_match_all_users = b; }
-
- NameMatch GetNameMatchType() const { return m_name_match_type; }
-
- void SetNameMatchType(NameMatch name_match_type) {
- m_name_match_type = name_match_type;
- }
-
- bool NameMatches(const char *process_name) const;
-
- bool Matches(const ProcessInstanceInfo &proc_info) const;
-
- bool MatchAllProcesses() const;
- void Clear();
-
-protected:
- ProcessInstanceInfo m_match_info;
- NameMatch m_name_match_type;
- bool m_match_all_users;
-};
-
-class ProcessInstanceInfoList {
-public:
- ProcessInstanceInfoList() = default;
-
- void Clear() { m_infos.clear(); }
-
- size_t GetSize() { return m_infos.size(); }
-
- void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }
-
- const char *GetProcessNameAtIndex(size_t idx) {
- return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
- }
-
- 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;
-};
-
// 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.)
@@ -511,10 +348,8 @@ inline bool operator!=(const ProcessModID &lhs, const ProcessModID &rhs) {
return (!lhs.StopIDEqual(rhs) || !lhs.MemoryIDEqual(rhs));
}
-//----------------------------------------------------------------------
-/// @class Process Process.h "lldb/Target/Process.h"
+/// \class Process Process.h "lldb/Target/Process.h"
/// A plug-in interface definition class for debugging a process.
-//----------------------------------------------------------------------
class Process : public std::enable_shared_from_this<Process>,
public ProcessProperties,
public UserID,
@@ -530,9 +365,7 @@ class Process : public std::enable_shared_from_this<Process>,
friend class ThreadList;
public:
- //------------------------------------------------------------------
/// Broadcaster event bits definitions.
- //------------------------------------------------------------------
enum {
eBroadcastBitStateChanged = (1 << 0),
eBroadcastBitInterrupt = (1 << 1),
@@ -548,9 +381,7 @@ public:
eBroadcastInternalStateControlResume = (1 << 2)
};
- //------------------------------------------------------------------
/// Process warning types.
- //------------------------------------------------------------------
enum Warnings { eWarningsOptimization = 1 };
typedef Range<lldb::addr_t, lldb::addr_t> LoadRange;
@@ -570,14 +401,11 @@ public:
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
+/// \see RegisterNotificationCallbacks (const Notifications&) @see
/// UnregisterNotificationCallbacks (const Notifications&)
-//------------------------------------------------------------------
-#ifndef SWIG
typedef struct {
void *baton;
void (*initialize)(void *baton, Process *process);
@@ -594,9 +422,9 @@ public:
~ProcessEventData() override;
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
- const ConstString &GetFlavor() const override;
+ ConstString GetFlavor() const override;
lldb::ProcessSP GetProcessSP() const { return m_process_wp.lock(); }
@@ -662,27 +490,20 @@ public:
DISALLOW_COPY_AND_ASSIGN(ProcessEventData);
};
-#endif // SWIG
- //------------------------------------------------------------------
/// 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();
@@ -691,7 +512,6 @@ public:
static const ProcessPropertiesSP &GetGlobalProperties();
- //------------------------------------------------------------------
/// Find a Process plug-in that can debug \a module using the currently
/// selected architecture.
///
@@ -699,22 +519,20 @@ public:
/// Process plug-in interface and returns the first instance that can debug
/// the file.
///
- /// @param[in] module_sp
+ /// \param[in] module_sp
/// The module shared pointer that this process will debug.
///
- /// @param[in] plugin_name
+ /// \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 ()
- //------------------------------------------------------------------
+ /// \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 ().
///
@@ -725,7 +543,6 @@ public:
/// 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,
@@ -738,38 +555,31 @@ public:
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
+ /// \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
+ /// \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.
///
@@ -778,14 +588,12 @@ public:
///
/// (lldb) process command <args>
///
- /// @return
+ /// \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
@@ -798,14 +606,13 @@ public:
/// launching. If DoLaunch returns \b true, then Process::DidLaunch() will
/// be called.
///
- /// @param[in] launch_info
+ /// \param[in] launch_info
/// Details regarding the environment, STDIN/STDOUT/STDERR
/// redirection, working path, etc. related to the requested launch.
///
- /// @return
+ /// \return
/// An error object. Call GetID() to get the process ID if
/// the error object is success.
- //------------------------------------------------------------------
virtual Status Launch(ProcessLaunchInfo &launch_info);
virtual Status LoadCore();
@@ -818,7 +625,6 @@ public:
return error;
}
- //------------------------------------------------------------------
// FUTURE WORK: GetLoadImageUtilityFunction are the first use we've
// had of having other plugins cache data in the Process. This is handy for
// long-living plugins - like the Platform - which manage interactions whose
@@ -833,27 +639,23 @@ public:
// whether the registree should be notified of the Process' demise.
//
// We are postponing designing this till we have at least a second use case.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Get the cached UtilityFunction that assists in loading binary images
/// into the process.
///
- /// @param[in] platform
+ /// \param[in] platform
/// The platform fetching the UtilityFunction.
- /// @param[in] factory
+ /// \param[in] factory
/// A function that will be called only once per-process in a
/// thread-safe way to create the UtilityFunction if it has not
/// been initialized yet.
///
- /// @return
+ /// \return
/// The cached utility function or null if the platform is not the
/// same as the target's platform.
- //------------------------------------------------------------------
UtilityFunction *GetLoadImageUtilityFunction(
Platform *platform,
llvm::function_ref<std::unique_ptr<UtilityFunction>()> factory);
- //------------------------------------------------------------------
/// Get the dynamic loader plug-in for this process.
///
/// The default action is to let the DynamicLoader plug-ins check the main
@@ -861,29 +663,24 @@ public:
/// 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();
+ // \return
+ // A data extractor containing the contents of the AUXV data.
+ virtual DataExtractor 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
+ /// \return
/// The number of shared libraries that were loaded
- //------------------------------------------------------------------
virtual size_t LoadModules() { return 0; }
virtual size_t LoadModules(LoadedModuleInfoList &) { return 0; }
@@ -892,16 +689,13 @@ protected:
virtual JITLoaderList &GetJITLoaders();
public:
- //------------------------------------------------------------------
/// Get the system runtime plug-in for this process.
///
- /// @return
+ /// \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
@@ -910,36 +704,32 @@ public:
/// char *) will be called to actually do the attach. If DoAttach returns \b
/// true, then Process::DidAttach() will be called.
///
- /// @param[in] pid
+ /// \param[in] pid
/// The process ID that we should attempt to attach to.
///
- /// @return
+ /// \return
/// Returns \a pid if attaching was successful, or
/// LLDB_INVALID_PROCESS_ID if attaching fails.
- //------------------------------------------------------------------
virtual Status Attach(ProcessAttachInfo &attach_info);
- //------------------------------------------------------------------
/// Attach to a remote system via a URL
///
- /// @param[in] strm
+ /// \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
+ /// \param[in] remote_url
/// The URL format that we are connecting to.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status 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
@@ -948,14 +738,12 @@ public:
/// opposed to the DynamicLoader interface) to ensure that remote debugging
/// can take advantage of this functionality.
///
- /// @return
+ /// \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
@@ -968,49 +756,39 @@ public:
/// 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
+/// \param[in] callbacks
/// A structure that contains the notification baton and
/// callback functions.
///
-/// @see Process::Notifications
-//------------------------------------------------------------------
-#ifndef SWIG
+/// \see Process::Notifications
void RegisterNotificationCallbacks(const Process::Notifications &callbacks);
-#endif
-//------------------------------------------------------------------
/// 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
+/// \param[in] callbacks
/// A structure that contains the notification baton and
/// callback functions.
///
-/// @return
+/// \return
/// Returns \b true if the notification callbacks were
/// successfully removed from the process, \b false otherwise.
///
-/// @see Process::Notifications
-//------------------------------------------------------------------
-#ifndef SWIG
+/// \see Process::Notifications
bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks);
-#endif
//==================================================================
// Built in Process Control functions
//==================================================================
- //------------------------------------------------------------------
/// Resumes all of a process's threads as configured using the Thread run
/// control functions.
///
@@ -1030,18 +808,16 @@ public:
/// use PrivateResume (though you should only do that from inside the
/// Process class.
///
- /// @return
+ /// \return
/// Returns an error object.
///
- /// @see Thread:Resume()
- /// @see Thread:Step()
- /// @see Thread:Suspend()
- //------------------------------------------------------------------
+ /// \see Thread:Resume()
+ /// \see Thread:Step()
+ /// \see Thread:Suspend()
Status Resume();
Status ResumeSynchronous(Stream *stream);
- //------------------------------------------------------------------
/// Halts a running process.
///
/// This function is not meant to be overridden by Process subclasses. If
@@ -1049,39 +825,35 @@ public:
/// GetInterrupted will be broadcast. If false, we will halt the process
/// with no events generated by the halt.
///
- /// @param[in] clear_thread_plans
+ /// \param[in] clear_thread_plans
/// If true, when the process stops, clear all thread plans.
///
- /// @param[in] use_run_lock
+ /// \param[in] use_run_lock
/// Whether to release the run lock after the stop.
///
- /// @return
+ /// \return
/// Returns an error object. If the error is empty, the process is
/// halted.
/// otherwise the halt has failed.
- //------------------------------------------------------------------
Status 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
+ /// \param[in] keep_stopped
/// If true, don't resume the process on detach.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
Status 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
+ /// \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
@@ -1089,19 +861,16 @@ public:
/// this behavior needs to be over-ridden, this is the bool that
/// can be used.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
Status Destroy(bool force_kill);
- //------------------------------------------------------------------
/// Sends a process a UNIX signal \a signal.
///
/// This function is not meant to be overridden by Process subclasses.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
Status Signal(int signal);
void SetUnixSignals(lldb::UnixSignalsSP &&signals_sp);
@@ -1112,65 +881,57 @@ public:
// Plug-in Process Control Overrides
//==================================================================
- //------------------------------------------------------------------
/// Called before attaching to a process.
///
/// Allow Process plug-ins to execute some code before attaching a process.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status WillAttachToProcessWithID(lldb::pid_t pid) { return Status(); }
- //------------------------------------------------------------------
/// Called before attaching to a process.
///
/// Allow Process plug-ins to execute some code before attaching a process.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status WillAttachToProcessWithName(const char *process_name,
bool wait_for_launch) {
return Status();
}
- //------------------------------------------------------------------
/// Attach to a remote system via a URL
///
- /// @param[in] strm
+ /// \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
+ /// \param[in] remote_url
/// The URL format that we are connecting to.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status DoConnectRemote(Stream *strm, llvm::StringRef remote_url) {
Status error;
error.SetErrorString("remote connections are not supported");
return error;
}
- //------------------------------------------------------------------
/// Attach to an existing process using a process ID.
///
- /// @param[in] pid
+ /// \param[in] pid
/// The process ID that we should attempt to attach to.
///
- /// @param[in] attach_info
+ /// \param[in] attach_info
/// Information on how to do the attach. For example, GetUserID()
/// will return the uid to attach as.
///
- /// @return
+ /// \return
/// Returns a successful Status attaching was successful, or
/// an appropriate (possibly platform-specific) error code if
/// attaching fails.
/// hanming : need flag
- //------------------------------------------------------------------
virtual Status DoAttachToProcessWithID(lldb::pid_t pid,
const ProcessAttachInfo &attach_info) {
Status error;
@@ -1180,21 +941,19 @@ public:
return error;
}
- //------------------------------------------------------------------
/// Attach to an existing process using a partial process name.
///
- /// @param[in] process_name
+ /// \param[in] process_name
/// The name of the process to attach to.
///
- /// @param[in] attach_info
+ /// \param[in] attach_info
/// Information on how to do the attach. For example, GetUserID()
/// will return the uid to attach as.
///
- /// @return
+ /// \return
/// Returns a successful Status attaching was successful, or
/// an appropriate (possibly platform-specific) error code if
/// attaching fails.
- //------------------------------------------------------------------
virtual Status
DoAttachToProcessWithName(const char *process_name,
const ProcessAttachInfo &attach_info) {
@@ -1203,63 +962,53 @@ public:
return error;
}
- //------------------------------------------------------------------
/// Called after attaching a process.
///
- /// @param[in] process_arch
+ /// \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
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status WillLaunch(Module *module) { return Status(); }
- //------------------------------------------------------------------
/// 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
+ /// \param[in] exe_module
/// The module from which to extract the file specification and
/// launch.
///
- /// @param[in] launch_info
+ /// \param[in] launch_info
/// Details (e.g. arguments, stdio redirection, etc.) for the
/// requested launch.
///
- /// @return
+ /// \return
/// An Status instance indicating success or failure of the
/// operation.
- //------------------------------------------------------------------
virtual Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) {
Status error;
error.SetErrorStringWithFormat(
@@ -1268,24 +1017,19 @@ public:
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
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status WillResume() { return Status(); }
- //------------------------------------------------------------------
/// Resumes all of a process's threads as configured using the Thread run
/// control functions.
///
@@ -1294,14 +1038,13 @@ public:
/// process is resumed. If no run control action is given to a thread it
/// will be resumed by default.
///
- /// @return
+ /// \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()
- //------------------------------------------------------------------
+ /// \see Thread:Resume()
+ /// \see Thread:Step()
+ /// \see Thread:Suspend()
virtual Status DoResume() {
Status error;
error.SetErrorStringWithFormat(
@@ -1310,24 +1053,19 @@ public:
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
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status WillHalt() { return Status(); }
- //------------------------------------------------------------------
/// Halts a running process.
///
/// DoHalt must produce one and only one stop StateChanged event if it
@@ -1336,14 +1074,13 @@ public:
/// Otherwise, you must generate the event manually. This function is called
/// from the context of the private state thread.
///
- /// @param[out] caused_stop
+ /// \param[out] caused_stop
/// If true, then this Halt caused the stop, otherwise, the
/// process was already stopped.
///
- /// @return
+ /// \return
/// Returns \b true if the process successfully halts, \b false
/// otherwise.
- //------------------------------------------------------------------
virtual Status DoHalt(bool &caused_stop) {
Status error;
error.SetErrorStringWithFormat(
@@ -1352,31 +1089,25 @@ public:
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
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status WillDetach() { return Status(); }
- //------------------------------------------------------------------
/// Detaches from a running or stopped process.
///
- /// @return
+ /// \return
/// Returns \b true if the process successfully detaches, \b
/// false otherwise.
- //------------------------------------------------------------------
virtual Status DoDetach(bool keep_stopped) {
Status error;
error.SetErrorStringWithFormat(
@@ -1385,35 +1116,29 @@ public:
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
+ /// \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 Status WillSignal() { return Status(); }
- //------------------------------------------------------------------
/// Sends a process a UNIX signal \a signal.
///
- /// @return
+ /// \return
/// Returns an error object.
- //------------------------------------------------------------------
virtual Status DoSignal(int signal) {
Status error;
error.SetErrorStringWithFormat(
@@ -1430,15 +1155,12 @@ public:
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...
@@ -1449,10 +1171,8 @@ public:
/// 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
@@ -1461,31 +1181,25 @@ public:
/// platform that might itself be running natively, but have different
/// heuristics for figuring out which OS is is emulating.
///
- /// @return
+ /// \return
/// Returns the version tuple of the host OS. In case of failure an empty
/// VersionTuple is returner.
- //------------------------------------------------------------------
virtual llvm::VersionTuple GetHostOSVersion() { return llvm::VersionTuple(); }
- //------------------------------------------------------------------
/// Get the target object pointer for this module.
///
- /// @return
+ /// \return
/// A Target object pointer to the target that owns this
/// module.
- //------------------------------------------------------------------
Target &GetTarget() { return *m_target_wp.lock(); }
- //------------------------------------------------------------------
/// Get the const target object pointer for this module.
///
- /// @return
+ /// \return
/// A const Target object pointer to the target that owns this
/// module.
- //------------------------------------------------------------------
const Target &GetTarget() const { return *m_target_wp.lock(); }
- //------------------------------------------------------------------
/// Flush all data in the process.
///
/// Flush the memory caches, all threads, and any other cached data in the
@@ -1494,17 +1208,14 @@ public:
/// 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
+ /// \return
/// The current state of the process.
///
- /// @see lldb::StateType
- //------------------------------------------------------------------
+ /// \see lldb::StateType
lldb::StateType GetState();
lldb::ExpressionResults
@@ -1523,15 +1234,12 @@ public:
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
@@ -1544,21 +1252,20 @@ public:
/// memory and return a concise summary sufficient for the DynamicLoader
/// plugin.
///
- /// @param [in] image_list_address
+ /// \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
+ /// \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
+ /// \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) {
@@ -1579,60 +1286,50 @@ public:
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
+ /// \param [in] sc
/// A SymbolContext with eSymbolContextFunction and eSymbolContextModule
/// pre-computed.
- //------------------------------------------------------------------
void PrintWarningOptimization(const SymbolContext &sc);
virtual bool GetProcessInfo(ProcessInstanceInfo &info);
public:
- //------------------------------------------------------------------
/// Get the exit status for a process.
///
- /// @return
+ /// \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
+ /// \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
+ /// \return
/// The modification ID of the process.
- //------------------------------------------------------------------
ProcessModID GetModID() const { return m_mod_id; }
const ProcessModID &GetModIDRef() const { return m_mod_id; }
@@ -1653,7 +1350,6 @@ public:
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
@@ -1663,66 +1359,58 @@ public:
/// Setting this will cause a eStateExited event to be posted to the process
/// event queue.
///
- /// @param[in] exit_status
+ /// \param[in] exit_status
/// The value for the process's return code.
///
- /// @see lldb::StateType
- //------------------------------------------------------------------
+ /// \see lldb::StateType
virtual bool SetExitStatus(int exit_status, const char *cstr);
- //------------------------------------------------------------------
/// Check if a process is still alive.
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] vm_addr
/// A virtual load address that indicates where to start reading
/// memory from.
///
- /// @param[in] size
+ /// \param[in] size
/// The number of bytes to read.
///
- /// @param[out] buf
+ /// \param[out] buf
/// A byte buffer that is at least \a size bytes long that
/// will receive the memory bytes.
///
- /// @param[out] error
+ /// \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
+ /// \return
/// The number of bytes that were actually read into \a buf.
/// Zero is returned in the case of an error.
- //------------------------------------------------------------------
virtual size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
Status &error) = 0;
- //------------------------------------------------------------------
/// Read of memory from a process.
///
/// This function will read memory from the current process's address space
@@ -1732,34 +1420,63 @@ public:
/// subclasses should implement Process::DoReadMemory (lldb::addr_t, size_t,
/// void *).
///
- /// @param[in] vm_addr
+ /// \param[in] vm_addr
/// A virtual load address that indicates where to start reading
/// memory from.
///
- /// @param[out] buf
+ /// \param[out] buf
/// A byte buffer that is at least \a size bytes long that
/// will receive the memory bytes.
///
- /// @param[in] size
+ /// \param[in] size
/// The number of bytes to read.
///
- /// @param[out] error
+ /// \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
+ /// \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 in the case of an error.
- //------------------------------------------------------------------
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
Status &error);
- //------------------------------------------------------------------
+ /// Read of memory from a process.
+ ///
+ /// This function has the same semantics of ReadMemory except that it
+ /// bypasses caching.
+ ///
+ /// \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.
+ ///
+ /// \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 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 in the case of an error.
+ size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size,
+ Status &error);
+
/// Read a NULL terminated string from memory
///
/// This function will read a cache page at a time until a NULL string
@@ -1769,29 +1486,27 @@ public:
/// terminated, and that no more than (max_bytes - type_width) bytes will be
/// read.
///
- /// @param[in] vm_addr
+ /// \param[in] vm_addr
/// The virtual load address to start the memory read.
///
- /// @param[in] str
+ /// \param[in] str
/// A character buffer containing at least max_bytes.
///
- /// @param[in] max_bytes
+ /// \param[in] max_bytes
/// The maximum number of bytes to read.
///
- /// @param[in] error
+ /// \param[in] error
/// The error status of the read operation.
///
- /// @param[in] type_width
+ /// \param[in] type_width
/// The size of the null terminator (1 to 4 bytes per
/// character). Defaults to 1.
///
- /// @return
+ /// \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,
Status &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
@@ -1799,43 +1514,37 @@ public:
/// 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, Status &error);
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, std::string &out_str,
Status &error);
- size_t ReadMemoryFromInferior(lldb::addr_t vm_addr, void *buf, size_t size,
- Status &error);
-
- //------------------------------------------------------------------
/// Reads an unsigned integer of the specified byte size from process
/// memory.
///
- /// @param[in] load_addr
+ /// \param[in] load_addr
/// A load address of the integer to read.
///
- /// @param[in] byte_size
+ /// \param[in] byte_size
/// The size in byte of the integer to read.
///
- /// @param[in] fail_value
+ /// \param[in] fail_value
/// The value to return if we fail to read an integer.
///
- /// @param[out] error
+ /// \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
+ /// \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,
Status &error);
@@ -1848,26 +1557,24 @@ public:
bool WritePointerToMemory(lldb::addr_t vm_addr, lldb::addr_t ptr_value,
Status &error);
- //------------------------------------------------------------------
/// Actually do the writing of memory to a process.
///
- /// @param[in] vm_addr
+ /// \param[in] vm_addr
/// A virtual load address that indicates where to start writing
/// memory to.
///
- /// @param[in] buf
+ /// \param[in] buf
/// A byte buffer that is at least \a size bytes long that
/// contains the data to write.
///
- /// @param[in] size
+ /// \param[in] size
/// The number of bytes to write.
///
- /// @param[out] error
+ /// \param[out] error
/// An error value in case the memory write fails.
///
- /// @return
+ /// \return
/// The number of bytes that were actually written.
- //------------------------------------------------------------------
virtual size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
size_t size, Status &error) {
error.SetErrorStringWithFormat(
@@ -1876,7 +1583,6 @@ public:
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
@@ -1886,14 +1592,14 @@ public:
/// 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
+ /// \param[in] vm_addr
/// A virtual load address that indicates where to start writing
/// memory to.
///
- /// @param[in] scalar
+ /// \param[in] scalar
/// The scalar to write to the debugged process.
///
- /// @param[in] size
+ /// \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
@@ -1901,12 +1607,11 @@ public:
/// 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
+ /// \param[out] error
/// An error value in case the memory write fails.
///
- /// @return
+ /// \return
/// The number of bytes that were actually written.
- //------------------------------------------------------------------
size_t WriteScalarToMemory(lldb::addr_t vm_addr, const Scalar &scalar,
size_t size, Status &error);
@@ -1914,7 +1619,6 @@ public:
bool is_signed, Scalar &scalar,
Status &error);
- //------------------------------------------------------------------
/// Write memory to a process.
///
/// This function will write memory to the current process's address space
@@ -1925,38 +1629,35 @@ public:
/// subclasses should implement Process::DoWriteMemory (lldb::addr_t,
/// size_t, void *).
///
- /// @param[in] vm_addr
+ /// \param[in] vm_addr
/// A virtual load address that indicates where to start writing
/// memory to.
///
- /// @param[in] buf
+ /// \param[in] buf
/// A byte buffer that is at least \a size bytes long that
/// contains the data to write.
///
- /// @param[in] size
+ /// \param[in] size
/// The number of bytes to write.
///
- /// @return
+ /// \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,
Status &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
+ /// \param[in] size
/// The size of the allocation requested.
///
- /// @return
+ /// \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,
Status &error) {
@@ -1968,32 +1669,29 @@ public:
virtual Status WriteObjectFile(std::vector<ObjectFile::LoadableData> entries);
- //------------------------------------------------------------------
/// 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
+ /// \param[in] size
/// The size of the allocation requested.
///
- /// @param[in] permissions
+ /// \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
+ /// \param[in,out] error
/// An error object to fill in if things go wrong.
- /// @return
+ /// \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, Status &error);
- //------------------------------------------------------------------
/// The public interface to allocating memory in the process, this also
/// clears the allocated memory.
///
@@ -2001,43 +1699,39 @@ public:
/// can't rely on the generic function calling mechanism, since that
/// requires this function.
///
- /// @param[in] size
+ /// \param[in] size
/// The size of the allocation requested.
///
- /// @param[in] permissions
+ /// \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
+ /// \param[in/out] error
/// An error object to fill in if things go wrong.
- /// @return
+ /// \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,
Status &error);
- //------------------------------------------------------------------
/// Resolve dynamically loaded indirect functions.
///
- /// @param[in] address
+ /// \param[in] address
/// The load address of the indirect function to resolve.
///
- /// @param[out] error
+ /// \param[out] error
/// An error value in case the resolve fails.
///
- /// @return
+ /// \return
/// The address of the resolved function.
/// LLDB_INVALID_ADDRESS if the resolution failed.
- //------------------------------------------------------------------
virtual lldb::addr_t ResolveIndirectFunction(const Address *address,
Status &error);
- //------------------------------------------------------------------
/// Locate the memory region that contains load_addr.
///
/// If load_addr is within the address space the process has mapped
@@ -2054,15 +1748,14 @@ public:
/// GetMemoryRegionInfo will only return an error if it is unimplemented for
/// the current process.
///
- /// @param[in] load_addr
+ /// \param[in] load_addr
/// The load address to query the range_info for.
///
- /// @param[out] range_info
+ /// \param[out] range_info
/// An range_info value containing the details of the range.
///
- /// @return
+ /// \return
/// An error value.
- //------------------------------------------------------------------
virtual Status GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) {
Status error;
@@ -2070,16 +1763,14 @@ public:
return error;
}
- //------------------------------------------------------------------
/// Obtain all the mapped memory regions within this process.
///
- /// @param[out] region_list
+ /// \param[out] region_list
/// A vector to contain MemoryRegionInfo objects for all mapped
/// ranges.
///
- /// @return
+ /// \return
/// An error value.
- //------------------------------------------------------------------
virtual Status
GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list);
@@ -2102,7 +1793,6 @@ public:
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
@@ -2110,81 +1800,68 @@ public:
/// of memory at a given address or whether that page is
/// readable/writable/executable by the process.
///
- /// @param[in] load_addr
+ /// \param[in] load_addr
/// The address of interest in the process.
///
- /// @param[out] permissions
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] ptr
/// A return value from AllocateMemory, pointing to the memory you
/// want to deallocate.
///
- /// @return
+ /// \return
/// \btrue if the memory was deallocated, \bfalse otherwise.
- //------------------------------------------------------------------
virtual Status DoDeallocateMemory(lldb::addr_t ptr) {
Status error;
error.SetErrorStringWithFormat(
@@ -2193,22 +1870,19 @@ public:
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
+ /// \param[in] ptr
/// A return value from AllocateMemory, pointing to the memory you
/// want to deallocate.
///
- /// @return
+ /// \return
/// \btrue if the memory was deallocated, \bfalse otherwise.
- //------------------------------------------------------------------
Status DeallocateMemory(lldb::addr_t ptr);
- //------------------------------------------------------------------
/// Get any available STDOUT.
///
/// Calling this method is a valid operation only if all of the following
@@ -2225,21 +1899,19 @@ public:
/// Events will be queued indicating that there is STDOUT available that can
/// be retrieved using this function.
///
- /// @param[out] buf
+ /// \param[out] buf
/// A buffer that will receive any STDOUT bytes that are
/// currently available.
///
- /// @param[in] buf_size
+ /// \param[in] buf_size
/// The size in bytes for the buffer \a buf.
///
- /// @return
+ /// \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, Status &error);
- //------------------------------------------------------------------
/// Get any available STDERR.
///
/// Calling this method is a valid operation only if all of the following
@@ -2256,21 +1928,19 @@ public:
/// Events will be queued indicating that there is STDERR available that can
/// be retrieved using this function.
///
- /// @param[in] buf
+ /// \param[in] buf
/// A buffer that will receive any STDERR bytes that are
/// currently available.
///
- /// @param[out] buf_size
+ /// \param[out] buf_size
/// The size in bytes for the buffer \a buf.
///
- /// @return
+ /// \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, Status &error);
- //------------------------------------------------------------------
/// Puts data into this process's STDIN.
///
/// Calling this method is a valid operation only if all of the following
@@ -2279,42 +1949,37 @@ public:
/// process was launched without supplying a valid file path
/// for STDIN.
///
- /// @param[in] buf
+ /// \param[in] buf
/// A buffer that contains the data to write to the process's STDIN.
///
- /// @param[in] buf_size
+ /// \param[in] buf_size
/// The size in bytes for the buffer \a buf.
///
- /// @return
+ /// \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, Status &error) {
error.SetErrorString("stdin unsupported");
return 0;
}
- //------------------------------------------------------------------
/// Get any available profile data.
///
- /// @param[out] buf
+ /// \param[out] buf
/// A buffer that will receive any profile data bytes that are
/// currently available.
///
- /// @param[out] buf_size
+ /// \param[out] buf_size
/// The size in bytes for the buffer \a buf.
///
- /// @return
+ /// \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, Status &error);
- //----------------------------------------------------------------------
// Process Breakpoints
- //----------------------------------------------------------------------
size_t GetSoftwareBreakpointTrapOpcode(BreakpointSite *bp_site);
virtual Status EnableBreakpointSite(BreakpointSite *bp_site) {
@@ -2366,16 +2031,12 @@ public:
lldb::user_id_t owner_loc_id,
lldb::BreakpointSiteSP &bp_site_sp);
- //----------------------------------------------------------------------
// Process Watchpoints (optional)
- //----------------------------------------------------------------------
virtual Status EnableWatchpoint(Watchpoint *wp, bool notify = true);
virtual Status DisableWatchpoint(Watchpoint *wp, bool notify = true);
- //------------------------------------------------------------------
// Thread Queries
- //------------------------------------------------------------------
virtual bool UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) = 0;
@@ -2403,9 +2064,7 @@ public:
// id will be used.
uint32_t AssignIndexIDToThread(uint64_t thread_id);
- //------------------------------------------------------------------
// Queue Queries
- //------------------------------------------------------------------
void UpdateQueueListIfNeeded();
@@ -2419,9 +2078,7 @@ public:
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
@@ -2439,16 +2096,14 @@ public:
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
+ /// \param[in] timeout
/// The maximum time length to wait for the process to transition to the
/// eStateRunning state.
- //--------------------------------------------------------------------------------------
void SyncIOHandler(uint32_t iohandler_id, const Timeout<std::micro> &timeout);
lldb::StateType GetStateChangedEvents(
@@ -2456,27 +2111,25 @@ public:
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
+ /// \param[in] event_sp
/// The process state changed event
///
- /// @param[in] stream
+ /// \param[in] stream
/// The output stream to get the state change description
///
- /// @param[in,out] pop_process_io_handler
+ /// \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
+ /// \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);
@@ -2498,7 +2151,6 @@ public:
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
@@ -2506,44 +2158,42 @@ public:
/// WaitFor* calls above. Be sure to call RestoreProcessEvents when you are
/// done.
///
- /// @param[in] listener
+ /// \param[in] listener
/// This is the new listener to whom all process events will be delivered.
///
- /// @return
+ /// \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();
+ bool StateChangedIsHijackedForSynchronousResume();
- OperatingSystem *GetOperatingSystem() { return m_os_ap.get(); }
+ bool StateChangedIsExternallyHijacked();
- virtual LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language,
- bool retry_if_null = true);
+ const lldb::ABISP &GetABI();
- virtual CPPLanguageRuntime *GetCPPLanguageRuntime(bool retry_if_null = true);
+ OperatingSystem *GetOperatingSystem() { return m_os_up.get(); }
- virtual ObjCLanguageRuntime *
- GetObjCLanguageRuntime(bool retry_if_null = true);
+ std::vector<LanguageRuntime *>
+ GetLanguageRuntimes(bool retry_if_null = true);
+
+ LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language,
+ bool retry_if_null = true);
bool IsPossibleDynamicValue(ValueObject &in_value);
bool IsRunning() const;
DynamicCheckerFunctions *GetDynamicCheckers() {
- return m_dynamic_checkers_ap.get();
+ return m_dynamic_checkers_up.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
@@ -2551,27 +2201,22 @@ public:
/// can immediately suspend it, and keep executing only the one thread you
/// intend.
///
- /// @return
+ /// \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
+ /// \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);
void SetRunningUtilityFunction(bool on);
- //------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
lldb::TargetSP CalculateTarget() override;
lldb::ProcessSP CalculateProcess() override { return shared_from_this(); }
@@ -2586,28 +2231,22 @@ public:
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 *);
@@ -2631,48 +2270,44 @@ public:
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
+ /// \param[in] module_file_spec
/// The file name of the module to get specification for.
///
- /// @param[in] arch
+ /// \param[in] arch
/// The architecture of the module to get specification for.
///
- /// @param[out] module_spec
+ /// \param[out] module_spec
/// The fetched module specification if the return value is
/// \b true, unchanged otherwise.
///
- /// @return
+ /// \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
+ /// \param[in] file
/// The name of the file whose load address we are looking for
///
- /// @param[out] is_loaded
+ /// \param[out] is_loaded
/// \b True if the file is loaded into the memory and false
/// otherwise.
///
- /// @param[out] load_addr
+ /// \param[out] load_addr
/// The load address of the file if it is loaded into the
/// processes address space, LLDB_INVALID_ADDRESS otherwise.
- //------------------------------------------------------------------
virtual Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded,
lldb::addr_t &load_addr) {
return Status("Not supported");
@@ -2684,7 +2319,6 @@ public:
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
@@ -2693,24 +2327,22 @@ public:
/// and continue the process to there, yielding significant performance
/// benefits over instruction stepping.
///
- /// @param[in] default_stop_addr
+ /// \param[in] default_stop_addr
/// The address of the instruction where lldb would put a
/// breakpoint normally.
///
- /// @param[in] range_bounds
+ /// \param[in] range_bounds
/// The range which the breakpoint must be contained within.
/// Typically a source line.
///
- /// @return
+ /// \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
@@ -2721,11 +2353,11 @@ public:
/// StructuredDataPlugin implementations will call this to configure a
/// feature that has been reported as being supported.
///
- /// @param[in] type_name
+ /// \param[in] type_name
/// The StructuredData type name as previously discovered by
/// the Process-derived instance.
///
- /// @param[in] config
+ /// \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,
@@ -2733,14 +2365,12 @@ public:
/// set up properly before it can be enabled, then the config should
/// also take an enable/disable flag.
///
- /// @return
+ /// \return
/// Returns the result of attempting to configure the feature.
- //------------------------------------------------------------------
virtual Status
- ConfigureStructuredData(const ConstString &type_name,
+ ConfigureStructuredData(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
@@ -2748,17 +2378,15 @@ public:
/// will come in on the structured data event bit
/// (eBroadcastBitStructuredData).
///
- /// @param[in] object_sp
+ /// \param[in] object_sp
/// The structured data object to broadcast.
///
- /// @param[in] plugin_sp
+ /// \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.
///
@@ -2766,14 +2394,12 @@ public:
/// debugged process monitor claims that the feature is supported. This is
/// one way to tell whether a feature is available.
///
- /// @return
+ /// \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;
+ GetStructuredDataPlugin(ConstString type_name) const;
- //------------------------------------------------------------------
/// Starts tracing with the configuration provided in options. To enable
/// tracing on the complete process the thread_id in the options should be
/// set to LLDB_INVALID_THREAD_ID. The API returns a user_id which is needed
@@ -2782,48 +2408,40 @@ public:
/// implementations in the server, as they could be returned as an error, or
/// rounded to a valid configuration to start tracing. In the later case the
/// GetTraceConfig should supply the actual used trace configuration.
- //------------------------------------------------------------------
virtual lldb::user_id_t StartTrace(const TraceOptions &options,
Status &error) {
error.SetErrorString("Not implemented");
return LLDB_INVALID_UID;
}
- //------------------------------------------------------------------
/// Stops the tracing instance leading to deletion of the trace data. The
/// tracing instance is identified by the user_id which is obtained when
/// tracing was started from the StartTrace. In case tracing of the complete
/// process needs to be stopped the thread_id should be set to
/// LLDB_INVALID_THREAD_ID. In the other case that tracing on an individual
/// thread needs to be stopped a thread_id can be supplied.
- //------------------------------------------------------------------
virtual Status StopTrace(lldb::user_id_t uid, lldb::tid_t thread_id) {
return Status("Not implemented");
}
- //------------------------------------------------------------------
/// Provides the trace data as raw bytes. A buffer needs to be supplied to
/// copy the trace data. The exact behavior of this API may vary across
/// trace technology, as some may support partial reading of the trace data
/// from a specified offset while some may not. The thread_id should be used
/// to select a particular thread for trace extraction.
- //------------------------------------------------------------------
virtual Status GetData(lldb::user_id_t uid, lldb::tid_t thread_id,
llvm::MutableArrayRef<uint8_t> &buffer,
size_t offset = 0) {
return Status("Not implemented");
}
- //------------------------------------------------------------------
/// Similar API as above except for obtaining meta data
- //------------------------------------------------------------------
virtual Status GetMetaData(lldb::user_id_t uid, lldb::tid_t thread_id,
llvm::MutableArrayRef<uint8_t> &buffer,
size_t offset = 0) {
return Status("Not implemented");
}
- //------------------------------------------------------------------
/// API to obtain the trace configuration used by a trace instance.
/// Configurations that may be specific to some trace technology should be
/// stored in the custom parameters. The options are transported to the
@@ -2831,7 +2449,6 @@ public:
/// specified in the options to obtain the configuration used by a specific
/// thread. The thread_id specified should also match the uid otherwise an
/// error will be returned.
- //------------------------------------------------------------------
virtual Status GetTraceConfig(lldb::user_id_t uid, TraceOptions &options) {
return Status("Not implemented");
}
@@ -2841,21 +2458,16 @@ protected:
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
+ /// \return
/// An Status object describing the success or failure of the resume.
- //------------------------------------------------------------------
Status 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.
@@ -2872,21 +2484,19 @@ protected:
/// that the warning strings are all centralized in Process, instead of
/// calling PrintWarning() directly.
///
- /// @param [in] warning_type
+ /// \param [in] warning_type
/// One of the types defined in Process::Warnings.
///
- /// @param [in] repeat_key
+ /// \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
+ /// \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
@@ -2895,14 +2505,13 @@ protected:
//
// 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 {
+ enum EventActionResult {
eEventActionSuccess,
eEventActionRetry,
eEventActionExit
- } EventActionResult;
+ };
NextEventAction(Process *process) : m_process(process) {}
@@ -2919,10 +2528,10 @@ protected:
};
void SetNextEventAction(Process::NextEventAction *next_event_action) {
- if (m_next_event_action_ap.get())
- m_next_event_action_ap->HandleBeingUnshipped();
+ if (m_next_event_action_up.get())
+ m_next_event_action_up->HandleBeingUnshipped();
- m_next_event_action_ap.reset(next_event_action);
+ m_next_event_action_up.reset(next_event_action);
}
// This is the completer for Attaching:
@@ -2949,7 +2558,6 @@ protected:
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.
///
@@ -2962,22 +2570,20 @@ protected:
/// 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
+ /// \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
+ /// \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
@@ -2986,19 +2592,16 @@ protected:
///
/// virtual void
/// HandleArrivalOfStructuredData(Process &process,
- /// const ConstString &type_name,
+ /// ConstString type_name,
/// const StructuredData::ObjectSP
/// &object_sp)
///
- /// @return
+ /// \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;
@@ -3018,9 +2621,7 @@ protected:
using StructuredDataPluginMap =
std::map<ConstString, lldb::StructuredDataPluginSP>;
- //------------------------------------------------------------------
// Member variables
- //------------------------------------------------------------------
std::weak_ptr<Target> m_target_wp; ///< The target that owns this process.
ThreadSafeValue<lldb::StateType> m_public_state;
ThreadSafeValue<lldb::StateType>
@@ -3071,15 +2672,15 @@ protected:
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::DynamicLoaderUP m_dyld_up;
+ lldb::JITLoaderListUP m_jit_loaders_up;
+ lldb::DynamicCheckerFunctionsUP m_dynamic_checkers_up; ///< The functions used
+ /// by the expression
+ /// parser to validate
+ /// data that
+ /// expressions use.
+ lldb::OperatingSystemUP m_os_up;
+ lldb::SystemRuntimeUP m_system_runtime_up;
lldb::UnixSignalsSP
m_unix_signals_sp; /// This is the current signal set for this process.
lldb::ABISP m_abi_sp;
@@ -3098,8 +2699,9 @@ protected:
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;
+ std::recursive_mutex m_language_runtimes_mutex;
InstrumentationRuntimeCollection m_instrumentation_runtimes;
- std::unique_ptr<NextEventAction> m_next_event_action_ap;
+ std::unique_ptr<NextEventAction> m_next_event_action_up;
std::vector<PreResumeCallbackAndBaton> m_pre_resume_actions;
ProcessRunLock m_public_run_lock;
ProcessRunLock m_private_run_lock;
@@ -3212,12 +2814,9 @@ protected:
virtual Status UpdateAutomaticSignalFiltering();
- bool StateChangedIsExternallyHijacked();
-
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
@@ -3225,13 +2824,12 @@ private:
/// again. There is only one place where this call should be called,
/// HandlePrivateEvent. Don't call it from anywhere else...
///
- /// @param[in] event_ptr
+ /// \param[in] event_ptr
/// This is the event we are handling.
///
- /// @return
+ /// \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);
@@ -3239,10 +2837,8 @@ private:
DISALLOW_COPY_AND_ASSIGN(Process);
};
-//------------------------------------------------------------------
/// RAII guard that should be aquired when an utility function is called within
/// a given process.
-//------------------------------------------------------------------
class UtilityFunctionScope {
Process *m_process;
diff --git a/include/lldb/Target/ProcessInfo.h b/include/lldb/Target/ProcessInfo.h
deleted file mode 100644
index 0e0d8548feb6f..0000000000000
--- a/include/lldb/Target/ProcessInfo.h
+++ /dev/null
@@ -1,102 +0,0 @@
-//===-- ProcessInfo.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_ProcessInfo_h_
-#define liblldb_ProcessInfo_h_
-
-// LLDB headers
-#include "lldb/Utility/ArchSpec.h"
-#include "lldb/Utility/Args.h"
-#include "lldb/Utility/Environment.h"
-#include "lldb/Utility/FileSpec.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; }
-
- 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);
-
- Environment &GetEnvironment() { return m_environment; }
- const Environment &GetEnvironment() 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]
- Environment 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/ProcessStructReader.h b/include/lldb/Target/ProcessStructReader.h
index 79f0b4cccd455..ade29c0a7cf7f 100644
--- a/include/lldb/Target/ProcessStructReader.h
+++ b/include/lldb/Target/ProcessStructReader.h
@@ -1,9 +1,8 @@
//===---------------------ProcessStructReader.h ------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/Queue.h b/include/lldb/Target/Queue.h
index 62cc3ccf2e2fc..01e8994f24418 100644
--- a/include/lldb/Target/Queue.h
+++ b/include/lldb/Target/Queue.h
@@ -1,9 +1,8 @@
//===-- Queue.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,7 +19,6 @@
namespace lldb_private {
-//------------------------------------------------------------------
// Queue:
// This class represents a libdispatch aka Grand Central Dispatch queue in the
// process.
@@ -30,7 +28,6 @@ namespace lldb_private {
// pthreads to execute the work items for the queues. A serial queue will be
// associated with a single thread (or possibly no thread, if it is not doing
// any work). A concurrent queue may be associated with multiple threads.
-//------------------------------------------------------------------
class Queue : public std::enable_shared_from_this<Queue> {
public:
@@ -39,7 +36,6 @@ public:
~Queue();
- //------------------------------------------------------------------
/// Get the QueueID for this Queue
///
/// A 64-bit ID number that uniquely identifies a queue at this particular
@@ -48,21 +44,17 @@ public:
/// each queue. A serialnum is not reused for a different queue in the
/// lifetime of that process execution.
///
- /// @return
+ /// \return
/// The QueueID for this Queue.
- //------------------------------------------------------------------
lldb::queue_id_t GetID();
- //------------------------------------------------------------------
/// Get the name of this Queue
///
- /// @return
+ /// \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,
@@ -73,66 +65,55 @@ public:
/// maintain similar API to the Thread class, and allow for the
/// possibility of GetID changing to a different source in the future.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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);
@@ -145,20 +126,16 @@ public:
m_pending_items.push_back(item);
}
- //------------------------------------------------------------------
/// Return the kind (serial, concurrent) of this queue
///
- /// @return
+ /// \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;
diff --git a/include/lldb/Target/QueueItem.h b/include/lldb/Target/QueueItem.h
index 3fd331ca525af..dfae3b8472633 100644
--- a/include/lldb/Target/QueueItem.h
+++ b/include/lldb/Target/QueueItem.h
@@ -1,9 +1,8 @@
//===-- QueueItem.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,14 +22,12 @@
namespace lldb_private {
-//------------------------------------------------------------------
// QueueItem:
// This class represents a work item enqueued on a libdispatch aka 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", execution of the item
// begins.
-//------------------------------------------------------------------
class QueueItem : public std::enable_shared_from_this<QueueItem> {
public:
@@ -39,71 +36,59 @@ public:
~QueueItem();
- //------------------------------------------------------------------
/// Get the kind of work item this is
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param [in] type
/// The type of extended backtrace being requested, e.g. "libdispatch"
/// or "pthread".
///
- /// @return
+ /// \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) {
diff --git a/include/lldb/Target/QueueList.h b/include/lldb/Target/QueueList.h
index b35de13aa1e54..761107e41def6 100644
--- a/include/lldb/Target/QueueList.h
+++ b/include/lldb/Target/QueueList.h
@@ -1,9 +1,8 @@
//===-- QueueList.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,14 +18,12 @@
namespace lldb_private {
-//------------------------------------------------------------------
// QueueList:
// 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 SystemRuntime.
-//------------------------------------------------------------------
class QueueList {
friend class Process;
@@ -36,22 +33,18 @@ public:
~QueueList();
- //------------------------------------------------------------------
/// Get the number of libdispatch queues that are available
///
- /// @return
+ /// \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
+ /// \param [in] idx
/// The index number (0-based) of the queue.
- /// @return
+ /// \return
/// The Queue at that index number.
- //------------------------------------------------------------------
lldb::QueueSP GetQueueAtIndex(uint32_t idx);
typedef std::vector<lldb::QueueSP> collection;
@@ -59,61 +52,49 @@ public:
std::mutex>
QueueIterable;
- //------------------------------------------------------------------
/// Iterate over the list of queues
///
- /// @return
+ /// \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
+ /// \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
+ /// \param [in] qid
/// The QueueID (same as returned by Thread::GetQueueID()) to find.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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.
@@ -121,7 +102,7 @@ protected:
std::mutex m_mutex;
private:
- QueueList();
+ QueueList() = delete;
};
} // namespace lldb_private
diff --git a/include/lldb/Target/RegisterCheckpoint.h b/include/lldb/Target/RegisterCheckpoint.h
index e4b407124c9fc..4f9654f763437 100644
--- a/include/lldb/Target/RegisterCheckpoint.h
+++ b/include/lldb/Target/RegisterCheckpoint.h
@@ -1,9 +1,8 @@
//===-- RegisterCheckpoint.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/RegisterContext.h b/include/lldb/Target/RegisterContext.h
index a24c270a1e5e9..d6212dd49dd6b 100644
--- a/include/lldb/Target/RegisterContext.h
+++ b/include/lldb/Target/RegisterContext.h
@@ -1,9 +1,8 @@
//===-- RegisterContext.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,18 +17,14 @@ namespace lldb_private {
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;
@@ -76,7 +71,6 @@ public:
bool CopyFromRegisterContext(lldb::RegisterContextSP context);
- //------------------------------------------------------------------
/// Convert from a given register numbering scheme to the lldb register
/// numbering scheme
///
@@ -100,23 +94,20 @@ public:
/// This method translates a given register kind + register number into
/// the eRegisterKindLLDB register numbering.
///
- /// @param [in] kind
+ /// \param [in] kind
/// The register numbering scheme (RegisterKind) that the following
/// register number is in.
///
- /// @param [in] num
+ /// \param [in] num
/// A register number in the 'kind' register numbering scheme.
///
- /// @return
+ /// \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);
@@ -142,9 +133,7 @@ public:
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; }
@@ -189,9 +178,7 @@ public:
lldb::RegisterKind target_rk,
uint32_t &target_regnum);
- //------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
lldb::TargetSP CalculateTarget() override;
lldb::ProcessSP CalculateProcess() override;
@@ -207,17 +194,13 @@ public:
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
private:
- //------------------------------------------------------------------
// For RegisterContext only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(RegisterContext);
};
diff --git a/include/lldb/Target/RegisterNumber.h b/include/lldb/Target/RegisterNumber.h
index 1a0ab49bdce39..0bef0c13f3785 100644
--- a/include/lldb/Target/RegisterNumber.h
+++ b/include/lldb/Target/RegisterNumber.h
@@ -1,9 +1,8 @@
//===-- RegisterNumber.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,11 +12,9 @@
#include "lldb/lldb-private.h"
#include <map>
-//--------------------------------------------------------------------
/// A class to represent register numbers, and able to convert between
/// different register numbering schemes that may be used in a single
/// debug session.
-//--------------------------------------------------------------------
class RegisterNumber {
public:
diff --git a/include/lldb/Target/RemoteAwarePlatform.h b/include/lldb/Target/RemoteAwarePlatform.h
new file mode 100644
index 0000000000000..524332f948a54
--- /dev/null
+++ b/include/lldb/Target/RemoteAwarePlatform.h
@@ -0,0 +1,97 @@
+//===-- RemoteAwarePlatform.h -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_TARGET_REMOTEAWAREPLATFORM_H
+#define LLDB_TARGET_REMOTEAWAREPLATFORM_H
+
+#include "lldb/Target/Platform.h"
+
+namespace lldb_private {
+
+/// A base class for platforms which automatically want to be able to forward
+/// operations to a remote platform instance (such as PlatformRemoteGDBServer).
+class RemoteAwarePlatform : public Platform {
+public:
+ using Platform::Platform;
+
+ bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
+ ModuleSpec &module_spec) override;
+
+ lldb::user_id_t OpenFile(const FileSpec &file_spec, uint32_t flags,
+ uint32_t mode, Status &error) override;
+
+ bool CloseFile(lldb::user_id_t fd, Status &error) override;
+
+ uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
+ uint64_t dst_len, Status &error) override;
+
+ uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
+ uint64_t src_len, Status &error) override;
+
+ lldb::user_id_t GetFileSize(const FileSpec &file_spec) override;
+
+ Status CreateSymlink(const FileSpec &src, const FileSpec &dst) override;
+
+ bool GetFileExists(const FileSpec &file_spec) override;
+
+ Status Unlink(const FileSpec &file_spec) override;
+
+ FileSpec GetRemoteWorkingDirectory() override;
+
+ bool SetRemoteWorkingDirectory(const FileSpec &working_dir) override;
+
+ Status MakeDirectory(const FileSpec &file_spec, uint32_t mode) override;
+
+ Status GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) override;
+
+ Status SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) override;
+
+ bool CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+ uint64_t &high) override;
+
+ Status GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
+ FileSpec &local_file) override;
+
+ bool GetRemoteOSVersion() override;
+ bool GetRemoteOSBuildString(std::string &s) override;
+ bool GetRemoteOSKernelDescription(std::string &s) override;
+ ArchSpec GetRemoteSystemArchitecture() override;
+
+ Status RunShellCommand(const char *command, const FileSpec &working_dir,
+ int *status_ptr, int *signo_ptr,
+ std::string *command_output,
+ const Timeout<std::micro> &timeout) override;
+
+ const char *GetHostname() override;
+ UserIDResolver &GetUserIDResolver() override;
+ lldb_private::Environment GetEnvironment() override;
+
+ bool IsConnected() const override;
+
+ bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
+ uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) override;
+
+ lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ Debugger &debugger, Target *target,
+ Status &error) override;
+
+ Status LaunchProcess(ProcessLaunchInfo &launch_info) override;
+
+ Status KillProcess(const lldb::pid_t pid) override;
+
+protected:
+ lldb::PlatformSP m_remote_platform_sp;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_TARGET_REMOTEAWAREPLATFORM_H
diff --git a/include/lldb/Target/SectionLoadHistory.h b/include/lldb/Target/SectionLoadHistory.h
index 0a14fc05c458f..71b5d0c427463 100644
--- a/include/lldb/Target/SectionLoadHistory.h
+++ b/include/lldb/Target/SectionLoadHistory.h
@@ -1,9 +1,8 @@
//===-- SectionLoadHistory.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@ public:
// value.
eStopIDNow = UINT32_MAX
};
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SectionLoadHistory() : m_stop_id_to_section_load_list(), m_mutex() {}
~SectionLoadHistory() {
diff --git a/include/lldb/Target/SectionLoadList.h b/include/lldb/Target/SectionLoadList.h
index 2a321e7a25454..caefa00ec1daa 100644
--- a/include/lldb/Target/SectionLoadList.h
+++ b/include/lldb/Target/SectionLoadList.h
@@ -1,10 +1,9 @@
//===-- SectionLoadList.h -----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ namespace lldb_private {
class SectionLoadList {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SectionLoadList() : m_addr_to_sect(), m_sect_to_addr(), m_mutex() {}
SectionLoadList(const SectionLoadList &rhs);
diff --git a/include/lldb/Target/StackFrame.h b/include/lldb/Target/StackFrame.h
index a4e31a567440a..4e6e79befc6ab 100644
--- a/include/lldb/Target/StackFrame.h
+++ b/include/lldb/Target/StackFrame.h
@@ -1,9 +1,8 @@
//===-- StackFrame.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,7 +25,7 @@
namespace lldb_private {
-/// @class StackFrame StackFrame.h "lldb/Target/StackFrame.h"
+/// \class StackFrame StackFrame.h "lldb/Target/StackFrame.h"
///
/// This base class provides an interface to stack frames.
///
@@ -64,7 +63,6 @@ public:
Artificial
};
- //------------------------------------------------------------------
/// Construct a StackFrame object without supplying a RegisterContextSP.
///
/// This is the one constructor that doesn't take a RegisterContext
@@ -73,19 +71,19 @@ public:
/// point in the past. We may only have pc values. We may have a CFA,
/// or more likely, we won't.
///
- /// @param [in] thread_sp
+ /// \param [in] thread_sp
/// The Thread that this frame belongs to.
///
- /// @param [in] frame_idx
+ /// \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
+ /// \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
+ /// \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
@@ -93,21 +91,20 @@ public:
/// function. It is usually not the same as the frame pointer register's
/// value.
///
- /// @param [in] cfa_is_valid
+ /// \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
+ /// \param [in] pc
/// The current pc value of this stack frame.
///
- /// @param [in] frame_kind
+ /// \param [in] frame_kind
///
- /// @param [in] sc_ptr
+ /// \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, Kind frame_kind,
@@ -129,31 +126,26 @@ public:
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
+ /// \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
+ /// \param[in] pc
/// The load address that the pc will be set to.
///
- /// @return
+ /// \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
@@ -161,17 +153,15 @@ public:
/// functions looking up symbolic information for a given pc value multiple
/// times.
///
- /// @params [in] resolve_scope
+ /// \params [in] resolve_scope
/// Flags from the SymbolContextItem enumerated type which specify what
/// type of symbol context is needed by this caller.
///
- /// @return
+ /// \return
/// A SymbolContext reference which includes the types of information
/// requested by resolve_scope, if they are available.
- //------------------------------------------------------------------
const SymbolContext &GetSymbolContext(lldb::SymbolContextItem 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
@@ -182,46 +172,40 @@ public:
/// Live StackFrames will always have a CFA but other types of frames may
/// not be able to supply one.
///
- /// @param [out] value
+ /// \param [out] value
/// The address of the CFA for this frame, if available.
///
- /// @param [out] error_ptr
+ /// \param [out] error_ptr
/// If there is an error determining the CFA address, this may contain a
/// string explaining the failure.
///
- /// @return
+ /// \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, Status *error_ptr);
- //------------------------------------------------------------------
/// Get the DWARFExpression corresponding to the Canonical Frame Address.
///
/// Often a register (bp), but sometimes a register + offset.
///
- /// @param [out] error_ptr
+ /// \param [out] error_ptr
/// If there is an error determining the CFA address, this may contain a
/// string explaining the failure.
///
- /// @return
+ /// \return
/// Returns the corresponding DWARF expression, or NULL.
- //------------------------------------------------------------------
DWARFExpression *GetFrameBaseExpression(Status *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
+ /// \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.
@@ -232,16 +216,14 @@ public:
/// registers. Only the currently executing frame (frame 0) can reliably
/// provide every register in the register context.
///
- /// @return
+ /// \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.
///
@@ -249,17 +231,15 @@ public:
/// pc value even though variables would be available at this point if it
/// were a live stack frame.
///
- /// @param[in] get_file_globals
+ /// \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
+ /// \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.
///
@@ -267,269 +247,230 @@ public:
/// given pc value even though variables would be available at this point if
/// it were a live stack frame.
///
- /// @param[in] get_file_globals
+ /// \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
+ /// \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
+ /// \param[in] var_expr
/// The string specifying a variable to base the VariableObject off
/// of.
///
- /// @param[in] use_dynamic
+ /// \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
+ /// \param[in] options
/// An unsigned integer of flags, values from
/// StackFrame::ExpressionPathOption
/// enum.
- /// @param[in] var_sp
+ /// \param[in] var_sp
/// A VariableSP that will be set to the variable described in the
/// var_expr path.
///
- /// @param[in] error
+ /// \param[in] error
/// Record any errors encountered while evaluating var_expr.
///
- /// @return
+ /// \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, Status &error);
- //------------------------------------------------------------------
/// Determine whether this StackFrame has debug information available or not
///
- /// @return
+ /// \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
+ /// \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
+ /// \param [in] strm
/// The Stream to print the description to.
///
- /// @param [in] show_unique
+ /// \param [in] show_unique
/// Whether to print the function arguments or not for backtrace unique.
///
- /// @param [in] frame_marker
+ /// \param [in] frame_marker
/// Optional string that will be prepended to the frame output description.
- //------------------------------------------------------------------
void DumpUsingSettingsFormat(Stream *strm, bool show_unique = false,
const char *frame_marker = nullptr);
- //------------------------------------------------------------------
/// Print a description for this frame using a default format.
///
- /// @param [in] strm
+ /// \param [in] strm
/// The Stream to print the description to.
///
- /// @param [in] show_frame_index
+ /// \param [in] show_frame_index
/// Whether to print the frame number or not.
///
- /// @param [in] show_fullpaths
+ /// \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
+ /// \param[in] strm
/// The Stream to send the output to.
///
- /// @param[in] show_frame_info
+ /// \param[in] show_frame_info
/// If true, print the frame info by calling DumpUsingSettingsFormat().
///
- /// @param[in] show_source
+ /// \param[in] show_source
/// If true, print source or disassembly as per the user's settings.
///
- /// @param[in] show_unique
+ /// \param[in] show_unique
/// If true, print using backtrace unique style, without function
/// arguments as per the user's settings.
///
- /// @param[in] frame_marker
+ /// \param[in] frame_marker
/// Passed to DumpUsingSettingsFormat() for the frame info printing.
///
- /// @return
+ /// \return
/// Returns true if successful.
- //------------------------------------------------------------------
bool GetStatus(Stream &strm, bool show_frame_info, bool show_source,
bool show_unique = false, 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
+ /// \return
/// true if this is an inlined frame.
- //------------------------------------------------------------------
bool IsInlined();
- //------------------------------------------------------------------
/// Query whether this frame is part of a historical backtrace.
- //------------------------------------------------------------------
bool IsHistorical() const;
- //------------------------------------------------------------------
/// Query whether this frame is artificial (e.g a synthesized result of
/// inferring missing tail call frames from a backtrace). Artificial frames
/// may have limited support for inspecting variables.
- //------------------------------------------------------------------
bool IsArtificial() const;
- //------------------------------------------------------------------
/// Query this frame to find what frame it is in this Thread's
/// StackFrameList.
///
- /// @return
+ /// \return
/// StackFrame index 0 indicates the currently-executing function. Inline
/// frames are included in this frame index count.
- //------------------------------------------------------------------
uint32_t GetFrameIndex() const;
- //------------------------------------------------------------------
/// Set this frame's synthetic frame index.
- //------------------------------------------------------------------
void SetFrameIndex(uint32_t index) { m_frame_index = index; }
- //------------------------------------------------------------------
/// Query this frame to find what frame it is in this Thread's
/// StackFrameList, not counting inlined frames.
///
- /// @return
+ /// \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
+ /// \params [in] variable_sp
/// The Variable to base this ValueObject on
///
- /// @params [in] use_dynamic
+ /// \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
+ /// \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
+ /// \params [in] variable_sp
/// The Variable to base this ValueObject on
///
- /// @params [in] use_dynamic
+ /// \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
+ /// \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
+ /// \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
+ /// \params [in] addr
/// The raw address.
///
- /// @return
+ /// \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
+ /// \params [in] reg
/// The name of the register.
///
- /// @params [in] offset
+ /// \params [in] offset
/// The offset from the register. Particularly important for sp...
///
- /// @return
+ /// \return
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
- //------------------------------------------------------------------
lldb::ValueObjectSP GuessValueForRegisterAndOffset(ConstString reg,
int64_t offset);
- //------------------------------------------------------------------
/// Attempt to reconstruct the ValueObject for a variable with a given \a name
/// from within the current StackFrame, within the current block. The search
/// for the variable starts in the deepest block corresponding to the current
/// PC in the stack frame and traverse through all parent blocks stopping at
/// inlined function boundaries.
///
- /// @params [in] name
+ /// \params [in] name
/// The name of the variable.
///
- /// @return
+ /// \return
/// The ValueObject if found.
- //------------------------------------------------------------------
lldb::ValueObjectSP FindVariable(ConstString name);
- //------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
- //------------------------------------------------------------------
lldb::TargetSP CalculateTarget() override;
lldb::ProcessSP CalculateProcess() override;
@@ -554,9 +495,7 @@ protected:
bool HasCachedData() const;
private:
- //------------------------------------------------------------------
// For StackFrame only
- //------------------------------------------------------------------
lldb::ThreadWP m_thread_wp;
uint32_t m_frame_index;
uint32_t m_concrete_frame_index;
diff --git a/include/lldb/Target/StackFrameList.h b/include/lldb/Target/StackFrameList.h
index 0de90b3ba4acb..5eb7919501722 100644
--- a/include/lldb/Target/StackFrameList.h
+++ b/include/lldb/Target/StackFrameList.h
@@ -1,9 +1,8 @@
//===-- StackFrameList.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@ namespace lldb_private {
class StackFrameList {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
StackFrameList(Thread &thread, const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames);
@@ -92,7 +89,7 @@ protected:
bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp);
- static void Merge(std::unique_ptr<StackFrameList> &curr_ap,
+ static void Merge(std::unique_ptr<StackFrameList> &curr_up,
lldb::StackFrameListSP &prev_sp);
void GetFramesUpTo(uint32_t end_idx);
diff --git a/include/lldb/Target/StackFrameRecognizer.h b/include/lldb/Target/StackFrameRecognizer.h
index 35ec23b754f3a..2021ac5215f38 100644
--- a/include/lldb/Target/StackFrameRecognizer.h
+++ b/include/lldb/Target/StackFrameRecognizer.h
@@ -1,15 +1,15 @@
//===-- StackFrameRecognizer.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_StackFrameRecognizer_h_
#define liblldb_StackFrameRecognizer_h_
+#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/StructuredData.h"
@@ -18,7 +18,7 @@
namespace lldb_private {
-/// @class RecognizedStackFrame
+/// \class RecognizedStackFrame
///
/// This class provides extra information about a stack frame that was
/// provided by a specific stack frame recognizer. Right now, this class only
@@ -39,7 +39,7 @@ protected:
lldb::ValueObjectListSP m_arguments;
};
-/// @class StackFrameRecognizer
+/// \class StackFrameRecognizer
///
/// A base class for frame recognizers. Subclasses (actual frame recognizers)
/// should implement RecognizeFrame to provide a RecognizedStackFrame for a
@@ -59,9 +59,7 @@ public:
virtual ~StackFrameRecognizer(){};
};
-#ifndef LLDB_DISABLE_PYTHON
-
-/// @class ScriptedStackFrameRecognizer
+/// \class ScriptedStackFrameRecognizer
///
/// Python implementation for frame recognizers. An instance of this class
/// tracks a particular Python classobject, which will be asked to recognize
@@ -75,7 +73,7 @@ class ScriptedStackFrameRecognizer : public StackFrameRecognizer {
public:
ScriptedStackFrameRecognizer(lldb_private::ScriptInterpreter *interpreter,
const char *pclass);
- ~ScriptedStackFrameRecognizer() {}
+ ~ScriptedStackFrameRecognizer() override {}
std::string GetName() override {
return GetPythonClassName();
@@ -90,9 +88,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(ScriptedStackFrameRecognizer);
};
-#endif
-
-/// @class StackFrameRecognizerManager
+/// \class StackFrameRecognizerManager
///
/// Static class that provides a registry of known stack frame recognizers.
/// Has static methods to add, enumerate, remove, query and invoke recognizers.
@@ -100,8 +96,8 @@ private:
class StackFrameRecognizerManager {
public:
static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
- const ConstString &module,
- const ConstString &symbol,
+ ConstString module,
+ ConstString symbol,
bool first_instruction_only = true);
static void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
@@ -124,6 +120,42 @@ public:
static lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame);
};
+/// \class ValueObjectRecognizerSynthesizedValue
+///
+/// ValueObject subclass that presents the passed ValueObject as a recognized
+/// value with the specified ValueType. Frame recognizers should return
+/// instances of this class as the returned objects in GetRecognizedArguments().
+
+class ValueObjectRecognizerSynthesizedValue : public ValueObject {
+ public:
+ static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type) {
+ return (new ValueObjectRecognizerSynthesizedValue(parent, type))->GetSP();
+ }
+ ValueObjectRecognizerSynthesizedValue(ValueObject &parent,
+ lldb::ValueType type)
+ : ValueObject(parent), m_type(type) {
+ SetName(parent.GetName());
+ }
+
+ uint64_t GetByteSize() override { return m_parent->GetByteSize(); }
+ lldb::ValueType GetValueType() const override { return m_type; }
+ bool UpdateValue() override {
+ if (!m_parent->UpdateValueIfNeeded()) return false;
+ m_value = m_parent->GetValue();
+ return true;
+ }
+ size_t CalculateNumChildren(uint32_t max = UINT32_MAX) override {
+ return m_parent->GetNumChildren(max);
+ }
+ CompilerType GetCompilerTypeImpl() override {
+ return m_parent->GetCompilerType();
+ }
+ bool IsSynthetic() override { return true; }
+
+ private:
+ lldb::ValueType m_type;
+};
+
} // namespace lldb_private
#endif // liblldb_StackFrameRecognizer_h_
diff --git a/include/lldb/Target/StackID.h b/include/lldb/Target/StackID.h
index 871f39c463a95..a649a4faa9391 100644
--- a/include/lldb/Target/StackID.h
+++ b/include/lldb/Target/StackID.h
@@ -1,9 +1,8 @@
//===-- StackID.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@ namespace lldb_private {
class StackID {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
StackID()
: m_pc(LLDB_INVALID_ADDRESS), m_cfa(LLDB_INVALID_ADDRESS),
m_symbol_scope(nullptr) {}
@@ -55,9 +52,7 @@ public:
void Dump(Stream *s);
- //------------------------------------------------------------------
// Operators
- //------------------------------------------------------------------
const StackID &operator=(const StackID &rhs) {
if (this != &rhs) {
m_pc = rhs.m_pc;
diff --git a/include/lldb/Target/StopInfo.h b/include/lldb/Target/StopInfo.h
index 1a9f5b8480dbd..59033b1b64416 100644
--- a/include/lldb/Target/StopInfo.h
+++ b/include/lldb/Target/StopInfo.h
@@ -1,9 +1,8 @@
//===-- StopInfo.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,9 +22,7 @@ class StopInfo {
friend class ThreadPlanBase;
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
StopInfo(Thread &thread, uint64_t value);
virtual ~StopInfo() {}
@@ -157,9 +154,7 @@ protected:
// 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.
diff --git a/include/lldb/Target/StructuredDataPlugin.h b/include/lldb/Target/StructuredDataPlugin.h
index 5ea265b054205..b20bdb3b263a3 100644
--- a/include/lldb/Target/StructuredDataPlugin.h
+++ b/include/lldb/Target/StructuredDataPlugin.h
@@ -1,9 +1,8 @@
//===-- StructuredDataPlugin.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,7 +16,6 @@ namespace lldb_private {
class CommandObjectMultiword;
-// -----------------------------------------------------------------------------
/// Plugin that supports process-related structured data sent asynchronously
/// from the debug monitor (e.g. debugserver, lldb-server, etc.)
///
@@ -38,21 +36,17 @@ class CommandObjectMultiword;
/// 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();
+ ~StructuredDataPlugin() override;
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
@@ -64,16 +58,14 @@ public:
/// 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
+ /// \param[in] type_name
/// The name of the feature tag supported by a process.
/// e.g. "darwin-log".
///
- /// @return
+ /// \return
/// true if the plugin supports the feature; otherwise, false.
- // -------------------------------------------------------------------------
- virtual bool SupportsStructuredDataType(const ConstString &type_name) = 0;
+ virtual bool SupportsStructuredDataType(ConstString type_name) = 0;
- // -------------------------------------------------------------------------
/// Handle the arrival of asynchronous structured data from the process.
///
/// When asynchronous structured data arrives from the process monitor,
@@ -84,27 +76,25 @@ public:
/// value. This is the manner in which the data is routed to the proper
/// plugin instance.
///
- /// @param[in] process
+ /// \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
+ /// \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
+ /// \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,
+ HandleArrivalOfStructuredData(Process &process, 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
@@ -113,33 +103,29 @@ public:
/// nothing will be printed; otherwise, a newline will be added to the end
/// when displayed.
///
- /// @param[in] object_sp
+ /// \param[in] object_sp
/// A shared pointer to the structured data to format.
///
- /// @param[in] stream
+ /// \param[in] stream
/// The stream where the structured data should be pretty printed.
///
- /// @return
+ /// \return
/// The error if formatting the object contents failed; otherwise,
/// success.
- // -------------------------------------------------------------------------
virtual Status 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
+ /// \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;
+ virtual bool GetEnabled(ConstString type_name) const;
- // -------------------------------------------------------------------------
/// Allow the plugin to do work related to modules that loaded in the
/// the corresponding process.
///
@@ -147,24 +133,20 @@ public:
/// if they have any behavior they want to enable/modify based on loaded
/// modules.
///
- /// @param[in] process
+ /// \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
+ /// \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.
///
@@ -172,10 +154,9 @@ protected:
/// StructuredDataPlugin derived classes are available for this debugger.
/// If this has already happened, this call is a no-op.
///
- /// @param[in] debugger
+ /// \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:
diff --git a/include/lldb/Target/SystemRuntime.h b/include/lldb/Target/SystemRuntime.h
index 328dbe2310783..b45f882d36b0e 100644
--- a/include/lldb/Target/SystemRuntime.h
+++ b/include/lldb/Target/SystemRuntime.h
@@ -1,9 +1,8 @@
//===-- SystemRuntime.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,8 +22,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h"
+/// \class SystemRuntime SystemRuntime.h "lldb/Target/SystemRuntime.h"
/// A plug-in interface definition class for system runtimes.
///
/// The system runtime plugins can collect information from the system
@@ -40,68 +38,52 @@ namespace lldb_private {
/// collecting information. Later when it comes time to augment a Thread, it
/// can be asked to provide that information.
///
-//----------------------------------------------------------------------
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
+ /// \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);
- //------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be inherited
/// by the plug-in instance.
- //------------------------------------------------------------------
~SystemRuntime() override;
- //------------------------------------------------------------------
/// Called after attaching to a process.
///
/// Allow the SystemRuntime plugin to execute some code after attaching to a
/// process.
- //------------------------------------------------------------------
virtual void DidAttach();
- //------------------------------------------------------------------
/// Called after launching a process.
///
/// Allow the SystemRuntime plugin to execute some code after launching a
/// process.
- //------------------------------------------------------------------
virtual void DidLaunch();
- //------------------------------------------------------------------
/// 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 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 list of thread origin extended backtraces that may be
/// available.
///
@@ -119,14 +101,12 @@ public:
/// libdispatch queue origin. If there is none, then request the pthread
/// origin.
///
- /// @return
+ /// \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();
- //------------------------------------------------------------------
/// Return a Thread which shows the origin of this thread's creation.
///
/// This likely returns a HistoryThread which shows how thread was
@@ -137,25 +117,23 @@ public:
/// 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
+ /// \param [in] thread
/// The thread to examine.
///
- /// @param [in] type
+ /// \param [in] type
/// The type of thread origin being requested. The types supported
/// are returned from SystemRuntime::GetExtendedBacktraceTypes.
///
- /// @return
+ /// \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);
- //------------------------------------------------------------------
/// Get the extended backtrace thread for a QueueItem
///
/// A QueueItem represents a function/block that will be executed on
@@ -165,38 +143,34 @@ public:
/// This method will report a thread backtrace of the function that enqueued
/// it originally, if possible.
///
- /// @param [in] queue_item_sp
+ /// \param [in] queue_item_sp
/// The QueueItem that we are getting an extended backtrace for.
///
- /// @param [in] type
+ /// \param [in] type
/// The type of extended backtrace to fetch. The types supported
/// are returned from SystemRuntime::GetExtendedBacktraceTypes.
///
- /// @return
+ /// \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();
}
- //------------------------------------------------------------------
/// 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
+ /// \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 queue name for a thread given a thread's dispatch_qaddr.
///
/// On systems using libdispatch queues, a thread may be associated with a
@@ -205,19 +179,17 @@ public:
/// 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
+ /// \param [in] dispatch_qaddr
/// The address of the dispatch_qaddr pointer for this thread.
///
- /// @return
+ /// \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 QueueID for the libdispatch queue given the thread's
/// dispatch_qaddr.
///
@@ -227,18 +199,16 @@ public:
/// 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
+ /// \param [in] dispatch_qaddr
/// The address of the dispatch_qaddr pointer for this thread.
///
- /// @return
+ /// \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.
///
@@ -247,71 +217,62 @@ public:
/// the thread's dispatch_qaddr, find the libdispatch_queue_t address and
/// return it.
///
- /// @param [in] dispatch_qaddr
+ /// \param [in] dispatch_qaddr
/// The address of the dispatch_qaddr pointer for this thread.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \param [in] queue_item
/// The QueueItem that we will be completing.
///
- /// @param [in] item_ref
+ /// \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
+ /// \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) {}
@@ -321,22 +282,19 @@ public:
/// this method gives a way for it to flag that the expression should not be
/// run.
///
- /// @param [in] thread_sp
+ /// \param [in] thread_sp
/// The thread we want to run the expression on.
///
- /// @return
+ /// \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;
std::vector<ConstString> m_types;
diff --git a/include/lldb/Target/Target.h b/include/lldb/Target/Target.h
index 90df1f4929b77..4ed11afc31ba6 100644
--- a/include/lldb/Target/Target.h
+++ b/include/lldb/Target/Target.h
@@ -1,9 +1,8 @@
//===-- Target.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,10 +23,10 @@
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/UserSettingsController.h"
#include "lldb/Expression/Expression.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/ExecutionContextScope.h"
#include "lldb/Target/PathMappingList.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/SectionLoadHistory.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Broadcaster.h"
@@ -39,33 +38,31 @@ namespace lldb_private {
OptionEnumValues GetDynamicValueTypes();
-typedef enum InlineStrategy {
+enum InlineStrategy {
eInlineBreakpointsNever = 0,
eInlineBreakpointsHeaders,
eInlineBreakpointsAlways
-} InlineStrategy;
+};
-typedef enum LoadScriptFromSymFile {
+enum LoadScriptFromSymFile {
eLoadScriptFromSymFileTrue,
eLoadScriptFromSymFileFalse,
eLoadScriptFromSymFileWarn
-} LoadScriptFromSymFile;
+};
-typedef enum LoadCWDlldbinitFile {
+enum LoadCWDlldbinitFile {
eLoadCWDlldbinitTrue,
eLoadCWDlldbinitFalse,
eLoadCWDlldbinitWarn
-} LoadCWDlldbinitFile;
+};
-typedef enum LoadDependentFiles {
+enum LoadDependentFiles {
eLoadDependentsDefault,
eLoadDependentsYes,
eLoadDependentsNo,
-} LoadDependentFiles;
+};
-//----------------------------------------------------------------------
// TargetProperties
-//----------------------------------------------------------------------
class TargetExperimentalProperties : public Properties {
public:
TargetExperimentalProperties();
@@ -122,14 +119,18 @@ public:
PathMappingList &GetSourcePathMap() const;
- FileSpecList &GetExecutableSearchPaths();
+ FileSpecList GetExecutableSearchPaths();
- FileSpecList &GetDebugFileSearchPaths();
+ void AppendExecutableSearchPaths(const FileSpec&);
- FileSpecList &GetClangModuleSearchPaths();
+ FileSpecList GetDebugFileSearchPaths();
+
+ FileSpecList GetClangModuleSearchPaths();
bool GetEnableAutoImportClangModules() const;
+ bool GetEnableImportStdModule() const;
+
bool GetEnableAutoApplyFixIts() const;
bool GetEnableNotifyAboutFixIts() const;
@@ -207,9 +208,7 @@ public:
bool GetRequireHardwareBreakpoints() const;
private:
- //------------------------------------------------------------------
// Callbacks for m_launch_info.
- //------------------------------------------------------------------
static void Arg0ValueChangedCallback(void *target_property_ptr,
OptionValue *);
static void RunArgsValueChangedCallback(void *target_property_ptr,
@@ -231,9 +230,7 @@ private:
static void DisableSTDIOValueChangedCallback(void *target_property_ptr,
OptionValue *);
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
ProcessLaunchInfo m_launch_info;
std::unique_ptr<TargetExperimentalProperties> m_experimental_properties_up;
};
@@ -422,9 +419,7 @@ private:
mutable uint32_t m_pound_line_line;
};
-//----------------------------------------------------------------------
// Target
-//----------------------------------------------------------------------
class Target : public std::enable_shared_from_this<Target>,
public TargetProperties,
public Broadcaster,
@@ -433,9 +428,7 @@ class Target : public std::enable_shared_from_this<Target>,
public:
friend class TargetList;
- //------------------------------------------------------------------
/// Broadcaster event bits definitions.
- //------------------------------------------------------------------
enum {
eBroadcastBitBreakpointChanged = (1 << 0),
eBroadcastBitModulesLoaded = (1 << 1),
@@ -463,9 +456,9 @@ public:
~TargetEventData() override;
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
- const ConstString &GetFlavor() const override {
+ ConstString GetFlavor() const override {
return TargetEventData::GetFlavorString();
}
@@ -498,18 +491,46 @@ public:
static FileSpecList GetDefaultDebugFileSearchPaths();
- static FileSpecList GetDefaultClangModuleSearchPaths();
-
static ArchSpec GetDefaultArchitecture();
static void SetDefaultArchitecture(const ArchSpec &arch);
- lldb::ModuleSP GetSharedModule(const ModuleSpec &module_spec,
- Status *error_ptr = nullptr);
+ /// Find a binary on the system and return its Module,
+ /// or return an existing Module that is already in the Target.
+ ///
+ /// Given a ModuleSpec, find a binary satisifying that specification,
+ /// or identify a matching Module already present in the Target,
+ /// and return a shared pointer to it.
+ ///
+ /// \param[in] module_spec
+ /// The criteria that must be matched for the binary being loaded.
+ /// e.g. UUID, architecture, file path.
+ ///
+ /// \param[in] notify
+ /// If notify is true, and the Module is new to this Target,
+ /// Target::ModulesDidLoad will be called.
+ /// If notify is false, it is assumed that the caller is adding
+ /// multiple Modules and will call ModulesDidLoad with the
+ /// full list at the end.
+ /// ModulesDidLoad must be called when a Module/Modules have
+ /// been added to the target, one way or the other.
+ ///
+ /// \param[out] error_ptr
+ /// Optional argument, pointing to a Status object to fill in
+ /// with any results / messages while attempting to find/load
+ /// this binary. Many callers will be internal functions that
+ /// will handle / summarize the failures in a custom way and
+ /// don't use these messages.
+ ///
+ /// \return
+ /// An empty ModuleSP will be returned if no matching file
+ /// was found. If error_ptr was non-nullptr, an error message
+ /// will likely be provided.
+ lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec,
+ bool notify,
+ Status *error_ptr = nullptr);
- //----------------------------------------------------------------------
// Settings accessors
- //----------------------------------------------------------------------
static const lldb::TargetPropertiesSP &GetGlobalProperties();
@@ -519,7 +540,6 @@ public:
void CleanupProcess();
- //------------------------------------------------------------------
/// Dump a description of this object to a Stream.
///
/// Dump a description of the contents of this object to the
@@ -528,9 +548,8 @@ public:
/// is called, so this is a good way to see what has been parsed
/// in a target.
///
- /// @param[in] s
+ /// \param[in] s
/// The stream to which to dump the object description.
- //------------------------------------------------------------------
void Dump(Stream *s, lldb::DescriptionLevel description_level);
// If listener_sp is null, the listener of the owning Debugger object will be
@@ -551,9 +570,7 @@ public:
Status Attach(ProcessAttachInfo &attach_info,
Stream *stream); // Optional stream to receive first stop info
- //------------------------------------------------------------------
// This part handles the breakpoints.
- //------------------------------------------------------------------
BreakpointList &GetBreakpointList(bool internal = false);
@@ -681,12 +698,12 @@ public:
Status &error);
void RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
- const ConstString &name);
+ ConstString name);
- BreakpointName *FindBreakpointName(const ConstString &name, bool can_create,
+ BreakpointName *FindBreakpointName(ConstString name, bool can_create,
Status &error);
- void DeleteBreakpointName(const ConstString &name);
+ void DeleteBreakpointName(ConstString name);
void ConfigureBreakpointName(BreakpointName &bp_name,
const BreakpointOptions &options,
@@ -752,7 +769,6 @@ public:
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
@@ -762,12 +778,10 @@ public:
/// 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,
AddressClass addr_class = AddressClass::eInvalid) const;
- //------------------------------------------------------------------
/// Get \a load_addr as an opcode for this target.
///
/// Take \a load_addr and potentially strip any address bits that are
@@ -778,7 +792,6 @@ public:
/// 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,
AddressClass addr_class = AddressClass::eInvalid) const;
@@ -798,7 +811,6 @@ public:
void ClearModules(bool delete_locations);
- //------------------------------------------------------------------
/// Called as the last function in Process::DidExec().
///
/// Process::DidExec() will clear a lot of state in the process,
@@ -808,10 +820,8 @@ public:
/// 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
@@ -819,20 +829,18 @@ public:
/// dependent modules that are discovered from the object files, or
/// discovered at runtime as things are dynamically loaded.
///
- /// @return
+ /// \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&)
- //------------------------------------------------------------------
+ /// \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
@@ -848,17 +856,16 @@ public:
/// Process::GetImages() will return the newly found images that
/// were obtained from all of the object files.
///
- /// @param[in] module_sp
+ /// \param[in] module_sp
/// A shared pointer reference to the module that will become
/// the main executable for this process.
///
- /// @param[in] load_dependent_files
+ /// \param[in] load_dependent_files
/// If \b true then ask the object files to track down any
/// known dependent files.
///
- /// @see ObjectFile::GetDependentModules (FileSpecList&)
- /// @see Process::GetImages()
- //------------------------------------------------------------------
+ /// \see ObjectFile::GetDependentModules (FileSpecList&)
+ /// \see Process::GetImages()
void SetExecutableModule(
lldb::ModuleSP &module_sp,
LoadDependentFiles load_dependent_files = eLoadDependentsDefault);
@@ -870,7 +877,6 @@ public:
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
@@ -886,14 +892,12 @@ public:
/// addresses is each image, and also in images that are loaded by
/// code.
///
- /// @return
+ /// \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.
///
@@ -905,14 +909,12 @@ public:
/// The target call at present just consults the Platform's call of the
/// same name.
///
- /// @param[in] module_sp
+ /// \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.
- //------------------------------------------------------------------
+ /// \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
@@ -927,17 +929,15 @@ public:
/// that they
/// don't want searched, in addition to or instead of the platform ones.
///
- /// @param[in] module_sp
+ /// \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.
- //------------------------------------------------------------------
+ /// \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.GetSpec(); }
- //------------------------------------------------------------------
/// Set the architecture for this target.
///
/// If the current target has no Images read in, then this just sets the
@@ -951,19 +951,18 @@ public:
/// 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
+ /// \param[in] arch_spec
/// The new architecture.
///
- /// @param[in] set_platform
+ /// \param[in] set_platform
/// If \b true, then the platform will be adjusted if the currently
/// selected platform is not compatible with the archicture being set.
/// If \b false, then just the architecture will be set even if the
/// currently selected platform isn't compatible (in case it might be
/// manually set following this function call).
///
- /// @return
+ /// \return
/// \b true if the architecture was successfully set, \bfalse otherwise.
- //------------------------------------------------------------------
bool SetArchitecture(const ArchSpec &arch_spec, bool set_platform = false);
bool MergeArchitecture(const ArchSpec &arch_spec);
@@ -1015,9 +1014,7 @@ public:
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;
@@ -1044,7 +1041,8 @@ public:
UserExpression *GetUserExpressionForLanguage(
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options, Status &error);
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj, Status &error);
// Creates a FunctionCaller for the given language, the rest of the
// parameters have the same meaning as for the FunctionCaller constructor.
@@ -1073,10 +1071,8 @@ public:
lldb::ClangASTImporterSP GetClangASTImporter();
- //----------------------------------------------------------------------
// Install any files through the platform that need be to installed prior to
// launching or attaching.
- //----------------------------------------------------------------------
Status Install(ProcessLaunchInfo *launch_info);
bool ResolveFileAddress(lldb::addr_t load_addr, Address &so_addr);
@@ -1103,25 +1099,24 @@ public:
// 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.
+ // the 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);
+ std::string *fixed_expression = nullptr,
+ ValueObject *ctx_obj = nullptr);
- lldb::ExpressionVariableSP GetPersistentVariable(const ConstString &name);
+ lldb::ExpressionVariableSP GetPersistentVariable(ConstString name);
/// Return the next available number for numbered persistent variables.
unsigned GetNextPersistentVariableIndex() {
return m_next_persistent_variable_index++;
}
- lldb::addr_t GetPersistentSymbol(const ConstString &name);
+ lldb::addr_t GetPersistentSymbol(ConstString name);
- //------------------------------------------------------------------
// Target Stop Hooks
- //------------------------------------------------------------------
class StopHook : public UserID {
public:
StopHook(const StopHook &rhs);
@@ -1146,20 +1141,25 @@ public:
// and is responsible for deleting it when we're done.
void SetThreadSpecifier(ThreadSpec *specifier);
- ThreadSpec *GetThreadSpecifier() { return m_thread_spec_ap.get(); }
+ ThreadSpec *GetThreadSpecifier() { return m_thread_spec_up.get(); }
bool IsActive() { return m_active; }
void SetIsActive(bool is_active) { m_active = is_active; }
+ void SetAutoContinue(bool auto_continue) {m_auto_continue = auto_continue;}
+
+ bool GetAutoContinue() const { return m_auto_continue; }
+
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;
+ std::unique_ptr<ThreadSpec> m_thread_spec_up;
+ bool m_active = true;
+ bool m_auto_continue = false;
// Use CreateStopHook to make a new empty stop hook. The GetCommandPointer
// and fill it with commands, and SetSpecifier to set the specifier shared
@@ -1219,9 +1219,7 @@ public:
ClangModulesDeclVendor *GetClangModulesDeclVendor();
- //------------------------------------------------------------------
// Methods.
- //------------------------------------------------------------------
lldb::SearchFilterSP
GetSearchFilterForModule(const FileSpec *containingModule);
@@ -1238,20 +1236,21 @@ public:
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 NotifyModuleAdded(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) override;
+
+ void NotifyModuleRemoved(const ModuleList &module_list,
+ const lldb::ModuleSP &module_sp) override;
+
+ void NotifyModuleUpdated(const ModuleList &module_list,
+ const lldb::ModuleSP &old_module_sp,
+ const lldb::ModuleSP &new_module_sp) override;
- void ModuleRemoved(const ModuleList &module_list,
- const lldb::ModuleSP &module_sp) override;
+ void NotifyWillClearList(const ModuleList &module_list) 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;
+ void NotifyModulesRemoved(lldb_private::ModuleList &module_list) override;
class Arch {
public:
@@ -1265,9 +1264,7 @@ protected:
ArchSpec m_spec;
std::unique_ptr<Architecture> m_plugin_up;
};
- //------------------------------------------------------------------
// 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*
@@ -1296,9 +1293,9 @@ protected:
REPLMap m_repl_map;
lldb::ClangASTImporterSP m_ast_importer_sp;
- lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_ap;
+ lldb::ClangModulesDeclVendorUP m_clang_modules_decl_vendor_up;
- lldb::SourceManagerUP m_source_manager_ap;
+ lldb::SourceManagerUP m_source_manager_up;
typedef std::map<lldb::user_id_t, StopHookSP> StopHookCollection;
StopHookCollection m_stop_hooks;
@@ -1311,9 +1308,7 @@ protected:
static void ImageSearchPathsChanged(const PathMappingList &path_list,
void *baton);
- //------------------------------------------------------------------
// Utilities for `statistics` command.
- //------------------------------------------------------------------
private:
std::vector<uint32_t> m_stats_storage;
bool m_collecting_stats = false;
@@ -1334,15 +1329,13 @@ public:
std::vector<uint32_t> GetStatistics() { return m_stats_storage; }
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*)
- //------------------------------------------------------------------
+ /// \see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
Target(Debugger &debugger, const ArchSpec &target_arch,
const lldb::PlatformSP &platform_sp, bool is_dummy_target);
diff --git a/include/lldb/Target/TargetList.h b/include/lldb/Target/TargetList.h
index 90c480745a0cb..ece0705ae71c0 100644
--- a/include/lldb/Target/TargetList.h
+++ b/include/lldb/Target/TargetList.h
@@ -1,9 +1,8 @@
//===-- TargetList.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,21 +21,17 @@ 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().
- //------------------------------------------------------------------
+ /// \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:
@@ -49,7 +44,6 @@ public:
~TargetList() override;
- //------------------------------------------------------------------
/// Create a new Target.
///
/// Clients must use this function to create a Target. This allows
@@ -58,68 +52,63 @@ public:
/// locate an appropriate target to deliver asynchronous information
/// to.
///
- /// @param[in] debugger
+ /// \param[in] debugger
/// The debugger to associate this target with
///
- /// @param[in] file_spec
+ /// \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
+ /// \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
+ /// \param[in] get_dependent_modules
/// Track down the dependent modules for an executable and
/// load those into the module list.
///
- /// @param[in] platform_options
+ /// \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
+ /// \param[out] target_sp
/// A shared pointer to a target that will be filled in if
/// this call is successful.
///
- /// @return
+ /// \return
/// An error object that indicates success or failure
- //------------------------------------------------------------------
Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path,
llvm::StringRef triple_str,
LoadDependentFiles 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
- //------------------------------------------------------------------
Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path,
const ArchSpec &arch,
LoadDependentFiles 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
+ /// \param[in] target_sp
/// The shared pointer to a target.
///
- /// @return
+ /// \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;
@@ -128,12 +117,11 @@ public:
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
+ /// \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
@@ -141,53 +129,48 @@ public:
/// compared. If \a exe_file_spec contains a filename and a
/// directory, then both must match.
///
- /// @param[in] exe_arch_ptr
+ /// \param[in] exe_arch_ptr
/// If not nullptr then the architecture also needs to match, else
/// the architectures will be compared.
///
- /// @return
+ /// \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
+ /// \param[in] pid
/// The process ID to search our target list for.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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);
@@ -198,9 +181,7 @@ public:
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;
diff --git a/include/lldb/Target/Thread.h b/include/lldb/Target/Thread.h
index 0d14b10c651f1..7aeaece5b5d51 100644
--- a/include/lldb/Target/Thread.h
+++ b/include/lldb/Target/Thread.h
@@ -1,9 +1,8 @@
//===-- Thread.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,18 +34,16 @@ public:
~ThreadProperties() override;
- //------------------------------------------------------------------
/// The regular expression returned determines symbols that this
/// thread won't stop in during "step-in" operations.
///
- /// @return
+ /// \return
/// A pointer to a regular expression to compare against symbols,
/// or nullptr if all symbols are allowed.
///
- //------------------------------------------------------------------
const RegularExpression *GetSymbolsToAvoidRegexp();
- FileSpecList &GetLibrariesToAvoid() const;
+ FileSpecList GetLibrariesToAvoid() const;
bool GetTraceEnabledState() const;
@@ -65,9 +62,7 @@ class Thread : public std::enable_shared_from_this<Thread>,
public ExecutionContextScope,
public Broadcaster {
public:
- //------------------------------------------------------------------
/// Broadcaster event bits definitions.
- //------------------------------------------------------------------
enum {
eBroadcastBitStackChanged = (1 << 0),
eBroadcastBitThreadSuspended = (1 << 1),
@@ -92,9 +87,9 @@ public:
~ThreadEventData() override;
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
- const ConstString &GetFlavor() const override {
+ ConstString GetFlavor() const override {
return ThreadEventData::GetFlavorString();
}
@@ -131,14 +126,13 @@ public:
lldb::addr_t current_inlined_pc;
};
- //------------------------------------------------------------------
/// Constructor
///
- /// @param [in] process
+ /// \param [in] process
///
- /// @param [in] tid
+ /// \param [in] tid
///
- /// @param [in] use_invalid_index_id
+ /// \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
@@ -147,7 +141,6 @@ public:
/// 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;
@@ -168,7 +161,6 @@ public:
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,
@@ -189,25 +181,22 @@ public:
/// 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
+ /// \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
+ /// \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
@@ -267,7 +256,6 @@ public:
virtual const char *GetInfo() { return nullptr; }
- //------------------------------------------------------------------
/// Retrieve a dictionary of information about this thread
///
/// On Mac OS X systems there may be voucher information.
@@ -278,7 +266,6 @@ public:
/// array
/// being a dictionary (keys include "message" with the text of the trace
/// message).
- //------------------------------------------------------------------
StructuredData::ObjectSP GetExtendedInfo() {
if (!m_extended_info_fetched) {
m_extended_info = FetchThreadExtendedInfo();
@@ -291,7 +278,6 @@ public:
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,
@@ -299,7 +285,7 @@ public:
/// queue, or it may be unknown whether it is associated with a libdispatch
/// queue.
///
- /// @return
+ /// \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).
@@ -308,7 +294,6 @@ public:
///
/// 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;
}
@@ -316,7 +301,6 @@ public:
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,
@@ -327,29 +311,25 @@ public:
/// queues and incrementing, a QueueID will not be reused for a
/// different queue during the lifetime of a process.
///
- /// @return
+ /// \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
+ /// \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,
@@ -357,27 +337,23 @@ public:
/// eQueueKindConcurrent, indicating that this queue processes work
/// items serially or concurrently.
///
- /// @return
+ /// \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
+ /// \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
///
@@ -389,17 +365,15 @@ public:
/// lifetime and should not be used to identify a queue uniquely. Use
/// the GetQueueID() call for that.
///
- /// @return
+ /// \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
@@ -412,7 +386,6 @@ public:
/// 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() {
@@ -500,102 +473,89 @@ public:
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
+ /// \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
+ /// \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
+ /// \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
+ /// \return
/// An error that describes anything that went wrong
- //------------------------------------------------------------------
virtual Status
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
+ /// \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
+ /// \return
/// An error that describes anything that went wrong
- //------------------------------------------------------------------
virtual Status 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
+ /// \return
/// An error that describes anything that went wrong
- //------------------------------------------------------------------
virtual Status 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
+ /// \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
+ /// \param[in] module
/// The module to query TLS data for.
///
- /// @param[in] tls_file_addr
+ /// \param[in] tls_file_addr
/// The thread local address in module
- /// @return
+ /// \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
+ /// \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
@@ -618,69 +578,63 @@ public:
// 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
+ /// \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
+ /// \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
+ /// \param[in] step_over
/// \b true if we step over calls to functions, false if we step in.
///
- /// @param[in] abort_other_plans
+ /// \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
+ /// \param[in] stop_other_threads
/// \b true if we will stop other threads while we single step this one.
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @return
+ /// \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,
Status &status);
- //------------------------------------------------------------------
/// Queues the plan used to step through an address range, stepping over
/// function calls.
///
- /// @param[in] abort_other_plans
+ /// \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
+ /// \param[in] type
/// Type of step to do, only eStepTypeInto and eStepTypeOver are supported
/// by this plan.
///
- /// @param[in] range
+ /// \param[in] range
/// The address range to step through.
///
- /// @param[in] addr_context
+ /// \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
@@ -689,21 +643,20 @@ public:
/// is supposed to be out of.
// FIXME: Currently unused.
///
- /// @param[in] stop_other_threads
+ /// \param[in] stop_other_threads
/// \b true if we will stop other threads while we single step this one.
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @param[in] step_out_avoids_code_without_debug_info
+ /// \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
+ /// \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,
@@ -719,23 +672,22 @@ public:
Status &status,
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
+ /// \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
+ /// \param[in] type
/// Type of step to do, only eStepTypeInto and eStepTypeOver are supported
/// by this plan.
///
- /// @param[in] range
+ /// \param[in] range
/// The address range to step through.
///
- /// @param[in] addr_context
+ /// \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
@@ -744,30 +696,29 @@ public:
/// is supposed to be out of.
// FIXME: Currently unused.
///
- /// @param[in] step_in_target
+ /// \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
+ /// \param[in] stop_other_threads
/// \b true if we will stop other threads while we single step this one.
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @param[in] step_in_avoids_code_without_debug_info
+ /// \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
+ /// \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
+ /// \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,
@@ -785,16 +736,15 @@ public:
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
+ /// \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
+ /// \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
@@ -803,47 +753,45 @@ public:
/// is supposed to be out of.
// FIXME: Currently unused.
///
- /// @param[in] first_insn
+ /// \param[in] first_insn
/// \b true if this is the first instruction of a function.
///
- /// @param[in] stop_other_threads
+ /// \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
+ /// \param[in] stop_vote
+ /// \param[in] run_vote
/// See standard meanings for the stop & run votes in ThreadPlan.h.
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @param[in] step_out_avoids_code_without_debug_info
+ /// \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
+ /// \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, Vote run_vote,
uint32_t frame_idx, Status &status,
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
+ /// \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
+ /// \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
@@ -852,23 +800,23 @@ public:
/// is supposed to be out of.
// FIXME: Currently unused.
///
- /// @param[in] first_insn
+ /// \param[in] first_insn
/// \b true if this is the first instruction of a function.
///
- /// @param[in] stop_other_threads
+ /// \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] stop_vote
///
- /// @param[in] run_vote
+ /// \param[in] run_vote
/// See standard meanings for the stop & run votes in ThreadPlan.h.
///
- /// @param[in] frame_idx
+ /// \param[in] frame_idx
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @param[in] continue_to_next_branch
+ /// \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
@@ -885,67 +833,62 @@ public:
/// registers which are overwritten
/// before the next branch instruction.
///
- /// @return
+ /// \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, Vote run_vote,
uint32_t frame_idx, Status &status, 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
+ /// \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
+ /// \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
+ /// \param[in] stop_other_threads
/// \b true if we will stop other threads while we single step this one.
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @return
+ /// \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,
Status &status);
- //------------------------------------------------------------------
/// 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
+ /// \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
+ /// \param[in] target_addr
/// The address to which we're running.
///
- /// @param[in] stop_other_threads
+ /// \param[in] stop_other_threads
/// \b true if we will stop other threads while we single step this one.
///
- /// @param[out] status
+ /// \param[out] status
/// A status with an error if queuing failed.
///
- /// @return
+ /// \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, Status &status);
@@ -958,150 +901,122 @@ public:
QueueThreadPlanForStepScripted(bool abort_other_plans, const char *class_name,
bool stop_other_threads, Status &status);
- //------------------------------------------------------------------
// Thread Plan accessors:
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Gets the plan which will execute next on the plan stack.
///
- /// @return
+ /// \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
+ /// \return
/// An error if the thread plan could not be unwound.
- //------------------------------------------------------------------
Status 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
+ /// \return
/// A pointer to the last completed plan.
- //------------------------------------------------------------------
lldb::ThreadPlanSP GetCompletedPlan();
- //------------------------------------------------------------------
/// Gets the outer-most return value from the completed plans
///
- /// @return
+ /// \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
+ /// \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
+ /// \param[in] plan
/// Pointer to the plan you're checking.
///
- /// @return
+ /// \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
+ /// \param[in] plan
/// Pointer to the plan you're checking.
///
- /// @return
+ /// \return
/// Returns true if the input plan is in the discarded plan stack,
/// false otherwise.
- //------------------------------------------------------------------
bool WasThreadPlanDiscarded(ThreadPlan *plan);
- //------------------------------------------------------------------
/// Check if we have completed plan to override breakpoint stop reason
///
- /// @return
+ /// \return
/// Returns true if completed plan stack is not empty
/// false otherwise.
- //------------------------------------------------------------------
bool CompletedPlanOverridesBreakpoint();
- //------------------------------------------------------------------
/// Queues a generic thread plan.
///
- /// @param[in] plan_sp
+ /// \param[in] plan_sp
/// The plan to queue.
///
- /// @param[in] abort_other_plans
+ /// \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
+ /// \return
/// A pointer to the last completed plan.
- //------------------------------------------------------------------
Status 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
+ // \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
+ /// \param[in] up_to_plan_sp
/// Discard all plans up to and including this user plan given by this
/// index.
///
- /// @return
+ /// \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
+ /// \param[in] s
/// The stream to which to dump the plan stack info.
///
- //------------------------------------------------------------------
void DumpThreadPlans(
Stream *s,
lldb::DescriptionLevel desc_level = lldb::eDescriptionLevelVerbose,
@@ -1119,15 +1034,12 @@ public:
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
@@ -1137,22 +1049,17 @@ public:
// 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;
@@ -1195,18 +1102,15 @@ public:
// 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
+ // \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
@@ -1220,7 +1124,6 @@ public:
// is resumed
// eStateSuspended - thread should not execute any instructions when
// process is resumed
- //----------------------------------------------------------------------
lldb::StateType GetTemporaryResumeState() const {
return m_temporary_resume_state;
}
@@ -1231,26 +1134,22 @@ public:
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
- //----------------------------------------------------------------------
+ /// \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
+ /// \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; }
lldb::ValueObjectSP GetCurrentException();
@@ -1306,9 +1205,7 @@ protected:
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
@@ -1348,7 +1245,7 @@ protected:
///thread plan logic for the current
///resume.
/// It gets set in Thread::ShouldResume.
- std::unique_ptr<lldb_private::Unwind> m_unwinder_ap;
+ std::unique_ptr<lldb_private::Unwind> m_unwinder_up;
bool m_destroy_called; // This is used internally to make sure derived Thread
// classes call DestroyThread.
LazyBool m_override_should_notify;
diff --git a/include/lldb/Target/ThreadCollection.h b/include/lldb/Target/ThreadCollection.h
index dd5e81c1af480..29ea827203e5e 100644
--- a/include/lldb/Target/ThreadCollection.h
+++ b/include/lldb/Target/ThreadCollection.h
@@ -1,9 +1,8 @@
//===-- ThreadCollection.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadList.h b/include/lldb/Target/ThreadList.h
index 6285cb1e0fb46..64ddf5aea504a 100644
--- a/include/lldb/Target/ThreadList.h
+++ b/include/lldb/Target/ThreadList.h
@@ -1,9 +1,8 @@
//===-- ThreadList.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -111,19 +110,17 @@ public:
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
+ /// \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();
@@ -145,9 +142,7 @@ protected:
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.
@@ -156,7 +151,7 @@ protected:
std::vector<lldb::tid_t> m_expression_tid_stack;
private:
- ThreadList();
+ ThreadList() = delete;
};
} // namespace lldb_private
diff --git a/include/lldb/Target/ThreadPlan.h b/include/lldb/Target/ThreadPlan.h
index 15bc4c7656c38..ff87ed23cda54 100644
--- a/include/lldb/Target/ThreadPlan.h
+++ b/include/lldb/Target/ThreadPlan.h
@@ -1,9 +1,8 @@
//===-- ThreadPlan.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,7 +22,6 @@
namespace lldb_private {
-//------------------------------------------------------------------
// ThreadPlan:
// This is the pure virtual base class for thread plans.
//
@@ -329,16 +327,15 @@ namespace lldb_private {
// 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 {
public:
- typedef enum { eAllThreads, eSomeThreads, eThisThread } ThreadScope;
+ enum ThreadScope { eAllThreads, eSomeThreads, eThisThread };
// 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 {
+ enum ThreadPlanKind {
eKindGeneric,
eKindNull,
eKindBase,
@@ -354,30 +351,24 @@ public:
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
+ /// \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
+ /// \return
/// A pointer to the thread plan's owning thread.
- //------------------------------------------------------------------
Thread &GetThread() { return m_thread; }
const Thread &GetThread() const { return m_thread; }
@@ -386,30 +377,26 @@ public:
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
+ /// \param[in] s
/// The stream to which to print the description.
///
- /// @param[in] level
+ /// \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
+ /// \param[in] error
/// A stream to which to print some reason why the plan could not be
/// created.
/// Can be NULL.
///
- /// @return
+ /// \return
/// \b true if the plan should be queued, \b false otherwise.
- //------------------------------------------------------------------
virtual bool ValidatePlan(Stream *error) = 0;
bool TracerExplainsStop() {
@@ -557,9 +544,7 @@ public:
}
protected:
- //------------------------------------------------------------------
// Classes that inherit from ThreadPlan can see and modify these
- //------------------------------------------------------------------
virtual bool DoWillResume(lldb::StateType resume_state, bool current_plan) {
return true;
@@ -605,9 +590,7 @@ protected:
int32_t m_iteration_count = 1;
private:
- //------------------------------------------------------------------
// For ThreadPlan only
- //------------------------------------------------------------------
static lldb::user_id_t GetNextID();
ThreadPlanKind m_kind;
@@ -626,13 +609,11 @@ private:
DISALLOW_COPY_AND_ASSIGN(ThreadPlan);
};
-//----------------------------------------------------------------------
// ThreadPlanNull:
// Threads are assumed to always have at least one plan on the plan stack. This
// is put on the plan stack when a thread is destroyed so that if you
// accidentally access a thread after it is destroyed you won't crash. But
// asking questions of the ThreadPlanNull is definitely an error.
-//----------------------------------------------------------------------
class ThreadPlanNull : public ThreadPlan {
public:
diff --git a/include/lldb/Target/ThreadPlanBase.h b/include/lldb/Target/ThreadPlanBase.h
index bcf20c5544bc4..bc92a06229a76 100644
--- a/include/lldb/Target/ThreadPlanBase.h
+++ b/include/lldb/Target/ThreadPlanBase.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanBase.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,12 +15,10 @@
namespace lldb_private {
-//------------------------------------------------------------------
// Base thread plans:
// 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.
diff --git a/include/lldb/Target/ThreadPlanCallFunction.h b/include/lldb/Target/ThreadPlanCallFunction.h
index 3bec86e370d18..685160a5678ae 100644
--- a/include/lldb/Target/ThreadPlanCallFunction.h
+++ b/include/lldb/Target/ThreadPlanCallFunction.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallFunction.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
index 9b75da5fd2f88..c21e4d3cf3f76 100644
--- a/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
+++ b/include/lldb/Target/ThreadPlanCallFunctionUsingABI.h
@@ -1,10 +1,9 @@
//===-- ThreadPlanCallFunctionUsingABI.h --------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
index c7ea368cca6ae..ad3ee6e0e8f9c 100644
--- a/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
+++ b/include/lldb/Target/ThreadPlanCallOnFunctionExit.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallOnFunctionExit.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,9 +29,7 @@ public:
void DidPush() override;
- // -------------------------------------------------------------------------
// ThreadPlan API
- // -------------------------------------------------------------------------
void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
diff --git a/include/lldb/Target/ThreadPlanCallUserExpression.h b/include/lldb/Target/ThreadPlanCallUserExpression.h
index ba1001ce5e916..6372155824104 100644
--- a/include/lldb/Target/ThreadPlanCallUserExpression.h
+++ b/include/lldb/Target/ThreadPlanCallUserExpression.h
@@ -1,10 +1,9 @@
//===-- ThreadPlanCallUserExpression.h --------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanPython.h b/include/lldb/Target/ThreadPlanPython.h
index fc4cfb3bf0b42..3825bf6ee4f31 100644
--- a/include/lldb/Target/ThreadPlanPython.h
+++ b/include/lldb/Target/ThreadPlanPython.h
@@ -1,10 +1,9 @@
//===-- ThreadPlanPython.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,10 +24,8 @@
namespace lldb_private {
-//------------------------------------------------------------------
// ThreadPlanPython:
//
-//------------------------------------------------------------------
class ThreadPlanPython : public ThreadPlan {
public:
diff --git a/include/lldb/Target/ThreadPlanRunToAddress.h b/include/lldb/Target/ThreadPlanRunToAddress.h
index 58608864d4632..d82a9fad548a5 100644
--- a/include/lldb/Target/ThreadPlanRunToAddress.h
+++ b/include/lldb/Target/ThreadPlanRunToAddress.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanRunToAddress.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanShouldStopHere.h b/include/lldb/Target/ThreadPlanShouldStopHere.h
index d3aca3e6f5c06..dfcbbb355c548 100644
--- a/include/lldb/Target/ThreadPlanShouldStopHere.h
+++ b/include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanShouldStopHere.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -63,9 +62,7 @@ public:
eStepOutAvoidNoDebug = (1 << 2)
};
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
ThreadPlanShouldStopHere(ThreadPlan *owner);
ThreadPlanShouldStopHere(ThreadPlan *owner,
diff --git a/include/lldb/Target/ThreadPlanStepInRange.h b/include/lldb/Target/ThreadPlanStepInRange.h
index c13b3533af1c9..a120c98fb36e1 100644
--- a/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/include/lldb/Target/ThreadPlanStepInRange.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepInRange.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -93,7 +92,7 @@ private:
// 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;
+ std::unique_ptr<RegularExpression> m_avoid_regexp_up;
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.
diff --git a/include/lldb/Target/ThreadPlanStepInstruction.h b/include/lldb/Target/ThreadPlanStepInstruction.h
index ea5d93fa4944d..127de417f6eb9 100644
--- a/include/lldb/Target/ThreadPlanStepInstruction.h
+++ b/include/lldb/Target/ThreadPlanStepInstruction.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepInstruction.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanStepOut.h b/include/lldb/Target/ThreadPlanStepOut.h
index 8ef9f95d4f967..00984db2dca97 100644
--- a/include/lldb/Target/ThreadPlanStepOut.h
+++ b/include/lldb/Target/ThreadPlanStepOut.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOut.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
index 7aaf56ed7c0b2..7df7049b568a4 100644
--- a/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
+++ b/include/lldb/Target/ThreadPlanStepOverBreakpoint.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOverBreakpoint.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanStepOverRange.h b/include/lldb/Target/ThreadPlanStepOverRange.h
index 2eeb2bb96022c..30763e3861fa1 100644
--- a/include/lldb/Target/ThreadPlanStepOverRange.h
+++ b/include/lldb/Target/ThreadPlanStepOverRange.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOverRange.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanStepRange.h b/include/lldb/Target/ThreadPlanStepRange.h
index b3e267a0827b4..93d54ad7dfd5a 100644
--- a/include/lldb/Target/ThreadPlanStepRange.h
+++ b/include/lldb/Target/ThreadPlanStepRange.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepRange.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanStepThrough.h b/include/lldb/Target/ThreadPlanStepThrough.h
index 1bff541e7df63..0d0621227b535 100644
--- a/include/lldb/Target/ThreadPlanStepThrough.h
+++ b/include/lldb/Target/ThreadPlanStepThrough.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepThrough.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanStepUntil.h b/include/lldb/Target/ThreadPlanStepUntil.h
index 33ccc0fa0d54e..9a5934a36d7d4 100644
--- a/include/lldb/Target/ThreadPlanStepUntil.h
+++ b/include/lldb/Target/ThreadPlanStepUntil.h
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepUntil.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Target/ThreadPlanTracer.h b/include/lldb/Target/ThreadPlanTracer.h
index 21f9023f8d578..80b08078e975e 100644
--- a/include/lldb/Target/ThreadPlanTracer.h
+++ b/include/lldb/Target/ThreadPlanTracer.h
@@ -1,10 +1,9 @@
//===-- ThreadPlanTracer.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,12 +21,12 @@ class ThreadPlanTracer {
friend class ThreadPlan;
public:
- typedef enum ThreadPlanTracerStyle {
+ enum ThreadPlanTracerStyle {
eLocation = 0,
eStateChange,
eCheckFrames,
ePython
- } ThreadPlanTracerStyle;
+ };
ThreadPlanTracer(Thread &thread, lldb::StreamSP &stream_sp);
ThreadPlanTracer(Thread &thread);
diff --git a/include/lldb/Target/ThreadSpec.h b/include/lldb/Target/ThreadSpec.h
index 34baf80462618..05e7dcdb38d3c 100644
--- a/include/lldb/Target/ThreadSpec.h
+++ b/include/lldb/Target/ThreadSpec.h
@@ -1,9 +1,8 @@
//===-- ThreadSpec.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,10 +34,6 @@ class ThreadSpec {
public:
ThreadSpec();
- ThreadSpec(const ThreadSpec &rhs);
-
- const ThreadSpec &operator=(const ThreadSpec &rhs);
-
static std::unique_ptr<ThreadSpec>
CreateFromStructuredData(const StructuredData::Dictionary &data_dict,
Status &error);
diff --git a/include/lldb/Target/UnixSignals.h b/include/lldb/Target/UnixSignals.h
index 8774139371f01..120ffdd7ae254 100644
--- a/include/lldb/Target/UnixSignals.h
+++ b/include/lldb/Target/UnixSignals.h
@@ -1,9 +1,8 @@
//===-- UnixSignals.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,10 +22,9 @@ namespace lldb_private {
class UnixSignals {
public:
static lldb::UnixSignalsSP Create(const ArchSpec &arch);
+ static lldb::UnixSignalsSP CreateForHost();
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
UnixSignals();
virtual ~UnixSignals();
@@ -95,9 +93,7 @@ public:
llvm::Optional<bool> should_notify);
protected:
- //------------------------------------------------------------------
// Classes that inherit from UnixSignals can see and modify these
- //------------------------------------------------------------------
struct Signal {
ConstString m_name;
diff --git a/include/lldb/Target/Unwind.h b/include/lldb/Target/Unwind.h
index 9e0da9ed553b5..a648e063e34b2 100644
--- a/include/lldb/Target/Unwind.h
+++ b/include/lldb/Target/Unwind.h
@@ -1,9 +1,8 @@
//===-- Unwind.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@ namespace lldb_private {
class Unwind {
protected:
- //------------------------------------------------------------------
// Classes that inherit from Unwind can see and modify these
- //------------------------------------------------------------------
Unwind(Thread &thread) : m_thread(thread), m_unwind_mutex() {}
public:
@@ -63,9 +60,7 @@ public:
Thread &GetThread() { return m_thread; }
protected:
- //------------------------------------------------------------------
// Classes that inherit from Unwind can see and modify these
- //------------------------------------------------------------------
virtual void DoClear() = 0;
virtual uint32_t DoGetFrameCount() = 0;
diff --git a/include/lldb/Target/UnwindAssembly.h b/include/lldb/Target/UnwindAssembly.h
index 3028ffeaa51d3..a70aef6e93c52 100644
--- a/include/lldb/Target/UnwindAssembly.h
+++ b/include/lldb/Target/UnwindAssembly.h
@@ -1,9 +1,8 @@
//===-- UnwindAssembly.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -45,7 +44,7 @@ protected:
ArchSpec m_arch;
private:
- UnwindAssembly(); // Outlaw default constructor
+ UnwindAssembly() = delete;
DISALLOW_COPY_AND_ASSIGN(UnwindAssembly);
};
diff --git a/include/lldb/Utility/AnsiTerminal.h b/include/lldb/Utility/AnsiTerminal.h
index b5ff239f800d1..1473c60eeaf2b 100644
--- a/include/lldb/Utility/AnsiTerminal.h
+++ b/include/lldb/Utility/AnsiTerminal.h
@@ -1,9 +1,8 @@
//===---------------------AnsiTerminal.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/ArchSpec.h b/include/lldb/Utility/ArchSpec.h
index e84cbbbe5efad..7a32556310c43 100644
--- a/include/lldb/Utility/ArchSpec.h
+++ b/include/lldb/Utility/ArchSpec.h
@@ -1,9 +1,8 @@
//===-- ArchSpec.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,15 +22,13 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ArchSpec ArchSpec.h "lldb/Utility/ArchSpec.h" An architecture
+/// \class ArchSpec ArchSpec.h "lldb/Utility/ArchSpec.h" An architecture
/// specification class.
///
/// A class designed to be created from a cpu type and subtype, a
/// string representation, or an llvm::Triple. Keeping all of the conversions
/// of strings to architecture enumeration values confined to this class
/// allows new architecture support to be added easily.
-//----------------------------------------------------------------------
class ArchSpec {
public:
enum MIPSSubType {
@@ -186,10 +183,6 @@ public:
eCore_uknownMach32,
eCore_uknownMach64,
- eCore_kalimba3,
- eCore_kalimba4,
- eCore_kalimba5,
-
kNumCores,
kCore_invalid,
@@ -223,9 +216,6 @@ public:
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,
@@ -243,131 +233,99 @@ public:
};
- //------------------------------------------------------------------
/// 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);
- //------------------------------------------------------------------
/// 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.
+ /// \param[in] rhs another ArchSpec object to copy.
///
- /// @return A const reference to this object.
- //------------------------------------------------------------------
+ /// \return A const reference to this object.
const ArchSpec &operator=(const ArchSpec &rhs);
- //---------------------------------------------------------------------------
/// Returns true if the OS, vendor and environment fields of the triple are
/// unset. The triple is expected to be normalized
/// (llvm::Triple::normalize).
- //---------------------------------------------------------------------------
static bool ContainsOnlyArch(const llvm::Triple &normalized_triple);
static void ListSupportedArchNames(StringList &list);
static size_t AutoComplete(CompletionRequest &request);
- //------------------------------------------------------------------
/// Returns a static string representing the current architecture.
///
- /// @return A static string corresponding to the current
+ /// \return A static string corresponding to the current
/// architecture.
- //------------------------------------------------------------------
const char *GetArchitectureName() const;
- //-----------------------------------------------------------------
/// if MIPS architecture return true.
///
- /// @return a boolean value.
- //-----------------------------------------------------------------
+ /// \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
+ /// \return A string representing target CPU for the current
/// architecture.
- //------------------------------------------------------------------
std::string GetClangTargetCPU() const;
- //------------------------------------------------------------------
/// Return a string representing target application ABI.
///
- /// @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.
- //------------------------------------------------------------------
+ /// \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.
- //------------------------------------------------------------------
+ /// \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,
+ /// \return A ConstString ref containing the distribution id,
/// potentially empty.
- //------------------------------------------------------------------
- const ConstString &GetDistributionId() 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
+ /// \return True if the current architecture is valid, false
/// otherwise.
- //------------------------------------------------------------------
bool IsValid() const {
return m_core >= eCore_arm_generic && m_core < kNumCores;
}
@@ -377,23 +335,12 @@ public:
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();
+ return m_triple.hasEnvironment();
}
- //------------------------------------------------------------------
/// Merges fields from another ArchSpec into this ArchSpec.
///
/// This will use the supplied ArchSpec to fill in any fields of the triple
@@ -403,23 +350,21 @@ public:
/// 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] arch_type The object type of this ArchSpec.
///
- /// @param[in] cpu The required CPU type.
+ /// \param[in] cpu The required CPU type.
///
- /// @param[in] os The optional OS 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.
+ /// \return True if the object, and CPU were successfully set.
///
/// As a side effect, the vendor value is usually set to unknown. The
/// exceptions are
@@ -441,26 +386,21 @@ public:
/// *-*-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
+ /// \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;
@@ -473,39 +413,30 @@ public:
uint32_t GetMachOCPUSubType() const;
- //------------------------------------------------------------------
/// Architecture data byte width accessor
///
- /// @return the size in 8-bit (host) bytes of a minimum addressable unit
+ /// \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
+ /// \return the size in 8-bit (host) bytes of a minimum addressable unit
/// from the Architecture's code bus
- //------------------------------------------------------------------
uint32_t GetCodeByteSize() const;
- //------------------------------------------------------------------
/// Architecture triple accessor.
///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
+ /// \return A triple describing this ArchSpec.
llvm::Triple &GetTriple() { return m_triple; }
- //------------------------------------------------------------------
/// Architecture triple accessor.
///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
+ /// \return A triple describing this ArchSpec.
const llvm::Triple &GetTriple() const { return m_triple; }
void DumpTriple(Stream &s) const;
- //------------------------------------------------------------------
/// Architecture triple setter.
///
/// Configures this ArchSpec according to the given triple. If the triple
@@ -515,45 +446,36 @@ public:
/// to further resolve the CPU type and subtype, endian characteristics,
/// etc.
///
- /// @return A triple describing this ArchSpec.
- //------------------------------------------------------------------
+ /// \return A triple describing this ArchSpec.
bool SetTriple(const llvm::Triple &triple);
bool SetTriple(llvm::StringRef triple_str);
- //------------------------------------------------------------------
/// Returns the default endianness of the architecture.
///
- /// @return The endian enumeration for the default endianness of
+ /// \return The endian enumeration for the default endianness of
/// the architecture.
- //------------------------------------------------------------------
lldb::ByteOrder GetDefaultEndian() const;
- //------------------------------------------------------------------
/// Returns true if 'char' is a signed type by default in the architecture
/// false otherwise
///
- /// @return True if 'char' is a signed type by default on the
+ /// \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.
- //------------------------------------------------------------------
+ /// \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
- //------------------------------------------------------------------
+ /// \return true if the two ArchSpecs are compatible
bool IsCompatibleMatch(const ArchSpec &rhs) const;
bool IsFullySpecifiedTriple() const;
@@ -563,7 +485,6 @@ public:
bool &os_version_different,
bool &env_different) const;
- //------------------------------------------------------------------
/// Detect whether this architecture uses thumb code exclusively
///
/// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute
@@ -573,9 +494,8 @@ public:
/// (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
+ /// \return true if this is an arm ArchSpec which can only execute Thumb
/// instructions
- //------------------------------------------------------------------
bool IsAlwaysThumbInstructions() const;
uint32_t GetFlags() const { return m_flags; }
@@ -603,17 +523,15 @@ protected:
void CoreUpdated(bool update_triple);
};
-//------------------------------------------------------------------
-/// @fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs) Less than
+/// \fn bool operator< (const ArchSpec& lhs, const ArchSpec& rhs) Less than
/// operator.
///
/// Tests two ArchSpec objects to see if \a lhs is less than \a rhs.
///
-/// @param[in] lhs The Left Hand Side ArchSpec object to compare. @param[in]
+/// \param[in] lhs The Left Hand Side ArchSpec object to compare. \param[in]
/// rhs The Left Hand Side ArchSpec object to compare.
///
-/// @return true if \a lhs is less than \a rhs
-//------------------------------------------------------------------
+/// \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);
diff --git a/include/lldb/Utility/Args.h b/include/lldb/Utility/Args.h
index dec3dfaa4785b..6f258498d5bae 100644
--- a/include/lldb/Utility/Args.h
+++ b/include/lldb/Utility/Args.h
@@ -1,9 +1,8 @@
//===-- Args.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,8 +20,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Args Args.h "lldb/Utility/Args.h"
+/// \class Args Args.h "lldb/Utility/Args.h"
/// A command line argument class.
///
/// The Args class is designed to be fed a command line. The command line is
@@ -31,7 +29,6 @@ namespace lldb_private {
/// quotes) surrounding the argument. Spaces can be escaped using a \
/// character to avoid having to surround an argument that contains a space
/// with quotes.
-//----------------------------------------------------------------------
class Args {
public:
struct ArgEntry {
@@ -49,21 +46,17 @@ public:
char quote;
const char *c_str() const { return ptr.get(); }
- //------------------------------------------------------------------
/// Returns true if this argument was quoted in any way.
- //------------------------------------------------------------------
bool IsQuoted() const { return quote != '\0'; }
};
- //------------------------------------------------------------------
/// Construct with an option command string.
///
- /// @param[in] command
+ /// \param[in] command
/// A NULL terminated command that will be copied and split up
/// into arguments.
///
- /// @see Args::SetCommandString(llvm::StringRef)
- //------------------------------------------------------------------
+ /// \see Args::SetCommandString(llvm::StringRef)
Args(llvm::StringRef command = llvm::StringRef());
Args(const Args &rhs);
@@ -71,9 +64,7 @@ public:
Args &operator=(const Args &rhs);
- //------------------------------------------------------------------
/// Destructor.
- //------------------------------------------------------------------
~Args();
explicit Args(const Environment &env) : Args() {
@@ -82,59 +73,51 @@ public:
explicit operator Environment() const { return GetConstArgumentVector(); }
- //------------------------------------------------------------------
/// 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
+ /// \param[in] s
/// The stream to which to dump all arguments in the argument
/// vector.
- /// @param[in] label_name
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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; }
@@ -148,7 +131,6 @@ public:
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
@@ -158,13 +140,11 @@ public:
/// int main (int argc, const char **argv);
/// \endcode
///
- /// @return
+ /// \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
@@ -174,81 +154,69 @@ public:
/// int main (int argc, const char **argv);
/// \endcode
///
- /// @return
+ /// \return
/// An array of NULL terminate C string argument pointers that
/// also has a terminating NULL C string pointer
- //------------------------------------------------------------------
const char **GetConstArgumentVector() const;
- //------------------------------------------------------------------
/// Gets the argument as an ArrayRef. Note that the return value does *not*
/// have a nullptr const char * at the end, as the size of the list is
/// embedded in the ArrayRef object.
- //------------------------------------------------------------------
llvm::ArrayRef<const char *> GetArgumentArrayRef() const {
return llvm::makeArrayRef(m_argv).drop_back();
}
- //------------------------------------------------------------------
/// Appends a new argument to the end of the list argument list.
///
- /// @param[in] arg_cstr
+ /// \param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
- /// @param[in] quote_char
+ /// \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
+ /// \param[in] idx
/// The index of where to insert the argument.
///
- /// @param[in] arg_cstr
+ /// \param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
- /// @param[in] quote_char
+ /// \param[in] quote_char
/// If the argument was originally quoted, put in the quote char here.
///
- /// @return
+ /// \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
+ /// \param[in] idx
/// The index of the argument that will have its value replaced.
///
- /// @param[in] arg_cstr
+ /// \param[in] arg_cstr
/// The new argument as a NULL terminated C string.
///
- /// @param[in] quote_char
+ /// \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
+ /// \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.
///
@@ -256,12 +224,10 @@ public:
/// 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.
///
@@ -269,29 +235,24 @@ public:
/// by calling Args::GetArgumentAtIndex (size_t) const first and copying the
/// returned value before calling Args::Shift().
///
- /// @see Args::GetArgumentAtIndex (size_t) const
- //------------------------------------------------------------------
+ /// \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
+ /// \param[in] arg_cstr
/// The argument to push on the front of the argument stack.
///
- /// @param[in] quote_char
+ /// \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');
- //------------------------------------------------------------------
// 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,
@@ -306,7 +267,9 @@ public:
if (total_byte_size == 8)
return true;
- const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
+ const uint64_t max = (static_cast<uint64_t>(1)
+ << static_cast<uint64_t>(total_byte_size * 8)) -
+ 1;
return uval64 <= max;
}
@@ -318,7 +281,9 @@ public:
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 max = (static_cast<int64_t>(1)
+ << static_cast<uint64_t>(total_byte_size * 8 - 1)) -
+ 1;
const int64_t min = ~(max);
return min <= sval64 && sval64 <= max;
}
@@ -358,8 +323,7 @@ private:
std::vector<char *> m_argv;
};
-//----------------------------------------------------------------------
-/// @class OptionsWithRaw Args.h "lldb/Utility/Args.h"
+/// \class OptionsWithRaw Args.h "lldb/Utility/Args.h"
/// A pair of an option list with a 'raw' string as a suffix.
///
/// This class works similar to Args, but handles the case where we have a
@@ -377,71 +341,56 @@ private:
/// All strings not matching the above format as considered to be just a raw
/// string without any options.
///
-/// @see Args
-//----------------------------------------------------------------------
+/// \see Args
class OptionsWithRaw {
public:
- //------------------------------------------------------------------
/// Parse the given string as a list of optional arguments with a raw suffix.
///
/// See the class description for a description of the input format.
///
- /// @param[in] argument_string
+ /// \param[in] argument_string
/// The string that should be parsed.
- //------------------------------------------------------------------
explicit OptionsWithRaw(llvm::StringRef argument_string);
- //------------------------------------------------------------------
/// Returns true if there are any arguments before the raw suffix.
- //------------------------------------------------------------------
bool HasArgs() const { return m_has_args; }
- //------------------------------------------------------------------
/// Returns the list of arguments.
///
/// You can only call this method if HasArgs returns true.
- //------------------------------------------------------------------
Args &GetArgs() {
assert(m_has_args);
return m_args;
}
- //------------------------------------------------------------------
/// Returns the list of arguments.
///
/// You can only call this method if HasArgs returns true.
- //------------------------------------------------------------------
const Args &GetArgs() const {
assert(m_has_args);
return m_args;
}
- //------------------------------------------------------------------
/// Returns the part of the input string that was used for parsing the
/// argument list. This string also includes the double dash that is used
/// for separating the argument list from the suffix.
///
/// You can only call this method if HasArgs returns true.
- //------------------------------------------------------------------
llvm::StringRef GetArgStringWithDelimiter() const {
assert(m_has_args);
return m_arg_string_with_delimiter;
}
- //------------------------------------------------------------------
/// Returns the part of the input string that was used for parsing the
/// argument list.
///
/// You can only call this method if HasArgs returns true.
- //------------------------------------------------------------------
llvm::StringRef GetArgString() const {
assert(m_has_args);
return m_arg_string;
}
- //------------------------------------------------------------------
/// Returns the raw suffix part of the parsed string.
- //------------------------------------------------------------------
const std::string &GetRawPart() const { return m_suffix; }
private:
diff --git a/include/lldb/Utility/Baton.h b/include/lldb/Utility/Baton.h
index 7477846be48bf..4050f2af2bf04 100644
--- a/include/lldb/Utility/Baton.h
+++ b/include/lldb/Utility/Baton.h
@@ -1,9 +1,8 @@
//===-- Baton.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,8 +20,7 @@ class Stream;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Baton Baton.h "lldb/Core/Baton.h"
+/// \class Baton Baton.h "lldb/Core/Baton.h"
/// A class designed to wrap callback batons so they can cleanup
/// any acquired resources
///
@@ -32,7 +30,6 @@ namespace lldb_private {
///
/// The default behavior is to not free anything. Subclasses can free any
/// needed resources in their destructors.
-//----------------------------------------------------------------------
class Baton {
public:
Baton() {}
@@ -47,7 +44,7 @@ public:
class UntypedBaton : public Baton {
public:
UntypedBaton(void *Data) : m_data(Data) {}
- virtual ~UntypedBaton() {
+ ~UntypedBaton() override {
// The default destructor for an untyped baton does NOT attempt to clean up
// anything in m_data.
}
@@ -66,8 +63,7 @@ public:
const T *getItem() const { return Item.get(); }
void *data() override { return Item.get(); }
- virtual void GetDescription(Stream *s,
- lldb::DescriptionLevel level) const override {}
+ void GetDescription(Stream *s, lldb::DescriptionLevel level) const override {}
protected:
std::unique_ptr<T> Item;
diff --git a/include/lldb/Utility/Broadcaster.h b/include/lldb/Utility/Broadcaster.h
index 8763a63b0d5ea..fe4d1ca479b89 100644
--- a/include/lldb/Utility/Broadcaster.h
+++ b/include/lldb/Utility/Broadcaster.h
@@ -1,9 +1,8 @@
//===-- Broadcaster.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,51 +26,41 @@
namespace lldb_private {
class Broadcaster;
-}
-namespace lldb_private {
class EventData;
-}
-namespace lldb_private {
class Listener;
-}
-namespace lldb_private {
class Stream;
-}
+} // namespace lldb_private
namespace lldb_private {
-//----------------------------------------------------------------------
-// lldb::BroadcastEventSpec
-//
-// 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
-//----------------------------------------------------------------------
+/// lldb::BroadcastEventSpec
+///
+/// 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 {
public:
- BroadcastEventSpec(const ConstString &broadcaster_class, uint32_t event_bits)
+ BroadcastEventSpec(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; }
+ 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 {
+ /// 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(const 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;
- }
+
+ if ((m_event_bits & in_bits) != 0 && (m_event_bits & ~in_bits) == 0)
+ return true;
+
return false;
}
@@ -92,21 +81,21 @@ protected:
BroadcasterManager();
public:
- // Listeners hold onto weak pointers to their broadcaster managers. So they
- // must be made into shared pointers, which you do with
- // MakeBroadcasterManager.
-
+ /// 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);
+ const BroadcastEventSpec &event_spec);
bool UnregisterListenerForEvents(const lldb::ListenerSP &listener_sp,
- BroadcastEventSpec event_spec);
+ const BroadcastEventSpec &event_spec);
- lldb::ListenerSP GetListenerForEventSpec(BroadcastEventSpec event_spec) const;
+ lldb::ListenerSP
+ GetListenerForEventSpec(const BroadcastEventSpec &event_spec) const;
void SignUpListenersForBroadcaster(Broadcaster &broadcaster);
@@ -129,12 +118,12 @@ private:
class BroadcasterClassMatches {
public:
- BroadcasterClassMatches(const ConstString &broadcaster_class)
+ BroadcasterClassMatches(ConstString broadcaster_class)
: m_broadcaster_class(broadcaster_class) {}
~BroadcasterClassMatches() = default;
- bool operator()(const event_listener_key input) const {
+ bool operator()(const event_listener_key &input) const {
return (input.first.GetBroadcasterClass() == m_broadcaster_class);
}
@@ -144,12 +133,12 @@ private:
class BroadcastEventSpecMatches {
public:
- BroadcastEventSpecMatches(BroadcastEventSpec broadcaster_spec)
+ BroadcastEventSpecMatches(const BroadcastEventSpec &broadcaster_spec)
: m_broadcaster_spec(broadcaster_spec) {}
~BroadcastEventSpecMatches() = default;
- bool operator()(const event_listener_key input) const {
+ bool operator()(const event_listener_key &input) const {
return (input.first.IsContainedIn(m_broadcaster_spec));
}
@@ -159,13 +148,14 @@ private:
class ListenerMatchesAndSharedBits {
public:
- explicit ListenerMatchesAndSharedBits(BroadcastEventSpec broadcaster_spec,
- const lldb::ListenerSP listener_sp)
+ explicit ListenerMatchesAndSharedBits(
+ const 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 {
+ bool operator()(const event_listener_key &input) const {
return (input.first.GetBroadcasterClass() ==
m_broadcaster_spec.GetBroadcasterClass() &&
(input.first.GetEventBits() &
@@ -180,16 +170,16 @@ private:
class ListenerMatches {
public:
- explicit ListenerMatches(const lldb::ListenerSP in_listener_sp)
+ explicit ListenerMatches(const lldb::ListenerSP &in_listener_sp)
: m_listener_sp(in_listener_sp) {}
~ListenerMatches() = default;
- bool operator()(const event_listener_key input) const {
+ bool operator()(const event_listener_key &input) const {
if (input.second == m_listener_sp)
return true;
- else
- return false;
+
+ return false;
}
private:
@@ -203,18 +193,18 @@ private:
~ListenerMatchesPointer() = default;
- bool operator()(const event_listener_key input) const {
+ bool operator()(const event_listener_key &input) const {
if (input.second.get() == m_listener)
return true;
- else
- return false;
+
+ return false;
}
- bool operator()(const lldb::ListenerSP input) const {
+ bool operator()(const lldb::ListenerSP &input) const {
if (input.get() == m_listener)
return true;
- else
- return false;
+
+ return false;
}
private:
@@ -222,17 +212,16 @@ private:
};
};
-//----------------------------------------------------------------------
-/// @class Broadcaster Broadcaster.h "lldb/Utility/Broadcaster.h" An event
+/// \class Broadcaster Broadcaster.h "lldb/Utility/Broadcaster.h" An event
/// broadcasting class.
///
/// The Broadcaster class is designed to be subclassed by objects that wish to
/// vend events in a multi-threaded environment. Broadcaster objects can each
/// vend 32 events. Each event is represented by a bit in a 32 bit value and
/// these bits can be set:
-/// @see Broadcaster::SetEventBits(uint32_t)
+/// \see Broadcaster::SetEventBits(uint32_t)
/// or cleared:
-/// @see Broadcaster::ResetEventBits(uint32_t)
+/// \see Broadcaster::ResetEventBits(uint32_t)
/// When an event gets set the Broadcaster object will notify the Listener
/// object that is listening for the event (if there is one).
///
@@ -242,9 +231,7 @@ private:
/// class Foo : public Broadcaster
/// {
/// public:
-/// //----------------------------------------------------------
/// // Broadcaster event bits definitions.
-/// //----------------------------------------------------------
/// enum
/// {
/// eBroadcastBitOne = (1 << 0),
@@ -253,46 +240,39 @@ private:
/// ...
/// };
/// \endcode
-//----------------------------------------------------------------------
class Broadcaster {
friend class Listener;
friend class Event;
public:
- //------------------------------------------------------------------
/// Construct with a broadcaster with a name.
///
- /// @param[in] 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
+ /// \param[in] event_type
/// The element from the enum defining this broadcaster's events
/// that is being broadcast.
///
- /// @param[in] event_data
+ /// \param[in] event_data
/// User event data that will be owned by the lldb::Event that
/// is created internally.
///
- /// @param[in] unique
+ /// \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);
}
@@ -320,7 +300,6 @@ public:
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.
@@ -330,55 +309,48 @@ public:
/// 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
+ /// \param[in] listener
/// The Listener object that wants to monitor the events that
/// get broadcast by this object.
///
- /// @param[in] event_mask
+ /// \param[in] event_mask
/// A bit mask that indicates which events the listener is
/// asking to monitor.
///
- /// @return
+ /// \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
+ /// \return
/// The NULL terminated C string name of this Broadcaster.
- //------------------------------------------------------------------
- const ConstString &GetBroadcasterName() { return m_broadcaster_name; }
+ ConstString GetBroadcasterName() { return m_broadcaster_name; }
- //------------------------------------------------------------------
/// Get the event name(s) for one or more event bits.
///
- /// @param[in] event_mask
+ /// \param[in] event_mask
/// A bit mask that indicates which events to get names for.
///
- /// @return
+ /// \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
+ /// \param[in] event_mask
/// A bit mask that indicates which events the listener is
/// asking to monitor.
///
- /// @return
+ /// \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);
}
@@ -391,49 +363,45 @@ public:
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
+ /// \param[in] listener
/// A Listener object that previously called AddListener.
///
- /// @param[in] event_mask
+ /// \param[in] event_mask
/// The event bits \a listener wishes to relinquish.
///
- /// @return
+ /// \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)
- //------------------------------------------------------------------
+ /// \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
+ /// \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
+ /// \param[in] event_mask
/// The event bits \a listener wishes to hijack.
///
- /// @return
+ /// \return
/// \b True if the event mask could be hijacked, \b false otherwise.
///
- /// @see uint32_t Broadcaster::AddListener (Listener*, uint32_t)
- //------------------------------------------------------------------
+ /// \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);
@@ -443,35 +411,31 @@ public:
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.
+ /// 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.
-
+ /// 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;
@@ -538,9 +502,6 @@ protected:
const char *GetHijackingListenerName();
- //------------------------------------------------------------------
- //
- //------------------------------------------------------------------
typedef llvm::SmallVector<std::pair<lldb::ListenerWP, uint32_t>, 4>
collection;
typedef std::map<uint32_t, std::string> event_names_map;
@@ -548,24 +509,28 @@ protected:
llvm::SmallVector<std::pair<lldb::ListenerSP, uint32_t &>, 4>
GetListeners();
- Broadcaster &m_broadcaster; ///< The broadcaster 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.
+ /// The broadcaster that this implements.
+ Broadcaster &m_broadcaster;
+
+ /// Optionally define event names for readability and logging for each
+ /// event bit.
+ event_names_map m_event_names;
+
+ /// A list of Listener / event_mask pairs that are listening to this
+ /// broadcaster.
+ collection m_listeners;
+
+ /// A mutex that protects \a m_listeners.
+ std::recursive_mutex m_listeners_mutex;
+
+ /// A simple mechanism to intercept events from a broadcaster
+ std::vector<lldb::ListenerSP> m_hijacking_listeners;
+
+ /// At some point we may want to have a stack or Listener collections, but
+ /// for now this is just for private hijacking.
+ std::vector<uint32_t> m_hijacking_masks;
private:
- //------------------------------------------------------------------
- // For Broadcaster only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(BroadcasterImpl);
};
@@ -577,18 +542,13 @@ protected:
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.
+
+ /// The name of this broadcaster object.
+ const ConstString m_broadcaster_name;
DISALLOW_COPY_AND_ASSIGN(Broadcaster);
};
diff --git a/include/lldb/Utility/CleanUp.h b/include/lldb/Utility/CleanUp.h
index ef460ddd5e7fe..6cd5f332ef953 100644
--- a/include/lldb/Utility/CleanUp.h
+++ b/include/lldb/Utility/CleanUp.h
@@ -1,9 +1,8 @@
//===-- CleanUp.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/CompletionRequest.h b/include/lldb/Utility/CompletionRequest.h
index 38d8d5c587e2a..f5ccb01ca16f9 100644
--- a/include/lldb/Utility/CompletionRequest.h
+++ b/include/lldb/Utility/CompletionRequest.h
@@ -1,9 +1,8 @@
//===-- CompletionRequest.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@
namespace lldb_private {
class CompletionResult {
- //----------------------------------------------------------
/// A single completion and all associated data.
- //----------------------------------------------------------
struct Completion {
Completion(llvm::StringRef completion, llvm::StringRef description)
: m_completion(completion.str()), m_descripton(description.str()) {}
@@ -39,56 +36,48 @@ class CompletionResult {
public:
void AddResult(llvm::StringRef completion, llvm::StringRef description);
- //----------------------------------------------------------
/// Adds all collected completion matches to the given list.
/// The list will be cleared before the results are added. The number of
/// results here is guaranteed to be equal to GetNumberOfResults().
- //----------------------------------------------------------
void GetMatches(StringList &matches) const;
- //----------------------------------------------------------
/// Adds all collected completion descriptions to the given list.
/// The list will be cleared before the results are added. The number of
/// results here is guaranteed to be equal to GetNumberOfResults().
- //----------------------------------------------------------
void GetDescriptions(StringList &descriptions) const;
std::size_t GetNumberOfResults() const { return m_results.size(); }
};
-//----------------------------------------------------------------------
-/// @class CompletionRequest CompletionRequest.h
+/// \class CompletionRequest CompletionRequest.h
/// "lldb/Utility/ArgCompletionRequest.h"
///
/// Contains all information necessary to complete an incomplete command
/// for the user. Will be filled with the generated completions by the different
/// completions functions.
///
-//----------------------------------------------------------------------
class CompletionRequest {
public:
- //----------------------------------------------------------
/// Constructs a completion request.
///
- /// @param [in] command_line
+ /// \param [in] command_line
/// The command line the user has typed at this point.
///
- /// @param [in] raw_cursor_pos
+ /// \param [in] raw_cursor_pos
/// The position of the cursor in the command line string. Index 0 means
/// the cursor is at the start of the line. The completion starts from
/// this cursor position.
///
- /// @param [in] match_start_point
- /// @param [in] max_return_elements
+ /// \param [in] match_start_point
+ /// \param [in] max_return_elements
/// 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 match_start_point, and return match_return_elements
/// elements.
///
- /// @param [out] result
+ /// \param [out] result
/// The CompletionResult that will be filled with the results after this
/// request has been handled.
- //----------------------------------------------------------
CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos,
int match_start_point, int max_return_elements,
CompletionResult &result);
@@ -122,8 +111,8 @@ public:
/// the suggested completion is stored, so the given string can be free'd
/// afterwards.
///
- /// @param match The suggested completion.
- /// @param match An optional description of the completion string. The
+ /// \param match The suggested completion.
+ /// \param match An optional description of the completion string. The
/// description will be displayed to the user alongside the completion.
void AddCompletion(llvm::StringRef completion,
llvm::StringRef description = "") {
@@ -134,7 +123,7 @@ public:
///
/// \param completions The list of completions.
///
- /// @see AddCompletion
+ /// \see AddCompletion
void AddCompletions(const StringList &completions) {
for (std::size_t i = 0; i < completions.GetSize(); ++i)
AddCompletion(completions.GetStringAtIndex(i));
@@ -147,7 +136,7 @@ public:
/// \param completions The list of completions.
/// \param completions The list of descriptions.
///
- /// @see AddCompletion
+ /// \see AddCompletion
void AddCompletions(const StringList &completions,
const StringList &descriptions) {
lldbassert(completions.GetSize() == descriptions.GetSize());
diff --git a/include/lldb/Utility/Connection.h b/include/lldb/Utility/Connection.h
index 074b44b368658..77f3ef4a76ba7 100644
--- a/include/lldb/Utility/Connection.h
+++ b/include/lldb/Utility/Connection.h
@@ -1,9 +1,8 @@
//===-- Connection.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,15 +22,12 @@
namespace lldb_private {
class Status;
-}
-namespace lldb_private {
template <typename Ratio> class Timeout;
}
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Connection Connection.h "lldb/Utility/Connection.h"
+/// \class Connection Connection.h "lldb/Utility/Connection.h"
/// A communication connection class.
///
/// A class that implements that actual communication functions for
@@ -42,136 +38,118 @@ namespace lldb_private {
/// Instances can be instantiated and given to a Communication class to
/// perform communications where clients can listen for broadcasts, and
/// perform other higher level communications.
-//----------------------------------------------------------------------
class Connection {
public:
- //------------------------------------------------------------------
/// Default constructor
- //------------------------------------------------------------------
Connection() = default;
- //------------------------------------------------------------------
/// Virtual destructor since this class gets subclassed and handed to a
/// Communication object.
- //------------------------------------------------------------------
virtual ~Connection();
- //------------------------------------------------------------------
/// Connect using the connect string \a url.
///
- /// @param[in] url
+ /// \param[in] url
/// A string that contains all information needed by the
/// subclass to connect to another client.
///
- /// @param[out] error_ptr
+ /// \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
+ /// \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 Status& Communication::GetError ();
- //------------------------------------------------------------------
+ /// \see Status& Communication::GetError ();
virtual lldb::ConnectionStatus Connect(llvm::StringRef url,
Status *error_ptr) = 0;
- //------------------------------------------------------------------
/// Disconnect the communications connection if one is currently connected.
///
- /// @param[out] error_ptr
+ /// \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
+ /// \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 Status& Communication::GetError ();
- //------------------------------------------------------------------
+ /// \see Status& Communication::GetError ();
virtual lldb::ConnectionStatus Disconnect(Status *error_ptr) = 0;
- //------------------------------------------------------------------
/// Check if the connection is valid.
///
- /// @return
+ /// \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
+ /// \param[in] dst
/// A destination buffer that must be at least \a dst_len bytes
/// long.
///
- /// @param[in] dst_len
+ /// \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
+ /// \param[in] timeout
/// The number of microseconds to wait for the data.
///
- /// @param[out] status
+ /// \param[out] status
/// On return, indicates whether the call was successful or terminated
/// due to some error condition.
///
- /// @param[out] error_ptr
+ /// \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
+ /// \return
/// The number of bytes actually read.
///
- /// @see size_t Communication::Read (void *, size_t, uint32_t);
- //------------------------------------------------------------------
+ /// \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, Status *error_ptr) = 0;
- //------------------------------------------------------------------
/// The actual write function that attempts to write to the communications
/// protocol.
///
/// Subclasses must override this function.
///
- /// @param[in] dst
+ /// \param[in] dst
/// A desination buffer that must be at least \a dst_len bytes
/// long.
///
- /// @param[in] dst_len
+ /// \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
+ /// \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
+ /// \return
/// The number of bytes actually Written.
- //------------------------------------------------------------------
virtual size_t Write(const void *dst, size_t dst_len,
lldb::ConnectionStatus &status, Status *error_ptr) = 0;
- //------------------------------------------------------------------
/// Returns a URI that describes this connection object
///
/// Subclasses may override this function.
///
- /// @return
+ /// \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
@@ -181,27 +159,22 @@ public:
/// interrupt request (which will remain queued for the next Read()
/// operation).
///
- /// @return
+ /// \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
+ /// \return
/// The underlying IOObject used for reading.
- //------------------------------------------------------------------
virtual lldb::IOObjectSP GetReadObject() { return lldb::IOObjectSP(); }
private:
- //------------------------------------------------------------------
// For Connection only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(Connection);
};
diff --git a/include/lldb/Utility/ConstString.h b/include/lldb/Utility/ConstString.h
index 41f6717edee98..8576c18ddcd81 100644
--- a/include/lldb/Utility/ConstString.h
+++ b/include/lldb/Utility/ConstString.h
@@ -1,9 +1,8 @@
//===-- ConstString.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,8 +23,7 @@ class raw_ostream;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ConstString ConstString.h "lldb/Utility/ConstString.h"
+/// \class ConstString ConstString.h "lldb/Utility/ConstString.h"
/// A uniqued constant string class.
///
/// Provides an efficient way to store strings as uniqued strings. After the
@@ -37,41 +35,33 @@ namespace lldb_private {
/// 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 {
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
+ /// \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
+ /// \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
@@ -79,125 +69,148 @@ public:
/// 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
+ /// \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
+ /// \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
+ /// \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
+ /// \code
/// ConstString str(...);
/// if (str)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \return
/// /b True this object contains a valid non-empty C string, \b
/// false otherwise.
- //------------------------------------------------------------------
explicit operator bool() const { return !IsEmpty(); }
- //------------------------------------------------------------------
/// Assignment operator
///
/// Assigns the string in this object with the value from \a rhs.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// Another string object to copy into this object.
///
- /// @return
+ /// \return
/// A const reference to this object.
- //------------------------------------------------------------------
- const ConstString &operator=(const ConstString &rhs) {
+ ConstString operator=(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
+ /// \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 {
+ /// \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==(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;
}
- //------------------------------------------------------------------
+ /// Equal to operator against a non-ConstString value.
+ ///
+ /// Returns true if this string is equal to the string in \a rhs. This
+ /// overload is usually slower than comparing against a ConstString value.
+ /// However, if the rhs string not already a ConstString and it is impractical
+ /// to turn it into a non-temporary variable, then this overload is faster.
+ ///
+ /// \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 char *rhs) const {
+ // ConstString differentiates between empty strings and nullptr strings, but
+ // StringRef doesn't. Therefore we have to do this check manually now.
+ if (m_string == nullptr && rhs != nullptr)
+ return false;
+ if (m_string != nullptr && rhs == nullptr)
+ return false;
+
+ return GetStringRef() == rhs;
+ }
+
/// 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
+ /// \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
+ /// \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!=(ConstString rhs) const {
return m_string != rhs.m_string;
}
- bool operator<(const ConstString &rhs) const;
+ /// Not equal to operator against a non-ConstString value.
+ ///
+ /// Returns true if this string is not equal to the string in \a rhs. This
+ /// overload is usually slower than comparing against a ConstString value.
+ /// However, if the rhs string not already a ConstString and it is impractical
+ /// to turn it into a non-temporary variable, then this overload is faster.
+ ///
+ /// \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 char *rhs) const { return !(*this == rhs); }
+
+ bool operator<(ConstString rhs) const;
- //------------------------------------------------------------------
/// Get the string value as a C string.
///
/// Get the value of the contained string as a NULL terminated C string
@@ -205,26 +218,22 @@ public:
///
/// If \a value_if_empty is nullptr, then nullptr will be returned.
///
- /// @return
+ /// \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
+ /// \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
@@ -232,33 +241,27 @@ public:
/// function will always return nullptr if the string is not valid. So this
/// function is a direct accessor to the string pointer value.
///
- /// @return
+ /// \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
+ /// \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 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
@@ -266,24 +269,22 @@ public:
/// in a pointer comparison since all strings are in a uniqued in a global
/// string pool.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// The Left Hand Side const ConstString object reference.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// The Right Hand Side const ConstString object reference.
///
- /// @param[in] case_sensitive
+ /// \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,
+ /// \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(ConstString lhs, 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
@@ -294,67 +295,57 @@ public:
/// it is much more efficient. Also if you want string inequality, use the
/// != operator for the same reasons.
///
- /// @param[in] lhs
+ /// \param[in] lhs
/// The Left Hand Side const ConstString object reference.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// The Right Hand Side const ConstString object reference.
///
- /// @param[in] case_sensitive
+ /// \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,
+ /// \return
+ /// \li -1 if lhs < rhs
+ /// \li 0 if lhs == rhs
+ /// \li 1 if lhs > rhs
+ static int Compare(ConstString lhs, 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
+ /// \param[in] s
/// The stream that will be used to dump the object description.
///
- /// @param[in] value_if_empty
+ /// \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
+ /// \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.
- //------------------------------------------------------------------
+ /// \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'; }
- //------------------------------------------------------------------
/// Test for null string.
///
- /// @return
- /// @li \b true if there is no string associated with this instance.
- /// @li \b false if there is a string associated with this instance.
- //------------------------------------------------------------------
+ /// \return
+ /// \li \b true if there is no string associated with this instance.
+ /// \li \b false if there is a string associated with this instance.
bool IsNull() const { return m_string == nullptr; }
- //------------------------------------------------------------------
/// Set the C string value.
///
/// Set the string value in the object by uniquing the \a cstr string value
@@ -364,14 +355,12 @@ public:
/// current entry and returns the existing value. If it doesn't exist, it is
/// added to the string pool.
///
- /// @param[in] cstr
+ /// \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
@@ -381,17 +370,15 @@ public:
/// demangler over and over on the same strings and then trying to unique
/// them.
///
- /// @param[in] demangled
+ /// \param[in] demangled
/// The demangled string to correlate with the \a mangled name.
///
- /// @param[in] mangled
+ /// \param[in] mangled
/// The already uniqued mangled ConstString to correlate the
/// soon to be uniqued version of \a demangled.
- //------------------------------------------------------------------
void SetStringWithMangledCounterpart(llvm::StringRef demangled,
- const ConstString &mangled);
+ ConstString mangled);
- //------------------------------------------------------------------
/// Retrieve the mangled or demangled counterpart for a mangled or demangled
/// ConstString.
///
@@ -402,17 +389,15 @@ public:
/// demangler over and over on the same strings and then trying to unique
/// them.
///
- /// @param[in] counterpart
+ /// \param[in] counterpart
/// A reference to a ConstString object that might get filled in
/// with the demangled/mangled counterpart.
///
- /// @return
+ /// \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
@@ -424,59 +409,48 @@ public:
/// current entry and returns the existing value. If it doesn't exist, it is
/// added to the string pool.
///
- /// @param[in] cstr
+ /// \param[in] cstr
/// A NULL terminated C string to add to the string pool.
///
- /// @param[in] cstr_len
+ /// \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
+ /// \return
/// The number of bytes that this object occupies in memory.
///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
+ /// \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
+ /// \return
/// The number of bytes that the global string pool occupies
/// in memory.
- //------------------------------------------------------------------
static size_t StaticMemorySize();
protected:
- //------------------------------------------------------------------
// 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, ConstString str);
} // namespace lldb_private
diff --git a/include/lldb/Utility/DataBuffer.h b/include/lldb/Utility/DataBuffer.h
index 05cb609207373..523569301e84a 100644
--- a/include/lldb/Utility/DataBuffer.h
+++ b/include/lldb/Utility/DataBuffer.h
@@ -1,9 +1,8 @@
//===-- DataBuffer.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,8 +19,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h"
+/// \class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h"
/// A pure virtual protocol class for abstracted data buffers.
///
/// DataBuffer is an abstract class that gets packaged into a shared pointer
@@ -42,43 +40,34 @@ namespace lldb_private {
/// This class currently expects all data to be available without any extra
/// calls being made, but we can modify it to optionally get data on demand
/// with some extra function calls to load the data before it gets accessed.
-//----------------------------------------------------------------------
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() {}
- //------------------------------------------------------------------
/// Get a pointer to the data.
///
- /// @return
+ /// \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
+ /// \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 the number of bytes in the data buffer.
///
- /// @return
+ /// \return
/// The number of bytes this object currently contains.
- //------------------------------------------------------------------
virtual lldb::offset_t GetByteSize() const = 0;
llvm::ArrayRef<uint8_t> GetData() const {
diff --git a/include/lldb/Utility/DataBufferHeap.h b/include/lldb/Utility/DataBufferHeap.h
index 5a1e98803f0a7..2a64694d7f296 100644
--- a/include/lldb/Utility/DataBufferHeap.h
+++ b/include/lldb/Utility/DataBufferHeap.h
@@ -1,9 +1,8 @@
//===-- DataBufferHeap.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,8 +18,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class DataBufferHeap DataBufferHeap.h "lldb/Core/DataBufferHeap.h"
+/// \class DataBufferHeap DataBufferHeap.h "lldb/Core/DataBufferHeap.h"
/// A subclass of DataBuffer that stores a data buffer on the heap.
///
/// This class keeps its data in a heap based buffer that is owned by the
@@ -29,91 +27,72 @@ namespace lldb_private {
/// pages in. Large amounts of data that comes from files should probably use
/// DataBufferLLVM, which can intelligently determine when memory mapping is
/// optimal.
-//----------------------------------------------------------------------
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
+ /// \param[in] n
/// The number of bytes that heap based buffer should contain.
///
- /// @param[in] ch
+ /// \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
+ /// \param[in] src
/// A pointer to the data to copy.
///
- /// @param[in] src_len
+ /// \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()
- //------------------------------------------------------------------
+ /// \copydoc DataBuffer::GetBytes()
uint8_t *GetBytes() override;
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetBytes() const
- //------------------------------------------------------------------
+ /// \copydoc DataBuffer::GetBytes() const
const uint8_t *GetBytes() const override;
- //------------------------------------------------------------------
- /// @copydoc DataBuffer::GetByteSize() const
- //------------------------------------------------------------------
+ /// \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. Note that this
/// zero-initializes up to \p byte_size bytes.
///
- /// @param[in] byte_size
+ /// \param[in] byte_size
/// The new size in bytes that this data buffer should attempt
/// to resize itself to.
///
- /// @return
+ /// \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
+ /// \param[in] src
/// A pointer to the data to copy.
///
- /// @param[in] src_len
+ /// \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()); }
@@ -122,10 +101,8 @@ public:
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
};
diff --git a/include/lldb/Utility/DataBufferLLVM.h b/include/lldb/Utility/DataBufferLLVM.h
index 947ddb54da4a8..d4c1107430686 100644
--- a/include/lldb/Utility/DataBufferLLVM.h
+++ b/include/lldb/Utility/DataBufferLLVM.h
@@ -1,9 +1,8 @@
//===--- DataBufferLLVM.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,7 +25,7 @@ namespace lldb_private {
class FileSystem;
class DataBufferLLVM : public DataBuffer {
public:
- ~DataBufferLLVM();
+ ~DataBufferLLVM() override;
uint8_t *GetBytes() override;
const uint8_t *GetBytes() const override;
diff --git a/include/lldb/Utility/DataEncoder.h b/include/lldb/Utility/DataEncoder.h
index b1ee5a5999833..19b7cef9f0ca3 100644
--- a/include/lldb/Utility/DataEncoder.h
+++ b/include/lldb/Utility/DataEncoder.h
@@ -1,9 +1,8 @@
//===-- DataEncoder.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,47 +21,40 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class DataEncoder DataEncoder.h "lldb/Core/DataEncoder.h" An binary data
+/// \class DataEncoder DataEncoder.h "lldb/Core/DataEncoder.h" An binary data
/// encoding class.
///
/// 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.
///
-/// @see DataBuffer
-//----------------------------------------------------------------------
+/// \see DataBuffer
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
+ /// \param[in] data
/// A pointer to caller owned data.
///
- /// @param[in] data_length
+ /// \param[in] data_length
/// The length in bytes of \a data.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// A byte order of the data that we are extracting from.
///
- /// @param[in] addr_size
+ /// \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
@@ -70,109 +62,90 @@ public:
/// the data lives as long as anyone still has a valid shared pointer to the
/// data in \a data_sp.
///
- /// @param[in] data_sp
+ /// \param[in] data_sp
/// A shared pointer to data.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// A byte order of the data that we are extracting from.
///
- /// @param[in] addr_size
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] offset
/// The offset within the contained data at which to put the
/// data.
///
- /// @param[in] value
+ /// \param[in] value
/// The value to encode into the data.
///
- /// @return
+ /// \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);
@@ -181,7 +154,6 @@ public:
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
@@ -189,44 +161,40 @@ public:
/// 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
+ /// \param[in] offset
/// The offset within the contained data at which to put the
/// encoded integer.
///
- /// @param[in] byte_size
+ /// \param[in] byte_size
/// The size in byte of the integer to encode.
///
- /// @param[in] value
+ /// \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
+ /// \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
+ /// \param[in] offset
/// The offset in bytes into the contained data at which to
/// start encoding.
///
- /// @param[in] src
+ /// \param[in] src
/// The buffer that contains the bytes to encode.
///
- /// @param[in] src_len
+ /// \param[in] src_len
/// The number of bytes to encode.
///
- /// @return
+ /// \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.
///
@@ -236,53 +204,47 @@ public:
/// m_addr_size member variable and should be set correctly prior to
/// extracting any address values.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
@@ -290,21 +252,19 @@ public:
/// 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
+ /// \param[in] bytes
/// A pointer to caller owned data.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of \a bytes.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// A byte order of the data that we are extracting from.
///
- /// @return
+ /// \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
@@ -316,48 +276,41 @@ public:
/// 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
+ /// \param[in] data_sp
/// A shared pointer to data.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into \a data_sp at which the subset starts.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of the subset of \a data_sp.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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);
}
@@ -370,9 +323,7 @@ public:
}
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
diff --git a/include/lldb/Utility/DataExtractor.h b/include/lldb/Utility/DataExtractor.h
index f1e15e6d00e32..74174b34ce99b 100644
--- a/include/lldb/Utility/DataExtractor.h
+++ b/include/lldb/Utility/DataExtractor.h
@@ -1,9 +1,8 @@
//===-- DataExtractor.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,8 +21,6 @@
namespace lldb_private {
class Log;
-}
-namespace lldb_private {
class Stream;
}
namespace llvm {
@@ -33,8 +30,7 @@ template <typename T> class SmallVectorImpl;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h" An data
+/// \class DataExtractor DataExtractor.h "lldb/Core/DataExtractor.h" An data
/// extractor class.
///
/// DataExtractor is a class that can extract data (swapping if needed) from a
@@ -45,15 +41,12 @@ namespace lldb_private {
/// unique position in the shared data and extract data from different
/// offsets.
///
-/// @see DataBuffer
-//----------------------------------------------------------------------
+/// \see DataBuffer
class DataExtractor {
public:
- //------------------------------------------------------------------
- /// @typedef DataExtractor::Type
+ /// \typedef DataExtractor::Type
/// Type enumerations used in the dump routines.
- //------------------------------------------------------------------
- typedef enum {
+ enum Type {
TypeUInt8, ///< Format output as unsigned 8 bit integers
TypeChar, ///< Format output as characters
TypeUInt16, ///< Format output as unsigned 16 bit integers
@@ -62,41 +55,36 @@ public:
TypePointer, ///< Format output as pointers
TypeULEB128, ///< Format output as ULEB128 numbers
TypeSLEB128 ///< Format output as SLEB128 numbers
- } Type;
+ };
- //------------------------------------------------------------------
/// 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
+ /// \param[in] data
/// A pointer to caller owned data.
///
- /// @param[in] data_length
+ /// \param[in] data_length
/// The length in bytes of \a data.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// A byte order of the data that we are extracting from.
///
- /// @param[in] addr_size
+ /// \param[in] addr_size
/// A new address byte size value.
///
- /// @param[in] target_byte_size
+ /// \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
@@ -104,22 +92,20 @@ public:
/// the data lives as long as anyone still has a valid shared pointer to the
/// data in \a data_sp.
///
- /// @param[in] data_sp
+ /// \param[in] data_sp
/// A shared pointer to data.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// A byte order of the data that we are extracting from.
///
- /// @param[in] addr_size
+ /// \param[in] addr_size
/// A new address byte size value.
///
- /// @param[in] target_byte_size
+ /// \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
@@ -131,128 +117,116 @@ public:
/// 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
+ /// \param[in] data
/// Another DataExtractor object that contains data.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into \a data at which the subset starts.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of the subset of data.
///
- /// @param[in] target_byte_size
+ /// \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
+ /// \param[in] rhs
/// Another DataExtractor object to copy.
///
- /// @return
+ /// \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.
- //------------------------------------------------------------------
virtual ~DataExtractor();
uint32_t getTargetByteSize() const { return m_target_byte_size; }
- //------------------------------------------------------------------
/// 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
+ /// \param[in] s
/// The stream to dump the output to. If nullptr the output will
/// be dumped to Log().
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into the data at which to start dumping.
///
- /// @param[in] length
+ /// \param[in] length
/// The number of bytes to dump.
///
- /// @param[in] base_addr
+ /// \param[in] base_addr
/// The base address that gets added to the offset displayed on
/// each line.
///
- /// @param[in] num_per_line
+ /// \param[in] num_per_line
/// The number of \a type objects to display on each line.
///
- /// @param[in] type
+ /// \param[in] type
/// The type of objects to use when dumping data from this
/// object. See DataExtractor::Type.
///
- /// @param[in] type_format
+ /// \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
+ /// \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;
- //------------------------------------------------------------------
/// 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
+ /// \param[in] offset
/// The offset in bytes into the contained data at which to
/// start extracting.
///
- /// @param[in] length
+ /// \param[in] length
/// The number of bytes to extract.
///
- /// @param[in] dst_byte_order
+ /// \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
+ /// \param[out] dst
/// The buffer that will receive the extracted value if there
/// are enough bytes available in the current data.
///
- /// @return
+ /// \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
@@ -260,39 +234,33 @@ public:
/// m_addr_size member variable and should be set correctly prior to
/// extracting any address values.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
@@ -300,22 +268,20 @@ public:
/// 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
+ /// \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
+ /// \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
@@ -324,14 +290,14 @@ public:
/// will be updated with the offset of the byte that follows the fixed
/// length field.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
@@ -339,7 +305,6 @@ public:
/// 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
@@ -347,21 +312,20 @@ public:
/// pointed to by \a offset_ptr will not be updated and nullptr will be
/// returned.
///
- /// @param[in,out] 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] length
+ /// \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
+ /// \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)
@@ -369,26 +333,23 @@ public:
return ptr;
}
- //------------------------------------------------------------------
/// Copy \a length bytes from \a *offset, without swapping bytes.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into this data from which to start copying
///
- /// @param[in] length
+ /// \param[in] length
/// The length of the data to copy from this object
///
- /// @param[out] dst
+ /// \param[out] dst
/// The buffer to place the output data.
///
- /// @return
+ /// \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.
@@ -400,88 +361,78 @@ public:
/// 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
+ /// \param[in] src_offset
/// The offset into this data from which to start copying an
/// endian entity
///
- /// @param[in] src_len
+ /// \param[in] src_len
/// The length of the endian data to copy from this object
/// into the \a dst object
///
- /// @param[out] dst
+ /// \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
+ /// \param[in] dst_len
/// The length number of bytes that the endian value will
/// occupy is \a dst.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// The byte order that the endian value should be in the \a dst
/// buffer.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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 an integer of size \a byte_size from \a *offset_ptr.
///
/// Extract a single integer value and update the offset pointed to by \a
@@ -489,22 +440,20 @@ public:
/// byte_size argument. \a byte_size must have a value >= 1 and <= 4 since
/// the return value is only 32 bits wide.
///
- /// @param[in,out] 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] byte_size
+ /// \param[in] byte_size
/// The size in byte of the integer to extract.
///
- /// @return
+ /// \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
@@ -513,26 +462,24 @@ public:
/// equal to one and less than or equal to eight since the return value is
/// 64 bits wide.
///
- /// @param[in,out] 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] byte_size
+ /// \param[in] byte_size
/// The size in byte of the integer to extract.
///
- /// @return
+ /// \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
@@ -541,23 +488,21 @@ public:
/// have a value greater than or equal to one and less than or equal to
/// eight since the return value is 64 bits wide.
///
- /// @param[in,out] 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] byte_size
+ /// \param[in] byte_size
/// The size in byte of the integer to extract.
///
- /// @return
+ /// \return
/// The sign extended signed integer value that was extracted,
/// or zero on failure.
- //------------------------------------------------------------------
int64_t GetMaxS64(lldb::offset_t *offset_ptr, size_t byte_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.
@@ -568,36 +513,34 @@ public:
/// equal to one and less than or equal to 8 since the return value is 64
/// bits wide.
///
- /// @param[in,out] 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] byte_size
+ /// \param[in] byte_size
/// The size in byte of the integer to extract.
///
- /// @param[in] bitfield_bit_size
+ /// \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
+ /// \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
+ /// \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.
@@ -608,36 +551,34 @@ public:
/// have a value greater than or equal to one and less than or equal to
/// eight since the return value is 64 bits wide.
///
- /// @param[in,out] 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] byte_size
+ /// \param[in] byte_size
/// The size in bytes of the integer to extract.
///
- /// @param[in] bitfield_bit_size
+ /// \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
+ /// \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
+ /// \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
@@ -645,43 +586,38 @@ public:
/// m_addr_size member variable and should be set correctly prior to
/// extracting any pointer values.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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 {
@@ -695,169 +631,154 @@ public:
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
+ /// \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
+ /// \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
+ /// \param[in] count
/// The number of uint8_t values to extract.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] count
/// The number of uint16_t values to extract.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] count
/// The number of uint32_t values to extract.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] count
/// The number of uint64_t values to extract.
///
- /// @return
+ /// \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
@@ -865,19 +786,17 @@ public:
/// offset_ptr will be updated with the offset of the byte following the
/// last extracted byte.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
@@ -885,62 +804,55 @@ public:
/// offset_ptr will be updated with the offset of the byte following the
/// last extracted byte.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
+ /// \param[in] offset
/// An offset into the data.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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);
@@ -948,7 +860,6 @@ public:
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
@@ -956,22 +867,20 @@ public:
/// 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
+ /// \param[in] bytes
/// A pointer to caller owned data.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of \a bytes.
///
- /// @param[in] byte_order
+ /// \param[in] byte_order
/// A byte order of the data that we are extracting from.
///
- /// @return
+ /// \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
@@ -983,22 +892,20 @@ public:
/// 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
+ /// \param[in] data
/// Another DataExtractor object that contains data.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into \a data at which the subset starts.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of the subset of \a data.
///
- /// @return
+ /// \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
@@ -1010,34 +917,30 @@ public:
/// 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
+ /// \param[in] data_sp
/// A shared pointer to data.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset into \a data_sp at which the subset starts.
///
- /// @param[in] length
+ /// \param[in] length
/// The length in bytes of the subset of \a data_sp.
///
- /// @return
+ /// \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
+ /// \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
@@ -1045,36 +948,31 @@ public:
/// to by \a offset_ptr will be updated with the offset of the byte
/// following the last extracted byte.
///
- /// @param[in,out] 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.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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);
@@ -1100,9 +998,7 @@ public:
}
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.
diff --git a/include/lldb/Utility/Endian.h b/include/lldb/Utility/Endian.h
index 2a102b63aa106..cead5f8603d22 100644
--- a/include/lldb/Utility/Endian.h
+++ b/include/lldb/Utility/Endian.h
@@ -1,9 +1,8 @@
//===-- Endian.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,7 +23,7 @@ static union EndianTest {
} const endianTest = {0x01020304};
inline lldb::ByteOrder InlHostByteOrder() {
- return (lldb::ByteOrder)endianTest.bytes[0];
+ return static_cast<lldb::ByteOrder>(endianTest.bytes[0]);
}
// ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0];
diff --git a/include/lldb/Utility/Environment.h b/include/lldb/Utility/Environment.h
index ed0a36d7b3aa5..398b3bae31066 100644
--- a/include/lldb/Utility/Environment.h
+++ b/include/lldb/Utility/Environment.h
@@ -1,9 +1,8 @@
//===-- Environment.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/Event.h b/include/lldb/Utility/Event.h
index d65043f564fb4..dd5d08024cef1 100644
--- a/include/lldb/Utility/Event.h
+++ b/include/lldb/Utility/Event.h
@@ -1,9 +1,8 @@
//===-- Event.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,16 +27,12 @@
namespace lldb_private {
class Event;
-}
-namespace lldb_private {
class Stream;
}
namespace lldb_private {
-//----------------------------------------------------------------------
// lldb::EventData
-//----------------------------------------------------------------------
class EventData {
friend class Event;
@@ -46,7 +41,7 @@ public:
virtual ~EventData();
- virtual const ConstString &GetFlavor() const = 0;
+ virtual ConstString GetFlavor() const = 0;
virtual void Dump(Stream *s) const;
@@ -56,14 +51,10 @@ private:
DISALLOW_COPY_AND_ASSIGN(EventData);
};
-//----------------------------------------------------------------------
// lldb::EventDataBytes
-//----------------------------------------------------------------------
class EventDataBytes : public EventData {
public:
- //------------------------------------------------------------------
// Constructors
- //------------------------------------------------------------------
EventDataBytes();
EventDataBytes(const char *cstr);
@@ -74,10 +65,8 @@ public:
~EventDataBytes() override;
- //------------------------------------------------------------------
// Member functions
- //------------------------------------------------------------------
- const ConstString &GetFlavor() const override;
+ ConstString GetFlavor() const override;
void Dump(Stream *s) const override;
@@ -91,16 +80,14 @@ public:
void SetBytesFromCString(const char *cstr);
- //------------------------------------------------------------------
// Static functions
- //------------------------------------------------------------------
static const EventDataBytes *GetEventDataFromEvent(const Event *event_ptr);
static const void *GetBytesFromEvent(const Event *event_ptr);
static size_t GetByteSizeFromEvent(const Event *event_ptr);
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
private:
std::string m_bytes;
@@ -114,12 +101,12 @@ public:
~EventDataReceipt() override {}
- static const ConstString &GetFlavorString() {
+ static ConstString GetFlavorString() {
static ConstString g_flavor("Process::ProcessEventData");
return g_flavor;
}
- const ConstString &GetFlavor() const override { return GetFlavorString(); }
+ ConstString GetFlavor() const override { return GetFlavorString(); }
bool WaitForEventReceived(const Timeout<std::micro> &timeout = llvm::None) {
return m_predicate.WaitForValueEqualTo(true, timeout);
@@ -133,16 +120,12 @@ private:
}
};
-//----------------------------------------------------------------------
/// This class handles one or more StructuredData::Dictionary entries
/// that are raised for structured data events.
-//----------------------------------------------------------------------
class EventDataStructuredData : public EventData {
public:
- //------------------------------------------------------------------
// Constructors
- //------------------------------------------------------------------
EventDataStructuredData();
EventDataStructuredData(const lldb::ProcessSP &process_sp,
@@ -151,10 +134,8 @@ public:
~EventDataStructuredData() override;
- //------------------------------------------------------------------
// Member functions
- //------------------------------------------------------------------
- const ConstString &GetFlavor() const override;
+ ConstString GetFlavor() const override;
void Dump(Stream *s) const override;
@@ -170,9 +151,7 @@ public:
void SetStructuredDataPlugin(const lldb::StructuredDataPluginSP &plugin_sp);
- //------------------------------------------------------------------
// Static functions
- //------------------------------------------------------------------
static const EventDataStructuredData *
GetEventDataFromEvent(const Event *event_ptr);
@@ -183,7 +162,7 @@ public:
static lldb::StructuredDataPluginSP
GetPluginFromEvent(const Event *event_ptr);
- static const ConstString &GetFlavorString();
+ static ConstString GetFlavorString();
private:
lldb::ProcessSP m_process_sp;
@@ -193,9 +172,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(EventDataStructuredData);
};
-//----------------------------------------------------------------------
// lldb::Event
-//----------------------------------------------------------------------
class Event {
friend class Listener;
friend class EventData;
@@ -266,7 +243,7 @@ private:
lldb::EventDataSP m_data_sp; // User specific data for this event
DISALLOW_COPY_AND_ASSIGN(Event);
- Event(); // Disallow default constructor
+ Event() = delete;
};
} // namespace lldb_private
diff --git a/include/lldb/Utility/FileCollector.h b/include/lldb/Utility/FileCollector.h
new file mode 100644
index 0000000000000..a89206747fe19
--- /dev/null
+++ b/include/lldb/Utility/FileCollector.h
@@ -0,0 +1,77 @@
+//===-- FileCollector.h -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_FILE_COLLECTOR_H
+#define LLDB_UTILITY_FILE_COLLECTOR_H
+
+#include "lldb/Utility/FileSpec.h"
+
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+#include <mutex>
+
+namespace lldb_private {
+
+/// Collects files into a directory and generates a mapping that can be used by
+/// the VFS.
+class FileCollector {
+public:
+ FileCollector(const FileSpec &root, const FileSpec &overlay);
+
+ void AddFile(const llvm::Twine &file);
+ void AddFile(const FileSpec &file) { return AddFile(file.GetPath()); }
+
+ /// Write the yaml mapping (for the VFS) to the given file.
+ std::error_code WriteMapping(const FileSpec &mapping_file);
+
+ /// Copy the files into the root directory.
+ ///
+ /// When stop_on_error is true (the default) we abort as soon as one file
+ /// cannot be copied. This is relatively common, for example when a file was
+ /// removed after it was added to the mapping.
+ std::error_code CopyFiles(bool stop_on_error = true);
+
+protected:
+ void AddFileImpl(llvm::StringRef src_path);
+
+ bool MarkAsSeen(llvm::StringRef path) { return m_seen.insert(path).second; }
+
+ bool GetRealPath(llvm::StringRef src_path,
+ llvm::SmallVectorImpl<char> &result);
+
+ void AddFileToMapping(llvm::StringRef virtual_path,
+ llvm::StringRef real_path) {
+ m_vfs_writer.addFileMapping(virtual_path, real_path);
+ }
+
+ /// Synchronizes adding files.
+ std::mutex m_mutex;
+
+ /// The root directory where files are copied.
+ FileSpec m_root;
+
+ /// The root directory where the VFS overlay lives.
+ FileSpec m_overlay_root;
+
+ /// Tracks already seen files so they can be skipped.
+ llvm::StringSet<> m_seen;
+
+ /// The yaml mapping writer.
+ llvm::vfs::YAMLVFSWriter m_vfs_writer;
+
+ /// Caches real_path calls when resolving symlinks.
+ llvm::StringMap<std::string> m_symlink_map;
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_UTILITY_FILE_COLLECTOR_H
diff --git a/include/lldb/Utility/FileSpec.h b/include/lldb/Utility/FileSpec.h
index 0699ab7b5c900..f0bc5c89fec77 100644
--- a/include/lldb/Utility/FileSpec.h
+++ b/include/lldb/Utility/FileSpec.h
@@ -1,9 +1,8 @@
//===-- FileSpec.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,8 +37,7 @@ template <typename T> class SmallVectorImpl;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class FileSpec FileSpec.h "lldb/Host/FileSpec.h"
+/// \class FileSpec FileSpec.h "lldb/Host/FileSpec.h"
/// A file utility class.
///
/// A file specification class that divides paths up into a directory
@@ -54,165 +52,133 @@ namespace lldb_private {
/// are already split up, it makes 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 {
public:
using Style = llvm::sys::path::Style;
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).
///
- /// @param[in] path
+ /// \param[in] path
/// The full or partial path to a file.
///
- /// @param[in] style
+ /// \param[in] style
/// The style of the path
///
- /// @see FileSpec::SetFile (const char *path)
- //------------------------------------------------------------------
+ /// \see FileSpec::SetFile (const char *path)
explicit FileSpec(llvm::StringRef path, Style style = Style::native);
explicit FileSpec(llvm::StringRef path, const llvm::Triple &Triple);
- //------------------------------------------------------------------
- /// 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
+ /// \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
+ /// \param[in] rhs
/// A const FileSpec object reference to assign to this object.
///
- /// @return
+ /// \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
+ /// \param[in] rhs
/// A const FileSpec object reference to compare this object
/// to.
///
- /// @return
+ /// \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
+ /// \param[in] rhs
/// A const FileSpec object reference to compare this object
/// to.
///
- /// @return
+ /// \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
+ /// \param[in] rhs
/// A const FileSpec object reference to compare this object
/// to.
///
- /// @return
+ /// \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
+ /// \code
/// FileSpec file_spec(...);
/// if (file_spec)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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
+ /// \code
/// FileSpec file_spec(...);
/// if (!file_spec)
/// { ...
- /// @endcode
+ /// \endcode
///
- /// @return
+ /// \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.
@@ -221,163 +187,148 @@ public:
/// to only contain a filename and it can match FileSpec objects that have
/// matching filenames with different paths.
///
- /// @param[in] lhs
+ /// \param[in] lhs
/// A const reference to the Left Hand Side object to compare.
///
- /// @param[in] rhs
+ /// \param[in] rhs
/// A const reference to the Right Hand Side object to compare.
///
- /// @param[in] full
+ /// \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
- //------------------------------------------------------------------
+ /// \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);
- //------------------------------------------------------------------
+ /// Attempt to guess path style for a given path string. It returns a style,
+ /// if it was able to make a reasonable guess, or None if it wasn't. The guess
+ /// will be correct if the input path was a valid absolute path on the system
+ /// which produced it. On other paths the result of this function is
+ /// unreliable (e.g. "c:\foo.txt" is a valid relative posix path).
+ static llvm::Optional<Style> GuessPathStyle(llvm::StringRef absolute_path);
+
/// Case sensitivity of path.
///
- /// @return
+ /// \return
/// \b true if the file path is case sensitive (POSIX), false
/// if case insensitive (Windows).
- //------------------------------------------------------------------
bool IsCaseSensitive() const { return m_style != Style::windows; }
- //------------------------------------------------------------------
/// 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
+ /// \param[in] s
/// The stream to which to dump the object description.
- //------------------------------------------------------------------
void Dump(Stream *s) const;
Style GetPathStyle() const;
- //------------------------------------------------------------------
/// Directory string get accessor.
///
- /// @return
+ /// \return
/// A reference to the directory string object.
- //------------------------------------------------------------------
ConstString &GetDirectory();
- //------------------------------------------------------------------
/// Directory string const get accessor.
///
- /// @return
+ /// \return
/// A const reference to the directory string object.
- //------------------------------------------------------------------
- const ConstString &GetDirectory() const;
+ ConstString GetDirectory() const;
- //------------------------------------------------------------------
/// Filename string get accessor.
///
- /// @return
+ /// \return
/// A reference to the filename string object.
- //------------------------------------------------------------------
ConstString &GetFilename();
- //------------------------------------------------------------------
/// Filename string const get accessor.
///
- /// @return
+ /// \return
/// A const reference to the filename string object.
- //------------------------------------------------------------------
- const ConstString &GetFilename() 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
+ /// \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
+ /// \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
+ /// \return
/// \b true if the filespec represents an absolute path,
/// \b false otherwise.
- //------------------------------------------------------------------
bool IsAbsolute() const;
+ /// Make the FileSpec absolute by treating it relative to \a dir. Absolute
+ /// FileSpecs are never changed by this function.
+ void MakeAbsolute(const FileSpec &dir);
+
/// Temporary helper for FileSystem change.
void SetPath(llvm::StringRef p) { SetFile(p); }
- //------------------------------------------------------------------
/// 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
+ /// \param[out] path
/// The buffer in which to place the extracted full path.
///
- /// @param[in] max_path_length
+ /// \param[in] max_path_length
/// The maximum length of \a path.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
@@ -385,59 +336,51 @@ public:
/// filename has no extension, ConstString(nullptr) is returned. The dot
/// ('.') character is not returned as part of the extension
///
- /// @return
+ /// \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
+ /// \return
/// Returns the filename without extension
/// as a ConstString object.
- //------------------------------------------------------------------
ConstString GetFileNameStrippingExtension() 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
+ /// \return
/// The number of bytes that this object occupies in memory.
///
- /// @see ConstString::StaticMemorySize ()
- //------------------------------------------------------------------
+ /// \see ConstString::StaticMemorySize ()
size_t MemorySize() 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
+ /// \param[in] path
/// A full, partial, or relative path to a file.
///
- /// @param[in] resolve_path
+ /// \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, Style style);
void SetFile(llvm::StringRef path, const llvm::Triple &Triple);
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
@@ -446,10 +389,9 @@ public:
/// we don't try and resolve it later, or try and resolve a path that has
/// already been resolved.
///
- /// @param[in] is_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; }
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const;
@@ -461,35 +403,27 @@ public:
void AppendPathComponent(llvm::StringRef component);
void AppendPathComponent(const FileSpec &new_path);
- //------------------------------------------------------------------
/// Removes the last path component by replacing the current path with its
/// parent. When the current path has no parent, this is a no-op.
///
- /// @return
+ /// \return
/// A boolean value indicating whether the path was updated.
- //------------------------------------------------------------------
bool RemoveLastPathComponent();
ConstString GetLastPathComponent() const;
protected:
- //------------------------------------------------------------------
// Convenience method for setting the file without changing the style.
- //------------------------------------------------------------------
void SetFile(llvm::StringRef path);
- //------------------------------------------------------------------
// 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.
Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix)
};
-//----------------------------------------------------------------------
/// Dump a FileSpec object to a stream
-//----------------------------------------------------------------------
Stream &operator<<(Stream &s, const FileSpec &f);
} // namespace lldb_private
diff --git a/include/lldb/Utility/Flags.h b/include/lldb/Utility/Flags.h
index 5ef6122d1146e..48b14e7d2a2ca 100644
--- a/include/lldb/Utility/Flags.h
+++ b/include/lldb/Utility/Flags.h
@@ -1,9 +1,8 @@
//===-- Flags.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,149 +14,117 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Flags Flags.h "lldb/Utility/Flags.h"
+/// \class Flags Flags.h "lldb/Utility/Flags.h"
/// A class to manage flags.
///
/// The Flags class managed flag bits and allows testing and modification of
/// individual or multiple flag bits.
-//----------------------------------------------------------------------
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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] mask
/// A bitfield containing one or more flags.
///
- /// @return
+ /// \return
/// The new flags after clearing all bits from \a mask.
- //----------------------------------------------------------------------
- ValueType Clear(ValueType mask = ~(ValueType)0) {
+ ValueType Clear(ValueType mask = ~static_cast<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
+ /// \param[in] mask
/// A bitfield containing one or more flags.
///
- /// @return
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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
+ /// \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) {
@@ -167,12 +134,10 @@ public:
return count;
}
- //----------------------------------------------------------------------
/// Get the number of one bits in \a m_flags.
///
- /// @return
+ /// \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) {
diff --git a/include/lldb/Utility/IOObject.h b/include/lldb/Utility/IOObject.h
index 61f288183850b..1640200a01d98 100644
--- a/include/lldb/Utility/IOObject.h
+++ b/include/lldb/Utility/IOObject.h
@@ -1,9 +1,8 @@
//===-- IOObject.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,10 +19,10 @@ namespace lldb_private {
class IOObject {
public:
- typedef enum {
+ enum FDType {
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
diff --git a/include/lldb/Utility/Iterable.h b/include/lldb/Utility/Iterable.h
index 1b7ec89d6cf57..d9c61aa958cca 100644
--- a/include/lldb/Utility/Iterable.h
+++ b/include/lldb/Utility/Iterable.h
@@ -1,9 +1,8 @@
//===-- Iterable.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/JSON.h b/include/lldb/Utility/JSON.h
index 6fe1945ea227a..172f77afb01fe 100644
--- a/include/lldb/Utility/JSON.h
+++ b/include/lldb/Utility/JSON.h
@@ -1,9 +1,8 @@
//===---------------------JSON.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,8 +21,6 @@
namespace lldb_private {
class Stream;
-}
-namespace lldb_private {
class JSONValue {
public:
diff --git a/include/lldb/Utility/LLDBAssert.h b/include/lldb/Utility/LLDBAssert.h
index e7448cdac5454..7008dd82496d6 100644
--- a/include/lldb/Utility/LLDBAssert.h
+++ b/include/lldb/Utility/LLDBAssert.h
@@ -1,9 +1,8 @@
//===----------------- LLDBAssert.h ------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/Listener.h b/include/lldb/Utility/Listener.h
index 11f89d7aeec28..17fc47880e8f8 100644
--- a/include/lldb/Utility/Listener.h
+++ b/include/lldb/Utility/Listener.h
@@ -1,9 +1,8 @@
//===-- Listener.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,8 +28,6 @@
namespace lldb_private {
class ConstString;
-}
-namespace lldb_private {
class Event;
}
@@ -43,9 +40,7 @@ public:
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,
@@ -63,10 +58,11 @@ public:
const char *GetName() { return m_name.c_str(); }
- uint32_t StartListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp,
- const BroadcastEventSpec &event_spec);
+ uint32_t
+ StartListeningForEventSpec(const lldb::BroadcasterManagerSP &manager_sp,
+ const BroadcastEventSpec &event_spec);
- bool StopListeningForEventSpec(lldb::BroadcasterManagerSP manager_sp,
+ bool StopListeningForEventSpec(const lldb::BroadcasterManagerSP &manager_sp,
const BroadcastEventSpec &event_spec);
uint32_t StartListeningForEvents(Broadcaster *broadcaster,
@@ -100,9 +96,7 @@ public:
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)
@@ -150,9 +144,7 @@ private:
// uint32_t event_mask,
// bool exact);
- //------------------------------------------------------------------
// For Listener only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(Listener);
};
diff --git a/include/lldb/Utility/Log.h b/include/lldb/Utility/Log.h
index 30b97f0137ef4..949de69c8e5a9 100644
--- a/include/lldb/Utility/Log.h
+++ b/include/lldb/Utility/Log.h
@@ -1,9 +1,8 @@
//===-- Log.h ---------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,7 @@
namespace llvm {
class raw_ostream;
}
-//----------------------------------------------------------------------
// Logging Options
-//----------------------------------------------------------------------
#define LLDB_LOG_OPTION_THREADSAFE (1u << 0)
#define LLDB_LOG_OPTION_VERBOSE (1u << 1)
#define LLDB_LOG_OPTION_PREPEND_SEQUENCE (1u << 3)
@@ -45,9 +42,7 @@ class raw_ostream;
#define LLDB_LOG_OPTION_APPEND (1U << 8)
#define LLDB_LOG_OPTION_PREPEND_FILE_FUNCTION (1U << 9)
-//----------------------------------------------------------------------
// Logging Functions
-//----------------------------------------------------------------------
namespace lldb_private {
class Log final {
@@ -74,7 +69,7 @@ public:
: log_ptr(nullptr), categories(categories),
default_flags(default_flags) {}
- // This function is safe to call at any time If the channel is disabled
+ // This function is safe to call at any time. If the channel is disabled
// after (or concurrently with) this function returning a non-null Log
// pointer, it is still safe to attempt to write to the Log object -- the
// output will be discarded.
@@ -85,7 +80,7 @@ public:
return nullptr;
}
- // This function is safe to call at any time If the channel is disabled
+ // This function is safe to call at any time. If the channel is disabled
// after (or concurrently with) this function returning a non-null Log
// pointer, it is still safe to attempt to write to the Log object -- the
// output will be discarded.
@@ -100,9 +95,7 @@ public:
static void Initialize();
- //------------------------------------------------------------------
// Static accessors for logging channels
- //------------------------------------------------------------------
static void Register(llvm::StringRef name, Channel &channel);
static void Unregister(llvm::StringRef name);
@@ -116,19 +109,18 @@ public:
llvm::ArrayRef<const char *> categories,
llvm::raw_ostream &error_stream);
- static bool ListChannelCategories(llvm::StringRef channel, llvm::raw_ostream &stream);
+ static bool ListChannelCategories(llvm::StringRef channel,
+ llvm::raw_ostream &stream);
static void DisableAllLogChannels();
static void ListAllLogChannels(llvm::raw_ostream &stream);
- //------------------------------------------------------------------
// Member functions
//
// These functions are safe to call at any time you have a Log* obtained from
// the Channel class. If logging is disabled between you obtaining the Log
// object and writing to it, the output will be silently discarded.
- //------------------------------------------------------------------
Log(Channel &channel) : m_channel(channel) {}
~Log() = default;
diff --git a/include/lldb/Utility/Logging.h b/include/lldb/Utility/Logging.h
index 2c75a3bf218b5..41086fedf8c2d 100644
--- a/include/lldb/Utility/Logging.h
+++ b/include/lldb/Utility/Logging.h
@@ -1,9 +1,8 @@
//===-- Logging.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,9 +11,7 @@
#include <cstdint>
-//----------------------------------------------------------------------
// Log Bits specific to logging in lldb
-//----------------------------------------------------------------------
#define LIBLLDB_LOG_PROCESS (1u << 1)
#define LIBLLDB_LOG_THREAD (1u << 2)
#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 3)
@@ -45,6 +42,7 @@
#define LIBLLDB_LOG_LANGUAGE (1u << 28)
#define LIBLLDB_LOG_DATAFORMATTERS (1u << 29)
#define LIBLLDB_LOG_DEMANGLE (1u << 30)
+#define LIBLLDB_LOG_AST (1u << 31)
#define LIBLLDB_LOG_ALL (UINT32_MAX)
#define LIBLLDB_LOG_DEFAULT \
(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_THREAD | LIBLLDB_LOG_DYNAMIC_LOADER | \
diff --git a/include/lldb/Utility/NameMatches.h b/include/lldb/Utility/NameMatches.h
index bc9ec703770a0..38900df2bd5d9 100644
--- a/include/lldb/Utility/NameMatches.h
+++ b/include/lldb/Utility/NameMatches.h
@@ -1,9 +1,8 @@
//===-- NameMatches.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_UTILITY_NAMEMATCHES_H
diff --git a/include/lldb/Utility/Predicate.h b/include/lldb/Utility/Predicate.h
index d05f17131c684..f1539b5766868 100644
--- a/include/lldb/Utility/Predicate.h
+++ b/include/lldb/Utility/Predicate.h
@@ -1,9 +1,8 @@
//===-- Predicate.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,20 +20,17 @@
//#define DB_PTHREAD_LOG_EVENTS
-//----------------------------------------------------------------------
/// Enumerations for broadcasting.
-//----------------------------------------------------------------------
namespace lldb_private {
-typedef enum {
+enum PredicateBroadcastType {
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;
+};
-//----------------------------------------------------------------------
-/// @class Predicate Predicate.h "lldb/Utility/Predicate.h"
+/// \class Predicate Predicate.h "lldb/Utility/Predicate.h"
/// A C++ wrapper class for providing threaded access to a value of
/// type T.
///
@@ -42,66 +38,55 @@ typedef enum {
/// of type T. Threads can efficiently wait for bits within T to be set
/// or reset, or wait for T to be set to be equal/not equal to a
/// specified values.
-//----------------------------------------------------------------------
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
+ /// \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
+ /// \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
+ /// \param[in] value
/// The new value to set.
///
- /// @param[in] broadcast_type
+ /// \param[in] broadcast_type
/// A value indicating when and if to broadcast. See the
/// PredicateBroadcastType enumeration for details.
///
- /// @see Predicate::Broadcast()
- //------------------------------------------------------------------
+ /// \see Predicate::Broadcast()
void SetValue(T value, PredicateBroadcastType broadcast_type) {
std::lock_guard<std::mutex> guard(m_mutex);
#ifdef DB_PTHREAD_LOG_EVENTS
@@ -114,7 +99,6 @@ public:
Broadcast(old_value, broadcast_type);
}
- //------------------------------------------------------------------
/// Wait for Cond(m_value) to be true.
///
/// Waits in a thread safe way for Cond(m_value) to be true. If Cond(m_value)
@@ -126,16 +110,15 @@ public:
/// into a wait state. It may be necessary for the calling code to use
/// additional thread synchronization methods to detect transitory states.
///
- /// @param[in] Cond
+ /// \param[in] Cond
/// The condition we want \a m_value satisfy.
///
- /// @param[in] timeout
+ /// \param[in] timeout
/// How long to wait for the condition to hold.
///
- /// @return
- /// @li m_value if Cond(m_value) is true.
- /// @li None otherwise (timeout occurred).
- //------------------------------------------------------------------
+ /// \return
+ /// \li m_value if Cond(m_value) is true.
+ /// \li None otherwise (timeout occurred).
template <typename C>
llvm::Optional<T> WaitFor(C Cond, const Timeout<std::micro> &timeout) {
std::unique_lock<std::mutex> lock(m_mutex);
@@ -148,7 +131,6 @@ public:
return m_value;
return llvm::None;
}
- //------------------------------------------------------------------
/// 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
@@ -162,23 +144,21 @@ public:
/// may be necessary for the calling code to use additional thread
/// synchronization methods to detect transitory states.
///
- /// @param[in] value
+ /// \param[in] value
/// The value we want \a m_value to be equal to.
///
- /// @param[in] timeout
+ /// \param[in] timeout
/// How long to wait for the condition to hold.
///
- /// @return
- /// @li \b true if the \a m_value is equal to \a value
- /// @li \b false otherwise (timeout occurred)
- //------------------------------------------------------------------
+ /// \return
+ /// \li \b true if the \a m_value is equal to \a value
+ /// \li \b false otherwise (timeout occurred)
bool WaitForValueEqualTo(T value,
const Timeout<std::micro> &timeout = llvm::None) {
return WaitFor([&value](T current) { return value == current; }, timeout) !=
llvm::None;
}
- //------------------------------------------------------------------
/// 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
@@ -192,16 +172,15 @@ public:
/// necessary for the calling code to use additional thread
/// synchronization methods to detect transitory states.
///
- /// @param[in] value
+ /// \param[in] value
/// The value we want \a m_value to not be equal to.
///
- /// @param[in] timeout
+ /// \param[in] timeout
/// How long to wait for the condition to hold.
///
- /// @return
- /// @li m_value if m_value != value
- /// @li None otherwise (timeout occurred).
- //------------------------------------------------------------------
+ /// \return
+ /// \li m_value if m_value != value
+ /// \li None otherwise (timeout occurred).
llvm::Optional<T>
WaitForValueNotEqualTo(T value,
const Timeout<std::micro> &timeout = llvm::None) {
@@ -209,10 +188,8 @@ public:
}
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 std::mutex m_mutex; ///< The mutex to use when accessing the data
std::condition_variable m_condition; ///< The pthread condition variable to
@@ -220,7 +197,6 @@ protected:
/// or changed.
private:
- //------------------------------------------------------------------
/// Broadcast if needed.
///
/// Check to see if we need to broadcast to our condition variable
@@ -234,7 +210,6 @@ private:
///
/// 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) ||
diff --git a/include/lldb/Utility/ProcessInfo.h b/include/lldb/Utility/ProcessInfo.h
new file mode 100644
index 0000000000000..a25c06cabdf6c
--- /dev/null
+++ b/include/lldb/Utility/ProcessInfo.h
@@ -0,0 +1,245 @@
+//===-- ProcessInfo.h -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_PROCESSINFO_H
+#define LLDB_UTILITY_PROCESSINFO_H
+
+// LLDB headers
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Args.h"
+#include "lldb/Utility/Environment.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/NameMatches.h"
+
+#include <vector>
+
+namespace lldb_private {
+
+class UserIDResolver;
+
+// 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);
+
+ Environment &GetEnvironment() { return m_environment; }
+ const Environment &GetEnvironment() 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]
+ Environment m_environment;
+ uint32_t m_uid;
+ uint32_t m_gid;
+ ArchSpec m_arch;
+ lldb::pid_t m_pid;
+};
+
+// ProcessInstanceInfo
+//
+// Describes an existing process and any discoverable information that pertains
+// to that process.
+class ProcessInstanceInfo : public ProcessInfo {
+public:
+ 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; }
+
+ uint32_t GetEffectiveGroupID() const { return m_egid; }
+
+ 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; }
+
+ bool ParentProcessIDIsValid() const {
+ return m_parent_pid != LLDB_INVALID_PROCESS_ID;
+ }
+
+ void Dump(Stream &s, UserIDResolver &resolver) const;
+
+ static void DumpTableHeader(Stream &s, bool show_args, bool verbose);
+
+ void DumpAsTableRow(Stream &s, UserIDResolver &resolver, bool show_args,
+ bool verbose) const;
+
+protected:
+ uint32_t m_euid;
+ uint32_t m_egid;
+ lldb::pid_t m_parent_pid;
+};
+
+class ProcessInstanceInfoList {
+public:
+ ProcessInstanceInfoList() = default;
+
+ void Clear() { m_infos.clear(); }
+
+ size_t GetSize() { return m_infos.size(); }
+
+ void Append(const ProcessInstanceInfo &info) { m_infos.push_back(info); }
+
+ const char *GetProcessNameAtIndex(size_t idx) {
+ return ((idx < m_infos.size()) ? m_infos[idx].GetName() : nullptr);
+ }
+
+ 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:
+ std::vector<ProcessInstanceInfo> m_infos;
+};
+
+// ProcessInstanceInfoMatch
+//
+// A class to help matching one ProcessInstanceInfo to another.
+
+class ProcessInstanceInfoMatch {
+public:
+ ProcessInstanceInfoMatch()
+ : m_match_info(), m_name_match_type(NameMatch::Ignore),
+ m_match_all_users(false) {}
+
+ ProcessInstanceInfoMatch(const char *process_name,
+ NameMatch 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,
+ FileSpec::Style::native);
+ }
+
+ ProcessInstanceInfo &GetProcessInfo() { return m_match_info; }
+
+ const ProcessInstanceInfo &GetProcessInfo() const { return m_match_info; }
+
+ bool GetMatchAllUsers() const { return m_match_all_users; }
+
+ void SetMatchAllUsers(bool b) { m_match_all_users = b; }
+
+ NameMatch GetNameMatchType() const { return m_name_match_type; }
+
+ void SetNameMatchType(NameMatch name_match_type) {
+ m_name_match_type = name_match_type;
+ }
+
+ bool NameMatches(const char *process_name) const;
+
+ bool Matches(const ProcessInstanceInfo &proc_info) const;
+
+ bool MatchAllProcesses() const;
+ void Clear();
+
+protected:
+ ProcessInstanceInfo m_match_info;
+ NameMatch m_name_match_type;
+ bool m_match_all_users;
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_UTILITY_PROCESSINFO_H
diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Utility/RangeMap.h
index 5a75a24f7f61c..36401f59d34f9 100644
--- a/include/lldb/Core/RangeMap.h
+++ b/include/lldb/Utility/RangeMap.h
@@ -1,14 +1,13 @@
//===-- RangeMap.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef liblldb_RangeMap_h_
-#define liblldb_RangeMap_h_
+#ifndef LLDB_UTILITY_RANGEMAP_H
+#define LLDB_UTILITY_RANGEMAP_H
#include <algorithm>
#include <vector>
@@ -22,15 +21,11 @@
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;
@@ -54,10 +49,8 @@ template <typename B, typename S> struct Range {
void Slide(BaseType slide) { base += slide; }
- bool Union(const Range &rhs)
- {
- if (DoesAdjoinOrIntersect(rhs))
- {
+ bool Union(const Range &rhs) {
+ if (DoesAdjoinOrIntersect(rhs)) {
auto new_end = std::max<BaseType>(GetRangeEnd(), rhs.GetRangeEnd());
base = std::min<BaseType>(base, rhs.base);
size = new_end - base;
@@ -129,10 +122,8 @@ template <typename B, typename S> struct Range {
}
};
-//----------------------------------------------------------------------
// 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:
@@ -570,7 +561,6 @@ public:
}
protected:
-
void CombinePrevAndNext(typename Collection::iterator pos) {
// Check if the prev or next entries in case they need to be unioned with
// the entry pointed to by "pos".
@@ -580,7 +570,7 @@ protected:
m_entries.erase(pos);
pos = prev;
}
-
+
auto end = m_entries.end();
if (pos != end) {
auto next = pos + 1;
@@ -595,11 +585,9 @@ 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;
@@ -636,6 +624,7 @@ struct RangeData : public Range<B, S> {
template <typename B, typename S, typename T, unsigned N = 0>
class RangeDataVector {
public:
+ typedef lldb_private::Range<B, S> Range;
typedef RangeData<B, S, T> Entry;
typedef llvm::SmallVector<Entry, N> Collection;
@@ -716,6 +705,7 @@ public:
// Clients must ensure that "i" is a valid index prior to calling this
// function
+ Entry &GetEntryRef(size_t i) { return m_entries[i]; }
const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
@@ -827,11 +817,9 @@ 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;
@@ -947,4 +935,4 @@ protected:
} // namespace lldb_private
-#endif // liblldb_RangeMap_h_
+#endif // LLDB_UTILITY_RANGEMAP_H
diff --git a/include/lldb/Utility/RegisterValue.h b/include/lldb/Utility/RegisterValue.h
index c025a26fb25a9..eeb3ce52a82bf 100644
--- a/include/lldb/Utility/RegisterValue.h
+++ b/include/lldb/Utility/RegisterValue.h
@@ -1,9 +1,8 @@
//===-- RegisterValue.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,7 +41,8 @@ public:
eTypeBytes
};
- RegisterValue() : m_type(eTypeInvalid), m_scalar((unsigned long)0) {}
+ RegisterValue()
+ : m_type(eTypeInvalid), m_scalar(static_cast<unsigned long>(0)) {}
explicit RegisterValue(uint8_t inst) : m_type(eTypeUInt8) { m_scalar = inst; }
diff --git a/include/lldb/Utility/RegularExpression.h b/include/lldb/Utility/RegularExpression.h
index b379c6e8bea14..54f3dd89c7a2a 100644
--- a/include/lldb/Utility/RegularExpression.h
+++ b/include/lldb/Utility/RegularExpression.h
@@ -1,9 +1,8 @@
//===-- RegularExpression.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -49,15 +48,13 @@ class StringRef;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class RegularExpression RegularExpression.h
+/// \class RegularExpression RegularExpression.h
/// "lldb/Utility/RegularExpression.h"
/// A C++ wrapper class for regex.
///
/// This regular expression class wraps the posix regex functions \c
/// regcomp(), \c regerror(), \c regexec(), and \c regfree() from the header
/// file in \c /usr/include/regex\.h.
-//----------------------------------------------------------------------
class RegularExpression {
public:
class Match {
@@ -95,29 +92,24 @@ public:
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.
@@ -126,18 +118,16 @@ public:
/// after the regular expression is compiled. Any previously compiled
/// regular expression contained in this object will be freed.
///
- /// @param[in] re
+ /// \param[in] re
/// A NULL terminated C string that represents the regular
/// expression to compile.
///
- /// @return
+ /// \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
@@ -146,52 +136,45 @@ public:
/// indicate the number of regmatch_t values that are present in \a
/// match_ptr.
///
- /// @param[in] string
+ /// \param[in] string
/// The string to match against the compile regular expression.
///
- /// @param[in] match
+ /// \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
+ /// \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
+ /// \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
+ /// \return
/// \b true if the regular expression compiled and is ready
/// for execution, \b false otherwise.
- //------------------------------------------------------------------
bool IsValid() const;
void Clear() {
@@ -205,9 +188,7 @@ public:
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; ///< Status code for the regular expression compilation
regex_t m_preg; ///< The compiled regular expression
diff --git a/include/lldb/Utility/Reproducer.h b/include/lldb/Utility/Reproducer.h
index ea315ad771a61..670041d06bbac 100644
--- a/include/lldb/Utility/Reproducer.h
+++ b/include/lldb/Utility/Reproducer.h
@@ -1,15 +1,15 @@
//===-- Reproducer.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_UTILITY_REPRODUCER_H
#define LLDB_UTILITY_REPRODUCER_H
+#include "lldb/Utility/FileCollector.h"
#include "lldb/Utility/FileSpec.h"
#include "llvm/ADT/DenseMap.h"
@@ -31,24 +31,14 @@ enum class ReproducerMode {
Off,
};
-/// Abstraction for information associated with a provider. This information
-/// is serialized into an index which is used by the loader.
-struct ProviderInfo {
- std::string name;
- std::vector<std::string> files;
-};
-
/// The provider defines an interface for generating files needed for
-/// reproducing. The provider must populate its ProviderInfo to communicate
-/// its name and files to the index, before registering with the generator,
-/// i.e. in the constructor.
+/// reproducing.
///
/// Different components will implement different providers.
class ProviderBase {
public:
virtual ~ProviderBase() = default;
- const ProviderInfo &GetInfo() const { return m_info; }
const FileSpec &GetRoot() const { return m_root; }
/// The Keep method is called when it is decided that we need to keep the
@@ -65,11 +55,12 @@ public:
// Returns the class ID for the dynamic type of this Provider instance.
virtual const void *DynamicClassID() const = 0;
+ virtual llvm::StringRef GetName() const = 0;
+ virtual llvm::StringRef GetFile() const = 0;
+
protected:
ProviderBase(const FileSpec &root) : m_root(root) {}
- /// Every provider keeps track of its own files.
- ProviderInfo m_info;
private:
/// Every provider knows where to dump its potential files.
FileSpec m_root;
@@ -84,10 +75,112 @@ public:
const void *DynamicClassID() const override { return &ThisProviderT::ID; }
+ llvm::StringRef GetName() const override { return ThisProviderT::Info::name; }
+ llvm::StringRef GetFile() const override { return ThisProviderT::Info::file; }
+
protected:
using ProviderBase::ProviderBase; // Inherit constructor.
};
+class FileProvider : public Provider<FileProvider> {
+public:
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
+
+ FileProvider(const FileSpec &directory)
+ : Provider(directory),
+ m_collector(directory.CopyByAppendingPathComponent("root"), directory) {
+ }
+
+ FileCollector &GetFileCollector() { return m_collector; }
+
+ void Keep() override {
+ auto mapping = GetRoot().CopyByAppendingPathComponent(Info::file);
+ // Temporary files that are removed during execution can cause copy errors.
+ if (auto ec = m_collector.CopyFiles(/*stop_on_error=*/false))
+ return;
+ m_collector.WriteMapping(mapping);
+ }
+
+ static char ID;
+
+private:
+ FileCollector m_collector;
+};
+
+/// Provider for the LLDB version number.
+///
+/// When the reproducer is kept, it writes the lldb version to a file named
+/// version.txt in the reproducer root.
+class VersionProvider : public Provider<VersionProvider> {
+public:
+ VersionProvider(const FileSpec &directory) : Provider(directory) {}
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
+ void SetVersion(std::string version) {
+ assert(m_version.empty());
+ m_version = std::move(version);
+ }
+ void Keep() override;
+ std::string m_version;
+ static char ID;
+};
+
+class DataRecorder {
+public:
+ DataRecorder(const FileSpec &filename, std::error_code &ec)
+ : m_filename(filename.GetFilename().GetStringRef()),
+ m_os(filename.GetPath(), ec, llvm::sys::fs::F_Text), m_record(true) {}
+
+ static llvm::Expected<std::unique_ptr<DataRecorder>>
+ Create(const FileSpec &filename);
+
+ template <typename T> void Record(const T &t, bool newline = false) {
+ if (!m_record)
+ return;
+ m_os << t;
+ if (newline)
+ m_os << '\n';
+ m_os.flush();
+ }
+
+ const FileSpec &GetFilename() { return m_filename; }
+
+ void Stop() {
+ assert(m_record);
+ m_record = false;
+ }
+
+private:
+ FileSpec m_filename;
+ llvm::raw_fd_ostream m_os;
+ bool m_record;
+};
+
+class CommandProvider : public Provider<CommandProvider> {
+public:
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
+
+ CommandProvider(const FileSpec &directory) : Provider(directory) {}
+
+ DataRecorder *GetNewDataRecorder();
+
+ void Keep() override;
+ void Discard() override;
+
+ static char ID;
+
+private:
+ std::vector<std::unique_ptr<DataRecorder>> m_data_recorders;
+};
+
/// The generator is responsible for the logic needed to generate a
/// reproducer. For doing so it relies on providers, who serialize data that
/// is necessary for reproducing a failure.
@@ -152,14 +245,22 @@ class Loader final {
public:
Loader(const FileSpec &root);
- llvm::Optional<ProviderInfo> GetProviderInfo(llvm::StringRef name);
+ template <typename T> FileSpec GetFile() {
+ if (!HasFile(T::file))
+ return {};
+
+ return GetRoot().CopyByAppendingPathComponent(T::file);
+ }
+
llvm::Error LoadIndex();
const FileSpec &GetRoot() const { return m_root; }
private:
- llvm::StringMap<ProviderInfo> m_provider_info;
+ bool HasFile(llvm::StringRef file);
+
FileSpec m_root;
+ std::vector<std::string> m_files;
bool m_loaded;
};
@@ -170,6 +271,7 @@ public:
static Reproducer &Instance();
static llvm::Error Initialize(ReproducerMode mode,
llvm::Optional<FileSpec> root);
+ static bool Initialized();
static void Terminate();
Reproducer() = default;
@@ -198,18 +300,4 @@ private:
} // namespace repro
} // namespace lldb_private
-LLVM_YAML_IS_DOCUMENT_LIST_VECTOR(lldb_private::repro::ProviderInfo)
-
-namespace llvm {
-namespace yaml {
-
-template <> struct MappingTraits<lldb_private::repro::ProviderInfo> {
- static void mapping(IO &io, lldb_private::repro::ProviderInfo &info) {
- io.mapRequired("name", info.name);
- io.mapOptional("files", info.files);
- }
-};
-} // namespace yaml
-} // namespace llvm
-
#endif // LLDB_UTILITY_REPRODUCER_H
diff --git a/include/lldb/Utility/ReproducerInstrumentation.h b/include/lldb/Utility/ReproducerInstrumentation.h
new file mode 100644
index 0000000000000..f90ce4bc767a3
--- /dev/null
+++ b/include/lldb/Utility/ReproducerInstrumentation.h
@@ -0,0 +1,717 @@
+//===-- ReproducerInstrumentation.h -----------------------------*- C++ -*-===//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H
+#define LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H
+
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Logging.h"
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ErrorHandling.h"
+
+#include <iostream>
+#include <map>
+#include <type_traits>
+
+template <typename T,
+ typename std::enable_if<std::is_fundamental<T>::value, int>::type = 0>
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
+ ss << t;
+}
+
+template <typename T, typename std::enable_if<!std::is_fundamental<T>::value,
+ int>::type = 0>
+inline void stringify_append(llvm::raw_string_ostream &ss, const T &t) {
+ ss << &t;
+}
+
+template <typename T>
+inline void stringify_append(llvm::raw_string_ostream &ss, const T *t) {
+ ss << reinterpret_cast<const void *>(t);
+}
+
+template <>
+inline void stringify_append<char>(llvm::raw_string_ostream &ss,
+ const char *t) {
+ ss << t;
+}
+
+template <typename Head>
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head) {
+ stringify_append(ss, head);
+}
+
+template <typename Head, typename... Tail>
+inline void stringify_helper(llvm::raw_string_ostream &ss, const Head &head,
+ const Tail &... tail) {
+ stringify_append(ss, head);
+ ss << ", ";
+ stringify_helper(ss, tail...);
+}
+
+template <typename... Ts> inline std::string stringify_args(const Ts &... ts) {
+ std::string buffer;
+ llvm::raw_string_ostream ss(buffer);
+ stringify_helper(ss, ts...);
+ return ss.str();
+}
+
+// Define LLDB_REPRO_INSTR_TRACE to trace to stderr instead of LLDB's log
+// infrastructure. This is useful when you need to see traces before the logger
+// is initialized or enabled.
+// #define LLDB_REPRO_INSTR_TRACE
+
+#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature) \
+ R.Register<Class * Signature>(&construct<Class Signature>::doit, "", #Class, \
+ #Class, #Signature)
+#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature) \
+ R.Register( \
+ &invoke<Result(Class::*) Signature>::method<(&Class::Method)>::doit, \
+ #Result, #Class, #Method, #Signature)
+#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature) \
+ R.Register(&invoke<Result(Class::*) Signature const>::method_const<( \
+ &Class::Method)>::doit, \
+ #Result, #Class, #Method, #Signature)
+#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature) \
+ R.Register<Result Signature>( \
+ static_cast<Result(*) Signature>(&Class::Method), #Result, #Class, \
+ #Method, #Signature)
+
+#define LLDB_RECORD_CONSTRUCTOR(Class, Signature, ...) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__)); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
+ &lldb_private::repro::construct<Class Signature>::doit, \
+ __VA_ARGS__); \
+ sb_recorder.RecordResult(this); \
+ }
+
+#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
+ &lldb_private::repro::construct<Class()>::doit); \
+ sb_recorder.RecordResult(this); \
+ }
+
+#define LLDB_RECORD_METHOD(Result, Class, Method, Signature, ...) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__)); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record( \
+ data.GetSerializer(), data.GetRegistry(), \
+ &lldb_private::repro::invoke<Result(Class::*) Signature>::method<( \
+ &Class::Method)>::doit, \
+ this, __VA_ARGS__); \
+ }
+
+#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature, ...) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__)); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record( \
+ data.GetSerializer(), data.GetRegistry(), \
+ &lldb_private::repro::invoke<Result( \
+ Class::*) Signature const>::method_const<(&Class::Method)>::doit, \
+ this, __VA_ARGS__); \
+ }
+
+#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
+ &lldb_private::repro::invoke<Result ( \
+ Class::*)()>::method<(&Class::Method)>::doit, \
+ this); \
+ }
+
+#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record( \
+ data.GetSerializer(), data.GetRegistry(), \
+ &lldb_private::repro::invoke<Result ( \
+ Class::*)() const>::method_const<(&Class::Method)>::doit, \
+ this); \
+ }
+
+#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature, ...) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__)); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
+ static_cast<Result(*) Signature>(&Class::Method), \
+ __VA_ARGS__); \
+ }
+
+#define LLDB_RECORD_STATIC_METHOD_NO_ARGS(Result, Class, Method) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION); \
+ if (lldb_private::repro::InstrumentationData data = \
+ LLDB_GET_INSTRUMENTATION_DATA()) { \
+ sb_recorder.Record(data.GetSerializer(), data.GetRegistry(), \
+ static_cast<Result (*)()>(&Class::Method)); \
+ }
+
+#define LLDB_RECORD_RESULT(Result) sb_recorder.RecordResult(Result);
+
+/// The LLDB_RECORD_DUMMY macro is special because it doesn't actually record
+/// anything. It's used to track API boundaries when we cannot record for
+/// technical reasons.
+#define LLDB_RECORD_DUMMY(Result, Class, Method, Signature, ...) \
+ lldb_private::repro::Recorder sb_recorder(LLVM_PRETTY_FUNCTION, \
+ stringify_args(__VA_ARGS__));
+
+namespace lldb_private {
+namespace repro {
+
+/// Mapping between serialized indices and their corresponding objects.
+///
+/// This class is used during replay to map indices back to in-memory objects.
+///
+/// When objects are constructed, they are added to this mapping using
+/// AddObjectForIndex.
+///
+/// When an object is passed to a function, its index is deserialized and
+/// AddObjectForIndex returns the corresponding object. If there is no object
+/// for the given index, a nullptr is returend. The latter is valid when custom
+/// replay code is in place and the actual object is ignored.
+class IndexToObject {
+public:
+ /// Returns an object as a pointer for the given index or nullptr if not
+ /// present in the map.
+ template <typename T> T *GetObjectForIndex(unsigned idx) {
+ assert(idx != 0 && "Cannot get object for sentinel");
+ void *object = GetObjectForIndexImpl(idx);
+ return static_cast<T *>(object);
+ }
+
+ /// Adds a pointer to an object to the mapping for the given index.
+ template <typename T> void AddObjectForIndex(unsigned idx, T *object) {
+ AddObjectForIndexImpl(
+ idx, static_cast<void *>(
+ const_cast<typename std::remove_const<T>::type *>(object)));
+ }
+
+ /// Adds a reference to an object to the mapping for the given index.
+ template <typename T> void AddObjectForIndex(unsigned idx, T &object) {
+ AddObjectForIndexImpl(
+ idx, static_cast<void *>(
+ const_cast<typename std::remove_const<T>::type *>(&object)));
+ }
+
+private:
+ /// Helper method that does the actual lookup. The void* result is later cast
+ /// by the caller.
+ void *GetObjectForIndexImpl(unsigned idx);
+
+ /// Helper method that does the actual insertion.
+ void AddObjectForIndexImpl(unsigned idx, void *object);
+
+ /// Keeps a mapping between indices and their corresponding object.
+ llvm::DenseMap<unsigned, void *> m_mapping;
+};
+
+/// We need to differentiate between pointers to fundamental and
+/// non-fundamental types. See the corresponding Deserializer::Read method
+/// for the reason why.
+struct PointerTag {};
+struct ReferenceTag {};
+struct ValueTag {};
+struct FundamentalPointerTag {};
+struct FundamentalReferenceTag {};
+
+/// Return the deserialization tag for the given type T.
+template <class T> struct serializer_tag { typedef ValueTag type; };
+template <class T> struct serializer_tag<T *> {
+ typedef
+ typename std::conditional<std::is_fundamental<T>::value,
+ FundamentalPointerTag, PointerTag>::type type;
+};
+template <class T> struct serializer_tag<T &> {
+ typedef typename std::conditional<std::is_fundamental<T>::value,
+ FundamentalReferenceTag, ReferenceTag>::type
+ type;
+};
+
+/// Deserializes data from a buffer. It is used to deserialize function indices
+/// to replay, their arguments and return values.
+///
+/// Fundamental types and strings are read by value. Objects are read by their
+/// index, which get translated by the IndexToObject mapping maintained in
+/// this class.
+///
+/// Additional bookkeeping with regards to the IndexToObject is required to
+/// deserialize objects. When a constructor is run or an object is returned by
+/// value, we need to capture the object and add it to the index together with
+/// its index. This is the job of HandleReplayResult(Void).
+class Deserializer {
+public:
+ Deserializer(llvm::StringRef buffer) : m_buffer(buffer) {}
+
+ /// Returns true when the buffer has unread data.
+ bool HasData(unsigned size) { return size <= m_buffer.size(); }
+
+ /// Deserialize and interpret value as T.
+ template <typename T> T Deserialize() {
+#ifdef LLDB_REPRO_INSTR_TRACE
+ llvm::errs() << "Deserializing with " << LLVM_PRETTY_FUNCTION << "\n";
+#endif
+ return Read<T>(typename serializer_tag<T>::type());
+ }
+
+ /// Store the returned value in the index-to-object mapping.
+ template <typename T> void HandleReplayResult(const T &t) {
+ unsigned result = Deserialize<unsigned>();
+ if (std::is_fundamental<T>::value)
+ return;
+ // We need to make a copy as the original object might go out of scope.
+ m_index_to_object.AddObjectForIndex(result, new T(t));
+ }
+
+ /// Store the returned value in the index-to-object mapping.
+ template <typename T> void HandleReplayResult(T *t) {
+ unsigned result = Deserialize<unsigned>();
+ if (std::is_fundamental<T>::value)
+ return;
+ m_index_to_object.AddObjectForIndex(result, t);
+ }
+
+ /// All returned types are recorded, even when the function returns a void.
+ /// The latter requires special handling.
+ void HandleReplayResultVoid() {
+ unsigned result = Deserialize<unsigned>();
+ assert(result == 0);
+ (void)result;
+ }
+
+private:
+ template <typename T> T Read(ValueTag) {
+ assert(HasData(sizeof(T)));
+ T t;
+ std::memcpy(reinterpret_cast<char *>(&t), m_buffer.data(), sizeof(T));
+ m_buffer = m_buffer.drop_front(sizeof(T));
+ return t;
+ }
+
+ template <typename T> T Read(PointerTag) {
+ typedef typename std::remove_pointer<T>::type UnderlyingT;
+ return m_index_to_object.template GetObjectForIndex<UnderlyingT>(
+ Deserialize<unsigned>());
+ }
+
+ template <typename T> T Read(ReferenceTag) {
+ typedef typename std::remove_reference<T>::type UnderlyingT;
+ // If this is a reference to a fundamental type we just read its value.
+ return *m_index_to_object.template GetObjectForIndex<UnderlyingT>(
+ Deserialize<unsigned>());
+ }
+
+ /// This method is used to parse references to fundamental types. Because
+ /// they're not recorded in the object table we have serialized their value.
+ /// We read its value, allocate a copy on the heap, and return a pointer to
+ /// the copy.
+ template <typename T> T Read(FundamentalPointerTag) {
+ typedef typename std::remove_pointer<T>::type UnderlyingT;
+ return new UnderlyingT(Deserialize<UnderlyingT>());
+ }
+
+ /// This method is used to parse references to fundamental types. Because
+ /// they're not recorded in the object table we have serialized their value.
+ /// We read its value, allocate a copy on the heap, and return a reference to
+ /// the copy.
+ template <typename T> T Read(FundamentalReferenceTag) {
+ // If this is a reference to a fundamental type we just read its value.
+ typedef typename std::remove_reference<T>::type UnderlyingT;
+ return *(new UnderlyingT(Deserialize<UnderlyingT>()));
+ }
+
+ /// Mapping of indices to objects.
+ IndexToObject m_index_to_object;
+
+ /// Buffer containing the serialized data.
+ llvm::StringRef m_buffer;
+};
+
+/// Partial specialization for C-style strings. We read the string value
+/// instead of treating it as pointer.
+template <> const char *Deserializer::Deserialize<const char *>();
+template <> char *Deserializer::Deserialize<char *>();
+
+/// Helpers to auto-synthesize function replay code. It deserializes the replay
+/// function's arguments one by one and finally calls the corresponding
+/// function.
+template <typename... Remaining> struct DeserializationHelper;
+
+template <typename Head, typename... Tail>
+struct DeserializationHelper<Head, Tail...> {
+ template <typename Result, typename... Deserialized> struct deserialized {
+ static Result doit(Deserializer &deserializer,
+ Result (*f)(Deserialized..., Head, Tail...),
+ Deserialized... d) {
+ return DeserializationHelper<Tail...>::
+ template deserialized<Result, Deserialized..., Head>::doit(
+ deserializer, f, d..., deserializer.Deserialize<Head>());
+ }
+ };
+};
+
+template <> struct DeserializationHelper<> {
+ template <typename Result, typename... Deserialized> struct deserialized {
+ static Result doit(Deserializer &deserializer, Result (*f)(Deserialized...),
+ Deserialized... d) {
+ return f(d...);
+ }
+ };
+};
+
+/// The replayer interface.
+struct Replayer {
+ virtual ~Replayer() {}
+ virtual void operator()(Deserializer &deserializer) const = 0;
+};
+
+/// The default replayer deserializes the arguments and calls the function.
+template <typename Signature> struct DefaultReplayer;
+template <typename Result, typename... Args>
+struct DefaultReplayer<Result(Args...)> : public Replayer {
+ DefaultReplayer(Result (*f)(Args...)) : Replayer(), f(f) {}
+
+ void operator()(Deserializer &deserializer) const override {
+ deserializer.HandleReplayResult(
+ DeserializationHelper<Args...>::template deserialized<Result>::doit(
+ deserializer, f));
+ }
+
+ Result (*f)(Args...);
+};
+
+/// Partial specialization for function returning a void type. It ignores the
+/// (absent) return value.
+template <typename... Args>
+struct DefaultReplayer<void(Args...)> : public Replayer {
+ DefaultReplayer(void (*f)(Args...)) : Replayer(), f(f) {}
+
+ void operator()(Deserializer &deserializer) const override {
+ DeserializationHelper<Args...>::template deserialized<void>::doit(
+ deserializer, f);
+ deserializer.HandleReplayResultVoid();
+ }
+
+ void (*f)(Args...);
+};
+
+/// The registry contains a unique mapping between functions and their ID. The
+/// IDs can be serialized and deserialized to replay a function. Functions need
+/// to be registered with the registry for this to work.
+class Registry {
+private:
+ struct SignatureStr {
+ SignatureStr(llvm::StringRef result = {}, llvm::StringRef scope = {},
+ llvm::StringRef name = {}, llvm::StringRef args = {})
+ : result(result), scope(scope), name(name), args(args) {}
+
+ std::string ToString() const;
+
+ llvm::StringRef result;
+ llvm::StringRef scope;
+ llvm::StringRef name;
+ llvm::StringRef args;
+ };
+
+public:
+ Registry() = default;
+ virtual ~Registry() = default;
+
+ /// Register a default replayer for a function.
+ template <typename Signature>
+ void Register(Signature *f, llvm::StringRef result = {},
+ llvm::StringRef scope = {}, llvm::StringRef name = {},
+ llvm::StringRef args = {}) {
+ DoRegister(uintptr_t(f), llvm::make_unique<DefaultReplayer<Signature>>(f),
+ SignatureStr(result, scope, name, args));
+ }
+
+ /// Register a replayer that invokes a custom function with the same
+ /// signature as the replayed function.
+ template <typename Signature>
+ void Register(Signature *f, Signature *g, llvm::StringRef result = {},
+ llvm::StringRef scope = {}, llvm::StringRef name = {},
+ llvm::StringRef args = {}) {
+ DoRegister(uintptr_t(f), llvm::make_unique<DefaultReplayer<Signature>>(g),
+ SignatureStr(result, scope, name, args));
+ }
+
+ /// Replay functions from a file.
+ bool Replay(const FileSpec &file);
+
+ /// Replay functions from a buffer.
+ bool Replay(llvm::StringRef buffer);
+
+ /// Returns the ID for a given function address.
+ unsigned GetID(uintptr_t addr);
+
+protected:
+ /// Register the given replayer for a function (and the ID mapping).
+ void DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer,
+ SignatureStr signature);
+
+private:
+ std::string GetSignature(unsigned id);
+ Replayer *GetReplayer(unsigned id);
+
+ /// Mapping of function addresses to replayers and their ID.
+ std::map<uintptr_t, std::pair<std::unique_ptr<Replayer>, unsigned>>
+ m_replayers;
+
+ /// Mapping of IDs to replayer instances.
+ std::map<unsigned, std::pair<Replayer *, SignatureStr>> m_ids;
+};
+
+/// To be used as the "Runtime ID" of a constructor. It also invokes the
+/// constructor when called.
+template <typename Signature> struct construct;
+template <typename Class, typename... Args> struct construct<Class(Args...)> {
+ static Class *doit(Args... args) { return new Class(args...); }
+};
+
+/// To be used as the "Runtime ID" of a member function. It also invokes the
+/// member function when called.
+template <typename Signature> struct invoke;
+template <typename Result, typename Class, typename... Args>
+struct invoke<Result (Class::*)(Args...)> {
+ template <Result (Class::*m)(Args...)> struct method {
+ static Result doit(Class *c, Args... args) { return (c->*m)(args...); }
+ };
+};
+
+template <typename Result, typename Class, typename... Args>
+struct invoke<Result (Class::*)(Args...) const> {
+ template <Result (Class::*m)(Args...) const> struct method_const {
+ static Result doit(Class *c, Args... args) { return (c->*m)(args...); }
+ };
+};
+
+template <typename Class, typename... Args>
+struct invoke<void (Class::*)(Args...)> {
+ template <void (Class::*m)(Args...)> struct method {
+ static void doit(Class *c, Args... args) { (c->*m)(args...); }
+ };
+};
+
+/// Maps an object to an index for serialization. Indices are unique and
+/// incremented for every new object.
+///
+/// Indices start at 1 in order to differentiate with an invalid index (0) in
+/// the serialized buffer.
+class ObjectToIndex {
+public:
+ template <typename T> unsigned GetIndexForObject(T *t) {
+ return GetIndexForObjectImpl(static_cast<const void *>(t));
+ }
+
+private:
+ unsigned GetIndexForObjectImpl(const void *object);
+
+ llvm::DenseMap<const void *, unsigned> m_mapping;
+};
+
+/// Serializes functions, their arguments and their return type to a stream.
+class Serializer {
+public:
+ Serializer(llvm::raw_ostream &stream = llvm::outs()) : m_stream(stream) {}
+
+ /// Recursively serialize all the given arguments.
+ template <typename Head, typename... Tail>
+ void SerializeAll(const Head &head, const Tail &... tail) {
+ Serialize(head);
+ SerializeAll(tail...);
+ }
+
+ void SerializeAll() {
+ m_stream.flush();
+ }
+
+private:
+ /// Serialize pointers. We need to differentiate between pointers to
+ /// fundamental types (in which case we serialize its value) and pointer to
+ /// objects (in which case we serialize their index).
+ template <typename T> void Serialize(T *t) {
+ if (std::is_fundamental<T>::value) {
+ Serialize(*t);
+ } else {
+ unsigned idx = m_tracker.GetIndexForObject(t);
+ Serialize(idx);
+ }
+ }
+
+ /// Serialize references. We need to differentiate between references to
+ /// fundamental types (in which case we serialize its value) and references
+ /// to objects (in which case we serialize their index).
+ template <typename T> void Serialize(T &t) {
+ if (std::is_fundamental<T>::value) {
+ m_stream.write(reinterpret_cast<const char *>(&t), sizeof(T));
+ } else {
+ unsigned idx = m_tracker.GetIndexForObject(&t);
+ Serialize(idx);
+ }
+ }
+
+ void Serialize(void *v) {
+ // FIXME: Support void*
+ llvm_unreachable("void* is currently unsupported.");
+ }
+
+ void Serialize(const char *t) {
+ m_stream << t;
+ m_stream.write(0x0);
+ }
+
+ /// Serialization stream.
+ llvm::raw_ostream &m_stream;
+
+ /// Mapping of objects to indices.
+ ObjectToIndex m_tracker;
+};
+
+class InstrumentationData {
+public:
+ InstrumentationData() : m_serializer(nullptr), m_registry(nullptr){};
+ InstrumentationData(Serializer &serializer, Registry &registry)
+ : m_serializer(&serializer), m_registry(&registry){};
+
+ Serializer &GetSerializer() { return *m_serializer; }
+ Registry &GetRegistry() { return *m_registry; }
+
+ operator bool() { return m_serializer != nullptr && m_registry != nullptr; }
+
+private:
+ Serializer *m_serializer;
+ Registry *m_registry;
+};
+
+/// RAII object that records function invocations and their return value.
+///
+/// API calls are only captured when the API boundary is crossed. Once we're in
+/// the API layer, and another API function is called, it doesn't need to be
+/// recorded.
+///
+/// When a call is recored, its result is always recorded as well, even if the
+/// function returns a void. For functions that return by value, RecordResult
+/// should be used. Otherwise a sentinel value (0) will be serialized.
+///
+/// Because of the functional overlap between logging and recording API calls,
+/// this class is also used for logging.
+class Recorder {
+public:
+ Recorder(llvm::StringRef pretty_func = {}, std::string &&pretty_args = {});
+ ~Recorder();
+
+ /// Records a single function call.
+ template <typename Result, typename... FArgs, typename... RArgs>
+ void Record(Serializer &serializer, Registry &registry, Result (*f)(FArgs...),
+ const RArgs &... args) {
+ m_serializer = &serializer;
+ if (!ShouldCapture())
+ return;
+
+ unsigned id = registry.GetID(uintptr_t(f));
+
+#ifdef LLDB_REPRO_INSTR_TRACE
+ Log(id);
+#endif
+
+ serializer.SerializeAll(id);
+ serializer.SerializeAll(args...);
+
+ if (std::is_class<typename std::remove_pointer<
+ typename std::remove_reference<Result>::type>::type>::value) {
+ m_result_recorded = false;
+ } else {
+ serializer.SerializeAll(0);
+ m_result_recorded = true;
+ }
+ }
+
+ /// Records a single function call.
+ template <typename... Args>
+ void Record(Serializer &serializer, Registry &registry, void (*f)(Args...),
+ const Args &... args) {
+ m_serializer = &serializer;
+ if (!ShouldCapture())
+ return;
+
+ unsigned id = registry.GetID(uintptr_t(f));
+
+#ifdef LLDB_REPRO_INSTR_TRACE
+ Log(id);
+#endif
+
+ serializer.SerializeAll(id);
+ serializer.SerializeAll(args...);
+
+ // Record result.
+ serializer.SerializeAll(0);
+ m_result_recorded = true;
+ }
+
+ /// Record the result of a function call.
+ template <typename Result> Result RecordResult(Result &&r) {
+ UpdateBoundary();
+ if (m_serializer && ShouldCapture()) {
+ assert(!m_result_recorded);
+ m_serializer->SerializeAll(r);
+ m_result_recorded = true;
+ }
+ return std::forward<Result>(r);
+ }
+
+private:
+ void UpdateBoundary() {
+ if (m_local_boundary)
+ g_global_boundary = false;
+ }
+
+ bool ShouldCapture() { return m_local_boundary; }
+
+#ifdef LLDB_REPRO_INSTR_TRACE
+ void Log(unsigned id) {
+ llvm::errs() << "Recording " << id << ": " << m_pretty_func << " ("
+ << m_pretty_args << ")\n";
+ }
+#endif
+
+ Serializer *m_serializer;
+
+ /// Pretty function for logging.
+ llvm::StringRef m_pretty_func;
+ std::string m_pretty_args;
+
+ /// Whether this function call was the one crossing the API boundary.
+ bool m_local_boundary;
+
+ /// Whether the return value was recorded explicitly.
+ bool m_result_recorded;
+
+ /// Whether we're currently across the API boundary.
+ static bool g_global_boundary;
+};
+
+} // namespace repro
+} // namespace lldb_private
+
+#endif // LLDB_UTILITY_REPRODUCER_INSTRUMENTATION_H
diff --git a/include/lldb/Utility/Scalar.h b/include/lldb/Utility/Scalar.h
index c23b2f8be25e2..62ee9f666e894 100644
--- a/include/lldb/Utility/Scalar.h
+++ b/include/lldb/Utility/Scalar.h
@@ -1,9 +1,8 @@
//===-- Scalar.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,6 +12,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/lldb-enumerations.h"
#include "lldb/lldb-private-types.h"
+#include "lldb/Utility/LLDBAssert.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include <cstddef>
@@ -27,15 +27,15 @@ class Stream;
#define BITWIDTH_INT128 128
#define NUM_OF_WORDS_INT256 4
#define BITWIDTH_INT256 256
+#define NUM_OF_WORDS_INT512 8
+#define BITWIDTH_INT512 512
namespace lldb_private {
-//----------------------------------------------------------------------
// A class designed to hold onto values and their corresponding types.
// Operators are defined and Scalar objects will correctly promote their types
// and values before performing these operations. Type promotion currently
// follows the ANSI C type promotion rules.
-//----------------------------------------------------------------------
class Scalar {
public:
enum Type {
@@ -50,31 +50,32 @@ public:
e_uint128,
e_sint256,
e_uint256,
+ e_sint512,
+ e_uint512,
e_float,
e_double,
e_long_double
};
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
Scalar();
- Scalar(int v) : m_type(e_sint), m_float((float)0) {
+ Scalar(int v) : m_type(e_sint), m_float(static_cast<float>(0)) {
m_integer = llvm::APInt(sizeof(int) * 8, v, true);
}
- Scalar(unsigned int v) : m_type(e_uint), m_float((float)0) {
+ Scalar(unsigned int v) : m_type(e_uint), m_float(static_cast<float>(0)) {
m_integer = llvm::APInt(sizeof(int) * 8, v);
}
- Scalar(long v) : m_type(e_slong), m_float((float)0) {
+ Scalar(long v) : m_type(e_slong), m_float(static_cast<float>(0)) {
m_integer = llvm::APInt(sizeof(long) * 8, v, true);
}
- Scalar(unsigned long v) : m_type(e_ulong), m_float((float)0) {
+ Scalar(unsigned long v) : m_type(e_ulong), m_float(static_cast<float>(0)) {
m_integer = llvm::APInt(sizeof(long) * 8, v);
}
- Scalar(long long v) : m_type(e_slonglong), m_float((float)0) {
+ Scalar(long long v) : m_type(e_slonglong), m_float(static_cast<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) {
+ Scalar(unsigned long long v)
+ : m_type(e_ulonglong), m_float(static_cast<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); }
@@ -82,48 +83,42 @@ public:
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) {
+ : m_type(e_long_double), m_float(static_cast<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));
+ m_float =
+ llvm::APFloat(llvm::APFloat::IEEEquad(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ (reinterpret_cast<type128 *>(&v))->x));
else
- m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- ((type128 *)&v)->x));
+ m_float =
+ llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ (reinterpret_cast<type128 *>(&v))->x));
}
- Scalar(llvm::APInt v) : m_type(), m_float((float)0) {
+ Scalar(llvm::APInt v) : m_type(), m_float(static_cast<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;
+ m_type = e_sint;
+ return;
case 64:
- if (m_integer.isSignedIntN(sizeof(slonglong_t) * 8))
- m_type = e_slonglong;
- else
- m_type = e_ulonglong;
- break;
+ m_type = e_slonglong;
+ return;
case 128:
- if (m_integer.isSignedIntN(BITWIDTH_INT128))
- m_type = e_sint128;
- else
- m_type = e_uint128;
- break;
+ m_type = e_sint128;
+ return;
case 256:
- if (m_integer.isSignedIntN(BITWIDTH_INT256))
- m_type = e_sint256;
- else
- m_type = e_uint256;
- break;
+ m_type = e_sint256;
+ return;
+ case 512:
+ m_type = e_sint512;
+ return;
}
+ lldbassert(false && "unsupported bitwidth");
}
- Scalar(const Scalar &rhs);
// Scalar(const RegisterValue& reg_value);
virtual ~Scalar();
@@ -175,12 +170,10 @@ public:
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);
@@ -197,41 +190,29 @@ public:
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;
@@ -256,10 +237,6 @@ public:
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;
@@ -279,7 +256,9 @@ public:
if (total_byte_size == 8)
return true;
- const uint64_t max = ((uint64_t)1 << (uint64_t)(total_byte_size * 8)) - 1;
+ const uint64_t max = (static_cast<uint64_t>(1)
+ << static_cast<uint64_t>(total_byte_size * 8)) -
+ 1;
return uval64 <= max;
}
@@ -290,7 +269,9 @@ public:
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 max = (static_cast<int64_t>(1)
+ << static_cast<uint64_t>(total_byte_size * 8 - 1)) -
+ 1;
const int64_t min = ~(max);
return min <= sval64 && sval64 <= max;
}
@@ -310,9 +291,7 @@ protected:
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;
@@ -337,7 +316,6 @@ private:
friend bool operator>=(const Scalar &lhs, const Scalar &rhs);
};
-//----------------------------------------------------------------------
// Split out the operators into a format where the compiler will be able to
// implicitly convert numbers into Scalar objects.
//
@@ -351,7 +329,6 @@ private:
// Item 19 of "Effective C++ Second Edition" by Scott Meyers
// 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);
@@ -369,6 +346,8 @@ bool operator<=(const Scalar &lhs, const Scalar &rhs);
bool operator>(const Scalar &lhs, const Scalar &rhs);
bool operator>=(const Scalar &lhs, const Scalar &rhs);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Scalar &scalar);
+
} // namespace lldb_private
#endif // LLDB_UTILITY_SCALAR_H
diff --git a/include/lldb/Utility/SelectHelper.h b/include/lldb/Utility/SelectHelper.h
index f2dac7cf53daf..ec37f194d329b 100644
--- a/include/lldb/Utility/SelectHelper.h
+++ b/include/lldb/Utility/SelectHelper.h
@@ -1,9 +1,8 @@
//===-- SelectHelper.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/SharedCluster.h b/include/lldb/Utility/SharedCluster.h
index 61b9804ad3356..71bbb334cff38 100644
--- a/include/lldb/Utility/SharedCluster.h
+++ b/include/lldb/Utility/SharedCluster.h
@@ -1,9 +1,8 @@
//===------------------SharedCluster.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h
index 7eaa049f4d18b..e4ab3d27a69b7 100644
--- a/include/lldb/Utility/SharingPtr.h
+++ b/include/lldb/Utility/SharingPtr.h
@@ -1,9 +1,8 @@
//===---------------------SharingPtr.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,8 +35,8 @@ namespace lldb_private {
namespace imp {
class shared_count {
- shared_count(const shared_count &);
- shared_count &operator=(const shared_count &);
+ shared_count(const shared_count &) = delete;
+ shared_count &operator=(const shared_count &) = delete;
public:
explicit shared_count(long refs = 0) : shared_owners_(refs) {}
@@ -67,10 +66,8 @@ public:
private:
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 &);
+ shared_ptr_pointer(const shared_ptr_pointer &) = delete;
+ shared_ptr_pointer &operator=(const shared_ptr_pointer &) = delete;
};
template <class T> void shared_ptr_pointer<T>::on_zero_shared() {
@@ -456,8 +453,8 @@ protected:
friend class IntrusiveSharingPtr<T>;
private:
- ReferenceCountedBase(const ReferenceCountedBase &);
- ReferenceCountedBase &operator=(const ReferenceCountedBase &);
+ ReferenceCountedBase(const ReferenceCountedBase &) = delete;
+ ReferenceCountedBase &operator=(const ReferenceCountedBase &) = delete;
};
template <class T> void lldb_private::ReferenceCountedBase<T>::add_shared() {
diff --git a/include/lldb/Utility/State.h b/include/lldb/Utility/State.h
index 7b3c0f1c17ab3..9ff755f14f635 100644
--- a/include/lldb/Utility/State.h
+++ b/include/lldb/Utility/State.h
@@ -1,9 +1,8 @@
//===-- State.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,53 +17,47 @@
namespace lldb_private {
-//------------------------------------------------------------------
/// Converts a StateType to a C string.
///
-/// @param[in] state
+/// \param[in] state
/// The StateType object to convert.
///
-/// @return
+/// \return
/// A NULL terminated C string that describes \a state. The
/// returned string comes from constant string buffers and does
/// not need to be freed.
-//------------------------------------------------------------------
const char *StateAsCString(lldb::StateType state);
-//------------------------------------------------------------------
/// Check if a state represents a state where the process or thread
/// is running.
///
-/// @param[in] state
+/// \param[in] state
/// The StateType enumeration value
///
-/// @return
+/// \return
/// \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);
-//------------------------------------------------------------------
/// 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
/// yet. The \a must_exist argument tells us which of these cases is
/// desired.
///
-/// @param[in] state
+/// \param[in] state
/// The StateType enumeration value
///
-/// @param[in] must_exist
+/// \param[in] must_exist
/// A boolean that indicates the thread must also be alive
/// so states like unloaded or exited won't return true.
///
-/// @return
+/// \return
/// \b true if the state represents a process or thread state
/// 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.
-//------------------------------------------------------------------
bool StateIsStoppedState(lldb::StateType state, bool must_exist);
const char *GetPermissionsAsCString(uint32_t permissions);
diff --git a/include/lldb/Utility/Status.h b/include/lldb/Utility/Status.h
index 9395ea86090bc..ae730b90dffe5 100644
--- a/include/lldb/Utility/Status.h
+++ b/include/lldb/Utility/Status.h
@@ -1,9 +1,8 @@
//===-- Status.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,8 +26,7 @@ class raw_ostream;
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Status Status.h "lldb/Utility/Status.h" An error handling class.
+/// \class Status Status.h "lldb/Utility/Status.h" An error handling class.
///
/// This class is designed to be able to hold any error code that can be
/// encountered on a given platform. The errors are stored as a value of type
@@ -43,26 +41,21 @@ namespace lldb_private {
/// of themselves for printing results and error codes. The string value will
/// be fetched on demand and its string value will be cached until the error
/// is cleared of the value of the error changes.
-//----------------------------------------------------------------------
class Status {
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
+ /// \param[in] err
/// An error code.
///
- /// @param[in] type
+ /// \param[in] type
/// The type for \a err.
- //------------------------------------------------------------------
Status();
explicit Status(ValueType err,
@@ -73,16 +66,13 @@ public:
explicit Status(const char *format, ...)
__attribute__((format(printf, 2, 3)));
- Status(const Status &rhs);
- //------------------------------------------------------------------
/// Assignment operator.
///
- /// @param[in] err
+ /// \param[in] err
/// An error code.
///
- /// @return
+ /// \return
/// A const reference to this object.
- //------------------------------------------------------------------
const Status &operator=(const Status &rhs);
~Status();
@@ -92,7 +82,6 @@ public:
const Status &operator=(llvm::Error error);
llvm::Error ToError() const;
- //------------------------------------------------------------------
/// Get the error string associated with the current error.
//
/// Gets the error value as a NULL terminated C string. The error string
@@ -100,55 +89,44 @@ public:
/// 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
+ /// \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
+ /// \return
/// \b true if this object contains an error, \b false
/// otherwise.
- //------------------------------------------------------------------
bool Fail() const;
- //------------------------------------------------------------------
/// Access the error value.
///
- /// @return
+ /// \return
/// The error value.
- //------------------------------------------------------------------
ValueType GetError() const;
- //------------------------------------------------------------------
/// Access the error type.
///
- /// @return
+ /// \return
/// The error type enumeration value.
- //------------------------------------------------------------------
lldb::ErrorType GetType() const;
- //------------------------------------------------------------------
/// 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
+ /// \param[in] err
/// A mach error code.
- //------------------------------------------------------------------
void SetMachError(uint32_t err);
void SetExpressionError(lldb::ExpressionResults, const char *mssg);
@@ -156,37 +134,30 @@ public:
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
+ /// \param[in] err
/// A mach error code.
///
- /// @param[in] type
+ /// \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
/// Status::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 Status::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
@@ -196,17 +167,14 @@ public:
/// will remain until the error value is cleared or a new error value/type
/// is assigned.
///
- /// @param err_str
+ /// \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
+ /// \param format
/// A printf style format string
- //------------------------------------------------------------------
int SetErrorStringWithFormat(const char *format, ...)
__attribute__((format(printf, 2, 3)));
@@ -217,34 +185,28 @@ public:
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
+ /// \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
+ /// \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; ///< Status 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.
diff --git a/include/lldb/Utility/Stream.h b/include/lldb/Utility/Stream.h
index bd4283edf8a9e..b24d4e4571775 100644
--- a/include/lldb/Utility/Stream.h
+++ b/include/lldb/Utility/Stream.h
@@ -1,9 +1,8 @@
//===-- Stream.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,15 +23,11 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class Stream Stream.h "lldb/Utility/Stream.h"
+/// \class Stream Stream.h "lldb/Utility/Stream.h"
/// A stream class that can stream formatted output to a file.
-//----------------------------------------------------------------------
class Stream {
public:
- //------------------------------------------------------------------
/// \a m_flags bit values.
- //------------------------------------------------------------------
enum {
eBinary = (1 << 0) ///< Get and put data as binary instead of as the default
/// string mode.
@@ -40,11 +35,11 @@ public:
/// Utility class for counting the bytes that were written to a stream in a
/// certain time span.
- /// @example
+ /// \example
/// ByteDelta delta(*this);
/// WriteDataToStream("foo");
/// return *delta;
- /// @endcode
+ /// \endcode
class ByteDelta {
Stream *m_stream;
/// Bytes we have written so far when ByteDelta was created.
@@ -57,19 +52,15 @@ public:
size_t operator*() const { return m_stream->GetWrittenBytes() - m_start; }
};
- //------------------------------------------------------------------
/// 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();
// FIXME: Streams should not be copyable.
@@ -83,37 +74,29 @@ public:
return *this;
}
- //------------------------------------------------------------------
/// 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
+ /// \param[in] src
/// A buffer containing at least \a src_len bytes of data.
///
- /// @param[in] src_len
+ /// \param[in] src_len
/// A number of bytes to append to the stream.
///
- /// @return
+ /// \return
/// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
size_t Write(const void *src, size_t src_len) {
size_t appended_byte_count = WriteImpl(src, src_len);
m_bytes_written += appended_byte_count;
@@ -122,50 +105,42 @@ public:
size_t GetWrittenBytes() const { return m_bytes_written; }
- //------------------------------------------------------------------
// 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
+ /// \param[in] byte_order
/// The byte order value to use when extracting data.
///
- /// @return
+ /// \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
+ /// \param[in] format
/// A printf style format string.
///
- /// @param[in] ...
+ /// \param[in] ...
/// Any additional arguments needed for the printf format string.
///
- /// @return
+ /// \return
/// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
size_t PrintfAsRawHex8(const char *format, ...)
__attribute__((__format__(__printf__, 2, 3)));
- //------------------------------------------------------------------
/// Append an uint8_t value in the hexadecimal format to the stream.
///
- /// @param[in] uvalue
+ /// \param[in] uvalue
/// The value to append.
///
- /// @return
+ /// \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);
@@ -204,292 +179,242 @@ public:
lldb::ByteOrder src_byte_order = lldb::eByteOrderInvalid,
lldb::ByteOrder dst_byte_order = lldb::eByteOrderInvalid);
- size_t PutCStringAsRawHex8(const char *s);
+ size_t PutStringAsRawHex8(llvm::StringRef s);
- //------------------------------------------------------------------
/// Output a NULL terminated C string \a cstr to the stream \a s.
///
- /// @param[in] cstr
+ /// \param[in] cstr
/// A NULL terminated C string.
///
- /// @return
+ /// \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
+ /// \param[in] p
/// A void pointer.
///
- /// @return
+ /// \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
+ /// \param[in] ch
/// A printable character value.
///
- /// @return
+ /// \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
+ /// \param[in] uval
/// A uint8_t value.
///
- /// @return
+ /// \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
+ /// \param[in] uval
/// A uint16_t value.
///
- /// @return
+ /// \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
+ /// \param[in] uval
/// A uint32_t value.
///
- /// @return
+ /// \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
+ /// \param[in] uval
/// A uint64_t value.
///
- /// @return
+ /// \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
+ /// \param[in] sval
/// A int8_t value.
///
- /// @return
+ /// \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
+ /// \param[in] sval
/// A int16_t value.
///
- /// @return
+ /// \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
+ /// \param[in] sval
/// A int32_t value.
///
- /// @return
+ /// \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
+ /// \param[in] sval
/// A int64_t value.
///
- /// @return
+ /// \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
+ /// \param[in] addr
/// An address value.
///
- /// @param[in] addr_size
+ /// \param[in] addr_size
/// Size in bytes of the address, used for formatting.
///
- /// @param[in] prefix
+ /// \param[in] prefix
/// A prefix C string. If nullptr, no prefix will be output.
///
- /// @param[in] suffix
+ /// \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
+ /// \param[in] lo_addr
/// The start address of the address range.
///
- /// @param[in] hi_addr
+ /// \param[in] hi_addr
/// The end address of the address range.
///
- /// @param[in] addr_size
+ /// \param[in] addr_size
/// Size in bytes of the address, used for formatting.
///
- /// @param[in] prefix
+ /// \param[in] prefix
/// A prefix C string. If nullptr, no prefix will be output.
///
- /// @param[in] suffix
+ /// \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
+ /// \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
+ /// \return
/// The size of an address in bytes that is used when outputting
/// address and pointer values to the stream.
- //------------------------------------------------------------------
uint32_t GetAddressByteSize() const;
- //------------------------------------------------------------------
/// The flags accessor.
///
- /// @return
+ /// \return
/// A reference to the Flags member variable.
- //------------------------------------------------------------------
Flags &GetFlags();
- //------------------------------------------------------------------
/// The flags const accessor.
///
- /// @return
+ /// \return
/// A const reference to the Flags member variable.
- //------------------------------------------------------------------
const Flags &GetFlags() const;
- //------------------------------------------------------------------
//// The byte order accessor.
////
- //// @return
+ //// \return
//// The byte order.
- //------------------------------------------------------------------
lldb::ByteOrder GetByteOrder() const;
- //------------------------------------------------------------------
/// Get the current indentation level.
///
- /// @return
+ /// \return
/// The current indentation level as an integer.
- //------------------------------------------------------------------
int GetIndentLevel() 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
+ /// \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
+ /// \param[in] offset
/// The offset value.
///
- /// @param[in] format
+ /// \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
+ /// \param[in] format
/// A printf style format string.
///
- /// @param[in] ...
+ /// \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);
@@ -498,70 +423,56 @@ public:
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
+ /// \param[in] cstr
/// A NULL terminated C string value.
///
- /// @param[in] format
+ /// \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
+ /// \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
+ /// \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
+ /// \param[in] uval
/// A uint64_t value that was extracted as a SLEB128 value.
- //------------------------------------------------------------------
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
+ /// \param[in] uval
/// A uint64_t value that was extracted as a ULEB128 value.
- //------------------------------------------------------------------
size_t PutULEB128(uint64_t uval);
- //------------------------------------------------------------------
/// Returns a raw_ostream that forwards the data to this Stream object.
- //------------------------------------------------------------------
llvm::raw_ostream &AsRawOstream() {
return m_forwarder;
}
protected:
- //------------------------------------------------------------------
// Member variables
- //------------------------------------------------------------------
Flags m_flags; ///< Dump flags.
uint32_t m_addr_size; ///< Size of an address in bytes.
lldb::ByteOrder
@@ -571,28 +482,24 @@ protected:
void _PutHex8(uint8_t uvalue, bool add_prefix);
- //------------------------------------------------------------------
/// Output character bytes to the stream.
///
/// Appends \a src_len characters from the buffer \a src to the stream.
///
- /// @param[in] src
+ /// \param[in] src
/// A buffer containing at least \a src_len bytes of data.
///
- /// @param[in] src_len
+ /// \param[in] src_len
/// A number of bytes to append to the stream.
///
- /// @return
+ /// \return
/// The number of bytes that were appended to the stream.
- //------------------------------------------------------------------
virtual size_t WriteImpl(const void *src, size_t src_len) = 0;
- //----------------------------------------------------------------------
- /// @class RawOstreamForward Stream.h "lldb/Utility/Stream.h"
+ /// \class RawOstreamForward Stream.h "lldb/Utility/Stream.h"
/// This is a wrapper class that exposes a raw_ostream interface that just
/// forwards to an LLDB stream, allowing to reuse LLVM algorithms that take
/// a raw_ostream within the LLDB code base.
- //----------------------------------------------------------------------
class RawOstreamForward : public llvm::raw_ostream {
// Note: This stream must *not* maintain its own buffer, but instead
// directly write everything to the internal Stream class. Without this,
diff --git a/include/lldb/Utility/StreamCallback.h b/include/lldb/Utility/StreamCallback.h
index 63a86eeece731..6dbee67ecca27 100644
--- a/include/lldb/Utility/StreamCallback.h
+++ b/include/lldb/Utility/StreamCallback.h
@@ -1,9 +1,8 @@
//===-- StreamCallback.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/StreamGDBRemote.h b/include/lldb/Utility/StreamGDBRemote.h
index dfc4a39de7912..dd0ea31126d93 100644
--- a/include/lldb/Utility/StreamGDBRemote.h
+++ b/include/lldb/Utility/StreamGDBRemote.h
@@ -1,9 +1,8 @@
//===-- StreamGDBRemote.h ----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,18 +26,16 @@ public:
~StreamGDBRemote() override;
- //------------------------------------------------------------------
/// Output a block of data to the stream performing GDB-remote escaping.
///
- /// @param[in] s
+ /// \param[in] s
/// A block of data.
///
- /// @param[in] src_len
+ /// \param[in] src_len
/// The amount of data to write.
///
- /// @return
+ /// \return
/// Number of bytes written.
- //------------------------------------------------------------------
// TODO: Convert this function to take ArrayRef<uint8_t>
int PutEscapedBytes(const void *s, size_t src_len);
};
diff --git a/include/lldb/Utility/StreamString.h b/include/lldb/Utility/StreamString.h
index dd2f9f67466e0..581e102d4e80d 100644
--- a/include/lldb/Utility/StreamString.h
+++ b/include/lldb/Utility/StreamString.h
@@ -1,9 +1,8 @@
//===-- StreamString.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/StreamTee.h b/include/lldb/Utility/StreamTee.h
index 4f8e6ab1f0029..92e94d4494f6e 100644
--- a/include/lldb/Utility/StreamTee.h
+++ b/include/lldb/Utility/StreamTee.h
@@ -1,9 +1,8 @@
//===-- StreamTee.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,8 +49,11 @@ public:
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);
+ std::lock(m_streams_mutex, rhs.m_streams_mutex);
+ std::lock_guard<std::recursive_mutex> lhs_locker(m_streams_mutex,
+ std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_locker(rhs.m_streams_mutex,
+ std::adopt_lock);
m_streams = rhs.m_streams;
}
return *this;
diff --git a/include/lldb/Utility/StringExtractor.h b/include/lldb/Utility/StringExtractor.h
index bc24c153bae68..f20ec92199bb9 100644
--- a/include/lldb/Utility/StringExtractor.h
+++ b/include/lldb/Utility/StringExtractor.h
@@ -1,9 +1,8 @@
//===-- StringExtractor.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,20 +19,12 @@
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;
@@ -122,9 +113,7 @@ protected:
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
diff --git a/include/lldb/Utility/StringExtractorGDBRemote.h b/include/lldb/Utility/StringExtractorGDBRemote.h
index 8c2eca898e64f..cbf6e0c29e8ee 100644
--- a/include/lldb/Utility/StringExtractorGDBRemote.h
+++ b/include/lldb/Utility/StringExtractorGDBRemote.h
@@ -1,9 +1,8 @@
//===-- StringExtractorGDBRemote.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,7 @@ public:
StringExtractorGDBRemote(const StringExtractorGDBRemote &rhs)
: StringExtractor(rhs), m_validator(rhs.m_validator) {}
- virtual ~StringExtractorGDBRemote() {}
+ ~StringExtractorGDBRemote() override {}
bool ValidateResponse() const;
@@ -129,7 +128,7 @@ public:
eServerPacketType_qVAttachOrWaitSupported,
eServerPacketType_qWatchpointSupportInfo,
eServerPacketType_qWatchpointSupportInfoSupported,
- eServerPacketType_qXfer_auxv_read,
+ eServerPacketType_qXfer,
eServerPacketType_jSignalsInfo,
eServerPacketType_jModulesInfo,
diff --git a/include/lldb/Utility/StringLexer.h b/include/lldb/Utility/StringLexer.h
index 32cfa4e3f6f2a..d9806c1b37d79 100644
--- a/include/lldb/Utility/StringLexer.h
+++ b/include/lldb/Utility/StringLexer.h
@@ -1,9 +1,8 @@
//===--------------------- StringLexer.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,8 +24,6 @@ public:
StringLexer(std::string s);
- StringLexer(const StringLexer &rhs);
-
// These APIs are not bounds-checked. Use HasAtLeast() if you're not sure.
Character Peek();
diff --git a/include/lldb/Utility/StringList.h b/include/lldb/Utility/StringList.h
index c080230249ddf..68c1f87510f63 100644
--- a/include/lldb/Utility/StringList.h
+++ b/include/lldb/Utility/StringList.h
@@ -1,9 +1,8 @@
//===-- StringList.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,8 +17,6 @@
namespace lldb_private {
class Log;
-}
-namespace lldb_private {
class Stream;
}
diff --git a/include/lldb/Utility/StructuredData.h b/include/lldb/Utility/StructuredData.h
index 100b4fa98ae1d..75eb2f7b7291e 100644
--- a/include/lldb/Utility/StructuredData.h
+++ b/include/lldb/Utility/StructuredData.h
@@ -1,9 +1,8 @@
//===-- StructuredData.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,15 +28,12 @@
namespace lldb_private {
class Status;
-}
-namespace lldb_private {
class Stream;
}
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class StructuredData StructuredData.h "lldb/Utility/StructuredData.h"
+/// \class StructuredData StructuredData.h "lldb/Utility/StructuredData.h"
/// A class which can hold structured data
///
/// The StructuredData class is designed to hold the data from a JSON or plist
@@ -49,7 +45,6 @@ namespace lldb_private {
/// 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.
-//----------------------------------------------------------------------
class StructuredData {
public:
diff --git a/include/lldb/Utility/TildeExpressionResolver.h b/include/lldb/Utility/TildeExpressionResolver.h
index ae6b4073f6aa6..196fdfcf9ab46 100644
--- a/include/lldb/Utility/TildeExpressionResolver.h
+++ b/include/lldb/Utility/TildeExpressionResolver.h
@@ -1,9 +1,8 @@
//===--------------------- TildeExpressionResolver.h ------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/Timeout.h b/include/lldb/Utility/Timeout.h
index ecb33b346e96a..202b747fd4804 100644
--- a/include/lldb/Utility/Timeout.h
+++ b/include/lldb/Utility/Timeout.h
@@ -1,9 +1,8 @@
//===-- Timeout.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/Timer.h b/include/lldb/Utility/Timer.h
index 7c41c62572543..ad9421a75b15f 100644
--- a/include/lldb/Utility/Timer.h
+++ b/include/lldb/Utility/Timer.h
@@ -1,9 +1,8 @@
//===-- Timer.h -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,10 +17,8 @@
namespace lldb_private {
class Stream;
-//----------------------------------------------------------------------
-/// @class Timer Timer.h "lldb/Utility/Timer.h"
+/// \class Timer Timer.h "lldb/Utility/Timer.h"
/// A timer class that simplifies common timing metrics.
-//----------------------------------------------------------------------
class Timer {
public:
@@ -33,20 +30,18 @@ public:
friend class Timer;
const char *m_name;
std::atomic<uint64_t> m_nanos;
+ std::atomic<uint64_t> m_nanos_total;
+ std::atomic<uint64_t> m_count;
std::atomic<Category *> m_next;
DISALLOW_COPY_AND_ASSIGN(Category);
};
- //--------------------------------------------------------------
/// Default constructor.
- //--------------------------------------------------------------
Timer(Category &category, const char *format, ...)
__attribute__((format(printf, 3, 4)));
- //--------------------------------------------------------------
/// Destructor
- //--------------------------------------------------------------
~Timer();
void Dump();
diff --git a/include/lldb/Utility/TraceOptions.h b/include/lldb/Utility/TraceOptions.h
index 325ff74e6f556..d5e21ccd8ba35 100644
--- a/include/lldb/Utility/TraceOptions.h
+++ b/include/lldb/Utility/TraceOptions.h
@@ -1,9 +1,8 @@
//===-- TraceOptions.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/UUID.h b/include/lldb/Utility/UUID.h
index e082db572e463..dbeb9db611b25 100644
--- a/include/lldb/Utility/UUID.h
+++ b/include/lldb/Utility/UUID.h
@@ -1,9 +1,8 @@
//===-- UUID.h --------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -68,26 +67,29 @@ public:
std::string GetAsString(llvm::StringRef separator = "-") const;
size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16);
+
+ // Same as SetFromStringRef, but if the resultant UUID is all 0 bytes, set the
+ // UUID to invalid.
+ size_t SetFromOptionalStringRef(llvm::StringRef 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
+ /// \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
+ /// \param[in] uuid_bytes
/// A buffer of bytes that will contain a full or patially
/// decoded UUID.
///
- /// @return
+ /// \return
/// The original string, with all decoded bytes removed.
- //------------------------------------------------------------------
static llvm::StringRef
DecodeUUIDBytesFromString(llvm::StringRef str,
llvm::SmallVectorImpl<uint8_t> &uuid_bytes,
diff --git a/include/lldb/Utility/UriParser.h b/include/lldb/Utility/UriParser.h
index db0049d9684ca..4a3f01230e1af 100644
--- a/include/lldb/Utility/UriParser.h
+++ b/include/lldb/Utility/UriParser.h
@@ -1,9 +1,8 @@
//===-- UriParser.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/UserID.h b/include/lldb/Utility/UserID.h
index 8560274bdeac5..2dc5cdb23d0e9 100644
--- a/include/lldb/Utility/UserID.h
+++ b/include/lldb/Utility/UserID.h
@@ -1,9 +1,8 @@
//===-- UserID.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,14 +11,11 @@
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
-namespace lldb_private {
-class Stream;
-}
namespace lldb_private {
+class Stream;
-//----------------------------------------------------------------------
-/// @class UserID UserID.h "lldb/Core/UserID.h"
+/// \class UserID UserID.h "lldb/Core/UserID.h"
/// A mix in class that contains a generic user ID.
///
/// UserID is designed as a mix in class that can contain an integer based
@@ -32,42 +28,30 @@ namespace lldb_private {
/// Symbol table entries can use this to store the original symbol table
/// 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
+ /// \return
/// The user ID.
- //------------------------------------------------------------------
lldb::user_id_t GetID() const { return m_uid; }
- //------------------------------------------------------------------
/// Set accessor for the user ID.
///
- /// @param[in] uid
+ /// \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:
@@ -75,30 +59,21 @@ struct UserID {
/// 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.
};
@@ -110,9 +85,7 @@ 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);
} // namespace lldb_private
diff --git a/include/lldb/Utility/UserIDResolver.h b/include/lldb/Utility/UserIDResolver.h
new file mode 100644
index 0000000000000..bca82a11b6609
--- /dev/null
+++ b/include/lldb/Utility/UserIDResolver.h
@@ -0,0 +1,56 @@
+//===-- UserIDResolver.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_UTILITY_USERIDRESOLVER_H
+#define LLDB_UTILITY_USERIDRESOLVER_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringRef.h"
+#include <mutex>
+
+namespace lldb_private {
+
+/// An abstract interface for things that know how to map numeric user/group IDs
+/// into names. It caches the resolved names to avoid repeating expensive
+/// queries. The cache is internally protected by a mutex, so concurrent queries
+/// are safe.
+class UserIDResolver {
+public:
+ typedef uint32_t id_t;
+ virtual ~UserIDResolver(); // anchor
+
+ llvm::Optional<llvm::StringRef> GetUserName(id_t uid) {
+ return Get(uid, m_uid_cache, &UserIDResolver::DoGetUserName);
+ }
+ llvm::Optional<llvm::StringRef> GetGroupName(id_t gid) {
+ return Get(gid, m_gid_cache, &UserIDResolver::DoGetGroupName);
+ }
+
+ /// Returns a resolver which returns a failure value for each query. Useful as
+ /// a fallback value for the case when we know all lookups will fail.
+ static UserIDResolver &GetNoopResolver();
+
+protected:
+ virtual llvm::Optional<std::string> DoGetUserName(id_t uid) = 0;
+ virtual llvm::Optional<std::string> DoGetGroupName(id_t gid) = 0;
+
+private:
+ using Map = llvm::DenseMap<id_t, llvm::Optional<std::string>>;
+
+ llvm::Optional<llvm::StringRef>
+ Get(id_t id, Map &cache,
+ llvm::Optional<std::string> (UserIDResolver::*do_get)(id_t));
+
+ std::mutex m_mutex;
+ Map m_uid_cache;
+ Map m_gid_cache;
+};
+
+} // namespace lldb_private
+
+#endif // #ifndef LLDB_HOST_USERIDRESOLVER_H
diff --git a/include/lldb/Utility/VASPrintf.h b/include/lldb/Utility/VASPrintf.h
index 6e2404ecef93b..582645fd22929 100644
--- a/include/lldb/Utility/VASPrintf.h
+++ b/include/lldb/Utility/VASPrintf.h
@@ -1,9 +1,8 @@
//===-- VASPrintf.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/Utility/VMRange.h b/include/lldb/Utility/VMRange.h
index a70b0cb6118ce..9c2f9d0909191 100644
--- a/include/lldb/Utility/VMRange.h
+++ b/include/lldb/Utility/VMRange.h
@@ -1,9 +1,8 @@
//===-- VMRange.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,10 +21,8 @@ class Stream;
namespace lldb_private {
-//----------------------------------------------------------------------
// A vm address range. These can represent offsets ranges or actual
// addresses.
-//----------------------------------------------------------------------
class VMRange {
public:
typedef std::vector<VMRange> collection;
diff --git a/include/lldb/lldb-defines.h b/include/lldb/lldb-defines.h
index 8a54b4c44364b..b87964403f7e2 100644
--- a/include/lldb/lldb-defines.h
+++ b/include/lldb/lldb-defines.h
@@ -1,9 +1,8 @@
//===-- lldb-defines.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,31 +35,23 @@
#define UINT64_MAX 18446744073709551615ULL
#endif
-//----------------------------------------------------------------------
// LLDB version
//
// A build script phase can modify this version number if needed.
-//----------------------------------------------------------------------
//#define LLDB_VERSION
//#define LLDB_REVISION
//#define LLDB_VERSION_STRING
-//----------------------------------------------------------------------
// LLDB defines
-//----------------------------------------------------------------------
#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)
-//----------------------------------------------------------------------
// 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)
@@ -68,9 +59,7 @@
#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
@@ -92,9 +81,7 @@
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
@@ -110,17 +97,13 @@
#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)
-//----------------------------------------------------------------------
/// 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
@@ -152,11 +135,9 @@
#if defined(__cplusplus)
-//----------------------------------------------------------------------
-/// @def DISALLOW_COPY_AND_ASSIGN(TypeName)
+/// \def DISALLOW_COPY_AND_ASSIGN(TypeName)
/// Macro definition for easily disallowing copy constructor and
/// assignment operators in C++ classes.
-//----------------------------------------------------------------------
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName &) = delete; \
const TypeName &operator=(const TypeName &) = delete
diff --git a/include/lldb/lldb-enumerations.h b/include/lldb/lldb-enumerations.h
index 1c4d6f509a2a9..f9830c04bc39f 100644
--- a/include/lldb/lldb-enumerations.h
+++ b/include/lldb/lldb-enumerations.h
@@ -1,9 +1,8 @@
//===-- lldb-enumerations.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -70,9 +69,7 @@
namespace lldb {
-//----------------------------------------------------------------------
// Process and Thread States
-//----------------------------------------------------------------------
enum StateType {
eStateInvalid = 0,
eStateUnloaded, ///< Process is object is valid, but not currently loaded
@@ -96,9 +93,7 @@ enum StateType {
kLastStateType = eStateSuspended
};
-//----------------------------------------------------------------------
// Launch Flags
-//----------------------------------------------------------------------
FLAGS_ENUM(LaunchFlags){
eLaunchFlagNone = 0u,
eLaunchFlagExec = (1u << 0), ///< Exec when launching and turn the calling
@@ -131,14 +126,10 @@ FLAGS_ENUM(LaunchFlags){
eLaunchFlagCloseTTYOnExit = (1u << 11), ///< Close the open TTY on exit
};
-//----------------------------------------------------------------------
// Thread Run Modes
-//----------------------------------------------------------------------
enum RunMode { eOnlyThisThread, eAllThreads, eOnlyDuringStepping };
-//----------------------------------------------------------------------
// Byte ordering definitions
-//----------------------------------------------------------------------
enum ByteOrder {
eByteOrderInvalid = 0,
eByteOrderBig = 1,
@@ -146,9 +137,7 @@ enum ByteOrder {
eByteOrderLittle = 4
};
-//----------------------------------------------------------------------
// Register encoding definitions
-//----------------------------------------------------------------------
enum Encoding {
eEncodingInvalid = 0,
eEncodingUint, // unsigned integer
@@ -157,9 +146,7 @@ enum Encoding {
eEncodingVector // vector registers
};
-//----------------------------------------------------------------------
// Display format definitions
-//----------------------------------------------------------------------
enum Format {
eFormatDefault = 0,
eFormatInvalid = 0,
@@ -209,10 +196,8 @@ enum Format {
kNumFormats
};
-//----------------------------------------------------------------------
// Description levels for "void GetDescription(Stream *, DescriptionLevel)"
// calls
-//----------------------------------------------------------------------
enum DescriptionLevel {
eDescriptionLevelBrief = 0,
eDescriptionLevelFull,
@@ -221,9 +206,7 @@ enum DescriptionLevel {
kNumDescriptionLevels
};
-//----------------------------------------------------------------------
// Script interpreter types
-//----------------------------------------------------------------------
enum ScriptLanguage {
eScriptLanguageNone,
eScriptLanguagePython,
@@ -231,11 +214,9 @@ enum ScriptLanguage {
eScriptLanguageUnknown
};
-//----------------------------------------------------------------------
// 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
@@ -247,9 +228,7 @@ enum RegisterKind {
kNumRegisterKinds
};
-//----------------------------------------------------------------------
// Thread stop reasons
-//----------------------------------------------------------------------
enum StopReason {
eStopReasonInvalid = 0,
eStopReasonNone,
@@ -264,9 +243,7 @@ enum StopReason {
eStopReasonInstrumentation
};
-//----------------------------------------------------------------------
// Command Return Status Types
-//----------------------------------------------------------------------
enum ReturnStatus {
eReturnStatusInvalid,
eReturnStatusSuccessFinishNoResult,
@@ -278,9 +255,7 @@ enum ReturnStatus {
eReturnStatusQuit
};
-//----------------------------------------------------------------------
// The results of expression evaluation:
-//----------------------------------------------------------------------
enum ExpressionResults {
eExpressionCompleted = 0,
eExpressionSetupError,
@@ -304,9 +279,7 @@ enum SearchDepth {
kLastSearchDepthKind = eSearchDepthAddress
};
-//----------------------------------------------------------------------
// Connection Status Types
-//----------------------------------------------------------------------
enum ConnectionStatus {
eConnectionStatusSuccess, // Success
eConnectionStatusEndOfFile, // End-of-file encountered
@@ -339,9 +312,7 @@ enum ValueType {
eValueTypeVariableThreadLocal = 8 // thread local storage variable
};
-//----------------------------------------------------------------------
// Token size/granularities for Input Readers
-//----------------------------------------------------------------------
enum InputReaderGranularity {
eInputReaderGranularityInvalid = 0,
@@ -351,7 +322,6 @@ enum InputReaderGranularity {
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
@@ -360,7 +330,6 @@ enum InputReaderGranularity {
/// 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
@@ -447,14 +416,12 @@ FLAGS_ENUM(WatchpointEventType){
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.
@@ -624,9 +591,9 @@ enum CommandArgumentType {
// enumeration!!
};
-//----------------------------------------------------------------------
// Symbol types
-//----------------------------------------------------------------------
+// Symbol holds the SymbolType in a 6-bit field (m_type), so if you get over 63
+// entries you will have to resize that field.
enum SymbolType {
eSymbolTypeAny = 0,
eSymbolTypeInvalid = 0,
@@ -719,6 +686,7 @@ enum SectionType {
eSectionTypeDWARFDebugInfoDwo,
eSectionTypeDWARFDebugStrDwo,
eSectionTypeDWARFDebugStrOffsetsDwo,
+ eSectionTypeDWARFDebugTypesDwo,
};
FLAGS_ENUM(EmulateInstructionOptions){
@@ -748,9 +716,7 @@ FLAGS_ENUM(FunctionNameType){
};
LLDB_MARK_AS_BITMASK_ENUM(FunctionNameType)
-//----------------------------------------------------------------------
// Basic types enumeration for the public API SBType::GetBasicType()
-//----------------------------------------------------------------------
enum BasicType {
eBasicTypeInvalid = 0,
eBasicTypeVoid = 1,
@@ -835,10 +801,8 @@ enum TemplateArgumentKind {
eTemplateArgumentKindNullPtr,
};
-//----------------------------------------------------------------------
// 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),
@@ -852,7 +816,6 @@ FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u),
eTypeOptionFrontEndWantsDereference = (1u << 9)
};
-//----------------------------------------------------------------------
// 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
@@ -864,7 +827,6 @@ FLAGS_ENUM(TypeOptions){eTypeOptionNone = (0u),
// 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,
@@ -874,12 +836,10 @@ enum FrameComparison {
eFrameCompareOlder
};
-//----------------------------------------------------------------------
// 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),
@@ -935,35 +895,29 @@ FLAGS_ENUM(FilePermissions){
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,
@@ -971,11 +925,9 @@ enum ExpressionEvaluationPhase {
eExpressionEvaluationComplete
};
-//----------------------------------------------------------------------
// Watchpoint Kind
// Indicates what types of events cause the watchpoint to fire. Used by Native
// *Protocol-related classes.
-//----------------------------------------------------------------------
FLAGS_ENUM(WatchpointKind){eWatchpointKindWrite = (1u << 0),
eWatchpointKindRead = (1u << 1)};
@@ -988,11 +940,9 @@ enum GdbSignal {
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
@@ -1009,10 +959,8 @@ enum PathType {
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
@@ -1024,14 +972,10 @@ enum MemberFunctionKind {
// 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),
@@ -1047,7 +991,6 @@ FLAGS_ENUM(TypeFlags){
eTypeInstanceIsPointer = (1u << 22)};
FLAGS_ENUM(CommandFlags){
- //----------------------------------------------------------------------
// eCommandRequiresTarget
//
// Ensures a valid target is contained in m_exe_ctx prior to executing the
@@ -1055,9 +998,7 @@ FLAGS_ENUM(CommandFlags){
// 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
@@ -1066,9 +1007,7 @@ FLAGS_ENUM(CommandFlags){
// 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
@@ -1076,9 +1015,7 @@ FLAGS_ENUM(CommandFlags){
// 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
@@ -1086,9 +1023,7 @@ FLAGS_ENUM(CommandFlags){
// 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
@@ -1098,34 +1033,25 @@ FLAGS_ENUM(CommandFlags){
// 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
diff --git a/include/lldb/lldb-forward.h b/include/lldb/lldb-forward.h
index 92aa5bb611c3c..0cdaf1cf9bf81 100644
--- a/include/lldb/lldb-forward.h
+++ b/include/lldb/lldb-forward.h
@@ -1,9 +1,8 @@
//===-- lldb-forward.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,14 +13,11 @@
#include "lldb/Utility/SharingPtr.h"
-//----------------------------------------------------------------------
// lldb forward declarations
-//----------------------------------------------------------------------
namespace lldb_private {
class ABI;
class Address;
-class AddressImpl;
class AddressRange;
class AddressResolver;
class ArchSpec;
@@ -41,13 +37,13 @@ class BreakpointLocationList;
class BreakpointName;
class BreakpointOptionGroup;
class BreakpointOptions;
+class BreakpointPrecondition;
class BreakpointResolver;
class BreakpointSite;
class BreakpointSiteList;
class BroadcastEventSpec;
class Broadcaster;
class BroadcasterManager;
-class CPPLanguageRuntime;
class ClangASTContext;
class ClangASTImporter;
class ClangASTMetadata;
@@ -55,7 +51,6 @@ class ClangASTSource;
class ClangExpressionDeclMap;
class ClangExpressionParser;
class ClangExpressionVariable;
-class ClangExpressionVariables;
class ClangModulesDeclVendor;
class ClangPersistentVariables;
class CommandInterpreter;
@@ -70,7 +65,6 @@ class CompilerDecl;
class CompilerDeclContext;
class CompilerType;
class CompileUnit;
-class Condition;
class Connection;
class ConnectionFileDescriptor;
class ConstString;
@@ -97,7 +91,6 @@ class EventData;
class EventDataStructuredData;
class ExecutionContext;
class ExecutionContextRef;
-class ExecutionContextRefLocker;
class ExecutionContextScope;
class Expression;
class ExpressionVariable;
@@ -137,10 +130,7 @@ class Module;
class ModuleList;
class ModuleSpec;
class ModuleSpecList;
-class Mutex;
struct NameSearchContext;
-class ObjCLanguageRuntime;
-class ObjCRuntimeSyntheticProvider;
class ObjectContainer;
class OptionGroup;
class OptionGroupOptions;
@@ -169,7 +159,6 @@ class OptionValueSInt64;
class OptionValueString;
class OptionValueUInt64;
class OptionValueUUID;
-class NamedOption;
class PathMappingList;
class FunctionCaller;
class PersistentExpressionState;
@@ -187,8 +176,6 @@ struct PropertyDefinition;
class RecognizedStackFrame;
class RegisterCheckpoint;
class RegisterContext;
-class RegisterLocation;
-class RegisterLocationList;
class RegisterValue;
class RegularExpression;
class REPL;
@@ -199,7 +186,6 @@ class ScriptInterpreterLocker;
struct ScriptSummaryFormat;
class SearchFilter;
class Section;
-class SectionImpl;
class SectionList;
class SectionLoadHistory;
class SectionLoadList;
@@ -207,7 +193,6 @@ class Settings;
class SourceManager;
class SourceManagerImpl;
class StackFrame;
-class StackFrameImpl;
class StackFrameList;
class StackFrameRecognizer;
class StackFrameRecognizerManager;
@@ -240,9 +225,7 @@ class SyntheticChildren;
class SyntheticChildrenFrontEnd;
class TypeFilterImpl;
class TypeSystem;
-#ifndef LLDB_DISABLE_PYTHON
class ScriptedSyntheticChildren;
-#endif
class Queue;
class QueueItem;
class QueueImpl;
@@ -276,7 +259,6 @@ class TypeEnumMemberImpl;
class TypeEnumMemberListImpl;
class TypeFormatImpl;
class TypeNameSpecifierImpl;
-class TypePair;
class TypeValidatorImpl;
class UUID;
class UnixSignals;
@@ -305,9 +287,7 @@ struct LineEntry;
} // namespace lldb_private
-//----------------------------------------------------------------------
// lldb forward declarations
-//----------------------------------------------------------------------
namespace lldb {
typedef std::shared_ptr<lldb_private::ABI> ABISP;
@@ -319,6 +299,7 @@ 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::BreakpointPrecondition> BreakpointPreconditionSP;
typedef std::shared_ptr<lldb_private::BreakpointResolver> BreakpointResolverSP;
typedef std::shared_ptr<lldb_private::Broadcaster> BroadcasterSP;
typedef std::shared_ptr<lldb_private::BroadcasterManager> BroadcasterManagerSP;
@@ -479,10 +460,8 @@ typedef std::shared_ptr<lldb_private::TypeNameSpecifierImpl>
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;
-#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;
@@ -498,9 +477,7 @@ typedef std::shared_ptr<lldb_private::Watchpoint> WatchpointSP;
} // namespace lldb
-//----------------------------------------------------------------------
// llvm forward declarations
-//----------------------------------------------------------------------
namespace llvm {
struct ItaniumPartialDemangler;
diff --git a/include/lldb/lldb-private-defines.h b/include/lldb/lldb-private-defines.h
index 9b6594422e827..737d9ef2434e1 100644
--- a/include/lldb/lldb-private-defines.h
+++ b/include/lldb/lldb-private-defines.h
@@ -1,9 +1,8 @@
//===-- lldb-private-defines.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/lldb-private-enumerations.h b/include/lldb/lldb-private-enumerations.h
index c25f285c97133..3d8b360fb301e 100644
--- a/include/lldb/lldb-private-enumerations.h
+++ b/include/lldb/lldb-private-enumerations.h
@@ -1,9 +1,8 @@
//===-- lldb-private-enumerations.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,10 +15,8 @@
namespace lldb_private {
-//----------------------------------------------------------------------
// Thread Step Types
-//----------------------------------------------------------------------
-typedef enum StepType {
+enum StepType {
eStepTypeNone,
eStepTypeTrace, ///< Single step one instruction.
eStepTypeTraceOver, ///< Single step one instruction, stepping over.
@@ -27,22 +24,19 @@ typedef enum StepType {
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 {
+enum AddressType {
eAddressTypeInvalid = 0,
eAddressTypeFile, ///< Address is an address as found in an object or symbol
- ///file
+ /// file
eAddressTypeLoad, ///< Address is an address as in the current target inferior
- ///process
+ /// process
eAddressTypeHost ///< Address is an address in the process that is running
- ///this code
-} AddressType;
+ /// this code
+};
-//----------------------------------------------------------------------
// Address Class
//
// A way of classifying an address used for disassembling and setting
@@ -51,7 +45,6 @@ typedef enum AddressType {
// 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 class AddressClass {
eInvalid,
eUnknown,
@@ -62,23 +55,19 @@ enum class AddressClass {
eRuntime
};
-//----------------------------------------------------------------------
// Votes - Need a tri-state, yes, no, no opinion...
-//----------------------------------------------------------------------
-typedef enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 } Vote;
+enum Vote { eVoteNo = -1, eVoteNoOpinion = 0, eVoteYes = 1 };
-typedef enum ArchitectureType {
+enum ArchitectureType {
eArchTypeInvalid,
eArchTypeMachO,
eArchTypeELF,
eArchTypeCOFF,
kNumArchTypes
-} ArchitectureType;
+};
-//----------------------------------------------------------------------
/// Settable state variable types.
///
-//----------------------------------------------------------------------
// typedef enum SettableVariableType
//{
@@ -91,7 +80,7 @@ typedef enum ArchitectureType {
// eSetVarTypeNone
//} SettableVariableType;
-typedef enum VarSetOperationType {
+enum VarSetOperationType {
eVarSetOperationReplace,
eVarSetOperationInsertBefore,
eVarSetOperationInsertAfter,
@@ -100,9 +89,9 @@ typedef enum VarSetOperationType {
eVarSetOperationClear,
eVarSetOperationAssign,
eVarSetOperationInvalid
-} VarSetOperationType;
+};
-typedef enum ArgumentRepetitionType {
+enum ArgumentRepetitionType {
eArgRepeatPlain, // Exactly one occurrence
eArgRepeatOptional, // At most one occurrence, but it's optional
eArgRepeatPlus, // One or more occurrences
@@ -116,29 +105,17 @@ typedef enum ArgumentRepetitionType {
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
-} SortOrder;
+enum SortOrder { eSortOrderNone, eSortOrderByAddress, eSortOrderByName };
-//----------------------------------------------------------------------
// LazyBool is for boolean values that need to be calculated lazily. Values
// start off set to eLazyBoolCalculate, and then they can be calculated once
// and set to eLazyBoolNo or eLazyBoolYes.
-//----------------------------------------------------------------------
-typedef enum LazyBool {
- eLazyBoolCalculate = -1,
- eLazyBoolNo = 0,
- eLazyBoolYes = 1
-} LazyBool;
+enum LazyBool { eLazyBoolCalculate = -1, eLazyBoolNo = 0, eLazyBoolYes = 1 };
-//------------------------------------------------------------------
/// Instruction types
-//------------------------------------------------------------------
-typedef enum InstructionType {
+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
@@ -147,12 +124,10 @@ typedef enum InstructionType {
// counter/instruction pointer
eInstructionTypeAll // All instructions of any kind
-} InstructionType;
+};
-//------------------------------------------------------------------
/// Format category entry types
-//------------------------------------------------------------------
-typedef enum FormatCategoryItem {
+enum FormatCategoryItem {
eFormatCategoryItemSummary = 0x0001,
eFormatCategoryItemRegexSummary = 0x0002,
eFormatCategoryItemFilter = 0x0004,
@@ -163,22 +138,18 @@ typedef enum FormatCategoryItem {
eFormatCategoryItemRegexValue = 0x0080,
eFormatCategoryItemValidator = 0x0100,
eFormatCategoryItemRegexValidator = 0x0200
-} FormatCategoryItem;
+};
-//------------------------------------------------------------------
/// Expression execution policies
-//------------------------------------------------------------------
-typedef enum {
+enum ExecutionPolicy {
eExecutionPolicyOnlyWhenNeeded,
eExecutionPolicyNever,
eExecutionPolicyAlways,
eExecutionPolicyTopLevel // used for top-level code
-} ExecutionPolicy;
+};
-//----------------------------------------------------------------------
// Ways that the FormatManager picks a particular format for a type
-//----------------------------------------------------------------------
-typedef enum FormatterChoiceCriterion {
+enum FormatterChoiceCriterion {
eFormatterChoiceCriterionDirectChoice = 0x00000000,
eFormatterChoiceCriterionStrippedPointerReference = 0x00000001,
eFormatterChoiceCriterionNavigatedTypedefs = 0x00000002,
@@ -187,41 +158,33 @@ typedef enum FormatterChoiceCriterion {
eFormatterChoiceCriterionLanguagePlugin = 0x00000008,
eFormatterChoiceCriterionStrippedBitField = 0x00000010,
eFormatterChoiceCriterionWentToStaticValue = 0x00000020
-} FormatterChoiceCriterion;
+};
-//----------------------------------------------------------------------
// Synchronicity behavior of scripted commands
-//----------------------------------------------------------------------
-typedef enum ScriptedCommandSynchronicity {
+enum ScriptedCommandSynchronicity {
eScriptedCommandSynchronicitySynchronous,
eScriptedCommandSynchronicityAsynchronous,
eScriptedCommandSynchronicityCurrentValue // use whatever the current
// synchronicity is
-} ScriptedCommandSynchronicity;
+};
-//----------------------------------------------------------------------
// Verbosity mode of "po" output
-//----------------------------------------------------------------------
-typedef enum LanguageRuntimeDescriptionDisplayVerbosity {
+enum LanguageRuntimeDescriptionDisplayVerbosity {
eLanguageRuntimeDescriptionDisplayVerbosityCompact, // only print the
// description string, if
// any
eLanguageRuntimeDescriptionDisplayVerbosityFull, // print the full-blown
// output
-} LanguageRuntimeDescriptionDisplayVerbosity;
+};
-//----------------------------------------------------------------------
// Loading modules from memory
-//----------------------------------------------------------------------
-typedef enum MemoryModuleLoadLevel {
+enum MemoryModuleLoadLevel {
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
@@ -231,14 +194,10 @@ enum class LineStatus {
Done // Lines are complete
};
-//----------------------------------------------------------------------
// Boolean result of running a Type Validator
-//----------------------------------------------------------------------
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,
@@ -253,10 +212,8 @@ enum class CompilerContextKind {
Typedef
};
-//----------------------------------------------------------------------
// Enumerations that can be used to specify the kind of metric we're looking at
// when collecting stats.
-//----------------------------------------------------------------------
enum StatisticKind {
ExpressionSuccessful = 0,
ExpressionFailure = 1,
diff --git a/include/lldb/lldb-private-forward.h b/include/lldb/lldb-private-forward.h
index 975d92d95727c..330070745adb7 100644
--- a/include/lldb/lldb-private-forward.h
+++ b/include/lldb/lldb-private-forward.h
@@ -1,9 +1,8 @@
//===-- lldb-private-forward.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,9 +10,7 @@
#define LLDB_lldb_private_forward_h_
namespace lldb_private {
-// --------------------------------------------------------------- Class
// forward decls.
-// ---------------------------------------------------------------
class NativeProcessProtocol;
class NativeRegisterContext;
class NativeThreadProtocol;
diff --git a/include/lldb/lldb-private-interfaces.h b/include/lldb/lldb-private-interfaces.h
index 76a9fad9f135a..3a9f78aae0fec 100644
--- a/include/lldb/lldb-private-interfaces.h
+++ b/include/lldb/lldb-private-interfaces.h
@@ -1,9 +1,8 @@
//===-- lldb-private-interfaces.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -56,6 +55,9 @@ typedef LanguageRuntime *(*LanguageRuntimeCreateInstance)(
Process *process, lldb::LanguageType language);
typedef lldb::CommandObjectSP (*LanguageRuntimeGetCommandObject)(
CommandInterpreter &interpreter);
+typedef lldb::BreakpointPreconditionSP (
+ *LanguageRuntimeGetExceptionPrecondition)(lldb::LanguageType language,
+ bool throw_bp);
typedef lldb::StructuredDataPluginSP (*StructuredDataPluginCreateInstance)(
Process &process);
typedef Status (*StructuredDataFilterLaunchInfo)(ProcessLaunchInfo &launch_info,
@@ -67,7 +69,7 @@ typedef lldb::ProcessSP (*ProcessCreateInstance)(
lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
const FileSpec *crash_file_path);
typedef lldb::ScriptInterpreterSP (*ScriptInterpreterCreateInstance)(
- CommandInterpreter &interpreter);
+ Debugger &debugger);
typedef SymbolFile *(*SymbolFileCreateInstance)(ObjectFile *obj_file);
typedef SymbolVendor *(*SymbolVendorCreateInstance)(
const lldb::ModuleSP &module_sp,
diff --git a/include/lldb/lldb-private-types.h b/include/lldb/lldb-private-types.h
index e0f0e413cef40..bff471177214e 100644
--- a/include/lldb/lldb-private-types.h
+++ b/include/lldb/lldb-private-types.h
@@ -1,9 +1,8 @@
//===-- lldb-private-types.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,10 +28,8 @@ class ExecutionContext;
typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(
const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &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
@@ -74,9 +71,7 @@ struct RegisterInfo {
}
};
-//----------------------------------------------------------------------
// 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
diff --git a/include/lldb/lldb-private.h b/include/lldb/lldb-private.h
index 252ca09fae295..24954ad2a1f56 100644
--- a/include/lldb/lldb-private.h
+++ b/include/lldb/lldb-private.h
@@ -1,9 +1,8 @@
//===-- lldb-private.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/lldb-public.h b/include/lldb/lldb-public.h
index 290ff6e6d501f..449062f832f66 100644
--- a/include/lldb/lldb-public.h
+++ b/include/lldb/lldb-public.h
@@ -1,9 +1,8 @@
-//===-- lldb-include.h ------------------------------------------*- C++ -*-===//
+//===-- lldb-public.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/lldb/lldb-types.h b/include/lldb/lldb-types.h
index 09dfc5c8a5ed9..414a9f3080522 100644
--- a/include/lldb/lldb-types.h
+++ b/include/lldb/lldb-types.h
@@ -1,9 +1,8 @@
//===-- lldb-types.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include <stdint.h>
-//----------------------------------------------------------------------
// All host systems must define:
// lldb::thread_t The native thread type for spawned threads on the
// system
@@ -28,7 +26,6 @@
// #define LLDB_INVALID_PROCESS_ID ...
// #define LLDB_INVALID_THREAD_ID ...
// #define LLDB_INVALID_HOST_THREAD ...
-//----------------------------------------------------------------------
// TODO: Add a bunch of ifdefs to determine the host system and what
// things should be defined. Currently MacOSX is being assumed by default since
@@ -55,9 +52,7 @@ typedef void *pipe_t; // Host pipe type is HANDLE
#include <pthread.h>
namespace lldb {
-//----------------------------------------------------------------------
// MacOSX Types
-//----------------------------------------------------------------------
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
diff --git a/include/lldb/lldb-versioning.h b/include/lldb/lldb-versioning.h
index 9d5fd164119e8..702ebd19a3ee2 100644
--- a/include/lldb/lldb-versioning.h
+++ b/include/lldb/lldb-versioning.h
@@ -1,19 +1,16 @@
//===-- lldb-versioning.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_lldb_versioning_h_
#define LLDB_lldb_versioning_h_
-//----------------------------------------------------------------------
// LLDB API version
-//----------------------------------------------------------------------
#define LLDB_API_MAJOR_VERSION 1
#define LLDB_API_MINOR_VERSION 0
diff --git a/include/lldb/module.modulemap b/include/lldb/module.modulemap
index 9c7f3e6f58e5a..e040df8f913bd 100644
--- a/include/lldb/module.modulemap
+++ b/include/lldb/module.modulemap
@@ -2,6 +2,8 @@
module lldb_API {
requires cplusplus
+ textual header "Utility/ReproducerInstrumentation.h"
+
umbrella "API"
module * { export * }
}
@@ -17,6 +19,7 @@ module lldb_Host {
module Editline { header "Host/Editline.h" export * }
module FileCache { header "Host/FileCache.h" export * }
module File { header "Host/File.h" export * }
+ module FileAction { header "Host/FileAction.h" export * }
module FileSystem { header "Host/FileSystem.h" export * }
module HostGetOpt { header "Host/HostGetOpt.h" export * }
module Host { header "Host/Host.h" export * }
@@ -39,13 +42,13 @@ module lldb_Host {
module Pipe { header "Host/Pipe.h" export * }
module PosixApi { header "Host/PosixApi.h" export * }
module ProcessLauncher { header "Host/ProcessLauncher.h" export * }
+ module ProcessLaunchInfo { header "Host/ProcessLaunchInfo.h" export * }
module ProcessRunLock { header "Host/ProcessRunLock.h" export * }
module PseudoTerminal { header "Host/PseudoTerminal.h" export * }
module SafeMachO { header "Host/SafeMachO.h" export * }
module SocketAddress { header "Host/SocketAddress.h" export * }
module Socket { header "Host/Socket.h" export * }
- module StringConvert { header "Host/StringConvert.h" export * }
- module Symbols { header "Host/Symbols.h" export * }
+ module StringConvert { textual header "Host/StringConvert.h" export * }
module TaskPool { header "Host/TaskPool.h" export * }
module Terminal { header "Host/Terminal.h" export * }
module ThreadLauncher { header "Host/ThreadLauncher.h" export * }
@@ -135,5 +138,4 @@ module lldb_Utility {
module lldb_public { header "lldb-public.h" export * }
module lldb_types { header "lldb-types.h" export * }
module lldb_versioning { header "lldb-versioning.h" export * }
-
}
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index 09ec6c3f10db9..358cb400a76cc 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -1,13 +1,14 @@
//===-- SBAddress.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBAddress.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBSection.h"
#include "lldb/API/SBStream.h"
@@ -15,44 +16,51 @@
#include "lldb/Core/Module.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
-SBAddress::SBAddress() : m_opaque_ap(new Address()) {}
+SBAddress::SBAddress() : m_opaque_up(new Address()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAddress);
+}
SBAddress::SBAddress(const Address *lldb_object_ptr)
- : m_opaque_ap(new Address()) {
+ : m_opaque_up(new Address()) {
if (lldb_object_ptr)
- ref() = *lldb_object_ptr;
+ m_opaque_up = llvm::make_unique<Address>(*lldb_object_ptr);
}
-SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_ap(new Address()) {
- if (rhs.IsValid())
- ref() = rhs.ref();
+SBAddress::SBAddress(const SBAddress &rhs) : m_opaque_up(new Address()) {
+ LLDB_RECORD_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBAddress::SBAddress(lldb::SBSection section, lldb::addr_t offset)
- : m_opaque_ap(new Address(section.GetSP(), offset)) {}
+ : m_opaque_up(new Address(section.GetSP(), offset)) {
+ LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t), section,
+ offset);
+}
// Create an address by resolving a load address using the supplied target
SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target)
- : m_opaque_ap(new Address()) {
+ : m_opaque_up(new Address()) {
+ LLDB_RECORD_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &),
+ load_addr, target);
+
SetLoadAddress(load_addr, target);
}
SBAddress::~SBAddress() {}
const SBAddress &SBAddress::operator=(const SBAddress &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- ref() = rhs.ref();
- else
- m_opaque_ap.reset(new Address());
- }
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBAddress &,
+ SBAddress, operator=,(const lldb::SBAddress &), rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
@@ -61,13 +69,33 @@ bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) {
return false;
}
+bool SBAddress::operator!=(const SBAddress &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBAddress, operator!=,(const SBAddress &),
+ &rhs);
+
+ return !(*this == rhs);
+}
+
bool SBAddress::IsValid() const {
- return m_opaque_ap != NULL && m_opaque_ap->IsValid();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, IsValid);
+ return this->operator bool();
}
+SBAddress::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBAddress, operator bool);
-void SBAddress::Clear() { m_opaque_ap.reset(new Address()); }
+ return m_opaque_up != nullptr && m_opaque_up->IsValid();
+}
+
+void SBAddress::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear);
+
+ m_opaque_up.reset(new Address());
+}
void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
+ LLDB_RECORD_METHOD(void, SBAddress, SetAddress,
+ (lldb::SBSection, lldb::addr_t), section, offset);
+
Address &addr = ref();
addr.SetSection(section.GetSP());
addr.SetOffset(offset);
@@ -77,61 +105,59 @@ void SBAddress::SetAddress(const Address *lldb_object_ptr) {
if (lldb_object_ptr)
ref() = *lldb_object_ptr;
else
- m_opaque_ap.reset(new Address());
+ m_opaque_up.reset(new Address());
}
lldb::addr_t SBAddress::GetFileAddress() const {
- if (m_opaque_ap->IsValid())
- return m_opaque_ap->GetFileAddress();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBAddress, GetFileAddress);
+
+ if (m_opaque_up->IsValid())
+ return m_opaque_up->GetFileAddress();
else
return LLDB_INVALID_ADDRESS;
}
lldb::addr_t SBAddress::GetLoadAddress(const SBTarget &target) const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress,
+ (const lldb::SBTarget &), target);
lldb::addr_t addr = LLDB_INVALID_ADDRESS;
TargetSP target_sp(target.GetSP());
if (target_sp) {
- if (m_opaque_ap->IsValid()) {
+ if (m_opaque_up->IsValid()) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- addr = m_opaque_ap->GetLoadAddress(target_sp.get());
+ addr = m_opaque_up->GetLoadAddress(target_sp.get());
}
}
- if (log) {
- if (addr == LLDB_INVALID_ADDRESS)
- log->Printf(
- "SBAddress::GetLoadAddress (SBTarget(%p)) => LLDB_INVALID_ADDRESS",
- static_cast<void *>(target_sp.get()));
- else
- log->Printf("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%" PRIx64,
- static_cast<void *>(target_sp.get()), addr);
- }
-
return addr;
}
void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) {
+ LLDB_RECORD_METHOD(void, SBAddress, SetLoadAddress,
+ (lldb::addr_t, lldb::SBTarget &), load_addr, target);
+
// Create the address object if we don't already have one
ref();
if (target.IsValid())
*this = target.ResolveLoadAddress(load_addr);
else
- m_opaque_ap->Clear();
+ m_opaque_up->Clear();
// Check if we weren't were able to resolve a section offset address. If we
// weren't it is ok, the load address might be a location on the stack or
// heap, so we should just have an address with no section and a valid offset
- if (!m_opaque_ap->IsValid())
- m_opaque_ap->SetOffset(load_addr);
+ if (!m_opaque_up->IsValid())
+ m_opaque_up->SetOffset(load_addr);
}
bool SBAddress::OffsetAddress(addr_t offset) {
- if (m_opaque_ap->IsValid()) {
- addr_t addr_offset = m_opaque_ap->GetOffset();
+ LLDB_RECORD_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t), offset);
+
+ if (m_opaque_up->IsValid()) {
+ addr_t addr_offset = m_opaque_up->GetOffset();
if (addr_offset != LLDB_INVALID_ADDRESS) {
- m_opaque_ap->SetOffset(addr_offset + offset);
+ m_opaque_up->SetOffset(addr_offset + offset);
return true;
}
}
@@ -139,46 +165,53 @@ bool SBAddress::OffsetAddress(addr_t offset) {
}
lldb::SBSection SBAddress::GetSection() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBAddress, GetSection);
+
lldb::SBSection sb_section;
- if (m_opaque_ap->IsValid())
- sb_section.SetSP(m_opaque_ap->GetSection());
- return sb_section;
+ if (m_opaque_up->IsValid())
+ sb_section.SetSP(m_opaque_up->GetSection());
+ return LLDB_RECORD_RESULT(sb_section);
}
lldb::addr_t SBAddress::GetOffset() {
- if (m_opaque_ap->IsValid())
- return m_opaque_ap->GetOffset();
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBAddress, GetOffset);
+
+ if (m_opaque_up->IsValid())
+ return m_opaque_up->GetOffset();
return 0;
}
-Address *SBAddress::operator->() { return m_opaque_ap.get(); }
+Address *SBAddress::operator->() { return m_opaque_up.get(); }
-const Address *SBAddress::operator->() const { return m_opaque_ap.get(); }
+const Address *SBAddress::operator->() const { return m_opaque_up.get(); }
Address &SBAddress::ref() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new Address());
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new Address());
+ return *m_opaque_up;
}
const Address &SBAddress::ref() const {
// This object should already have checked with "IsValid()" prior to calling
// this function. In case you didn't we will assert and die to let you know.
- assert(m_opaque_ap.get());
- return *m_opaque_ap;
+ assert(m_opaque_up.get());
+ return *m_opaque_up;
}
-Address *SBAddress::get() { return m_opaque_ap.get(); }
+Address *SBAddress::get() { return m_opaque_up.get(); }
bool SBAddress::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &),
+ description);
+
// Call "ref()" on the stream to make sure it creates a backing stream in
// case there isn't one already...
Stream &strm = description.ref();
- if (m_opaque_ap->IsValid()) {
- m_opaque_ap->Dump(&strm, NULL, Address::DumpStyleResolvedDescription,
+ if (m_opaque_up->IsValid()) {
+ m_opaque_up->Dump(&strm, nullptr, Address::DumpStyleResolvedDescription,
Address::DumpStyleModuleWithFileAddress, 4);
StreamString sstrm;
- // m_opaque_ap->Dump (&sstrm, NULL,
+ // m_opaque_up->Dump (&sstrm, NULL,
// Address::DumpStyleResolvedDescription, Address::DumpStyleInvalid,
// 4);
// if (sstrm.GetData())
@@ -190,54 +223,109 @@ bool SBAddress::GetDescription(SBStream &description) {
}
SBModule SBAddress::GetModule() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBAddress, GetModule);
+
SBModule sb_module;
- if (m_opaque_ap->IsValid())
- sb_module.SetSP(m_opaque_ap->GetModule());
- return sb_module;
+ if (m_opaque_up->IsValid())
+ sb_module.SetSP(m_opaque_up->GetModule());
+ return LLDB_RECORD_RESULT(sb_module);
}
SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext,
+ (uint32_t), resolve_scope);
+
SBSymbolContext sb_sc;
SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
- if (m_opaque_ap->IsValid())
- m_opaque_ap->CalculateSymbolContext(&sb_sc.ref(), scope);
- return sb_sc;
+ if (m_opaque_up->IsValid())
+ m_opaque_up->CalculateSymbolContext(&sb_sc.ref(), scope);
+ return LLDB_RECORD_RESULT(sb_sc);
}
SBCompileUnit SBAddress::GetCompileUnit() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBAddress, GetCompileUnit);
+
SBCompileUnit sb_comp_unit;
- if (m_opaque_ap->IsValid())
- sb_comp_unit.reset(m_opaque_ap->CalculateSymbolContextCompileUnit());
- return sb_comp_unit;
+ if (m_opaque_up->IsValid())
+ sb_comp_unit.reset(m_opaque_up->CalculateSymbolContextCompileUnit());
+ return LLDB_RECORD_RESULT(sb_comp_unit);
}
SBFunction SBAddress::GetFunction() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBAddress, GetFunction);
+
SBFunction sb_function;
- if (m_opaque_ap->IsValid())
- sb_function.reset(m_opaque_ap->CalculateSymbolContextFunction());
- return sb_function;
+ if (m_opaque_up->IsValid())
+ sb_function.reset(m_opaque_up->CalculateSymbolContextFunction());
+ return LLDB_RECORD_RESULT(sb_function);
}
SBBlock SBAddress::GetBlock() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBAddress, GetBlock);
+
SBBlock sb_block;
- if (m_opaque_ap->IsValid())
- sb_block.SetPtr(m_opaque_ap->CalculateSymbolContextBlock());
- return sb_block;
+ if (m_opaque_up->IsValid())
+ sb_block.SetPtr(m_opaque_up->CalculateSymbolContextBlock());
+ return LLDB_RECORD_RESULT(sb_block);
}
SBSymbol SBAddress::GetSymbol() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBAddress, GetSymbol);
+
SBSymbol sb_symbol;
- if (m_opaque_ap->IsValid())
- sb_symbol.reset(m_opaque_ap->CalculateSymbolContextSymbol());
- return sb_symbol;
+ if (m_opaque_up->IsValid())
+ sb_symbol.reset(m_opaque_up->CalculateSymbolContextSymbol());
+ return LLDB_RECORD_RESULT(sb_symbol);
}
SBLineEntry SBAddress::GetLineEntry() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBAddress, GetLineEntry);
+
SBLineEntry sb_line_entry;
- if (m_opaque_ap->IsValid()) {
+ if (m_opaque_up->IsValid()) {
LineEntry line_entry;
- if (m_opaque_ap->CalculateSymbolContextLineEntry(line_entry))
+ if (m_opaque_up->CalculateSymbolContextLineEntry(line_entry))
sb_line_entry.SetLineEntry(line_entry);
}
- return sb_line_entry;
+ return LLDB_RECORD_RESULT(sb_line_entry);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBAddress>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBAddress, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBAddress, (const lldb::SBAddress &));
+ LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::SBSection, lldb::addr_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBAddress, (lldb::addr_t, lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(const lldb::SBAddress &,
+ SBAddress, operator=,(const lldb::SBAddress &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBAddress, operator!=,(const lldb::SBAddress &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBAddress, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBAddress, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBAddress, Clear, ());
+ LLDB_REGISTER_METHOD(void, SBAddress, SetAddress,
+ (lldb::SBSection, lldb::addr_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetFileAddress, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBAddress, GetLoadAddress,
+ (const lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(void, SBAddress, SetLoadAddress,
+ (lldb::addr_t, lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(bool, SBAddress, OffsetAddress, (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBAddress, GetSection, ());
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBAddress, GetOffset, ());
+ LLDB_REGISTER_METHOD(bool, SBAddress, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBAddress, GetModule, ());
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBAddress, GetSymbolContext,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBAddress, GetCompileUnit, ());
+ LLDB_REGISTER_METHOD(lldb::SBFunction, SBAddress, GetFunction, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBAddress, GetBlock, ());
+ LLDB_REGISTER_METHOD(lldb::SBSymbol, SBAddress, GetSymbol, ());
+ LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBAddress, GetLineEntry, ());
+}
+
+}
}
diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp
index a74487a70fe3a..838385c104ae6 100644
--- a/source/API/SBAttachInfo.cpp
+++ b/source/API/SBAttachInfo.cpp
@@ -1,14 +1,14 @@
//===-- SBAttachInfo.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBAttachInfo.h"
-
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBListener.h"
#include "lldb/Target/Process.h"
@@ -16,15 +16,21 @@
using namespace lldb;
using namespace lldb_private;
-SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) {}
+SBAttachInfo::SBAttachInfo() : m_opaque_sp(new ProcessAttachInfo()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBAttachInfo);
+}
SBAttachInfo::SBAttachInfo(lldb::pid_t pid)
: m_opaque_sp(new ProcessAttachInfo()) {
+ LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (lldb::pid_t), pid);
+
m_opaque_sp->SetProcessID(pid);
}
SBAttachInfo::SBAttachInfo(const char *path, bool wait_for)
: m_opaque_sp(new ProcessAttachInfo()) {
+ LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool), path, wait_for);
+
if (path && path[0])
m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
m_opaque_sp->SetWaitForLaunch(wait_for);
@@ -32,6 +38,9 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for)
SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async)
: m_opaque_sp(new ProcessAttachInfo()) {
+ LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool), path,
+ wait_for, async);
+
if (path && path[0])
m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
m_opaque_sp->SetWaitForLaunch(wait_for);
@@ -40,7 +49,9 @@ SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async)
SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs)
: m_opaque_sp(new ProcessAttachInfo()) {
- *m_opaque_sp = *rhs.m_opaque_sp;
+ LLDB_RECORD_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &), rhs);
+
+ m_opaque_sp = clone(rhs.m_opaque_sp);
}
SBAttachInfo::~SBAttachInfo() {}
@@ -48,34 +59,54 @@ SBAttachInfo::~SBAttachInfo() {}
lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; }
SBAttachInfo &SBAttachInfo::operator=(const SBAttachInfo &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBAttachInfo &,
+ SBAttachInfo, operator=,(const lldb::SBAttachInfo &), rhs);
+
if (this != &rhs)
- *m_opaque_sp = *rhs.m_opaque_sp;
- return *this;
+ m_opaque_sp = clone(rhs.m_opaque_sp);
+ return LLDB_RECORD_RESULT(*this);
}
-lldb::pid_t SBAttachInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); }
+lldb::pid_t SBAttachInfo::GetProcessID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBAttachInfo, GetProcessID);
+
+ return m_opaque_sp->GetProcessID();
+}
void SBAttachInfo::SetProcessID(lldb::pid_t pid) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t), pid);
+
m_opaque_sp->SetProcessID(pid);
}
uint32_t SBAttachInfo::GetResumeCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetResumeCount);
+
return m_opaque_sp->GetResumeCount();
}
void SBAttachInfo::SetResumeCount(uint32_t c) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t), c);
+
m_opaque_sp->SetResumeCount(c);
}
const char *SBAttachInfo::GetProcessPluginName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBAttachInfo, GetProcessPluginName);
+
return m_opaque_sp->GetProcessPluginName();
}
void SBAttachInfo::SetProcessPluginName(const char *plugin_name) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetProcessPluginName, (const char *),
+ plugin_name);
+
return m_opaque_sp->SetProcessPluginName(plugin_name);
}
void SBAttachInfo::SetExecutable(const char *path) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (const char *), path);
+
if (path && path[0])
m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native);
else
@@ -83,6 +114,9 @@ void SBAttachInfo::SetExecutable(const char *path) {
}
void SBAttachInfo::SetExecutable(SBFileSpec exe_file) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec),
+ exe_file);
+
if (exe_file.IsValid())
m_opaque_sp->GetExecutableFile() = exe_file.ref();
else
@@ -90,78 +124,185 @@ void SBAttachInfo::SetExecutable(SBFileSpec exe_file) {
}
bool SBAttachInfo::GetWaitForLaunch() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GetWaitForLaunch);
+
return m_opaque_sp->GetWaitForLaunch();
}
void SBAttachInfo::SetWaitForLaunch(bool b) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool), b);
+
m_opaque_sp->SetWaitForLaunch(b);
}
void SBAttachInfo::SetWaitForLaunch(bool b, bool async) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool), b,
+ async);
+
m_opaque_sp->SetWaitForLaunch(b);
m_opaque_sp->SetAsync(async);
}
bool SBAttachInfo::GetIgnoreExisting() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GetIgnoreExisting);
+
return m_opaque_sp->GetIgnoreExisting();
}
void SBAttachInfo::SetIgnoreExisting(bool b) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool), b);
+
m_opaque_sp->SetIgnoreExisting(b);
}
-uint32_t SBAttachInfo::GetUserID() { return m_opaque_sp->GetUserID(); }
+uint32_t SBAttachInfo::GetUserID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetUserID);
+
+ return m_opaque_sp->GetUserID();
+}
+
+uint32_t SBAttachInfo::GetGroupID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetGroupID);
-uint32_t SBAttachInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); }
+ return m_opaque_sp->GetGroupID();
+}
+
+bool SBAttachInfo::UserIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, UserIDIsValid);
-bool SBAttachInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); }
+ return m_opaque_sp->UserIDIsValid();
+}
-bool SBAttachInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); }
+bool SBAttachInfo::GroupIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, GroupIDIsValid);
-void SBAttachInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); }
+ return m_opaque_sp->GroupIDIsValid();
+}
+
+void SBAttachInfo::SetUserID(uint32_t uid) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetUserID, (uint32_t), uid);
+
+ m_opaque_sp->SetUserID(uid);
+}
-void SBAttachInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); }
+void SBAttachInfo::SetGroupID(uint32_t gid) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t), gid);
+
+ m_opaque_sp->SetGroupID(gid);
+}
uint32_t SBAttachInfo::GetEffectiveUserID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetEffectiveUserID);
+
return m_opaque_sp->GetEffectiveUserID();
}
uint32_t SBAttachInfo::GetEffectiveGroupID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBAttachInfo, GetEffectiveGroupID);
+
return m_opaque_sp->GetEffectiveGroupID();
}
bool SBAttachInfo::EffectiveUserIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, EffectiveUserIDIsValid);
+
return m_opaque_sp->EffectiveUserIDIsValid();
}
bool SBAttachInfo::EffectiveGroupIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, EffectiveGroupIDIsValid);
+
return m_opaque_sp->EffectiveGroupIDIsValid();
}
void SBAttachInfo::SetEffectiveUserID(uint32_t uid) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t), uid);
+
m_opaque_sp->SetEffectiveUserID(uid);
}
void SBAttachInfo::SetEffectiveGroupID(uint32_t gid) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t), gid);
+
m_opaque_sp->SetEffectiveGroupID(gid);
}
lldb::pid_t SBAttachInfo::GetParentProcessID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBAttachInfo, GetParentProcessID);
+
return m_opaque_sp->GetParentProcessID();
}
void SBAttachInfo::SetParentProcessID(lldb::pid_t pid) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t),
+ pid);
+
m_opaque_sp->SetParentProcessID(pid);
}
bool SBAttachInfo::ParentProcessIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBAttachInfo, ParentProcessIDIsValid);
+
return m_opaque_sp->ParentProcessIDIsValid();
}
SBListener SBAttachInfo::GetListener() {
- return SBListener(m_opaque_sp->GetListener());
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBAttachInfo, GetListener);
+
+ return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener()));
}
void SBAttachInfo::SetListener(SBListener &listener) {
+ LLDB_RECORD_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &),
+ listener);
+
m_opaque_sp->SetListener(listener.GetSP());
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBAttachInfo>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (lldb::pid_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool));
+ LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const char *, bool, bool));
+ LLDB_REGISTER_CONSTRUCTOR(SBAttachInfo, (const lldb::SBAttachInfo &));
+ LLDB_REGISTER_METHOD(lldb::SBAttachInfo &,
+ SBAttachInfo, operator=,(const lldb::SBAttachInfo &));
+ LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetProcessID, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessID, (lldb::pid_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetResumeCount, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetResumeCount, (uint32_t));
+ LLDB_REGISTER_METHOD(const char *, SBAttachInfo, GetProcessPluginName, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetProcessPluginName,
+ (const char *));
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (const char *));
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetExecutable, (lldb::SBFileSpec));
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetWaitForLaunch, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool));
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetWaitForLaunch, (bool, bool));
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, GetIgnoreExisting, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetIgnoreExisting, (bool));
+ LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetUserID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetGroupID, ());
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, UserIDIsValid, ());
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, GroupIDIsValid, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetUserID, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetGroupID, (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveUserID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBAttachInfo, GetEffectiveGroupID, ());
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveUserIDIsValid, ());
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, EffectiveGroupIDIsValid, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveUserID, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetEffectiveGroupID, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::pid_t, SBAttachInfo, GetParentProcessID, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetParentProcessID, (lldb::pid_t));
+ LLDB_REGISTER_METHOD(bool, SBAttachInfo, ParentProcessIDIsValid, ());
+ LLDB_REGISTER_METHOD(lldb::SBListener, SBAttachInfo, GetListener, ());
+ LLDB_REGISTER_METHOD(void, SBAttachInfo, SetListener, (lldb::SBListener &));
+}
+
+}
+}
diff --git a/source/API/SBBlock.cpp b/source/API/SBBlock.cpp
index cd453872201ad..f333d1d7b5f32 100644
--- a/source/API/SBBlock.cpp
+++ b/source/API/SBBlock.cpp
@@ -1,13 +1,13 @@
//===-- SBBlock.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBBlock.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFrame.h"
@@ -21,34 +21,52 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-SBBlock::SBBlock() : m_opaque_ptr(NULL) {}
+SBBlock::SBBlock() : m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBlock);
+}
SBBlock::SBBlock(lldb_private::Block *lldb_object_ptr)
: m_opaque_ptr(lldb_object_ptr) {}
-SBBlock::SBBlock(const SBBlock &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) {}
+SBBlock::SBBlock(const SBBlock &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBBlock, (const lldb::SBBlock &), rhs);
+}
const SBBlock &SBBlock::operator=(const SBBlock &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBBlock &,
+ SBBlock, operator=,(const lldb::SBBlock &), rhs);
+
m_opaque_ptr = rhs.m_opaque_ptr;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-SBBlock::~SBBlock() { m_opaque_ptr = NULL; }
+SBBlock::~SBBlock() { m_opaque_ptr = nullptr; }
-bool SBBlock::IsValid() const { return m_opaque_ptr != NULL; }
+bool SBBlock::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsValid);
+ return this->operator bool();
+}
+SBBlock::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, operator bool);
+
+ return m_opaque_ptr != nullptr;
+}
bool SBBlock::IsInlined() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBlock, IsInlined);
+
if (m_opaque_ptr)
- return m_opaque_ptr->GetInlinedFunctionInfo() != NULL;
+ return m_opaque_ptr->GetInlinedFunctionInfo() != nullptr;
return false;
}
const char *SBBlock::GetInlinedName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBlock, GetInlinedName);
+
if (m_opaque_ptr) {
const InlineFunctionInfo *inlined_info =
m_opaque_ptr->GetInlinedFunctionInfo();
@@ -59,13 +77,16 @@ const char *SBBlock::GetInlinedName() const {
language = function->GetLanguage();
else
language = lldb::eLanguageTypeUnknown;
- return inlined_info->GetName(language).AsCString(NULL);
+ return inlined_info->GetName(language).AsCString(nullptr);
}
}
- return NULL;
+ return nullptr;
}
SBFileSpec SBBlock::GetInlinedCallSiteFile() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBBlock,
+ GetInlinedCallSiteFile);
+
SBFileSpec sb_file;
if (m_opaque_ptr) {
const InlineFunctionInfo *inlined_info =
@@ -73,10 +94,12 @@ SBFileSpec SBBlock::GetInlinedCallSiteFile() const {
if (inlined_info)
sb_file.SetFileSpec(inlined_info->GetCallSite().GetFile());
}
- return sb_file;
+ return LLDB_RECORD_RESULT(sb_file);
}
uint32_t SBBlock::GetInlinedCallSiteLine() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBlock, GetInlinedCallSiteLine);
+
if (m_opaque_ptr) {
const InlineFunctionInfo *inlined_info =
m_opaque_ptr->GetInlinedFunctionInfo();
@@ -87,6 +110,8 @@ uint32_t SBBlock::GetInlinedCallSiteLine() const {
}
uint32_t SBBlock::GetInlinedCallSiteColumn() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBlock, GetInlinedCallSiteColumn);
+
if (m_opaque_ptr) {
const InlineFunctionInfo *inlined_info =
m_opaque_ptr->GetInlinedFunctionInfo();
@@ -106,31 +131,39 @@ void SBBlock::AppendVariables(bool can_create, bool get_parent_variables,
}
SBBlock SBBlock::GetParent() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetParent);
+
SBBlock sb_block;
if (m_opaque_ptr)
sb_block.m_opaque_ptr = m_opaque_ptr->GetParent();
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
lldb::SBBlock SBBlock::GetContainingInlinedBlock() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetContainingInlinedBlock);
+
SBBlock sb_block;
if (m_opaque_ptr)
sb_block.m_opaque_ptr = m_opaque_ptr->GetContainingInlinedBlock();
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
SBBlock SBBlock::GetSibling() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetSibling);
+
SBBlock sb_block;
if (m_opaque_ptr)
sb_block.m_opaque_ptr = m_opaque_ptr->GetSibling();
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
SBBlock SBBlock::GetFirstChild() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBBlock, GetFirstChild);
+
SBBlock sb_block;
if (m_opaque_ptr)
sb_block.m_opaque_ptr = m_opaque_ptr->GetFirstChild();
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
lldb_private::Block *SBBlock::GetPtr() { return m_opaque_ptr; }
@@ -138,6 +171,9 @@ lldb_private::Block *SBBlock::GetPtr() { return m_opaque_ptr; }
void SBBlock::SetPtr(lldb_private::Block *block) { m_opaque_ptr = block; }
bool SBBlock::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBBlock, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
if (m_opaque_ptr) {
@@ -160,12 +196,17 @@ bool SBBlock::GetDescription(SBStream &description) {
}
uint32_t SBBlock::GetNumRanges() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBlock, GetNumRanges);
+
if (m_opaque_ptr)
return m_opaque_ptr->GetNumRanges();
return 0;
}
lldb::SBAddress SBBlock::GetRangeStartAddress(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBAddress, SBBlock, GetRangeStartAddress, (uint32_t),
+ idx);
+
lldb::SBAddress sb_addr;
if (m_opaque_ptr) {
AddressRange range;
@@ -173,10 +214,13 @@ lldb::SBAddress SBBlock::GetRangeStartAddress(uint32_t idx) {
sb_addr.ref() = range.GetBaseAddress();
}
}
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
lldb::SBAddress SBBlock::GetRangeEndAddress(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBAddress, SBBlock, GetRangeEndAddress, (uint32_t),
+ idx);
+
lldb::SBAddress sb_addr;
if (m_opaque_ptr) {
AddressRange range;
@@ -185,10 +229,13 @@ lldb::SBAddress SBBlock::GetRangeEndAddress(uint32_t idx) {
sb_addr.ref().Slide(range.GetByteSize());
}
}
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
uint32_t SBBlock::GetRangeIndexForBlockAddress(lldb::SBAddress block_addr) {
+ LLDB_RECORD_METHOD(uint32_t, SBBlock, GetRangeIndexForBlockAddress,
+ (lldb::SBAddress), block_addr);
+
if (m_opaque_ptr && block_addr.IsValid()) {
return m_opaque_ptr->GetRangeIndexContainingAddress(block_addr.ref());
}
@@ -199,6 +246,11 @@ uint32_t SBBlock::GetRangeIndexForBlockAddress(lldb::SBAddress block_addr) {
lldb::SBValueList SBBlock::GetVariables(lldb::SBFrame &frame, bool arguments,
bool locals, bool statics,
lldb::DynamicValueType use_dynamic) {
+ LLDB_RECORD_METHOD(
+ lldb::SBValueList, SBBlock, GetVariables,
+ (lldb::SBFrame &, bool, bool, bool, lldb::DynamicValueType), frame,
+ arguments, locals, statics, use_dynamic);
+
Block *block = GetPtr();
SBValueList value_list;
if (block) {
@@ -245,11 +297,15 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBFrame &frame, bool arguments,
}
}
}
- return value_list;
+ return LLDB_RECORD_RESULT(value_list);
}
lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments,
bool locals, bool statics) {
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBBlock, GetVariables,
+ (lldb::SBTarget &, bool, bool, bool), target, arguments,
+ locals, statics);
+
Block *block = GetPtr();
SBValueList value_list;
@@ -293,5 +349,44 @@ lldb::SBValueList SBBlock::GetVariables(lldb::SBTarget &target, bool arguments,
}
}
}
- return value_list;
+ return LLDB_RECORD_RESULT(value_list);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBBlock>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBBlock, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBBlock, (const lldb::SBBlock &));
+ LLDB_REGISTER_METHOD(const lldb::SBBlock &,
+ SBBlock, operator=,(const lldb::SBBlock &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBlock, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBlock, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBlock, IsInlined, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBlock, GetInlinedName, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBBlock,
+ GetInlinedCallSiteFile, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBlock, GetInlinedCallSiteLine, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBlock, GetInlinedCallSiteColumn, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetParent, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetContainingInlinedBlock, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetSibling, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBBlock, GetFirstChild, ());
+ LLDB_REGISTER_METHOD(bool, SBBlock, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(uint32_t, SBBlock, GetNumRanges, ());
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBBlock, GetRangeStartAddress,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBBlock, GetRangeEndAddress,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBBlock, GetRangeIndexForBlockAddress,
+ (lldb::SBAddress));
+ LLDB_REGISTER_METHOD(
+ lldb::SBValueList, SBBlock, GetVariables,
+ (lldb::SBFrame &, bool, bool, bool, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBBlock, GetVariables,
+ (lldb::SBTarget &, bool, bool, bool));
+}
+
+}
}
diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp
index b6720071e17c7..45eaea6b61819 100644
--- a/source/API/SBBreakpoint.cpp
+++ b/source/API/SBBreakpoint.cpp
@@ -1,13 +1,13 @@
//===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBBreakpoint.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBBreakpointLocation.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBEvent.h"
@@ -32,7 +32,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "SBBreakpointOptionCommon.h"
@@ -44,42 +43,60 @@
using namespace lldb;
using namespace lldb_private;
-SBBreakpoint::SBBreakpoint() {}
+SBBreakpoint::SBBreakpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpoint); }
SBBreakpoint::SBBreakpoint(const SBBreakpoint &rhs)
- : m_opaque_wp(rhs.m_opaque_wp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &), rhs);
+}
SBBreakpoint::SBBreakpoint(const lldb::BreakpointSP &bp_sp)
- : m_opaque_wp(bp_sp) {}
+ : m_opaque_wp(bp_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &), bp_sp);
+}
SBBreakpoint::~SBBreakpoint() = default;
const SBBreakpoint &SBBreakpoint::operator=(const SBBreakpoint &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBBreakpoint &,
+ SBBreakpoint, operator=,(const lldb::SBBreakpoint &), rhs);
+
m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBBreakpoint::operator==(const lldb::SBBreakpoint &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBBreakpoint, operator==,(const lldb::SBBreakpoint &), rhs);
+
return m_opaque_wp.lock() == rhs.m_opaque_wp.lock();
}
bool SBBreakpoint::operator!=(const lldb::SBBreakpoint &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBBreakpoint, operator!=,(const lldb::SBBreakpoint &), rhs);
+
return m_opaque_wp.lock() != rhs.m_opaque_wp.lock();
}
break_id_t SBBreakpoint::GetID() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::break_id_t, SBBreakpoint, GetID);
break_id_t break_id = LLDB_INVALID_BREAK_ID;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp)
break_id = bkpt_sp->GetID();
- LLDB_LOG(log, "breakpoint = {0}, id = {1}", bkpt_sp.get(), break_id);
return break_id;
}
bool SBBreakpoint::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsValid);
+ return this->operator bool();
+}
+SBBreakpoint::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, operator bool);
+
BreakpointSP bkpt_sp = GetSP();
if (!bkpt_sp)
return false;
@@ -90,6 +107,8 @@ bool SBBreakpoint::IsValid() const {
}
void SBBreakpoint::ClearAllBreakpointSites() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpoint, ClearAllBreakpointSites);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -99,6 +118,9 @@ void SBBreakpoint::ClearAllBreakpointSites() {
}
SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ FindLocationByAddress, (lldb::addr_t), vm_addr);
+
SBBreakpointLocation sb_bp_location;
BreakpointSP bkpt_sp = GetSP();
@@ -114,10 +136,13 @@ SBBreakpointLocation SBBreakpoint::FindLocationByAddress(addr_t vm_addr) {
sb_bp_location.SetLocation(bkpt_sp->FindLocationByAddress(address));
}
}
- return sb_bp_location;
+ return LLDB_RECORD_RESULT(sb_bp_location);
}
break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
+ LLDB_RECORD_METHOD(lldb::break_id_t, SBBreakpoint, FindLocationIDByAddress,
+ (lldb::addr_t), vm_addr);
+
break_id_t break_id = LLDB_INVALID_BREAK_ID;
BreakpointSP bkpt_sp = GetSP();
@@ -136,6 +161,9 @@ break_id_t SBBreakpoint::FindLocationIDByAddress(addr_t vm_addr) {
}
SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint, FindLocationByID,
+ (lldb::break_id_t), bp_loc_id);
+
SBBreakpointLocation sb_bp_location;
BreakpointSP bkpt_sp = GetSP();
@@ -145,10 +173,13 @@ SBBreakpointLocation SBBreakpoint::FindLocationByID(break_id_t bp_loc_id) {
sb_bp_location.SetLocation(bkpt_sp->FindLocationByID(bp_loc_id));
}
- return sb_bp_location;
+ return LLDB_RECORD_RESULT(sb_bp_location);
}
SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ GetLocationAtIndex, (uint32_t), index);
+
SBBreakpointLocation sb_bp_location;
BreakpointSP bkpt_sp = GetSP();
@@ -158,14 +189,13 @@ SBBreakpointLocation SBBreakpoint::GetLocationAtIndex(uint32_t index) {
sb_bp_location.SetLocation(bkpt_sp->GetLocationAtIndex(index));
}
- return sb_bp_location;
+ return LLDB_RECORD_RESULT(sb_bp_location);
}
void SBBreakpoint::SetEnabled(bool enable) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- BreakpointSP bkpt_sp = GetSP();
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetEnabled, (bool), enable);
- LLDB_LOG(log, "breakpoint = {0}, enable = {1}", bkpt_sp.get(), enable);
+ BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -175,6 +205,8 @@ void SBBreakpoint::SetEnabled(bool enable) {
}
bool SBBreakpoint::IsEnabled() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsEnabled);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -185,10 +217,9 @@ bool SBBreakpoint::IsEnabled() {
}
void SBBreakpoint::SetOneShot(bool one_shot) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- BreakpointSP bkpt_sp = GetSP();
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetOneShot, (bool), one_shot);
- LLDB_LOG(log, "breakpoint = {0}, one_shot = {1}", bkpt_sp.get(), one_shot);
+ BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -198,6 +229,8 @@ void SBBreakpoint::SetOneShot(bool one_shot) {
}
bool SBBreakpoint::IsOneShot() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsOneShot);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -208,6 +241,8 @@ bool SBBreakpoint::IsOneShot() const {
}
bool SBBreakpoint::IsInternal() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, IsInternal);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -218,10 +253,9 @@ bool SBBreakpoint::IsInternal() {
}
void SBBreakpoint::SetIgnoreCount(uint32_t count) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- BreakpointSP bkpt_sp = GetSP();
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t), count);
- LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
+ BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -231,6 +265,9 @@ void SBBreakpoint::SetIgnoreCount(uint32_t count) {
}
void SBBreakpoint::SetCondition(const char *condition) {
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetCondition, (const char *),
+ condition);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -240,6 +277,8 @@ void SBBreakpoint::SetCondition(const char *condition) {
}
const char *SBBreakpoint::GetCondition() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpoint, GetCondition);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -250,6 +289,9 @@ const char *SBBreakpoint::GetCondition() {
}
void SBBreakpoint::SetAutoContinue(bool auto_continue) {
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetAutoContinue, (bool),
+ auto_continue);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -259,6 +301,8 @@ void SBBreakpoint::SetAutoContinue(bool auto_continue) {
}
bool SBBreakpoint::GetAutoContinue() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpoint, GetAutoContinue);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -269,6 +313,8 @@ bool SBBreakpoint::GetAutoContinue() {
}
uint32_t SBBreakpoint::GetHitCount() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetHitCount);
+
uint32_t count = 0;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -277,13 +323,12 @@ uint32_t SBBreakpoint::GetHitCount() const {
count = bkpt_sp->GetHitCount();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
-
return count;
}
uint32_t SBBreakpoint::GetIgnoreCount() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetIgnoreCount);
+
uint32_t count = 0;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -292,24 +337,23 @@ uint32_t SBBreakpoint::GetIgnoreCount() const {
count = bkpt_sp->GetIgnoreCount();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, count = {1}", bkpt_sp.get(), count);
-
return count;
}
void SBBreakpoint::SetThreadID(tid_t tid) {
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t), tid);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
bkpt_sp->GetTarget().GetAPIMutex());
bkpt_sp->SetThreadID(tid);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid);
}
tid_t SBBreakpoint::GetThreadID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpoint, GetThreadID);
+
tid_t tid = LLDB_INVALID_THREAD_ID;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -318,15 +362,13 @@ tid_t SBBreakpoint::GetThreadID() {
tid = bkpt_sp->GetThreadID();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, tid = {1:x}", bkpt_sp.get(), tid);
return tid;
}
void SBBreakpoint::SetThreadIndex(uint32_t index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t), index);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), index);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
bkpt_sp->GetTarget().GetAPIMutex());
@@ -335,6 +377,8 @@ void SBBreakpoint::SetThreadIndex(uint32_t index) {
}
uint32_t SBBreakpoint::GetThreadIndex() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpoint, GetThreadIndex);
+
uint32_t thread_idx = UINT32_MAX;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -345,16 +389,15 @@ uint32_t SBBreakpoint::GetThreadIndex() const {
if (thread_spec != nullptr)
thread_idx = thread_spec->GetIndex();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, index = {1}", bkpt_sp.get(), thread_idx);
return thread_idx;
}
void SBBreakpoint::SetThreadName(const char *thread_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetThreadName, (const char *),
+ thread_name);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), thread_name);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -364,6 +407,8 @@ void SBBreakpoint::SetThreadName(const char *thread_name) {
}
const char *SBBreakpoint::GetThreadName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetThreadName);
+
const char *name = nullptr;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -374,17 +419,15 @@ const char *SBBreakpoint::GetThreadName() const {
if (thread_spec != nullptr)
name = thread_spec->GetName();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
return name;
}
void SBBreakpoint::SetQueueName(const char *queue_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetQueueName, (const char *),
+ queue_name);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, queue_name = {1}", bkpt_sp.get(),
- queue_name);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
bkpt_sp->GetTarget().GetAPIMutex());
@@ -393,6 +436,8 @@ void SBBreakpoint::SetQueueName(const char *queue_name) {
}
const char *SBBreakpoint::GetQueueName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpoint, GetQueueName);
+
const char *name = nullptr;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -403,13 +448,14 @@ const char *SBBreakpoint::GetQueueName() const {
if (thread_spec)
name = thread_spec->GetQueueName();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
return name;
}
size_t SBBreakpoint::GetNumResolvedLocations() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint,
+ GetNumResolvedLocations);
+
size_t num_resolved = 0;
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
@@ -417,13 +463,12 @@ size_t SBBreakpoint::GetNumResolvedLocations() const {
bkpt_sp->GetTarget().GetAPIMutex());
num_resolved = bkpt_sp->GetNumResolvedLocations();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, num_resolved = {1}", bkpt_sp.get(),
- num_resolved);
return num_resolved;
}
size_t SBBreakpoint::GetNumLocations() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpoint, GetNumLocations);
+
BreakpointSP bkpt_sp = GetSP();
size_t num_locs = 0;
if (bkpt_sp) {
@@ -431,12 +476,13 @@ size_t SBBreakpoint::GetNumLocations() const {
bkpt_sp->GetTarget().GetAPIMutex());
num_locs = bkpt_sp->GetNumLocations();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOG(log, "breakpoint = {0}, num_locs = {1}", bkpt_sp.get(), num_locs);
return num_locs;
}
void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetCommandLineCommands,
+ (lldb::SBStringList &), commands);
+
BreakpointSP bkpt_sp = GetSP();
if (!bkpt_sp)
return;
@@ -452,6 +498,9 @@ void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) {
}
bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
+ LLDB_RECORD_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
+ (lldb::SBStringList &), commands);
+
BreakpointSP bkpt_sp = GetSP();
if (!bkpt_sp)
return false;
@@ -464,10 +513,15 @@ bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) {
}
bool SBBreakpoint::GetDescription(SBStream &s) {
+ LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription, (lldb::SBStream &), s);
+
return GetDescription(s, true);
}
bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
+ LLDB_RECORD_METHOD(bool, SBBreakpoint, GetDescription,
+ (lldb::SBStream &, bool), s, include_locations);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -485,47 +539,45 @@ bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) {
return false;
}
-SBError
-SBBreakpoint::AddLocation(SBAddress &address) {
- BreakpointSP bkpt_sp = GetSP();
- SBError error;
-
- if (!address.IsValid()) {
- error.SetErrorString("Can't add an invalid address.");
- return error;
- }
-
- if (!bkpt_sp) {
- error.SetErrorString("No breakpoint to add a location to.");
- return error;
- }
-
- if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
- error.SetErrorString("Only a scripted resolver can add locations.");
- return error;
- }
-
- if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
- bkpt_sp->AddLocation(address.ref());
- else
- {
- StreamString s;
- address.get()->Dump(&s, &bkpt_sp->GetTarget(),
- Address::DumpStyleModuleWithFileAddress);
- error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
- s.GetData());
- }
- return error;
+SBError SBBreakpoint::AddLocation(SBAddress &address) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
+ (lldb::SBAddress &), address);
+
+ BreakpointSP bkpt_sp = GetSP();
+ SBError error;
+
+ if (!address.IsValid()) {
+ error.SetErrorString("Can't add an invalid address.");
+ return LLDB_RECORD_RESULT(error);
+ }
+
+ if (!bkpt_sp) {
+ error.SetErrorString("No breakpoint to add a location to.");
+ return LLDB_RECORD_RESULT(error);
+ }
+
+ if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) {
+ error.SetErrorString("Only a scripted resolver can add locations.");
+ return LLDB_RECORD_RESULT(error);
+ }
+
+ if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref()))
+ bkpt_sp->AddLocation(address.ref());
+ else {
+ StreamString s;
+ address.get()->Dump(&s, &bkpt_sp->GetTarget(),
+ Address::DumpStyleModuleWithFileAddress);
+ error.SetErrorStringWithFormat("Address: %s didn't pass the filter.",
+ s.GetData());
+ }
+ return LLDB_RECORD_RESULT(error);
}
+void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) {
+ LLDB_RECORD_DUMMY(void, SBBreakpoint, SetCallback,
+ (lldb::SBBreakpointHitCallback, void *), callback, baton);
-void SBBreakpoint
- ::SetCallback(SBBreakpointHitCallback callback,
- void *baton) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, callback = {1}, baton = {2}", bkpt_sp.get(),
- callback, baton);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -539,10 +591,10 @@ void SBBreakpoint
void SBBreakpoint::SetScriptCallbackFunction(
const char *callback_function_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
+ (const char *), callback_function_name);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, callback = {1}", bkpt_sp.get(),
- callback_function_name);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -550,7 +602,6 @@ void SBBreakpoint::SetScriptCallbackFunction(
BreakpointOptions *bp_options = bkpt_sp->GetOptions();
bkpt_sp->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(bp_options,
callback_function_name);
@@ -558,10 +609,10 @@ void SBBreakpoint::SetScriptCallbackFunction(
}
SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
+ (const char *), callback_body_text);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, callback body:\n{1}", bkpt_sp.get(),
- callback_body_text);
SBError sb_error;
if (bkpt_sp) {
@@ -571,20 +622,19 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
Status error =
bkpt_sp->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(bp_options, callback_body_text);
sb_error.SetError(error);
} else
sb_error.SetErrorString("invalid breakpoint");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
bool SBBreakpoint::AddName(const char *new_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), new_name);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -593,34 +643,30 @@ bool SBBreakpoint::AddName(const char *new_name) {
// probably more annoying to have to provide it.
bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error);
if (error.Fail())
- {
- if (log)
- log->Printf("Failed to add name: '%s' to breakpoint: %s",
- new_name, error.AsCString());
return false;
- }
}
return true;
}
void SBBreakpoint::RemoveName(const char *name_to_remove) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpoint, RemoveName, (const char *),
+ name_to_remove);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name_to_remove);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
bkpt_sp->GetTarget().GetAPIMutex());
- bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
- ConstString(name_to_remove));
+ bkpt_sp->GetTarget().RemoveNameFromBreakpoint(bkpt_sp,
+ ConstString(name_to_remove));
}
}
bool SBBreakpoint::MatchesName(const char *name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBBreakpoint, MatchesName, (const char *), name);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}, name = {1}", bkpt_sp.get(), name);
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -632,9 +678,10 @@ bool SBBreakpoint::MatchesName(const char *name) {
}
void SBBreakpoint::GetNames(SBStringList &names) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &),
+ names);
+
BreakpointSP bkpt_sp = GetSP();
- LLDB_LOG(log, "breakpoint = {0}", bkpt_sp.get());
if (bkpt_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -648,12 +695,19 @@ void SBBreakpoint::GetNames(SBStringList &names) {
}
bool SBBreakpoint::EventIsBreakpointEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
+ (const lldb::SBEvent &), event);
+
return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) !=
nullptr;
}
BreakpointEventType
SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
+ GetBreakpointEventTypeFromEvent,
+ (const lldb::SBEvent &), event);
+
if (event.IsValid())
return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent(
event.GetSP());
@@ -661,25 +715,38 @@ SBBreakpoint::GetBreakpointEventTypeFromEvent(const SBEvent &event) {
}
SBBreakpoint SBBreakpoint::GetBreakpointFromEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
+ GetBreakpointFromEvent, (const lldb::SBEvent &),
+ event);
+
if (event.IsValid())
- return SBBreakpoint(
- Breakpoint::BreakpointEventData::GetBreakpointFromEvent(event.GetSP()));
- return SBBreakpoint();
+ return LLDB_RECORD_RESULT(
+ SBBreakpoint(Breakpoint::BreakpointEventData::GetBreakpointFromEvent(
+ event.GetSP())));
+ return LLDB_RECORD_RESULT(SBBreakpoint());
}
SBBreakpointLocation
SBBreakpoint::GetBreakpointLocationAtIndexFromEvent(const lldb::SBEvent &event,
uint32_t loc_idx) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ GetBreakpointLocationAtIndexFromEvent,
+ (const lldb::SBEvent &, uint32_t), event, loc_idx);
+
SBBreakpointLocation sb_breakpoint_loc;
if (event.IsValid())
sb_breakpoint_loc.SetLocation(
Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent(
event.GetSP(), loc_idx));
- return sb_breakpoint_loc;
+ return LLDB_RECORD_RESULT(sb_breakpoint_loc);
}
uint32_t
SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(uint32_t, SBBreakpoint,
+ GetNumBreakpointLocationsFromEvent,
+ (const lldb::SBEvent &), event);
+
uint32_t num_locations = 0;
if (event.IsValid())
num_locations =
@@ -689,6 +756,8 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) {
}
bool SBBreakpoint::IsHardware() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpoint, IsHardware);
+
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp)
return bkpt_sp->IsHardware();
@@ -782,11 +851,15 @@ private:
};
SBBreakpointList::SBBreakpointList(SBTarget &target)
- : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {}
+ : m_opaque_sp(new SBBreakpointListImpl(target.GetSP())) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target);
+}
SBBreakpointList::~SBBreakpointList() {}
size_t SBBreakpointList::GetSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize);
+
if (!m_opaque_sp)
return 0;
else
@@ -794,21 +867,30 @@ size_t SBBreakpointList::GetSize() const {
}
SBBreakpoint SBBreakpointList::GetBreakpointAtIndex(size_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, GetBreakpointAtIndex,
+ (size_t), idx);
+
if (!m_opaque_sp)
- return SBBreakpoint();
+ return LLDB_RECORD_RESULT(SBBreakpoint());
BreakpointSP bkpt_sp = m_opaque_sp->GetBreakpointAtIndex(idx);
- return SBBreakpoint(bkpt_sp);
+ return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
}
SBBreakpoint SBBreakpointList::FindBreakpointByID(lldb::break_id_t id) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBBreakpointList, FindBreakpointByID,
+ (lldb::break_id_t), id);
+
if (!m_opaque_sp)
- return SBBreakpoint();
+ return LLDB_RECORD_RESULT(SBBreakpoint());
BreakpointSP bkpt_sp = m_opaque_sp->FindBreakpointByID(id);
- return SBBreakpoint(bkpt_sp);
+ return LLDB_RECORD_RESULT(SBBreakpoint(bkpt_sp));
}
void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) {
+ LLDB_RECORD_METHOD(void, SBBreakpointList, Append,
+ (const lldb::SBBreakpoint &), sb_bkpt);
+
if (!sb_bkpt.IsValid())
return;
if (!m_opaque_sp)
@@ -817,12 +899,18 @@ void SBBreakpointList::Append(const SBBreakpoint &sb_bkpt) {
}
void SBBreakpointList::AppendByID(lldb::break_id_t id) {
+ LLDB_RECORD_METHOD(void, SBBreakpointList, AppendByID, (lldb::break_id_t),
+ id);
+
if (!m_opaque_sp)
return;
m_opaque_sp->AppendByID(id);
}
bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) {
+ LLDB_RECORD_METHOD(bool, SBBreakpointList, AppendIfUnique,
+ (const lldb::SBBreakpoint &), sb_bkpt);
+
if (!sb_bkpt.IsValid())
return false;
if (!m_opaque_sp)
@@ -831,6 +919,8 @@ bool SBBreakpointList::AppendIfUnique(const SBBreakpoint &sb_bkpt) {
}
void SBBreakpointList::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBBreakpointList, Clear);
+
if (m_opaque_sp)
m_opaque_sp->Clear();
}
@@ -840,3 +930,107 @@ void SBBreakpointList::CopyToBreakpointIDList(
if (m_opaque_sp)
m_opaque_sp->CopyToBreakpointIDList(bp_id_list);
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBBreakpoint>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::SBBreakpoint &));
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpoint, (const lldb::BreakpointSP &));
+ LLDB_REGISTER_METHOD(const lldb::SBBreakpoint &,
+ SBBreakpoint, operator=,(const lldb::SBBreakpoint &));
+ LLDB_REGISTER_METHOD(bool,
+ SBBreakpoint, operator==,(const lldb::SBBreakpoint &));
+ LLDB_REGISTER_METHOD(bool,
+ SBBreakpoint, operator!=,(const lldb::SBBreakpoint &));
+ LLDB_REGISTER_METHOD_CONST(lldb::break_id_t, SBBreakpoint, GetID, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, ClearAllBreakpointSites, ());
+ LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ FindLocationByAddress, (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpoint,
+ FindLocationIDByAddress, (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ FindLocationByID, (lldb::break_id_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ GetLocationAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetEnabled, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsEnabled, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetOneShot, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsOneShot, ());
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, IsInternal, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetIgnoreCount, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCondition, (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBBreakpoint, GetCondition, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetAutoContinue, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetAutoContinue, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetHitCount, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetIgnoreCount, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadID, (lldb::tid_t));
+ LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpoint, GetThreadID, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadIndex, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpoint, GetThreadIndex, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetThreadName, (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetThreadName, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetQueueName, (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpoint, GetQueueName, ());
+ LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumResolvedLocations,
+ ());
+ LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpoint, GetNumLocations, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetCommandLineCommands,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetCommandLineCommands,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, GetDescription,
+ (lldb::SBStream &, bool));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddLocation,
+ (lldb::SBAddress &));
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, SetScriptCallbackFunction,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *));
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *));
+ LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBBreakpoint, EventIsBreakpointEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::BreakpointEventType, SBBreakpoint,
+ GetBreakpointEventTypeFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpoint, SBBreakpoint,
+ GetBreakpointFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBBreakpointLocation, SBBreakpoint,
+ GetBreakpointLocationAtIndexFromEvent,
+ (const lldb::SBEvent &, uint32_t));
+ LLDB_REGISTER_STATIC_METHOD(uint32_t, SBBreakpoint,
+ GetNumBreakpointLocationsFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpoint, IsHardware, ());
+}
+
+template <>
+void RegisterMethods<SBBreakpointList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &));
+ LLDB_REGISTER_METHOD_CONST(size_t, SBBreakpointList, GetSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList,
+ GetBreakpointAtIndex, (size_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointList,
+ FindBreakpointByID, (lldb::break_id_t));
+ LLDB_REGISTER_METHOD(void, SBBreakpointList, Append,
+ (const lldb::SBBreakpoint &));
+ LLDB_REGISTER_METHOD(void, SBBreakpointList, AppendByID,
+ (lldb::break_id_t));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointList, AppendIfUnique,
+ (const lldb::SBBreakpoint &));
+ LLDB_REGISTER_METHOD(void, SBBreakpointList, Clear, ());
+}
+
+}
+}
diff --git a/source/API/SBBreakpointLocation.cpp b/source/API/SBBreakpointLocation.cpp
index 99ac0277e7000..640545f55ef97 100644
--- a/source/API/SBBreakpointLocation.cpp
+++ b/source/API/SBBreakpointLocation.cpp
@@ -1,13 +1,13 @@
//===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBBreakpointLocation.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDefines.h"
@@ -22,7 +22,6 @@
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
@@ -30,27 +29,32 @@
using namespace lldb;
using namespace lldb_private;
-SBBreakpointLocation::SBBreakpointLocation() {}
+SBBreakpointLocation::SBBreakpointLocation() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointLocation);
+}
SBBreakpointLocation::SBBreakpointLocation(
const lldb::BreakpointLocationSP &break_loc_sp)
: m_opaque_wp(break_loc_sp) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log) {
- SBStream sstr;
- GetDescription(sstr, lldb::eDescriptionLevelBrief);
- LLDB_LOG(log, "location = {0} ({1})", break_loc_sp.get(), sstr.GetData());
- }
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation,
+ (const lldb::BreakpointLocationSP &), break_loc_sp);
}
SBBreakpointLocation::SBBreakpointLocation(const SBBreakpointLocation &rhs)
- : m_opaque_wp(rhs.m_opaque_wp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpointLocation,
+ (const lldb::SBBreakpointLocation &), rhs);
+}
const SBBreakpointLocation &SBBreakpointLocation::
operator=(const SBBreakpointLocation &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBBreakpointLocation &,
+ SBBreakpointLocation, operator=,(const lldb::SBBreakpointLocation &),
+ rhs);
+
m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBBreakpointLocation::~SBBreakpointLocation() {}
@@ -59,17 +63,31 @@ BreakpointLocationSP SBBreakpointLocation::GetSP() const {
return m_opaque_wp.lock();
}
-bool SBBreakpointLocation::IsValid() const { return bool(GetSP()); }
+bool SBBreakpointLocation::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointLocation, IsValid);
+ return this->operator bool();
+}
+SBBreakpointLocation::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointLocation, operator bool);
+
+ return bool(GetSP());
+}
SBAddress SBBreakpointLocation::GetAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBBreakpointLocation, GetAddress);
+
BreakpointLocationSP loc_sp = GetSP();
- if (loc_sp)
- return SBAddress(&loc_sp->GetAddress());
- else
- return SBAddress();
+ if (loc_sp) {
+ return LLDB_RECORD_RESULT(SBAddress(&loc_sp->GetAddress()));
+ }
+
+ return LLDB_RECORD_RESULT(SBAddress());
}
addr_t SBBreakpointLocation::GetLoadAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBBreakpointLocation,
+ GetLoadAddress);
+
addr_t ret_addr = LLDB_INVALID_ADDRESS;
BreakpointLocationSP loc_sp = GetSP();
@@ -83,6 +101,8 @@ addr_t SBBreakpointLocation::GetLoadAddress() {
}
void SBBreakpointLocation::SetEnabled(bool enabled) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetEnabled, (bool), enabled);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -92,6 +112,8 @@ void SBBreakpointLocation::SetEnabled(bool enabled) {
}
bool SBBreakpointLocation::IsEnabled() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, IsEnabled);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -102,6 +124,8 @@ bool SBBreakpointLocation::IsEnabled() {
}
uint32_t SBBreakpointLocation::GetHitCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBreakpointLocation, GetHitCount);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -112,6 +136,8 @@ uint32_t SBBreakpointLocation::GetHitCount() {
}
uint32_t SBBreakpointLocation::GetIgnoreCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBBreakpointLocation, GetIgnoreCount);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -122,6 +148,8 @@ uint32_t SBBreakpointLocation::GetIgnoreCount() {
}
void SBBreakpointLocation::SetIgnoreCount(uint32_t n) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetIgnoreCount, (uint32_t), n);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -131,6 +159,9 @@ void SBBreakpointLocation::SetIgnoreCount(uint32_t n) {
}
void SBBreakpointLocation::SetCondition(const char *condition) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetCondition, (const char *),
+ condition);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -140,16 +171,21 @@ void SBBreakpointLocation::SetCondition(const char *condition) {
}
const char *SBBreakpointLocation::GetCondition() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointLocation, GetCondition);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
loc_sp->GetTarget().GetAPIMutex());
return loc_sp->GetConditionText();
}
- return NULL;
+ return nullptr;
}
void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetAutoContinue, (bool),
+ auto_continue);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -159,6 +195,8 @@ void SBBreakpointLocation::SetAutoContinue(bool auto_continue) {
}
bool SBBreakpointLocation::GetAutoContinue() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, GetAutoContinue);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -170,10 +208,10 @@ bool SBBreakpointLocation::GetAutoContinue() {
void SBBreakpointLocation::SetScriptCallbackFunction(
const char *callback_function_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction,
+ (const char *), callback_function_name);
+
BreakpointLocationSP loc_sp = GetSP();
- LLDB_LOG(log, "location = {0}, callback = {1}", loc_sp.get(),
- callback_function_name);
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -182,7 +220,6 @@ void SBBreakpointLocation::SetScriptCallbackFunction(
loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(bp_options,
callback_function_name);
@@ -191,10 +228,10 @@ void SBBreakpointLocation::SetScriptCallbackFunction(
SBError
SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointLocation, SetScriptCallbackBody,
+ (const char *), callback_body_text);
+
BreakpointLocationSP loc_sp = GetSP();
- LLDB_LOG(log, "location = {0}: callback body:\n{1}", loc_sp.get(),
- callback_body_text);
SBError sb_error;
if (loc_sp) {
@@ -205,17 +242,19 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(bp_options, callback_body_text);
sb_error.SetError(error);
} else
sb_error.SetErrorString("invalid breakpoint");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetCommandLineCommands,
+ (lldb::SBStringList &), commands);
+
BreakpointLocationSP loc_sp = GetSP();
if (!loc_sp)
return;
@@ -231,6 +270,9 @@ void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) {
}
bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) {
+ LLDB_RECORD_METHOD(bool, SBBreakpointLocation, GetCommandLineCommands,
+ (lldb::SBStringList &), commands);
+
BreakpointLocationSP loc_sp = GetSP();
if (!loc_sp)
return false;
@@ -243,6 +285,9 @@ bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) {
}
void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadID, (lldb::tid_t),
+ thread_id);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -252,6 +297,8 @@ void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
}
tid_t SBBreakpointLocation::GetThreadID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointLocation, GetThreadID);
+
tid_t tid = LLDB_INVALID_THREAD_ID;
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
@@ -263,6 +310,9 @@ tid_t SBBreakpointLocation::GetThreadID() {
}
void SBBreakpointLocation::SetThreadIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadIndex, (uint32_t),
+ index);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -272,6 +322,9 @@ void SBBreakpointLocation::SetThreadIndex(uint32_t index) {
}
uint32_t SBBreakpointLocation::GetThreadIndex() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointLocation,
+ GetThreadIndex);
+
uint32_t thread_idx = UINT32_MAX;
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
@@ -283,6 +336,9 @@ uint32_t SBBreakpointLocation::GetThreadIndex() const {
}
void SBBreakpointLocation::SetThreadName(const char *thread_name) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetThreadName, (const char *),
+ thread_name);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -292,16 +348,22 @@ void SBBreakpointLocation::SetThreadName(const char *thread_name) {
}
const char *SBBreakpointLocation::GetThreadName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointLocation,
+ GetThreadName);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
loc_sp->GetTarget().GetAPIMutex());
return loc_sp->GetThreadName();
}
- return NULL;
+ return nullptr;
}
void SBBreakpointLocation::SetQueueName(const char *queue_name) {
+ LLDB_RECORD_METHOD(void, SBBreakpointLocation, SetQueueName, (const char *),
+ queue_name);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -311,16 +373,21 @@ void SBBreakpointLocation::SetQueueName(const char *queue_name) {
}
const char *SBBreakpointLocation::GetQueueName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointLocation,
+ GetQueueName);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
loc_sp->GetTarget().GetAPIMutex());
loc_sp->GetQueueName();
}
- return NULL;
+ return nullptr;
}
bool SBBreakpointLocation::IsResolved() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointLocation, IsResolved);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -338,6 +405,10 @@ void SBBreakpointLocation::SetLocation(
bool SBBreakpointLocation::GetDescription(SBStream &description,
DescriptionLevel level) {
+ LLDB_RECORD_METHOD(bool, SBBreakpointLocation, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ level);
+
Stream &strm = description.ref();
BreakpointLocationSP loc_sp = GetSP();
@@ -353,6 +424,8 @@ bool SBBreakpointLocation::GetDescription(SBStream &description,
}
break_id_t SBBreakpointLocation::GetID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::break_id_t, SBBreakpointLocation, GetID);
+
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -363,7 +436,9 @@ break_id_t SBBreakpointLocation::GetID() {
}
SBBreakpoint SBBreakpointLocation::GetBreakpoint() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBreakpoint, SBBreakpointLocation,
+ GetBreakpoint);
+
BreakpointLocationSP loc_sp = GetSP();
SBBreakpoint sb_bp;
@@ -373,11 +448,68 @@ SBBreakpoint SBBreakpointLocation::GetBreakpoint() {
sb_bp = loc_sp->GetBreakpoint().shared_from_this();
}
- if (log) {
- SBStream sstr;
- sb_bp.GetDescription(sstr);
- LLDB_LOG(log, "location = {0}, breakpoint = {1} ({2})", loc_sp.get(),
- sb_bp.GetSP().get(), sstr.GetData());
- }
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBBreakpointLocation>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation,
+ (const lldb::BreakpointLocationSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointLocation,
+ (const lldb::SBBreakpointLocation &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBBreakpointLocation &,
+ SBBreakpointLocation, operator=,(const lldb::SBBreakpointLocation &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointLocation, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointLocation, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBBreakpointLocation, GetAddress, ());
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBBreakpointLocation, GetLoadAddress,
+ ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetEnabled, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, IsEnabled, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBBreakpointLocation, GetHitCount, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBBreakpointLocation, GetIgnoreCount, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetIgnoreCount,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCondition,
+ (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBBreakpointLocation, GetCondition, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetAutoContinue, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetAutoContinue, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetScriptCallbackFunction,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointLocation,
+ SetScriptCallbackBody, (const char *));
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetCommandLineCommands,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetCommandLineCommands,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadID,
+ (lldb::tid_t));
+ LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointLocation, GetThreadID, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointLocation, GetThreadIndex,
+ ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetThreadName,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointLocation,
+ GetThreadName, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointLocation, SetQueueName,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointLocation, GetQueueName,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, IsResolved, ());
+ LLDB_REGISTER_METHOD(bool, SBBreakpointLocation, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(lldb::break_id_t, SBBreakpointLocation, GetID, ());
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBBreakpointLocation,
+ GetBreakpoint, ());
+}
+
+}
}
diff --git a/source/API/SBBreakpointName.cpp b/source/API/SBBreakpointName.cpp
index 47bddd752346c..1c794fca8ca5a 100644
--- a/source/API/SBBreakpointName.cpp
+++ b/source/API/SBBreakpointName.cpp
@@ -1,13 +1,13 @@
//===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBBreakpointName.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
@@ -21,7 +21,6 @@
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadSpec.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "SBBreakpointOptionCommon.h"
@@ -37,10 +36,10 @@ public:
if (!name || name[0] == '\0')
return;
m_name.assign(name);
-
+
if (!target_sp)
return;
-
+
m_target_wp = target_sp;
}
@@ -50,15 +49,15 @@ public:
// For now we take a simple approach and only keep the name, and relook up
// the location when we need it.
-
+
TargetSP GetTarget() const {
return m_target_wp.lock();
}
-
+
const char *GetName() const {
return m_name.c_str();
}
-
+
bool IsValid() const {
return !m_name.empty() && m_target_wp.lock();
}
@@ -106,10 +105,14 @@ lldb_private::BreakpointName *SBBreakpointNameImpl::GetBreakpointName() const {
} // namespace lldb
-SBBreakpointName::SBBreakpointName() {}
+SBBreakpointName::SBBreakpointName() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBreakpointName);
+}
+
+SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *),
+ sb_target, name);
-SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name)
-{
m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name));
// Call FindBreakpointName here to make sure the name is valid, reset if not:
BreakpointName *bp_name = GetBreakpointName();
@@ -117,8 +120,10 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name)
m_impl_up.reset();
}
-SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name)
-{
+SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpointName,
+ (lldb::SBBreakpoint &, const char *), sb_bkpt, name);
+
if (!sb_bkpt.IsValid()) {
m_impl_up.reset();
return;
@@ -127,21 +132,23 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name)
Target &target = bkpt_sp->GetTarget();
m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name));
-
+
// Call FindBreakpointName here to make sure the name is valid, reset if not:
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name) {
m_impl_up.reset();
return;
}
-
+
// Now copy over the breakpoint's options:
target.ConfigureBreakpointName(*bp_name, *bkpt_sp->GetOptions(),
BreakpointName::Permissions());
}
-SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs)
-{
+SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) {
+ LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (const lldb::SBBreakpointName &),
+ rhs);
+
if (!rhs.m_impl_up)
return;
else
@@ -151,46 +158,63 @@ SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs)
SBBreakpointName::~SBBreakpointName() = default;
-const SBBreakpointName &SBBreakpointName::operator=(const SBBreakpointName &rhs)
-{
+const SBBreakpointName &SBBreakpointName::
+operator=(const SBBreakpointName &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBBreakpointName &,
+ SBBreakpointName, operator=,(const lldb::SBBreakpointName &), rhs);
+
if (!rhs.m_impl_up) {
m_impl_up.reset();
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-
+
m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
rhs.m_impl_up->GetName()));
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &), rhs);
+
return *m_impl_up == *rhs.m_impl_up;
}
bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &), rhs);
+
return *m_impl_up != *rhs.m_impl_up;
}
bool SBBreakpointName::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsValid);
+ return this->operator bool();
+}
+SBBreakpointName::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, operator bool);
+
if (!m_impl_up)
return false;
return m_impl_up->IsValid();
}
const char *SBBreakpointName::GetName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName, GetName);
+
if (!m_impl_up)
return "<Invalid Breakpoint Name Object>";
return m_impl_up->GetName();
}
void SBBreakpointName::SetEnabled(bool enable) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetEnabled, (bool), enable);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} enabled: {1}\n", bp_name->GetName(), enable);
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -209,13 +233,12 @@ void SBBreakpointName::UpdateName(BreakpointName &bp_name) {
}
bool SBBreakpointName::IsEnabled() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, IsEnabled);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -223,13 +246,12 @@ bool SBBreakpointName::IsEnabled() {
}
void SBBreakpointName::SetOneShot(bool one_shot) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetOneShot, (bool), one_shot);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} one_shot: {1}\n", bp_name->GetName(), one_shot);
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -238,13 +260,12 @@ void SBBreakpointName::SetOneShot(bool one_shot) {
}
bool SBBreakpointName::IsOneShot() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, IsOneShot);
+
const BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -252,13 +273,12 @@ bool SBBreakpointName::IsOneShot() const {
}
void SBBreakpointName::SetIgnoreCount(uint32_t count) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t), count);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} one_shot: {1}\n", bp_name->GetName(), count);
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -267,13 +287,12 @@ void SBBreakpointName::SetIgnoreCount(uint32_t count) {
}
uint32_t SBBreakpointName::GetIgnoreCount() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetIgnoreCount);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -281,15 +300,13 @@ uint32_t SBBreakpointName::GetIgnoreCount() const {
}
void SBBreakpointName::SetCondition(const char *condition) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetCondition, (const char *),
+ condition);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} one_shot: {1}\n", bp_name->GetName(),
- condition ? condition : "<NULL>");
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -298,13 +315,12 @@ void SBBreakpointName::SetCondition(const char *condition) {
}
const char *SBBreakpointName::GetCondition() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBBreakpointName, GetCondition);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return nullptr;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -312,14 +328,13 @@ const char *SBBreakpointName::GetCondition() {
}
void SBBreakpointName::SetAutoContinue(bool auto_continue) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetAutoContinue, (bool),
+ auto_continue);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} auto-continue: {1}\n", bp_name->GetName(), auto_continue);
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -328,13 +343,12 @@ void SBBreakpointName::SetAutoContinue(bool auto_continue) {
}
bool SBBreakpointName::GetAutoContinue() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAutoContinue);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -342,14 +356,12 @@ bool SBBreakpointName::GetAutoContinue() {
}
void SBBreakpointName::SetThreadID(tid_t tid) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t), tid);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} tid: {1:x}\n", bp_name->GetName(), tid);
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -358,13 +370,12 @@ void SBBreakpointName::SetThreadID(tid_t tid) {
}
tid_t SBBreakpointName::GetThreadID() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBBreakpointName, GetThreadID);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return LLDB_INVALID_THREAD_ID;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -372,14 +383,12 @@ tid_t SBBreakpointName::GetThreadID() {
}
void SBBreakpointName::SetThreadIndex(uint32_t index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t), index);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} thread index: {1}\n", bp_name->GetName(), index);
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -388,13 +397,12 @@ void SBBreakpointName::SetThreadIndex(uint32_t index) {
}
uint32_t SBBreakpointName::GetThreadIndex() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBBreakpointName, GetThreadIndex);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return LLDB_INVALID_THREAD_ID;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -402,14 +410,13 @@ uint32_t SBBreakpointName::GetThreadIndex() const {
}
void SBBreakpointName::SetThreadName(const char *thread_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetThreadName, (const char *),
+ thread_name);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} thread name: {1}\n", bp_name->GetName(), thread_name);
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -418,13 +425,13 @@ void SBBreakpointName::SetThreadName(const char *thread_name) {
}
const char *SBBreakpointName::GetThreadName() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName,
+ GetThreadName);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return nullptr;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -432,14 +439,13 @@ const char *SBBreakpointName::GetThreadName() const {
}
void SBBreakpointName::SetQueueName(const char *queue_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetQueueName, (const char *),
+ queue_name);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} queue name: {1}\n", bp_name->GetName(), queue_name);
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -448,13 +454,13 @@ void SBBreakpointName::SetQueueName(const char *queue_name) {
}
const char *SBBreakpointName::GetQueueName() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName,
+ GetQueueName);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return nullptr;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -462,14 +468,15 @@ const char *SBBreakpointName::GetQueueName() const {
}
void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetCommandLineCommands,
+ (lldb::SBStringList &), commands);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
if (commands.GetSize() == 0)
return;
- LLDB_LOG(log, "Name: {0} commands\n", bp_name->GetName());
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -481,13 +488,13 @@ void SBBreakpointName::SetCommandLineCommands(SBStringList &commands) {
}
bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(bool, SBBreakpointName, GetCommandLineCommands,
+ (lldb::SBStringList &), commands);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
StringList command_list;
bool has_commands =
bp_name->GetOptions().GetCommandLineCallbacks(command_list);
@@ -497,23 +504,24 @@ bool SBBreakpointName::GetCommandLineCommands(SBStringList &commands) {
}
const char *SBBreakpointName::GetHelpString() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBreakpointName,
+ GetHelpString);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return "";
-
- LLDB_LOG(log, "Help: {0}\n", bp_name->GetHelp());
+
return bp_name->GetHelp();
}
void SBBreakpointName::SetHelpString(const char *help_string) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetHelpString, (const char *),
+ help_string);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
- LLDB_LOG(log, "Name: {0} help: {1}\n", bp_name->GetName(), help_string);
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -521,16 +529,16 @@ void SBBreakpointName::SetHelpString(const char *help_string) {
}
bool SBBreakpointName::GetDescription(SBStream &s) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(bool, SBBreakpointName, GetDescription, (lldb::SBStream &),
+ s);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
{
s.Printf("No value");
return false;
}
-
- LLDB_LOG(log, "Name: {0}\n", bp_name->GetName());
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
bp_name->GetDescription(s.get(), eDescriptionLevelFull);
@@ -539,11 +547,12 @@ bool SBBreakpointName::GetDescription(SBStream &s) {
void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback,
void *baton) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_DUMMY(void, SBBreakpointName, SetCallback,
+ (lldb::SBBreakpointHitCallback, void *), callback, baton);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
- LLDB_LOG(log, "callback = {1}, baton = {2}", callback, baton);
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -557,39 +566,35 @@ void SBBreakpointName::SetCallback(SBBreakpointHitCallback callback,
void SBBreakpointName::SetScriptCallbackFunction(
const char *callback_function_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
+ (const char *), callback_function_name);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
-
- LLDB_LOG(log, "Name: {0} callback: {1}\n", bp_name->GetName(),
- callback_function_name);
-
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
BreakpointOptions &bp_options = bp_name->GetOptions();
m_impl_up->GetTarget()
->GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallbackFunction(&bp_options,
callback_function_name);
UpdateName(*bp_name);
}
-SBError SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+SBError
+SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody,
+ (const char *), callback_body_text);
+
SBError sb_error;
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
- return sb_error;
-
- LLDB_LOG(log, "Name: {0} callback: {1}\n", bp_name->GetName(),
- callback_body_text);
-
+ return LLDB_RECORD_RESULT(sb_error);
+
std::lock_guard<std::recursive_mutex> guard(
m_impl_up->GetTarget()->GetAPIMutex());
@@ -597,76 +602,68 @@ SBError SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text)
Status error =
m_impl_up->GetTarget()
->GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(&bp_options, callback_body_text);
sb_error.SetError(error);
if (!sb_error.Fail())
UpdateName(*bp_name);
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
-bool SBBreakpointName::GetAllowList() const
-{
+bool SBBreakpointName::GetAllowList() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBreakpointName, GetAllowList);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
return bp_name->GetPermissions().GetAllowList();
}
-void SBBreakpointName::SetAllowList(bool value)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+void SBBreakpointName::SetAllowList(bool value) {
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowList, (bool), value);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
- if (log)
- log->Printf("Setting allow list to %u for %s.", value,
- bp_name->GetName().AsCString());
bp_name->GetPermissions().SetAllowList(value);
}
-
-bool SBBreakpointName::GetAllowDelete()
-{
+
+bool SBBreakpointName::GetAllowDelete() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDelete);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
return bp_name->GetPermissions().GetAllowDelete();
}
-void SBBreakpointName::SetAllowDelete(bool value)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+void SBBreakpointName::SetAllowDelete(bool value) {
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDelete, (bool), value);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
- if (log)
- log->Printf("Setting allow delete to %u for %s.", value,
- bp_name->GetName().AsCString());
bp_name->GetPermissions().SetAllowDelete(value);
}
-
-bool SBBreakpointName::GetAllowDisable()
-{
+
+bool SBBreakpointName::GetAllowDisable() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBBreakpointName, GetAllowDisable);
+
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return false;
return bp_name->GetPermissions().GetAllowDisable();
}
-void SBBreakpointName::SetAllowDisable(bool value)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+void SBBreakpointName::SetAllowDisable(bool value) {
+ LLDB_RECORD_METHOD(void, SBBreakpointName, SetAllowDisable, (bool), value);
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
return;
- if (log)
- log->Printf("Setting allow disable to %u for %s.", value,
- bp_name->GetName().AsCString());
bp_name->GetPermissions().SetAllowDisable(value);
}
@@ -677,3 +674,69 @@ lldb_private::BreakpointName *SBBreakpointName::GetBreakpointName() const
return m_impl_up->GetBreakpointName();
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBBreakpointName>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName,
+ (lldb::SBTarget &, const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName,
+ (lldb::SBBreakpoint &, const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBBreakpointName,
+ (const lldb::SBBreakpointName &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBBreakpointName &,
+ SBBreakpointName, operator=,(const lldb::SBBreakpointName &));
+ LLDB_REGISTER_METHOD(
+ bool, SBBreakpointName, operator==,(const lldb::SBBreakpointName &));
+ LLDB_REGISTER_METHOD(
+ bool, SBBreakpointName, operator!=,(const lldb::SBBreakpointName &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetName, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetEnabled, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointName, IsEnabled, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetOneShot, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, IsOneShot, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetIgnoreCount, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetIgnoreCount, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCondition, (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBBreakpointName, GetCondition, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAutoContinue, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAutoContinue, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadID, (lldb::tid_t));
+ LLDB_REGISTER_METHOD(lldb::tid_t, SBBreakpointName, GetThreadID, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadIndex, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBBreakpointName, GetThreadIndex, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetThreadName, (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetThreadName,
+ ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetQueueName, (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetQueueName,
+ ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetCommandLineCommands,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetCommandLineCommands,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBreakpointName, GetHelpString,
+ ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetHelpString, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetScriptCallbackFunction,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpointName, SetScriptCallbackBody,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBreakpointName, GetAllowList, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowList, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDelete, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDelete, (bool));
+ LLDB_REGISTER_METHOD(bool, SBBreakpointName, GetAllowDisable, ());
+ LLDB_REGISTER_METHOD(void, SBBreakpointName, SetAllowDisable, (bool));
+}
+
+}
+}
diff --git a/source/API/SBBreakpointOptionCommon.cpp b/source/API/SBBreakpointOptionCommon.cpp
index c0618adb238a3..058b3e0398cd5 100644
--- a/source/API/SBBreakpointOptionCommon.cpp
+++ b/source/API/SBBreakpointOptionCommon.cpp
@@ -1,9 +1,8 @@
-//===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===//
+//===-- SBBreakpointOptionCommon.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/API/SBBreakpointOptionCommon.h b/source/API/SBBreakpointOptionCommon.h
index fe276ac636fef..52049e4e7588c 100644
--- a/source/API/SBBreakpointOptionCommon.h
+++ b/source/API/SBBreakpointOptionCommon.h
@@ -1,9 +1,8 @@
//===-- SBBreakpointOptionCommon.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,7 +24,7 @@ public:
SBBreakpointCallbackBaton(SBBreakpointHitCallback callback,
void *baton);
- ~SBBreakpointCallbackBaton();
+ ~SBBreakpointCallbackBaton() override;
static bool PrivateBreakpointHitCallback(void *baton,
lldb_private::StoppointCallbackContext *ctx,
diff --git a/source/API/SBBroadcaster.cpp b/source/API/SBBroadcaster.cpp
index 7868c38a818ab..e1efdf7baf61f 100644
--- a/source/API/SBBroadcaster.cpp
+++ b/source/API/SBBroadcaster.cpp
@@ -1,14 +1,13 @@
//===-- SBBroadcaster.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "SBReproducerPrivate.h"
#include "lldb/Utility/Broadcaster.h"
-#include "lldb/Utility/Log.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBEvent.h"
@@ -17,44 +16,44 @@
using namespace lldb;
using namespace lldb_private;
-SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(NULL) {}
+SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster);
+}
SBBroadcaster::SBBroadcaster(const char *name)
- : m_opaque_sp(new Broadcaster(NULL, name)), m_opaque_ptr(NULL) {
+ : m_opaque_sp(new Broadcaster(nullptr, name)), m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const char *), name);
+
m_opaque_ptr = m_opaque_sp.get();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOGV(log, "(name=\"{0}\") => SBBroadcaster({1})", name, m_opaque_ptr);
}
SBBroadcaster::SBBroadcaster(lldb_private::Broadcaster *broadcaster, bool owns)
- : m_opaque_sp(owns ? broadcaster : NULL), m_opaque_ptr(broadcaster) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOGV(log, "(broadcaster={0}, owns={1}) => SBBroadcaster({2})",
- broadcaster, owns, m_opaque_ptr);
-}
+ : m_opaque_sp(owns ? broadcaster : nullptr), m_opaque_ptr(broadcaster) {}
SBBroadcaster::SBBroadcaster(const SBBroadcaster &rhs)
- : m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) {}
+ : m_opaque_sp(rhs.m_opaque_sp), m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBBroadcaster, (const lldb::SBBroadcaster &), rhs);
+}
const SBBroadcaster &SBBroadcaster::operator=(const SBBroadcaster &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBBroadcaster &,
+ SBBroadcaster, operator=,(const lldb::SBBroadcaster &),
+ rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
m_opaque_ptr = rhs.m_opaque_ptr;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-SBBroadcaster::~SBBroadcaster() { reset(NULL, false); }
+SBBroadcaster::~SBBroadcaster() { reset(nullptr, false); }
void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBBroadcaster(%p)::BroadcastEventByType (event_type=0x%8.8x, "
- "unique=%i)",
- static_cast<void *>(m_opaque_ptr), event_type, unique);
+ LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEventByType,
+ (uint32_t, bool), event_type, unique);
- if (m_opaque_ptr == NULL)
+ if (m_opaque_ptr == nullptr)
return;
if (unique)
@@ -64,15 +63,10 @@ void SBBroadcaster::BroadcastEventByType(uint32_t event_type, bool unique) {
}
void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBBroadcaster, BroadcastEvent,
+ (const lldb::SBEvent &, bool), event, unique);
- if (log)
- log->Printf(
- "SBBroadcaster(%p)::BroadcastEventByType (SBEvent(%p), unique=%i)",
- static_cast<void *>(m_opaque_ptr), static_cast<void *>(event.get()),
- unique);
-
- if (m_opaque_ptr == NULL)
+ if (m_opaque_ptr == nullptr)
return;
EventSP event_sp = event.GetSP();
@@ -84,12 +78,10 @@ void SBBroadcaster::BroadcastEvent(const SBEvent &event, bool unique) {
void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener,
uint32_t requested_events) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBBroadcaster(%p)::AddInitialEventsToListener "
- "(SBListener(%p), event_mask=0x%8.8x)",
- static_cast<void *>(m_opaque_ptr),
- static_cast<void *>(listener.get()), requested_events);
+ LLDB_RECORD_METHOD(void, SBBroadcaster, AddInitialEventsToListener,
+ (const lldb::SBListener &, uint32_t), listener,
+ requested_events);
+
if (m_opaque_ptr)
m_opaque_ptr->AddInitialEventsToListener(listener.m_opaque_sp,
requested_events);
@@ -97,18 +89,27 @@ void SBBroadcaster::AddInitialEventsToListener(const SBListener &listener,
uint32_t SBBroadcaster::AddListener(const SBListener &listener,
uint32_t event_mask) {
+ LLDB_RECORD_METHOD(uint32_t, SBBroadcaster, AddListener,
+ (const lldb::SBListener &, uint32_t), listener,
+ event_mask);
+
if (m_opaque_ptr)
return m_opaque_ptr->AddListener(listener.m_opaque_sp, event_mask);
return 0;
}
const char *SBBroadcaster::GetName() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBBroadcaster, GetName);
+
if (m_opaque_ptr)
return m_opaque_ptr->GetBroadcasterName().GetCString();
- return NULL;
+ return nullptr;
}
bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) {
+ LLDB_RECORD_METHOD(bool, SBBroadcaster, EventTypeHasListeners, (uint32_t),
+ event_type);
+
if (m_opaque_ptr)
return m_opaque_ptr->EventTypeHasListeners(event_type);
return false;
@@ -116,6 +117,10 @@ bool SBBroadcaster::EventTypeHasListeners(uint32_t event_type) {
bool SBBroadcaster::RemoveListener(const SBListener &listener,
uint32_t event_mask) {
+ LLDB_RECORD_METHOD(bool, SBBroadcaster, RemoveListener,
+ (const lldb::SBListener &, uint32_t), listener,
+ event_mask);
+
if (m_opaque_ptr)
return m_opaque_ptr->RemoveListener(listener.m_opaque_sp, event_mask);
return false;
@@ -131,21 +136,78 @@ void SBBroadcaster::reset(Broadcaster *broadcaster, bool owns) {
m_opaque_ptr = broadcaster;
}
-bool SBBroadcaster::IsValid() const { return m_opaque_ptr != NULL; }
+bool SBBroadcaster::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, IsValid);
+ return this->operator bool();
+}
+SBBroadcaster::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBBroadcaster, operator bool);
+
+ return m_opaque_ptr != nullptr;
+}
void SBBroadcaster::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBBroadcaster, Clear);
+
m_opaque_sp.reset();
- m_opaque_ptr = NULL;
+ m_opaque_ptr = nullptr;
}
bool SBBroadcaster::operator==(const SBBroadcaster &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBBroadcaster, operator==,(const lldb::SBBroadcaster &), rhs);
+
return m_opaque_ptr == rhs.m_opaque_ptr;
}
bool SBBroadcaster::operator!=(const SBBroadcaster &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBBroadcaster, operator!=,(const lldb::SBBroadcaster &), rhs);
+
return m_opaque_ptr != rhs.m_opaque_ptr;
}
bool SBBroadcaster::operator<(const SBBroadcaster &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBBroadcaster, operator<,(const lldb::SBBroadcaster &), rhs);
+
return m_opaque_ptr < rhs.m_opaque_ptr;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBBroadcaster>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, (const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBBroadcaster, (const lldb::SBBroadcaster &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBBroadcaster &,
+ SBBroadcaster, operator=,(const lldb::SBBroadcaster &));
+ LLDB_REGISTER_METHOD(void, SBBroadcaster, BroadcastEventByType,
+ (uint32_t, bool));
+ LLDB_REGISTER_METHOD(void, SBBroadcaster, BroadcastEvent,
+ (const lldb::SBEvent &, bool));
+ LLDB_REGISTER_METHOD(void, SBBroadcaster, AddInitialEventsToListener,
+ (const lldb::SBListener &, uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBBroadcaster, AddListener,
+ (const lldb::SBListener &, uint32_t));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBBroadcaster, GetName, ());
+ LLDB_REGISTER_METHOD(bool, SBBroadcaster, EventTypeHasListeners,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBBroadcaster, RemoveListener,
+ (const lldb::SBListener &, uint32_t));
+ LLDB_REGISTER_METHOD_CONST(bool, SBBroadcaster, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBBroadcaster, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBBroadcaster, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBBroadcaster, operator==,(const lldb::SBBroadcaster &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBBroadcaster, operator!=,(const lldb::SBBroadcaster &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBBroadcaster, operator<,(const lldb::SBBroadcaster &));
+}
+
+}
+}
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index 2a06e608c0b94..c07dffce0baaf 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -1,14 +1,14 @@
//===-- SBCommandInterpreter.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/lldb-types.h"
+#include "SBReproducerPrivate.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandObjectMultiword.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -26,68 +26,114 @@
#include "lldb/API/SBStringList.h"
#include "lldb/API/SBTarget.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions);
+
m_opaque_up.reset(new CommandInterpreterRunOptions());
}
SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
bool SBCommandInterpreterRunOptions::GetStopOnContinue() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetStopOnContinue);
+
return m_opaque_up->GetStopOnContinue();
}
void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue,
+ (bool), stop_on_continue);
+
m_opaque_up->SetStopOnContinue(stop_on_continue);
}
bool SBCommandInterpreterRunOptions::GetStopOnError() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetStopOnError);
+
return m_opaque_up->GetStopOnError();
}
void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
+ (bool), stop_on_error);
+
m_opaque_up->SetStopOnError(stop_on_error);
}
bool SBCommandInterpreterRunOptions::GetStopOnCrash() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetStopOnCrash);
+
return m_opaque_up->GetStopOnCrash();
}
void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
+ (bool), stop_on_crash);
+
m_opaque_up->SetStopOnCrash(stop_on_crash);
}
bool SBCommandInterpreterRunOptions::GetEchoCommands() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommands);
+
return m_opaque_up->GetEchoCommands();
}
void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
+ (bool), echo_commands);
+
m_opaque_up->SetEchoCommands(echo_commands);
}
bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommentCommands);
+
return m_opaque_up->GetEchoCommentCommands();
}
void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions,
+ SetEchoCommentCommands, (bool), echo);
+
m_opaque_up->SetEchoCommentCommands(echo);
}
bool SBCommandInterpreterRunOptions::GetPrintResults() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetPrintResults);
+
return m_opaque_up->GetPrintResults();
}
void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
+ (bool), print_results);
+
m_opaque_up->SetPrintResults(print_results);
}
bool SBCommandInterpreterRunOptions::GetAddToHistory() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions,
+ GetAddToHistory);
+
return m_opaque_up->GetAddToHistory();
}
void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
+ (bool), add_to_history);
+
m_opaque_up->SetAddToHistory(add_to_history);
}
@@ -129,47 +175,72 @@ protected:
SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter)
: m_opaque_ptr(interpreter) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter,
+ (lldb_private::CommandInterpreter *), interpreter);
- if (log)
- log->Printf("SBCommandInterpreter::SBCommandInterpreter (interpreter=%p)"
- " => SBCommandInterpreter(%p)",
- static_cast<void *>(interpreter),
- static_cast<void *>(m_opaque_ptr));
}
SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs)
- : m_opaque_ptr(rhs.m_opaque_ptr) {}
+ : m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreter,
+ (const lldb::SBCommandInterpreter &), rhs);
+}
SBCommandInterpreter::~SBCommandInterpreter() = default;
const SBCommandInterpreter &SBCommandInterpreter::
operator=(const SBCommandInterpreter &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBCommandInterpreter &,
+ SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &),
+ rhs);
+
m_opaque_ptr = rhs.m_opaque_ptr;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-bool SBCommandInterpreter::IsValid() const { return m_opaque_ptr != nullptr; }
+bool SBCommandInterpreter::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, IsValid);
+ return this->operator bool();
+}
+SBCommandInterpreter::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, operator bool);
+
+ return m_opaque_ptr != nullptr;
+}
bool SBCommandInterpreter::CommandExists(const char *cmd) {
+ LLDB_RECORD_METHOD(bool, SBCommandInterpreter, CommandExists, (const char *),
+ cmd);
+
return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd)
: false);
}
bool SBCommandInterpreter::AliasExists(const char *cmd) {
+ LLDB_RECORD_METHOD(bool, SBCommandInterpreter, AliasExists, (const char *),
+ cmd);
+
return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd)
: false);
}
bool SBCommandInterpreter::IsActive() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, IsActive);
+
return (IsValid() ? m_opaque_ptr->IsActive() : false);
}
bool SBCommandInterpreter::WasInterrupted() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreter, WasInterrupted);
+
return (IsValid() ? m_opaque_ptr->WasInterrupted() : false);
}
const char *SBCommandInterpreter::GetIOHandlerControlSequence(char ch) {
+ LLDB_RECORD_METHOD(const char *, SBCommandInterpreter,
+ GetIOHandlerControlSequence, (char), ch);
+
return (IsValid()
? m_opaque_ptr->GetDebugger()
.GetTopIOHandlerControlSequence(ch)
@@ -181,6 +252,10 @@ lldb::ReturnStatus
SBCommandInterpreter::HandleCommand(const char *command_line,
SBCommandReturnObject &result,
bool add_to_history) {
+ LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand,
+ (const char *, lldb::SBCommandReturnObject &, bool),
+ command_line, result, add_to_history);
+
SBExecutionContext sb_exe_ctx;
return HandleCommand(command_line, sb_exe_ctx, result, add_to_history);
}
@@ -188,13 +263,11 @@ SBCommandInterpreter::HandleCommand(const char *command_line,
lldb::ReturnStatus SBCommandInterpreter::HandleCommand(
const char *command_line, SBExecutionContext &override_context,
SBCommandReturnObject &result, bool add_to_history) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::ReturnStatus, SBCommandInterpreter, HandleCommand,
+ (const char *, lldb::SBExecutionContext &,
+ lldb::SBCommandReturnObject &, bool),
+ command_line, override_context, result, add_to_history);
- if (log)
- log->Printf("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", "
- "SBCommandReturnObject(%p), add_to_history=%i)",
- static_cast<void *>(m_opaque_ptr), command_line,
- static_cast<void *>(result.get()), add_to_history);
ExecutionContext ctx, *ctx_ptr;
if (override_context.get()) {
@@ -215,17 +288,6 @@ lldb::ReturnStatus SBCommandInterpreter::HandleCommand(
result->SetStatus(eReturnStatusFailed);
}
- // We need to get the value again, in case the command disabled the log!
- log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
- if (log) {
- SBStream sstr;
- result.GetDescription(sstr);
- log->Printf("SBCommandInterpreter(%p)::HandleCommand (command=\"%s\", "
- "SBCommandReturnObject(%p): %s, add_to_history=%i) => %i",
- static_cast<void *>(m_opaque_ptr), command_line,
- static_cast<void *>(result.get()), sstr.GetData(),
- add_to_history, result.GetStatus());
- }
return result.GetStatus();
}
@@ -234,16 +296,11 @@ void SBCommandInterpreter::HandleCommandsFromFile(
lldb::SBFileSpec &file, lldb::SBExecutionContext &override_context,
lldb::SBCommandInterpreterRunOptions &options,
lldb::SBCommandReturnObject result) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log) {
- SBStream s;
- file.GetDescription(s);
- log->Printf("SBCommandInterpreter(%p)::HandleCommandsFromFile "
- "(file=\"%s\", SBCommandReturnObject(%p))",
- static_cast<void *>(m_opaque_ptr), s.GetData(),
- static_cast<void *>(result.get()));
- }
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile,
+ (lldb::SBFileSpec &, lldb::SBExecutionContext &,
+ lldb::SBCommandInterpreterRunOptions &,
+ lldb::SBCommandReturnObject),
+ file, override_context, options, result);
if (!IsValid()) {
result->AppendError("SBCommandInterpreter is not valid.");
@@ -273,6 +330,12 @@ void SBCommandInterpreter::HandleCommandsFromFile(
int SBCommandInterpreter::HandleCompletion(
const char *current_line, const char *cursor, const char *last_char,
int match_start_point, int max_return_elements, SBStringList &matches) {
+ LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion,
+ (const char *, const char *, const char *, int, int,
+ lldb::SBStringList &),
+ current_line, cursor, last_char, match_start_point,
+ max_return_elements, matches);
+
SBStringList dummy_descriptions;
return HandleCompletionWithDescriptions(
current_line, cursor, last_char, match_start_point, max_return_elements,
@@ -283,7 +346,13 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
const char *current_line, const char *cursor, const char *last_char,
int match_start_point, int max_return_elements, SBStringList &matches,
SBStringList &descriptions) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(int, SBCommandInterpreter,
+ HandleCompletionWithDescriptions,
+ (const char *, const char *, const char *, int, int,
+ lldb::SBStringList &, lldb::SBStringList &),
+ current_line, cursor, last_char, match_start_point,
+ max_return_elements, matches, descriptions);
+
int num_completions = 0;
// Sanity check the arguments that are passed in: cursor & last_char have to
@@ -299,15 +368,6 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
last_char - current_line > static_cast<ptrdiff_t>(current_line_size))
return 0;
- if (log)
- log->Printf("SBCommandInterpreter(%p)::HandleCompletion "
- "(current_line=\"%s\", cursor at: %" PRId64
- ", last char at: %" PRId64
- ", match_start_point: %d, max_return_elements: %d)",
- static_cast<void *>(m_opaque_ptr), current_line,
- static_cast<uint64_t>(cursor - current_line),
- static_cast<uint64_t>(last_char - current_line),
- match_start_point, max_return_elements);
if (IsValid()) {
lldb_private::StringList lldb_matches, lldb_descriptions;
@@ -320,10 +380,6 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
SBStringList temp_descriptions_list(&lldb_descriptions);
descriptions.AppendList(temp_descriptions_list);
}
- if (log)
- log->Printf(
- "SBCommandInterpreter(%p)::HandleCompletion - Found %d completions.",
- static_cast<void *>(m_opaque_ptr), num_completions);
return num_completions;
}
@@ -332,6 +388,13 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
const char *current_line, uint32_t cursor_pos, int match_start_point,
int max_return_elements, SBStringList &matches,
SBStringList &descriptions) {
+ LLDB_RECORD_METHOD(int, SBCommandInterpreter,
+ HandleCompletionWithDescriptions,
+ (const char *, uint32_t, int, int, lldb::SBStringList &,
+ lldb::SBStringList &),
+ current_line, cursor_pos, match_start_point,
+ max_return_elements, matches, descriptions);
+
const char *cursor = current_line + cursor_pos;
const char *last_char = current_line + strlen(current_line);
return HandleCompletionWithDescriptions(
@@ -344,6 +407,11 @@ int SBCommandInterpreter::HandleCompletion(const char *current_line,
int match_start_point,
int max_return_elements,
lldb::SBStringList &matches) {
+ LLDB_RECORD_METHOD(int, SBCommandInterpreter, HandleCompletion,
+ (const char *, uint32_t, int, int, lldb::SBStringList &),
+ current_line, cursor_pos, match_start_point,
+ max_return_elements, matches);
+
const char *cursor = current_line + cursor_pos;
const char *last_char = current_line + strlen(current_line);
return HandleCompletion(current_line, cursor, last_char, match_start_point,
@@ -351,18 +419,26 @@ int SBCommandInterpreter::HandleCompletion(const char *current_line,
}
bool SBCommandInterpreter::HasCommands() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCommands);
+
return (IsValid() ? m_opaque_ptr->HasCommands() : false);
}
bool SBCommandInterpreter::HasAliases() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliases);
+
return (IsValid() ? m_opaque_ptr->HasAliases() : false);
}
bool SBCommandInterpreter::HasAliasOptions() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasAliasOptions);
+
return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false);
}
SBProcess SBCommandInterpreter::GetProcess() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBCommandInterpreter, GetProcess);
+
SBProcess sb_process;
ProcessSP process_sp;
if (IsValid()) {
@@ -373,45 +449,45 @@ SBProcess SBCommandInterpreter::GetProcess() {
sb_process.SetSP(process_sp);
}
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBCommandInterpreter(%p)::GetProcess () => SBProcess(%p)",
- static_cast<void *>(m_opaque_ptr),
- static_cast<void *>(process_sp.get()));
-
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
SBDebugger SBCommandInterpreter::GetDebugger() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDebugger, SBCommandInterpreter,
+ GetDebugger);
+
SBDebugger sb_debugger;
if (IsValid())
sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBCommandInterpreter(%p)::GetDebugger () => SBDebugger(%p)",
- static_cast<void *>(m_opaque_ptr),
- static_cast<void *>(sb_debugger.get()));
- return sb_debugger;
+ return LLDB_RECORD_RESULT(sb_debugger);
}
bool SBCommandInterpreter::GetPromptOnQuit() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, GetPromptOnQuit);
+
return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false);
}
void SBCommandInterpreter::SetPromptOnQuit(bool b) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool), b);
+
if (IsValid())
m_opaque_ptr->SetPromptOnQuit(b);
}
void SBCommandInterpreter::AllowExitCodeOnQuit(bool allow) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit, (bool),
+ allow);
+
if (m_opaque_ptr)
m_opaque_ptr->AllowExitCodeOnQuit(allow);
}
bool SBCommandInterpreter::HasCustomQuitExitCode() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandInterpreter, HasCustomQuitExitCode);
+
bool exited = false;
if (m_opaque_ptr)
m_opaque_ptr->GetQuitExitCode(exited);
@@ -419,12 +495,18 @@ bool SBCommandInterpreter::HasCustomQuitExitCode() {
}
int SBCommandInterpreter::GetQuitStatus() {
+ LLDB_RECORD_METHOD_NO_ARGS(int, SBCommandInterpreter, GetQuitStatus);
+
bool exited = false;
return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0);
}
void SBCommandInterpreter::ResolveCommand(const char *command_line,
SBCommandReturnObject &result) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter, ResolveCommand,
+ (const char *, lldb::SBCommandReturnObject &),
+ command_line, result);
+
result.Clear();
if (command_line && IsValid()) {
m_opaque_ptr->ResolveCommand(command_line, result.ref());
@@ -449,78 +531,83 @@ void SBCommandInterpreter::reset(
void SBCommandInterpreter::SourceInitFileInHomeDirectory(
SBCommandReturnObject &result) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter, SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &), result);
+
result.Clear();
if (IsValid()) {
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
- m_opaque_ptr->SourceInitFile(false, result.ref());
+ m_opaque_ptr->SourceInitFileHome(result.ref());
} else {
result->AppendError("SBCommandInterpreter is not valid");
result->SetStatus(eReturnStatusFailed);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBCommandInterpreter(%p)::SourceInitFileInHomeDirectory "
- "(&SBCommandReturnObject(%p))",
- static_cast<void *>(m_opaque_ptr),
- static_cast<void *>(result.get()));
}
void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory(
SBCommandReturnObject &result) {
+ LLDB_RECORD_METHOD(void, SBCommandInterpreter,
+ SourceInitFileInCurrentWorkingDirectory,
+ (lldb::SBCommandReturnObject &), result);
+
result.Clear();
if (IsValid()) {
TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget());
std::unique_lock<std::recursive_mutex> lock;
if (target_sp)
lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex());
- m_opaque_ptr->SourceInitFile(true, result.ref());
+ m_opaque_ptr->SourceInitFileCwd(result.ref());
} else {
result->AppendError("SBCommandInterpreter is not valid");
result->SetStatus(eReturnStatusFailed);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf(
- "SBCommandInterpreter(%p)::SourceInitFileInCurrentWorkingDirectory "
- "(&SBCommandReturnObject(%p))",
- static_cast<void *>(m_opaque_ptr), static_cast<void *>(result.get()));
}
SBBroadcaster SBCommandInterpreter::GetBroadcaster() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommandInterpreter,
+ GetBroadcaster);
+
SBBroadcaster broadcaster(m_opaque_ptr, false);
- if (log)
- log->Printf(
- "SBCommandInterpreter(%p)::GetBroadcaster() => SBBroadcaster(%p)",
- static_cast<void *>(m_opaque_ptr),
- static_cast<void *>(broadcaster.get()));
- return broadcaster;
+ return LLDB_RECORD_RESULT(broadcaster);
}
const char *SBCommandInterpreter::GetBroadcasterClass() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommandInterpreter,
+ GetBroadcasterClass);
+
return CommandInterpreter::GetStaticBroadcasterClass().AsCString();
}
const char *SBCommandInterpreter::GetArgumentTypeAsCString(
const lldb::CommandArgumentType arg_type) {
+ LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter,
+ GetArgumentTypeAsCString,
+ (const lldb::CommandArgumentType), arg_type);
+
return CommandObject::GetArgumentTypeAsCString(arg_type);
}
const char *SBCommandInterpreter::GetArgumentDescriptionAsCString(
const lldb::CommandArgumentType arg_type) {
+ LLDB_RECORD_STATIC_METHOD(const char *, SBCommandInterpreter,
+ GetArgumentDescriptionAsCString,
+ (const lldb::CommandArgumentType), arg_type);
+
return CommandObject::GetArgumentDescriptionAsCString(arg_type);
}
bool SBCommandInterpreter::EventIsCommandInterpreterEvent(
const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBCommandInterpreter,
+ EventIsCommandInterpreterEvent,
+ (const lldb::SBEvent &), event);
+
return event.GetBroadcasterClass() ==
SBCommandInterpreter::GetBroadcasterClass();
}
@@ -528,6 +615,10 @@ bool SBCommandInterpreter::EventIsCommandInterpreterEvent(
bool SBCommandInterpreter::SetCommandOverrideCallback(
const char *command_name, lldb::CommandOverrideCallback callback,
void *baton) {
+ LLDB_RECORD_DUMMY(bool, SBCommandInterpreter, SetCommandOverrideCallback,
+ (const char *, lldb::CommandOverrideCallback, void *),
+ command_name, callback, baton);
+
if (command_name && command_name[0] && IsValid()) {
llvm::StringRef command_name_str = command_name;
CommandObject *cmd_obj =
@@ -543,122 +634,310 @@ bool SBCommandInterpreter::SetCommandOverrideCallback(
lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand(const char *name,
const char *help) {
+ LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddMultiwordCommand,
+ (const char *, const char *), name, help);
+
CommandObjectMultiword *new_command =
new CommandObjectMultiword(*m_opaque_ptr, name, help);
new_command->SetRemovable(true);
lldb::CommandObjectSP new_command_sp(new_command);
if (new_command_sp &&
m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
- return lldb::SBCommand(new_command_sp);
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
}
lldb::SBCommand SBCommandInterpreter::AddCommand(
const char *name, lldb::SBCommandPluginInterface *impl, const char *help) {
+ LLDB_RECORD_METHOD(
+ lldb::SBCommand, SBCommandInterpreter, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *, const char *), name,
+ impl, help);
+
lldb::CommandObjectSP new_command_sp;
- new_command_sp.reset(new CommandPluginInterfaceImplementation(
- *m_opaque_ptr, name, impl, help));
+ new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
+ *m_opaque_ptr, name, impl, help);
if (new_command_sp &&
m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
- return lldb::SBCommand(new_command_sp);
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
}
lldb::SBCommand
SBCommandInterpreter::AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help, const char *syntax) {
+ LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *),
+ name, impl, help, syntax);
+
lldb::CommandObjectSP new_command_sp;
- new_command_sp.reset(new CommandPluginInterfaceImplementation(
- *m_opaque_ptr, name, impl, help, syntax));
+ new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
+ *m_opaque_ptr, name, impl, help, syntax);
if (new_command_sp &&
m_opaque_ptr->AddUserCommand(name, new_command_sp, true))
- return lldb::SBCommand(new_command_sp);
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
}
-SBCommand::SBCommand() = default;
+SBCommand::SBCommand() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommand); }
SBCommand::SBCommand(lldb::CommandObjectSP cmd_sp) : m_opaque_sp(cmd_sp) {}
-bool SBCommand::IsValid() { return m_opaque_sp.get() != nullptr; }
+bool SBCommand::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommand, IsValid);
+ return this->operator bool();
+}
+SBCommand::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommand, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
const char *SBCommand::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetName);
+
return (IsValid() ? ConstString(m_opaque_sp->GetCommandName()).AsCString() : nullptr);
}
const char *SBCommand::GetHelp() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelp);
+
return (IsValid() ? ConstString(m_opaque_sp->GetHelp()).AsCString()
: nullptr);
}
const char *SBCommand::GetHelpLong() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommand, GetHelpLong);
+
return (IsValid() ? ConstString(m_opaque_sp->GetHelpLong()).AsCString()
: nullptr);
}
void SBCommand::SetHelp(const char *help) {
+ LLDB_RECORD_METHOD(void, SBCommand, SetHelp, (const char *), help);
+
if (IsValid())
m_opaque_sp->SetHelp(help);
}
void SBCommand::SetHelpLong(const char *help) {
+ LLDB_RECORD_METHOD(void, SBCommand, SetHelpLong, (const char *), help);
+
if (IsValid())
m_opaque_sp->SetHelpLong(help);
}
lldb::SBCommand SBCommand::AddMultiwordCommand(const char *name,
const char *help) {
+ LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand,
+ (const char *, const char *), name, help);
+
if (!IsValid())
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
if (!m_opaque_sp->IsMultiwordObject())
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
CommandObjectMultiword *new_command = new CommandObjectMultiword(
m_opaque_sp->GetCommandInterpreter(), name, help);
new_command->SetRemovable(true);
lldb::CommandObjectSP new_command_sp(new_command);
if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
- return lldb::SBCommand(new_command_sp);
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
}
lldb::SBCommand SBCommand::AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help) {
+ LLDB_RECORD_METHOD(
+ lldb::SBCommand, SBCommand, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *, const char *), name,
+ impl, help);
+
if (!IsValid())
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
if (!m_opaque_sp->IsMultiwordObject())
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
lldb::CommandObjectSP new_command_sp;
- new_command_sp.reset(new CommandPluginInterfaceImplementation(
- m_opaque_sp->GetCommandInterpreter(), name, impl, help));
+ new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
+ m_opaque_sp->GetCommandInterpreter(), name, impl, help);
if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
- return lldb::SBCommand(new_command_sp);
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
}
lldb::SBCommand SBCommand::AddCommand(const char *name,
lldb::SBCommandPluginInterface *impl,
const char *help, const char *syntax) {
+ LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *),
+ name, impl, help, syntax);
+
if (!IsValid())
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
if (!m_opaque_sp->IsMultiwordObject())
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
lldb::CommandObjectSP new_command_sp;
- new_command_sp.reset(new CommandPluginInterfaceImplementation(
- m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax));
+ new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>(
+ m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax);
if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp))
- return lldb::SBCommand(new_command_sp);
- return lldb::SBCommand();
+ return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp));
+ return LLDB_RECORD_RESULT(lldb::SBCommand());
}
uint32_t SBCommand::GetFlags() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBCommand, GetFlags);
+
return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0);
}
void SBCommand::SetFlags(uint32_t flags) {
+ LLDB_RECORD_METHOD(void, SBCommand, SetFlags, (uint32_t), flags);
+
if (IsValid())
m_opaque_sp->GetFlags().Set(flags);
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetStopOnContinue, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
+ SetStopOnContinue, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetStopOnError, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetStopOnCrash, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommands, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetEchoCommentCommands, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions,
+ SetEchoCommentCommands, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetPrintResults, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions,
+ GetAddToHistory, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory,
+ (bool));
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter,
+ (lldb_private::CommandInterpreter *));
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter,
+ (const lldb::SBCommandInterpreter &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBCommandInterpreter &,
+ SBCommandInterpreter, operator=,(const lldb::SBCommandInterpreter &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, CommandExists,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, AliasExists,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, IsActive, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreter, WasInterrupted, ());
+ LLDB_REGISTER_METHOD(const char *, SBCommandInterpreter,
+ GetIOHandlerControlSequence, (char));
+ LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter,
+ HandleCommand,
+ (const char *, lldb::SBCommandReturnObject &, bool));
+ LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandInterpreter,
+ HandleCommand,
+ (const char *, lldb::SBExecutionContext &,
+ lldb::SBCommandReturnObject &, bool));
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter, HandleCommandsFromFile,
+ (lldb::SBFileSpec &, lldb::SBExecutionContext &,
+ lldb::SBCommandInterpreterRunOptions &,
+ lldb::SBCommandReturnObject));
+ LLDB_REGISTER_METHOD(int, SBCommandInterpreter, HandleCompletion,
+ (const char *, const char *, const char *, int, int,
+ lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(int, SBCommandInterpreter,
+ HandleCompletionWithDescriptions,
+ (const char *, const char *, const char *, int, int,
+ lldb::SBStringList &, lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(int, SBCommandInterpreter,
+ HandleCompletionWithDescriptions,
+ (const char *, uint32_t, int, int,
+ lldb::SBStringList &, lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(
+ int, SBCommandInterpreter, HandleCompletion,
+ (const char *, uint32_t, int, int, lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCommands, ());
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliases, ());
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasAliasOptions, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBCommandInterpreter, GetProcess, ());
+ LLDB_REGISTER_METHOD(lldb::SBDebugger, SBCommandInterpreter, GetDebugger,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, GetPromptOnQuit, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter, SetPromptOnQuit, (bool));
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter, AllowExitCodeOnQuit,
+ (bool));
+ LLDB_REGISTER_METHOD(bool, SBCommandInterpreter, HasCustomQuitExitCode, ());
+ LLDB_REGISTER_METHOD(int, SBCommandInterpreter, GetQuitStatus, ());
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter, ResolveCommand,
+ (const char *, lldb::SBCommandReturnObject &));
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
+ SourceInitFileInHomeDirectory,
+ (lldb::SBCommandReturnObject &));
+ LLDB_REGISTER_METHOD(void, SBCommandInterpreter,
+ SourceInitFileInCurrentWorkingDirectory,
+ (lldb::SBCommandReturnObject &));
+ LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommandInterpreter,
+ GetBroadcaster, ());
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter,
+ GetBroadcasterClass, ());
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter,
+ GetArgumentTypeAsCString,
+ (const lldb::CommandArgumentType));
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBCommandInterpreter,
+ GetArgumentDescriptionAsCString,
+ (const lldb::CommandArgumentType));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBCommandInterpreter,
+ EventIsCommandInterpreterEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter,
+ AddMultiwordCommand, (const char *, const char *));
+ LLDB_REGISTER_METHOD(
+ lldb::SBCommand, SBCommandInterpreter, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBCommand, ());
+ LLDB_REGISTER_METHOD(bool, SBCommand, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommand, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBCommand, GetName, ());
+ LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelp, ());
+ LLDB_REGISTER_METHOD(const char *, SBCommand, GetHelpLong, ());
+ LLDB_REGISTER_METHOD(void, SBCommand, SetHelp, (const char *));
+ LLDB_REGISTER_METHOD(void, SBCommand, SetHelpLong, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddMultiwordCommand,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(
+ lldb::SBCommand, SBCommand, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand,
+ (const char *, lldb::SBCommandPluginInterface *,
+ const char *, const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBCommand, GetFlags, ());
+ LLDB_REGISTER_METHOD(void, SBCommand, SetFlags, (uint32_t));
+}
+
+}
+}
diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp
index 7bc02985a3ec1..94e89916f7f6d 100644
--- a/source/API/SBCommandReturnObject.cpp
+++ b/source/API/SBCommandReturnObject.cpp
@@ -1,105 +1,113 @@
//===-- SBCommandReturnObject.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBCommandReturnObject.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
-
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
using namespace lldb;
using namespace lldb_private;
SBCommandReturnObject::SBCommandReturnObject()
- : m_opaque_ap(new CommandReturnObject()) {}
+ : m_opaque_up(new CommandReturnObject()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandReturnObject);
+}
SBCommandReturnObject::SBCommandReturnObject(const SBCommandReturnObject &rhs)
- : m_opaque_ap() {
- if (rhs.m_opaque_ap)
- m_opaque_ap.reset(new CommandReturnObject(*rhs.m_opaque_ap));
+ : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
+ (const lldb::SBCommandReturnObject &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBCommandReturnObject::SBCommandReturnObject(CommandReturnObject *ptr)
- : m_opaque_ap(ptr) {}
+ : m_opaque_up(ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBCommandReturnObject,
+ (lldb_private::CommandReturnObject *), ptr);
+}
SBCommandReturnObject::~SBCommandReturnObject() = default;
CommandReturnObject *SBCommandReturnObject::Release() {
- return m_opaque_ap.release();
+ LLDB_RECORD_METHOD_NO_ARGS(lldb_private::CommandReturnObject *,
+ SBCommandReturnObject, Release);
+
+ return LLDB_RECORD_RESULT(m_opaque_up.release());
}
const SBCommandReturnObject &SBCommandReturnObject::
operator=(const SBCommandReturnObject &rhs) {
- if (this != &rhs) {
- if (rhs.m_opaque_ap)
- m_opaque_ap.reset(new CommandReturnObject(*rhs.m_opaque_ap));
- else
- m_opaque_ap.reset();
- }
- return *this;
+ LLDB_RECORD_METHOD(
+ const lldb::SBCommandReturnObject &,
+ SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &),
+ rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
+}
+
+bool SBCommandReturnObject::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, IsValid);
+ return this->operator bool();
}
+SBCommandReturnObject::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandReturnObject, operator bool);
-bool SBCommandReturnObject::IsValid() const { return m_opaque_ap != nullptr; }
+ return m_opaque_up != nullptr;
+}
const char *SBCommandReturnObject::GetOutput() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetOutput);
- if (m_opaque_ap) {
- llvm::StringRef output = m_opaque_ap->GetOutputData();
+ if (m_opaque_up) {
+ llvm::StringRef output = m_opaque_up->GetOutputData();
ConstString result(output.empty() ? llvm::StringRef("") : output);
- if (log)
- log->Printf("SBCommandReturnObject(%p)::GetOutput () => \"%s\"",
- static_cast<void *>(m_opaque_ap.get()), result.AsCString());
-
return result.AsCString();
}
- if (log)
- log->Printf("SBCommandReturnObject(%p)::GetOutput () => nullptr",
- static_cast<void *>(m_opaque_ap.get()));
-
return nullptr;
}
const char *SBCommandReturnObject::GetError() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBCommandReturnObject, GetError);
- if (m_opaque_ap) {
- llvm::StringRef output = m_opaque_ap->GetErrorData();
+ if (m_opaque_up) {
+ llvm::StringRef output = m_opaque_up->GetErrorData();
ConstString result(output.empty() ? llvm::StringRef("") : output);
- if (log)
- log->Printf("SBCommandReturnObject(%p)::GetError () => \"%s\"",
- static_cast<void *>(m_opaque_ap.get()), result.AsCString());
-
return result.AsCString();
}
- if (log)
- log->Printf("SBCommandReturnObject(%p)::GetError () => nullptr",
- static_cast<void *>(m_opaque_ap.get()));
-
return nullptr;
}
size_t SBCommandReturnObject::GetOutputSize() {
- return (m_opaque_ap ? m_opaque_ap->GetOutputData().size() : 0);
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetOutputSize);
+
+ return (m_opaque_up ? m_opaque_up->GetOutputData().size() : 0);
}
size_t SBCommandReturnObject::GetErrorSize() {
- return (m_opaque_ap ? m_opaque_ap->GetErrorData().size() : 0);
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBCommandReturnObject, GetErrorSize);
+
+ return (m_opaque_up ? m_opaque_up->GetErrorData().size() : 0);
}
size_t SBCommandReturnObject::PutOutput(FILE *fh) {
+ LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *), fh);
+
if (fh) {
size_t num_bytes = GetOutputSize();
if (num_bytes)
@@ -109,6 +117,8 @@ size_t SBCommandReturnObject::PutOutput(FILE *fh) {
}
size_t SBCommandReturnObject::PutError(FILE *fh) {
+ LLDB_RECORD_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *), fh);
+
if (fh) {
size_t num_bytes = GetErrorSize();
if (num_bytes)
@@ -118,71 +128,92 @@ size_t SBCommandReturnObject::PutError(FILE *fh) {
}
void SBCommandReturnObject::Clear() {
- if (m_opaque_ap)
- m_opaque_ap->Clear();
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBCommandReturnObject, Clear);
+
+ if (m_opaque_up)
+ m_opaque_up->Clear();
}
lldb::ReturnStatus SBCommandReturnObject::GetStatus() {
- return (m_opaque_ap ? m_opaque_ap->GetStatus() : lldb::eReturnStatusInvalid);
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::ReturnStatus, SBCommandReturnObject,
+ GetStatus);
+
+ return (m_opaque_up ? m_opaque_up->GetStatus() : lldb::eReturnStatusInvalid);
}
void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) {
- if (m_opaque_ap)
- m_opaque_ap->SetStatus(status);
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetStatus,
+ (lldb::ReturnStatus), status);
+
+ if (m_opaque_up)
+ m_opaque_up->SetStatus(status);
}
bool SBCommandReturnObject::Succeeded() {
- return (m_opaque_ap ? m_opaque_ap->Succeeded() : false);
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, Succeeded);
+
+ return (m_opaque_up ? m_opaque_up->Succeeded() : false);
}
bool SBCommandReturnObject::HasResult() {
- return (m_opaque_ap ? m_opaque_ap->HasResult() : false);
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommandReturnObject, HasResult);
+
+ return (m_opaque_up ? m_opaque_up->HasResult() : false);
}
void SBCommandReturnObject::AppendMessage(const char *message) {
- if (m_opaque_ap)
- m_opaque_ap->AppendMessage(message);
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendMessage, (const char *),
+ message);
+
+ if (m_opaque_up)
+ m_opaque_up->AppendMessage(message);
}
void SBCommandReturnObject::AppendWarning(const char *message) {
- if (m_opaque_ap)
- m_opaque_ap->AppendWarning(message);
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, AppendWarning, (const char *),
+ message);
+
+ if (m_opaque_up)
+ m_opaque_up->AppendWarning(message);
}
CommandReturnObject *SBCommandReturnObject::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
CommandReturnObject *SBCommandReturnObject::get() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
CommandReturnObject &SBCommandReturnObject::operator*() const {
- assert(m_opaque_ap.get());
- return *(m_opaque_ap.get());
+ assert(m_opaque_up.get());
+ return *(m_opaque_up.get());
}
CommandReturnObject &SBCommandReturnObject::ref() const {
- assert(m_opaque_ap.get());
- return *(m_opaque_ap.get());
+ assert(m_opaque_up.get());
+ return *(m_opaque_up.get());
}
void SBCommandReturnObject::SetLLDBObjectPtr(CommandReturnObject *ptr) {
- if (m_opaque_ap)
- m_opaque_ap.reset(ptr);
+ if (m_opaque_up)
+ m_opaque_up.reset(ptr);
}
bool SBCommandReturnObject::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBCommandReturnObject, GetDescription,
+ (lldb::SBStream &), description);
+
Stream &strm = description.ref();
- if (m_opaque_ap) {
+ if (m_opaque_up) {
description.Printf("Error: ");
- lldb::ReturnStatus status = m_opaque_ap->GetStatus();
+ lldb::ReturnStatus status = m_opaque_up->GetStatus();
if (status == lldb::eReturnStatusStarted)
strm.PutCString("Started");
else if (status == lldb::eReturnStatusInvalid)
strm.PutCString("Invalid");
- else if (m_opaque_ap->Succeeded())
+ else if (m_opaque_up->Succeeded())
strm.PutCString("Success");
else
strm.PutCString("Fail");
@@ -199,60 +230,81 @@ bool SBCommandReturnObject::GetDescription(SBStream &description) {
}
void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FILE *), fh);
+
SetImmediateOutputFile(fh, false);
}
void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FILE *), fh);
+
SetImmediateErrorFile(fh, false);
}
void SBCommandReturnObject::SetImmediateOutputFile(FILE *fh,
bool transfer_ownership) {
- if (m_opaque_ap)
- m_opaque_ap->SetImmediateOutputFile(fh, transfer_ownership);
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FILE *, bool), fh, transfer_ownership);
+
+ if (m_opaque_up)
+ m_opaque_up->SetImmediateOutputFile(fh, transfer_ownership);
}
void SBCommandReturnObject::SetImmediateErrorFile(FILE *fh,
bool transfer_ownership) {
- if (m_opaque_ap)
- m_opaque_ap->SetImmediateErrorFile(fh, transfer_ownership);
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FILE *, bool), fh, transfer_ownership);
+
+ if (m_opaque_up)
+ m_opaque_up->SetImmediateErrorFile(fh, transfer_ownership);
}
void SBCommandReturnObject::PutCString(const char *string, int len) {
- if (m_opaque_ap) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, PutCString,
+ (const char *, int), string, len);
+
+ if (m_opaque_up) {
if (len == 0 || string == nullptr || *string == 0) {
return;
} else if (len > 0) {
std::string buffer(string, len);
- m_opaque_ap->AppendMessage(buffer.c_str());
+ m_opaque_up->AppendMessage(buffer.c_str());
} else
- m_opaque_ap->AppendMessage(string);
+ m_opaque_up->AppendMessage(string);
}
}
const char *SBCommandReturnObject::GetOutput(bool only_if_no_immediate) {
- if (!m_opaque_ap)
+ LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetOutput, (bool),
+ only_if_no_immediate);
+
+ if (!m_opaque_up)
return nullptr;
if (!only_if_no_immediate ||
- m_opaque_ap->GetImmediateOutputStream().get() == nullptr)
+ m_opaque_up->GetImmediateOutputStream().get() == nullptr)
return GetOutput();
return nullptr;
}
const char *SBCommandReturnObject::GetError(bool only_if_no_immediate) {
- if (!m_opaque_ap)
+ LLDB_RECORD_METHOD(const char *, SBCommandReturnObject, GetError, (bool),
+ only_if_no_immediate);
+
+ if (!m_opaque_up)
return nullptr;
if (!only_if_no_immediate ||
- m_opaque_ap->GetImmediateErrorStream().get() == nullptr)
+ m_opaque_up->GetImmediateErrorStream().get() == nullptr)
return GetError();
return nullptr;
}
size_t SBCommandReturnObject::Printf(const char *format, ...) {
- if (m_opaque_ap) {
+ if (m_opaque_up) {
va_list args;
va_start(args, format);
- size_t result = m_opaque_ap->GetOutputStream().PrintfVarArg(format, args);
+ size_t result = m_opaque_up->GetOutputStream().PrintfVarArg(format, args);
va_end(args);
return result;
}
@@ -261,15 +313,79 @@ size_t SBCommandReturnObject::Printf(const char *format, ...) {
void SBCommandReturnObject::SetError(lldb::SBError &error,
const char *fallback_error_cstr) {
- if (m_opaque_ap) {
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError,
+ (lldb::SBError &, const char *), error,
+ fallback_error_cstr);
+
+ if (m_opaque_up) {
if (error.IsValid())
- m_opaque_ap->SetError(error.ref(), fallback_error_cstr);
+ m_opaque_up->SetError(error.ref(), fallback_error_cstr);
else if (fallback_error_cstr)
- m_opaque_ap->SetError(Status(), fallback_error_cstr);
+ m_opaque_up->SetError(Status(), fallback_error_cstr);
}
}
void SBCommandReturnObject::SetError(const char *error_cstr) {
- if (m_opaque_ap && error_cstr)
- m_opaque_ap->SetError(error_cstr);
+ LLDB_RECORD_METHOD(void, SBCommandReturnObject, SetError, (const char *),
+ error_cstr);
+
+ if (m_opaque_up && error_cstr)
+ m_opaque_up->SetError(error_cstr);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBCommandReturnObject>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject,
+ (const lldb::SBCommandReturnObject &));
+ LLDB_REGISTER_CONSTRUCTOR(SBCommandReturnObject,
+ (lldb_private::CommandReturnObject *));
+ LLDB_REGISTER_METHOD(lldb_private::CommandReturnObject *,
+ SBCommandReturnObject, Release, ());
+ LLDB_REGISTER_METHOD(
+ const lldb::SBCommandReturnObject &,
+ SBCommandReturnObject, operator=,(const lldb::SBCommandReturnObject &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommandReturnObject, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput, ());
+ LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, ());
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetOutputSize, ());
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, GetErrorSize, ());
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutOutput, (FILE *));
+ LLDB_REGISTER_METHOD(size_t, SBCommandReturnObject, PutError, (FILE *));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::ReturnStatus, SBCommandReturnObject, GetStatus,
+ ());
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetStatus,
+ (lldb::ReturnStatus));
+ LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, Succeeded, ());
+ LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, HasResult, ());
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendMessage,
+ (const char *));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, AppendWarning,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBCommandReturnObject, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FILE *));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FILE *));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateOutputFile,
+ (FILE *, bool));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetImmediateErrorFile,
+ (FILE *, bool));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, PutCString,
+ (const char *, int));
+ LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetOutput,
+ (bool));
+ LLDB_REGISTER_METHOD(const char *, SBCommandReturnObject, GetError, (bool));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError,
+ (lldb::SBError &, const char *));
+ LLDB_REGISTER_METHOD(void, SBCommandReturnObject, SetError, (const char *));
+}
+
+}
}
diff --git a/source/API/SBCommunication.cpp b/source/API/SBCommunication.cpp
index 63b672efe3c02..90df70bde72f1 100644
--- a/source/API/SBCommunication.cpp
+++ b/source/API/SBCommunication.cpp
@@ -1,65 +1,77 @@
//===-- SBCommunication.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBCommunication.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/Core/Communication.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Host.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-SBCommunication::SBCommunication() : m_opaque(NULL), m_opaque_owned(false) {}
+SBCommunication::SBCommunication() : m_opaque(nullptr), m_opaque_owned(false) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommunication);
+}
SBCommunication::SBCommunication(const char *broadcaster_name)
: m_opaque(new Communication(broadcaster_name)), m_opaque_owned(true) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBCommunication::SBCommunication (broadcaster_name=\"%s\") => "
- "SBCommunication(%p)",
- broadcaster_name, static_cast<void *>(m_opaque));
+ LLDB_RECORD_CONSTRUCTOR(SBCommunication, (const char *), broadcaster_name);
}
SBCommunication::~SBCommunication() {
if (m_opaque && m_opaque_owned)
delete m_opaque;
- m_opaque = NULL;
+ m_opaque = nullptr;
m_opaque_owned = false;
}
-bool SBCommunication::IsValid() const { return m_opaque != NULL; }
+bool SBCommunication::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsValid);
+ return this->operator bool();
+}
+SBCommunication::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, operator bool);
+
+ return m_opaque != nullptr;
+}
bool SBCommunication::GetCloseOnEOF() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, GetCloseOnEOF);
+
if (m_opaque)
return m_opaque->GetCloseOnEOF();
return false;
}
void SBCommunication::SetCloseOnEOF(bool b) {
+ LLDB_RECORD_METHOD(void, SBCommunication, SetCloseOnEOF, (bool), b);
+
if (m_opaque)
m_opaque->SetCloseOnEOF(b);
}
ConnectionStatus SBCommunication::Connect(const char *url) {
+ LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication, Connect,
+ (const char *), url);
+
if (m_opaque) {
if (!m_opaque->HasConnection())
m_opaque->SetConnection(Host::CreateDefaultConnection(url).release());
- return m_opaque->Connect(url, NULL);
+ return m_opaque->Connect(url, nullptr);
}
return eConnectionStatusNoConnection;
}
ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::ConnectionStatus, SBCommunication,
+ AdoptFileDesriptor, (int, bool), fd, owns_fd);
ConnectionStatus status = eConnectionStatusNoConnection;
if (m_opaque) {
@@ -73,183 +85,131 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) {
else
status = eConnectionStatusLostConnection;
}
-
- if (log)
- log->Printf(
- "SBCommunication(%p)::AdoptFileDescriptor (fd=%d, ownd_fd=%i) => %s",
- static_cast<void *>(m_opaque), fd, owns_fd,
- Communication::ConnectionStatusAsCString(status));
-
return status;
}
ConnectionStatus SBCommunication::Disconnect() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::ConnectionStatus, SBCommunication,
+ Disconnect);
ConnectionStatus status = eConnectionStatusNoConnection;
if (m_opaque)
status = m_opaque->Disconnect();
-
- if (log)
- log->Printf("SBCommunication(%p)::Disconnect () => %s",
- static_cast<void *>(m_opaque),
- Communication::ConnectionStatusAsCString(status));
-
return status;
}
bool SBCommunication::IsConnected() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- bool result = false;
- if (m_opaque)
- result = m_opaque->IsConnected();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommunication, IsConnected);
- if (log)
- log->Printf("SBCommunication(%p)::IsConnected () => %i",
- static_cast<void *>(m_opaque), result);
-
- return false;
+ return m_opaque ? m_opaque->IsConnected() : false;
}
size_t SBCommunication::Read(void *dst, size_t dst_len, uint32_t timeout_usec,
ConnectionStatus &status) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBCommunication(%p)::Read (dst=%p, dst_len=%" PRIu64
- ", timeout_usec=%u, &status)...",
- static_cast<void *>(m_opaque), static_cast<void *>(dst),
- static_cast<uint64_t>(dst_len), timeout_usec);
+ LLDB_RECORD_DUMMY(size_t, SBCommunication, Read,
+ (void *, size_t, uint32_t, lldb::ConnectionStatus &), dst,
+ dst_len, timeout_usec, status);
+
size_t bytes_read = 0;
Timeout<std::micro> timeout = timeout_usec == UINT32_MAX
? Timeout<std::micro>(llvm::None)
: std::chrono::microseconds(timeout_usec);
if (m_opaque)
- bytes_read = m_opaque->Read(dst, dst_len, timeout, status, NULL);
+ bytes_read = m_opaque->Read(dst, dst_len, timeout, status, nullptr);
else
status = eConnectionStatusNoConnection;
- if (log)
- log->Printf("SBCommunication(%p)::Read (dst=%p, dst_len=%" PRIu64
- ", timeout_usec=%u, &status=%s) => %" PRIu64,
- static_cast<void *>(m_opaque), static_cast<void *>(dst),
- static_cast<uint64_t>(dst_len), timeout_usec,
- Communication::ConnectionStatusAsCString(status),
- static_cast<uint64_t>(bytes_read));
return bytes_read;
}
size_t SBCommunication::Write(const void *src, size_t src_len,
ConnectionStatus &status) {
+ LLDB_RECORD_DUMMY(size_t, SBCommunication, Write,
+ (const void *, size_t, lldb::ConnectionStatus &), src,
+ src_len, status);
+
size_t bytes_written = 0;
if (m_opaque)
- bytes_written = m_opaque->Write(src, src_len, status, NULL);
+ bytes_written = m_opaque->Write(src, src_len, status, nullptr);
else
status = eConnectionStatusNoConnection;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBCommunication(%p)::Write (src=%p, src_len=%" PRIu64
- ", &status=%s) => %" PRIu64,
- static_cast<void *>(m_opaque), static_cast<const void *>(src),
- static_cast<uint64_t>(src_len),
- Communication::ConnectionStatusAsCString(status),
- static_cast<uint64_t>(bytes_written));
-
- return 0;
+ return bytes_written;
}
bool SBCommunication::ReadThreadStart() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- bool success = false;
- if (m_opaque)
- success = m_opaque->StartReadThread();
-
- if (log)
- log->Printf("SBCommunication(%p)::ReadThreadStart () => %i",
- static_cast<void *>(m_opaque), success);
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStart);
- return success;
+ return m_opaque ? m_opaque->StartReadThread() : false;
}
bool SBCommunication::ReadThreadStop() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBCommunication(%p)::ReadThreadStop ()...",
- static_cast<void *>(m_opaque));
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadStop);
- bool success = false;
- if (m_opaque)
- success = m_opaque->StopReadThread();
-
- if (log)
- log->Printf("SBCommunication(%p)::ReadThreadStop () => %i",
- static_cast<void *>(m_opaque), success);
-
- return success;
+ return m_opaque ? m_opaque->StopReadThread() : false;
}
bool SBCommunication::ReadThreadIsRunning() {
- bool result = false;
- if (m_opaque)
- result = m_opaque->ReadThreadIsRunning();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBCommunication(%p)::ReadThreadIsRunning () => %i",
- static_cast<void *>(m_opaque), result);
- return result;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBCommunication, ReadThreadIsRunning);
+
+ return m_opaque ? m_opaque->ReadThreadIsRunning() : false;
}
bool SBCommunication::SetReadThreadBytesReceivedCallback(
ReadThreadBytesReceived callback, void *callback_baton) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_DUMMY(bool, SBCommunication, SetReadThreadBytesReceivedCallback,
+ (lldb::SBCommunication::ReadThreadBytesReceived, void *),
+ callback, callback_baton);
bool result = false;
if (m_opaque) {
m_opaque->SetReadThreadBytesReceivedCallback(callback, callback_baton);
result = true;
}
-
- if (log)
- log->Printf("SBCommunication(%p)::SetReadThreadBytesReceivedCallback "
- "(callback=%p, baton=%p) => %i",
- static_cast<void *>(m_opaque),
- reinterpret_cast<void *>(reinterpret_cast<intptr_t>(callback)),
- static_cast<void *>(callback_baton), result);
-
return result;
}
SBBroadcaster SBCommunication::GetBroadcaster() {
- SBBroadcaster broadcaster(m_opaque, false);
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBCommunication,
+ GetBroadcaster);
- if (log)
- log->Printf("SBCommunication(%p)::GetBroadcaster () => SBBroadcaster (%p)",
- static_cast<void *>(m_opaque),
- static_cast<void *>(broadcaster.get()));
-
- return broadcaster;
+ SBBroadcaster broadcaster(m_opaque, false);
+ return LLDB_RECORD_RESULT(broadcaster);
}
const char *SBCommunication::GetBroadcasterClass() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBCommunication,
+ GetBroadcasterClass);
+
return Communication::GetStaticBroadcasterClass().AsCString();
}
-//
-// void
-// SBCommunication::CreateIfNeeded ()
-//{
-// if (m_opaque == NULL)
-// {
-// static uint32_t g_broadcaster_num;
-// char broadcaster_name[256];
-// ::snprintf (name, broadcaster_name, "%p SBCommunication", this);
-// m_opaque = new Communication (broadcaster_name);
-// m_opaque_owned = true;
-// }
-// assert (m_opaque);
-//}
-//
-//
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBCommunication>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBCommunication, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBCommunication, (const char *));
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBCommunication, GetCloseOnEOF, ());
+ LLDB_REGISTER_METHOD(void, SBCommunication, SetCloseOnEOF, (bool));
+ LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, Connect,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication,
+ AdoptFileDesriptor, (int, bool));
+ LLDB_REGISTER_METHOD(lldb::ConnectionStatus, SBCommunication, Disconnect,
+ ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCommunication, IsConnected, ());
+ LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadStart, ());
+ LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadStop, ());
+ LLDB_REGISTER_METHOD(bool, SBCommunication, ReadThreadIsRunning, ());
+ LLDB_REGISTER_METHOD(lldb::SBBroadcaster, SBCommunication, GetBroadcaster,
+ ());
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBCommunication,
+ GetBroadcasterClass, ());
+}
+
+}
+}
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index 4e2fc6af460a4..c9ca70645d958 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/source/API/SBCompileUnit.cpp
@@ -1,13 +1,13 @@
//===-- SBCompileUnit.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBCompileUnit.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Module.h"
@@ -16,44 +16,58 @@
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Type.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-SBCompileUnit::SBCompileUnit() : m_opaque_ptr(NULL) {}
+SBCompileUnit::SBCompileUnit() : m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCompileUnit);
+}
SBCompileUnit::SBCompileUnit(lldb_private::CompileUnit *lldb_object_ptr)
: m_opaque_ptr(lldb_object_ptr) {}
SBCompileUnit::SBCompileUnit(const SBCompileUnit &rhs)
- : m_opaque_ptr(rhs.m_opaque_ptr) {}
+ : m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBCompileUnit, (const lldb::SBCompileUnit &), rhs);
+}
const SBCompileUnit &SBCompileUnit::operator=(const SBCompileUnit &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBCompileUnit &,
+ SBCompileUnit, operator=,(const lldb::SBCompileUnit &),
+ rhs);
+
m_opaque_ptr = rhs.m_opaque_ptr;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = NULL; }
+SBCompileUnit::~SBCompileUnit() { m_opaque_ptr = nullptr; }
SBFileSpec SBCompileUnit::GetFileSpec() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBCompileUnit,
+ GetFileSpec);
+
SBFileSpec file_spec;
if (m_opaque_ptr)
file_spec.SetFileSpec(*m_opaque_ptr);
- return file_spec;
+ return LLDB_RECORD_RESULT(file_spec);
}
uint32_t SBCompileUnit::GetNumLineEntries() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumLineEntries);
+
if (m_opaque_ptr) {
LineTable *line_table = m_opaque_ptr->GetLineTable();
- if (line_table)
+ if (line_table) {
return line_table->GetSize();
+ }
}
return 0;
}
SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit,
+ GetLineEntryAtIndex, (uint32_t), idx);
SBLineEntry sb_line_entry;
if (m_opaque_ptr) {
@@ -65,20 +79,15 @@ SBLineEntry SBCompileUnit::GetLineEntryAtIndex(uint32_t idx) const {
}
}
- if (log) {
- SBStream sstr;
- sb_line_entry.GetDescription(sstr);
- log->Printf("SBCompileUnit(%p)::GetLineEntryAtIndex (idx=%u) => "
- "SBLineEntry(%p): '%s'",
- static_cast<void *>(m_opaque_ptr), idx,
- static_cast<void *>(sb_line_entry.get()), sstr.GetData());
- }
-
- return sb_line_entry;
+ return LLDB_RECORD_RESULT(sb_line_entry);
}
uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
SBFileSpec *inline_file_spec) const {
+ LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex,
+ (uint32_t, uint32_t, lldb::SBFileSpec *), start_idx,
+ line, inline_file_spec);
+
const bool exact = true;
return FindLineEntryIndex(start_idx, line, inline_file_spec, exact);
}
@@ -86,7 +95,9 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
SBFileSpec *inline_file_spec,
bool exact) const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex,
+ (uint32_t, uint32_t, lldb::SBFileSpec *, bool),
+ start_idx, line, inline_file_spec, exact);
uint32_t index = UINT32_MAX;
if (m_opaque_ptr) {
@@ -97,107 +108,103 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line,
file_spec = *m_opaque_ptr;
index = m_opaque_ptr->FindLineEntry(
- start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL,
- exact, NULL);
- }
-
- if (log) {
- SBStream sstr;
- if (index == UINT32_MAX) {
- log->Printf("SBCompileUnit(%p)::FindLineEntryIndex (start_idx=%u, "
- "line=%u, SBFileSpec(%p)) => NOT FOUND",
- static_cast<void *>(m_opaque_ptr), start_idx, line,
- inline_file_spec
- ? static_cast<const void *>(inline_file_spec->get())
- : NULL);
- } else {
- log->Printf("SBCompileUnit(%p)::FindLineEntryIndex (start_idx=%u, "
- "line=%u, SBFileSpec(%p)) => %u",
- static_cast<void *>(m_opaque_ptr), start_idx, line,
- inline_file_spec
- ? static_cast<const void *>(inline_file_spec->get())
- : NULL,
- index);
- }
+ start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr,
+ exact, nullptr);
}
return index;
}
uint32_t SBCompileUnit::GetNumSupportFiles() const {
- if (m_opaque_ptr) {
- FileSpecList &support_files = m_opaque_ptr->GetSupportFiles();
- return support_files.GetSize();
- }
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBCompileUnit, GetNumSupportFiles);
+
+ if (m_opaque_ptr)
+ return m_opaque_ptr->GetSupportFiles().GetSize();
+
return 0;
}
lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) {
+ LLDB_RECORD_METHOD(lldb::SBTypeList, SBCompileUnit, GetTypes, (uint32_t),
+ type_mask);
+
SBTypeList sb_type_list;
if (!m_opaque_ptr)
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
ModuleSP module_sp(m_opaque_ptr->GetModule());
if (!module_sp)
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (!vendor)
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
TypeClass type_class = static_cast<TypeClass>(type_mask);
TypeList type_list;
vendor->GetTypes(m_opaque_ptr, type_class, type_list);
- sb_type_list.m_opaque_ap->Append(type_list);
- return sb_type_list;
+ sb_type_list.m_opaque_up->Append(type_list);
+ return LLDB_RECORD_RESULT(sb_type_list);
}
SBFileSpec SBCompileUnit::GetSupportFileAtIndex(uint32_t idx) const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit,
+ GetSupportFileAtIndex, (uint32_t), idx);
SBFileSpec sb_file_spec;
if (m_opaque_ptr) {
- FileSpecList &support_files = m_opaque_ptr->GetSupportFiles();
- FileSpec file_spec = support_files.GetFileSpecAtIndex(idx);
- sb_file_spec.SetFileSpec(file_spec);
+ FileSpec spec = m_opaque_ptr->GetSupportFiles().GetFileSpecAtIndex(idx);
+ sb_file_spec.SetFileSpec(spec);
}
- if (log) {
- SBStream sstr;
- sb_file_spec.GetDescription(sstr);
- log->Printf("SBCompileUnit(%p)::GetGetFileSpecAtIndex (idx=%u) => "
- "SBFileSpec(%p): '%s'",
- static_cast<void *>(m_opaque_ptr), idx,
- static_cast<const void *>(sb_file_spec.get()), sstr.GetData());
- }
- return sb_file_spec;
+ return LLDB_RECORD_RESULT(sb_file_spec);
}
uint32_t SBCompileUnit::FindSupportFileIndex(uint32_t start_idx,
const SBFileSpec &sb_file,
bool full) {
+ LLDB_RECORD_METHOD(uint32_t, SBCompileUnit, FindSupportFileIndex,
+ (uint32_t, const lldb::SBFileSpec &, bool), start_idx,
+ sb_file, full);
+
if (m_opaque_ptr) {
- FileSpecList &support_files = m_opaque_ptr->GetSupportFiles();
+ const FileSpecList &support_files = m_opaque_ptr->GetSupportFiles();
return support_files.FindFileIndex(start_idx, sb_file.ref(), full);
}
return 0;
}
lldb::LanguageType SBCompileUnit::GetLanguage() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBCompileUnit, GetLanguage);
+
if (m_opaque_ptr)
return m_opaque_ptr->GetLanguage();
return lldb::eLanguageTypeUnknown;
}
-bool SBCompileUnit::IsValid() const { return m_opaque_ptr != NULL; }
+bool SBCompileUnit::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, IsValid);
+ return this->operator bool();
+}
+SBCompileUnit::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCompileUnit, operator bool);
+
+ return m_opaque_ptr != nullptr;
+}
bool SBCompileUnit::operator==(const SBCompileUnit &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBCompileUnit, operator==,(const lldb::SBCompileUnit &), rhs);
+
return m_opaque_ptr == rhs.m_opaque_ptr;
}
bool SBCompileUnit::operator!=(const SBCompileUnit &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBCompileUnit, operator!=,(const lldb::SBCompileUnit &), rhs);
+
return m_opaque_ptr != rhs.m_opaque_ptr;
}
@@ -216,6 +223,9 @@ void SBCompileUnit::reset(lldb_private::CompileUnit *lldb_object_ptr) {
}
bool SBCompileUnit::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBCompileUnit, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
if (m_opaque_ptr) {
@@ -225,3 +235,42 @@ bool SBCompileUnit::GetDescription(SBStream &description) {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBCompileUnit>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBCompileUnit, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBCompileUnit, (const lldb::SBCompileUnit &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBCompileUnit &,
+ SBCompileUnit, operator=,(const lldb::SBCompileUnit &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit, GetFileSpec,
+ ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, GetNumLineEntries, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBLineEntry, SBCompileUnit,
+ GetLineEntryAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex,
+ (uint32_t, uint32_t, lldb::SBFileSpec *));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, FindLineEntryIndex,
+ (uint32_t, uint32_t, lldb::SBFileSpec *, bool));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBCompileUnit, GetNumSupportFiles, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeList, SBCompileUnit, GetTypes, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBCompileUnit,
+ GetSupportFileAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBCompileUnit, FindSupportFileIndex,
+ (uint32_t, const lldb::SBFileSpec &, bool));
+ LLDB_REGISTER_METHOD(lldb::LanguageType, SBCompileUnit, GetLanguage, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCompileUnit, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBCompileUnit, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBCompileUnit, operator==,(const lldb::SBCompileUnit &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBCompileUnit, operator!=,(const lldb::SBCompileUnit &));
+ LLDB_REGISTER_METHOD(bool, SBCompileUnit, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBData.cpp b/source/API/SBData.cpp
index a30a778a19d2b..528cd8d43ecce 100644
--- a/source/API/SBData.cpp
+++ b/source/API/SBData.cpp
@@ -1,37 +1,44 @@
//===-- SBData.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <inttypes.h>
-
#include "lldb/API/SBData.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
+#include <cinttypes>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-SBData::SBData() : m_opaque_sp(new DataExtractor()) {}
+SBData::SBData() : m_opaque_sp(new DataExtractor()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBData);
+}
SBData::SBData(const lldb::DataExtractorSP &data_sp) : m_opaque_sp(data_sp) {}
-SBData::SBData(const SBData &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
+SBData::SBData(const SBData &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBData, (const lldb::SBData &), rhs);
+}
const SBData &SBData::operator=(const SBData &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBData &,
+ SBData, operator=,(const lldb::SBData &), rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBData::~SBData() {}
@@ -50,67 +57,69 @@ lldb::DataExtractorSP &SBData::operator*() { return m_opaque_sp; }
const lldb::DataExtractorSP &SBData::operator*() const { return m_opaque_sp; }
-bool SBData::IsValid() { return m_opaque_sp.get() != NULL; }
+bool SBData::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBData, IsValid);
+ return this->operator bool();
+}
+SBData::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBData, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
uint8_t SBData::GetAddressByteSize() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(uint8_t, SBData, GetAddressByteSize);
+
uint8_t value = 0;
if (m_opaque_sp.get())
value = m_opaque_sp->GetAddressByteSize();
- if (log)
- log->Printf("SBData::GetAddressByteSize () => "
- "(%i)",
- value);
return value;
}
void SBData::SetAddressByteSize(uint8_t addr_byte_size) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBData, SetAddressByteSize, (uint8_t),
+ addr_byte_size);
+
if (m_opaque_sp.get())
m_opaque_sp->SetAddressByteSize(addr_byte_size);
- if (log)
- log->Printf("SBData::SetAddressByteSize (%i)", addr_byte_size);
}
void SBData::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBData, Clear);
+
if (m_opaque_sp.get())
m_opaque_sp->Clear();
}
size_t SBData::GetByteSize() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBData, GetByteSize);
+
size_t value = 0;
if (m_opaque_sp.get())
value = m_opaque_sp->GetByteSize();
- if (log)
- log->Printf("SBData::GetByteSize () => "
- "( %" PRIu64 " )",
- (uint64_t)value);
return value;
}
lldb::ByteOrder SBData::GetByteOrder() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBData, GetByteOrder);
+
lldb::ByteOrder value = eByteOrderInvalid;
if (m_opaque_sp.get())
value = m_opaque_sp->GetByteOrder();
- if (log)
- log->Printf("SBData::GetByteOrder () => "
- "(%i)",
- value);
return value;
}
void SBData::SetByteOrder(lldb::ByteOrder endian) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder), endian);
+
if (m_opaque_sp.get())
m_opaque_sp->SetByteOrder(endian);
- if (log)
- log->Printf("SBData::GetByteOrder (%i)", endian);
}
float SBData::GetFloat(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(float, SBData, GetFloat, (lldb::SBError &, lldb::offset_t),
+ error, offset);
+
float value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -120,14 +129,13 @@ float SBData::GetFloat(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetFloat (error=%p,offset=%" PRIu64 ") => (%f)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(double, SBData, GetDouble,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
double value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -137,15 +145,13 @@ double SBData::GetDouble(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetDouble (error=%p,offset=%" PRIu64 ") => "
- "(%f)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(long double, SBData, GetLongDouble,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
long double value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -155,15 +161,13 @@ long double SBData::GetLongDouble(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetLongDouble (error=%p,offset=%" PRIu64 ") => "
- "(%Lf)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::addr_t, SBData, GetAddress,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
lldb::addr_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -173,16 +177,13 @@ lldb::addr_t SBData::GetAddress(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetAddress (error=%p,offset=%" PRIu64 ") => "
- "(%p)",
- static_cast<void *>(error.get()), offset,
- reinterpret_cast<void *>(value));
return value;
}
uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(uint8_t, SBData, GetUnsignedInt8,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
uint8_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -192,15 +193,13 @@ uint8_t SBData::GetUnsignedInt8(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetUnsignedInt8 (error=%p,offset=%" PRIu64 ") => "
- "(%c)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(uint16_t, SBData, GetUnsignedInt16,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
uint16_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -210,15 +209,13 @@ uint16_t SBData::GetUnsignedInt16(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetUnsignedInt16 (error=%p,offset=%" PRIu64 ") => "
- "(%hd)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(uint32_t, SBData, GetUnsignedInt32,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
uint32_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -228,15 +225,13 @@ uint32_t SBData::GetUnsignedInt32(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetUnsignedInt32 (error=%p,offset=%" PRIu64 ") => "
- "(%d)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(uint64_t, SBData, GetUnsignedInt64,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
uint64_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -246,15 +241,13 @@ uint64_t SBData::GetUnsignedInt64(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetUnsignedInt64 (error=%p,offset=%" PRIu64 ") => "
- "(%" PRId64 ")",
- static_cast<void *>(error.get()), offset, value);
return value;
}
int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(int8_t, SBData, GetSignedInt8,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
int8_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -264,15 +257,13 @@ int8_t SBData::GetSignedInt8(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetSignedInt8 (error=%p,offset=%" PRIu64 ") => "
- "(%c)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(int16_t, SBData, GetSignedInt16,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
int16_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -282,15 +273,13 @@ int16_t SBData::GetSignedInt16(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetSignedInt16 (error=%p,offset=%" PRIu64 ") => "
- "(%hd)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(int32_t, SBData, GetSignedInt32,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
int32_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -300,15 +289,13 @@ int32_t SBData::GetSignedInt32(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetSignedInt32 (error=%p,offset=%" PRIu64 ") => "
- "(%d)",
- static_cast<void *>(error.get()), offset, value);
return value;
}
int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(int64_t, SBData, GetSignedInt64,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
int64_t value = 0;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
@@ -318,33 +305,30 @@ int64_t SBData::GetSignedInt64(lldb::SBError &error, lldb::offset_t offset) {
if (offset == old_offset)
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetSignedInt64 (error=%p,offset=%" PRIu64 ") => "
- "(%" PRId64 ")",
- static_cast<void *>(error.get()), offset, value);
return value;
}
const char *SBData::GetString(lldb::SBError &error, lldb::offset_t offset) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *value = 0;
+ LLDB_RECORD_METHOD(const char *, SBData, GetString,
+ (lldb::SBError &, lldb::offset_t), error, offset);
+
+ const char *value = nullptr;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
} else {
uint32_t old_offset = offset;
value = m_opaque_sp->GetCStr(&offset);
- if (offset == old_offset || (value == NULL))
+ if (offset == old_offset || (value == nullptr))
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::GetString (error=%p,offset=%" PRIu64 ") => (%p)",
- static_cast<void *>(error.get()), offset,
- static_cast<const void *>(value));
return value;
}
bool SBData::GetDescription(lldb::SBStream &description,
lldb::addr_t base_addr) {
+ LLDB_RECORD_METHOD(bool, SBData, GetDescription,
+ (lldb::SBStream &, lldb::addr_t), description, base_addr);
+
Stream &strm = description.ref();
if (m_opaque_sp) {
@@ -358,62 +342,56 @@ bool SBData::GetDescription(lldb::SBStream &description,
size_t SBData::ReadRawData(lldb::SBError &error, lldb::offset_t offset,
void *buf, size_t size) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- void *ok = NULL;
+ LLDB_RECORD_DUMMY(size_t, SBData, ReadRawData,
+ (lldb::SBError &, lldb::offset_t, void *, size_t), error,
+ offset, buf, size);
+
+ void *ok = nullptr;
if (!m_opaque_sp.get()) {
error.SetErrorString("no value to read from");
} else {
uint32_t old_offset = offset;
ok = m_opaque_sp->GetU8(&offset, buf, size);
- if ((offset == old_offset) || (ok == NULL))
+ if ((offset == old_offset) || (ok == nullptr))
error.SetErrorString("unable to read data");
}
- if (log)
- log->Printf("SBData::ReadRawData (error=%p,offset=%" PRIu64
- ",buf=%p,size=%" PRIu64 ") => "
- "(%p)",
- static_cast<void *>(error.get()), offset,
- static_cast<void *>(buf), static_cast<uint64_t>(size),
- static_cast<void *>(ok));
return ok ? size : 0;
}
void SBData::SetData(lldb::SBError &error, const void *buf, size_t size,
lldb::ByteOrder endian, uint8_t addr_size) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_DUMMY(
+ void, SBData, SetData,
+ (lldb::SBError &, const void *, size_t, lldb::ByteOrder, uint8_t), error,
+ buf, size, endian, addr_size);
+
if (!m_opaque_sp.get())
- m_opaque_sp.reset(new DataExtractor(buf, size, endian, addr_size));
+ m_opaque_sp = std::make_shared<DataExtractor>(buf, size, endian, addr_size);
else
{
m_opaque_sp->SetData(buf, size, endian);
m_opaque_sp->SetAddressByteSize(addr_size);
}
-
- if (log)
- log->Printf("SBData::SetData (error=%p,buf=%p,size=%" PRIu64
- ",endian=%d,addr_size=%c) => "
- "(%p)",
- static_cast<void *>(error.get()),
- static_cast<const void *>(buf), static_cast<uint64_t>(size),
- endian, addr_size, static_cast<void *>(m_opaque_sp.get()));
}
bool SBData::Append(const SBData &rhs) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, Append, (const lldb::SBData &), rhs);
+
bool value = false;
if (m_opaque_sp.get() && rhs.m_opaque_sp.get())
value = m_opaque_sp.get()->Append(*rhs.m_opaque_sp);
- if (log)
- log->Printf("SBData::Append (rhs=%p) => (%s)",
- static_cast<void *>(rhs.get()), value ? "true" : "false");
return value;
}
lldb::SBData SBData::CreateDataFromCString(lldb::ByteOrder endian,
uint32_t addr_byte_size,
const char *data) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromCString,
+ (lldb::ByteOrder, uint32_t, const char *), endian,
+ addr_byte_size, data);
+
if (!data || !data[0])
- return SBData();
+ return LLDB_RECORD_RESULT(SBData());
uint32_t data_len = strlen(data);
@@ -423,15 +401,19 @@ lldb::SBData SBData::CreateDataFromCString(lldb::ByteOrder endian,
SBData ret(data_sp);
- return ret;
+ return LLDB_RECORD_RESULT(ret);
}
lldb::SBData SBData::CreateDataFromUInt64Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
uint64_t *array,
size_t array_len) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromUInt64Array,
+ (lldb::ByteOrder, uint32_t, uint64_t *, size_t),
+ endian, addr_byte_size, array, array_len);
+
if (!array || array_len == 0)
- return SBData();
+ return LLDB_RECORD_RESULT(SBData());
size_t data_len = array_len * sizeof(uint64_t);
@@ -441,15 +423,19 @@ lldb::SBData SBData::CreateDataFromUInt64Array(lldb::ByteOrder endian,
SBData ret(data_sp);
- return ret;
+ return LLDB_RECORD_RESULT(ret);
}
lldb::SBData SBData::CreateDataFromUInt32Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
uint32_t *array,
size_t array_len) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromUInt32Array,
+ (lldb::ByteOrder, uint32_t, uint32_t *, size_t),
+ endian, addr_byte_size, array, array_len);
+
if (!array || array_len == 0)
- return SBData();
+ return LLDB_RECORD_RESULT(SBData());
size_t data_len = array_len * sizeof(uint32_t);
@@ -459,15 +445,19 @@ lldb::SBData SBData::CreateDataFromUInt32Array(lldb::ByteOrder endian,
SBData ret(data_sp);
- return ret;
+ return LLDB_RECORD_RESULT(ret);
}
lldb::SBData SBData::CreateDataFromSInt64Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
int64_t *array,
size_t array_len) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt64Array,
+ (lldb::ByteOrder, uint32_t, int64_t *, size_t),
+ endian, addr_byte_size, array, array_len);
+
if (!array || array_len == 0)
- return SBData();
+ return LLDB_RECORD_RESULT(SBData());
size_t data_len = array_len * sizeof(int64_t);
@@ -477,15 +467,19 @@ lldb::SBData SBData::CreateDataFromSInt64Array(lldb::ByteOrder endian,
SBData ret(data_sp);
- return ret;
+ return LLDB_RECORD_RESULT(ret);
}
lldb::SBData SBData::CreateDataFromSInt32Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
int32_t *array,
size_t array_len) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt32Array,
+ (lldb::ByteOrder, uint32_t, int32_t *, size_t),
+ endian, addr_byte_size, array, array_len);
+
if (!array || array_len == 0)
- return SBData();
+ return LLDB_RECORD_RESULT(SBData());
size_t data_len = array_len * sizeof(int32_t);
@@ -495,15 +489,19 @@ lldb::SBData SBData::CreateDataFromSInt32Array(lldb::ByteOrder endian,
SBData ret(data_sp);
- return ret;
+ return LLDB_RECORD_RESULT(ret);
}
lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian,
uint32_t addr_byte_size,
double *array,
size_t array_len) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromDoubleArray,
+ (lldb::ByteOrder, uint32_t, double *, size_t),
+ endian, addr_byte_size, array, array_len);
+
if (!array || array_len == 0)
- return SBData();
+ return LLDB_RECORD_RESULT(SBData());
size_t data_len = array_len * sizeof(double);
@@ -513,16 +511,14 @@ lldb::SBData SBData::CreateDataFromDoubleArray(lldb::ByteOrder endian,
SBData ret(data_sp);
- return ret;
+ return LLDB_RECORD_RESULT(ret);
}
bool SBData::SetDataFromCString(const char *data) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, SetDataFromCString, (const char *), data);
+
if (!data) {
- if (log)
- log->Printf("SBData::SetDataFromCString (data=%p) => false",
- static_cast<const void *>(data));
return false;
}
@@ -531,28 +527,21 @@ bool SBData::SetDataFromCString(const char *data) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(data, data_len));
if (!m_opaque_sp.get())
- m_opaque_sp.reset(
- new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(),
+ GetAddressByteSize());
else
m_opaque_sp->SetData(buffer_sp);
- if (log)
- log->Printf("SBData::SetDataFromCString (data=%p) => true",
- static_cast<const void *>(data));
return true;
}
bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt64Array, (uint64_t *, size_t),
+ array, array_len);
+
if (!array || array_len == 0) {
- if (log)
- log->Printf(
- "SBData::SetDataFromUInt64Array (array=%p, array_len = %" PRIu64
- ") => "
- "false",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
return false;
}
@@ -561,30 +550,21 @@ bool SBData::SetDataFromUInt64Array(uint64_t *array, size_t array_len) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
if (!m_opaque_sp.get())
- m_opaque_sp.reset(
- new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(),
+ GetAddressByteSize());
else
m_opaque_sp->SetData(buffer_sp);
- if (log)
- log->Printf("SBData::SetDataFromUInt64Array (array=%p, array_len = %" PRIu64
- ") => "
- "true",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
return true;
}
bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, SetDataFromUInt32Array, (uint32_t *, size_t),
+ array, array_len);
+
if (!array || array_len == 0) {
- if (log)
- log->Printf(
- "SBData::SetDataFromUInt32Array (array=%p, array_len = %" PRIu64
- ") => "
- "false",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
return false;
}
@@ -593,30 +573,20 @@ bool SBData::SetDataFromUInt32Array(uint32_t *array, size_t array_len) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
if (!m_opaque_sp.get())
- m_opaque_sp.reset(
- new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(),
+ GetAddressByteSize());
else
m_opaque_sp->SetData(buffer_sp);
- if (log)
- log->Printf("SBData::SetDataFromUInt32Array (array=%p, array_len = %" PRIu64
- ") => "
- "true",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
-
return true;
}
bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt64Array, (int64_t *, size_t),
+ array, array_len);
+
if (!array || array_len == 0) {
- if (log)
- log->Printf(
- "SBData::SetDataFromSInt64Array (array=%p, array_len = %" PRIu64
- ") => "
- "false",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
return false;
}
@@ -625,30 +595,20 @@ bool SBData::SetDataFromSInt64Array(int64_t *array, size_t array_len) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
if (!m_opaque_sp.get())
- m_opaque_sp.reset(
- new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(),
+ GetAddressByteSize());
else
m_opaque_sp->SetData(buffer_sp);
- if (log)
- log->Printf("SBData::SetDataFromSInt64Array (array=%p, array_len = %" PRIu64
- ") => "
- "true",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
-
return true;
}
bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, SetDataFromSInt32Array, (int32_t *, size_t),
+ array, array_len);
+
if (!array || array_len == 0) {
- if (log)
- log->Printf(
- "SBData::SetDataFromSInt32Array (array=%p, array_len = %" PRIu64
- ") => "
- "false",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
return false;
}
@@ -657,30 +617,20 @@ bool SBData::SetDataFromSInt32Array(int32_t *array, size_t array_len) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
if (!m_opaque_sp.get())
- m_opaque_sp.reset(
- new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(),
+ GetAddressByteSize());
else
m_opaque_sp->SetData(buffer_sp);
- if (log)
- log->Printf("SBData::SetDataFromSInt32Array (array=%p, array_len = %" PRIu64
- ") => "
- "true",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
-
return true;
}
bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBData, SetDataFromDoubleArray, (double *, size_t),
+ array, array_len);
+
if (!array || array_len == 0) {
- if (log)
- log->Printf(
- "SBData::SetDataFromDoubleArray (array=%p, array_len = %" PRIu64
- ") => "
- "false",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
return false;
}
@@ -689,16 +639,86 @@ bool SBData::SetDataFromDoubleArray(double *array, size_t array_len) {
lldb::DataBufferSP buffer_sp(new DataBufferHeap(array, data_len));
if (!m_opaque_sp.get())
- m_opaque_sp.reset(
- new DataExtractor(buffer_sp, GetByteOrder(), GetAddressByteSize()));
+ m_opaque_sp = std::make_shared<DataExtractor>(buffer_sp, GetByteOrder(),
+ GetAddressByteSize());
else
m_opaque_sp->SetData(buffer_sp);
- if (log)
- log->Printf("SBData::SetDataFromDoubleArray (array=%p, array_len = %" PRIu64
- ") => "
- "true",
- static_cast<void *>(array), static_cast<uint64_t>(array_len));
-
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBData>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBData, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBData, (const lldb::SBData &));
+ LLDB_REGISTER_METHOD(const lldb::SBData &,
+ SBData, operator=,(const lldb::SBData &));
+ LLDB_REGISTER_METHOD(bool, SBData, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBData, operator bool, ());
+ LLDB_REGISTER_METHOD(uint8_t, SBData, GetAddressByteSize, ());
+ LLDB_REGISTER_METHOD(void, SBData, SetAddressByteSize, (uint8_t));
+ LLDB_REGISTER_METHOD(void, SBData, Clear, ());
+ LLDB_REGISTER_METHOD(size_t, SBData, GetByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::ByteOrder, SBData, GetByteOrder, ());
+ LLDB_REGISTER_METHOD(void, SBData, SetByteOrder, (lldb::ByteOrder));
+ LLDB_REGISTER_METHOD(float, SBData, GetFloat,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(double, SBData, GetDouble,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(long double, SBData, GetLongDouble,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBData, GetAddress,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(uint8_t, SBData, GetUnsignedInt8,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(uint16_t, SBData, GetUnsignedInt16,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBData, GetUnsignedInt32,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(uint64_t, SBData, GetUnsignedInt64,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(int8_t, SBData, GetSignedInt8,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(int16_t, SBData, GetSignedInt16,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(int32_t, SBData, GetSignedInt32,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(int64_t, SBData, GetSignedInt64,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(const char *, SBData, GetString,
+ (lldb::SBError &, lldb::offset_t));
+ LLDB_REGISTER_METHOD(bool, SBData, GetDescription,
+ (lldb::SBStream &, lldb::addr_t));
+ LLDB_REGISTER_METHOD(bool, SBData, Append, (const lldb::SBData &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromCString,
+ (lldb::ByteOrder, uint32_t, const char *));
+ LLDB_REGISTER_STATIC_METHOD(
+ lldb::SBData, SBData, CreateDataFromUInt64Array,
+ (lldb::ByteOrder, uint32_t, uint64_t *, size_t));
+ LLDB_REGISTER_STATIC_METHOD(
+ lldb::SBData, SBData, CreateDataFromUInt32Array,
+ (lldb::ByteOrder, uint32_t, uint32_t *, size_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt64Array,
+ (lldb::ByteOrder, uint32_t, int64_t *, size_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromSInt32Array,
+ (lldb::ByteOrder, uint32_t, int32_t *, size_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBData, SBData, CreateDataFromDoubleArray,
+ (lldb::ByteOrder, uint32_t, double *, size_t));
+ LLDB_REGISTER_METHOD(bool, SBData, SetDataFromCString, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBData, SetDataFromUInt64Array,
+ (uint64_t *, size_t));
+ LLDB_REGISTER_METHOD(bool, SBData, SetDataFromUInt32Array,
+ (uint32_t *, size_t));
+ LLDB_REGISTER_METHOD(bool, SBData, SetDataFromSInt64Array,
+ (int64_t *, size_t));
+ LLDB_REGISTER_METHOD(bool, SBData, SetDataFromSInt32Array,
+ (int32_t *, size_t));
+ LLDB_REGISTER_METHOD(bool, SBData, SetDataFromDoubleArray,
+ (double *, size_t));
+}
+
+}
+}
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index af343233c90ec..634c4a9295953 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -1,13 +1,12 @@
//===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-
+#include "SBReproducerPrivate.h"
#include "SystemInitializerFull.h"
#include "lldb/API/SBDebugger.h"
@@ -58,6 +57,51 @@
using namespace lldb;
using namespace lldb_private;
+/// Helper class for replaying commands through the reproducer.
+class CommandLoader {
+public:
+ CommandLoader(std::vector<std::string> files) : m_files(files) {}
+
+ static std::unique_ptr<CommandLoader> Create() {
+ repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
+ if (!loader)
+ return {};
+
+ FileSpec file = loader->GetFile<repro::CommandProvider::Info>();
+ if (!file)
+ return {};
+
+ auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
+ if (auto err = error_or_file.getError())
+ return {};
+
+ std::vector<std::string> files;
+ llvm::yaml::Input yin((*error_or_file)->getBuffer());
+ yin >> files;
+
+ if (auto err = yin.error())
+ return {};
+
+ for (auto &file : files) {
+ FileSpec absolute_path =
+ loader->GetRoot().CopyByAppendingPathComponent(file);
+ file = absolute_path.GetPath();
+ }
+
+ return llvm::make_unique<CommandLoader>(std::move(files));
+ }
+
+ FILE *GetNextFile() {
+ if (m_index >= m_files.size())
+ return nullptr;
+ return FileSystem::Instance().Fopen(m_files[m_index++].c_str(), "r");
+ }
+
+private:
+ std::vector<std::string> m_files;
+ unsigned m_index = 0;
+};
+
static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp,
const FileSpec &spec,
Status &error) {
@@ -98,60 +142,83 @@ static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime;
SBError SBInputReader::Initialize(
lldb::SBDebugger &sb_debugger,
- unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction,
- char const *, unsigned long),
- void *, lldb::InputReaderGranularity, char const *, char const *, bool) {
+ unsigned long (*callback)(void *, lldb::SBInputReader *,
+ lldb::InputReaderAction, char const *,
+ unsigned long),
+ void *a, lldb::InputReaderGranularity b, char const *c, char const *d,
+ bool e) {
+ LLDB_RECORD_DUMMY(
+ lldb::SBError, SBInputReader, Initialize,
+ (lldb::SBDebugger &,
+ unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction,
+ const char *, unsigned long),
+ void *, lldb::InputReaderGranularity, const char *, const char *, bool),
+ sb_debugger, callback, a, b, c, d, e);
+
return SBError();
}
-void SBInputReader::SetIsDone(bool) {}
+void SBInputReader::SetIsDone(bool b) {
+ LLDB_RECORD_METHOD(void, SBInputReader, SetIsDone, (bool), b);
+}
-bool SBInputReader::IsActive() const { return false; }
+bool SBInputReader::IsActive() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInputReader, IsActive);
-SBDebugger::SBDebugger() = default;
+ return false;
+}
+
+SBDebugger::SBDebugger() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDebugger); }
SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp)
- : m_opaque_sp(debugger_sp) {}
+ : m_opaque_sp(debugger_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &), debugger_sp);
+}
-SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
+SBDebugger::SBDebugger(const SBDebugger &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &), rhs);
+}
SBDebugger::~SBDebugger() = default;
SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBDebugger &,
+ SBDebugger, operator=,(const lldb::SBDebugger &), rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
void SBDebugger::Initialize() {
- SBInitializerOptions options;
- SBDebugger::Initialize(options);
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize);
+ SBError ignored = SBDebugger::InitializeWithErrorHandling();
}
-lldb::SBError SBDebugger::Initialize(SBInitializerOptions &options) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+lldb::SBError SBDebugger::InitializeWithErrorHandling() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBError, SBDebugger,
+ InitializeWithErrorHandling);
+
- if (log)
- log->Printf("SBDebugger::Initialize ()");
SBError error;
if (auto e = g_debugger_lifetime->Initialize(
- llvm::make_unique<SystemInitializerFull>(), *options.m_opaque_up,
- LoadPlugin)) {
+ llvm::make_unique<SystemInitializerFull>(), LoadPlugin)) {
error.SetError(Status(std::move(e)));
}
- return error;
+ return LLDB_RECORD_RESULT(error);
}
-void SBDebugger::Terminate() { g_debugger_lifetime->Terminate(); }
+void SBDebugger::Terminate() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Terminate);
+
+ g_debugger_lifetime->Terminate();
+}
void SBDebugger::Clear() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, Clear);
- if (log)
- log->Printf("SBDebugger(%p)::Clear ()",
- static_cast<void *>(m_opaque_sp.get()));
if (m_opaque_sp)
m_opaque_sp->ClearIOHandlers();
@@ -160,18 +227,26 @@ void SBDebugger::Clear() {
}
SBDebugger SBDebugger::Create() {
- return SBDebugger::Create(false, nullptr, nullptr);
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBDebugger, SBDebugger, Create);
+
+ return LLDB_RECORD_RESULT(SBDebugger::Create(false, nullptr, nullptr));
}
SBDebugger SBDebugger::Create(bool source_init_files) {
- return SBDebugger::Create(source_init_files, nullptr, nullptr);
+ LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool),
+ source_init_files);
+
+ return LLDB_RECORD_RESULT(
+ SBDebugger::Create(source_init_files, nullptr, nullptr));
}
SBDebugger SBDebugger::Create(bool source_init_files,
lldb::LogOutputCallback callback, void *baton)
{
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_DUMMY(lldb::SBDebugger, SBDebugger, Create,
+ (bool, lldb::LogOutputCallback, void *), source_init_files,
+ callback, baton);
SBDebugger debugger;
@@ -185,13 +260,6 @@ SBDebugger SBDebugger::Create(bool source_init_files,
debugger.reset(Debugger::CreateInstance(callback, baton));
- if (log) {
- SBStream sstr;
- debugger.GetDescription(sstr);
- log->Printf("SBDebugger::Create () => SBDebugger(%p): %s",
- static_cast<void *>(debugger.m_opaque_sp.get()),
- sstr.GetData());
- }
SBCommandInterpreter interp = debugger.GetCommandInterpreter();
if (source_init_files) {
@@ -207,15 +275,9 @@ SBDebugger SBDebugger::Create(bool source_init_files,
}
void SBDebugger::Destroy(SBDebugger &debugger) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &),
+ debugger);
- if (log) {
- SBStream sstr;
- debugger.GetDescription(sstr);
- log->Printf("SBDebugger::Destroy () => SBDebugger(%p): %s",
- static_cast<void *>(debugger.m_opaque_sp.get()),
- sstr.GetData());
- }
Debugger::Destroy(debugger.m_opaque_sp);
@@ -224,38 +286,51 @@ void SBDebugger::Destroy(SBDebugger &debugger) {
}
void SBDebugger::MemoryPressureDetected() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, MemoryPressureDetected);
+
// Since this function can be call asynchronously, we allow it to be non-
// mandatory. We have seen deadlocks with this function when called so we
// need to safeguard against this until we can determine what is causing the
// deadlocks.
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
const bool mandatory = false;
- if (log) {
- log->Printf("SBDebugger::MemoryPressureDetected (), mandatory = %d",
- mandatory);
- }
ModuleList::RemoveOrphanSharedModules(mandatory);
}
-bool SBDebugger::IsValid() const { return m_opaque_sp.get() != nullptr; }
+bool SBDebugger::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, IsValid);
+ return this->operator bool();
+}
+SBDebugger::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
void SBDebugger::SetAsync(bool b) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetAsync, (bool), b);
+
if (m_opaque_sp)
m_opaque_sp->SetAsyncExecution(b);
}
bool SBDebugger::GetAsync() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetAsync);
+
return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false);
}
void SBDebugger::SkipLLDBInitFiles(bool b) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool), b);
+
if (m_opaque_sp)
m_opaque_sp->GetCommandInterpreter().SkipLLDBInitFiles(b);
}
void SBDebugger::SkipAppInitFiles(bool b) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SkipAppInitFiles, (bool), b);
+
if (m_opaque_sp)
m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b);
}
@@ -264,97 +339,102 @@ void SBDebugger::SkipAppInitFiles(bool b) {
// of problems; don't want users trying to switch modes in the middle of a
// debugging session.
void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh,
+ transfer_ownership);
- if (log)
- log->Printf(
- "SBDebugger(%p)::SetInputFileHandle (fh=%p, transfer_ownership=%i)",
- static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(fh),
- transfer_ownership);
+ if (!m_opaque_sp)
+ return;
- if (m_opaque_sp)
- m_opaque_sp->SetInputFileHandle(fh, transfer_ownership);
+ repro::DataRecorder *recorder = nullptr;
+ if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator())
+ recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder();
+
+ static std::unique_ptr<CommandLoader> loader = CommandLoader::Create();
+ if (loader)
+ fh = loader->GetNextFile();
+
+ m_opaque_sp->SetInputFileHandle(fh, transfer_ownership, recorder);
}
void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf(
- "SBDebugger(%p)::SetOutputFileHandle (fh=%p, transfer_ownership=%i)",
- static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(fh),
- transfer_ownership);
+ LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh,
+ transfer_ownership);
if (m_opaque_sp)
m_opaque_sp->SetOutputFileHandle(fh, transfer_ownership);
}
void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh,
+ transfer_ownership);
- if (log)
- log->Printf(
- "SBDebugger(%p)::SetErrorFileHandle (fh=%p, transfer_ownership=%i)",
- static_cast<void *>(m_opaque_sp.get()), static_cast<void *>(fh),
- transfer_ownership);
if (m_opaque_sp)
m_opaque_sp->SetErrorFileHandle(fh, transfer_ownership);
}
FILE *SBDebugger::GetInputFileHandle() {
+ LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetInputFileHandle);
+
if (m_opaque_sp) {
StreamFileSP stream_file_sp(m_opaque_sp->GetInputFile());
if (stream_file_sp)
- return stream_file_sp->GetFile().GetStream();
+ return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
}
return nullptr;
}
FILE *SBDebugger::GetOutputFileHandle() {
+ LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetOutputFileHandle);
+
if (m_opaque_sp) {
StreamFileSP stream_file_sp(m_opaque_sp->GetOutputFile());
if (stream_file_sp)
- return stream_file_sp->GetFile().GetStream();
+ return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
}
return nullptr;
}
FILE *SBDebugger::GetErrorFileHandle() {
+ LLDB_RECORD_METHOD_NO_ARGS(FILE *, SBDebugger, GetErrorFileHandle);
+
if (m_opaque_sp) {
StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile());
if (stream_file_sp)
- return stream_file_sp->GetFile().GetStream();
+ return LLDB_RECORD_RESULT(stream_file_sp->GetFile().GetStream());
}
return nullptr;
}
void SBDebugger::SaveInputTerminalState() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, SaveInputTerminalState);
+
if (m_opaque_sp)
m_opaque_sp->SaveInputTerminalState();
}
void SBDebugger::RestoreInputTerminalState() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, RestoreInputTerminalState);
+
if (m_opaque_sp)
m_opaque_sp->RestoreInputTerminalState();
}
SBCommandInterpreter SBDebugger::GetCommandInterpreter() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCommandInterpreter, SBDebugger,
+ GetCommandInterpreter);
+
SBCommandInterpreter sb_interpreter;
if (m_opaque_sp)
sb_interpreter.reset(&m_opaque_sp->GetCommandInterpreter());
- if (log)
- log->Printf(
- "SBDebugger(%p)::GetCommandInterpreter () => SBCommandInterpreter(%p)",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(sb_interpreter.get()));
- return sb_interpreter;
+ return LLDB_RECORD_RESULT(sb_interpreter);
}
void SBDebugger::HandleCommand(const char *command) {
+ LLDB_RECORD_METHOD(void, SBDebugger, HandleCommand, (const char *), command);
+
if (m_opaque_sp) {
TargetSP target_sp(m_opaque_sp->GetSelectedTarget());
std::unique_lock<std::recursive_mutex> lock;
@@ -389,23 +469,25 @@ void SBDebugger::HandleCommand(const char *command) {
}
SBListener SBDebugger::GetListener() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBDebugger, GetListener);
+
SBListener sb_listener;
if (m_opaque_sp)
sb_listener.reset(m_opaque_sp->GetListener());
- if (log)
- log->Printf("SBDebugger(%p)::GetListener () => SBListener(%p)",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(sb_listener.get()));
- return sb_listener;
+ return LLDB_RECORD_RESULT(sb_listener);
}
void SBDebugger::HandleProcessEvent(const SBProcess &process,
const SBEvent &event, FILE *out,
FILE *err) {
+ LLDB_RECORD_METHOD(
+ void, SBDebugger, HandleProcessEvent,
+ (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *), process,
+ event, out, err);
+
if (!process.IsValid())
return;
@@ -448,11 +530,17 @@ void SBDebugger::HandleProcessEvent(const SBProcess &process,
}
SBSourceManager SBDebugger::GetSourceManager() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBDebugger,
+ GetSourceManager);
+
SBSourceManager sb_source_manager(*this);
- return sb_source_manager;
+ return LLDB_RECORD_RESULT(sb_source_manager);
}
bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture,
+ (char *, size_t), "", arch_name_len);
+
if (arch_name && arch_name_len) {
ArchSpec default_arch = Target::GetDefaultArchitecture();
@@ -472,6 +560,9 @@ bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) {
}
bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture,
+ (const char *), arch_name);
+
if (arch_name) {
ArchSpec arch(arch_name);
if (arch.IsValid()) {
@@ -484,16 +575,24 @@ bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
ScriptLanguage
SBDebugger::GetScriptingLanguage(const char *script_language_name) {
+ LLDB_RECORD_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage,
+ (const char *), script_language_name);
+
if (!script_language_name) return eScriptLanguageDefault;
return OptionArgParser::ToScriptLanguage(
llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
}
const char *SBDebugger::GetVersionString() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, GetVersionString);
+
return lldb_private::GetVersion();
}
const char *SBDebugger::StateAsCString(StateType state) {
+ LLDB_RECORD_STATIC_METHOD(const char *, SBDebugger, StateAsCString,
+ (lldb::StateType), state);
+
return lldb_private::StateAsCString(state);
}
@@ -518,6 +617,9 @@ static void AddLLVMTargets(StructuredData::Dictionary &dict) {
}
SBStructuredData SBDebugger::GetBuildConfiguration() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBStructuredData, SBDebugger,
+ GetBuildConfiguration);
+
auto config_up = llvm::make_unique<StructuredData::Dictionary>();
AddBoolConfigEntry(
*config_up, "xml", XMLDocument::XMLEnabled(),
@@ -526,27 +628,25 @@ SBStructuredData SBDebugger::GetBuildConfiguration() {
SBStructuredData data;
data.m_impl_up->SetObjectSP(std::move(config_up));
- return data;
+ return LLDB_RECORD_RESULT(data);
}
bool SBDebugger::StateIsRunningState(StateType state) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsRunningState,
+ (lldb::StateType), state);
+
const bool result = lldb_private::StateIsRunningState(state);
- if (log)
- log->Printf("SBDebugger::StateIsRunningState (state=%s) => %i",
- StateAsCString(state), result);
return result;
}
bool SBDebugger::StateIsStoppedState(StateType state) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState,
+ (lldb::StateType), state);
+
const bool result = lldb_private::StateIsStoppedState(state, false);
- if (log)
- log->Printf("SBDebugger::StateIsStoppedState (state=%s) => %i",
- StateAsCString(state), result);
return result;
}
@@ -556,6 +656,11 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename,
const char *platform_name,
bool add_dependent_modules,
lldb::SBError &sb_error) {
+ LLDB_RECORD_METHOD(
+ lldb::SBTarget, SBDebugger, CreateTarget,
+ (const char *, const char *, const char *, bool, lldb::SBError &),
+ filename, target_triple, platform_name, add_dependent_modules, sb_error);
+
SBTarget sb_target;
TargetSP target_sp;
if (m_opaque_sp) {
@@ -583,12 +688,16 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename,
platform_name, add_dependent_modules, sb_error.GetCString(),
static_cast<void *>(target_sp.get()));
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBTarget
SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename,
const char *target_triple) {
+ LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger,
+ CreateTargetWithFileAndTargetTriple,
+ (const char *, const char *), filename, target_triple);
+
SBTarget sb_target;
TargetSP target_sp;
if (m_opaque_sp) {
@@ -607,11 +716,14 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename,
static_cast<void *>(m_opaque_sp.get()), filename, target_triple,
static_cast<void *>(target_sp.get()));
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
const char *arch_cstr) {
+ LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTargetWithFileAndArch,
+ (const char *, const char *), filename, arch_cstr);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
SBTarget sb_target;
@@ -637,10 +749,13 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename,
static_cast<void *>(m_opaque_sp.get()), filename, arch_cstr,
static_cast<void *>(target_sp.get()));
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBTarget SBDebugger::CreateTarget(const char *filename) {
+ LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, CreateTarget, (const char *),
+ filename);
+
SBTarget sb_target;
TargetSP target_sp;
if (m_opaque_sp) {
@@ -662,10 +777,12 @@ SBTarget SBDebugger::CreateTarget(const char *filename) {
"SBDebugger(%p)::CreateTarget (filename=\"%s\") => SBTarget(%p)",
static_cast<void *>(m_opaque_sp.get()), filename,
static_cast<void *>(target_sp.get()));
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBTarget SBDebugger::GetDummyTarget() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetDummyTarget);
+
SBTarget sb_target;
if (m_opaque_sp) {
sb_target.SetSP(m_opaque_sp->GetDummyTarget()->shared_from_this());
@@ -676,10 +793,13 @@ SBTarget SBDebugger::GetDummyTarget() {
"SBDebugger(%p)::GetDummyTarget() => SBTarget(%p)",
static_cast<void *>(m_opaque_sp.get()),
static_cast<void *>(sb_target.GetSP().get()));
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
bool SBDebugger::DeleteTarget(lldb::SBTarget &target) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &),
+ target);
+
bool result = false;
if (m_opaque_sp) {
TargetSP target_sp(target.GetSP());
@@ -703,15 +823,20 @@ bool SBDebugger::DeleteTarget(lldb::SBTarget &target) {
}
SBTarget SBDebugger::GetTargetAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex, (uint32_t),
+ idx);
+
SBTarget sb_target;
if (m_opaque_sp) {
// No need to lock, the target list is thread safe
sb_target.SetSP(m_opaque_sp->GetTargetList().GetTargetAtIndex(idx));
}
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) {
+ LLDB_RECORD_METHOD(uint32_t, SBDebugger, GetIndexOfTarget, (lldb::SBTarget),
+ target);
lldb::TargetSP target_sp = target.GetSP();
if (!target_sp)
@@ -724,16 +849,22 @@ uint32_t SBDebugger::GetIndexOfTarget(lldb::SBTarget target) {
}
SBTarget SBDebugger::FindTargetWithProcessID(lldb::pid_t pid) {
+ LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID,
+ (lldb::pid_t), pid);
+
SBTarget sb_target;
if (m_opaque_sp) {
// No need to lock, the target list is thread safe
sb_target.SetSP(m_opaque_sp->GetTargetList().FindTargetWithProcessID(pid));
}
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename,
const char *arch_name) {
+ LLDB_RECORD_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch,
+ (const char *, const char *), filename, arch_name);
+
SBTarget sb_target;
if (m_opaque_sp && filename && filename[0]) {
// No need to lock, the target list is thread safe
@@ -744,7 +875,7 @@ SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename,
FileSpec(filename), arch_name ? &arch : nullptr));
sb_target.SetSP(target_sp);
}
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) {
@@ -758,6 +889,8 @@ SBTarget SBDebugger::FindTargetWithLLDBProcess(const ProcessSP &process_sp) {
}
uint32_t SBDebugger::GetNumTargets() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumTargets);
+
if (m_opaque_sp) {
// No need to lock, the target list is thread safe
return m_opaque_sp->GetTargetList().GetNumTargets();
@@ -766,6 +899,8 @@ uint32_t SBDebugger::GetNumTargets() {
}
SBTarget SBDebugger::GetSelectedTarget() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBDebugger, GetSelectedTarget);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
SBTarget sb_target;
@@ -784,10 +919,13 @@ SBTarget SBDebugger::GetSelectedTarget() {
static_cast<void *>(target_sp.get()), sstr.GetData());
}
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedTarget, (lldb::SBTarget &),
+ sb_target);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
TargetSP target_sp(sb_target.GetSP());
@@ -804,6 +942,8 @@ void SBDebugger::SetSelectedTarget(SBTarget &sb_target) {
}
SBPlatform SBDebugger::GetSelectedPlatform() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBDebugger, GetSelectedPlatform);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
SBPlatform sb_platform;
@@ -816,10 +956,13 @@ SBPlatform SBDebugger::GetSelectedPlatform() {
static_cast<void *>(m_opaque_sp.get()),
static_cast<void *>(sb_platform.GetSP().get()),
sb_platform.GetName());
- return sb_platform;
+ return LLDB_RECORD_RESULT(sb_platform);
}
void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetSelectedPlatform,
+ (lldb::SBPlatform &), sb_platform);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
DebuggerSP debugger_sp(m_opaque_sp);
@@ -835,6 +978,8 @@ void SBDebugger::SetSelectedPlatform(SBPlatform &sb_platform) {
}
uint32_t SBDebugger::GetNumPlatforms() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumPlatforms);
+
if (m_opaque_sp) {
// No need to lock, the platform list is thread safe
return m_opaque_sp->GetPlatformList().GetSize();
@@ -843,15 +988,20 @@ uint32_t SBDebugger::GetNumPlatforms() {
}
SBPlatform SBDebugger::GetPlatformAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex,
+ (uint32_t), idx);
+
SBPlatform sb_platform;
if (m_opaque_sp) {
// No need to lock, the platform list is thread safe
sb_platform.SetSP(m_opaque_sp->GetPlatformList().GetAtIndex(idx));
}
- return sb_platform;
+ return LLDB_RECORD_RESULT(sb_platform);
}
uint32_t SBDebugger::GetNumAvailablePlatforms() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumAvailablePlatforms);
+
uint32_t idx = 0;
while (true) {
if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) {
@@ -864,6 +1014,9 @@ uint32_t SBDebugger::GetNumAvailablePlatforms() {
}
SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBStructuredData, SBDebugger,
+ GetAvailablePlatformInfoAtIndex, (uint32_t), idx);
+
SBStructuredData data;
auto platform_dict = llvm::make_unique<StructuredData::Dictionary>();
llvm::StringRef name_str("name"), desc_str("description");
@@ -878,28 +1031,34 @@ SBStructuredData SBDebugger::GetAvailablePlatformInfoAtIndex(uint32_t idx) {
const char *plugin_name =
PluginManager::GetPlatformPluginNameAtIndex(idx - 1);
if (!plugin_name) {
- return data;
+ return LLDB_RECORD_RESULT(data);
}
platform_dict->AddStringItem(name_str, llvm::StringRef(plugin_name));
const char *plugin_desc =
PluginManager::GetPlatformPluginDescriptionAtIndex(idx - 1);
if (!plugin_desc) {
- return data;
+ return LLDB_RECORD_RESULT(data);
}
platform_dict->AddStringItem(desc_str, llvm::StringRef(plugin_desc));
}
data.m_impl_up->SetObjectSP(
StructuredData::ObjectSP(platform_dict.release()));
- return data;
+ return LLDB_RECORD_RESULT(data);
}
void SBDebugger::DispatchInput(void *baton, const void *data, size_t data_len) {
+ LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput,
+ (void *, const void *, size_t), baton, data, data_len);
+
DispatchInput(data, data_len);
}
void SBDebugger::DispatchInput(const void *data, size_t data_len) {
+ LLDB_RECORD_DUMMY(void, SBDebugger, DispatchInput, (const void *, size_t),
+ data, data_len);
+
// Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
//
// if (log)
@@ -915,19 +1074,29 @@ void SBDebugger::DispatchInput(const void *data, size_t data_len) {
}
void SBDebugger::DispatchInputInterrupt() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputInterrupt);
+
if (m_opaque_sp)
m_opaque_sp->DispatchInputInterrupt();
}
void SBDebugger::DispatchInputEndOfFile() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBDebugger, DispatchInputEndOfFile);
+
if (m_opaque_sp)
m_opaque_sp->DispatchInputEndOfFile();
}
-void SBDebugger::PushInputReader(SBInputReader &reader) {}
+void SBDebugger::PushInputReader(SBInputReader &reader) {
+ LLDB_RECORD_METHOD(void, SBDebugger, PushInputReader, (lldb::SBInputReader &),
+ reader);
+}
void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
bool spawn_thread) {
+ LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool),
+ auto_handle_events, spawn_thread);
+
if (m_opaque_sp) {
CommandInterpreterRunOptions options;
@@ -943,6 +1112,12 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
bool &stopped_for_crash)
{
+ LLDB_RECORD_METHOD(void, SBDebugger, RunCommandInterpreter,
+ (bool, bool, lldb::SBCommandInterpreterRunOptions &, int &,
+ bool &, bool &),
+ auto_handle_events, spawn_thread, options, num_errors,
+ quit_requested, stopped_for_crash);
+
if (m_opaque_sp) {
CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter();
interp.RunCommandInterpreter(auto_handle_events, spawn_thread,
@@ -955,12 +1130,16 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events,
SBError SBDebugger::RunREPL(lldb::LanguageType language,
const char *repl_options) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL,
+ (lldb::LanguageType, const char *), language,
+ repl_options);
+
SBError error;
if (m_opaque_sp)
error.ref() = m_opaque_sp->RunREPL(language, repl_options);
else
error.SetErrorString("invalid debugger");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
void SBDebugger::reset(const DebuggerSP &debugger_sp) {
@@ -977,20 +1156,29 @@ Debugger &SBDebugger::ref() const {
const lldb::DebuggerSP &SBDebugger::get_sp() const { return m_opaque_sp; }
SBDebugger SBDebugger::FindDebuggerWithID(int id) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBDebugger, SBDebugger, FindDebuggerWithID,
+ (int), id);
+
// No need to lock, the debugger list is thread safe
SBDebugger sb_debugger;
DebuggerSP debugger_sp = Debugger::FindDebuggerWithID(id);
if (debugger_sp)
sb_debugger.reset(debugger_sp);
- return sb_debugger;
+ return LLDB_RECORD_RESULT(sb_debugger);
}
const char *SBDebugger::GetInstanceName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBDebugger, GetInstanceName);
+
return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr);
}
SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
const char *debugger_instance_name) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable,
+ (const char *, const char *, const char *),
+ var_name, value, debugger_instance_name);
+
SBError sb_error;
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
ConstString(debugger_instance_name)));
@@ -1006,12 +1194,16 @@ SBError SBDebugger::SetInternalVariable(const char *var_name, const char *value,
}
if (error.Fail())
sb_error.SetError(error);
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBStringList
SBDebugger::GetInternalVariableValue(const char *var_name,
const char *debugger_instance_name) {
+ LLDB_RECORD_STATIC_METHOD(
+ lldb::SBStringList, SBDebugger, GetInternalVariableValue,
+ (const char *, const char *), var_name, debugger_instance_name);
+
SBStringList ret_value;
DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName(
ConstString(debugger_instance_name)));
@@ -1028,23 +1220,30 @@ SBDebugger::GetInternalVariableValue(const char *var_name,
if (!value_str.empty()) {
StringList string_list;
string_list.SplitIntoLines(value_str);
- return SBStringList(&string_list);
+ return LLDB_RECORD_RESULT(SBStringList(&string_list));
}
}
}
- return SBStringList();
+ return LLDB_RECORD_RESULT(SBStringList());
}
uint32_t SBDebugger::GetTerminalWidth() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDebugger, GetTerminalWidth);
+
return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0);
}
void SBDebugger::SetTerminalWidth(uint32_t term_width) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t),
+ term_width);
+
if (m_opaque_sp)
m_opaque_sp->SetTerminalWidth(term_width);
}
const char *SBDebugger::GetPrompt() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetPrompt);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (log)
@@ -1057,43 +1256,64 @@ const char *SBDebugger::GetPrompt() const {
}
void SBDebugger::SetPrompt(const char *prompt) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt);
+
if (m_opaque_sp)
m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt));
}
const char *SBDebugger::GetReproducerPath() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBDebugger, GetReproducerPath);
+
return (m_opaque_sp
? ConstString(m_opaque_sp->GetReproducerPath()).GetCString()
: nullptr);
}
ScriptLanguage SBDebugger::GetScriptLanguage() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ScriptLanguage, SBDebugger,
+ GetScriptLanguage);
+
return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone);
}
void SBDebugger::SetScriptLanguage(ScriptLanguage script_lang) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetScriptLanguage,
+ (lldb::ScriptLanguage), script_lang);
+
if (m_opaque_sp) {
m_opaque_sp->SetScriptLanguage(script_lang);
}
}
bool SBDebugger::SetUseExternalEditor(bool value) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool), value);
+
return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false);
}
bool SBDebugger::GetUseExternalEditor() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBDebugger, GetUseExternalEditor);
+
return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false);
}
bool SBDebugger::SetUseColor(bool value) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, SetUseColor, (bool), value);
+
return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false);
}
bool SBDebugger::GetUseColor() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseColor);
+
return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false);
}
bool SBDebugger::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
if (m_opaque_sp) {
@@ -1107,10 +1327,15 @@ bool SBDebugger::GetDescription(SBStream &description) {
}
user_id_t SBDebugger::GetID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBDebugger, GetID);
+
return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID);
}
SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform,
+ (const char *), platform_name_cstr);
+
SBError sb_error;
if (m_opaque_sp) {
if (platform_name_cstr && platform_name_cstr[0]) {
@@ -1135,10 +1360,13 @@ SBError SBDebugger::SetCurrentPlatform(const char *platform_name_cstr) {
} else {
sb_error.ref().SetErrorString("invalid debugger");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot,
+ (const char *), sysroot);
+
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (m_opaque_sp) {
PlatformSP platform_sp(
@@ -1155,49 +1383,68 @@ bool SBDebugger::SetCurrentPlatformSDKRoot(const char *sysroot) {
}
bool SBDebugger::GetCloseInputOnEOF() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetCloseInputOnEOF);
+
return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false);
}
void SBDebugger::SetCloseInputOnEOF(bool b) {
+ LLDB_RECORD_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool), b);
+
if (m_opaque_sp)
m_opaque_sp->SetCloseInputOnEOF(b);
}
SBTypeCategory SBDebugger::GetCategory(const char *category_name) {
+ LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
+ (const char *), category_name);
+
if (!category_name || *category_name == 0)
- return SBTypeCategory();
+ return LLDB_RECORD_RESULT(SBTypeCategory());
TypeCategoryImplSP category_sp;
if (DataVisualization::Categories::GetCategory(ConstString(category_name),
- category_sp, false))
- return SBTypeCategory(category_sp);
- else
- return SBTypeCategory();
+ category_sp, false)) {
+ return LLDB_RECORD_RESULT(SBTypeCategory(category_sp));
+ } else {
+ return LLDB_RECORD_RESULT(SBTypeCategory());
+ }
}
SBTypeCategory SBDebugger::GetCategory(lldb::LanguageType lang_type) {
+ LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
+ (lldb::LanguageType), lang_type);
+
TypeCategoryImplSP category_sp;
- if (DataVisualization::Categories::GetCategory(lang_type, category_sp))
- return SBTypeCategory(category_sp);
- else
- return SBTypeCategory();
+ if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) {
+ return LLDB_RECORD_RESULT(SBTypeCategory(category_sp));
+ } else {
+ return LLDB_RECORD_RESULT(SBTypeCategory());
+ }
}
SBTypeCategory SBDebugger::CreateCategory(const char *category_name) {
+ LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory,
+ (const char *), category_name);
+
if (!category_name || *category_name == 0)
- return SBTypeCategory();
+ return LLDB_RECORD_RESULT(SBTypeCategory());
TypeCategoryImplSP category_sp;
if (DataVisualization::Categories::GetCategory(ConstString(category_name),
- category_sp, true))
- return SBTypeCategory(category_sp);
- else
- return SBTypeCategory();
+ category_sp, true)) {
+ return LLDB_RECORD_RESULT(SBTypeCategory(category_sp));
+ } else {
+ return LLDB_RECORD_RESULT(SBTypeCategory());
+ }
}
bool SBDebugger::DeleteCategory(const char *category_name) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, DeleteCategory, (const char *),
+ category_name);
+
if (!category_name || *category_name == 0)
return false;
@@ -1205,47 +1452,65 @@ bool SBDebugger::DeleteCategory(const char *category_name) {
}
uint32_t SBDebugger::GetNumCategories() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBDebugger, GetNumCategories);
+
return DataVisualization::Categories::GetCount();
}
SBTypeCategory SBDebugger::GetCategoryAtIndex(uint32_t index) {
- return SBTypeCategory(
- DataVisualization::Categories::GetCategoryAtIndex(index));
+ LLDB_RECORD_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex,
+ (uint32_t), index);
+
+ return LLDB_RECORD_RESULT(
+ SBTypeCategory(DataVisualization::Categories::GetCategoryAtIndex(index)));
}
SBTypeCategory SBDebugger::GetDefaultCategory() {
- return GetCategory("default");
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeCategory, SBDebugger,
+ GetDefaultCategory);
+
+ return LLDB_RECORD_RESULT(GetCategory("default"));
}
SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType,
+ (lldb::SBTypeNameSpecifier), type_name);
+
SBTypeCategory default_category_sb = GetDefaultCategory();
if (default_category_sb.GetEnabled())
- return default_category_sb.GetFormatForType(type_name);
- return SBTypeFormat();
+ return LLDB_RECORD_RESULT(default_category_sb.GetFormatForType(type_name));
+ return LLDB_RECORD_RESULT(SBTypeFormat());
}
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!type_name.IsValid())
- return SBTypeSummary();
- return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()));
+ return LLDB_RECORD_RESULT(SBTypeSummary());
+ return LLDB_RECORD_RESULT(
+ SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP())));
}
-#endif // LLDB_DISABLE_PYTHON
SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!type_name.IsValid())
- return SBTypeFilter();
- return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()));
+ return LLDB_RECORD_RESULT(SBTypeFilter());
+ return LLDB_RECORD_RESULT(
+ SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP())));
}
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!type_name.IsValid())
- return SBTypeSynthetic();
- return SBTypeSynthetic(
- DataVisualization::GetSyntheticForType(type_name.GetSP()));
+ return LLDB_RECORD_RESULT(SBTypeSynthetic());
+ return LLDB_RECORD_RESULT(SBTypeSynthetic(
+ DataVisualization::GetSyntheticForType(type_name.GetSP())));
}
-#endif // LLDB_DISABLE_PYTHON
static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
if (categories == nullptr)
@@ -1257,6 +1522,9 @@ static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
}
bool SBDebugger::EnableLog(const char *channel, const char **categories) {
+ LLDB_RECORD_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **),
+ channel, categories);
+
if (m_opaque_sp) {
uint32_t log_options =
LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME;
@@ -1270,7 +1538,193 @@ bool SBDebugger::EnableLog(const char *channel, const char **categories) {
void SBDebugger::SetLoggingCallback(lldb::LogOutputCallback log_callback,
void *baton) {
+ LLDB_RECORD_DUMMY(void, SBDebugger, SetLoggingCallback,
+ (lldb::LogOutputCallback, void *), log_callback, baton);
+
if (m_opaque_sp) {
return m_opaque_sp->SetLoggingCallback(log_callback, baton);
}
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBInputReader>(Registry &R) {
+ LLDB_REGISTER_METHOD(void, SBInputReader, SetIsDone, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBInputReader, IsActive, ());
+}
+
+static void SetFileHandleRedirect(SBDebugger *, FILE *, bool) {
+ // Do nothing.
+}
+
+static bool GetDefaultArchitectureRedirect(char *arch_name,
+ size_t arch_name_len) {
+ // The function is writing to its argument. Without the redirect it would
+ // write into the replay buffer.
+ char buffer[1024];
+ return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len);
+}
+
+template <>
+void RegisterMethods<SBDebugger>(Registry &R) {
+ // Custom implementation.
+ R.Register(&invoke<void (SBDebugger::*)(
+ FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit,
+ &SetFileHandleRedirect);
+ R.Register(&invoke<void (SBDebugger::*)(
+ FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit,
+ &SetFileHandleRedirect);
+ R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>(
+ &SBDebugger::GetDefaultArchitecture),
+ &GetDefaultArchitectureRedirect);
+
+ LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &));
+ LLDB_REGISTER_METHOD(lldb::SBDebugger &,
+ SBDebugger, operator=,(const lldb::SBDebugger &));
+ LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Initialize, ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger,
+ InitializeWithErrorHandling, ());
+ LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Terminate, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool));
+ LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy,
+ (lldb::SBDebugger &));
+ LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetAsync, (bool));
+ LLDB_REGISTER_METHOD(bool, SBDebugger, GetAsync, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SkipLLDBInitFiles, (bool));
+ LLDB_REGISTER_METHOD(void, SBDebugger, SkipAppInitFiles, (bool));
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool));
+ LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetInputFileHandle, ());
+ LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetOutputFileHandle, ());
+ LLDB_REGISTER_METHOD(FILE *, SBDebugger, GetErrorFileHandle, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SaveInputTerminalState, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, RestoreInputTerminalState, ());
+ LLDB_REGISTER_METHOD(lldb::SBCommandInterpreter, SBDebugger,
+ GetCommandInterpreter, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, HandleCommand, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBListener, SBDebugger, GetListener, ());
+ LLDB_REGISTER_METHOD(
+ void, SBDebugger, HandleProcessEvent,
+ (const lldb::SBProcess &, const lldb::SBEvent &, FILE *, FILE *));
+ LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBDebugger, GetSourceManager,
+ ());
+ LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, SetDefaultArchitecture,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::ScriptLanguage, SBDebugger, GetScriptingLanguage,
+ (const char *));
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetVersionString, ());
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, StateAsCString,
+ (lldb::StateType));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBDebugger,
+ GetBuildConfiguration, ());
+ LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsRunningState,
+ (lldb::StateType));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBDebugger, StateIsStoppedState,
+ (lldb::StateType));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTarget, SBDebugger, CreateTarget,
+ (const char *, const char *, const char *, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger,
+ CreateTargetWithFileAndTargetTriple,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger,
+ CreateTargetWithFileAndArch,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, CreateTarget,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetDummyTarget, ());
+ LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteTarget, (lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetTargetAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetIndexOfTarget,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithProcessID,
+ (lldb::pid_t));
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, FindTargetWithFileAndArch,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumTargets, ());
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBDebugger, GetSelectedTarget, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedTarget,
+ (lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetSelectedPlatform, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetSelectedPlatform,
+ (lldb::SBPlatform &));
+ LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumPlatforms, ());
+ LLDB_REGISTER_METHOD(lldb::SBPlatform, SBDebugger, GetPlatformAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumAvailablePlatforms, ());
+ LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBDebugger,
+ GetAvailablePlatformInfoAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputInterrupt, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, DispatchInputEndOfFile, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, PushInputReader,
+ (lldb::SBInputReader &));
+ LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter, (bool, bool));
+ LLDB_REGISTER_METHOD(void, SBDebugger, RunCommandInterpreter,
+ (bool, bool, lldb::SBCommandInterpreterRunOptions &,
+ int &, bool &, bool &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, RunREPL,
+ (lldb::LanguageType, const char *));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger,
+ FindDebuggerWithID, (int));
+ LLDB_REGISTER_METHOD(const char *, SBDebugger, GetInstanceName, ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBError, SBDebugger, SetInternalVariable,
+ (const char *, const char *, const char *));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBStringList, SBDebugger,
+ GetInternalVariableValue,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBDebugger, GetTerminalWidth, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetTerminalWidth, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetPrompt, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetPrompt, (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBDebugger, GetReproducerPath, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::ScriptLanguage, SBDebugger,
+ GetScriptLanguage, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetScriptLanguage,
+ (lldb::ScriptLanguage));
+ LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseExternalEditor, (bool));
+ LLDB_REGISTER_METHOD(bool, SBDebugger, GetUseExternalEditor, ());
+ LLDB_REGISTER_METHOD(bool, SBDebugger, SetUseColor, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetUseColor, ());
+ LLDB_REGISTER_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::user_id_t, SBDebugger, GetID, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBDebugger, SetCurrentPlatform,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBDebugger, SetCurrentPlatformSDKRoot,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, GetCloseInputOnEOF, ());
+ LLDB_REGISTER_METHOD(void, SBDebugger, SetCloseInputOnEOF, (bool));
+ LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategory,
+ (lldb::LanguageType));
+ LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, CreateCategory,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBDebugger, DeleteCategory, (const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBDebugger, GetNumCategories, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetCategoryAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeCategory, SBDebugger, GetDefaultCategory,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog,
+ (const char *, const char **));
+}
+
+}
+}
diff --git a/source/API/SBDeclaration.cpp b/source/API/SBDeclaration.cpp
index 90e4db367d2a7..a7790b2939810 100644
--- a/source/API/SBDeclaration.cpp
+++ b/source/API/SBDeclaration.cpp
@@ -1,17 +1,17 @@
//===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBDeclaration.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/Declaration.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include <limits.h>
@@ -19,27 +19,30 @@
using namespace lldb;
using namespace lldb_private;
-SBDeclaration::SBDeclaration() : m_opaque_ap() {}
+SBDeclaration::SBDeclaration() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBDeclaration);
+}
+
+SBDeclaration::SBDeclaration(const SBDeclaration &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &), rhs);
-SBDeclaration::SBDeclaration(const SBDeclaration &rhs) : m_opaque_ap() {
- if (rhs.IsValid())
- ref() = rhs.ref();
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBDeclaration::SBDeclaration(const lldb_private::Declaration *lldb_object_ptr)
- : m_opaque_ap() {
+ : m_opaque_up() {
if (lldb_object_ptr)
- ref() = *lldb_object_ptr;
+ m_opaque_up = llvm::make_unique<Declaration>(*lldb_object_ptr);
}
const SBDeclaration &SBDeclaration::operator=(const SBDeclaration &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- ref() = rhs.ref();
- else
- m_opaque_ap.reset();
- }
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBDeclaration &,
+ SBDeclaration, operator=,(const lldb::SBDeclaration &),
+ rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
void SBDeclaration::SetDeclaration(
@@ -50,60 +53,75 @@ void SBDeclaration::SetDeclaration(
SBDeclaration::~SBDeclaration() {}
bool SBDeclaration::IsValid() const {
- return m_opaque_ap.get() && m_opaque_ap->IsValid();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, IsValid);
+ return this->operator bool();
+}
+SBDeclaration::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, operator bool);
+
+ return m_opaque_up.get() && m_opaque_up->IsValid();
}
SBFileSpec SBDeclaration::GetFileSpec() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBDeclaration,
+ GetFileSpec);
+
SBFileSpec sb_file_spec;
- if (m_opaque_ap.get() && m_opaque_ap->GetFile())
- sb_file_spec.SetFileSpec(m_opaque_ap->GetFile());
+ if (m_opaque_up.get() && m_opaque_up->GetFile())
+ sb_file_spec.SetFileSpec(m_opaque_up->GetFile());
- if (log) {
- SBStream sstr;
- sb_file_spec.GetDescription(sstr);
- log->Printf("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<const void *>(sb_file_spec.get()), sstr.GetData());
- }
- return sb_file_spec;
+ return LLDB_RECORD_RESULT(sb_file_spec);
}
uint32_t SBDeclaration::GetLine() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetLine);
+
uint32_t line = 0;
- if (m_opaque_ap)
- line = m_opaque_ap->GetLine();
+ if (m_opaque_up)
+ line = m_opaque_up->GetLine();
- if (log)
- log->Printf("SBLineEntry(%p)::GetLine () => %u",
- static_cast<void *>(m_opaque_ap.get()), line);
return line;
}
uint32_t SBDeclaration::GetColumn() const {
- if (m_opaque_ap)
- return m_opaque_ap->GetColumn();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBDeclaration, GetColumn);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetColumn();
return 0;
}
void SBDeclaration::SetFileSpec(lldb::SBFileSpec filespec) {
+ LLDB_RECORD_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec),
+ filespec);
+
if (filespec.IsValid())
ref().SetFile(filespec.ref());
else
ref().SetFile(FileSpec());
}
-void SBDeclaration::SetLine(uint32_t line) { ref().SetLine(line); }
+void SBDeclaration::SetLine(uint32_t line) {
+ LLDB_RECORD_METHOD(void, SBDeclaration, SetLine, (uint32_t), line);
-void SBDeclaration::SetColumn(uint32_t column) { ref().SetColumn(column); }
+ ref().SetLine(line);
+}
+
+void SBDeclaration::SetColumn(uint32_t column) {
+ LLDB_RECORD_METHOD(void, SBDeclaration, SetColumn, (uint32_t), column);
+
+ ref().SetColumn(column);
+}
bool SBDeclaration::operator==(const SBDeclaration &rhs) const {
- lldb_private::Declaration *lhs_ptr = m_opaque_ap.get();
- lldb_private::Declaration *rhs_ptr = rhs.m_opaque_ap.get();
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBDeclaration, operator==,(const lldb::SBDeclaration &), rhs);
+
+ lldb_private::Declaration *lhs_ptr = m_opaque_up.get();
+ lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get();
if (lhs_ptr && rhs_ptr)
return lldb_private::Declaration::Compare(*lhs_ptr, *rhs_ptr) == 0;
@@ -112,8 +130,11 @@ bool SBDeclaration::operator==(const SBDeclaration &rhs) const {
}
bool SBDeclaration::operator!=(const SBDeclaration &rhs) const {
- lldb_private::Declaration *lhs_ptr = m_opaque_ap.get();
- lldb_private::Declaration *rhs_ptr = rhs.m_opaque_ap.get();
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &), rhs);
+
+ lldb_private::Declaration *lhs_ptr = m_opaque_up.get();
+ lldb_private::Declaration *rhs_ptr = rhs.m_opaque_up.get();
if (lhs_ptr && rhs_ptr)
return lldb_private::Declaration::Compare(*lhs_ptr, *rhs_ptr) != 0;
@@ -122,25 +143,28 @@ bool SBDeclaration::operator!=(const SBDeclaration &rhs) const {
}
const lldb_private::Declaration *SBDeclaration::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
lldb_private::Declaration &SBDeclaration::ref() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new lldb_private::Declaration());
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new lldb_private::Declaration());
+ return *m_opaque_up;
}
const lldb_private::Declaration &SBDeclaration::ref() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
bool SBDeclaration::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBDeclaration, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
- if (m_opaque_ap) {
+ if (m_opaque_up) {
char file_path[PATH_MAX * 2];
- m_opaque_ap->GetFile().GetPath(file_path, sizeof(file_path));
+ m_opaque_up->GetFile().GetPath(file_path, sizeof(file_path));
strm.Printf("%s:%u", file_path, GetLine());
if (GetColumn() > 0)
strm.Printf(":%u", GetColumn());
@@ -150,4 +174,34 @@ bool SBDeclaration::GetDescription(SBStream &description) {
return true;
}
-lldb_private::Declaration *SBDeclaration::get() { return m_opaque_ap.get(); }
+lldb_private::Declaration *SBDeclaration::get() { return m_opaque_up.get(); }
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBDeclaration>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBDeclaration, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBDeclaration, (const lldb::SBDeclaration &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBDeclaration &,
+ SBDeclaration, operator=,(const lldb::SBDeclaration &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBDeclaration, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBDeclaration, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBDeclaration, GetFileSpec,
+ ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBDeclaration, GetLine, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBDeclaration, GetColumn, ());
+ LLDB_REGISTER_METHOD(void, SBDeclaration, SetFileSpec, (lldb::SBFileSpec));
+ LLDB_REGISTER_METHOD(void, SBDeclaration, SetLine, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBDeclaration, SetColumn, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBDeclaration, operator==,(const lldb::SBDeclaration &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBDeclaration, operator!=,(const lldb::SBDeclaration &));
+ LLDB_REGISTER_METHOD(bool, SBDeclaration, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBError.cpp b/source/API/SBError.cpp
index 04433bb1aab01..7256e8e55de94 100644
--- a/source/API/SBError.cpp
+++ b/source/API/SBError.cpp
@@ -1,15 +1,15 @@
//===-- SBError.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBError.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Status.h"
#include <stdarg.h>
@@ -17,157 +17,196 @@
using namespace lldb;
using namespace lldb_private;
-SBError::SBError() : m_opaque_ap() {}
+SBError::SBError() : m_opaque_up() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBError); }
+
+SBError::SBError(const SBError &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBError, (const lldb::SBError &), rhs);
-SBError::SBError(const SBError &rhs) : m_opaque_ap() {
- if (rhs.IsValid())
- m_opaque_ap.reset(new Status(*rhs));
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBError::~SBError() {}
const SBError &SBError::operator=(const SBError &rhs) {
- if (rhs.IsValid()) {
- if (m_opaque_ap)
- *m_opaque_ap = *rhs;
- else
- m_opaque_ap.reset(new Status(*rhs));
- } else
- m_opaque_ap.reset();
+ LLDB_RECORD_METHOD(const lldb::SBError &,
+ SBError, operator=,(const lldb::SBError &), rhs);
- return *this;
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
const char *SBError::GetCString() const {
- if (m_opaque_ap)
- return m_opaque_ap->AsCString();
- return NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBError, GetCString);
+
+ if (m_opaque_up)
+ return m_opaque_up->AsCString();
+ return nullptr;
}
void SBError::Clear() {
- if (m_opaque_ap)
- m_opaque_ap->Clear();
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBError, Clear);
+
+ if (m_opaque_up)
+ m_opaque_up->Clear();
}
bool SBError::Fail() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Fail);
bool ret_value = false;
- if (m_opaque_ap)
- ret_value = m_opaque_ap->Fail();
+ if (m_opaque_up)
+ ret_value = m_opaque_up->Fail();
- if (log)
- log->Printf("SBError(%p)::Fail () => %i",
- static_cast<void *>(m_opaque_ap.get()), ret_value);
return ret_value;
}
bool SBError::Success() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- bool ret_value = true;
- if (m_opaque_ap)
- ret_value = m_opaque_ap->Success();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, Success);
- if (log)
- log->Printf("SBError(%p)::Success () => %i",
- static_cast<void *>(m_opaque_ap.get()), ret_value);
+ bool ret_value = true;
+ if (m_opaque_up)
+ ret_value = m_opaque_up->Success();
return ret_value;
}
uint32_t SBError::GetError() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBError, GetError);
+
uint32_t err = 0;
- if (m_opaque_ap)
- err = m_opaque_ap->GetError();
+ if (m_opaque_up)
+ err = m_opaque_up->GetError();
- if (log)
- log->Printf("SBError(%p)::GetError () => 0x%8.8x",
- static_cast<void *>(m_opaque_ap.get()), err);
return err;
}
ErrorType SBError::GetType() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- ErrorType err_type = eErrorTypeInvalid;
- if (m_opaque_ap)
- err_type = m_opaque_ap->GetType();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ErrorType, SBError, GetType);
- if (log)
- log->Printf("SBError(%p)::GetType () => %i",
- static_cast<void *>(m_opaque_ap.get()), err_type);
+ ErrorType err_type = eErrorTypeInvalid;
+ if (m_opaque_up)
+ err_type = m_opaque_up->GetType();
return err_type;
}
void SBError::SetError(uint32_t err, ErrorType type) {
+ LLDB_RECORD_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType), err,
+ type);
+
CreateIfNeeded();
- m_opaque_ap->SetError(err, type);
+ m_opaque_up->SetError(err, type);
}
void SBError::SetError(const Status &lldb_error) {
CreateIfNeeded();
- *m_opaque_ap = lldb_error;
+ *m_opaque_up = lldb_error;
}
void SBError::SetErrorToErrno() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToErrno);
+
CreateIfNeeded();
- m_opaque_ap->SetErrorToErrno();
+ m_opaque_up->SetErrorToErrno();
}
void SBError::SetErrorToGenericError() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
+
CreateIfNeeded();
- m_opaque_ap->SetErrorToErrno();
+ m_opaque_up->SetErrorToErrno();
}
void SBError::SetErrorString(const char *err_str) {
+ LLDB_RECORD_METHOD(void, SBError, SetErrorString, (const char *), err_str);
+
CreateIfNeeded();
- m_opaque_ap->SetErrorString(err_str);
+ m_opaque_up->SetErrorString(err_str);
}
int SBError::SetErrorStringWithFormat(const char *format, ...) {
CreateIfNeeded();
va_list args;
va_start(args, format);
- int num_chars = m_opaque_ap->SetErrorStringWithVarArg(format, args);
+ int num_chars = m_opaque_up->SetErrorStringWithVarArg(format, args);
va_end(args);
return num_chars;
}
-bool SBError::IsValid() const { return m_opaque_ap != NULL; }
+bool SBError::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, IsValid);
+ return this->operator bool();
+}
+SBError::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBError, operator bool);
+
+ return m_opaque_up != nullptr;
+}
void SBError::CreateIfNeeded() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new Status());
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new Status());
}
-lldb_private::Status *SBError::operator->() { return m_opaque_ap.get(); }
+lldb_private::Status *SBError::operator->() { return m_opaque_up.get(); }
-lldb_private::Status *SBError::get() { return m_opaque_ap.get(); }
+lldb_private::Status *SBError::get() { return m_opaque_up.get(); }
lldb_private::Status &SBError::ref() {
CreateIfNeeded();
- return *m_opaque_ap;
+ return *m_opaque_up;
}
const lldb_private::Status &SBError::operator*() const {
// Be sure to call "IsValid()" before calling this function or it will crash
- return *m_opaque_ap;
+ return *m_opaque_up;
}
bool SBError::GetDescription(SBStream &description) {
- if (m_opaque_ap) {
- if (m_opaque_ap->Success())
+ LLDB_RECORD_METHOD(bool, SBError, GetDescription, (lldb::SBStream &),
+ description);
+
+ if (m_opaque_up) {
+ if (m_opaque_up->Success())
description.Printf("success");
else {
const char *err_string = GetCString();
- description.Printf("error: %s", (err_string != NULL ? err_string : ""));
+ description.Printf("error: %s",
+ (err_string != nullptr ? err_string : ""));
}
} else
description.Printf("error: <NULL>");
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBError>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBError, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBError, (const lldb::SBError &));
+ LLDB_REGISTER_METHOD(const lldb::SBError &,
+ SBError, operator=,(const lldb::SBError &));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBError, GetCString, ());
+ LLDB_REGISTER_METHOD(void, SBError, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBError, Fail, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBError, Success, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBError, GetError, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::ErrorType, SBError, GetType, ());
+ LLDB_REGISTER_METHOD(void, SBError, SetError, (uint32_t, lldb::ErrorType));
+ LLDB_REGISTER_METHOD(void, SBError, SetErrorToErrno, ());
+ LLDB_REGISTER_METHOD(void, SBError, SetErrorToGenericError, ());
+ LLDB_REGISTER_METHOD(void, SBError, SetErrorString, (const char *));
+ LLDB_REGISTER_METHOD_CONST(bool, SBError, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBError, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBError, GetDescription, (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp
index 0556f50f65442..75ca2830df9fb 100644
--- a/source/API/SBEvent.cpp
+++ b/source/API/SBEvent.cpp
@@ -1,13 +1,13 @@
//===-- SBEvent.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBEvent.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBStream.h"
@@ -22,71 +22,83 @@
using namespace lldb;
using namespace lldb_private;
-SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(NULL) {}
+SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEvent);
+}
SBEvent::SBEvent(uint32_t event_type, const char *cstr, uint32_t cstr_len)
: m_event_sp(new Event(event_type, new EventDataBytes(cstr, cstr_len))),
- m_opaque_ptr(m_event_sp.get()) {}
+ m_opaque_ptr(m_event_sp.get()) {
+ LLDB_RECORD_CONSTRUCTOR(SBEvent, (uint32_t, const char *, uint32_t),
+ event_type, cstr, cstr_len);
+}
SBEvent::SBEvent(EventSP &event_sp)
- : m_event_sp(event_sp), m_opaque_ptr(event_sp.get()) {}
+ : m_event_sp(event_sp), m_opaque_ptr(event_sp.get()) {
+ LLDB_RECORD_CONSTRUCTOR(SBEvent, (lldb::EventSP &), event_sp);
+}
-SBEvent::SBEvent(Event *event_ptr) : m_event_sp(), m_opaque_ptr(event_ptr) {}
+SBEvent::SBEvent(Event *event_ptr) : m_event_sp(), m_opaque_ptr(event_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBEvent, (lldb_private::Event *), event_ptr);
+}
SBEvent::SBEvent(const SBEvent &rhs)
- : m_event_sp(rhs.m_event_sp), m_opaque_ptr(rhs.m_opaque_ptr) {}
+ : m_event_sp(rhs.m_event_sp), m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBEvent, (const lldb::SBEvent &), rhs);
+}
const SBEvent &SBEvent::operator=(const SBEvent &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBEvent &,
+ SBEvent, operator=,(const lldb::SBEvent &), rhs);
+
if (this != &rhs) {
m_event_sp = rhs.m_event_sp;
m_opaque_ptr = rhs.m_opaque_ptr;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBEvent::~SBEvent() {}
const char *SBEvent::GetDataFlavor() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBEvent, GetDataFlavor);
+
Event *lldb_event = get();
if (lldb_event) {
EventData *event_data = lldb_event->GetData();
if (event_data)
return lldb_event->GetData()->GetFlavor().AsCString();
}
- return NULL;
+ return nullptr;
}
uint32_t SBEvent::GetType() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBEvent, GetType);
+
const Event *lldb_event = get();
uint32_t event_type = 0;
if (lldb_event)
event_type = lldb_event->GetType();
- if (log) {
- StreamString sstr;
- if (lldb_event && lldb_event->GetBroadcaster() &&
- lldb_event->GetBroadcaster()->GetEventNames(sstr, event_type, true))
- log->Printf("SBEvent(%p)::GetType () => 0x%8.8x (%s)",
- static_cast<void *>(get()), event_type, sstr.GetData());
- else
- log->Printf("SBEvent(%p)::GetType () => 0x%8.8x",
- static_cast<void *>(get()), event_type);
- }
return event_type;
}
SBBroadcaster SBEvent::GetBroadcaster() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBEvent,
+ GetBroadcaster);
+
SBBroadcaster broadcaster;
const Event *lldb_event = get();
if (lldb_event)
broadcaster.reset(lldb_event->GetBroadcaster(), false);
- return broadcaster;
+ return LLDB_RECORD_RESULT(broadcaster);
}
const char *SBEvent::GetBroadcasterClass() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBEvent, GetBroadcasterClass);
+
const Event *lldb_event = get();
if (lldb_event)
return lldb_event->GetBroadcaster()->GetBroadcasterClass().AsCString();
@@ -95,28 +107,30 @@ const char *SBEvent::GetBroadcasterClass() const {
}
bool SBEvent::BroadcasterMatchesPtr(const SBBroadcaster *broadcaster) {
+ LLDB_RECORD_METHOD(bool, SBEvent, BroadcasterMatchesPtr,
+ (const lldb::SBBroadcaster *), broadcaster);
+
if (broadcaster)
return BroadcasterMatchesRef(*broadcaster);
return false;
}
bool SBEvent::BroadcasterMatchesRef(const SBBroadcaster &broadcaster) {
+ LLDB_RECORD_METHOD(bool, SBEvent, BroadcasterMatchesRef,
+ (const lldb::SBBroadcaster &), broadcaster);
Event *lldb_event = get();
bool success = false;
if (lldb_event)
success = lldb_event->BroadcasterIs(broadcaster.get());
- // For logging, this gets a little chatty so only enable this when verbose
- // logging is on
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- LLDB_LOGV(log, "({0}) (SBBroadcaster({1}): {2}) => {3}", get(),
- broadcaster.get(), broadcaster.GetName(), success);
return success;
}
void SBEvent::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBEvent, Clear);
+
Event *lldb_event = get();
if (lldb_event)
lldb_event->Clear();
@@ -146,25 +160,29 @@ void SBEvent::reset(Event *event_ptr) {
}
bool SBEvent::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, IsValid);
+ return this->operator bool();
+}
+SBEvent::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBEvent, operator bool);
+
// Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get() accessor.
// See comments in SBEvent::get()....
- return SBEvent::get() != NULL;
+ return SBEvent::get() != nullptr;
}
const char *SBEvent::GetCStringFromEvent(const SBEvent &event) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBEvent(%p)::GetCStringFromEvent () => \"%s\"",
- static_cast<void *>(event.get()),
- reinterpret_cast<const char *>(
- EventDataBytes::GetBytesFromEvent(event.get())));
+ LLDB_RECORD_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent,
+ (const lldb::SBEvent &), event);
return reinterpret_cast<const char *>(
EventDataBytes::GetBytesFromEvent(event.get()));
}
bool SBEvent::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
if (get()) {
@@ -176,6 +194,9 @@ bool SBEvent::GetDescription(SBStream &description) {
}
bool SBEvent::GetDescription(SBStream &description) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBEvent, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
if (get()) {
@@ -185,3 +206,37 @@ bool SBEvent::GetDescription(SBStream &description) const {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBEvent>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBEvent, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBEvent, (uint32_t, const char *, uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBEvent, (lldb::EventSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBEvent, (lldb_private::Event *));
+ LLDB_REGISTER_CONSTRUCTOR(SBEvent, (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(const lldb::SBEvent &,
+ SBEvent, operator=,(const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(const char *, SBEvent, GetDataFlavor, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBEvent, GetType, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBEvent, GetBroadcaster,
+ ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBEvent, GetBroadcasterClass, ());
+ LLDB_REGISTER_METHOD(bool, SBEvent, BroadcasterMatchesPtr,
+ (const lldb::SBBroadcaster *));
+ LLDB_REGISTER_METHOD(bool, SBEvent, BroadcasterMatchesRef,
+ (const lldb::SBBroadcaster &));
+ LLDB_REGISTER_METHOD(void, SBEvent, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBEvent, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBEvent, operator bool, ());
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBEvent, GetCStringFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(bool, SBEvent, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBEvent, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBExecutionContext.cpp b/source/API/SBExecutionContext.cpp
index 74a543c77d2d3..1224c2abe989b 100644
--- a/source/API/SBExecutionContext.cpp
+++ b/source/API/SBExecutionContext.cpp
@@ -1,14 +1,14 @@
//===-- SBExecutionContext.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBExecutionContext.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBFrame.h"
#include "lldb/API/SBProcess.h"
@@ -20,32 +20,49 @@
using namespace lldb;
using namespace lldb_private;
-SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() {}
+SBExecutionContext::SBExecutionContext() : m_exe_ctx_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExecutionContext);
+}
SBExecutionContext::SBExecutionContext(const lldb::SBExecutionContext &rhs)
- : m_exe_ctx_sp(rhs.m_exe_ctx_sp) {}
+ : m_exe_ctx_sp(rhs.m_exe_ctx_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBExecutionContext,
+ (const lldb::SBExecutionContext &), rhs);
+}
SBExecutionContext::SBExecutionContext(
lldb::ExecutionContextRefSP exe_ctx_ref_sp)
- : m_exe_ctx_sp(exe_ctx_ref_sp) {}
+ : m_exe_ctx_sp(exe_ctx_ref_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (lldb::ExecutionContextRefSP),
+ exe_ctx_ref_sp);
+}
SBExecutionContext::SBExecutionContext(const lldb::SBTarget &target)
: m_exe_ctx_sp(new ExecutionContextRef()) {
+ LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBTarget &), target);
+
m_exe_ctx_sp->SetTargetSP(target.GetSP());
}
SBExecutionContext::SBExecutionContext(const lldb::SBProcess &process)
: m_exe_ctx_sp(new ExecutionContextRef()) {
+ LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBProcess &),
+ process);
+
m_exe_ctx_sp->SetProcessSP(process.GetSP());
}
SBExecutionContext::SBExecutionContext(lldb::SBThread thread)
: m_exe_ctx_sp(new ExecutionContextRef()) {
+ LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (lldb::SBThread), thread);
+
m_exe_ctx_sp->SetThreadPtr(thread.get());
}
SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame)
: m_exe_ctx_sp(new ExecutionContextRef()) {
+ LLDB_RECORD_CONSTRUCTOR(SBExecutionContext, (const lldb::SBFrame &), frame);
+
m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP());
}
@@ -53,8 +70,12 @@ SBExecutionContext::~SBExecutionContext() {}
const SBExecutionContext &SBExecutionContext::
operator=(const lldb::SBExecutionContext &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBExecutionContext &,
+ SBExecutionContext, operator=,(const lldb::SBExecutionContext &), rhs);
+
m_exe_ctx_sp = rhs.m_exe_ctx_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
ExecutionContextRef *SBExecutionContext::get() const {
@@ -62,41 +83,81 @@ ExecutionContextRef *SBExecutionContext::get() const {
}
SBTarget SBExecutionContext::GetTarget() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBExecutionContext,
+ GetTarget);
+
SBTarget sb_target;
if (m_exe_ctx_sp) {
TargetSP target_sp(m_exe_ctx_sp->GetTargetSP());
if (target_sp)
sb_target.SetSP(target_sp);
}
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
SBProcess SBExecutionContext::GetProcess() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBProcess, SBExecutionContext,
+ GetProcess);
+
SBProcess sb_process;
if (m_exe_ctx_sp) {
ProcessSP process_sp(m_exe_ctx_sp->GetProcessSP());
if (process_sp)
sb_process.SetSP(process_sp);
}
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
SBThread SBExecutionContext::GetThread() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBExecutionContext,
+ GetThread);
+
SBThread sb_thread;
if (m_exe_ctx_sp) {
ThreadSP thread_sp(m_exe_ctx_sp->GetThreadSP());
if (thread_sp)
sb_thread.SetThread(thread_sp);
}
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
SBFrame SBExecutionContext::GetFrame() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFrame, SBExecutionContext, GetFrame);
+
SBFrame sb_frame;
if (m_exe_ctx_sp) {
StackFrameSP frame_sp(m_exe_ctx_sp->GetFrameSP());
if (frame_sp)
sb_frame.SetFrameSP(frame_sp);
}
- return sb_frame;
+ return LLDB_RECORD_RESULT(sb_frame);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBExecutionContext>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext,
+ (const lldb::SBExecutionContext &));
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext,
+ (lldb::ExecutionContextRefSP));
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBTarget &));
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBProcess &));
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (lldb::SBThread));
+ LLDB_REGISTER_CONSTRUCTOR(SBExecutionContext, (const lldb::SBFrame &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBExecutionContext &,
+ SBExecutionContext, operator=,(const lldb::SBExecutionContext &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBExecutionContext, GetTarget,
+ ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBProcess, SBExecutionContext, GetProcess,
+ ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBExecutionContext, GetThread,
+ ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFrame, SBExecutionContext, GetFrame, ());
+}
+
+}
}
diff --git a/source/API/SBExpressionOptions.cpp b/source/API/SBExpressionOptions.cpp
index 76cec876a2161..8c34194abf1e2 100644
--- a/source/API/SBExpressionOptions.cpp
+++ b/source/API/SBExpressionOptions.cpp
@@ -1,177 +1,336 @@
//===-- SBExpressionOptions.cpp ---------------------------------------------*-
//C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBExpressionOptions.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
-
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
SBExpressionOptions::SBExpressionOptions()
- : m_opaque_ap(new EvaluateExpressionOptions()) {}
+ : m_opaque_up(new EvaluateExpressionOptions()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBExpressionOptions);
+}
-SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) {
- m_opaque_ap.reset(new EvaluateExpressionOptions());
- *(m_opaque_ap.get()) = rhs.ref();
+SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs)
+ : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBExpressionOptions,
+ (const lldb::SBExpressionOptions &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
const SBExpressionOptions &SBExpressionOptions::
operator=(const SBExpressionOptions &rhs) {
- if (this != &rhs) {
- this->ref() = rhs.ref();
- }
- return *this;
+ LLDB_RECORD_METHOD(
+ const lldb::SBExpressionOptions &,
+ SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &), rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
SBExpressionOptions::~SBExpressionOptions() {}
bool SBExpressionOptions::GetCoerceResultToId() const {
- return m_opaque_ap->DoesCoerceToId();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
+ GetCoerceResultToId);
+
+ return m_opaque_up->DoesCoerceToId();
}
void SBExpressionOptions::SetCoerceResultToId(bool coerce) {
- m_opaque_ap->SetCoerceToId(coerce);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetCoerceResultToId, (bool),
+ coerce);
+
+ m_opaque_up->SetCoerceToId(coerce);
}
bool SBExpressionOptions::GetUnwindOnError() const {
- return m_opaque_ap->DoesUnwindOnError();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetUnwindOnError);
+
+ return m_opaque_up->DoesUnwindOnError();
}
void SBExpressionOptions::SetUnwindOnError(bool unwind) {
- m_opaque_ap->SetUnwindOnError(unwind);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool),
+ unwind);
+
+ m_opaque_up->SetUnwindOnError(unwind);
}
bool SBExpressionOptions::GetIgnoreBreakpoints() const {
- return m_opaque_ap->DoesIgnoreBreakpoints();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
+ GetIgnoreBreakpoints);
+
+ return m_opaque_up->DoesIgnoreBreakpoints();
}
void SBExpressionOptions::SetIgnoreBreakpoints(bool ignore) {
- m_opaque_ap->SetIgnoreBreakpoints(ignore);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints, (bool),
+ ignore);
+
+ m_opaque_up->SetIgnoreBreakpoints(ignore);
}
lldb::DynamicValueType SBExpressionOptions::GetFetchDynamicValue() const {
- return m_opaque_ap->GetUseDynamic();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBExpressionOptions,
+ GetFetchDynamicValue);
+
+ return m_opaque_up->GetUseDynamic();
}
void SBExpressionOptions::SetFetchDynamicValue(lldb::DynamicValueType dynamic) {
- m_opaque_ap->SetUseDynamic(dynamic);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
+ (lldb::DynamicValueType), dynamic);
+
+ m_opaque_up->SetUseDynamic(dynamic);
}
uint32_t SBExpressionOptions::GetTimeoutInMicroSeconds() const {
- return m_opaque_ap->GetTimeout() ? m_opaque_ap->GetTimeout()->count() : 0;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
+ GetTimeoutInMicroSeconds);
+
+ return m_opaque_up->GetTimeout() ? m_opaque_up->GetTimeout()->count() : 0;
}
void SBExpressionOptions::SetTimeoutInMicroSeconds(uint32_t timeout) {
- m_opaque_ap->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
+ (uint32_t), timeout);
+
+ m_opaque_up->SetTimeout(timeout == 0 ? Timeout<std::micro>(llvm::None)
: std::chrono::microseconds(timeout));
}
uint32_t SBExpressionOptions::GetOneThreadTimeoutInMicroSeconds() const {
- return m_opaque_ap->GetOneThreadTimeout() ? m_opaque_ap->GetOneThreadTimeout()->count() : 0;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBExpressionOptions,
+ GetOneThreadTimeoutInMicroSeconds);
+
+ return m_opaque_up->GetOneThreadTimeout()
+ ? m_opaque_up->GetOneThreadTimeout()->count()
+ : 0;
}
void SBExpressionOptions::SetOneThreadTimeoutInMicroSeconds(uint32_t timeout) {
- m_opaque_ap->SetOneThreadTimeout(timeout == 0
+ LLDB_RECORD_METHOD(void, SBExpressionOptions,
+ SetOneThreadTimeoutInMicroSeconds, (uint32_t), timeout);
+
+ m_opaque_up->SetOneThreadTimeout(timeout == 0
? Timeout<std::micro>(llvm::None)
: std::chrono::microseconds(timeout));
}
bool SBExpressionOptions::GetTryAllThreads() const {
- return m_opaque_ap->GetTryAllThreads();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetTryAllThreads);
+
+ return m_opaque_up->GetTryAllThreads();
}
void SBExpressionOptions::SetTryAllThreads(bool run_others) {
- m_opaque_ap->SetTryAllThreads(run_others);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool),
+ run_others);
+
+ m_opaque_up->SetTryAllThreads(run_others);
}
bool SBExpressionOptions::GetStopOthers() const {
- return m_opaque_ap->GetStopOthers();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, GetStopOthers);
+
+ return m_opaque_up->GetStopOthers();
}
void SBExpressionOptions::SetStopOthers(bool run_others) {
- m_opaque_ap->SetStopOthers(run_others);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetStopOthers, (bool),
+ run_others);
+
+ m_opaque_up->SetStopOthers(run_others);
}
bool SBExpressionOptions::GetTrapExceptions() const {
- return m_opaque_ap->GetTrapExceptions();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions,
+ GetTrapExceptions);
+
+ return m_opaque_up->GetTrapExceptions();
}
void SBExpressionOptions::SetTrapExceptions(bool trap_exceptions) {
- m_opaque_ap->SetTrapExceptions(trap_exceptions);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool),
+ trap_exceptions);
+
+ m_opaque_up->SetTrapExceptions(trap_exceptions);
}
void SBExpressionOptions::SetLanguage(lldb::LanguageType language) {
- m_opaque_ap->SetLanguage(language);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetLanguage,
+ (lldb::LanguageType), language);
+
+ m_opaque_up->SetLanguage(language);
}
void SBExpressionOptions::SetCancelCallback(
lldb::ExpressionCancelCallback callback, void *baton) {
- m_opaque_ap->SetCancelCallback(callback, baton);
+ LLDB_RECORD_DUMMY(void, SBExpressionOptions, SetCancelCallback,
+ (lldb::ExpressionCancelCallback, void *), callback, baton);
+
+ m_opaque_up->SetCancelCallback(callback, baton);
}
bool SBExpressionOptions::GetGenerateDebugInfo() {
- return m_opaque_ap->GetGenerateDebugInfo();
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetGenerateDebugInfo);
+
+ return m_opaque_up->GetGenerateDebugInfo();
}
void SBExpressionOptions::SetGenerateDebugInfo(bool b) {
- return m_opaque_ap->SetGenerateDebugInfo(b);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo, (bool),
+ b);
+
+ return m_opaque_up->SetGenerateDebugInfo(b);
}
bool SBExpressionOptions::GetSuppressPersistentResult() {
- return m_opaque_ap->GetResultIsInternal();
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions,
+ GetSuppressPersistentResult);
+
+ return m_opaque_up->GetResultIsInternal();
}
void SBExpressionOptions::SetSuppressPersistentResult(bool b) {
- return m_opaque_ap->SetResultIsInternal(b);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
+ (bool), b);
+
+ return m_opaque_up->SetResultIsInternal(b);
}
const char *SBExpressionOptions::GetPrefix() const {
- return m_opaque_ap->GetPrefix();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBExpressionOptions,
+ GetPrefix);
+
+ return m_opaque_up->GetPrefix();
}
void SBExpressionOptions::SetPrefix(const char *prefix) {
- return m_opaque_ap->SetPrefix(prefix);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetPrefix, (const char *),
+ prefix);
+
+ return m_opaque_up->SetPrefix(prefix);
}
bool SBExpressionOptions::GetAutoApplyFixIts() {
- return m_opaque_ap->GetAutoApplyFixIts();
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAutoApplyFixIts);
+
+ return m_opaque_up->GetAutoApplyFixIts();
}
void SBExpressionOptions::SetAutoApplyFixIts(bool b) {
- return m_opaque_ap->SetAutoApplyFixIts(b);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool), b);
+
+ return m_opaque_up->SetAutoApplyFixIts(b);
}
bool SBExpressionOptions::GetTopLevel() {
- return m_opaque_ap->GetExecutionPolicy() == eExecutionPolicyTopLevel;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel);
+
+ return m_opaque_up->GetExecutionPolicy() == eExecutionPolicyTopLevel;
}
void SBExpressionOptions::SetTopLevel(bool b) {
- m_opaque_ap->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
- : m_opaque_ap->default_execution_policy);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetTopLevel, (bool), b);
+
+ m_opaque_up->SetExecutionPolicy(b ? eExecutionPolicyTopLevel
+ : m_opaque_up->default_execution_policy);
}
bool SBExpressionOptions::GetAllowJIT() {
- return m_opaque_ap->GetExecutionPolicy() != eExecutionPolicyNever;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetAllowJIT);
+
+ return m_opaque_up->GetExecutionPolicy() != eExecutionPolicyNever;
}
void SBExpressionOptions::SetAllowJIT(bool allow) {
- m_opaque_ap->SetExecutionPolicy(allow ? m_opaque_ap->default_execution_policy
- : eExecutionPolicyNever);
+ LLDB_RECORD_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool), allow);
+
+ m_opaque_up->SetExecutionPolicy(allow ? m_opaque_up->default_execution_policy
+ : eExecutionPolicyNever);
}
EvaluateExpressionOptions *SBExpressionOptions::get() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
EvaluateExpressionOptions &SBExpressionOptions::ref() const {
- return *(m_opaque_ap.get());
+ return *(m_opaque_up.get());
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBExpressionOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBExpressionOptions,
+ (const lldb::SBExpressionOptions &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBExpressionOptions &,
+ SBExpressionOptions, operator=,(const lldb::SBExpressionOptions &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetCoerceResultToId,
+ ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetCoerceResultToId,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetUnwindOnError, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetUnwindOnError, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetIgnoreBreakpoints,
+ ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetIgnoreBreakpoints,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBExpressionOptions,
+ GetFetchDynamicValue, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetFetchDynamicValue,
+ (lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions,
+ GetTimeoutInMicroSeconds, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTimeoutInMicroSeconds,
+ (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBExpressionOptions,
+ GetOneThreadTimeoutInMicroSeconds, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions,
+ SetOneThreadTimeoutInMicroSeconds, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTryAllThreads, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTryAllThreads, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetStopOthers, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetStopOthers, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBExpressionOptions, GetTrapExceptions,
+ ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTrapExceptions, (bool));
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetLanguage,
+ (lldb::LanguageType));
+ LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetGenerateDebugInfo, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetGenerateDebugInfo,
+ (bool));
+ LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetSuppressPersistentResult,
+ ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetSuppressPersistentResult,
+ (bool));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBExpressionOptions, GetPrefix,
+ ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetPrefix, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAutoApplyFixIts, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAutoApplyFixIts, (bool));
+ LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetTopLevel, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool));
+ LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ());
+ LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool));
+}
+
+}
}
diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp
index f136409d0b68e..2f910b9ba294e 100644
--- a/source/API/SBFileSpec.cpp
+++ b/source/API/SBFileSpec.cpp
@@ -1,76 +1,109 @@
//===-- SBFileSpec.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <inttypes.h>
-#include <limits.h>
-
#include "lldb/API/SBFileSpec.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/SmallString.h"
+#include <inttypes.h>
+#include <limits.h>
+
using namespace lldb;
using namespace lldb_private;
-SBFileSpec::SBFileSpec() : m_opaque_ap(new lldb_private::FileSpec()) {}
+SBFileSpec::SBFileSpec() : m_opaque_up(new lldb_private::FileSpec()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpec);
+}
-SBFileSpec::SBFileSpec(const SBFileSpec &rhs)
- : m_opaque_ap(new lldb_private::FileSpec(*rhs.m_opaque_ap)) {}
+SBFileSpec::SBFileSpec(const SBFileSpec &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
+}
SBFileSpec::SBFileSpec(const lldb_private::FileSpec &fspec)
- : m_opaque_ap(new lldb_private::FileSpec(fspec)) {}
+ : m_opaque_up(new lldb_private::FileSpec(fspec)) {}
// Deprecated!!!
-SBFileSpec::SBFileSpec(const char *path) : m_opaque_ap(new FileSpec(path)) {
- FileSystem::Instance().Resolve(*m_opaque_ap);
+SBFileSpec::SBFileSpec(const char *path) : m_opaque_up(new FileSpec(path)) {
+ LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *), path);
+
+ FileSystem::Instance().Resolve(*m_opaque_up);
}
SBFileSpec::SBFileSpec(const char *path, bool resolve)
- : m_opaque_ap(new FileSpec(path)) {
+ : m_opaque_up(new FileSpec(path)) {
+ LLDB_RECORD_CONSTRUCTOR(SBFileSpec, (const char *, bool), path, resolve);
+
if (resolve)
- FileSystem::Instance().Resolve(*m_opaque_ap);
+ FileSystem::Instance().Resolve(*m_opaque_up);
}
SBFileSpec::~SBFileSpec() {}
const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBFileSpec &,
+ SBFileSpec, operator=,(const lldb::SBFileSpec &), rhs);
+
if (this != &rhs)
- *m_opaque_ap = *rhs.m_opaque_ap;
- return *this;
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
-bool SBFileSpec::IsValid() const { return m_opaque_ap->operator bool(); }
+bool SBFileSpec::operator==(const SBFileSpec &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, operator==,(const SBFileSpec &rhs),
+ rhs);
-bool SBFileSpec::Exists() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ return ref() == rhs.ref();
+}
- bool result = FileSystem::Instance().Exists(*m_opaque_ap);
+bool SBFileSpec::operator!=(const SBFileSpec &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, operator!=,(const SBFileSpec &rhs),
+ rhs);
- if (log)
- log->Printf("SBFileSpec(%p)::Exists () => %s",
- static_cast<void *>(m_opaque_ap.get()),
- (result ? "true" : "false"));
+ return !(*this == rhs);
+}
- return result;
+bool SBFileSpec::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, IsValid);
+ return this->operator bool();
+}
+SBFileSpec::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, operator bool);
+
+ return m_opaque_up->operator bool();
+}
+
+bool SBFileSpec::Exists() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFileSpec, Exists);
+
+ return FileSystem::Instance().Exists(*m_opaque_up);
}
bool SBFileSpec::ResolveExecutableLocation() {
- return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_ap);
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBFileSpec, ResolveExecutableLocation);
+
+ return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_up);
}
int SBFileSpec::ResolvePath(const char *src_path, char *dst_path,
size_t dst_len) {
+ LLDB_RECORD_STATIC_METHOD(int, SBFileSpec, ResolvePath,
+ (const char *, char *, size_t), src_path, dst_path,
+ dst_len);
+
llvm::SmallString<64> result(src_path);
FileSystem::Instance().Resolve(result);
::snprintf(dst_path, dst_len, "%s", result.c_str());
@@ -78,61 +111,42 @@ int SBFileSpec::ResolvePath(const char *src_path, char *dst_path,
}
const char *SBFileSpec::GetFilename() const {
- const char *s = m_opaque_ap->GetFilename().AsCString();
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (s)
- log->Printf("SBFileSpec(%p)::GetFilename () => \"%s\"",
- static_cast<void *>(m_opaque_ap.get()), s);
- else
- log->Printf("SBFileSpec(%p)::GetFilename () => NULL",
- static_cast<void *>(m_opaque_ap.get()));
- }
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetFilename);
- return s;
+ return m_opaque_up->GetFilename().AsCString();
}
const char *SBFileSpec::GetDirectory() const {
- FileSpec directory{*m_opaque_ap};
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFileSpec, GetDirectory);
+
+ FileSpec directory{*m_opaque_up};
directory.GetFilename().Clear();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (directory)
- log->Printf("SBFileSpec(%p)::GetDirectory () => \"%s\"",
- static_cast<void *>(m_opaque_ap.get()),
- directory.GetCString());
- else
- log->Printf("SBFileSpec(%p)::GetDirectory () => NULL",
- static_cast<void *>(m_opaque_ap.get()));
- }
return directory.GetCString();
}
void SBFileSpec::SetFilename(const char *filename) {
+ LLDB_RECORD_METHOD(void, SBFileSpec, SetFilename, (const char *), filename);
+
if (filename && filename[0])
- m_opaque_ap->GetFilename().SetCString(filename);
+ m_opaque_up->GetFilename().SetCString(filename);
else
- m_opaque_ap->GetFilename().Clear();
+ m_opaque_up->GetFilename().Clear();
}
void SBFileSpec::SetDirectory(const char *directory) {
+ LLDB_RECORD_METHOD(void, SBFileSpec, SetDirectory, (const char *), directory);
+
if (directory && directory[0])
- m_opaque_ap->GetDirectory().SetCString(directory);
+ m_opaque_up->GetDirectory().SetCString(directory);
else
- m_opaque_ap->GetDirectory().Clear();
+ m_opaque_up->GetDirectory().Clear();
}
uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- uint32_t result = m_opaque_ap->GetPath(dst_path, dst_len);
+ LLDB_RECORD_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t),
+ dst_path, dst_len);
- if (log)
- log->Printf("SBFileSpec(%p)::GetPath (dst_path=\"%.*s\", dst_len=%" PRIu64
- ") => %u",
- static_cast<void *>(m_opaque_ap.get()), result, dst_path,
- static_cast<uint64_t>(dst_len), result);
+ uint32_t result = m_opaque_up->GetPath(dst_path, dst_len);
if (result == 0 && dst_path && dst_len > 0)
*dst_path = '\0';
@@ -140,31 +154,70 @@ uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const {
}
const lldb_private::FileSpec *SBFileSpec::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::FileSpec *SBFileSpec::get() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::FileSpec &SBFileSpec::operator*() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
-const lldb_private::FileSpec &SBFileSpec::ref() const { return *m_opaque_ap; }
+const lldb_private::FileSpec &SBFileSpec::ref() const { return *m_opaque_up; }
void SBFileSpec::SetFileSpec(const lldb_private::FileSpec &fs) {
- *m_opaque_ap = fs;
+ *m_opaque_up = fs;
}
bool SBFileSpec::GetDescription(SBStream &description) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFileSpec, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
char path[PATH_MAX];
- if (m_opaque_ap->GetPath(path, sizeof(path)))
+ if (m_opaque_up->GetPath(path, sizeof(path)))
strm.PutCString(path);
return true;
}
void SBFileSpec::AppendPathComponent(const char *fn) {
- m_opaque_ap->AppendPathComponent(fn);
+ LLDB_RECORD_METHOD(void, SBFileSpec, AppendPathComponent, (const char *), fn);
+
+ m_opaque_up->AppendPathComponent(fn);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBFileSpec>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const lldb::SBFileSpec &));
+ LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBFileSpec, (const char *, bool));
+ LLDB_REGISTER_METHOD(const lldb::SBFileSpec &,
+ SBFileSpec, operator=,(const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBFileSpec, operator==,(const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBFileSpec, operator!=,(const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, Exists, ());
+ LLDB_REGISTER_METHOD(bool, SBFileSpec, ResolveExecutableLocation, ());
+ LLDB_REGISTER_STATIC_METHOD(int, SBFileSpec, ResolvePath,
+ (const char *, char *, size_t));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetFilename, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetDirectory, ());
+ LLDB_REGISTER_METHOD(void, SBFileSpec, SetFilename, (const char *));
+ LLDB_REGISTER_METHOD(void, SBFileSpec, SetDirectory, (const char *));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t));
+ LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(void, SBFileSpec, AppendPathComponent, (const char *));
+}
+
+}
}
diff --git a/source/API/SBFileSpecList.cpp b/source/API/SBFileSpecList.cpp
index 439859c3fd856..3143964b38cbe 100644
--- a/source/API/SBFileSpecList.cpp
+++ b/source/API/SBFileSpecList.cpp
@@ -1,99 +1,121 @@
//===-- SBFileSpecList.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <limits.h>
-
-#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBFileSpecList.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
+#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/FileSpecList.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
+#include <limits.h>
+
using namespace lldb;
using namespace lldb_private;
-SBFileSpecList::SBFileSpecList() : m_opaque_ap(new FileSpecList()) {}
+SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFileSpecList);
+}
-SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_ap() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &), rhs);
- if (rhs.m_opaque_ap)
- m_opaque_ap.reset(new FileSpecList(*(rhs.get())));
- if (log) {
- log->Printf("SBFileSpecList::SBFileSpecList (const SBFileSpecList "
- "rhs.ap=%p) => SBFileSpecList(%p)",
- static_cast<void *>(rhs.m_opaque_ap.get()),
- static_cast<void *>(m_opaque_ap.get()));
- }
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBFileSpecList::~SBFileSpecList() {}
const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {
- if (this != &rhs) {
- m_opaque_ap.reset(new lldb_private::FileSpecList(*(rhs.get())));
- }
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBFileSpecList &,
+ SBFileSpecList, operator=,(const lldb::SBFileSpecList &),
+ rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
-uint32_t SBFileSpecList::GetSize() const { return m_opaque_ap->GetSize(); }
+uint32_t SBFileSpecList::GetSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFileSpecList, GetSize);
+
+ return m_opaque_up->GetSize();
+}
void SBFileSpecList::Append(const SBFileSpec &sb_file) {
- m_opaque_ap->Append(sb_file.ref());
+ LLDB_RECORD_METHOD(void, SBFileSpecList, Append, (const lldb::SBFileSpec &),
+ sb_file);
+
+ m_opaque_up->Append(sb_file.ref());
}
bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) {
- return m_opaque_ap->AppendIfUnique(sb_file.ref());
+ LLDB_RECORD_METHOD(bool, SBFileSpecList, AppendIfUnique,
+ (const lldb::SBFileSpec &), sb_file);
+
+ return m_opaque_up->AppendIfUnique(sb_file.ref());
}
-void SBFileSpecList::Clear() { m_opaque_ap->Clear(); }
+void SBFileSpecList::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBFileSpecList, Clear);
+
+ m_opaque_up->Clear();
+}
uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file,
bool full) {
- return m_opaque_ap->FindFileIndex(idx, sb_file.ref(), full);
+ LLDB_RECORD_METHOD(uint32_t, SBFileSpecList, FindFileIndex,
+ (uint32_t, const lldb::SBFileSpec &, bool), idx, sb_file,
+ full);
+
+ return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);
}
const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const {
+ LLDB_RECORD_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList,
+ GetFileSpecAtIndex, (uint32_t), idx);
+
SBFileSpec new_spec;
- new_spec.SetFileSpec(m_opaque_ap->GetFileSpecAtIndex(idx));
- return new_spec;
+ new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));
+ return LLDB_RECORD_RESULT(new_spec);
}
const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::FileSpecList *SBFileSpecList::get() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::FileSpecList &SBFileSpecList::operator*() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
const lldb_private::FileSpecList &SBFileSpecList::ref() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
bool SBFileSpecList::GetDescription(SBStream &description) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFileSpecList, GetDescription,
+ (lldb::SBStream &), description);
+
Stream &strm = description.ref();
- if (m_opaque_ap) {
- uint32_t num_files = m_opaque_ap->GetSize();
+ if (m_opaque_up) {
+ uint32_t num_files = m_opaque_up->GetSize();
strm.Printf("%d files: ", num_files);
for (uint32_t i = 0; i < num_files; i++) {
char path[PATH_MAX];
- if (m_opaque_ap->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
+ if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
strm.Printf("\n %s", path);
}
} else
@@ -101,3 +123,30 @@ bool SBFileSpecList::GetDescription(SBStream &description) const {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBFileSpecList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBFileSpecList, (const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBFileSpecList &,
+ SBFileSpecList, operator=,(const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpecList, GetSize, ());
+ LLDB_REGISTER_METHOD(void, SBFileSpecList, Append,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(bool, SBFileSpecList, AppendIfUnique,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(void, SBFileSpecList, Clear, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBFileSpecList, FindFileIndex,
+ (uint32_t, const lldb::SBFileSpec &, bool));
+ LLDB_REGISTER_METHOD_CONST(const lldb::SBFileSpec, SBFileSpecList,
+ GetFileSpecAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(bool, SBFileSpecList, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 44dcfd806be59..9268f0f9bdbf9 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -1,9 +1,8 @@
//===-- SBFrame.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,11 +14,13 @@
#include "lldb/lldb-types.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/Core/Address.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectRegister.h"
#include "lldb/Core/ValueObjectVariable.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/Host.h"
#include "lldb/Symbol/Block.h"
@@ -37,7 +38,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "lldb/API/SBAddress.h"
@@ -54,30 +54,31 @@
using namespace lldb;
using namespace lldb_private;
-SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {}
+SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFrame);
+}
SBFrame::SBFrame(const StackFrameSP &lldb_object_sp)
: m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log) {
- SBStream sstr;
- GetDescription(sstr);
- log->Printf("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
- static_cast<void *>(lldb_object_sp.get()),
- static_cast<void *>(lldb_object_sp.get()), sstr.GetData());
- }
+ LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &),
+ lldb_object_sp);
}
-SBFrame::SBFrame(const SBFrame &rhs)
- : m_opaque_sp(new ExecutionContextRef(*rhs.m_opaque_sp)) {}
+SBFrame::SBFrame(const SBFrame &rhs) : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::SBFrame &), rhs);
+
+ m_opaque_sp = clone(rhs.m_opaque_sp);
+}
SBFrame::~SBFrame() = default;
const SBFrame &SBFrame::operator=(const SBFrame &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBFrame &,
+ SBFrame, operator=,(const lldb::SBFrame &), rhs);
+
if (this != &rhs)
- *m_opaque_sp = *rhs.m_opaque_sp;
- return *this;
+ m_opaque_sp = clone(rhs.m_opaque_sp);
+ return LLDB_RECORD_RESULT(*this);
}
StackFrameSP SBFrame::GetFrameSP() const {
@@ -89,6 +90,12 @@ void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) {
}
bool SBFrame::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsValid);
+ return this->operator bool();
+}
+SBFrame::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, operator bool);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -105,7 +112,9 @@ bool SBFrame::IsValid() const {
}
SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(lldb::SBSymbolContext, SBFrame, GetSymbolContext,
+ (uint32_t), resolve_scope);
+
SBSymbolContext sb_sym_ctx;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -117,31 +126,17 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
+ if (frame)
sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(scope));
- } else {
- if (log)
- log->Printf("SBFrame::GetVariables () => error: could not "
- "reconstruct frame object for this SBFrame.");
- }
- } else {
- if (log)
- log->Printf(
- "SBFrame::GetSymbolContext () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => "
- "SBSymbolContext(%p)",
- static_cast<void *>(frame), resolve_scope,
- static_cast<void *>(sb_sym_ctx.get()));
-
- return sb_sym_ctx;
+ return LLDB_RECORD_RESULT(sb_sym_ctx);
}
SBModule SBFrame::GetModule() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBModule, SBFrame, GetModule);
+
SBModule sb_module;
ModuleSP module_sp;
std::unique_lock<std::recursive_mutex> lock;
@@ -157,27 +152,17 @@ SBModule SBFrame::GetModule() const {
if (frame) {
module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp;
sb_module.SetSP(module_sp);
- } else {
- if (log)
- log->Printf("SBFrame::GetModule () => error: could not reconstruct "
- "frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetModule () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetModule () => SBModule(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(module_sp.get()));
-
- return sb_module;
+ return LLDB_RECORD_RESULT(sb_module);
}
SBCompileUnit SBFrame::GetCompileUnit() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBCompileUnit, SBFrame,
+ GetCompileUnit);
+
SBCompileUnit sb_comp_unit;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -192,26 +177,16 @@ SBCompileUnit SBFrame::GetCompileUnit() const {
if (frame) {
sb_comp_unit.reset(
frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
- } else {
- if (log)
- log->Printf("SBFrame::GetCompileUnit () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetCompileUnit () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(sb_comp_unit.get()));
- return sb_comp_unit;
+ return LLDB_RECORD_RESULT(sb_comp_unit);
}
SBFunction SBFrame::GetFunction() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFunction, SBFrame, GetFunction);
+
SBFunction sb_function;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -226,26 +201,16 @@ SBFunction SBFrame::GetFunction() const {
if (frame) {
sb_function.reset(
frame->GetSymbolContext(eSymbolContextFunction).function);
- } else {
- if (log)
- log->Printf("SBFrame::GetFunction () => error: could not reconstruct "
- "frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetFunction () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetFunction () => SBFunction(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(sb_function.get()));
- return sb_function;
+ return LLDB_RECORD_RESULT(sb_function);
}
SBSymbol SBFrame::GetSymbol() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBSymbol, SBFrame, GetSymbol);
+
SBSymbol sb_symbol;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -259,25 +224,16 @@ SBSymbol SBFrame::GetSymbol() const {
frame = exe_ctx.GetFramePtr();
if (frame) {
sb_symbol.reset(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
- } else {
- if (log)
- log->Printf("SBFrame::GetSymbol () => error: could not reconstruct "
- "frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetSymbol () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(sb_symbol.get()));
- return sb_symbol;
+
+ return LLDB_RECORD_RESULT(sb_symbol);
}
SBBlock SBFrame::GetBlock() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBlock, SBFrame, GetBlock);
+
SBBlock sb_block;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -289,60 +245,37 @@ SBBlock SBFrame::GetBlock() const {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
+ if (frame)
sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block);
- } else {
- if (log)
- log->Printf("SBFrame::GetBlock () => error: could not reconstruct "
- "frame object for this SBFrame.");
- }
- } else {
- if (log)
- log->Printf("SBFrame(%p)::GetBlock () => error: process is running",
- static_cast<void *>(frame));
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetBlock () => SBBlock(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(sb_block.GetPtr()));
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
SBBlock SBFrame::GetFrameBlock() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBlock, SBFrame, GetFrameBlock);
+
SBBlock sb_block;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
Process *process = exe_ctx.GetProcessPtr();
if (target && process) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
+ if (frame)
sb_block.SetPtr(frame->GetFrameBlock());
- } else {
- if (log)
- log->Printf("SBFrame::GetFrameBlock () => error: could not "
- "reconstruct frame object for this SBFrame.");
- }
- } else {
- if (log)
- log->Printf("SBFrame::GetFrameBlock () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(sb_block.GetPtr()));
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
SBLineEntry SBFrame::GetLineEntry() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLineEntry, SBFrame, GetLineEntry);
+
SBLineEntry sb_line_entry;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -357,24 +290,15 @@ SBLineEntry SBFrame::GetLineEntry() const {
if (frame) {
sb_line_entry.SetLineEntry(
frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
- } else {
- if (log)
- log->Printf("SBFrame::GetLineEntry () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetLineEntry () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(sb_line_entry.get()));
- return sb_line_entry;
+ return LLDB_RECORD_RESULT(sb_line_entry);
}
uint32_t SBFrame::GetFrameID() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBFrame, GetFrameID);
+
uint32_t frame_idx = UINT32_MAX;
std::unique_lock<std::recursive_mutex> lock;
@@ -384,14 +308,12 @@ uint32_t SBFrame::GetFrameID() const {
if (frame)
frame_idx = frame->GetFrameIndex();
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBFrame(%p)::GetFrameID () => %u", static_cast<void *>(frame),
- frame_idx);
return frame_idx;
}
lldb::addr_t SBFrame::GetCFA() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetCFA);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -402,7 +324,8 @@ lldb::addr_t SBFrame::GetCFA() const {
}
addr_t SBFrame::GetPC() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetPC);
+
addr_t addr = LLDB_INVALID_ADDRESS;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -417,26 +340,16 @@ addr_t SBFrame::GetPC() const {
if (frame) {
addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress(
target, AddressClass::eCode);
- } else {
- if (log)
- log->Printf("SBFrame::GetPC () => error: could not reconstruct frame "
- "object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetPC () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetPC () => 0x%" PRIx64,
- static_cast<void *>(frame), addr);
-
return addr;
}
bool SBFrame::SetPC(addr_t new_pc) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBFrame, SetPC, (lldb::addr_t), new_pc);
+
bool ret_val = false;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -450,26 +363,16 @@ bool SBFrame::SetPC(addr_t new_pc) {
frame = exe_ctx.GetFramePtr();
if (frame) {
ret_val = frame->GetRegisterContext()->SetPC(new_pc);
- } else {
- if (log)
- log->Printf("SBFrame::SetPC () => error: could not reconstruct frame "
- "object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::SetPC () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::SetPC (new_pc=0x%" PRIx64 ") => %i",
- static_cast<void *>(frame), new_pc, ret_val);
-
return ret_val;
}
addr_t SBFrame::GetSP() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetSP);
+
addr_t addr = LLDB_INVALID_ADDRESS;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -483,25 +386,16 @@ addr_t SBFrame::GetSP() const {
frame = exe_ctx.GetFramePtr();
if (frame) {
addr = frame->GetRegisterContext()->GetSP();
- } else {
- if (log)
- log->Printf("SBFrame::GetSP () => error: could not reconstruct frame "
- "object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetSP () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetSP () => 0x%" PRIx64,
- static_cast<void *>(frame), addr);
return addr;
}
addr_t SBFrame::GetFP() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::addr_t, SBFrame, GetFP);
+
addr_t addr = LLDB_INVALID_ADDRESS;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -513,27 +407,17 @@ addr_t SBFrame::GetFP() const {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
+ if (frame)
addr = frame->GetRegisterContext()->GetFP();
- } else {
- if (log)
- log->Printf("SBFrame::GetFP () => error: could not reconstruct frame "
- "object for this SBFrame.");
- }
- } else {
- if (log)
- log->Printf("SBFrame::GetFP () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetFP () => 0x%" PRIx64,
- static_cast<void *>(frame), addr);
return addr;
}
SBAddress SBFrame::GetPCAddress() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBFrame, GetPCAddress);
+
SBAddress sb_addr;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -545,27 +429,23 @@ SBAddress SBFrame::GetPCAddress() const {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
+ if (frame)
sb_addr.SetAddress(&frame->GetFrameCodeAddress());
- } else {
- if (log)
- log->Printf("SBFrame::GetPCAddress () => error: could not "
- "reconstruct frame object for this SBFrame.");
- }
- } else {
- if (log)
- log->Printf("SBFrame::GetPCAddress () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetPCAddress () => SBAddress(%p)",
- static_cast<void *>(frame), static_cast<void *>(sb_addr.get()));
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
-void SBFrame::Clear() { m_opaque_sp->Clear(); }
+void SBFrame::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBFrame, Clear);
+
+ m_opaque_sp->Clear();
+}
lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath,
+ (const char *), var_path);
+
SBValue sb_value;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -577,18 +457,18 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path) {
frame->CalculateTarget()->GetPreferDynamicValue();
sb_value = GetValueForVariablePath(var_path, use_dynamic);
}
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path,
DynamicValueType use_dynamic) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath,
+ (const char *, lldb::DynamicValueType), var_path,
+ use_dynamic);
+
SBValue sb_value;
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (var_path == nullptr || var_path[0] == '\0') {
- if (log)
- log->Printf(
- "SBFrame::GetValueForVariablePath called with empty variable path.");
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
std::unique_lock<std::recursive_mutex> lock;
@@ -610,21 +490,16 @@ lldb::SBValue SBFrame::GetValueForVariablePath(const char *var_path,
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
var_sp, error));
sb_value.SetSP(value_sp, use_dynamic);
- } else {
- if (log)
- log->Printf("SBFrame::GetValueForVariablePath () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf(
- "SBFrame::GetValueForVariablePath () => error: process is running");
}
}
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
SBValue SBFrame::FindVariable(const char *name) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *),
+ name);
+
SBValue value;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -636,19 +511,19 @@ SBValue SBFrame::FindVariable(const char *name) {
frame->CalculateTarget()->GetPreferDynamicValue();
value = FindVariable(name, use_dynamic);
}
- return value;
+ return LLDB_RECORD_RESULT(value);
}
SBValue SBFrame::FindVariable(const char *name,
lldb::DynamicValueType use_dynamic) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindVariable,
+ (const char *, lldb::DynamicValueType), name, use_dynamic);
+
VariableSP var_sp;
SBValue sb_value;
if (name == nullptr || name[0] == '\0') {
- if (log)
- log->Printf("SBFrame::FindVariable called with empty name");
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
ValueObjectSP value_sp;
@@ -667,26 +542,17 @@ SBValue SBFrame::FindVariable(const char *name,
if (value_sp)
sb_value.SetSP(value_sp, use_dynamic);
- } else {
- if (log)
- log->Printf("SBFrame::FindVariable () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::FindVariable () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
- static_cast<void *>(frame), name,
- static_cast<void *>(value_sp.get()));
-
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindValue,
+ (const char *, lldb::ValueType), name, value_type);
+
SBValue value;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -698,18 +564,19 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
frame->CalculateTarget()->GetPreferDynamicValue();
value = FindValue(name, value_type, use_dynamic);
}
- return value;
+ return LLDB_RECORD_RESULT(value);
}
SBValue SBFrame::FindValue(const char *name, ValueType value_type,
lldb::DynamicValueType use_dynamic) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindValue,
+ (const char *, lldb::ValueType, lldb::DynamicValueType),
+ name, value_type, use_dynamic);
+
SBValue sb_value;
if (name == nullptr || name[0] == '\0') {
- if (log)
- log->Printf("SBFrame::FindValue called with empty name.");
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
ValueObjectSP value_sp;
@@ -816,38 +683,38 @@ SBValue SBFrame::FindValue(const char *name, ValueType value_type,
default:
break;
}
- } else {
- if (log)
- log->Printf("SBFrame::FindValue () => error: could not reconstruct "
- "frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::FindValue () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) "
- "=> SBValue(%p)",
- static_cast<void *>(frame), name, value_type,
- static_cast<void *>(value_sp.get()));
-
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
bool SBFrame::IsEqual(const SBFrame &that) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &),
+ that);
+
lldb::StackFrameSP this_sp = GetFrameSP();
lldb::StackFrameSP that_sp = that.GetFrameSP();
return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
}
-bool SBFrame::operator==(const SBFrame &rhs) const { return IsEqual(rhs); }
+bool SBFrame::operator==(const SBFrame &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator==,(const lldb::SBFrame &),
+ rhs);
+
+ return IsEqual(rhs);
+}
+
+bool SBFrame::operator!=(const SBFrame &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator!=,(const lldb::SBFrame &),
+ rhs);
-bool SBFrame::operator!=(const SBFrame &rhs) const { return !IsEqual(rhs); }
+ return !IsEqual(rhs);
+}
SBThread SBFrame::GetThread() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBFrame, GetThread);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -855,19 +722,12 @@ SBThread SBFrame::GetThread() const {
ThreadSP thread_sp(exe_ctx.GetThreadSP());
SBThread sb_thread(thread_sp);
- if (log) {
- SBStream sstr;
- sb_thread.GetDescription(sstr);
- log->Printf("SBFrame(%p)::GetThread () => SBThread(%p): %s",
- static_cast<void *>(exe_ctx.GetFramePtr()),
- static_cast<void *>(thread_sp.get()), sstr.GetData());
- }
-
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
const char *SBFrame::Disassemble() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFrame, Disassemble);
+
const char *disassembly = nullptr;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -881,26 +741,19 @@ const char *SBFrame::Disassemble() const {
frame = exe_ctx.GetFramePtr();
if (frame) {
disassembly = frame->Disassemble();
- } else {
- if (log)
- log->Printf("SBFrame::Disassemble () => error: could not reconstruct "
- "frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::Disassemble () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::Disassemble () => %s", static_cast<void *>(frame),
- disassembly);
-
return disassembly;
}
SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
bool in_scope_only) {
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables,
+ (bool, bool, bool, bool), arguments, locals, statics,
+ in_scope_only);
+
SBValueList value_list;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -923,12 +776,16 @@ SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
value_list = GetVariables(options);
}
- return value_list;
+ return LLDB_RECORD_RESULT(value_list);
}
lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
bool statics, bool in_scope_only,
lldb::DynamicValueType use_dynamic) {
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables,
+ (bool, bool, bool, bool, lldb::DynamicValueType),
+ arguments, locals, statics, in_scope_only, use_dynamic);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -942,11 +799,12 @@ lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
options.SetInScopeOnly(in_scope_only);
options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
options.SetUseDynamic(use_dynamic);
- return GetVariables(options);
+ return LLDB_RECORD_RESULT(GetVariables(options));
}
SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBFrame, GetVariables,
+ (const lldb::SBVariablesOptions &), options);
SBValueList value_list;
std::unique_lock<std::recursive_mutex> lock;
@@ -965,12 +823,6 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) {
options.GetIncludeRuntimeSupportValues();
const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
- if (log)
- log->Printf(
- "SBFrame::GetVariables (arguments=%i, recognized_arguments=%i, "
- "locals=%i, statics=%i, in_scope_only=%i runtime=%i dynamic=%i)",
- arguments, recognized_arguments, locals, statics, in_scope_only,
- include_runtime_support_values, use_dynamic);
std::set<VariableSP> variable_set;
Process *process = exe_ctx.GetProcessPtr();
@@ -1046,27 +898,15 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) {
}
}
}
- } else {
- if (log)
- log->Printf("SBFrame::GetVariables () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetVariables () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetVariables (...) => SBValueList(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(value_list.opaque_ptr()));
-
- return value_list;
+ return LLDB_RECORD_RESULT(value_list);
}
SBValueList SBFrame::GetRegisters() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValueList, SBFrame, GetRegisters);
SBValueList value_list;
std::unique_lock<std::recursive_mutex> lock;
@@ -1088,27 +928,16 @@ SBValueList SBFrame::GetRegisters() {
ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
}
}
- } else {
- if (log)
- log->Printf("SBFrame::GetRegisters () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetRegisters () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::GetRegisters () => SBValueList(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(value_list.opaque_ptr()));
-
- return value_list;
+ return LLDB_RECORD_RESULT(value_list);
}
SBValue SBFrame::FindRegister(const char *name) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *),
+ name);
SBValue result;
ValueObjectSP value_sp;
@@ -1139,27 +968,17 @@ SBValue SBFrame::FindRegister(const char *name) {
}
}
}
- } else {
- if (log)
- log->Printf("SBFrame::FindRegister () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::FindRegister () => error: process is running");
}
}
- if (log)
- log->Printf("SBFrame(%p)::FindRegister () => SBValue(%p)",
- static_cast<void *>(frame),
- static_cast<void *>(value_sp.get()));
-
- return result;
+ return LLDB_RECORD_RESULT(result);
}
bool SBFrame::GetDescription(SBStream &description) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
std::unique_lock<std::recursive_mutex> lock;
@@ -1174,14 +993,7 @@ bool SBFrame::GetDescription(SBStream &description) {
frame = exe_ctx.GetFramePtr();
if (frame) {
frame->DumpUsingSettingsFormat(&strm);
- } else {
- if (log)
- log->Printf("SBFrame::GetDescription () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetDescription () => error: process is running");
}
} else
@@ -1191,6 +1003,9 @@ bool SBFrame::GetDescription(SBStream &description) {
}
SBValue SBFrame::EvaluateExpression(const char *expr) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression, (const char *),
+ expr);
+
SBValue result;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1208,14 +1023,18 @@ SBValue SBFrame::EvaluateExpression(const char *expr) {
options.SetLanguage(target->GetLanguage());
else
options.SetLanguage(frame->GetLanguage());
- return EvaluateExpression(expr, options);
+ return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
}
- return result;
+ return LLDB_RECORD_RESULT(result);
}
SBValue
SBFrame::EvaluateExpression(const char *expr,
lldb::DynamicValueType fetch_dynamic_value) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *, lldb::DynamicValueType), expr,
+ fetch_dynamic_value);
+
SBExpressionOptions options;
options.SetFetchDynamicValue(fetch_dynamic_value);
options.SetUnwindOnError(true);
@@ -1229,12 +1048,16 @@ SBFrame::EvaluateExpression(const char *expr,
options.SetLanguage(target->GetLanguage());
else if (frame)
options.SetLanguage(frame->GetLanguage());
- return EvaluateExpression(expr, options);
+ return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
}
SBValue SBFrame::EvaluateExpression(const char *expr,
lldb::DynamicValueType fetch_dynamic_value,
bool unwind_on_error) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *, lldb::DynamicValueType, bool), expr,
+ fetch_dynamic_value, unwind_on_error);
+
SBExpressionOptions options;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1248,25 +1071,21 @@ SBValue SBFrame::EvaluateExpression(const char *expr,
options.SetLanguage(target->GetLanguage());
else if (frame)
options.SetLanguage(frame->GetLanguage());
- return EvaluateExpression(expr, options);
+ return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
}
lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
const SBExpressionOptions &options) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &), expr,
+ options);
-#ifndef LLDB_DISABLE_PYTHON
Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-#endif
- ExpressionResults exe_results = eExpressionSetupError;
SBValue expr_result;
if (expr == nullptr || expr[0] == '\0') {
- if (log)
- log->Printf(
- "SBFrame::EvaluateExpression called with an empty expression");
- return expr_result;
+ return LLDB_RECORD_RESULT(expr_result);
}
ValueObjectSP expr_value_sp;
@@ -1274,8 +1093,6 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
@@ -1297,43 +1114,29 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
frame_description.GetData());
}
- exe_results = target->EvaluateExpression(expr, frame, expr_value_sp,
- options.ref());
+ target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
- } else {
- if (log)
- log->Printf("SBFrame::EvaluateExpression () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf(
- "SBFrame::EvaluateExpression () => error: process is running");
}
}
-#ifndef LLDB_DISABLE_PYTHON
if (expr_log)
expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is "
"%s, summary %s **",
expr_result.GetValue(), expr_result.GetSummary());
- if (log)
- log->Printf("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) "
- "(execution result=%d)",
- static_cast<void *>(frame), expr,
- static_cast<void *>(expr_value_sp.get()), exe_results);
-#endif
-
- return expr_result;
+ return LLDB_RECORD_RESULT(expr_result);
}
bool SBFrame::IsInlined() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBFrame, IsInlined);
+
return static_cast<const SBFrame *>(this)->IsInlined();
}
bool SBFrame::IsInlined() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsInlined);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1349,24 +1152,21 @@ bool SBFrame::IsInlined() const {
Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
if (block)
return block->GetContainingInlinedBlock() != nullptr;
- } else {
- if (log)
- log->Printf("SBFrame::IsInlined () => error: could not reconstruct "
- "frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::IsInlined () => error: process is running");
}
}
return false;
}
bool SBFrame::IsArtificial() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBFrame, IsArtificial);
+
return static_cast<const SBFrame *>(this)->IsArtificial();
}
bool SBFrame::IsArtificial() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, IsArtificial);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1378,13 +1178,17 @@ bool SBFrame::IsArtificial() const {
}
const char *SBFrame::GetFunctionName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBFrame, GetFunctionName);
+
return static_cast<const SBFrame *>(this)->GetFunctionName();
}
lldb::LanguageType SBFrame::GuessLanguage() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::LanguageType, SBFrame, GuessLanguage);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
-
+
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
@@ -1401,7 +1205,8 @@ lldb::LanguageType SBFrame::GuessLanguage() const {
}
const char *SBFrame::GetFunctionName() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFrame, GetFunctionName);
+
const char *name = nullptr;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1436,21 +1241,15 @@ const char *SBFrame::GetFunctionName() const {
if (sc.symbol)
name = sc.symbol->GetName().GetCString();
}
- } else {
- if (log)
- log->Printf("SBFrame::GetFunctionName () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf("SBFrame::GetFunctionName() => error: process is running");
}
}
return name;
}
const char *SBFrame::GetDisplayFunctionName() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBFrame, GetDisplayFunctionName);
+
const char *name = nullptr;
std::unique_lock<std::recursive_mutex> lock;
@@ -1486,16 +1285,87 @@ const char *SBFrame::GetDisplayFunctionName() {
if (sc.symbol)
name = sc.symbol->GetDisplayName().GetCString();
}
- } else {
- if (log)
- log->Printf("SBFrame::GetDisplayFunctionName () => error: could not "
- "reconstruct frame object for this SBFrame.");
}
- } else {
- if (log)
- log->Printf(
- "SBFrame::GetDisplayFunctionName() => error: process is running");
}
}
return name;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBFrame>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBFrame, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::SBFrame &));
+ LLDB_REGISTER_METHOD(const lldb::SBFrame &,
+ SBFrame, operator=,(const lldb::SBFrame &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFrame, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBSymbolContext, SBFrame, GetSymbolContext,
+ (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBModule, SBFrame, GetModule, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBCompileUnit, SBFrame, GetCompileUnit,
+ ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFunction, SBFrame, GetFunction, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBSymbol, SBFrame, GetSymbol, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetBlock, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetFrameBlock, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBLineEntry, SBFrame, GetLineEntry, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBFrame, GetFrameID, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetCFA, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetPC, ());
+ LLDB_REGISTER_METHOD(bool, SBFrame, SetPC, (lldb::addr_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetSP, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::addr_t, SBFrame, GetFP, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBFrame, GetPCAddress, ());
+ LLDB_REGISTER_METHOD(void, SBFrame, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath,
+ (const char *, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable,
+ (const char *, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindValue,
+ (const char *, lldb::ValueType));
+ LLDB_REGISTER_METHOD(
+ lldb::SBValue, SBFrame, FindValue,
+ (const char *, lldb::ValueType, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBFrame, operator==,(const lldb::SBFrame &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBFrame, operator!=,(const lldb::SBFrame &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBFrame, GetThread, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, Disassemble, ());
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables,
+ (bool, bool, bool, bool));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables,
+ (bool, bool, bool, bool, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetVariables,
+ (const lldb::SBVariablesOptions &));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetRegisters, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *, lldb::DynamicValueType, bool));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &));
+ LLDB_REGISTER_METHOD(bool, SBFrame, IsInlined, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsInlined, ());
+ LLDB_REGISTER_METHOD(bool, SBFrame, IsArtificial, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsArtificial, ());
+ LLDB_REGISTER_METHOD(const char *, SBFrame, GetFunctionName, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::LanguageType, SBFrame, GuessLanguage, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, GetFunctionName, ());
+ LLDB_REGISTER_METHOD(const char *, SBFrame, GetDisplayFunctionName, ());
+}
+
+}
+}
diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp
index 6a24f64b43e4e..1770bede2f428 100644
--- a/source/API/SBFunction.cpp
+++ b/source/API/SBFunction.cpp
@@ -1,13 +1,13 @@
//===-- SBFunction.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBFunction.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
@@ -18,89 +18,90 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-SBFunction::SBFunction() : m_opaque_ptr(NULL) {}
+SBFunction::SBFunction() : m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFunction);
+}
SBFunction::SBFunction(lldb_private::Function *lldb_object_ptr)
: m_opaque_ptr(lldb_object_ptr) {}
SBFunction::SBFunction(const lldb::SBFunction &rhs)
- : m_opaque_ptr(rhs.m_opaque_ptr) {}
+ : m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBFunction, (const lldb::SBFunction &), rhs);
+}
const SBFunction &SBFunction::operator=(const SBFunction &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBFunction &,
+ SBFunction, operator=,(const lldb::SBFunction &), rhs);
+
m_opaque_ptr = rhs.m_opaque_ptr;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-SBFunction::~SBFunction() { m_opaque_ptr = NULL; }
+SBFunction::~SBFunction() { m_opaque_ptr = nullptr; }
-bool SBFunction::IsValid() const { return m_opaque_ptr != NULL; }
+bool SBFunction::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFunction, IsValid);
+ return this->operator bool();
+}
+SBFunction::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFunction, operator bool);
+
+ return m_opaque_ptr != nullptr;
+}
const char *SBFunction::GetName() const {
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetName);
+
+ const char *cstr = nullptr;
if (m_opaque_ptr)
cstr = m_opaque_ptr->GetName().AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (cstr)
- log->Printf("SBFunction(%p)::GetName () => \"%s\"",
- static_cast<void *>(m_opaque_ptr), cstr);
- else
- log->Printf("SBFunction(%p)::GetName () => NULL",
- static_cast<void *>(m_opaque_ptr));
- }
return cstr;
}
const char *SBFunction::GetDisplayName() const {
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetDisplayName);
+
+ const char *cstr = nullptr;
if (m_opaque_ptr)
cstr = m_opaque_ptr->GetMangled()
.GetDisplayDemangledName(m_opaque_ptr->GetLanguage())
.AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (cstr)
- log->Printf("SBFunction(%p)::GetDisplayName () => \"%s\"",
- static_cast<void *>(m_opaque_ptr), cstr);
- else
- log->Printf("SBFunction(%p)::GetDisplayName () => NULL",
- static_cast<void *>(m_opaque_ptr));
- }
return cstr;
}
const char *SBFunction::GetMangledName() const {
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBFunction, GetMangledName);
+
+ const char *cstr = nullptr;
if (m_opaque_ptr)
cstr = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (cstr)
- log->Printf("SBFunction(%p)::GetMangledName () => \"%s\"",
- static_cast<void *>(m_opaque_ptr), cstr);
- else
- log->Printf("SBFunction(%p)::GetMangledName () => NULL",
- static_cast<void *>(m_opaque_ptr));
- }
return cstr;
}
bool SBFunction::operator==(const SBFunction &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBFunction, operator==,(const lldb::SBFunction &), rhs);
+
return m_opaque_ptr == rhs.m_opaque_ptr;
}
bool SBFunction::operator!=(const SBFunction &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBFunction, operator!=,(const lldb::SBFunction &), rhs);
+
return m_opaque_ptr != rhs.m_opaque_ptr;
}
bool SBFunction::GetDescription(SBStream &s) {
+ LLDB_RECORD_METHOD(bool, SBFunction, GetDescription, (lldb::SBStream &), s);
+
if (m_opaque_ptr) {
s.Printf("SBFunction: id = 0x%8.8" PRIx64 ", name = %s",
m_opaque_ptr->GetID(), m_opaque_ptr->GetName().AsCString());
@@ -114,11 +115,17 @@ bool SBFunction::GetDescription(SBStream &s) {
}
SBInstructionList SBFunction::GetInstructions(SBTarget target) {
- return GetInstructions(target, NULL);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions,
+ (lldb::SBTarget), target);
+
+ return LLDB_RECORD_RESULT(GetInstructions(target, nullptr));
}
SBInstructionList SBFunction::GetInstructions(SBTarget target,
const char *flavor) {
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions,
+ (lldb::SBTarget, const char *), target, flavor);
+
SBInstructionList sb_instructions;
if (m_opaque_ptr) {
ExecutionContext exe_ctx;
@@ -134,11 +141,11 @@ SBInstructionList SBFunction::GetInstructions(SBTarget target,
if (module_sp) {
const bool prefer_file_cache = false;
sb_instructions.SetDisassembler(Disassembler::DisassembleRange(
- module_sp->GetArchitecture(), NULL, flavor, exe_ctx,
+ module_sp->GetArchitecture(), nullptr, flavor, exe_ctx,
m_opaque_ptr->GetAddressRange(), prefer_file_cache));
}
}
- return sb_instructions;
+ return LLDB_RECORD_RESULT(sb_instructions);
}
lldb_private::Function *SBFunction::get() { return m_opaque_ptr; }
@@ -148,13 +155,17 @@ void SBFunction::reset(lldb_private::Function *lldb_object_ptr) {
}
SBAddress SBFunction::GetStartAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBFunction, GetStartAddress);
+
SBAddress addr;
if (m_opaque_ptr)
addr.SetAddress(&m_opaque_ptr->GetAddressRange().GetBaseAddress());
- return addr;
+ return LLDB_RECORD_RESULT(addr);
}
SBAddress SBFunction::GetEndAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBFunction, GetEndAddress);
+
SBAddress addr;
if (m_opaque_ptr) {
addr_t byte_size = m_opaque_ptr->GetAddressRange().GetByteSize();
@@ -163,10 +174,13 @@ SBAddress SBFunction::GetEndAddress() {
addr->Slide(byte_size);
}
}
- return addr;
+ return LLDB_RECORD_RESULT(addr);
}
const char *SBFunction::GetArgumentName(uint32_t arg_idx) {
+ LLDB_RECORD_METHOD(const char *, SBFunction, GetArgumentName, (uint32_t),
+ arg_idx);
+
if (m_opaque_ptr) {
Block &block = m_opaque_ptr->GetBlock(true);
VariableListSP variable_list_sp = block.GetBlockVariableList(true);
@@ -183,29 +197,37 @@ const char *SBFunction::GetArgumentName(uint32_t arg_idx) {
}
uint32_t SBFunction::GetPrologueByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBFunction, GetPrologueByteSize);
+
if (m_opaque_ptr)
return m_opaque_ptr->GetPrologueByteSize();
return 0;
}
SBType SBFunction::GetType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBFunction, GetType);
+
SBType sb_type;
if (m_opaque_ptr) {
Type *function_type = m_opaque_ptr->GetType();
if (function_type)
sb_type.ref().SetType(function_type->shared_from_this());
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
SBBlock SBFunction::GetBlock() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBFunction, GetBlock);
+
SBBlock sb_block;
if (m_opaque_ptr)
sb_block.SetPtr(&m_opaque_ptr->GetBlock(true));
- return sb_block;
+ return LLDB_RECORD_RESULT(sb_block);
}
lldb::LanguageType SBFunction::GetLanguage() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBFunction, GetLanguage);
+
if (m_opaque_ptr) {
if (m_opaque_ptr->GetCompileUnit())
return m_opaque_ptr->GetCompileUnit()->GetLanguage();
@@ -214,9 +236,47 @@ lldb::LanguageType SBFunction::GetLanguage() {
}
bool SBFunction::GetIsOptimized() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBFunction, GetIsOptimized);
+
if (m_opaque_ptr) {
if (m_opaque_ptr->GetCompileUnit())
return m_opaque_ptr->GetCompileUnit()->GetIsOptimized();
}
return false;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBFunction>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBFunction, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBFunction, (const lldb::SBFunction &));
+ LLDB_REGISTER_METHOD(const lldb::SBFunction &,
+ SBFunction, operator=,(const lldb::SBFunction &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBFunction, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBFunction, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetName, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetDisplayName, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBFunction, GetMangledName, ());
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBFunction, operator==,(const lldb::SBFunction &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBFunction, operator!=,(const lldb::SBFunction &));
+ LLDB_REGISTER_METHOD(bool, SBFunction, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBFunction, GetInstructions,
+ (lldb::SBTarget, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBFunction, GetStartAddress, ());
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBFunction, GetEndAddress, ());
+ LLDB_REGISTER_METHOD(const char *, SBFunction, GetArgumentName, (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBFunction, GetPrologueByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBFunction, GetType, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBFunction, GetBlock, ());
+ LLDB_REGISTER_METHOD(lldb::LanguageType, SBFunction, GetLanguage, ());
+ LLDB_REGISTER_METHOD(bool, SBFunction, GetIsOptimized, ());
+}
+
+}
+}
diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp
index ac6ab40bda416..c3c92e68140d4 100644
--- a/source/API/SBHostOS.cpp
+++ b/source/API/SBHostOS.cpp
@@ -1,16 +1,12 @@
//===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_DISABLE_PYTHON
-#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
-#endif
-
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBHostOS.h"
#include "lldb/Host/FileSystem.h"
@@ -20,7 +16,6 @@
#include "lldb/Host/HostThread.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/Log.h"
#include "Plugins/ExpressionParser/Clang/ClangHost.h"
#ifndef LLDB_DISABLE_PYTHON
@@ -34,16 +29,25 @@ using namespace lldb;
using namespace lldb_private;
SBFileSpec SBHostOS::GetProgramFileSpec() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS,
+ GetProgramFileSpec);
+
SBFileSpec sb_filespec;
sb_filespec.SetFileSpec(HostInfo::GetProgramFileSpec());
- return sb_filespec;
+ return LLDB_RECORD_RESULT(sb_filespec);
}
SBFileSpec SBHostOS::GetLLDBPythonPath() {
- return GetLLDBPath(ePathTypePythonDir);
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS,
+ GetLLDBPythonPath);
+
+ return LLDB_RECORD_RESULT(GetLLDBPath(ePathTypePythonDir));
}
SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath,
+ (lldb::PathType), path_type);
+
FileSpec fspec;
switch (path_type) {
case ePathTypeLLDBShlibDir:
@@ -79,10 +83,13 @@ SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {
SBFileSpec sb_fspec;
sb_fspec.SetFileSpec(fspec);
- return sb_fspec;
+ return LLDB_RECORD_RESULT(sb_fspec);
}
SBFileSpec SBHostOS::GetUserHomeDirectory() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBFileSpec, SBHostOS,
+ GetUserHomeDirectory);
+
SBFileSpec sb_fspec;
llvm::SmallString<64> home_dir_path;
@@ -91,32 +98,38 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() {
FileSystem::Instance().Resolve(homedir);
sb_fspec.SetFileSpec(homedir);
- return sb_fspec;
+ return LLDB_RECORD_RESULT(sb_fspec);
}
lldb::thread_t SBHostOS::ThreadCreate(const char *name,
lldb::thread_func_t thread_function,
void *thread_arg, SBError *error_ptr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf(
- "SBHostOS::ThreadCreate (name=\"%s\", thread_function=%p, "
- "thread_arg=%p, error_ptr=%p)",
- name,
- reinterpret_cast<void *>(reinterpret_cast<intptr_t>(thread_function)),
- static_cast<void *>(thread_arg), static_cast<void *>(error_ptr));
-
- // FIXME: You should log the return value?
+ LLDB_RECORD_DUMMY(lldb::thread_t, SBHostOS, ThreadCreate,
+ (lldb::thread_func_t, void *, SBError *), name,
+ thread_function, thread_arg, error_ptr);
+ llvm::Expected<HostThread> thread =
+ ThreadLauncher::LaunchThread(name, thread_function, thread_arg);
+ if (!thread) {
+ if (error_ptr)
+ error_ptr->SetError(Status(thread.takeError()));
+ else
+ llvm::consumeError(thread.takeError());
+ return LLDB_INVALID_HOST_THREAD;
+ }
- HostThread thread(ThreadLauncher::LaunchThread(
- name, thread_function, thread_arg, error_ptr ? error_ptr->get() : NULL));
- return thread.Release();
+ return thread->Release();
}
-void SBHostOS::ThreadCreated(const char *name) {}
+void SBHostOS::ThreadCreated(const char *name) {
+ LLDB_RECORD_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *),
+ name);
+}
bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) {
+ LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadCancel,
+ (lldb::thread_t, lldb::SBError *), thread,
+ error_ptr);
+
Status error;
HostThread host_thread(thread);
error = host_thread.Cancel();
@@ -127,6 +140,10 @@ bool SBHostOS::ThreadCancel(lldb::thread_t thread, SBError *error_ptr) {
}
bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) {
+ LLDB_RECORD_DUMMY(bool, SBHostOS, ThreadDetach,
+ (lldb::thread_t, lldb::SBError *), thread,
+ error_ptr);
+
Status error;
#if defined(_WIN32)
if (error_ptr)
@@ -143,6 +160,11 @@ bool SBHostOS::ThreadDetach(lldb::thread_t thread, SBError *error_ptr) {
bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result,
SBError *error_ptr) {
+ LLDB_RECORD_DUMMY(
+ bool, SBHostOS, ThreadJoin,
+ (lldb::thread_t, lldb::thread_result_t *, lldb::SBError *), thread,
+ result, error_ptr);
+
Status error;
HostThread host_thread(thread);
error = host_thread.Join(result);
@@ -151,3 +173,22 @@ bool SBHostOS::ThreadJoin(lldb::thread_t thread, lldb::thread_result_t *result,
host_thread.Release();
return error.Success();
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBHostOS>(Registry &R) {
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetProgramFileSpec,
+ ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPythonPath,
+ ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS, GetLLDBPath,
+ (lldb::PathType));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBFileSpec, SBHostOS,
+ GetUserHomeDirectory, ());
+ LLDB_REGISTER_STATIC_METHOD(void, SBHostOS, ThreadCreated, (const char *));
+}
+
+}
+}
diff --git a/source/API/SBInitializerOptions.cpp b/source/API/SBInitializerOptions.cpp
deleted file mode 100644
index 8d8ec28190ec1..0000000000000
--- a/source/API/SBInitializerOptions.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-//===-- SBInitializerOptions.cpp --------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/API/SBInitializerOptions.h"
-#include "lldb/Initialization/SystemInitializer.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-SBInitializerOptions::SBInitializerOptions(const SBInitializerOptions &rhs) {
- m_opaque_up.reset(new InitializerOptions());
- *(m_opaque_up.get()) = rhs.ref();
-}
-
-const SBInitializerOptions &SBInitializerOptions::
-operator=(const SBInitializerOptions &rhs) {
- if (this != &rhs) {
- this->ref() = rhs.ref();
- }
- return *this;
-}
-
-SBInitializerOptions::~SBInitializerOptions() {}
-
-SBInitializerOptions::SBInitializerOptions() {
- m_opaque_up.reset(new InitializerOptions());
-}
-
-void SBInitializerOptions::SetCaptureReproducer(bool b) {
- m_opaque_up->reproducer_capture = b;
-}
-
-void SBInitializerOptions::SetReplayReproducer(bool b) {
- m_opaque_up->reproducer_replay = b;
-}
-
-void SBInitializerOptions::SetReproducerPath(const char *path) {
- m_opaque_up->reproducer_path = path;
-}
-
-InitializerOptions &SBInitializerOptions::ref() const {
- return *(m_opaque_up.get());
-}
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 462f082880920..fcf66fd258240 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -1,16 +1,17 @@
//===-- SBInstruction.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBInstruction.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFrame.h"
+
#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTarget.h"
@@ -26,7 +27,8 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
-//----------------------------------------------------------------------
+#include <memory>
+
// We recently fixed a leak in one of the Instruction subclasses where the
// instruction will only hold a weak reference to the disassembler to avoid a
// cycle that was keeping both objects alive (leak) and we need the
@@ -45,7 +47,6 @@
// objects that are given out have a strong reference to the disassembler and
// the instruction so that the object can live and successfully respond to all
// queries.
-//----------------------------------------------------------------------
class InstructionImpl {
public:
InstructionImpl(const lldb::DisassemblerSP &disasm_sp,
@@ -64,34 +65,55 @@ protected:
using namespace lldb;
using namespace lldb_private;
-SBInstruction::SBInstruction() : m_opaque_sp() {}
+SBInstruction::SBInstruction() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstruction);
+}
SBInstruction::SBInstruction(const lldb::DisassemblerSP &disasm_sp,
const lldb::InstructionSP &inst_sp)
: m_opaque_sp(new InstructionImpl(disasm_sp, inst_sp)) {}
SBInstruction::SBInstruction(const SBInstruction &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &), rhs);
+}
const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBInstruction &,
+ SBInstruction, operator=,(const lldb::SBInstruction &),
+ rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBInstruction::~SBInstruction() {}
-bool SBInstruction::IsValid() { return m_opaque_sp && m_opaque_sp->IsValid(); }
+bool SBInstruction::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, IsValid);
+ return this->operator bool();
+}
+SBInstruction::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstruction, operator bool);
+
+ return m_opaque_sp && m_opaque_sp->IsValid();
+}
SBAddress SBInstruction::GetAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBInstruction, GetAddress);
+
SBAddress sb_addr;
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp && inst_sp->GetAddress().IsValid())
sb_addr.SetAddress(&inst_sp->GetAddress());
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
const char *SBInstruction::GetMnemonic(SBTarget target) {
+ LLDB_RECORD_METHOD(const char *, SBInstruction, GetMnemonic, (lldb::SBTarget),
+ target);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp) {
ExecutionContext exe_ctx;
@@ -105,10 +127,13 @@ const char *SBInstruction::GetMnemonic(SBTarget target) {
}
return inst_sp->GetMnemonic(&exe_ctx);
}
- return NULL;
+ return nullptr;
}
const char *SBInstruction::GetOperands(SBTarget target) {
+ LLDB_RECORD_METHOD(const char *, SBInstruction, GetOperands, (lldb::SBTarget),
+ target);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp) {
ExecutionContext exe_ctx;
@@ -122,10 +147,13 @@ const char *SBInstruction::GetOperands(SBTarget target) {
}
return inst_sp->GetOperands(&exe_ctx);
}
- return NULL;
+ return nullptr;
}
const char *SBInstruction::GetComment(SBTarget target) {
+ LLDB_RECORD_METHOD(const char *, SBInstruction, GetComment, (lldb::SBTarget),
+ target);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp) {
ExecutionContext exe_ctx;
@@ -139,10 +167,12 @@ const char *SBInstruction::GetComment(SBTarget target) {
}
return inst_sp->GetComment(&exe_ctx);
}
- return NULL;
+ return nullptr;
}
size_t SBInstruction::GetByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstruction, GetByteSize);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp)
return inst_sp->GetOpcode().GetByteSize();
@@ -150,6 +180,9 @@ size_t SBInstruction::GetByteSize() {
}
SBData SBInstruction::GetData(SBTarget target) {
+ LLDB_RECORD_METHOD(lldb::SBData, SBInstruction, GetData, (lldb::SBTarget),
+ target);
+
lldb::SBData sb_data;
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp) {
@@ -158,10 +191,12 @@ SBData SBInstruction::GetData(SBTarget target) {
sb_data.SetOpaque(data_extractor_sp);
}
}
- return sb_data;
+ return LLDB_RECORD_RESULT(sb_data);
}
bool SBInstruction::DoesBranch() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, DoesBranch);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp)
return inst_sp->DoesBranch();
@@ -169,13 +204,17 @@ bool SBInstruction::DoesBranch() {
}
bool SBInstruction::HasDelaySlot() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, HasDelaySlot);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp)
return inst_sp->HasDelaySlot();
return false;
}
-bool SBInstruction::CanSetBreakpoint () {
+bool SBInstruction::CanSetBreakpoint() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, CanSetBreakpoint);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp)
return inst_sp->CanSetBreakpoint();
@@ -191,10 +230,13 @@ lldb::InstructionSP SBInstruction::GetOpaque() {
void SBInstruction::SetOpaque(const lldb::DisassemblerSP &disasm_sp,
const lldb::InstructionSP &inst_sp) {
- m_opaque_sp.reset(new InstructionImpl(disasm_sp, inst_sp));
+ m_opaque_sp = std::make_shared<InstructionImpl>(disasm_sp, inst_sp);
}
bool SBInstruction::GetDescription(lldb::SBStream &s) {
+ LLDB_RECORD_METHOD(bool, SBInstruction, GetDescription, (lldb::SBStream &),
+ s);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp) {
SymbolContext sc;
@@ -207,14 +249,16 @@ bool SBInstruction::GetDescription(lldb::SBStream &s) {
// didn't have a stream already created, one will get created...
FormatEntity::Entry format;
FormatEntity::Parse("${addr}: ", format);
- inst_sp->Dump(&s.ref(), 0, true, false, NULL, &sc, NULL, &format, 0);
+ inst_sp->Dump(&s.ref(), 0, true, false, nullptr, &sc, nullptr, &format, 0);
return true;
}
return false;
}
void SBInstruction::Print(FILE *out) {
- if (out == NULL)
+ LLDB_RECORD_METHOD(void, SBInstruction, Print, (FILE *), out);
+
+ if (out == nullptr)
return;
lldb::InstructionSP inst_sp(GetOpaque());
@@ -228,12 +272,16 @@ void SBInstruction::Print(FILE *out) {
StreamFile out_stream(out, false);
FormatEntity::Entry format;
FormatEntity::Parse("${addr}: ", format);
- inst_sp->Dump(&out_stream, 0, true, false, NULL, &sc, NULL, &format, 0);
+ inst_sp->Dump(&out_stream, 0, true, false, nullptr, &sc, nullptr, &format,
+ 0);
}
}
bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame,
uint32_t evaluate_options) {
+ LLDB_RECORD_METHOD(bool, SBInstruction, EmulateWithFrame,
+ (lldb::SBFrame &, uint32_t), frame, evaluate_options);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp) {
lldb::StackFrameSP frame_sp(frame.GetFrameSP());
@@ -256,6 +304,9 @@ bool SBInstruction::EmulateWithFrame(lldb::SBFrame &frame,
}
bool SBInstruction::DumpEmulation(const char *triple) {
+ LLDB_RECORD_METHOD(bool, SBInstruction, DumpEmulation, (const char *),
+ triple);
+
lldb::InstructionSP inst_sp(GetOpaque());
if (inst_sp && triple) {
return inst_sp->DumpEmulation(HostInfo::GetAugmentedArchSpec(triple));
@@ -265,6 +316,10 @@ bool SBInstruction::DumpEmulation(const char *triple) {
bool SBInstruction::TestEmulation(lldb::SBStream &output_stream,
const char *test_file) {
+ LLDB_RECORD_METHOD(bool, SBInstruction, TestEmulation,
+ (lldb::SBStream &, const char *), output_stream,
+ test_file);
+
if (!m_opaque_sp)
SetOpaque(lldb::DisassemblerSP(),
lldb::InstructionSP(new PseudoInstruction()));
@@ -274,3 +329,41 @@ bool SBInstruction::TestEmulation(lldb::SBStream &output_stream,
return inst_sp->TestEmulation(output_stream.get(), test_file);
return false;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBInstruction>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBInstruction, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBInstruction, (const lldb::SBInstruction &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBInstruction &,
+ SBInstruction, operator=,(const lldb::SBInstruction &));
+ LLDB_REGISTER_METHOD(bool, SBInstruction, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBInstruction, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBInstruction, GetAddress, ());
+ LLDB_REGISTER_METHOD(const char *, SBInstruction, GetMnemonic,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(const char *, SBInstruction, GetOperands,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(const char *, SBInstruction, GetComment,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(size_t, SBInstruction, GetByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBData, SBInstruction, GetData,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(bool, SBInstruction, DoesBranch, ());
+ LLDB_REGISTER_METHOD(bool, SBInstruction, HasDelaySlot, ());
+ LLDB_REGISTER_METHOD(bool, SBInstruction, CanSetBreakpoint, ());
+ LLDB_REGISTER_METHOD(bool, SBInstruction, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(void, SBInstruction, Print, (FILE *));
+ LLDB_REGISTER_METHOD(bool, SBInstruction, EmulateWithFrame,
+ (lldb::SBFrame &, uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBInstruction, DumpEmulation, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBInstruction, TestEmulation,
+ (lldb::SBStream &, const char *));
+}
+
+}
+}
diff --git a/source/API/SBInstructionList.cpp b/source/API/SBInstructionList.cpp
index 29e0c96075fd0..cce923bf04a4b 100644
--- a/source/API/SBInstructionList.cpp
+++ b/source/API/SBInstructionList.cpp
@@ -1,15 +1,15 @@
//===-- SBInstructionList.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBInstructionList.h"
-#include "lldb/API/SBInstruction.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBInstruction.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
@@ -19,40 +19,66 @@
using namespace lldb;
using namespace lldb_private;
-SBInstructionList::SBInstructionList() : m_opaque_sp() {}
+SBInstructionList::SBInstructionList() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBInstructionList);
+}
SBInstructionList::SBInstructionList(const SBInstructionList &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBInstructionList, (const lldb::SBInstructionList &),
+ rhs);
+}
const SBInstructionList &SBInstructionList::
operator=(const SBInstructionList &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBInstructionList &,
+ SBInstructionList, operator=,(const lldb::SBInstructionList &), rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBInstructionList::~SBInstructionList() {}
-bool SBInstructionList::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBInstructionList::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, IsValid);
+ return this->operator bool();
+}
+SBInstructionList::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
size_t SBInstructionList::GetSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBInstructionList, GetSize);
+
if (m_opaque_sp)
return m_opaque_sp->GetInstructionList().GetSize();
return 0;
}
SBInstruction SBInstructionList::GetInstructionAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBInstruction, SBInstructionList,
+ GetInstructionAtIndex, (uint32_t), idx);
+
SBInstruction inst;
if (m_opaque_sp && idx < m_opaque_sp->GetInstructionList().GetSize())
inst.SetOpaque(
m_opaque_sp,
m_opaque_sp->GetInstructionList().GetInstructionAtIndex(idx));
- return inst;
+ return LLDB_RECORD_RESULT(inst);
}
size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
- const SBAddress &end,
- bool canSetBreakpoint) {
+ const SBAddress &end,
+ bool canSetBreakpoint) {
+ LLDB_RECORD_METHOD(size_t, SBInstructionList, GetInstructionsCount,
+ (const lldb::SBAddress &, const lldb::SBAddress &, bool),
+ start, end, canSetBreakpoint);
+
size_t num_instructions = GetSize();
size_t i = 0;
SBAddress addr;
@@ -75,20 +101,32 @@ size_t SBInstructionList::GetInstructionsCount(const SBAddress &start,
return upper_index - lower_index - instructions_to_skip;
}
-void SBInstructionList::Clear() { m_opaque_sp.reset(); }
+void SBInstructionList::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBInstructionList, Clear);
-void SBInstructionList::AppendInstruction(SBInstruction insn) {}
+ m_opaque_sp.reset();
+}
+
+void SBInstructionList::AppendInstruction(SBInstruction insn) {
+ LLDB_RECORD_METHOD(void, SBInstructionList, AppendInstruction,
+ (lldb::SBInstruction), insn);
+}
void SBInstructionList::SetDisassembler(const lldb::DisassemblerSP &opaque_sp) {
m_opaque_sp = opaque_sp;
}
void SBInstructionList::Print(FILE *out) {
- if (out == NULL)
+ LLDB_RECORD_METHOD(void, SBInstructionList, Print, (FILE *), out);
+
+ if (out == nullptr)
return;
}
bool SBInstructionList::GetDescription(lldb::SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBInstructionList, GetDescription,
+ (lldb::SBStream &), description);
+
if (m_opaque_sp) {
size_t num_instructions = GetSize();
if (num_instructions) {
@@ -104,7 +142,7 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) {
for (size_t i = 0; i < num_instructions; ++i) {
Instruction *inst =
m_opaque_sp->GetInstructionList().GetInstructionAtIndex(i).get();
- if (inst == NULL)
+ if (inst == nullptr)
break;
const Address &addr = inst->GetAddress();
@@ -115,7 +153,7 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) {
addr, eSymbolContextEverything, sc);
}
- inst->Dump(&sref, max_opcode_byte_size, true, false, NULL, &sc,
+ inst->Dump(&sref, max_opcode_byte_size, true, false, nullptr, &sc,
&prev_sc, &format, 0);
sref.EOL();
}
@@ -126,6 +164,9 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) {
}
bool SBInstructionList::DumpEmulationForAllInstructions(const char *triple) {
+ LLDB_RECORD_METHOD(bool, SBInstructionList, DumpEmulationForAllInstructions,
+ (const char *), triple);
+
if (m_opaque_sp) {
size_t len = GetSize();
for (size_t i = 0; i < len; ++i) {
@@ -135,3 +176,35 @@ bool SBInstructionList::DumpEmulationForAllInstructions(const char *triple) {
}
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBInstructionList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBInstructionList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBInstructionList,
+ (const lldb::SBInstructionList &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBInstructionList &,
+ SBInstructionList, operator=,(const lldb::SBInstructionList &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBInstructionList, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBInstructionList, operator bool, ());
+ LLDB_REGISTER_METHOD(size_t, SBInstructionList, GetSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBInstruction, SBInstructionList,
+ GetInstructionAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(
+ size_t, SBInstructionList, GetInstructionsCount,
+ (const lldb::SBAddress &, const lldb::SBAddress &, bool));
+ LLDB_REGISTER_METHOD(void, SBInstructionList, Clear, ());
+ LLDB_REGISTER_METHOD(void, SBInstructionList, AppendInstruction,
+ (lldb::SBInstruction));
+ LLDB_REGISTER_METHOD(void, SBInstructionList, Print, (FILE *));
+ LLDB_REGISTER_METHOD(bool, SBInstructionList, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(bool, SBInstructionList,
+ DumpEmulationForAllInstructions, (const char *));
+}
+
+}
+}
diff --git a/source/API/SBLanguageRuntime.cpp b/source/API/SBLanguageRuntime.cpp
index d3b7514346aab..04bd08fb739e0 100644
--- a/source/API/SBLanguageRuntime.cpp
+++ b/source/API/SBLanguageRuntime.cpp
@@ -1,13 +1,13 @@
//===-- SBLanguageRuntime.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBLanguageRuntime.h"
+#include "SBReproducerPrivate.h"
#include "lldb/Target/Language.h"
using namespace lldb;
@@ -15,11 +15,32 @@ using namespace lldb_private;
lldb::LanguageType
SBLanguageRuntime::GetLanguageTypeFromString(const char *string) {
+ LLDB_RECORD_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime,
+ GetLanguageTypeFromString, (const char *), string);
+
return Language::GetLanguageTypeFromString(
llvm::StringRef::withNullAsEmpty(string));
}
const char *
SBLanguageRuntime::GetNameForLanguageType(lldb::LanguageType language) {
+ LLDB_RECORD_STATIC_METHOD(const char *, SBLanguageRuntime,
+ GetNameForLanguageType, (lldb::LanguageType),
+ language);
+
return Language::GetNameForLanguageType(language);
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBLanguageRuntime>(Registry &R) {
+ LLDB_REGISTER_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime,
+ GetLanguageTypeFromString, (const char *));
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBLanguageRuntime,
+ GetNameForLanguageType, (lldb::LanguageType));
+}
+
+}
+}
diff --git a/source/API/SBLaunchInfo.cpp b/source/API/SBLaunchInfo.cpp
index b1bbfa55d5c18..5c5e69704c7cf 100644
--- a/source/API/SBLaunchInfo.cpp
+++ b/source/API/SBLaunchInfo.cpp
@@ -1,17 +1,17 @@
//===-- SBLaunchInfo.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBLaunchInfo.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBListener.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
using namespace lldb;
using namespace lldb_private;
@@ -36,6 +36,8 @@ private:
SBLaunchInfo::SBLaunchInfo(const char **argv)
: m_opaque_sp(new SBLaunchInfoImpl()) {
+ LLDB_RECORD_CONSTRUCTOR(SBLaunchInfo, (const char **), argv);
+
m_opaque_sp->GetFlags().Reset(eLaunchFlagDebug | eLaunchFlagDisableASLR);
if (argv && argv[0])
m_opaque_sp->GetArguments().SetArguments(argv);
@@ -51,46 +53,92 @@ void SBLaunchInfo::set_ref(const ProcessLaunchInfo &info) {
*m_opaque_sp = info;
}
-lldb::pid_t SBLaunchInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); }
+lldb::pid_t SBLaunchInfo::GetProcessID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBLaunchInfo, GetProcessID);
+
+ return m_opaque_sp->GetProcessID();
+}
+
+uint32_t SBLaunchInfo::GetUserID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetUserID);
+
+ return m_opaque_sp->GetUserID();
+}
+
+uint32_t SBLaunchInfo::GetGroupID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetGroupID);
-uint32_t SBLaunchInfo::GetUserID() { return m_opaque_sp->GetUserID(); }
+ return m_opaque_sp->GetGroupID();
+}
-uint32_t SBLaunchInfo::GetGroupID() { return m_opaque_sp->GetGroupID(); }
+bool SBLaunchInfo::UserIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, UserIDIsValid);
-bool SBLaunchInfo::UserIDIsValid() { return m_opaque_sp->UserIDIsValid(); }
+ return m_opaque_sp->UserIDIsValid();
+}
-bool SBLaunchInfo::GroupIDIsValid() { return m_opaque_sp->GroupIDIsValid(); }
+bool SBLaunchInfo::GroupIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, GroupIDIsValid);
-void SBLaunchInfo::SetUserID(uint32_t uid) { m_opaque_sp->SetUserID(uid); }
+ return m_opaque_sp->GroupIDIsValid();
+}
+
+void SBLaunchInfo::SetUserID(uint32_t uid) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetUserID, (uint32_t), uid);
+
+ m_opaque_sp->SetUserID(uid);
+}
-void SBLaunchInfo::SetGroupID(uint32_t gid) { m_opaque_sp->SetGroupID(gid); }
+void SBLaunchInfo::SetGroupID(uint32_t gid) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetGroupID, (uint32_t), gid);
+
+ m_opaque_sp->SetGroupID(gid);
+}
SBFileSpec SBLaunchInfo::GetExecutableFile() {
- return SBFileSpec(m_opaque_sp->GetExecutableFile());
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBLaunchInfo, GetExecutableFile);
+
+ return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_sp->GetExecutableFile()));
}
void SBLaunchInfo::SetExecutableFile(SBFileSpec exe_file,
bool add_as_first_arg) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetExecutableFile,
+ (lldb::SBFileSpec, bool), exe_file, add_as_first_arg);
+
m_opaque_sp->SetExecutableFile(exe_file.ref(), add_as_first_arg);
}
SBListener SBLaunchInfo::GetListener() {
- return SBListener(m_opaque_sp->GetListener());
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBListener, SBLaunchInfo, GetListener);
+
+ return LLDB_RECORD_RESULT(SBListener(m_opaque_sp->GetListener()));
}
void SBLaunchInfo::SetListener(SBListener &listener) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetListener, (lldb::SBListener &),
+ listener);
+
m_opaque_sp->SetListener(listener.GetSP());
}
uint32_t SBLaunchInfo::GetNumArguments() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetNumArguments);
+
return m_opaque_sp->GetArguments().GetArgumentCount();
}
const char *SBLaunchInfo::GetArgumentAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(const char *, SBLaunchInfo, GetArgumentAtIndex, (uint32_t),
+ idx);
+
return m_opaque_sp->GetArguments().GetArgumentAtIndex(idx);
}
void SBLaunchInfo::SetArguments(const char **argv, bool append) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetArguments, (const char **, bool),
+ argv, append);
+
if (append) {
if (argv)
m_opaque_sp->GetArguments().AppendArguments(argv);
@@ -103,16 +151,24 @@ void SBLaunchInfo::SetArguments(const char **argv, bool append) {
}
uint32_t SBLaunchInfo::GetNumEnvironmentEntries() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetNumEnvironmentEntries);
+
return m_opaque_sp->GetEnvironment().size();
}
const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(const char *, SBLaunchInfo, GetEnvironmentEntryAtIndex,
+ (uint32_t), idx);
+
if (idx > GetNumEnvironmentEntries())
return nullptr;
return m_opaque_sp->GetEnvp()[idx];
}
void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironmentEntries,
+ (const char **, bool), envp, append);
+
Environment env(envp);
if (append)
m_opaque_sp->GetEnvironment().insert(env.begin(), env.end());
@@ -121,33 +177,54 @@ void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) {
m_opaque_sp->RegenerateEnvp();
}
-void SBLaunchInfo::Clear() { m_opaque_sp->Clear(); }
+void SBLaunchInfo::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBLaunchInfo, Clear);
+
+ m_opaque_sp->Clear();
+}
const char *SBLaunchInfo::GetWorkingDirectory() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo,
+ GetWorkingDirectory);
+
return m_opaque_sp->GetWorkingDirectory().GetCString();
}
void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetWorkingDirectory, (const char *),
+ working_dir);
+
m_opaque_sp->SetWorkingDirectory(FileSpec(working_dir));
}
uint32_t SBLaunchInfo::GetLaunchFlags() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetLaunchFlags);
+
return m_opaque_sp->GetFlags().Get();
}
void SBLaunchInfo::SetLaunchFlags(uint32_t flags) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetLaunchFlags, (uint32_t), flags);
+
m_opaque_sp->GetFlags().Reset(flags);
}
const char *SBLaunchInfo::GetProcessPluginName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBLaunchInfo, GetProcessPluginName);
+
return m_opaque_sp->GetProcessPluginName();
}
void SBLaunchInfo::SetProcessPluginName(const char *plugin_name) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetProcessPluginName, (const char *),
+ plugin_name);
+
return m_opaque_sp->SetProcessPluginName(plugin_name);
}
const char *SBLaunchInfo::GetShell() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBLaunchInfo, GetShell);
+
// Constify this string so that it is saved in the string pool. Otherwise it
// would be freed when this function goes out of scope.
ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
@@ -155,54 +232,148 @@ const char *SBLaunchInfo::GetShell() {
}
void SBLaunchInfo::SetShell(const char *path) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetShell, (const char *), path);
+
m_opaque_sp->SetShell(FileSpec(path));
}
bool SBLaunchInfo::GetShellExpandArguments() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBLaunchInfo, GetShellExpandArguments);
+
return m_opaque_sp->GetShellExpandArguments();
}
void SBLaunchInfo::SetShellExpandArguments(bool expand) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetShellExpandArguments, (bool),
+ expand);
+
m_opaque_sp->SetShellExpandArguments(expand);
}
uint32_t SBLaunchInfo::GetResumeCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBLaunchInfo, GetResumeCount);
+
return m_opaque_sp->GetResumeCount();
}
void SBLaunchInfo::SetResumeCount(uint32_t c) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetResumeCount, (uint32_t), c);
+
m_opaque_sp->SetResumeCount(c);
}
bool SBLaunchInfo::AddCloseFileAction(int fd) {
+ LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddCloseFileAction, (int), fd);
+
return m_opaque_sp->AppendCloseFileAction(fd);
}
bool SBLaunchInfo::AddDuplicateFileAction(int fd, int dup_fd) {
+ LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddDuplicateFileAction, (int, int), fd,
+ dup_fd);
+
return m_opaque_sp->AppendDuplicateFileAction(fd, dup_fd);
}
bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read,
bool write) {
+ LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddOpenFileAction,
+ (int, const char *, bool, bool), fd, path, read, write);
+
return m_opaque_sp->AppendOpenFileAction(fd, FileSpec(path), read, write);
}
bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) {
+ LLDB_RECORD_METHOD(bool, SBLaunchInfo, AddSuppressFileAction,
+ (int, bool, bool), fd, read, write);
+
return m_opaque_sp->AppendSuppressFileAction(fd, read, write);
}
void SBLaunchInfo::SetLaunchEventData(const char *data) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetLaunchEventData, (const char *),
+ data);
+
m_opaque_sp->SetLaunchEventData(data);
}
const char *SBLaunchInfo::GetLaunchEventData() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo,
+ GetLaunchEventData);
+
return m_opaque_sp->GetLaunchEventData();
}
void SBLaunchInfo::SetDetachOnError(bool enable) {
+ LLDB_RECORD_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool), enable);
+
m_opaque_sp->SetDetachOnError(enable);
}
bool SBLaunchInfo::GetDetachOnError() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLaunchInfo, GetDetachOnError);
+
return m_opaque_sp->GetDetachOnError();
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBLaunchInfo>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const char **));
+ LLDB_REGISTER_METHOD(lldb::pid_t, SBLaunchInfo, GetProcessID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetUserID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetGroupID, ());
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, UserIDIsValid, ());
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, GroupIDIsValid, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetUserID, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetGroupID, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBLaunchInfo, GetExecutableFile, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetExecutableFile,
+ (lldb::SBFileSpec, bool));
+ LLDB_REGISTER_METHOD(lldb::SBListener, SBLaunchInfo, GetListener, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetListener, (lldb::SBListener &));
+ LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetNumArguments, ());
+ LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetArgumentAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetArguments,
+ (const char **, bool));
+ LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetNumEnvironmentEntries, ());
+ LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetEnvironmentEntryAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironmentEntries,
+ (const char **, bool));
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, GetWorkingDirectory,
+ ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetWorkingDirectory,
+ (const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetLaunchFlags, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetLaunchFlags, (uint32_t));
+ LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetProcessPluginName, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetProcessPluginName,
+ (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBLaunchInfo, GetShell, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetShell, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, GetShellExpandArguments, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetShellExpandArguments, (bool));
+ LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetResumeCount, ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetResumeCount, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddCloseFileAction, (int));
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddDuplicateFileAction,
+ (int, int));
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddOpenFileAction,
+ (int, const char *, bool, bool));
+ LLDB_REGISTER_METHOD(bool, SBLaunchInfo, AddSuppressFileAction,
+ (int, bool, bool));
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetLaunchEventData,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, GetLaunchEventData,
+ ());
+ LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ());
+}
+
+}
+}
diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp
index 6f59fe3407e8a..010a6057cd310 100644
--- a/source/API/SBLineEntry.cpp
+++ b/source/API/SBLineEntry.cpp
@@ -1,148 +1,142 @@
//===-- SBLineEntry.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <limits.h>
-
#include "lldb/API/SBLineEntry.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Host/PosixApi.h"
#include "lldb/Symbol/LineEntry.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
+#include <limits.h>
+
using namespace lldb;
using namespace lldb_private;
-SBLineEntry::SBLineEntry() : m_opaque_ap() {}
+SBLineEntry::SBLineEntry() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBLineEntry);
+}
+
+SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &), rhs);
-SBLineEntry::SBLineEntry(const SBLineEntry &rhs) : m_opaque_ap() {
- if (rhs.IsValid())
- ref() = rhs.ref();
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBLineEntry::SBLineEntry(const lldb_private::LineEntry *lldb_object_ptr)
- : m_opaque_ap() {
+ : m_opaque_up() {
if (lldb_object_ptr)
- ref() = *lldb_object_ptr;
+ m_opaque_up = llvm::make_unique<LineEntry>(*lldb_object_ptr);
}
const SBLineEntry &SBLineEntry::operator=(const SBLineEntry &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- ref() = rhs.ref();
- else
- m_opaque_ap.reset();
- }
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBLineEntry &,
+ SBLineEntry, operator=,(const lldb::SBLineEntry &), rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) {
- ref() = lldb_object_ref;
+ m_opaque_up = llvm::make_unique<LineEntry>(lldb_object_ref);
}
SBLineEntry::~SBLineEntry() {}
SBAddress SBLineEntry::GetStartAddress() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry,
+ GetStartAddress);
+
SBAddress sb_address;
- if (m_opaque_ap)
- sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- StreamString sstr;
- const Address *addr = sb_address.get();
- if (addr)
- addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress,
- Address::DumpStyleInvalid, 4);
- log->Printf("SBLineEntry(%p)::GetStartAddress () => SBAddress (%p): %s",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<void *>(sb_address.get()), sstr.GetData());
- }
+ if (m_opaque_up)
+ sb_address.SetAddress(&m_opaque_up->range.GetBaseAddress());
- return sb_address;
+ return LLDB_RECORD_RESULT(sb_address);
}
SBAddress SBLineEntry::GetEndAddress() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, GetEndAddress);
+
SBAddress sb_address;
- if (m_opaque_ap) {
- sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
- sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize());
+ if (m_opaque_up) {
+ sb_address.SetAddress(&m_opaque_up->range.GetBaseAddress());
+ sb_address.OffsetAddress(m_opaque_up->range.GetByteSize());
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- StreamString sstr;
- const Address *addr = sb_address.get();
- if (addr)
- addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress,
- Address::DumpStyleInvalid, 4);
- log->Printf("SBLineEntry(%p)::GetEndAddress () => SBAddress (%p): %s",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<void *>(sb_address.get()), sstr.GetData());
- }
- return sb_address;
+ return LLDB_RECORD_RESULT(sb_address);
}
bool SBLineEntry::IsValid() const {
- return m_opaque_ap.get() && m_opaque_ap->IsValid();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, IsValid);
+ return this->operator bool();
+}
+SBLineEntry::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBLineEntry, operator bool);
+
+ return m_opaque_up.get() && m_opaque_up->IsValid();
}
SBFileSpec SBLineEntry::GetFileSpec() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBLineEntry, GetFileSpec);
SBFileSpec sb_file_spec;
- if (m_opaque_ap.get() && m_opaque_ap->file)
- sb_file_spec.SetFileSpec(m_opaque_ap->file);
-
- if (log) {
- SBStream sstr;
- sb_file_spec.GetDescription(sstr);
- log->Printf("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<const void *>(sb_file_spec.get()), sstr.GetData());
- }
+ if (m_opaque_up.get() && m_opaque_up->file)
+ sb_file_spec.SetFileSpec(m_opaque_up->file);
- return sb_file_spec;
+ return LLDB_RECORD_RESULT(sb_file_spec);
}
uint32_t SBLineEntry::GetLine() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetLine);
uint32_t line = 0;
- if (m_opaque_ap)
- line = m_opaque_ap->line;
-
- if (log)
- log->Printf("SBLineEntry(%p)::GetLine () => %u",
- static_cast<void *>(m_opaque_ap.get()), line);
+ if (m_opaque_up)
+ line = m_opaque_up->line;
return line;
}
uint32_t SBLineEntry::GetColumn() const {
- if (m_opaque_ap)
- return m_opaque_ap->column;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBLineEntry, GetColumn);
+
+ if (m_opaque_up)
+ return m_opaque_up->column;
return 0;
}
void SBLineEntry::SetFileSpec(lldb::SBFileSpec filespec) {
+ LLDB_RECORD_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec),
+ filespec);
+
if (filespec.IsValid())
ref().file = filespec.ref();
else
ref().file.Clear();
}
-void SBLineEntry::SetLine(uint32_t line) { ref().line = line; }
+void SBLineEntry::SetLine(uint32_t line) {
+ LLDB_RECORD_METHOD(void, SBLineEntry, SetLine, (uint32_t), line);
+
+ ref().line = line;
+}
+
+void SBLineEntry::SetColumn(uint32_t column) {
+ LLDB_RECORD_METHOD(void, SBLineEntry, SetColumn, (uint32_t), column);
-void SBLineEntry::SetColumn(uint32_t column) { ref().line = column; }
+ ref().line = column;
+}
bool SBLineEntry::operator==(const SBLineEntry &rhs) const {
- lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
- lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBLineEntry, operator==,(const lldb::SBLineEntry &), rhs);
+
+ lldb_private::LineEntry *lhs_ptr = m_opaque_up.get();
+ lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get();
if (lhs_ptr && rhs_ptr)
return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) == 0;
@@ -151,8 +145,11 @@ bool SBLineEntry::operator==(const SBLineEntry &rhs) const {
}
bool SBLineEntry::operator!=(const SBLineEntry &rhs) const {
- lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
- lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &), rhs);
+
+ lldb_private::LineEntry *lhs_ptr = m_opaque_up.get();
+ lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_up.get();
if (lhs_ptr && rhs_ptr)
return lldb_private::LineEntry::Compare(*lhs_ptr, *rhs_ptr) != 0;
@@ -161,23 +158,26 @@ bool SBLineEntry::operator!=(const SBLineEntry &rhs) const {
}
const lldb_private::LineEntry *SBLineEntry::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
lldb_private::LineEntry &SBLineEntry::ref() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new lldb_private::LineEntry());
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new lldb_private::LineEntry());
+ return *m_opaque_up;
}
-const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_ap; }
+const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_up; }
bool SBLineEntry::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
- if (m_opaque_ap) {
+ if (m_opaque_up) {
char file_path[PATH_MAX * 2];
- m_opaque_ap->file.GetPath(file_path, sizeof(file_path));
+ m_opaque_up->file.GetPath(file_path, sizeof(file_path));
strm.Printf("%s:%u", file_path, GetLine());
if (GetColumn() > 0)
strm.Printf(":%u", GetColumn());
@@ -187,4 +187,34 @@ bool SBLineEntry::GetDescription(SBStream &description) {
return true;
}
-lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_ap.get(); }
+lldb_private::LineEntry *SBLineEntry::get() { return m_opaque_up.get(); }
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBLineEntry>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBLineEntry, (const lldb::SBLineEntry &));
+ LLDB_REGISTER_METHOD(const lldb::SBLineEntry &,
+ SBLineEntry, operator=,(const lldb::SBLineEntry &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetStartAddress,
+ ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBLineEntry, GetEndAddress, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBLineEntry, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBLineEntry, GetFileSpec, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetLine, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBLineEntry, GetColumn, ());
+ LLDB_REGISTER_METHOD(void, SBLineEntry, SetFileSpec, (lldb::SBFileSpec));
+ LLDB_REGISTER_METHOD(void, SBLineEntry, SetLine, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBLineEntry, SetColumn, (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBLineEntry, operator==,(const lldb::SBLineEntry &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBLineEntry, operator!=,(const lldb::SBLineEntry &));
+ LLDB_REGISTER_METHOD(bool, SBLineEntry, GetDescription, (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBListener.cpp b/source/API/SBListener.cpp
index e671d9f2ce8cc..4fe90f6f68620 100644
--- a/source/API/SBListener.cpp
+++ b/source/API/SBListener.cpp
@@ -1,13 +1,13 @@
//===-- SBListener.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBListener.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBBroadcaster.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBEvent.h"
@@ -15,32 +15,34 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Utility/Broadcaster.h"
#include "lldb/Utility/Listener.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
-SBListener::SBListener() : m_opaque_sp(), m_unused_ptr(NULL) {}
+SBListener::SBListener() : m_opaque_sp(), m_unused_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBListener);
+}
SBListener::SBListener(const char *name)
: m_opaque_sp(Listener::MakeListener(name)), m_unused_ptr(nullptr) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBListener::SBListener (name=\"%s\") => SBListener(%p)", name,
- static_cast<void *>(m_opaque_sp.get()));
+ LLDB_RECORD_CONSTRUCTOR(SBListener, (const char *), name);
}
SBListener::SBListener(const SBListener &rhs)
- : m_opaque_sp(rhs.m_opaque_sp), m_unused_ptr(nullptr) {}
+ : m_opaque_sp(rhs.m_opaque_sp), m_unused_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBListener, (const lldb::SBListener &), rhs);
+}
const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBListener &,
+ SBListener, operator=,(const lldb::SBListener &), rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
m_unused_ptr = nullptr;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBListener::SBListener(const lldb::ListenerSP &listener_sp)
@@ -48,15 +50,28 @@ SBListener::SBListener(const lldb::ListenerSP &listener_sp)
SBListener::~SBListener() {}
-bool SBListener::IsValid() const { return m_opaque_sp != nullptr; }
+bool SBListener::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, IsValid);
+ return this->operator bool();
+}
+SBListener::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, operator bool);
+
+ return m_opaque_sp != nullptr;
+}
void SBListener::AddEvent(const SBEvent &event) {
+ LLDB_RECORD_METHOD(void, SBListener, AddEvent, (const lldb::SBEvent &),
+ event);
+
EventSP &event_sp = event.GetSP();
if (event_sp)
m_opaque_sp->AddEvent(event_sp);
}
void SBListener::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBListener, Clear);
+
if (m_opaque_sp)
m_opaque_sp->Clear();
}
@@ -64,6 +79,10 @@ void SBListener::Clear() {
uint32_t SBListener::StartListeningForEventClass(SBDebugger &debugger,
const char *broadcaster_class,
uint32_t event_mask) {
+ LLDB_RECORD_METHOD(uint32_t, SBListener, StartListeningForEventClass,
+ (lldb::SBDebugger &, const char *, uint32_t), debugger,
+ broadcaster_class, event_mask);
+
if (m_opaque_sp) {
Debugger *lldb_debugger = debugger.get();
if (!lldb_debugger)
@@ -78,6 +97,10 @@ uint32_t SBListener::StartListeningForEventClass(SBDebugger &debugger,
bool SBListener::StopListeningForEventClass(SBDebugger &debugger,
const char *broadcaster_class,
uint32_t event_mask) {
+ LLDB_RECORD_METHOD(bool, SBListener, StopListeningForEventClass,
+ (lldb::SBDebugger &, const char *, uint32_t), debugger,
+ broadcaster_class, event_mask);
+
if (m_opaque_sp) {
Debugger *lldb_debugger = debugger.get();
if (!lldb_debugger)
@@ -91,47 +114,25 @@ bool SBListener::StopListeningForEventClass(SBDebugger &debugger,
uint32_t SBListener::StartListeningForEvents(const SBBroadcaster &broadcaster,
uint32_t event_mask) {
+ LLDB_RECORD_METHOD(uint32_t, SBListener, StartListeningForEvents,
+ (const lldb::SBBroadcaster &, uint32_t), broadcaster,
+ event_mask);
+
uint32_t acquired_event_mask = 0;
if (m_opaque_sp && broadcaster.IsValid()) {
acquired_event_mask =
m_opaque_sp->StartListeningForEvents(broadcaster.get(), event_mask);
}
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
- if (log) {
- StreamString sstr_requested;
- StreamString sstr_acquired;
-
- Broadcaster *lldb_broadcaster = broadcaster.get();
- if (lldb_broadcaster) {
- const bool got_requested_names =
- lldb_broadcaster->GetEventNames(sstr_requested, event_mask, false);
- const bool got_acquired_names = lldb_broadcaster->GetEventNames(
- sstr_acquired, acquired_event_mask, false);
- log->Printf("SBListener(%p)::StartListeneingForEvents "
- "(SBBroadcaster(%p): %s, event_mask=0x%8.8x%s%s%s) => "
- "0x%8.8x%s%s%s",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(lldb_broadcaster),
- lldb_broadcaster->GetBroadcasterName().GetCString(),
- event_mask, got_requested_names ? " (" : "",
- sstr_requested.GetData(), got_requested_names ? ")" : "",
- acquired_event_mask, got_acquired_names ? " (" : "",
- sstr_acquired.GetData(), got_acquired_names ? ")" : "");
- } else {
- log->Printf("SBListener(%p)::StartListeneingForEvents "
- "(SBBroadcaster(%p), event_mask=0x%8.8x) => 0x%8.8x",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(lldb_broadcaster), event_mask,
- acquired_event_mask);
- }
- }
-
return acquired_event_mask;
}
bool SBListener::StopListeningForEvents(const SBBroadcaster &broadcaster,
uint32_t event_mask) {
+ LLDB_RECORD_METHOD(bool, SBListener, StopListeningForEvents,
+ (const lldb::SBBroadcaster &, uint32_t), broadcaster,
+ event_mask);
+
if (m_opaque_sp && broadcaster.IsValid()) {
return m_opaque_sp->StopListeningForEvents(broadcaster.get(), event_mask);
}
@@ -139,20 +140,9 @@ bool SBListener::StopListeningForEvents(const SBBroadcaster &broadcaster,
}
bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (timeout_secs == UINT32_MAX) {
- log->Printf("SBListener(%p)::WaitForEvent (timeout_secs=INFINITE, "
- "SBEvent(%p))...",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(event.get()));
- } else {
- log->Printf(
- "SBListener(%p)::WaitForEvent (timeout_secs=%d, SBEvent(%p))...",
- static_cast<void *>(m_opaque_sp.get()), timeout_secs,
- static_cast<void *>(event.get()));
- }
- }
+ LLDB_RECORD_METHOD(bool, SBListener, WaitForEvent,
+ (uint32_t, lldb::SBEvent &), timeout_secs, event);
+
bool success = false;
if (m_opaque_sp) {
@@ -169,27 +159,18 @@ bool SBListener::WaitForEvent(uint32_t timeout_secs, SBEvent &event) {
}
}
- if (log) {
- if (timeout_secs == UINT32_MAX) {
- log->Printf("SBListener(%p)::WaitForEvent (timeout_secs=INFINITE, "
- "SBEvent(%p)) => %i",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(event.get()), success);
- } else {
- log->Printf(
- "SBListener(%p)::WaitForEvent (timeout_secs=%d, SBEvent(%p)) => %i",
- static_cast<void *>(m_opaque_sp.get()), timeout_secs,
- static_cast<void *>(event.get()), success);
- }
- }
if (!success)
- event.reset(NULL);
+ event.reset(nullptr);
return success;
}
bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds,
const SBBroadcaster &broadcaster,
SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, WaitForEventForBroadcaster,
+ (uint32_t, const lldb::SBBroadcaster &, lldb::SBEvent &),
+ num_seconds, broadcaster, event);
+
if (m_opaque_sp && broadcaster.IsValid()) {
Timeout<std::micro> timeout(llvm::None);
if (num_seconds != UINT32_MAX)
@@ -201,13 +182,18 @@ bool SBListener::WaitForEventForBroadcaster(uint32_t num_seconds,
return true;
}
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::WaitForEventForBroadcasterWithType(
uint32_t num_seconds, const SBBroadcaster &broadcaster,
uint32_t event_type_mask, SBEvent &event) {
+ LLDB_RECORD_METHOD(
+ bool, SBListener, WaitForEventForBroadcasterWithType,
+ (uint32_t, const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &),
+ num_seconds, broadcaster, event_type_mask, event);
+
if (m_opaque_sp && broadcaster.IsValid()) {
Timeout<std::micro> timeout(llvm::None);
if (num_seconds != UINT32_MAX)
@@ -219,42 +205,55 @@ bool SBListener::WaitForEventForBroadcasterWithType(
return true;
}
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::PeekAtNextEvent(SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEvent, (lldb::SBEvent &),
+ event);
+
if (m_opaque_sp) {
event.reset(m_opaque_sp->PeekAtNextEvent());
return event.IsValid();
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::PeekAtNextEventForBroadcaster(const SBBroadcaster &broadcaster,
SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEventForBroadcaster,
+ (const lldb::SBBroadcaster &, lldb::SBEvent &),
+ broadcaster, event);
+
if (m_opaque_sp && broadcaster.IsValid()) {
event.reset(m_opaque_sp->PeekAtNextEventForBroadcaster(broadcaster.get()));
return event.IsValid();
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::PeekAtNextEventForBroadcasterWithType(
const SBBroadcaster &broadcaster, uint32_t event_type_mask,
SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, PeekAtNextEventForBroadcasterWithType,
+ (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &),
+ broadcaster, event_type_mask, event);
+
if (m_opaque_sp && broadcaster.IsValid()) {
event.reset(m_opaque_sp->PeekAtNextEventForBroadcasterWithType(
broadcaster.get(), event_type_mask));
return event.IsValid();
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::GetNextEvent(SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, GetNextEvent, (lldb::SBEvent &), event);
+
if (m_opaque_sp) {
EventSP event_sp;
if (m_opaque_sp->GetEvent(event_sp, std::chrono::seconds(0))) {
@@ -262,12 +261,16 @@ bool SBListener::GetNextEvent(SBEvent &event) {
return true;
}
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::GetNextEventForBroadcaster(const SBBroadcaster &broadcaster,
SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, GetNextEventForBroadcaster,
+ (const lldb::SBBroadcaster &, lldb::SBEvent &),
+ broadcaster, event);
+
if (m_opaque_sp && broadcaster.IsValid()) {
EventSP event_sp;
if (m_opaque_sp->GetEventForBroadcaster(broadcaster.get(), event_sp,
@@ -276,13 +279,17 @@ bool SBListener::GetNextEventForBroadcaster(const SBBroadcaster &broadcaster,
return true;
}
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::GetNextEventForBroadcasterWithType(
const SBBroadcaster &broadcaster, uint32_t event_type_mask,
SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, GetNextEventForBroadcasterWithType,
+ (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &),
+ broadcaster, event_type_mask, event);
+
if (m_opaque_sp && broadcaster.IsValid()) {
EventSP event_sp;
if (m_opaque_sp->GetEventForBroadcasterWithType(broadcaster.get(),
@@ -292,11 +299,14 @@ bool SBListener::GetNextEventForBroadcasterWithType(
return true;
}
}
- event.reset(NULL);
+ event.reset(nullptr);
return false;
}
bool SBListener::HandleBroadcastEvent(const SBEvent &event) {
+ LLDB_RECORD_METHOD(bool, SBListener, HandleBroadcastEvent,
+ (const lldb::SBEvent &), event);
+
if (m_opaque_sp)
return m_opaque_sp->HandleBroadcastEvent(event.GetSP());
return false;
@@ -312,3 +322,52 @@ void SBListener::reset(ListenerSP listener_sp) {
m_opaque_sp = listener_sp;
m_unused_ptr = nullptr;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBListener>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBListener, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBListener, (const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBListener, (const lldb::SBListener &));
+ LLDB_REGISTER_METHOD(const lldb::SBListener &,
+ SBListener, operator=,(const lldb::SBListener &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBListener, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBListener, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBListener, AddEvent, (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(void, SBListener, Clear, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBListener, StartListeningForEventClass,
+ (lldb::SBDebugger &, const char *, uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBListener, StopListeningForEventClass,
+ (lldb::SBDebugger &, const char *, uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBListener, StartListeningForEvents,
+ (const lldb::SBBroadcaster &, uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBListener, StopListeningForEvents,
+ (const lldb::SBBroadcaster &, uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBListener, WaitForEvent,
+ (uint32_t, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(
+ bool, SBListener, WaitForEventForBroadcaster,
+ (uint32_t, const lldb::SBBroadcaster &, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(
+ bool, SBListener, WaitForEventForBroadcasterWithType,
+ (uint32_t, const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(bool, SBListener, PeekAtNextEvent, (lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(bool, SBListener, PeekAtNextEventForBroadcaster,
+ (const lldb::SBBroadcaster &, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(
+ bool, SBListener, PeekAtNextEventForBroadcasterWithType,
+ (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(bool, SBListener, GetNextEvent, (lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(bool, SBListener, GetNextEventForBroadcaster,
+ (const lldb::SBBroadcaster &, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(
+ bool, SBListener, GetNextEventForBroadcasterWithType,
+ (const lldb::SBBroadcaster &, uint32_t, lldb::SBEvent &));
+ LLDB_REGISTER_METHOD(bool, SBListener, HandleBroadcastEvent,
+ (const lldb::SBEvent &));
+}
+
+}
+}
diff --git a/source/API/SBMemoryRegionInfo.cpp b/source/API/SBMemoryRegionInfo.cpp
index c4dbaec707bb9..d25570f51ce54 100644
--- a/source/API/SBMemoryRegionInfo.cpp
+++ b/source/API/SBMemoryRegionInfo.cpp
@@ -1,13 +1,14 @@
//===-- SBMemoryRegionInfo.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBMemoryRegionInfo.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStream.h"
@@ -17,82 +18,149 @@
using namespace lldb;
using namespace lldb_private;
-SBMemoryRegionInfo::SBMemoryRegionInfo()
- : m_opaque_ap(new MemoryRegionInfo()) {}
+SBMemoryRegionInfo::SBMemoryRegionInfo() : m_opaque_up(new MemoryRegionInfo()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfo);
+}
SBMemoryRegionInfo::SBMemoryRegionInfo(const MemoryRegionInfo *lldb_object_ptr)
- : m_opaque_ap(new MemoryRegionInfo()) {
+ : m_opaque_up(new MemoryRegionInfo()) {
if (lldb_object_ptr)
ref() = *lldb_object_ptr;
}
SBMemoryRegionInfo::SBMemoryRegionInfo(const SBMemoryRegionInfo &rhs)
- : m_opaque_ap(new MemoryRegionInfo()) {
- ref() = rhs.ref();
+ : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfo,
+ (const lldb::SBMemoryRegionInfo &), rhs);
+ m_opaque_up = clone(rhs.m_opaque_up);
}
const SBMemoryRegionInfo &SBMemoryRegionInfo::
operator=(const SBMemoryRegionInfo &rhs) {
- if (this != &rhs) {
- ref() = rhs.ref();
- }
- return *this;
+ LLDB_RECORD_METHOD(
+ const lldb::SBMemoryRegionInfo &,
+ SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &), rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
SBMemoryRegionInfo::~SBMemoryRegionInfo() {}
-void SBMemoryRegionInfo::Clear() { m_opaque_ap->Clear(); }
+void SBMemoryRegionInfo::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfo, Clear);
+
+ m_opaque_up->Clear();
+}
bool SBMemoryRegionInfo::operator==(const SBMemoryRegionInfo &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &),
+ rhs);
+
return ref() == rhs.ref();
}
bool SBMemoryRegionInfo::operator!=(const SBMemoryRegionInfo &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &),
+ rhs);
+
return ref() != rhs.ref();
}
-MemoryRegionInfo &SBMemoryRegionInfo::ref() { return *m_opaque_ap; }
+MemoryRegionInfo &SBMemoryRegionInfo::ref() { return *m_opaque_up; }
-const MemoryRegionInfo &SBMemoryRegionInfo::ref() const { return *m_opaque_ap; }
+const MemoryRegionInfo &SBMemoryRegionInfo::ref() const { return *m_opaque_up; }
lldb::addr_t SBMemoryRegionInfo::GetRegionBase() {
- return m_opaque_ap->GetRange().GetRangeBase();
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBMemoryRegionInfo, GetRegionBase);
+
+ return m_opaque_up->GetRange().GetRangeBase();
}
lldb::addr_t SBMemoryRegionInfo::GetRegionEnd() {
- return m_opaque_ap->GetRange().GetRangeEnd();
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBMemoryRegionInfo, GetRegionEnd);
+
+ return m_opaque_up->GetRange().GetRangeEnd();
}
bool SBMemoryRegionInfo::IsReadable() {
- return m_opaque_ap->GetReadable() == MemoryRegionInfo::eYes;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsReadable);
+
+ return m_opaque_up->GetReadable() == MemoryRegionInfo::eYes;
}
bool SBMemoryRegionInfo::IsWritable() {
- return m_opaque_ap->GetWritable() == MemoryRegionInfo::eYes;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsWritable);
+
+ return m_opaque_up->GetWritable() == MemoryRegionInfo::eYes;
}
bool SBMemoryRegionInfo::IsExecutable() {
- return m_opaque_ap->GetExecutable() == MemoryRegionInfo::eYes;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsExecutable);
+
+ return m_opaque_up->GetExecutable() == MemoryRegionInfo::eYes;
}
bool SBMemoryRegionInfo::IsMapped() {
- return m_opaque_ap->GetMapped() == MemoryRegionInfo::eYes;
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, IsMapped);
+
+ return m_opaque_up->GetMapped() == MemoryRegionInfo::eYes;
}
const char *SBMemoryRegionInfo::GetName() {
- return m_opaque_ap->GetName().AsCString();
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBMemoryRegionInfo, GetName);
+
+ return m_opaque_up->GetName().AsCString();
}
bool SBMemoryRegionInfo::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBMemoryRegionInfo, GetDescription,
+ (lldb::SBStream &), description);
+
Stream &strm = description.ref();
- const addr_t load_addr = m_opaque_ap->GetRange().base;
+ const addr_t load_addr = m_opaque_up->GetRange().base;
strm.Printf("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 " ", load_addr,
- load_addr + m_opaque_ap->GetRange().size);
- strm.Printf(m_opaque_ap->GetReadable() ? "R" : "-");
- strm.Printf(m_opaque_ap->GetWritable() ? "W" : "-");
- strm.Printf(m_opaque_ap->GetExecutable() ? "X" : "-");
+ load_addr + m_opaque_up->GetRange().size);
+ strm.Printf(m_opaque_up->GetReadable() ? "R" : "-");
+ strm.Printf(m_opaque_up->GetWritable() ? "W" : "-");
+ strm.Printf(m_opaque_up->GetExecutable() ? "X" : "-");
strm.Printf("]");
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBMemoryRegionInfo>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfo, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfo,
+ (const lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBMemoryRegionInfo &,
+ SBMemoryRegionInfo, operator=,(const lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD(void, SBMemoryRegionInfo, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(
+ bool,
+ SBMemoryRegionInfo, operator==,(const lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool,
+ SBMemoryRegionInfo, operator!=,(const lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetRegionBase, ());
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBMemoryRegionInfo, GetRegionEnd, ());
+ LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsReadable, ());
+ LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsWritable, ());
+ LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsExecutable, ());
+ LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, IsMapped, ());
+ LLDB_REGISTER_METHOD(const char *, SBMemoryRegionInfo, GetName, ());
+ LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfo, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBMemoryRegionInfoList.cpp b/source/API/SBMemoryRegionInfoList.cpp
index 1cefc9dcc0448..32a3afb84af0e 100644
--- a/source/API/SBMemoryRegionInfoList.cpp
+++ b/source/API/SBMemoryRegionInfoList.cpp
@@ -1,17 +1,16 @@
//===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBMemoryRegionInfoList.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBMemoryRegionInfo.h"
#include "lldb/API/SBStream.h"
#include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Utility/Log.h"
#include <vector>
@@ -65,69 +64,103 @@ private:
MemoryRegionInfos m_regions;
};
-MemoryRegionInfos &SBMemoryRegionInfoList::ref() {
- return m_opaque_ap->Ref();
-}
+MemoryRegionInfos &SBMemoryRegionInfoList::ref() { return m_opaque_up->Ref(); }
const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const {
- return m_opaque_ap->Ref();
+ return m_opaque_up->Ref();
}
SBMemoryRegionInfoList::SBMemoryRegionInfoList()
- : m_opaque_ap(new MemoryRegionInfoListImpl()) {}
+ : m_opaque_up(new MemoryRegionInfoListImpl()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBMemoryRegionInfoList);
+}
SBMemoryRegionInfoList::SBMemoryRegionInfoList(
const SBMemoryRegionInfoList &rhs)
- : m_opaque_ap(new MemoryRegionInfoListImpl(*rhs.m_opaque_ap)) {}
+ : m_opaque_up(new MemoryRegionInfoListImpl(*rhs.m_opaque_up)) {
+ LLDB_RECORD_CONSTRUCTOR(SBMemoryRegionInfoList,
+ (const lldb::SBMemoryRegionInfoList &), rhs);
+}
SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {}
const SBMemoryRegionInfoList &SBMemoryRegionInfoList::
operator=(const SBMemoryRegionInfoList &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBMemoryRegionInfoList &,
+ SBMemoryRegionInfoList, operator=,(const lldb::SBMemoryRegionInfoList &),
+ rhs);
+
if (this != &rhs) {
- *m_opaque_ap = *rhs.m_opaque_ap;
+ *m_opaque_up = *rhs.m_opaque_up;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
uint32_t SBMemoryRegionInfoList::GetSize() const {
- return m_opaque_ap->GetSize();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBMemoryRegionInfoList, GetSize);
+
+ return m_opaque_up->GetSize();
}
bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex(
uint32_t idx, SBMemoryRegionInfo &region_info) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
-
- if (log) {
- SBStream sstr;
- region_info.GetDescription(sstr);
- log->Printf("SBMemoryRegionInfoList::GetMemoryRegionAtIndex (this.ap=%p, "
- "idx=%d) => SBMemoryRegionInfo (this.ap=%p, '%s')",
- static_cast<void *>(m_opaque_ap.get()), idx,
- static_cast<void *>(region_info.m_opaque_ap.get()),
- sstr.GetData());
- }
+ LLDB_RECORD_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
+ (uint32_t, lldb::SBMemoryRegionInfo &), idx, region_info);
- return result;
+ return m_opaque_up->GetMemoryRegionInfoAtIndex(idx, region_info.ref());
}
-void SBMemoryRegionInfoList::Clear() { m_opaque_ap->Clear(); }
+void SBMemoryRegionInfoList::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfoList, Clear);
+
+ m_opaque_up->Clear();
+}
void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) {
- m_opaque_ap->Append(sb_region.ref());
+ LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append,
+ (lldb::SBMemoryRegionInfo &), sb_region);
+
+ m_opaque_up->Append(sb_region.ref());
}
void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) {
- m_opaque_ap->Append(*sb_region_list);
+ LLDB_RECORD_METHOD(void, SBMemoryRegionInfoList, Append,
+ (lldb::SBMemoryRegionInfoList &), sb_region_list);
+
+ m_opaque_up->Append(*sb_region_list);
}
const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const {
- assert(m_opaque_ap.get());
- return *m_opaque_ap;
+ assert(m_opaque_up.get());
+ return *m_opaque_up;
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBMemoryRegionInfoList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBMemoryRegionInfoList,
+ (const lldb::SBMemoryRegionInfoList &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBMemoryRegionInfoList &,
+ SBMemoryRegionInfoList, operator=,(
+ const lldb::SBMemoryRegionInfoList &));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBMemoryRegionInfoList, GetSize, ());
+ LLDB_REGISTER_METHOD(bool, SBMemoryRegionInfoList, GetMemoryRegionAtIndex,
+ (uint32_t, lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Clear, ());
+ LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append,
+ (lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD(void, SBMemoryRegionInfoList, Append,
+ (lldb::SBMemoryRegionInfoList &));
+}
+
+}
}
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 31980793bce0a..4bd32bce1c532 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -1,13 +1,13 @@
//===-- SBModule.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBModule.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBModuleSpec.h"
@@ -25,28 +25,36 @@
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
-SBModule::SBModule() : m_opaque_sp() {}
+SBModule::SBModule() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModule);
+}
SBModule::SBModule(const lldb::ModuleSP &module_sp) : m_opaque_sp(module_sp) {}
SBModule::SBModule(const SBModuleSpec &module_spec) : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &), module_spec);
+
ModuleSP module_sp;
- Status error = ModuleList::GetSharedModule(*module_spec.m_opaque_ap,
- module_sp, NULL, NULL, NULL);
+ Status error = ModuleList::GetSharedModule(
+ *module_spec.m_opaque_up, module_sp, nullptr, nullptr, nullptr);
if (module_sp)
SetSP(module_sp);
}
-SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
+SBModule::SBModule(const SBModule &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBModule, (const lldb::SBModule &), rhs);
+}
SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr)
: m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t), process,
+ header_addr);
+
ProcessSP process_sp(process.GetSP());
if (process_sp) {
m_opaque_sp = process_sp->ReadModuleFromMemory(FileSpec(), header_addr);
@@ -60,52 +68,61 @@ SBModule::SBModule(lldb::SBProcess &process, lldb::addr_t header_addr)
}
const SBModule &SBModule::operator=(const SBModule &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBModule &,
+ SBModule, operator=,(const lldb::SBModule &), rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBModule::~SBModule() {}
-bool SBModule::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBModule::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, IsValid);
+ return this->operator bool();
+}
+SBModule::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, operator bool);
-void SBModule::Clear() { m_opaque_sp.reset(); }
+ return m_opaque_sp.get() != nullptr;
+}
+
+void SBModule::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBModule, Clear);
+
+ m_opaque_sp.reset();
+}
SBFileSpec SBModule::GetFileSpec() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule, GetFileSpec);
SBFileSpec file_spec;
ModuleSP module_sp(GetSP());
if (module_sp)
file_spec.SetFileSpec(module_sp->GetFileSpec());
- if (log)
- log->Printf("SBModule(%p)::GetFileSpec () => SBFileSpec(%p)",
- static_cast<void *>(module_sp.get()),
- static_cast<const void *>(file_spec.get()));
-
- return file_spec;
+ return LLDB_RECORD_RESULT(file_spec);
}
lldb::SBFileSpec SBModule::GetPlatformFileSpec() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule,
+ GetPlatformFileSpec);
+
SBFileSpec file_spec;
ModuleSP module_sp(GetSP());
if (module_sp)
file_spec.SetFileSpec(module_sp->GetPlatformFileSpec());
- if (log)
- log->Printf("SBModule(%p)::GetPlatformFileSpec () => SBFileSpec(%p)",
- static_cast<void *>(module_sp.get()),
- static_cast<const void *>(file_spec.get()));
-
- return file_spec;
+ return LLDB_RECORD_RESULT(file_spec);
}
bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) {
+ LLDB_RECORD_METHOD(bool, SBModule, SetPlatformFileSpec,
+ (const lldb::SBFileSpec &), platform_file);
+
bool result = false;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
ModuleSP module_sp(GetSP());
if (module_sp) {
@@ -113,23 +130,24 @@ bool SBModule::SetPlatformFileSpec(const lldb::SBFileSpec &platform_file) {
result = true;
}
- if (log)
- log->Printf("SBModule(%p)::SetPlatformFileSpec (SBFileSpec(%p (%s)) => %i",
- static_cast<void *>(module_sp.get()),
- static_cast<const void *>(platform_file.get()),
- platform_file->GetPath().c_str(), result);
return result;
}
lldb::SBFileSpec SBModule::GetRemoteInstallFileSpec() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModule,
+ GetRemoteInstallFileSpec);
+
SBFileSpec sb_file_spec;
ModuleSP module_sp(GetSP());
if (module_sp)
sb_file_spec.SetFileSpec(module_sp->GetRemoteInstallFileSpec());
- return sb_file_spec;
+ return LLDB_RECORD_RESULT(sb_file_spec);
}
bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) {
+ LLDB_RECORD_METHOD(bool, SBModule, SetRemoteInstallFileSpec,
+ (lldb::SBFileSpec &), file);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
module_sp->SetRemoteInstallFileSpec(file.ref());
@@ -139,30 +157,20 @@ bool SBModule::SetRemoteInstallFileSpec(lldb::SBFileSpec &file) {
}
const uint8_t *SBModule::GetUUIDBytes() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const uint8_t *, SBModule, GetUUIDBytes);
- const uint8_t *uuid_bytes = NULL;
+ const uint8_t *uuid_bytes = nullptr;
ModuleSP module_sp(GetSP());
if (module_sp)
uuid_bytes = module_sp->GetUUID().GetBytes().data();
- if (log) {
- if (uuid_bytes) {
- StreamString s;
- module_sp->GetUUID().Dump(&s);
- log->Printf("SBModule(%p)::GetUUIDBytes () => %s",
- static_cast<void *>(module_sp.get()), s.GetData());
- } else
- log->Printf("SBModule(%p)::GetUUIDBytes () => NULL",
- static_cast<void *>(module_sp.get()));
- }
return uuid_bytes;
}
const char *SBModule::GetUUIDString() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBModule, GetUUIDString);
- const char *uuid_cstr = NULL;
+ const char *uuid_cstr = nullptr;
ModuleSP module_sp(GetSP());
if (module_sp) {
// We are going to return a "const char *" value through the public API, so
@@ -173,25 +181,25 @@ const char *SBModule::GetUUIDString() const {
}
if (uuid_cstr && uuid_cstr[0]) {
- if (log)
- log->Printf("SBModule(%p)::GetUUIDString () => %s",
- static_cast<void *>(module_sp.get()), uuid_cstr);
return uuid_cstr;
}
- if (log)
- log->Printf("SBModule(%p)::GetUUIDString () => NULL",
- static_cast<void *>(module_sp.get()));
- return NULL;
+ return nullptr;
}
bool SBModule::operator==(const SBModule &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBModule, operator==,(const lldb::SBModule &),
+ rhs);
+
if (m_opaque_sp)
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
return false;
}
bool SBModule::operator!=(const SBModule &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBModule, operator!=,(const lldb::SBModule &),
+ rhs);
+
if (m_opaque_sp)
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
return false;
@@ -202,6 +210,9 @@ ModuleSP SBModule::GetSP() const { return m_opaque_sp; }
void SBModule::SetSP(const ModuleSP &module_sp) { m_opaque_sp = module_sp; }
SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) {
+ LLDB_RECORD_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress,
+ (lldb::addr_t), vm_addr);
+
lldb::SBAddress sb_addr;
ModuleSP module_sp(GetSP());
if (module_sp) {
@@ -209,21 +220,28 @@ SBAddress SBModule::ResolveFileAddress(lldb::addr_t vm_addr) {
if (module_sp->ResolveFileAddress(vm_addr, addr))
sb_addr.ref() = addr;
}
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
SBSymbolContext
SBModule::ResolveSymbolContextForAddress(const SBAddress &addr,
uint32_t resolve_scope) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBModule,
+ ResolveSymbolContextForAddress,
+ (const lldb::SBAddress &, uint32_t), addr, resolve_scope);
+
SBSymbolContext sb_sc;
ModuleSP module_sp(GetSP());
SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
if (module_sp && addr.IsValid())
module_sp->ResolveSymbolContextForAddress(addr.ref(), scope, *sb_sc);
- return sb_sc;
+ return LLDB_RECORD_RESULT(sb_sc);
}
bool SBModule::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
ModuleSP module_sp(GetSP());
@@ -236,6 +254,8 @@ bool SBModule::GetDescription(SBStream &description) {
}
uint32_t SBModule::GetNumCompileUnits() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetNumCompileUnits);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
return module_sp->GetNumCompileUnits();
@@ -244,24 +264,29 @@ uint32_t SBModule::GetNumCompileUnits() {
}
SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex,
+ (uint32_t), index);
+
SBCompileUnit sb_cu;
ModuleSP module_sp(GetSP());
if (module_sp) {
CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(index);
sb_cu.reset(cu_sp.get());
}
- return sb_cu;
+ return LLDB_RECORD_RESULT(sb_cu);
}
-SBSymbolContextList
-SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) {
+SBSymbolContextList SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits,
+ (const lldb::SBFileSpec &), sb_file_spec);
+
SBSymbolContextList sb_sc_list;
const ModuleSP module_sp(GetSP());
if (sb_file_spec.IsValid() && module_sp) {
const bool append = true;
module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list);
}
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) {
@@ -270,10 +295,12 @@ static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) {
if (symbols)
return symbols->GetSymtab();
}
- return NULL;
+ return nullptr;
}
size_t SBModule::GetNumSymbols() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSymbols);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
@@ -284,16 +311,21 @@ size_t SBModule::GetNumSymbols() {
}
SBSymbol SBModule::GetSymbolAtIndex(size_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t), idx);
+
SBSymbol sb_symbol;
ModuleSP module_sp(GetSP());
Symtab *symtab = GetUnifiedSymbolTable(module_sp);
if (symtab)
sb_symbol.SetSymbol(symtab->SymbolAtIndex(idx));
- return sb_symbol;
+ return LLDB_RECORD_RESULT(sb_symbol);
}
lldb::SBSymbol SBModule::FindSymbol(const char *name,
lldb::SymbolType symbol_type) {
+ LLDB_RECORD_METHOD(lldb::SBSymbol, SBModule, FindSymbol,
+ (const char *, lldb::SymbolType), name, symbol_type);
+
SBSymbol sb_symbol;
if (name && name[0]) {
ModuleSP module_sp(GetSP());
@@ -303,11 +335,14 @@ lldb::SBSymbol SBModule::FindSymbol(const char *name,
ConstString(name), symbol_type, Symtab::eDebugAny,
Symtab::eVisibilityAny));
}
- return sb_symbol;
+ return LLDB_RECORD_RESULT(sb_symbol);
}
lldb::SBSymbolContextList SBModule::FindSymbols(const char *name,
lldb::SymbolType symbol_type) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols,
+ (const char *, lldb::SymbolType), name, symbol_type);
+
SBSymbolContextList sb_sc_list;
if (name && name[0]) {
ModuleSP module_sp(GetSP());
@@ -328,10 +363,12 @@ lldb::SBSymbolContextList SBModule::FindSymbols(const char *name,
}
}
}
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
size_t SBModule::GetNumSections() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModule, GetNumSections);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
// Give the symbol vendor a chance to add to the unified section list.
@@ -344,6 +381,9 @@ size_t SBModule::GetNumSections() {
}
SBSection SBModule::GetSectionAtIndex(size_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex, (size_t),
+ idx);
+
SBSection sb_section;
ModuleSP module_sp(GetSP());
if (module_sp) {
@@ -354,11 +394,14 @@ SBSection SBModule::GetSectionAtIndex(size_t idx) {
if (section_list)
sb_section.SetSP(section_list->GetSectionAtIndex(idx));
}
- return sb_section;
+ return LLDB_RECORD_RESULT(sb_section);
}
lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
uint32_t name_type_mask) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions,
+ (const char *, uint32_t), name, name_type_mask);
+
lldb::SBSymbolContextList sb_sc_list;
ModuleSP module_sp(GetSP());
if (name && module_sp) {
@@ -366,20 +409,24 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name,
const bool symbols_ok = true;
const bool inlines_ok = true;
FunctionNameType type = static_cast<FunctionNameType>(name_type_mask);
- module_sp->FindFunctions(ConstString(name), NULL, type, symbols_ok,
+ module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok,
inlines_ok, append, *sb_sc_list);
}
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
uint32_t max_matches) {
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables,
+ (lldb::SBTarget &, const char *, uint32_t), target, name,
+ max_matches);
+
SBValueList sb_value_list;
ModuleSP module_sp(GetSP());
if (name && module_sp) {
VariableList variable_list;
const uint32_t match_count = module_sp->FindGlobalVariables(
- ConstString(name), NULL, max_matches, variable_list);
+ ConstString(name), nullptr, max_matches, variable_list);
if (match_count > 0) {
for (uint32_t i = 0; i < match_count; ++i) {
@@ -393,18 +440,24 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
}
}
- return sb_value_list;
+ return LLDB_RECORD_RESULT(sb_value_list);
}
lldb::SBValue SBModule::FindFirstGlobalVariable(lldb::SBTarget &target,
const char *name) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable,
+ (lldb::SBTarget &, const char *), target, name);
+
SBValueList sb_value_list(FindGlobalVariables(target, name, 1));
if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
- return sb_value_list.GetValueAtIndex(0);
- return SBValue();
+ return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0));
+ return LLDB_RECORD_RESULT(SBValue());
}
lldb::SBType SBModule::FindFirstType(const char *name_cstr) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *),
+ name_cstr);
+
SBType sb_type;
ModuleSP module_sp(GetSP());
if (name_cstr && module_sp) {
@@ -421,21 +474,27 @@ lldb::SBType SBModule::FindFirstType(const char *name_cstr) {
sb_type = SBType(type_system->GetBuiltinTypeByName(name));
}
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
lldb::SBType SBModule::GetBasicType(lldb::BasicType type) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetBasicType, (lldb::BasicType),
+ type);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
TypeSystem *type_system =
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
if (type_system)
- return SBType(type_system->GetBasicTypeFromAST(type));
+ return LLDB_RECORD_RESULT(SBType(type_system->GetBasicTypeFromAST(type)));
}
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
}
lldb::SBTypeList SBModule::FindTypes(const char *type) {
+ LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *),
+ type);
+
SBTypeList retval;
ModuleSP module_sp(GetSP());
@@ -464,40 +523,49 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) {
}
}
- return retval;
+ return LLDB_RECORD_RESULT(retval);
}
lldb::SBType SBModule::GetTypeByID(lldb::user_id_t uid) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBModule, GetTypeByID, (lldb::user_id_t),
+ uid);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (vendor) {
Type *type_ptr = vendor->ResolveTypeUID(uid);
if (type_ptr)
- return SBType(type_ptr->shared_from_this());
+ return LLDB_RECORD_RESULT(SBType(type_ptr->shared_from_this()));
}
}
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
}
lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) {
+ LLDB_RECORD_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t),
+ type_mask);
+
SBTypeList sb_type_list;
ModuleSP module_sp(GetSP());
if (!module_sp)
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
SymbolVendor *vendor = module_sp->GetSymbolVendor();
if (!vendor)
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
TypeClass type_class = static_cast<TypeClass>(type_mask);
TypeList type_list;
- vendor->GetTypes(NULL, type_class, type_list);
- sb_type_list.m_opaque_ap->Append(type_list);
- return sb_type_list;
+ vendor->GetTypes(nullptr, type_class, type_list);
+ sb_type_list.m_opaque_up->Append(type_list);
+ return LLDB_RECORD_RESULT(sb_type_list);
}
SBSection SBModule::FindSection(const char *sect_name) {
+ LLDB_RECORD_METHOD(lldb::SBSection, SBModule, FindSection, (const char *),
+ sect_name);
+
SBSection sb_section;
ModuleSP module_sp(GetSP());
@@ -513,10 +581,12 @@ SBSection SBModule::FindSection(const char *sect_name) {
}
}
}
- return sb_section;
+ return LLDB_RECORD_RESULT(sb_section);
}
lldb::ByteOrder SBModule::GetByteOrder() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBModule, GetByteOrder);
+
ModuleSP module_sp(GetSP());
if (module_sp)
return module_sp->GetArchitecture().GetByteOrder();
@@ -524,6 +594,8 @@ lldb::ByteOrder SBModule::GetByteOrder() {
}
const char *SBModule::GetTriple() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModule, GetTriple);
+
ModuleSP module_sp(GetSP());
if (module_sp) {
std::string triple(module_sp->GetArchitecture().GetTriple().str());
@@ -533,10 +605,12 @@ const char *SBModule::GetTriple() {
ConstString const_triple(triple.c_str());
return const_triple.GetCString();
}
- return NULL;
+ return nullptr;
}
uint32_t SBModule::GetAddressByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBModule, GetAddressByteSize);
+
ModuleSP module_sp(GetSP());
if (module_sp)
return module_sp->GetArchitecture().GetAddressByteSize();
@@ -544,6 +618,9 @@ uint32_t SBModule::GetAddressByteSize() {
}
uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
+ LLDB_RECORD_METHOD(uint32_t, SBModule, GetVersion, (uint32_t *, uint32_t),
+ versions, num_versions);
+
llvm::VersionTuple version;
if (ModuleSP module_sp = GetSP())
version = module_sp->GetVersion();
@@ -570,6 +647,9 @@ uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
}
lldb::SBFileSpec SBModule::GetSymbolFileSpec() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBFileSpec, SBModule,
+ GetSymbolFileSpec);
+
lldb::SBFileSpec sb_file_spec;
ModuleSP module_sp(GetSP());
if (module_sp) {
@@ -577,10 +657,13 @@ lldb::SBFileSpec SBModule::GetSymbolFileSpec() const {
if (symbol_vendor_ptr)
sb_file_spec.SetFileSpec(symbol_vendor_ptr->GetMainFileSpec());
}
- return sb_file_spec;
+ return LLDB_RECORD_RESULT(sb_file_spec);
}
lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule,
+ GetObjectFileHeaderAddress);
+
lldb::SBAddress sb_addr;
ModuleSP module_sp(GetSP());
if (module_sp) {
@@ -588,10 +671,13 @@ lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const {
if (objfile_ptr)
sb_addr.ref() = objfile_ptr->GetBaseAddress();
}
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBModule,
+ GetObjectFileEntryPointAddress);
+
lldb::SBAddress sb_addr;
ModuleSP module_sp(GetSP());
if (module_sp) {
@@ -599,5 +685,84 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const {
if (objfile_ptr)
sb_addr.ref() = objfile_ptr->GetEntryPointAddress();
}
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBModule>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBModule, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModuleSpec &));
+ LLDB_REGISTER_CONSTRUCTOR(SBModule, (const lldb::SBModule &));
+ LLDB_REGISTER_CONSTRUCTOR(SBModule, (lldb::SBProcess &, lldb::addr_t));
+ LLDB_REGISTER_METHOD(const lldb::SBModule &,
+ SBModule, operator=,(const lldb::SBModule &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBModule, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBModule, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBModule, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetFileSpec, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetPlatformFileSpec,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBModule, SetPlatformFileSpec,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModule, GetRemoteInstallFileSpec,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBModule, SetRemoteInstallFileSpec,
+ (lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBModule, GetUUIDString, ());
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBModule, operator==,(const lldb::SBModule &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBModule, operator!=,(const lldb::SBModule &));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBModule, ResolveFileAddress,
+ (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBModule,
+ ResolveSymbolContextForAddress,
+ (const lldb::SBAddress &, uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBModule, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(uint32_t, SBModule, GetNumCompileUnits, ());
+ LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBModule, GetCompileUnitAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindCompileUnits,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSymbols, ());
+ LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, GetSymbolAtIndex, (size_t));
+ LLDB_REGISTER_METHOD(lldb::SBSymbol, SBModule, FindSymbol,
+ (const char *, lldb::SymbolType));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindSymbols,
+ (const char *, lldb::SymbolType));
+ LLDB_REGISTER_METHOD(size_t, SBModule, GetNumSections, ());
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, GetSectionAtIndex,
+ (size_t));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBModule, FindFunctions,
+ (const char *, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBModule, FindGlobalVariables,
+ (lldb::SBTarget &, const char *, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBModule, FindFirstGlobalVariable,
+ (lldb::SBTarget &, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBModule, FindFirstType, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetBasicType,
+ (lldb::BasicType));
+ LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, FindTypes, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBModule, GetTypeByID,
+ (lldb::user_id_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeList, SBModule, GetTypes, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBModule, FindSection,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::ByteOrder, SBModule, GetByteOrder, ());
+ LLDB_REGISTER_METHOD(const char *, SBModule, GetTriple, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBModule, GetAddressByteSize, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBModule, GetVersion,
+ (uint32_t *, uint32_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBFileSpec, SBModule, GetSymbolFileSpec,
+ ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
+ GetObjectFileHeaderAddress, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule,
+ GetObjectFileEntryPointAddress, ());
+}
+
+}
}
diff --git a/source/API/SBModuleSpec.cpp b/source/API/SBModuleSpec.cpp
index 65492f58b0158..a5e9ad26fac12 100644
--- a/source/API/SBModuleSpec.cpp
+++ b/source/API/SBModuleSpec.cpp
@@ -1,13 +1,14 @@
//===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBModuleSpec.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -18,58 +19,100 @@
using namespace lldb;
using namespace lldb_private;
-SBModuleSpec::SBModuleSpec() : m_opaque_ap(new lldb_private::ModuleSpec()) {}
+SBModuleSpec::SBModuleSpec() : m_opaque_up(new lldb_private::ModuleSpec()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpec);
+}
-SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs)
- : m_opaque_ap(new lldb_private::ModuleSpec(*rhs.m_opaque_ap)) {}
+SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
+}
const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBModuleSpec &,
+ SBModuleSpec, operator=,(const lldb::SBModuleSpec &), rhs);
+
if (this != &rhs)
- *m_opaque_ap = *(rhs.m_opaque_ap);
- return *this;
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
SBModuleSpec::~SBModuleSpec() {}
-bool SBModuleSpec::IsValid() const { return m_opaque_ap->operator bool(); }
+bool SBModuleSpec::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, IsValid);
+ return this->operator bool();
+}
+SBModuleSpec::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, operator bool);
+
+ return m_opaque_up->operator bool();
+}
-void SBModuleSpec::Clear() { m_opaque_ap->Clear(); }
+void SBModuleSpec::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBModuleSpec, Clear);
+
+ m_opaque_up->Clear();
+}
SBFileSpec SBModuleSpec::GetFileSpec() {
- SBFileSpec sb_spec(m_opaque_ap->GetFileSpec());
- return sb_spec;
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetFileSpec);
+
+ SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
+ return LLDB_RECORD_RESULT(sb_spec);
}
void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) {
- m_opaque_ap->GetFileSpec() = *sb_spec;
+ LLDB_RECORD_METHOD(void, SBModuleSpec, SetFileSpec,
+ (const lldb::SBFileSpec &), sb_spec);
+
+ m_opaque_up->GetFileSpec() = *sb_spec;
}
lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() {
- return SBFileSpec(m_opaque_ap->GetPlatformFileSpec());
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec,
+ GetPlatformFileSpec);
+
+ return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetPlatformFileSpec()));
}
void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) {
- m_opaque_ap->GetPlatformFileSpec() = *sb_spec;
+ LLDB_RECORD_METHOD(void, SBModuleSpec, SetPlatformFileSpec,
+ (const lldb::SBFileSpec &), sb_spec);
+
+ m_opaque_up->GetPlatformFileSpec() = *sb_spec;
}
lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() {
- return SBFileSpec(m_opaque_ap->GetSymbolFileSpec());
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec);
+
+ return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetSymbolFileSpec()));
}
void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) {
- m_opaque_ap->GetSymbolFileSpec() = *sb_spec;
+ LLDB_RECORD_METHOD(void, SBModuleSpec, SetSymbolFileSpec,
+ (const lldb::SBFileSpec &), sb_spec);
+
+ m_opaque_up->GetSymbolFileSpec() = *sb_spec;
}
const char *SBModuleSpec::GetObjectName() {
- return m_opaque_ap->GetObjectName().GetCString();
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetObjectName);
+
+ return m_opaque_up->GetObjectName().GetCString();
}
void SBModuleSpec::SetObjectName(const char *name) {
- m_opaque_ap->GetObjectName().SetCString(name);
+ LLDB_RECORD_METHOD(void, SBModuleSpec, SetObjectName, (const char *), name);
+
+ m_opaque_up->GetObjectName().SetCString(name);
}
const char *SBModuleSpec::GetTriple() {
- std::string triple(m_opaque_ap->GetArchitecture().GetTriple().str());
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetTriple);
+
+ std::string triple(m_opaque_up->GetArchitecture().GetTriple().str());
// Unique the string so we don't run into ownership issues since the const
// strings put the string into the string pool once and the strings never
// comes out
@@ -78,82 +121,180 @@ const char *SBModuleSpec::GetTriple() {
}
void SBModuleSpec::SetTriple(const char *triple) {
- m_opaque_ap->GetArchitecture().SetTriple(triple);
+ LLDB_RECORD_METHOD(void, SBModuleSpec, SetTriple, (const char *), triple);
+
+ m_opaque_up->GetArchitecture().SetTriple(triple);
}
const uint8_t *SBModuleSpec::GetUUIDBytes() {
- return m_opaque_ap->GetUUID().GetBytes().data();
+ return m_opaque_up->GetUUID().GetBytes().data();
}
size_t SBModuleSpec::GetUUIDLength() {
- return m_opaque_ap->GetUUID().GetBytes().size();
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpec, GetUUIDLength);
+
+ return m_opaque_up->GetUUID().GetBytes().size();
}
bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
- m_opaque_ap->GetUUID() = UUID::fromOptionalData(uuid, uuid_len);
- return m_opaque_ap->GetUUID().IsValid();
+ m_opaque_up->GetUUID() = UUID::fromOptionalData(uuid, uuid_len);
+ return m_opaque_up->GetUUID().IsValid();
}
bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
- m_opaque_ap->Dump(description.ref());
+ LLDB_RECORD_METHOD(bool, SBModuleSpec, GetDescription, (lldb::SBStream &),
+ description);
+
+ m_opaque_up->Dump(description.ref());
return true;
}
-SBModuleSpecList::SBModuleSpecList() : m_opaque_ap(new ModuleSpecList()) {}
+SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpecList);
+}
SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs)
- : m_opaque_ap(new ModuleSpecList(*rhs.m_opaque_ap)) {}
+ : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) {
+ LLDB_RECORD_CONSTRUCTOR(SBModuleSpecList, (const lldb::SBModuleSpecList &),
+ rhs);
+}
SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
+ LLDB_RECORD_METHOD(
+ lldb::SBModuleSpecList &,
+ SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &), rhs);
+
if (this != &rhs)
- *m_opaque_ap = *rhs.m_opaque_ap;
- return *this;
+ *m_opaque_up = *rhs.m_opaque_up;
+ return LLDB_RECORD_RESULT(*this);
}
SBModuleSpecList::~SBModuleSpecList() {}
SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
+ GetModuleSpecifications, (const char *), path);
+
SBModuleSpecList specs;
FileSpec file_spec(path);
FileSystem::Instance().Resolve(file_spec);
Host::ResolveExecutableInBundle(file_spec);
- ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap);
- return specs;
+ ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up);
+ return LLDB_RECORD_RESULT(specs);
}
void SBModuleSpecList::Append(const SBModuleSpec &spec) {
- m_opaque_ap->Append(*spec.m_opaque_ap);
+ LLDB_RECORD_METHOD(void, SBModuleSpecList, Append,
+ (const lldb::SBModuleSpec &), spec);
+
+ m_opaque_up->Append(*spec.m_opaque_up);
}
void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) {
- m_opaque_ap->Append(*spec_list.m_opaque_ap);
+ LLDB_RECORD_METHOD(void, SBModuleSpecList, Append,
+ (const lldb::SBModuleSpecList &), spec_list);
+
+ m_opaque_up->Append(*spec_list.m_opaque_up);
}
-size_t SBModuleSpecList::GetSize() { return m_opaque_ap->GetSize(); }
+size_t SBModuleSpecList::GetSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpecList, GetSize);
+
+ return m_opaque_up->GetSize();
+}
SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) {
+ LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex,
+ (size_t), i);
+
SBModuleSpec sb_module_spec;
- m_opaque_ap->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_ap);
- return sb_module_spec;
+ m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
+ return LLDB_RECORD_RESULT(sb_module_spec);
}
SBModuleSpec
SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) {
+ LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList,
+ FindFirstMatchingSpec, (const lldb::SBModuleSpec &),
+ match_spec);
+
SBModuleSpec sb_module_spec;
- m_opaque_ap->FindMatchingModuleSpec(*match_spec.m_opaque_ap,
- *sb_module_spec.m_opaque_ap);
- return sb_module_spec;
+ m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up,
+ *sb_module_spec.m_opaque_up);
+ return LLDB_RECORD_RESULT(sb_module_spec);
}
SBModuleSpecList
SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) {
+ LLDB_RECORD_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
+ FindMatchingSpecs, (const lldb::SBModuleSpec &),
+ match_spec);
+
SBModuleSpecList specs;
- m_opaque_ap->FindMatchingModuleSpecs(*match_spec.m_opaque_ap,
- *specs.m_opaque_ap);
- return specs;
+ m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
+ *specs.m_opaque_up);
+ return LLDB_RECORD_RESULT(specs);
}
bool SBModuleSpecList::GetDescription(lldb::SBStream &description) {
- m_opaque_ap->Dump(description.ref());
+ LLDB_RECORD_METHOD(bool, SBModuleSpecList, GetDescription, (lldb::SBStream &),
+ description);
+
+ m_opaque_up->Dump(description.ref());
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBModuleSpec>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &));
+ LLDB_REGISTER_METHOD(const lldb::SBModuleSpec &,
+ SBModuleSpec, operator=,(const lldb::SBModuleSpec &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBModuleSpec, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetFileSpec, ());
+ LLDB_REGISTER_METHOD(void, SBModuleSpec, SetFileSpec,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetPlatformFileSpec,
+ ());
+ LLDB_REGISTER_METHOD(void, SBModuleSpec, SetPlatformFileSpec,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec, ());
+ LLDB_REGISTER_METHOD(void, SBModuleSpec, SetSymbolFileSpec,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetObjectName, ());
+ LLDB_REGISTER_METHOD(void, SBModuleSpec, SetObjectName, (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetTriple, ());
+ LLDB_REGISTER_METHOD(void, SBModuleSpec, SetTriple, (const char *));
+ LLDB_REGISTER_METHOD(size_t, SBModuleSpec, GetUUIDLength, ());
+ LLDB_REGISTER_METHOD(bool, SBModuleSpec, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList,
+ (const lldb::SBModuleSpecList &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBModuleSpecList &,
+ SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
+ GetModuleSpecifications, (const char *));
+ LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append,
+ (const lldb::SBModuleSpec &));
+ LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append,
+ (const lldb::SBModuleSpecList &));
+ LLDB_REGISTER_METHOD(size_t, SBModuleSpecList, GetSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex,
+ (size_t));
+ LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList,
+ FindFirstMatchingSpec, (const lldb::SBModuleSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
+ FindMatchingSpecs, (const lldb::SBModuleSpec &));
+ LLDB_REGISTER_METHOD(bool, SBModuleSpecList, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp
index aedad871cd208..f3708d8e084f3 100644
--- a/source/API/SBPlatform.cpp
+++ b/source/API/SBPlatform.cpp
@@ -1,13 +1,13 @@
//===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBPlatform.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBFileSpec.h"
#include "lldb/API/SBLaunchInfo.h"
@@ -26,11 +26,9 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// PlatformConnectOptions
-//----------------------------------------------------------------------
struct PlatformConnectOptions {
- PlatformConnectOptions(const char *url = NULL)
+ PlatformConnectOptions(const char *url = nullptr)
: m_url(), m_rsync_options(), m_rsync_remote_path_prefix(),
m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false),
m_local_cache_directory() {
@@ -48,11 +46,9 @@ struct PlatformConnectOptions {
ConstString m_local_cache_directory;
};
-//----------------------------------------------------------------------
// PlatformShellCommand
-//----------------------------------------------------------------------
struct PlatformShellCommand {
- PlatformShellCommand(const char *shell_command = NULL)
+ PlatformShellCommand(const char *shell_command = nullptr)
: m_command(), m_working_dir(), m_status(0), m_signo(0) {
if (shell_command && shell_command[0])
m_command = shell_command;
@@ -67,31 +63,45 @@ struct PlatformShellCommand {
int m_signo;
Timeout<std::ratio<1>> m_timeout = llvm::None;
};
-//----------------------------------------------------------------------
// SBPlatformConnectOptions
-//----------------------------------------------------------------------
SBPlatformConnectOptions::SBPlatformConnectOptions(const char *url)
- : m_opaque_ptr(new PlatformConnectOptions(url)) {}
+ : m_opaque_ptr(new PlatformConnectOptions(url)) {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions, (const char *), url);
+}
SBPlatformConnectOptions::SBPlatformConnectOptions(
const SBPlatformConnectOptions &rhs)
: m_opaque_ptr(new PlatformConnectOptions()) {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatformConnectOptions,
+ (const lldb::SBPlatformConnectOptions &), rhs);
+
*m_opaque_ptr = *rhs.m_opaque_ptr;
}
SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; }
void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) {
+ LLDB_RECORD_METHOD(
+ void,
+ SBPlatformConnectOptions, operator=,(
+ const lldb::SBPlatformConnectOptions &),
+ rhs);
+
*m_opaque_ptr = *rhs.m_opaque_ptr;
}
const char *SBPlatformConnectOptions::GetURL() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions, GetURL);
+
if (m_opaque_ptr->m_url.empty())
- return NULL;
+ return nullptr;
return m_opaque_ptr->m_url.c_str();
}
void SBPlatformConnectOptions::SetURL(const char *url) {
+ LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetURL, (const char *),
+ url);
+
if (url && url[0])
m_opaque_ptr->m_url = url;
else
@@ -99,12 +109,18 @@ void SBPlatformConnectOptions::SetURL(const char *url) {
}
bool SBPlatformConnectOptions::GetRsyncEnabled() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatformConnectOptions, GetRsyncEnabled);
+
return m_opaque_ptr->m_rsync_enabled;
}
void SBPlatformConnectOptions::EnableRsync(
const char *options, const char *remote_path_prefix,
bool omit_hostname_from_remote_path) {
+ LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, EnableRsync,
+ (const char *, const char *, bool), options,
+ remote_path_prefix, omit_hostname_from_remote_path);
+
m_opaque_ptr->m_rsync_enabled = true;
m_opaque_ptr->m_rsync_omit_hostname_from_remote_path =
omit_hostname_from_remote_path;
@@ -120,47 +136,66 @@ void SBPlatformConnectOptions::EnableRsync(
}
void SBPlatformConnectOptions::DisableRsync() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformConnectOptions, DisableRsync);
+
m_opaque_ptr->m_rsync_enabled = false;
}
const char *SBPlatformConnectOptions::GetLocalCacheDirectory() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformConnectOptions,
+ GetLocalCacheDirectory);
+
return m_opaque_ptr->m_local_cache_directory.GetCString();
}
void SBPlatformConnectOptions::SetLocalCacheDirectory(const char *path) {
+ LLDB_RECORD_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory,
+ (const char *), path);
+
if (path && path[0])
m_opaque_ptr->m_local_cache_directory.SetCString(path);
else
m_opaque_ptr->m_local_cache_directory = ConstString();
}
-//----------------------------------------------------------------------
// SBPlatformShellCommand
-//----------------------------------------------------------------------
SBPlatformShellCommand::SBPlatformShellCommand(const char *shell_command)
- : m_opaque_ptr(new PlatformShellCommand(shell_command)) {}
+ : m_opaque_ptr(new PlatformShellCommand(shell_command)) {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand, (const char *),
+ shell_command);
+}
SBPlatformShellCommand::SBPlatformShellCommand(
const SBPlatformShellCommand &rhs)
: m_opaque_ptr(new PlatformShellCommand()) {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatformShellCommand,
+ (const lldb::SBPlatformShellCommand &), rhs);
+
*m_opaque_ptr = *rhs.m_opaque_ptr;
}
SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; }
void SBPlatformShellCommand::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatformShellCommand, Clear);
+
m_opaque_ptr->m_output = std::string();
m_opaque_ptr->m_status = 0;
m_opaque_ptr->m_signo = 0;
}
const char *SBPlatformShellCommand::GetCommand() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetCommand);
+
if (m_opaque_ptr->m_command.empty())
- return NULL;
+ return nullptr;
return m_opaque_ptr->m_command.c_str();
}
void SBPlatformShellCommand::SetCommand(const char *shell_command) {
+ LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetCommand, (const char *),
+ shell_command);
+
if (shell_command && shell_command[0])
m_opaque_ptr->m_command = shell_command;
else
@@ -168,12 +203,18 @@ void SBPlatformShellCommand::SetCommand(const char *shell_command) {
}
const char *SBPlatformShellCommand::GetWorkingDirectory() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand,
+ GetWorkingDirectory);
+
if (m_opaque_ptr->m_working_dir.empty())
- return NULL;
+ return nullptr;
return m_opaque_ptr->m_working_dir.c_str();
}
void SBPlatformShellCommand::SetWorkingDirectory(const char *path) {
+ LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory,
+ (const char *), path);
+
if (path && path[0])
m_opaque_ptr->m_working_dir = path;
else
@@ -181,34 +222,52 @@ void SBPlatformShellCommand::SetWorkingDirectory(const char *path) {
}
uint32_t SBPlatformShellCommand::GetTimeoutSeconds() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatformShellCommand,
+ GetTimeoutSeconds);
+
if (m_opaque_ptr->m_timeout)
return m_opaque_ptr->m_timeout->count();
return UINT32_MAX;
}
void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) {
+ LLDB_RECORD_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds,
+ (uint32_t), sec);
+
if (sec == UINT32_MAX)
m_opaque_ptr->m_timeout = llvm::None;
else
m_opaque_ptr->m_timeout = std::chrono::seconds(sec);
}
-int SBPlatformShellCommand::GetSignal() { return m_opaque_ptr->m_signo; }
+int SBPlatformShellCommand::GetSignal() {
+ LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetSignal);
+
+ return m_opaque_ptr->m_signo;
+}
-int SBPlatformShellCommand::GetStatus() { return m_opaque_ptr->m_status; }
+int SBPlatformShellCommand::GetStatus() {
+ LLDB_RECORD_METHOD_NO_ARGS(int, SBPlatformShellCommand, GetStatus);
+
+ return m_opaque_ptr->m_status;
+}
const char *SBPlatformShellCommand::GetOutput() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatformShellCommand, GetOutput);
+
if (m_opaque_ptr->m_output.empty())
- return NULL;
+ return nullptr;
return m_opaque_ptr->m_output.c_str();
}
-//----------------------------------------------------------------------
// SBPlatform
-//----------------------------------------------------------------------
-SBPlatform::SBPlatform() : m_opaque_sp() {}
+SBPlatform::SBPlatform() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBPlatform);
+}
SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const char *), platform_name);
+
Status error;
if (platform_name && platform_name[0])
m_opaque_sp = Platform::Create(ConstString(platform_name), error);
@@ -216,15 +275,29 @@ SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() {
SBPlatform::~SBPlatform() {}
-bool SBPlatform::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBPlatform::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid);
+ return this->operator bool();
+}
+SBPlatform::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
+
+void SBPlatform::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, Clear);
-void SBPlatform::Clear() { m_opaque_sp.reset(); }
+ m_opaque_sp.reset();
+}
const char *SBPlatform::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetName);
+
PlatformSP platform_sp(GetSP());
if (platform_sp)
return platform_sp->GetName().GetCString();
- return NULL;
+ return nullptr;
}
lldb::PlatformSP SBPlatform::GetSP() const { return m_opaque_sp; }
@@ -234,13 +307,18 @@ void SBPlatform::SetSP(const lldb::PlatformSP &platform_sp) {
}
const char *SBPlatform::GetWorkingDirectory() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetWorkingDirectory);
+
PlatformSP platform_sp(GetSP());
if (platform_sp)
return platform_sp->GetWorkingDirectory().GetCString();
- return NULL;
+ return nullptr;
}
bool SBPlatform::SetWorkingDirectory(const char *path) {
+ LLDB_RECORD_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *),
+ path);
+
PlatformSP platform_sp(GetSP());
if (platform_sp) {
if (path)
@@ -253,6 +331,9 @@ bool SBPlatform::SetWorkingDirectory(const char *path) {
}
SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, ConnectRemote,
+ (lldb::SBPlatformConnectOptions &), connect_options);
+
SBError sb_error;
PlatformSP platform_sp(GetSP());
if (platform_sp && connect_options.GetURL()) {
@@ -263,16 +344,20 @@ SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) {
} else {
sb_error.SetErrorString("invalid platform");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
void SBPlatform::DisconnectRemote() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBPlatform, DisconnectRemote);
+
PlatformSP platform_sp(GetSP());
if (platform_sp)
platform_sp->DisconnectRemote();
}
bool SBPlatform::IsConnected() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBPlatform, IsConnected);
+
PlatformSP platform_sp(GetSP());
if (platform_sp)
return platform_sp->IsConnected();
@@ -280,6 +365,8 @@ bool SBPlatform::IsConnected() {
}
const char *SBPlatform::GetTriple() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetTriple);
+
PlatformSP platform_sp(GetSP());
if (platform_sp) {
ArchSpec arch(platform_sp->GetSystemArchitecture());
@@ -289,10 +376,12 @@ const char *SBPlatform::GetTriple() {
return ConstString(arch.GetTriple().getTriple().c_str()).GetCString();
}
}
- return NULL;
+ return nullptr;
}
const char *SBPlatform::GetOSBuild() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSBuild);
+
PlatformSP platform_sp(GetSP());
if (platform_sp) {
std::string s;
@@ -304,10 +393,12 @@ const char *SBPlatform::GetOSBuild() {
}
}
}
- return NULL;
+ return nullptr;
}
const char *SBPlatform::GetOSDescription() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetOSDescription);
+
PlatformSP platform_sp(GetSP());
if (platform_sp) {
std::string s;
@@ -319,17 +410,21 @@ const char *SBPlatform::GetOSDescription() {
}
}
}
- return NULL;
+ return nullptr;
}
const char *SBPlatform::GetHostname() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBPlatform, GetHostname);
+
PlatformSP platform_sp(GetSP());
if (platform_sp)
return platform_sp->GetHostname();
- return NULL;
+ return nullptr;
}
uint32_t SBPlatform::GetOSMajorVersion() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMajorVersion);
+
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
@@ -337,6 +432,8 @@ uint32_t SBPlatform::GetOSMajorVersion() {
}
uint32_t SBPlatform::GetOSMinorVersion() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSMinorVersion);
+
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
@@ -344,6 +441,8 @@ uint32_t SBPlatform::GetOSMinorVersion() {
}
uint32_t SBPlatform::GetOSUpdateVersion() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBPlatform, GetOSUpdateVersion);
+
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
@@ -351,6 +450,9 @@ uint32_t SBPlatform::GetOSUpdateVersion() {
}
SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Get,
+ (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst);
+
SBError sb_error;
PlatformSP platform_sp(GetSP());
if (platform_sp) {
@@ -358,50 +460,60 @@ SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
} else {
sb_error.SetErrorString("invalid platform");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) {
- return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
- if (src.Exists()) {
- uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref());
- if (permissions == 0) {
- if (FileSystem::Instance().IsDirectory(src.ref()))
- permissions = eFilePermissionsDirectoryDefault;
- else
- permissions = eFilePermissionsFileDefault;
- }
-
- return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
- }
-
- Status error;
- error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
- src.ref().GetPath().c_str());
- return error;
- });
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Put,
+ (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst);
+ return LLDB_RECORD_RESULT(
+ ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ if (src.Exists()) {
+ uint32_t permissions =
+ FileSystem::Instance().GetPermissions(src.ref());
+ if (permissions == 0) {
+ if (FileSystem::Instance().IsDirectory(src.ref()))
+ permissions = eFilePermissionsDirectoryDefault;
+ else
+ permissions = eFilePermissionsFileDefault;
+ }
+
+ return platform_sp->PutFile(src.ref(), dst.ref(), permissions);
+ }
+
+ Status error;
+ error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
+ src.ref().GetPath().c_str());
+ return error;
+ }));
}
SBError SBPlatform::Install(SBFileSpec &src, SBFileSpec &dst) {
- return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
- if (src.Exists())
- return platform_sp->Install(src.ref(), dst.ref());
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Install,
+ (lldb::SBFileSpec &, lldb::SBFileSpec &), src, dst);
+ return LLDB_RECORD_RESULT(
+ ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ if (src.Exists())
+ return platform_sp->Install(src.ref(), dst.ref());
- Status error;
- error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
- src.ref().GetPath().c_str());
- return error;
- });
+ Status error;
+ error.SetErrorStringWithFormat("'src' argument doesn't exist: '%s'",
+ src.ref().GetPath().c_str());
+ return error;
+ }));
}
SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
- return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Run,
+ (lldb::SBPlatformShellCommand &), shell_command);
+ return LLDB_RECORD_RESULT(ExecuteConnected([&](const lldb::PlatformSP
+ &platform_sp) {
const char *command = shell_command.GetCommand();
if (!command)
return Status("invalid shell command (empty)");
const char *working_dir = shell_command.GetWorkingDirectory();
- if (working_dir == NULL) {
+ if (working_dir == nullptr) {
working_dir = platform_sp->GetWorkingDirectory().GetCString();
if (working_dir)
shell_command.SetWorkingDirectory(working_dir);
@@ -411,22 +523,27 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
&shell_command.m_opaque_ptr->m_signo,
&shell_command.m_opaque_ptr->m_output,
shell_command.m_opaque_ptr->m_timeout);
- });
+ }));
}
SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
- return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
- ProcessLaunchInfo info = launch_info.ref();
- Status error = platform_sp->LaunchProcess(info);
- launch_info.set_ref(info);
- return error;
- });
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Launch, (lldb::SBLaunchInfo &),
+ launch_info);
+ return LLDB_RECORD_RESULT(
+ ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ ProcessLaunchInfo info = launch_info.ref();
+ Status error = platform_sp->LaunchProcess(info);
+ launch_info.set_ref(info);
+ return error;
+ }));
}
SBError SBPlatform::Kill(const lldb::pid_t pid) {
- return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
- return platform_sp->KillProcess(pid);
- });
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t), pid);
+ return LLDB_RECORD_RESULT(
+ ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
+ return platform_sp->KillProcess(pid);
+ }));
}
SBError SBPlatform::ExecuteConnected(
@@ -445,6 +562,9 @@ SBError SBPlatform::ExecuteConnected(
}
SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, MakeDirectory,
+ (const char *, uint32_t), path, file_permissions);
+
SBError sb_error;
PlatformSP platform_sp(GetSP());
if (platform_sp) {
@@ -453,10 +573,13 @@ SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) {
} else {
sb_error.SetErrorString("invalid platform");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
uint32_t SBPlatform::GetFilePermissions(const char *path) {
+ LLDB_RECORD_METHOD(uint32_t, SBPlatform, GetFilePermissions, (const char *),
+ path);
+
PlatformSP platform_sp(GetSP());
if (platform_sp) {
uint32_t file_permissions = 0;
@@ -468,6 +591,9 @@ uint32_t SBPlatform::GetFilePermissions(const char *path) {
SBError SBPlatform::SetFilePermissions(const char *path,
uint32_t file_permissions) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBPlatform, SetFilePermissions,
+ (const char *, uint32_t), path, file_permissions);
+
SBError sb_error;
PlatformSP platform_sp(GetSP());
if (platform_sp) {
@@ -476,12 +602,107 @@ SBError SBPlatform::SetFilePermissions(const char *path,
} else {
sb_error.SetErrorString("invalid platform");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBUnixSignals SBPlatform::GetUnixSignals() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBUnixSignals, SBPlatform,
+ GetUnixSignals);
+
if (auto platform_sp = GetSP())
- return SBUnixSignals{platform_sp};
+ return LLDB_RECORD_RESULT(SBUnixSignals{platform_sp});
+
+ return LLDB_RECORD_RESULT(SBUnixSignals());
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBPlatformConnectOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions,
+ (const lldb::SBPlatformConnectOptions &));
+ LLDB_REGISTER_METHOD(
+ void,
+ SBPlatformConnectOptions, operator=,(
+ const lldb::SBPlatformConnectOptions &));
+ LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ());
+ LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetURL,
+ (const char *));
+ LLDB_REGISTER_METHOD(bool, SBPlatformConnectOptions, GetRsyncEnabled, ());
+ LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, EnableRsync,
+ (const char *, const char *, bool));
+ LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, DisableRsync, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions,
+ GetLocalCacheDirectory, ());
+ LLDB_REGISTER_METHOD(void, SBPlatformConnectOptions, SetLocalCacheDirectory,
+ (const char *));
+}
+
+template <>
+void RegisterMethods<SBPlatformShellCommand>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *));
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand,
+ (const lldb::SBPlatformShellCommand &));
+ LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ());
+ LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand,
+ (const char *));
+ LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand,
+ GetWorkingDirectory, ());
+ LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetWorkingDirectory,
+ (const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBPlatformShellCommand, GetTimeoutSeconds,
+ ());
+ LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetTimeoutSeconds,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetSignal, ());
+ LLDB_REGISTER_METHOD(int, SBPlatformShellCommand, GetStatus, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetOutput, ());
+}
+
+template <>
+void RegisterMethods<SBPlatform>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *));
+ LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatform, GetName, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatform, GetWorkingDirectory, ());
+ LLDB_REGISTER_METHOD(bool, SBPlatform, SetWorkingDirectory, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, ConnectRemote,
+ (lldb::SBPlatformConnectOptions &));
+ LLDB_REGISTER_METHOD(void, SBPlatform, DisconnectRemote, ());
+ LLDB_REGISTER_METHOD(bool, SBPlatform, IsConnected, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatform, GetTriple, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSBuild, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatform, GetOSDescription, ());
+ LLDB_REGISTER_METHOD(const char *, SBPlatform, GetHostname, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMajorVersion, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSMinorVersion, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetOSUpdateVersion, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Get,
+ (lldb::SBFileSpec &, lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Put,
+ (lldb::SBFileSpec &, lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Install,
+ (lldb::SBFileSpec &, lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Run,
+ (lldb::SBPlatformShellCommand &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Launch,
+ (lldb::SBLaunchInfo &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, Kill, (const lldb::pid_t));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, MakeDirectory,
+ (const char *, uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBPlatform, GetFilePermissions,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions,
+ (const char *, uint32_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals,
+ ());
+}
- return {};
+}
}
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index cb1124607ec01..4226ff77ecdc3 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -1,13 +1,13 @@
//===-- SBProcess.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBProcess.h"
+#include "SBReproducerPrivate.h"
#include <inttypes.h>
@@ -25,7 +25,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Args.h"
-#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
@@ -49,33 +49,43 @@
using namespace lldb;
using namespace lldb_private;
-SBProcess::SBProcess() : m_opaque_wp() {}
+SBProcess::SBProcess() : m_opaque_wp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcess);
+}
-//----------------------------------------------------------------------
// SBProcess constructor
-//----------------------------------------------------------------------
-SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) {}
+SBProcess::SBProcess(const SBProcess &rhs) : m_opaque_wp(rhs.m_opaque_wp) {
+ LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &), rhs);
+}
SBProcess::SBProcess(const lldb::ProcessSP &process_sp)
- : m_opaque_wp(process_sp) {}
+ : m_opaque_wp(process_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &), process_sp);
+}
const SBProcess &SBProcess::operator=(const SBProcess &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBProcess &,
+ SBProcess, operator=,(const lldb::SBProcess &), rhs);
+
if (this != &rhs)
m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SBProcess::~SBProcess() {}
const char *SBProcess::GetBroadcasterClassName() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess,
+ GetBroadcasterClassName);
+
return Process::GetStaticBroadcasterClass().AsCString();
}
const char *SBProcess::GetPluginName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetPluginName);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
return process_sp->GetPluginName().GetCString();
@@ -84,6 +94,8 @@ const char *SBProcess::GetPluginName() {
}
const char *SBProcess::GetShortPluginName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetShortPluginName);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
return process_sp->GetPluginName().GetCString();
@@ -95,9 +107,19 @@ lldb::ProcessSP SBProcess::GetSP() const { return m_opaque_wp.lock(); }
void SBProcess::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
-void SBProcess::Clear() { m_opaque_wp.reset(); }
+void SBProcess::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, Clear);
+
+ m_opaque_wp.reset();
+}
bool SBProcess::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, IsValid);
+ return this->operator bool();
+}
+SBProcess::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcess, operator bool);
+
ProcessSP process_sp(m_opaque_wp.lock());
return ((bool)process_sp && process_sp->IsValid());
}
@@ -108,18 +130,12 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp,
const char *working_directory,
uint32_t launch_flags, bool stop_at_entry,
lldb::SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::RemoteLaunch (argv=%p, envp=%p, stdin=%s, "
- "stdout=%s, stderr=%s, working-dir=%s, launch_flags=0x%x, "
- "stop_at_entry=%i, &error (%p))...",
- static_cast<void *>(m_opaque_wp.lock().get()),
- static_cast<void *>(argv), static_cast<void *>(envp),
- stdin_path ? stdin_path : "NULL",
- stdout_path ? stdout_path : "NULL",
- stderr_path ? stderr_path : "NULL",
- working_directory ? working_directory : "NULL", launch_flags,
- stop_at_entry, static_cast<void *>(error.get()));
+ LLDB_RECORD_METHOD(bool, SBProcess, RemoteLaunch,
+ (const char **, const char **, const char *, const char *,
+ const char *, const char *, uint32_t, bool,
+ lldb::SBError &),
+ argv, envp, stdin_path, stdout_path, stderr_path,
+ working_directory, launch_flags, stop_at_entry, error);
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -146,19 +162,14 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp,
error.SetErrorString("unable to attach pid");
}
- if (log) {
- SBStream sstr;
- error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::RemoteLaunch (...) => SBError (%p): %s",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(error.get()), sstr.GetData());
- }
-
return error.Success();
}
bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid,
lldb::SBError &error) {
+ LLDB_RECORD_METHOD(bool, SBProcess, RemoteAttachToProcessWithID,
+ (lldb::pid_t, lldb::SBError &), pid, error);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -175,21 +186,11 @@ bool SBProcess::RemoteAttachToProcessWithID(lldb::pid_t pid,
error.SetErrorString("unable to attach pid");
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- SBStream sstr;
- error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::RemoteAttachToProcessWithID (%" PRIu64
- ") => SBError (%p): %s",
- static_cast<void *>(process_sp.get()), pid,
- static_cast<void *>(error.get()), sstr.GetData());
- }
-
return error.Success();
}
uint32_t SBProcess::GetNumThreads() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumThreads);
uint32_t num_threads = 0;
ProcessSP process_sp(GetSP());
@@ -202,15 +203,12 @@ uint32_t SBProcess::GetNumThreads() {
num_threads = process_sp->GetThreadList().GetSize(can_update);
}
- if (log)
- log->Printf("SBProcess(%p)::GetNumThreads () => %d",
- static_cast<void *>(process_sp.get()), num_threads);
-
return num_threads;
}
SBThread SBProcess::GetSelectedThread() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBProcess,
+ GetSelectedThread);
SBThread sb_thread;
ThreadSP thread_sp;
@@ -222,17 +220,13 @@ SBThread SBProcess::GetSelectedThread() const {
sb_thread.SetThread(thread_sp);
}
- if (log)
- log->Printf("SBProcess(%p)::GetSelectedThread () => SBThread(%p)",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(thread_sp.get()));
-
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid,
lldb::addr_t context) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread,
+ (lldb::tid_t, lldb::addr_t), tid, context);
SBThread sb_thread;
ThreadSP thread_sp;
@@ -244,17 +238,11 @@ SBThread SBProcess::CreateOSPluginThread(lldb::tid_t tid,
sb_thread.SetThread(thread_sp);
}
- if (log)
- log->Printf("SBProcess(%p)::CreateOSPluginThread (tid=0x%" PRIx64
- ", context=0x%" PRIx64 ") => SBThread(%p)",
- static_cast<void *>(process_sp.get()), tid, context,
- static_cast<void *>(thread_sp.get()));
-
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
SBTarget SBProcess::GetTarget() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBTarget, SBProcess, GetTarget);
SBTarget sb_target;
TargetSP target_sp;
@@ -264,16 +252,12 @@ SBTarget SBProcess::GetTarget() const {
sb_target.SetSP(target_sp);
}
- if (log)
- log->Printf("SBProcess(%p)::GetTarget () => SBTarget(%p)",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(target_sp.get()));
-
- return sb_target;
+ return LLDB_RECORD_RESULT(sb_target);
}
size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t), src,
+ src_len);
size_t ret_val = 0;
ProcessSP process_sp(GetSP());
@@ -282,16 +266,13 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) {
ret_val = process_sp->PutSTDIN(src, src_len, error);
}
- if (log)
- log->Printf("SBProcess(%p)::PutSTDIN (src=\"%s\", src_len=%" PRIu64
- ") => %" PRIu64,
- static_cast<void *>(process_sp.get()), src,
- static_cast<uint64_t>(src_len), static_cast<uint64_t>(ret_val));
-
return ret_val;
}
size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
+ LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst,
+ dst_len);
+
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -299,18 +280,13 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const {
bytes_read = process_sp->GetSTDOUT(dst, dst_len, error);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBProcess(%p)::GetSTDOUT (dst=\"%.*s\", dst_len=%" PRIu64
- ") => %" PRIu64,
- static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read),
- dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read));
-
return bytes_read;
}
size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
+ LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst,
+ dst_len);
+
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -318,18 +294,13 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const {
bytes_read = process_sp->GetSTDERR(dst, dst_len, error);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBProcess(%p)::GetSTDERR (dst=\"%.*s\", dst_len=%" PRIu64
- ") => %" PRIu64,
- static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read),
- dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read));
-
return bytes_read;
}
size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
+ LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
+ (char *, size_t), dst, dst_len);
+
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -337,20 +308,14 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const {
bytes_read = process_sp->GetAsyncProfileData(dst, dst_len, error);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBProcess(%p)::GetAsyncProfileData (dst=\"%.*s\", dst_len=%" PRIu64
- ") => %" PRIu64,
- static_cast<void *>(process_sp.get()), static_cast<int>(bytes_read),
- dst, static_cast<uint64_t>(dst_len), static_cast<uint64_t>(bytes_read));
-
return bytes_read;
}
lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options,
lldb::SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBTrace, SBProcess, StartTrace,
+ (lldb::SBTraceOptions &, lldb::SBError &), options, error);
+
ProcessSP process_sp(GetSP());
error.Clear();
SBTrace trace_instance;
@@ -362,13 +327,15 @@ lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options,
} else {
uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref());
trace_instance.SetTraceUID(uid);
- LLDB_LOG(log, "SBProcess::returned uid - {0}", uid);
}
- return trace_instance;
+ return LLDB_RECORD_RESULT(trace_instance);
}
void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
- if (out == NULL)
+ LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, FILE *), event, out);
+
+ if (out == nullptr)
return;
ProcessSP process_sp(GetSP());
@@ -386,6 +353,10 @@ void SBProcess::ReportEventState(const SBEvent &event, FILE *out) const {
void SBProcess::AppendEventStateReport(const SBEvent &event,
SBCommandReturnObject &result) {
+ LLDB_RECORD_METHOD(void, SBProcess, AppendEventStateReport,
+ (const lldb::SBEvent &, lldb::SBCommandReturnObject &),
+ event, result);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
const StateType event_state = SBProcess::GetStateFromEvent(event);
@@ -398,6 +369,9 @@ void SBProcess::AppendEventStateReport(const SBEvent &event,
}
bool SBProcess::SetSelectedThread(const SBThread &thread) {
+ LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThread,
+ (const lldb::SBThread &), thread);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -409,7 +383,9 @@ bool SBProcess::SetSelectedThread(const SBThread &thread) {
}
bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t),
+ tid);
+
bool ret_val = false;
ProcessSP process_sp(GetSP());
@@ -419,17 +395,12 @@ bool SBProcess::SetSelectedThreadByID(lldb::tid_t tid) {
ret_val = process_sp->GetThreadList().SetSelectedThreadByID(tid);
}
- if (log)
- log->Printf("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4" PRIx64
- ") => %s",
- static_cast<void *>(process_sp.get()), tid,
- (ret_val ? "true" : "false"));
-
return ret_val;
}
bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBProcess, SetSelectedThreadByIndexID, (uint32_t),
+ index_id);
bool ret_val = false;
ProcessSP process_sp(GetSP());
@@ -439,16 +410,13 @@ bool SBProcess::SetSelectedThreadByIndexID(uint32_t index_id) {
ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID(index_id);
}
- if (log)
- log->Printf("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s",
- static_cast<void *>(process_sp.get()), index_id,
- (ret_val ? "true" : "false"));
return ret_val;
}
SBThread SBProcess::GetThreadAtIndex(size_t index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t),
+ index);
SBThread sb_thread;
ThreadSP thread_sp;
@@ -462,17 +430,11 @@ SBThread SBProcess::GetThreadAtIndex(size_t index) {
sb_thread.SetThread(thread_sp);
}
- if (log)
- log->Printf("SBProcess(%p)::GetThreadAtIndex (index=%d) => SBThread(%p)",
- static_cast<void *>(process_sp.get()),
- static_cast<uint32_t>(index),
- static_cast<void *>(thread_sp.get()));
-
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
uint32_t SBProcess::GetNumQueues() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumQueues);
uint32_t num_queues = 0;
ProcessSP process_sp(GetSP());
@@ -485,15 +447,12 @@ uint32_t SBProcess::GetNumQueues() {
}
}
- if (log)
- log->Printf("SBProcess(%p)::GetNumQueues () => %d",
- static_cast<void *>(process_sp.get()), num_queues);
-
return num_queues;
}
SBQueue SBProcess::GetQueueAtIndex(size_t index) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t),
+ index);
SBQueue sb_queue;
QueueSP queue_sp;
@@ -508,16 +467,13 @@ SBQueue SBProcess::GetQueueAtIndex(size_t index) {
}
}
- if (log)
- log->Printf("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)",
- static_cast<void *>(process_sp.get()),
- static_cast<uint32_t>(index),
- static_cast<void *>(queue_sp.get()));
-
- return sb_queue;
+ return LLDB_RECORD_RESULT(sb_queue);
}
uint32_t SBProcess::GetStopID(bool include_expression_stops) {
+ LLDB_RECORD_METHOD(uint32_t, SBProcess, GetStopID, (bool),
+ include_expression_stops);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -531,7 +487,8 @@ uint32_t SBProcess::GetStopID(bool include_expression_stops) {
}
SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID,
+ (uint32_t), stop_id);
SBEvent sb_event;
EventSP event_sp;
@@ -543,16 +500,11 @@ SBEvent SBProcess::GetStopEventForStopID(uint32_t stop_id) {
sb_event.reset(event_sp);
}
- if (log)
- log->Printf("SBProcess(%p)::GetStopEventForStopID (stop_id=%" PRIu32
- ") => SBEvent(%p)",
- static_cast<void *>(process_sp.get()), stop_id,
- static_cast<void *>(event_sp.get()));
-
- return sb_event;
+ return LLDB_RECORD_RESULT(sb_event);
}
StateType SBProcess::GetState() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::StateType, SBProcess, GetState);
StateType ret_val = eStateInvalid;
ProcessSP process_sp(GetSP());
@@ -562,16 +514,12 @@ StateType SBProcess::GetState() {
ret_val = process_sp->GetState();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetState () => %s",
- static_cast<void *>(process_sp.get()),
- lldb_private::StateAsCString(ret_val));
-
return ret_val;
}
int SBProcess::GetExitStatus() {
+ LLDB_RECORD_METHOD_NO_ARGS(int, SBProcess, GetExitStatus);
+
int exit_status = 0;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -579,94 +527,74 @@ int SBProcess::GetExitStatus() {
process_sp->GetTarget().GetAPIMutex());
exit_status = process_sp->GetExitStatus();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)",
- static_cast<void *>(process_sp.get()), exit_status,
- exit_status);
return exit_status;
}
const char *SBProcess::GetExitDescription() {
- const char *exit_desc = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcess, GetExitDescription);
+
+ const char *exit_desc = nullptr;
ProcessSP process_sp(GetSP());
if (process_sp) {
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
exit_desc = process_sp->GetExitDescription();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetExitDescription () => %s",
- static_cast<void *>(process_sp.get()), exit_desc);
return exit_desc;
}
lldb::pid_t SBProcess::GetProcessID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcess, GetProcessID);
+
lldb::pid_t ret_val = LLDB_INVALID_PROCESS_ID;
ProcessSP process_sp(GetSP());
if (process_sp)
ret_val = process_sp->GetID();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetProcessID () => %" PRIu64,
- static_cast<void *>(process_sp.get()), ret_val);
-
return ret_val;
}
uint32_t SBProcess::GetUniqueID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetUniqueID);
+
uint32_t ret_val = 0;
ProcessSP process_sp(GetSP());
if (process_sp)
ret_val = process_sp->GetUniqueID();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetUniqueID () => %" PRIu32,
- static_cast<void *>(process_sp.get()), ret_val);
return ret_val;
}
ByteOrder SBProcess::GetByteOrder() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ByteOrder, SBProcess, GetByteOrder);
+
ByteOrder byteOrder = eByteOrderInvalid;
ProcessSP process_sp(GetSP());
if (process_sp)
byteOrder = process_sp->GetTarget().GetArchitecture().GetByteOrder();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetByteOrder () => %d",
- static_cast<void *>(process_sp.get()), byteOrder);
return byteOrder;
}
uint32_t SBProcess::GetAddressByteSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBProcess, GetAddressByteSize);
+
uint32_t size = 0;
ProcessSP process_sp(GetSP());
if (process_sp)
size = process_sp->GetTarget().GetArchitecture().GetAddressByteSize();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetAddressByteSize () => %d",
- static_cast<void *>(process_sp.get()), size);
return size;
}
SBError SBProcess::Continue() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Continue);
SBError sb_error;
ProcessSP process_sp(GetSP());
- if (log)
- log->Printf("SBProcess(%p)::Continue ()...",
- static_cast<void *>(process_sp.get()));
-
if (process_sp) {
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
@@ -674,22 +602,16 @@ SBError SBProcess::Continue() {
if (process_sp->GetTarget().GetDebugger().GetAsyncExecution())
sb_error.ref() = process_sp->Resume();
else
- sb_error.ref() = process_sp->ResumeSynchronous(NULL);
+ sb_error.ref() = process_sp->ResumeSynchronous(nullptr);
} else
sb_error.SetErrorString("SBProcess is invalid");
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::Continue () => SBError (%p): %s",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBProcess::Destroy() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Destroy);
+
SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -699,19 +621,12 @@ SBError SBProcess::Destroy() {
} else
sb_error.SetErrorString("SBProcess is invalid");
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::Destroy () => SBError (%p): %s",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBProcess::Stop() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Stop);
+
SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -721,19 +636,12 @@ SBError SBProcess::Stop() {
} else
sb_error.SetErrorString("SBProcess is invalid");
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::Stop () => SBError (%p): %s",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBProcess::Kill() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Kill);
+
SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -743,25 +651,20 @@ SBError SBProcess::Kill() {
} else
sb_error.SetErrorString("SBProcess is invalid");
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::Kill () => SBError (%p): %s",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(sb_error.get()), sstr.GetData());
- }
-
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBProcess::Detach() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBProcess, Detach);
+
// FIXME: This should come from a process default.
bool keep_stopped = false;
- return Detach(keep_stopped);
+ return LLDB_RECORD_RESULT(Detach(keep_stopped));
}
SBError SBProcess::Detach(bool keep_stopped) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Detach, (bool), keep_stopped);
+
SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -771,10 +674,12 @@ SBError SBProcess::Detach(bool keep_stopped) {
} else
sb_error.SetErrorString("SBProcess is invalid");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBProcess::Signal(int signo) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBProcess, Signal, (int), signo);
+
SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -783,25 +688,22 @@ SBError SBProcess::Signal(int signo) {
sb_error.SetError(process_sp->Signal(signo));
} else
sb_error.SetErrorString("SBProcess is invalid");
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::Signal (signo=%i) => SBError (%p): %s",
- static_cast<void *>(process_sp.get()), signo,
- static_cast<void *>(sb_error.get()), sstr.GetData());
- }
- return sb_error;
+
+ return LLDB_RECORD_RESULT(sb_error);
}
SBUnixSignals SBProcess::GetUnixSignals() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBUnixSignals, SBProcess, GetUnixSignals);
+
if (auto process_sp = GetSP())
- return SBUnixSignals{process_sp};
+ return LLDB_RECORD_RESULT(SBUnixSignals{process_sp});
- return {};
+ return LLDB_RECORD_RESULT(SBUnixSignals{});
}
void SBProcess::SendAsyncInterrupt() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBProcess, SendAsyncInterrupt);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
process_sp->SendAsyncInterrupt();
@@ -809,6 +711,9 @@ void SBProcess::SendAsyncInterrupt() {
}
SBThread SBProcess::GetThreadByID(tid_t tid) {
+ LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByID, (lldb::tid_t),
+ tid);
+
SBThread sb_thread;
ThreadSP thread_sp;
ProcessSP process_sp(GetSP());
@@ -821,17 +726,13 @@ SBThread SBProcess::GetThreadByID(tid_t tid) {
sb_thread.SetThread(thread_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetThreadByID (tid=0x%4.4" PRIx64
- ") => SBThread (%p)",
- static_cast<void *>(process_sp.get()), tid,
- static_cast<void *>(thread_sp.get()));
-
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) {
+ LLDB_RECORD_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID, (uint32_t),
+ index_id);
+
SBThread sb_thread;
ThreadSP thread_sp;
ProcessSP process_sp(GetSP());
@@ -845,51 +746,48 @@ SBThread SBProcess::GetThreadByIndexID(uint32_t index_id) {
sb_thread.SetThread(thread_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)",
- static_cast<void *>(process_sp.get()), index_id,
- static_cast<void *>(thread_sp.get()));
-
- return sb_thread;
+ return LLDB_RECORD_RESULT(sb_thread);
}
StateType SBProcess::GetStateFromEvent(const SBEvent &event) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent,
+ (const lldb::SBEvent &), event);
StateType ret_val = Process::ProcessEventData::GetStateFromEvent(event.get());
- if (log)
- log->Printf("SBProcess::GetStateFromEvent (event.sp=%p) => %s",
- static_cast<void *>(event.get()),
- lldb_private::StateAsCString(ret_val));
-
return ret_val;
}
bool SBProcess::GetRestartedFromEvent(const SBEvent &event) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent,
+ (const lldb::SBEvent &), event);
bool ret_val = Process::ProcessEventData::GetRestartedFromEvent(event.get());
- if (log)
- log->Printf("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__,
- static_cast<void *>(event.get()), ret_val);
-
return ret_val;
}
size_t SBProcess::GetNumRestartedReasonsFromEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(size_t, SBProcess, GetNumRestartedReasonsFromEvent,
+ (const lldb::SBEvent &), event);
+
return Process::ProcessEventData::GetNumRestartedReasons(event.get());
}
const char *
SBProcess::GetRestartedReasonAtIndexFromEvent(const lldb::SBEvent &event,
size_t idx) {
+ LLDB_RECORD_STATIC_METHOD(const char *, SBProcess,
+ GetRestartedReasonAtIndexFromEvent,
+ (const lldb::SBEvent &, size_t), event, idx);
+
return Process::ProcessEventData::GetRestartedReasonAtIndex(event.get(), idx);
}
SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent,
+ (const lldb::SBEvent &), event);
+
ProcessSP process_sp =
Process::ProcessEventData::GetProcessFromEvent(event.get());
if (!process_sp) {
@@ -897,24 +795,37 @@ SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) {
process_sp = EventDataStructuredData::GetProcessFromEvent(event.get());
}
- return SBProcess(process_sp);
+ return LLDB_RECORD_RESULT(SBProcess(process_sp));
}
bool SBProcess::GetInterruptedFromEvent(const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent,
+ (const lldb::SBEvent &), event);
+
return Process::ProcessEventData::GetInterruptedFromEvent(event.get());
}
lldb::SBStructuredData
SBProcess::GetStructuredDataFromEvent(const lldb::SBEvent &event) {
- return SBStructuredData(event.GetSP());
+ LLDB_RECORD_STATIC_METHOD(lldb::SBStructuredData, SBProcess,
+ GetStructuredDataFromEvent, (const lldb::SBEvent &),
+ event);
+
+ return LLDB_RECORD_RESULT(SBStructuredData(event.GetSP()));
}
bool SBProcess::EventIsProcessEvent(const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent,
+ (const lldb::SBEvent &), event);
+
return (event.GetBroadcasterClass() == SBProcess::GetBroadcasterClass()) &&
!EventIsStructuredDataEvent(event);
}
bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent,
+ (const lldb::SBEvent &), event);
+
EventSP event_sp = event.GetSP();
EventData *event_data = event_sp ? event_sp->GetData() : nullptr;
return event_data && (event_data->GetFlavor() ==
@@ -922,38 +833,35 @@ bool SBProcess::EventIsStructuredDataEvent(const lldb::SBEvent &event) {
}
SBBroadcaster SBProcess::GetBroadcaster() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBProcess,
+ GetBroadcaster);
+
ProcessSP process_sp(GetSP());
SBBroadcaster broadcaster(process_sp.get(), false);
- if (log)
- log->Printf("SBProcess(%p)::GetBroadcaster () => SBBroadcaster (%p)",
- static_cast<void *>(process_sp.get()),
- static_cast<void *>(broadcaster.get()));
- return broadcaster;
+ return LLDB_RECORD_RESULT(broadcaster);
}
const char *SBProcess::GetBroadcasterClass() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess,
+ GetBroadcasterClass);
+
return Process::GetStaticBroadcasterClass().AsCString();
}
size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
SBError &sb_error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_DUMMY(size_t, SBProcess, ReadMemory,
+ (lldb::addr_t, void *, size_t, lldb::SBError &), addr, dst,
+ dst_len, sb_error);
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
- if (log)
- log->Printf("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64
- ", dst=%p, dst_len=%" PRIu64 ", SBError (%p))...",
- static_cast<void *>(process_sp.get()), addr,
- static_cast<void *>(dst), static_cast<uint64_t>(dst_len),
- static_cast<void *>(sb_error.get()));
if (process_sp) {
Process::StopLocker stop_locker;
@@ -962,31 +870,21 @@ size_t SBProcess::ReadMemory(addr_t addr, void *dst, size_t dst_len,
process_sp->GetTarget().GetAPIMutex());
bytes_read = process_sp->ReadMemory(addr, dst, dst_len, sb_error.ref());
} else {
- if (log)
- log->Printf("SBProcess(%p)::ReadMemory() => error: process is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else {
sb_error.SetErrorString("SBProcess is invalid");
}
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::ReadMemory (addr=0x%" PRIx64
- ", dst=%p, dst_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
- static_cast<void *>(process_sp.get()), addr,
- static_cast<void *>(dst), static_cast<uint64_t>(dst_len),
- static_cast<void *>(sb_error.get()), sstr.GetData(),
- static_cast<uint64_t>(bytes_read));
- }
-
return bytes_read;
}
size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
lldb::SBError &sb_error) {
+ LLDB_RECORD_DUMMY(size_t, SBProcess, ReadCStringFromMemory,
+ (lldb::addr_t, void *, size_t, lldb::SBError &), addr, buf,
+ size, sb_error);
+
size_t bytes_read = 0;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -997,11 +895,6 @@ size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
bytes_read = process_sp->ReadCStringFromMemory(addr, (char *)buf, size,
sb_error.ref());
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::ReadCStringFromMemory() => error: process "
- "is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else {
@@ -1012,6 +905,10 @@ size_t SBProcess::ReadCStringFromMemory(addr_t addr, void *buf, size_t size,
uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
lldb::SBError &sb_error) {
+ LLDB_RECORD_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory,
+ (lldb::addr_t, uint32_t, lldb::SBError &), addr, byte_size,
+ sb_error);
+
uint64_t value = 0;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -1022,11 +919,6 @@ uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
value = process_sp->ReadUnsignedIntegerFromMemory(addr, byte_size, 0,
sb_error.ref());
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::ReadUnsignedFromMemory() => error: process "
- "is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else {
@@ -1037,6 +929,9 @@ uint64_t SBProcess::ReadUnsignedFromMemory(addr_t addr, uint32_t byte_size,
lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr,
lldb::SBError &sb_error) {
+ LLDB_RECORD_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory,
+ (lldb::addr_t, lldb::SBError &), addr, sb_error);
+
lldb::addr_t ptr = LLDB_INVALID_ADDRESS;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -1046,11 +941,6 @@ lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr,
process_sp->GetTarget().GetAPIMutex());
ptr = process_sp->ReadPointerFromMemory(addr, sb_error.ref());
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::ReadPointerFromMemory() => error: process "
- "is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else {
@@ -1061,19 +951,14 @@ lldb::addr_t SBProcess::ReadPointerFromMemory(addr_t addr,
size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
SBError &sb_error) {
- size_t bytes_written = 0;
+ LLDB_RECORD_DUMMY(size_t, SBProcess, WriteMemory,
+ (lldb::addr_t, const void *, size_t, lldb::SBError &), addr,
+ src, src_len, sb_error);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ size_t bytes_written = 0;
ProcessSP process_sp(GetSP());
- if (log)
- log->Printf("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64
- ", src=%p, src_len=%" PRIu64 ", SBError (%p))...",
- static_cast<void *>(process_sp.get()), addr,
- static_cast<const void *>(src), static_cast<uint64_t>(src_len),
- static_cast<void *>(sb_error.get()));
-
if (process_sp) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
@@ -1082,28 +967,17 @@ size_t SBProcess::WriteMemory(addr_t addr, const void *src, size_t src_len,
bytes_written =
process_sp->WriteMemory(addr, src, src_len, sb_error.ref());
} else {
- if (log)
- log->Printf("SBProcess(%p)::WriteMemory() => error: process is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
}
- if (log) {
- SBStream sstr;
- sb_error.GetDescription(sstr);
- log->Printf("SBProcess(%p)::WriteMemory (addr=0x%" PRIx64
- ", src=%p, src_len=%" PRIu64 ", SBError (%p): %s) => %" PRIu64,
- static_cast<void *>(process_sp.get()), addr,
- static_cast<const void *>(src), static_cast<uint64_t>(src_len),
- static_cast<void *>(sb_error.get()), sstr.GetData(),
- static_cast<uint64_t>(bytes_written));
- }
-
return bytes_written;
}
bool SBProcess::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
ProcessSP process_sp(GetSP());
@@ -1111,7 +985,7 @@ bool SBProcess::GetDescription(SBStream &description) {
char path[PATH_MAX];
GetTarget().GetExecutable().GetPath(path, sizeof(path));
Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer();
- const char *exe_name = NULL;
+ const char *exe_name = nullptr;
if (exe_module)
exe_name = exe_module->GetFileSpec().GetFilename().AsCString();
@@ -1127,7 +1001,9 @@ bool SBProcess::GetDescription(SBStream &description) {
uint32_t
SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess,
+ GetNumSupportedHardwareWatchpoints,
+ (lldb::SBError &), sb_error);
uint32_t num = 0;
ProcessSP process_sp(GetSP());
@@ -1135,9 +1011,6 @@ SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const {
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
sb_error.SetError(process_sp->GetWatchpointSupportInfo(num));
- if (log)
- log->Printf("SBProcess(%p)::GetNumSupportedHardwareWatchpoints () => %u",
- static_cast<void *>(process_sp.get()), num);
} else {
sb_error.SetErrorString("SBProcess is invalid");
}
@@ -1146,39 +1019,34 @@ SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const {
uint32_t SBProcess::LoadImage(lldb::SBFileSpec &sb_remote_image_spec,
lldb::SBError &sb_error) {
+ LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImage,
+ (lldb::SBFileSpec &, lldb::SBError &),
+ sb_remote_image_spec, sb_error);
+
return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error);
}
uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
const lldb::SBFileSpec &sb_remote_image_spec,
lldb::SBError &sb_error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(
+ uint32_t, SBProcess, LoadImage,
+ (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &),
+ sb_local_image_spec, sb_remote_image_spec, sb_error);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
- if (log)
- log->Printf("SBProcess(%p)::LoadImage() => calling Platform::LoadImage"
- "for: %s",
- static_cast<void *>(process_sp.get()),
- sb_local_image_spec.GetFilename());
-
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
return platform_sp->LoadImage(process_sp.get(), *sb_local_image_spec,
*sb_remote_image_spec, sb_error.ref());
} else {
- if (log)
- log->Printf("SBProcess(%p)::LoadImage() => error: process is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
- } else {
- if (log)
- log->Printf("SBProcess(%p)::LoadImage() => error: called with invalid"
- " process",
- static_cast<void *>(process_sp.get()));
+ } else {
sb_error.SetErrorString("process is invalid");
}
return LLDB_INVALID_IMAGE_TOKEN;
@@ -1186,19 +1054,17 @@ uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
SBStringList &paths,
- lldb::SBFileSpec &loaded_path,
+ lldb::SBFileSpec &loaded_path,
lldb::SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(uint32_t, SBProcess, LoadImageUsingPaths,
+ (const lldb::SBFileSpec &, lldb::SBStringList &,
+ lldb::SBFileSpec &, lldb::SBError &),
+ image_spec, paths, loaded_path, error);
+
ProcessSP process_sp(GetSP());
if (process_sp) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process_sp->GetRunLock())) {
- if (log)
- log->Printf("SBProcess(%p)::LoadImageUsingPaths() => "
- "calling Platform::LoadImageUsingPaths for: %s",
- static_cast<void *>(process_sp.get()),
- image_spec.GetFilename());
-
std::lock_guard<std::recursive_mutex> guard(
process_sp->GetTarget().GetAPIMutex());
PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
@@ -1208,34 +1074,26 @@ uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
for (size_t i = 0; i < num_paths; i++)
paths_vec.push_back(paths.GetStringAtIndex(i));
FileSpec loaded_spec;
-
- uint32_t token = platform_sp->LoadImageUsingPaths(process_sp.get(),
- *image_spec,
- paths_vec,
- error.ref(),
- &loaded_spec);
- if (token != LLDB_INVALID_IMAGE_TOKEN)
- loaded_path = loaded_spec;
- return token;
+
+ uint32_t token = platform_sp->LoadImageUsingPaths(
+ process_sp.get(), *image_spec, paths_vec, error.ref(), &loaded_spec);
+ if (token != LLDB_INVALID_IMAGE_TOKEN)
+ loaded_path = loaded_spec;
+ return token;
} else {
- if (log)
- log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: "
- "process is running",
- static_cast<void *>(process_sp.get()));
error.SetErrorString("process is running");
}
- } else {
- if (log)
- log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: "
- "called with invalid process",
- static_cast<void *>(process_sp.get()));
+ } else {
error.SetErrorString("process is invalid");
}
-
+
return LLDB_INVALID_IMAGE_TOKEN;
}
lldb::SBError SBProcess::UnloadImage(uint32_t image_token) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t),
+ image_token);
+
lldb::SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -1247,18 +1105,17 @@ lldb::SBError SBProcess::UnloadImage(uint32_t image_token) {
sb_error.SetError(
platform_sp->UnloadImage(process_sp.get(), image_token));
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::UnloadImage() => error: process is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else
sb_error.SetErrorString("invalid process");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
lldb::SBError SBProcess::SendEventData(const char *event_data) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SendEventData, (const char *),
+ event_data);
+
lldb::SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -1268,19 +1125,16 @@ lldb::SBError SBProcess::SendEventData(const char *event_data) {
process_sp->GetTarget().GetAPIMutex());
sb_error.SetError(process_sp->SendEventData(event_data));
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBProcess(%p)::SendEventData() => error: process is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else
sb_error.SetErrorString("invalid process");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
uint32_t SBProcess::GetNumExtendedBacktraceTypes() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcess, GetNumExtendedBacktraceTypes);
+
ProcessSP process_sp(GetSP());
if (process_sp && process_sp->GetSystemRuntime()) {
SystemRuntime *runtime = process_sp->GetSystemRuntime();
@@ -1290,6 +1144,9 @@ uint32_t SBProcess::GetNumExtendedBacktraceTypes() {
}
const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(const char *, SBProcess, GetExtendedBacktraceTypeAtIndex,
+ (uint32_t), idx);
+
ProcessSP process_sp(GetSP());
if (process_sp && process_sp->GetSystemRuntime()) {
SystemRuntime *runtime = process_sp->GetSystemRuntime();
@@ -1297,28 +1154,28 @@ const char *SBProcess::GetExtendedBacktraceTypeAtIndex(uint32_t idx) {
runtime->GetExtendedBacktraceTypes();
if (idx < names.size()) {
return names[idx].AsCString();
- } else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBProcess(%p)::GetExtendedBacktraceTypeAtIndex() => "
- "error: requested extended backtrace name out of bounds",
- static_cast<void *>(process_sp.get()));
}
}
- return NULL;
+ return nullptr;
}
SBThreadCollection SBProcess::GetHistoryThreads(addr_t addr) {
+ LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads,
+ (lldb::addr_t), addr);
+
ProcessSP process_sp(GetSP());
SBThreadCollection threads;
if (process_sp) {
threads = SBThreadCollection(process_sp->GetHistoryThreads(addr));
}
- return threads;
+ return LLDB_RECORD_RESULT(threads);
}
bool SBProcess::IsInstrumentationRuntimePresent(
InstrumentationRuntimeType type) {
+ LLDB_RECORD_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent,
+ (lldb::InstrumentationRuntimeType), type);
+
ProcessSP process_sp(GetSP());
if (!process_sp)
return false;
@@ -1333,11 +1190,14 @@ bool SBProcess::IsInstrumentationRuntimePresent(
}
lldb::SBError SBProcess::SaveCore(const char *file_name) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *),
+ file_name);
+
lldb::SBError error;
ProcessSP process_sp(GetSP());
if (!process_sp) {
error.SetErrorString("SBProcess is invalid");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
std::lock_guard<std::recursive_mutex> guard(
@@ -1345,17 +1205,21 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) {
if (process_sp->GetState() != eStateStopped) {
error.SetErrorString("the process is not stopped");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
FileSpec core_file(file_name);
error.ref() = PluginManager::SaveCore(process_sp, core_file);
- return error;
+ return LLDB_RECORD_RESULT(error);
}
lldb::SBError
SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
SBMemoryRegionInfo &sb_region_info) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo,
+ (lldb::addr_t, lldb::SBMemoryRegionInfo &), load_addr,
+ sb_region_info);
+
lldb::SBError sb_error;
ProcessSP process_sp(GetSP());
if (process_sp) {
@@ -1367,20 +1231,18 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr,
sb_error.ref() =
process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref());
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
- static_cast<void *>(process_sp.get()));
sb_error.SetErrorString("process is running");
}
} else {
sb_error.SetErrorString("SBProcess is invalid");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBMemoryRegionInfoList, SBProcess,
+ GetMemoryRegions);
+
lldb::SBMemoryRegionInfoList sb_region_list;
ProcessSP process_sp(GetSP());
@@ -1390,23 +1252,153 @@ lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() {
process_sp->GetTarget().GetAPIMutex());
process_sp->GetMemoryRegions(sb_region_list.ref());
- } else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running",
- static_cast<void *>(process_sp.get()));
}
- return sb_region_list;
+ return LLDB_RECORD_RESULT(sb_region_list);
}
lldb::SBProcessInfo SBProcess::GetProcessInfo() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcessInfo, SBProcess, GetProcessInfo);
+
lldb::SBProcessInfo sb_proc_info;
ProcessSP process_sp(GetSP());
ProcessInstanceInfo proc_info;
if (process_sp && process_sp->GetProcessInfo(proc_info)) {
sb_proc_info.SetProcessInfo(proc_info);
}
- return sb_proc_info;
+ return LLDB_RECORD_RESULT(sb_proc_info);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBProcess>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBProcess, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::SBProcess &));
+ LLDB_REGISTER_CONSTRUCTOR(SBProcess, (const lldb::ProcessSP &));
+ LLDB_REGISTER_METHOD(const lldb::SBProcess &,
+ SBProcess, operator=,(const lldb::SBProcess &));
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess,
+ GetBroadcasterClassName, ());
+ LLDB_REGISTER_METHOD(const char *, SBProcess, GetPluginName, ());
+ LLDB_REGISTER_METHOD(const char *, SBProcess, GetShortPluginName, ());
+ LLDB_REGISTER_METHOD(void, SBProcess, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBProcess, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBProcess, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBProcess, RemoteLaunch,
+ (const char **, const char **, const char *,
+ const char *, const char *, const char *, uint32_t,
+ bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(bool, SBProcess, RemoteAttachToProcessWithID,
+ (lldb::pid_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumThreads, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBProcess, GetSelectedThread,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, CreateOSPluginThread,
+ (lldb::tid_t, lldb::addr_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ());
+ LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t));
+ LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t));
+ LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t));
+ LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData,
+ (char *, size_t));
+ LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace,
+ (lldb::SBTraceOptions &, lldb::SBError &));
+ LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState,
+ (const lldb::SBEvent &, FILE *));
+ LLDB_REGISTER_METHOD(
+ void, SBProcess, AppendEventStateReport,
+ (const lldb::SBEvent &, lldb::SBCommandReturnObject &));
+ LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThread,
+ (const lldb::SBThread &));
+ LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByID, (lldb::tid_t));
+ LLDB_REGISTER_METHOD(bool, SBProcess, SetSelectedThreadByIndexID,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadAtIndex, (size_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumQueues, ());
+ LLDB_REGISTER_METHOD(lldb::SBQueue, SBProcess, GetQueueAtIndex, (size_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetStopID, (bool));
+ LLDB_REGISTER_METHOD(lldb::SBEvent, SBProcess, GetStopEventForStopID,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::StateType, SBProcess, GetState, ());
+ LLDB_REGISTER_METHOD(int, SBProcess, GetExitStatus, ());
+ LLDB_REGISTER_METHOD(const char *, SBProcess, GetExitDescription, ());
+ LLDB_REGISTER_METHOD(lldb::pid_t, SBProcess, GetProcessID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetUniqueID, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::ByteOrder, SBProcess, GetByteOrder, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, GetAddressByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Continue, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Destroy, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Stop, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Kill, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Detach, (bool));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, Signal, (int));
+ LLDB_REGISTER_METHOD(lldb::SBUnixSignals, SBProcess, GetUnixSignals, ());
+ LLDB_REGISTER_METHOD(void, SBProcess, SendAsyncInterrupt, ());
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByID,
+ (lldb::tid_t));
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBProcess, GetThreadByIndexID,
+ (uint32_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::StateType, SBProcess, GetStateFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetRestartedFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(size_t, SBProcess,
+ GetNumRestartedReasonsFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess,
+ GetRestartedReasonAtIndexFromEvent,
+ (const lldb::SBEvent &, size_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBProcess, SBProcess, GetProcessFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, GetInterruptedFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBStructuredData, SBProcess,
+ GetStructuredDataFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsProcessEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBProcess, EventIsStructuredDataEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBProcess, GetBroadcaster,
+ ());
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBProcess, GetBroadcasterClass,
+ ());
+ LLDB_REGISTER_METHOD(uint64_t, SBProcess, ReadUnsignedFromMemory,
+ (lldb::addr_t, uint32_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory,
+ (lldb::addr_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess,
+ GetNumSupportedHardwareWatchpoints,
+ (lldb::SBError &));
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImage,
+ (lldb::SBFileSpec &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(
+ uint32_t, SBProcess, LoadImage,
+ (const lldb::SBFileSpec &, const lldb::SBFileSpec &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, LoadImageUsingPaths,
+ (const lldb::SBFileSpec &, lldb::SBStringList &,
+ lldb::SBFileSpec &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, UnloadImage, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SendEventData,
+ (const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBProcess, GetNumExtendedBacktraceTypes, ());
+ LLDB_REGISTER_METHOD(const char *, SBProcess,
+ GetExtendedBacktraceTypeAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBProcess, GetHistoryThreads,
+ (lldb::addr_t));
+ LLDB_REGISTER_METHOD(bool, SBProcess, IsInstrumentationRuntimePresent,
+ (lldb::InstrumentationRuntimeType));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, SaveCore, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, GetMemoryRegionInfo,
+ (lldb::addr_t, lldb::SBMemoryRegionInfo &));
+ LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess,
+ GetMemoryRegions, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ());
+}
+
+}
}
diff --git a/source/API/SBProcessInfo.cpp b/source/API/SBProcessInfo.cpp
index 2b3ebfb2465f1..be242ec5872d9 100644
--- a/source/API/SBProcessInfo.cpp
+++ b/source/API/SBProcessInfo.cpp
@@ -1,145 +1,210 @@
//===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBProcessInfo.h"
-
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBFileSpec.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Utility/ProcessInfo.h"
using namespace lldb;
using namespace lldb_private;
-SBProcessInfo::SBProcessInfo() : m_opaque_ap() {}
+SBProcessInfo::SBProcessInfo() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBProcessInfo);
+}
-SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_ap() {
- if (rhs.IsValid()) {
- ref() = *rhs.m_opaque_ap;
- }
+SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBProcessInfo::~SBProcessInfo() {}
SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- ref() = *rhs.m_opaque_ap;
- else
- m_opaque_ap.reset();
- }
- return *this;
+ LLDB_RECORD_METHOD(lldb::SBProcessInfo &,
+ SBProcessInfo, operator=,(const lldb::SBProcessInfo &),
+ rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
ProcessInstanceInfo &SBProcessInfo::ref() {
- if (m_opaque_ap == nullptr) {
- m_opaque_ap.reset(new ProcessInstanceInfo());
+ if (m_opaque_up == nullptr) {
+ m_opaque_up.reset(new ProcessInstanceInfo());
}
- return *m_opaque_ap;
+ return *m_opaque_up;
}
void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) {
ref() = proc_info_ref;
}
-bool SBProcessInfo::IsValid() const { return m_opaque_ap != nullptr; }
+bool SBProcessInfo::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, IsValid);
+ return this->operator bool();
+}
+SBProcessInfo::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBProcessInfo, operator bool);
+
+ return m_opaque_up != nullptr;
+}
const char *SBProcessInfo::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetName);
+
const char *name = nullptr;
- if (m_opaque_ap) {
- name = m_opaque_ap->GetName();
+ if (m_opaque_up) {
+ name = m_opaque_up->GetName();
}
return name;
}
SBFileSpec SBProcessInfo::GetExecutableFile() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBProcessInfo,
+ GetExecutableFile);
+
SBFileSpec file_spec;
- if (m_opaque_ap) {
- file_spec.SetFileSpec(m_opaque_ap->GetExecutableFile());
+ if (m_opaque_up) {
+ file_spec.SetFileSpec(m_opaque_up->GetExecutableFile());
}
- return file_spec;
+ return LLDB_RECORD_RESULT(file_spec);
}
lldb::pid_t SBProcessInfo::GetProcessID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetProcessID);
+
lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
- if (m_opaque_ap) {
- proc_id = m_opaque_ap->GetProcessID();
+ if (m_opaque_up) {
+ proc_id = m_opaque_up->GetProcessID();
}
return proc_id;
}
uint32_t SBProcessInfo::GetUserID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetUserID);
+
uint32_t user_id = UINT32_MAX;
- if (m_opaque_ap) {
- user_id = m_opaque_ap->GetUserID();
+ if (m_opaque_up) {
+ user_id = m_opaque_up->GetUserID();
}
return user_id;
}
uint32_t SBProcessInfo::GetGroupID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetGroupID);
+
uint32_t group_id = UINT32_MAX;
- if (m_opaque_ap) {
- group_id = m_opaque_ap->GetGroupID();
+ if (m_opaque_up) {
+ group_id = m_opaque_up->GetGroupID();
}
return group_id;
}
bool SBProcessInfo::UserIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, UserIDIsValid);
+
bool is_valid = false;
- if (m_opaque_ap) {
- is_valid = m_opaque_ap->UserIDIsValid();
+ if (m_opaque_up) {
+ is_valid = m_opaque_up->UserIDIsValid();
}
return is_valid;
}
bool SBProcessInfo::GroupIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, GroupIDIsValid);
+
bool is_valid = false;
- if (m_opaque_ap) {
- is_valid = m_opaque_ap->GroupIDIsValid();
+ if (m_opaque_up) {
+ is_valid = m_opaque_up->GroupIDIsValid();
}
return is_valid;
}
uint32_t SBProcessInfo::GetEffectiveUserID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveUserID);
+
uint32_t user_id = UINT32_MAX;
- if (m_opaque_ap) {
- user_id = m_opaque_ap->GetEffectiveUserID();
+ if (m_opaque_up) {
+ user_id = m_opaque_up->GetEffectiveUserID();
}
return user_id;
}
uint32_t SBProcessInfo::GetEffectiveGroupID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBProcessInfo, GetEffectiveGroupID);
+
uint32_t group_id = UINT32_MAX;
- if (m_opaque_ap) {
- group_id = m_opaque_ap->GetEffectiveGroupID();
+ if (m_opaque_up) {
+ group_id = m_opaque_up->GetEffectiveGroupID();
}
return group_id;
}
bool SBProcessInfo::EffectiveUserIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveUserIDIsValid);
+
bool is_valid = false;
- if (m_opaque_ap) {
- is_valid = m_opaque_ap->EffectiveUserIDIsValid();
+ if (m_opaque_up) {
+ is_valid = m_opaque_up->EffectiveUserIDIsValid();
}
return is_valid;
}
bool SBProcessInfo::EffectiveGroupIDIsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBProcessInfo, EffectiveGroupIDIsValid);
+
bool is_valid = false;
- if (m_opaque_ap) {
- is_valid = m_opaque_ap->EffectiveGroupIDIsValid();
+ if (m_opaque_up) {
+ is_valid = m_opaque_up->EffectiveGroupIDIsValid();
}
return is_valid;
}
lldb::pid_t SBProcessInfo::GetParentProcessID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::pid_t, SBProcessInfo, GetParentProcessID);
+
lldb::pid_t proc_id = LLDB_INVALID_PROCESS_ID;
- if (m_opaque_ap) {
- proc_id = m_opaque_ap->GetParentProcessID();
+ if (m_opaque_up) {
+ proc_id = m_opaque_up->GetParentProcessID();
}
return proc_id;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBProcessInfo>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBProcessInfo, (const lldb::SBProcessInfo &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBProcessInfo &,
+ SBProcessInfo, operator=,(const lldb::SBProcessInfo &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBProcessInfo, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetName, ());
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBProcessInfo, GetExecutableFile,
+ ());
+ LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetProcessID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetUserID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetGroupID, ());
+ LLDB_REGISTER_METHOD(bool, SBProcessInfo, UserIDIsValid, ());
+ LLDB_REGISTER_METHOD(bool, SBProcessInfo, GroupIDIsValid, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveUserID, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBProcessInfo, GetEffectiveGroupID, ());
+ LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveUserIDIsValid, ());
+ LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveGroupIDIsValid, ());
+ LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetParentProcessID, ());
+}
+
+}
+}
diff --git a/source/API/SBQueue.cpp b/source/API/SBQueue.cpp
index b4a3cd0c52fb9..7d1581c42f60a 100644
--- a/source/API/SBQueue.cpp
+++ b/source/API/SBQueue.cpp
@@ -1,14 +1,14 @@
//===-- SBQueue.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <inttypes.h>
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBQueue.h"
#include "lldb/API/SBProcess.h"
@@ -19,7 +19,6 @@
#include "lldb/Target/Queue.h"
#include "lldb/Target/QueueItem.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
@@ -50,7 +49,7 @@ public:
~QueueImpl() {}
- bool IsValid() { return m_queue_wp.lock() != NULL; }
+ bool IsValid() { return m_queue_wp.lock() != nullptr; }
void Clear() {
m_queue_wp.reset();
@@ -71,10 +70,6 @@ public:
if (queue_sp) {
result = queue_sp->GetID();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(%p)::GetQueueID () => 0x%" PRIx64,
- static_cast<const void *>(this), result);
return result;
}
@@ -84,25 +79,15 @@ public:
if (queue_sp) {
result = queue_sp->GetIndexID();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueueImpl(%p)::GetIndexID () => %d",
- static_cast<const void *>(this), result);
return result;
}
const char *GetName() const {
- const char *name = NULL;
+ const char *name = nullptr;
lldb::QueueSP queue_sp = m_queue_wp.lock();
if (queue_sp.get()) {
name = queue_sp->GetName();
}
-
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueueImpl(%p)::GetName () => %s",
- static_cast<const void *>(this), name ? name : "NULL");
-
return name;
}
@@ -232,12 +217,18 @@ private:
};
}
-SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) {}
+SBQueue::SBQueue() : m_opaque_sp(new QueueImpl()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueue);
+}
SBQueue::SBQueue(const QueueSP &queue_sp)
- : m_opaque_sp(new QueueImpl(queue_sp)) {}
+ : m_opaque_sp(new QueueImpl(queue_sp)) {
+ LLDB_RECORD_CONSTRUCTOR(SBQueue, (const lldb::QueueSP &), queue_sp);
+}
SBQueue::SBQueue(const SBQueue &rhs) {
+ LLDB_RECORD_CONSTRUCTOR(SBQueue, (const lldb::SBQueue &), rhs);
+
if (&rhs == this)
return;
@@ -245,25 +236,28 @@ SBQueue::SBQueue(const SBQueue &rhs) {
}
const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBQueue &,
+ SBQueue, operator=,(const lldb::SBQueue &), rhs);
+
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBQueue::~SBQueue() {}
bool SBQueue::IsValid() const {
- bool is_valid = m_opaque_sp->IsValid();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::IsValid() == %s",
- m_opaque_sp->GetQueueID(), is_valid ? "true" : "false");
- return is_valid;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, IsValid);
+ return this->operator bool();
+}
+SBQueue::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, operator bool);
+
+ return m_opaque_sp->IsValid();
}
void SBQueue::Clear() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::Clear()", m_opaque_sp->GetQueueID());
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBQueue, Clear);
+
m_opaque_sp->Clear();
}
@@ -272,76 +266,94 @@ void SBQueue::SetQueue(const QueueSP &queue_sp) {
}
lldb::queue_id_t SBQueue::GetQueueID() const {
- lldb::queue_id_t qid = m_opaque_sp->GetQueueID();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetQueueID() == 0x%" PRIx64,
- m_opaque_sp->GetQueueID(), (uint64_t)qid);
- return qid;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBQueue, GetQueueID);
+
+ return m_opaque_sp->GetQueueID();
}
uint32_t SBQueue::GetIndexID() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBQueue, GetIndexID);
+
uint32_t index_id = m_opaque_sp->GetIndexID();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetIndexID() == 0x%" PRIx32,
- m_opaque_sp->GetQueueID(), index_id);
return index_id;
}
const char *SBQueue::GetName() const {
- const char *name = m_opaque_sp->GetName();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetName() == %s",
- m_opaque_sp->GetQueueID(), name ? name : "");
- return name;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBQueue, GetName);
+
+ return m_opaque_sp->GetName();
}
uint32_t SBQueue::GetNumThreads() {
- uint32_t numthreads = m_opaque_sp->GetNumThreads();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetNumThreads() == %d",
- m_opaque_sp->GetQueueID(), numthreads);
- return numthreads;
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumThreads);
+
+ return m_opaque_sp->GetNumThreads();
}
SBThread SBQueue::GetThreadAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBThread, SBQueue, GetThreadAtIndex, (uint32_t),
+ idx);
+
SBThread th = m_opaque_sp->GetThreadAtIndex(idx);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetThreadAtIndex(%d)",
- m_opaque_sp->GetQueueID(), idx);
- return th;
+ return LLDB_RECORD_RESULT(th);
}
uint32_t SBQueue::GetNumPendingItems() {
- uint32_t pending_items = m_opaque_sp->GetNumPendingItems();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetNumPendingItems() == %d",
- m_opaque_sp->GetQueueID(), pending_items);
- return pending_items;
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumPendingItems);
+
+ return m_opaque_sp->GetNumPendingItems();
}
SBQueueItem SBQueue::GetPendingItemAtIndex(uint32_t idx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetPendingItemAtIndex(%d)",
- m_opaque_sp->GetQueueID(), idx);
- return m_opaque_sp->GetPendingItemAtIndex(idx);
+ LLDB_RECORD_METHOD(lldb::SBQueueItem, SBQueue, GetPendingItemAtIndex,
+ (uint32_t), idx);
+
+ return LLDB_RECORD_RESULT(m_opaque_sp->GetPendingItemAtIndex(idx));
}
uint32_t SBQueue::GetNumRunningItems() {
- uint32_t running_items = m_opaque_sp->GetNumRunningItems();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueue(0x%" PRIx64 ")::GetNumRunningItems() == %d",
- m_opaque_sp->GetQueueID(), running_items);
- return running_items;
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBQueue, GetNumRunningItems);
+
+ return m_opaque_sp->GetNumRunningItems();
+}
+
+SBProcess SBQueue::GetProcess() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBQueue, GetProcess);
+
+ return LLDB_RECORD_RESULT(m_opaque_sp->GetProcess());
}
-SBProcess SBQueue::GetProcess() { return m_opaque_sp->GetProcess(); }
+lldb::QueueKind SBQueue::GetKind() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::QueueKind, SBQueue, GetKind);
-lldb::QueueKind SBQueue::GetKind() { return m_opaque_sp->GetKind(); }
+ return m_opaque_sp->GetKind();
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBQueue>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBQueue, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBQueue, (const lldb::QueueSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBQueue, (const lldb::SBQueue &));
+ LLDB_REGISTER_METHOD(const lldb::SBQueue &,
+ SBQueue, operator=,(const lldb::SBQueue &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBQueue, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBQueue, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBQueue, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBQueue, GetQueueID, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBQueue, GetIndexID, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBQueue, GetName, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumThreads, ());
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBQueue, GetThreadAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumPendingItems, ());
+ LLDB_REGISTER_METHOD(lldb::SBQueueItem, SBQueue, GetPendingItemAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBQueue, GetNumRunningItems, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBQueue, GetProcess, ());
+ LLDB_REGISTER_METHOD(lldb::QueueKind, SBQueue, GetKind, ());
+}
+
+}
+}
diff --git a/source/API/SBQueueItem.cpp b/source/API/SBQueueItem.cpp
index aac5844240fba..5f2cbd1bdbfb9 100644
--- a/source/API/SBQueueItem.cpp
+++ b/source/API/SBQueueItem.cpp
@@ -1,14 +1,14 @@
//===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/lldb-forward.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBQueueItem.h"
#include "lldb/API/SBThread.h"
@@ -16,93 +16,88 @@
#include "lldb/Target/Process.h"
#include "lldb/Target/QueueItem.h"
#include "lldb/Target/Thread.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Constructors
-//----------------------------------------------------------------------
-SBQueueItem::SBQueueItem() : m_queue_item_sp() {}
+SBQueueItem::SBQueueItem() : m_queue_item_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBQueueItem);
+}
SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp)
- : m_queue_item_sp(queue_item_sp) {}
+ : m_queue_item_sp(queue_item_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &),
+ queue_item_sp);
+}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); }
bool SBQueueItem::IsValid() const {
- bool is_valid = m_queue_item_sp.get() != NULL;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueueItem(%p)::IsValid() == %s",
- static_cast<void *>(m_queue_item_sp.get()),
- is_valid ? "true" : "false");
- return is_valid;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, IsValid);
+ return this->operator bool();
+}
+SBQueueItem::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, operator bool);
+
+ return m_queue_item_sp.get() != nullptr;
}
void SBQueueItem::Clear() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBQueueItem(%p)::Clear()",
- static_cast<void *>(m_queue_item_sp.get()));
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBQueueItem, Clear);
+
m_queue_item_sp.reset();
}
void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
+ LLDB_RECORD_METHOD(void, SBQueueItem, SetQueueItem,
+ (const lldb::QueueItemSP &), queue_item_sp);
+
m_queue_item_sp = queue_item_sp;
}
lldb::QueueItemKind SBQueueItem::GetKind() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::QueueItemKind, SBQueueItem, GetKind);
+
QueueItemKind result = eQueueItemKindUnknown;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (m_queue_item_sp) {
result = m_queue_item_sp->GetKind();
}
- if (log)
- log->Printf("SBQueueItem(%p)::GetKind() == %d",
- static_cast<void *>(m_queue_item_sp.get()),
- static_cast<int>(result));
return result;
}
void SBQueueItem::SetKind(lldb::QueueItemKind kind) {
+ LLDB_RECORD_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind), kind);
+
if (m_queue_item_sp) {
m_queue_item_sp->SetKind(kind);
}
}
SBAddress SBQueueItem::GetAddress() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBQueueItem, GetAddress);
+
SBAddress result;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (m_queue_item_sp) {
result.SetAddress(&m_queue_item_sp->GetAddress());
}
- if (log) {
- StreamString sstr;
- const Address *addr = result.get();
- if (addr)
- addr->Dump(&sstr, NULL, Address::DumpStyleModuleWithFileAddress,
- Address::DumpStyleInvalid, 4);
- log->Printf("SBQueueItem(%p)::GetAddress() == SBAddress(%p): %s",
- static_cast<void *>(m_queue_item_sp.get()),
- static_cast<void *>(result.get()), sstr.GetData());
- }
- return result;
+ return LLDB_RECORD_RESULT(result);
}
void SBQueueItem::SetAddress(SBAddress addr) {
+ LLDB_RECORD_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress), addr);
+
if (m_queue_item_sp) {
m_queue_item_sp->SetAddress(addr.ref());
}
}
SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) {
+ LLDB_RECORD_METHOD(lldb::SBThread, SBQueueItem, GetExtendedBacktraceThread,
+ (const char *), type);
+
SBThread result;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (m_queue_item_sp) {
ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
Process::StopLocker stop_locker;
@@ -115,19 +110,31 @@ SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) {
// retains the object
process_sp->GetExtendedThreadList().AddThread(thread_sp);
result.SetThread(thread_sp);
- if (log) {
- const char *queue_name = thread_sp->GetQueueName();
- if (queue_name == NULL)
- queue_name = "";
- log->Printf(
- "SBQueueItem(%p)::GetExtendedBacktraceThread() = new extended "
- "Thread created (%p) with queue_id 0x%" PRIx64 " queue name '%s'",
- static_cast<void *>(m_queue_item_sp.get()),
- static_cast<void *>(thread_sp.get()),
- static_cast<uint64_t>(thread_sp->GetQueueID()), queue_name);
- }
}
}
}
- return result;
+ return LLDB_RECORD_RESULT(result);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBQueueItem>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBQueueItem, Clear, ());
+ LLDB_REGISTER_METHOD(void, SBQueueItem, SetQueueItem,
+ (const lldb::QueueItemSP &));
+ LLDB_REGISTER_METHOD_CONST(lldb::QueueItemKind, SBQueueItem, GetKind, ());
+ LLDB_REGISTER_METHOD(void, SBQueueItem, SetKind, (lldb::QueueItemKind));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBQueueItem, GetAddress, ());
+ LLDB_REGISTER_METHOD(void, SBQueueItem, SetAddress, (lldb::SBAddress));
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBQueueItem,
+ GetExtendedBacktraceThread, (const char *));
+}
+
+}
}
diff --git a/source/API/SBReproducer.cpp b/source/API/SBReproducer.cpp
new file mode 100644
index 0000000000000..439ee5a704603
--- /dev/null
+++ b/source/API/SBReproducer.cpp
@@ -0,0 +1,153 @@
+//===-- SBReproducer.cpp ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "SBReproducerPrivate.h"
+
+#include "SBReproducerPrivate.h"
+#include "lldb/API/LLDB.h"
+#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBAttachInfo.h"
+#include "lldb/API/SBBlock.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBCommandInterpreter.h"
+#include "lldb/API/SBData.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBDeclaration.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBHostOS.h"
+#include "lldb/API/SBReproducer.h"
+
+#include "lldb/Host/FileSystem.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::repro;
+
+SBRegistry::SBRegistry() {
+ Registry& R = *this;
+
+ RegisterMethods<SBAddress>(R);
+ RegisterMethods<SBAttachInfo>(R);
+ RegisterMethods<SBBlock>(R);
+ RegisterMethods<SBBreakpoint>(R);
+ RegisterMethods<SBBreakpointList>(R);
+ RegisterMethods<SBBreakpointLocation>(R);
+ RegisterMethods<SBBreakpointName>(R);
+ RegisterMethods<SBBroadcaster>(R);
+ RegisterMethods<SBCommandInterpreterRunOptions>(R);
+ RegisterMethods<SBCommandReturnObject>(R);
+ RegisterMethods<SBCommunication>(R);
+ RegisterMethods<SBCompileUnit>(R);
+ RegisterMethods<SBData>(R);
+ RegisterMethods<SBInputReader>(R);
+ RegisterMethods<SBDebugger>(R);
+ RegisterMethods<SBDeclaration>(R);
+ RegisterMethods<SBError>(R);
+ RegisterMethods<SBEvent>(R);
+ RegisterMethods<SBExecutionContext>(R);
+ RegisterMethods<SBExpressionOptions>(R);
+ RegisterMethods<SBFileSpec>(R);
+ RegisterMethods<SBFileSpecList>(R);
+ RegisterMethods<SBFrame>(R);
+ RegisterMethods<SBFunction>(R);
+ RegisterMethods<SBHostOS>(R);
+ RegisterMethods<SBInstruction>(R);
+ RegisterMethods<SBInstructionList>(R);
+ RegisterMethods<SBLanguageRuntime>(R);
+ RegisterMethods<SBLaunchInfo>(R);
+ RegisterMethods<SBLineEntry>(R);
+ RegisterMethods<SBListener>(R);
+ RegisterMethods<SBMemoryRegionInfo>(R);
+ RegisterMethods<SBMemoryRegionInfoList>(R);
+ RegisterMethods<SBModule>(R);
+ RegisterMethods<SBModuleSpec>(R);
+ RegisterMethods<SBPlatformConnectOptions>(R);
+ RegisterMethods<SBPlatformShellCommand>(R);
+ RegisterMethods<SBPlatform>(R);
+ RegisterMethods<SBProcess>(R);
+ RegisterMethods<SBProcessInfo>(R);
+ RegisterMethods<SBQueue>(R);
+ RegisterMethods<SBQueueItem>(R);
+ RegisterMethods<SBSection>(R);
+ RegisterMethods<SBSourceManager>(R);
+ RegisterMethods<SBStream>(R);
+ RegisterMethods<SBStringList>(R);
+ RegisterMethods<SBStructuredData>(R);
+ RegisterMethods<SBSymbol>(R);
+ RegisterMethods<SBSymbolContext>(R);
+ RegisterMethods<SBSymbolContextList>(R);
+ RegisterMethods<SBTarget>(R);
+ RegisterMethods<SBThread>(R);
+ RegisterMethods<SBThreadCollection>(R);
+ RegisterMethods<SBThreadPlan>(R);
+ RegisterMethods<SBTrace>(R);
+ RegisterMethods<SBTraceOptions>(R);
+ RegisterMethods<SBType>(R);
+ RegisterMethods<SBTypeCategory>(R);
+ RegisterMethods<SBTypeEnumMember>(R);
+ RegisterMethods<SBTypeFilter>(R);
+ RegisterMethods<SBTypeFormat>(R);
+ RegisterMethods<SBTypeNameSpecifier>(R);
+ RegisterMethods<SBTypeSummaryOptions>(R);
+ RegisterMethods<SBTypeSummary>(R);
+ RegisterMethods<SBTypeSynthetic>(R);
+ RegisterMethods<SBUnixSignals>(R);
+ RegisterMethods<SBValue>(R);
+ RegisterMethods<SBValueList>(R);
+ RegisterMethods<SBVariablesOptions>(R);
+ RegisterMethods<SBWatchpoint>(R);
+}
+
+const char *SBReproducer::Capture() {
+ static std::string error;
+ if (auto e = Reproducer::Initialize(ReproducerMode::Capture, llvm::None)) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+ return nullptr;
+}
+
+const char *SBReproducer::Capture(const char *path) {
+ static std::string error;
+ if (auto e =
+ Reproducer::Initialize(ReproducerMode::Capture, FileSpec(path))) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+ return nullptr;
+}
+
+const char *SBReproducer::Replay(const char *path) {
+ static std::string error;
+ if (auto e = Reproducer::Initialize(ReproducerMode::Replay, FileSpec(path))) {
+ error = llvm::toString(std::move(e));
+ return error.c_str();
+ }
+
+ repro::Loader *loader = repro::Reproducer::Instance().GetLoader();
+ if (!loader) {
+ error = "unable to get replay loader.";
+ return error.c_str();
+ }
+
+ FileSpec file = loader->GetFile<SBProvider::Info>();
+ if (!file) {
+ error = "unable to get replay data from reproducer.";
+ return error.c_str();
+ }
+
+ SBRegistry registry;
+ registry.Replay(file);
+
+ return nullptr;
+}
+
+char lldb_private::repro::SBProvider::ID = 0;
+const char *SBProvider::Info::name = "sbapi";
+const char *SBProvider::Info::file = "sbapi.bin";
diff --git a/source/API/SBReproducerPrivate.h b/source/API/SBReproducerPrivate.h
new file mode 100644
index 0000000000000..84b6ce967c0be
--- /dev/null
+++ b/source/API/SBReproducerPrivate.h
@@ -0,0 +1,75 @@
+//===-- SBReproducerPrivate.h -----------------------------------*- C++ -*-===//
+//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SBREPRODUCER_PRIVATE_H
+#define LLDB_API_SBREPRODUCER_PRIVATE_H
+
+#include "lldb/API/SBReproducer.h"
+
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Reproducer.h"
+#include "lldb/Utility/ReproducerInstrumentation.h"
+
+#include "llvm/ADT/DenseMap.h"
+
+#define LLDB_GET_INSTRUMENTATION_DATA() \
+ lldb_private::repro::GetInstrumentationData()
+
+namespace lldb_private {
+namespace repro {
+
+class SBRegistry : public Registry {
+public:
+ SBRegistry();
+};
+
+class SBProvider : public Provider<SBProvider> {
+public:
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
+
+ SBProvider(const FileSpec &directory)
+ : Provider(directory),
+ m_stream(directory.CopyByAppendingPathComponent("sbapi.bin").GetPath(),
+ m_ec, llvm::sys::fs::OpenFlags::F_None),
+ m_serializer(m_stream) {}
+
+ Serializer &GetSerializer() { return m_serializer; }
+ Registry &GetRegistry() { return m_registry; }
+
+ static char ID;
+
+private:
+ std::error_code m_ec;
+ llvm::raw_fd_ostream m_stream;
+ Serializer m_serializer;
+ SBRegistry m_registry;
+};
+
+inline InstrumentationData GetInstrumentationData() {
+ if (!lldb_private::repro::Reproducer::Initialized())
+ return {};
+
+ if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) {
+ auto &p = g->GetOrCreate<SBProvider>();
+ return {p.GetSerializer(), p.GetRegistry()};
+ }
+
+ return {};
+}
+
+template <typename T> void RegisterMethods(Registry &R);
+
+} // namespace repro
+} // namespace lldb_private
+
+#endif
diff --git a/source/API/SBSection.cpp b/source/API/SBSection.cpp
index 7193857d1281e..14e1e14f59aa1 100644
--- a/source/API/SBSection.cpp
+++ b/source/API/SBSection.cpp
@@ -1,13 +1,13 @@
//===-- SBSection.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSection.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTarget.h"
#include "lldb/Core/Module.h"
@@ -15,15 +15,18 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb;
using namespace lldb_private;
-SBSection::SBSection() : m_opaque_wp() {}
+SBSection::SBSection() : m_opaque_wp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSection);
+}
-SBSection::SBSection(const SBSection &rhs) : m_opaque_wp(rhs.m_opaque_wp) {}
+SBSection::SBSection(const SBSection &rhs) : m_opaque_wp(rhs.m_opaque_wp) {
+ LLDB_RECORD_CONSTRUCTOR(SBSection, (const lldb::SBSection &), rhs);
+}
SBSection::SBSection(const lldb::SectionSP &section_sp)
: m_opaque_wp() // Don't init with section_sp otherwise this will throw if
@@ -34,25 +37,38 @@ SBSection::SBSection(const lldb::SectionSP &section_sp)
}
const SBSection &SBSection::operator=(const SBSection &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBSection &,
+ SBSection, operator=,(const lldb::SBSection &), rhs);
+
m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBSection::~SBSection() {}
bool SBSection::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, IsValid);
+ return this->operator bool();
+}
+SBSection::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, operator bool);
+
SectionSP section_sp(GetSP());
- return section_sp && section_sp->GetModule().get() != NULL;
+ return section_sp && section_sp->GetModule().get() != nullptr;
}
const char *SBSection::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBSection, GetName);
+
SectionSP section_sp(GetSP());
if (section_sp)
return section_sp->GetName().GetCString();
- return NULL;
+ return nullptr;
}
lldb::SBSection SBSection::GetParent() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSection, SBSection, GetParent);
+
lldb::SBSection sb_section;
SectionSP section_sp(GetSP());
if (section_sp) {
@@ -60,10 +76,13 @@ lldb::SBSection SBSection::GetParent() {
if (parent_section_sp)
sb_section.SetSP(parent_section_sp);
}
- return sb_section;
+ return LLDB_RECORD_RESULT(sb_section);
}
lldb::SBSection SBSection::FindSubSection(const char *sect_name) {
+ LLDB_RECORD_METHOD(lldb::SBSection, SBSection, FindSubSection, (const char *),
+ sect_name);
+
lldb::SBSection sb_section;
if (sect_name) {
SectionSP section_sp(GetSP());
@@ -73,10 +92,12 @@ lldb::SBSection SBSection::FindSubSection(const char *sect_name) {
section_sp->GetChildren().FindSectionByName(const_sect_name));
}
}
- return sb_section;
+ return LLDB_RECORD_RESULT(sb_section);
}
size_t SBSection::GetNumSubSections() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBSection, GetNumSubSections);
+
SectionSP section_sp(GetSP());
if (section_sp)
return section_sp->GetChildren().GetSize();
@@ -84,11 +105,14 @@ size_t SBSection::GetNumSubSections() {
}
lldb::SBSection SBSection::GetSubSectionAtIndex(size_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBSection, SBSection, GetSubSectionAtIndex, (size_t),
+ idx);
+
lldb::SBSection sb_section;
SectionSP section_sp(GetSP());
if (section_sp)
sb_section.SetSP(section_sp->GetChildren().GetSectionAtIndex(idx));
- return sb_section;
+ return LLDB_RECORD_RESULT(sb_section);
}
lldb::SectionSP SBSection::GetSP() const { return m_opaque_wp.lock(); }
@@ -98,6 +122,8 @@ void SBSection::SetSP(const lldb::SectionSP &section_sp) {
}
lldb::addr_t SBSection::GetFileAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBSection, GetFileAddress);
+
lldb::addr_t file_addr = LLDB_INVALID_ADDRESS;
SectionSP section_sp(GetSP());
if (section_sp)
@@ -106,6 +132,9 @@ lldb::addr_t SBSection::GetFileAddress() {
}
lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) {
+ LLDB_RECORD_METHOD(lldb::addr_t, SBSection, GetLoadAddress,
+ (lldb::SBTarget &), sb_target);
+
TargetSP target_sp(sb_target.GetSP());
if (target_sp) {
SectionSP section_sp(GetSP());
@@ -116,6 +145,8 @@ lldb::addr_t SBSection::GetLoadAddress(lldb::SBTarget &sb_target) {
}
lldb::addr_t SBSection::GetByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBSection, GetByteSize);
+
SectionSP section_sp(GetSP());
if (section_sp)
return section_sp->GetByteSize();
@@ -123,6 +154,8 @@ lldb::addr_t SBSection::GetByteSize() {
}
uint64_t SBSection::GetFileOffset() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBSection, GetFileOffset);
+
SectionSP section_sp(GetSP());
if (section_sp) {
ModuleSP module_sp(section_sp->GetModule());
@@ -136,15 +169,24 @@ uint64_t SBSection::GetFileOffset() {
}
uint64_t SBSection::GetFileByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBSection, GetFileByteSize);
+
SectionSP section_sp(GetSP());
if (section_sp)
return section_sp->GetFileSize();
return 0;
}
-SBData SBSection::GetSectionData() { return GetSectionData(0, UINT64_MAX); }
+SBData SBSection::GetSectionData() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBSection, GetSectionData);
+
+ return LLDB_RECORD_RESULT(GetSectionData(0, UINT64_MAX));
+}
SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) {
+ LLDB_RECORD_METHOD(lldb::SBData, SBSection, GetSectionData,
+ (uint64_t, uint64_t), offset, size);
+
SBData sb_data;
SectionSP section_sp(GetSP());
if (section_sp) {
@@ -178,26 +220,30 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) {
}
}
}
- return sb_data;
+ return LLDB_RECORD_RESULT(sb_data);
}
SectionType SBSection::GetSectionType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SectionType, SBSection, GetSectionType);
+
SectionSP section_sp(GetSP());
if (section_sp.get())
return section_sp->GetType();
return eSectionTypeInvalid;
}
-uint32_t
-SBSection::GetPermissions() const
-{
- SectionSP section_sp(GetSP());
- if (section_sp)
- return section_sp->GetPermissions();
- return 0;
+uint32_t SBSection::GetPermissions() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSection, GetPermissions);
+
+ SectionSP section_sp(GetSP());
+ if (section_sp)
+ return section_sp->GetPermissions();
+ return 0;
}
uint32_t SBSection::GetTargetByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBSection, GetTargetByteSize);
+
SectionSP section_sp(GetSP());
if (section_sp.get())
return section_sp->GetTargetByteSize();
@@ -205,6 +251,9 @@ uint32_t SBSection::GetTargetByteSize() {
}
bool SBSection::operator==(const SBSection &rhs) {
+ LLDB_RECORD_METHOD(bool, SBSection, operator==,(const lldb::SBSection &),
+ rhs);
+
SectionSP lhs_section_sp(GetSP());
SectionSP rhs_section_sp(rhs.GetSP());
if (lhs_section_sp && rhs_section_sp)
@@ -213,12 +262,18 @@ bool SBSection::operator==(const SBSection &rhs) {
}
bool SBSection::operator!=(const SBSection &rhs) {
+ LLDB_RECORD_METHOD(bool, SBSection, operator!=,(const lldb::SBSection &),
+ rhs);
+
SectionSP lhs_section_sp(GetSP());
SectionSP rhs_section_sp(rhs.GetSP());
return lhs_section_sp != rhs_section_sp;
}
bool SBSection::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBSection, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
SectionSP section_sp(GetSP());
@@ -233,3 +288,41 @@ bool SBSection::GetDescription(SBStream &description) {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBSection>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBSection, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBSection, (const lldb::SBSection &));
+ LLDB_REGISTER_METHOD(const lldb::SBSection &,
+ SBSection, operator=,(const lldb::SBSection &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBSection, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBSection, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBSection, GetName, ());
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, GetParent, ());
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, FindSubSection,
+ (const char *));
+ LLDB_REGISTER_METHOD(size_t, SBSection, GetNumSubSections, ());
+ LLDB_REGISTER_METHOD(lldb::SBSection, SBSection, GetSubSectionAtIndex,
+ (size_t));
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetFileAddress, ());
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetLoadAddress,
+ (lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBSection, GetByteSize, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBSection, GetFileOffset, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBSection, GetFileByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBData, SBSection, GetSectionData, ());
+ LLDB_REGISTER_METHOD(lldb::SBData, SBSection, GetSectionData,
+ (uint64_t, uint64_t));
+ LLDB_REGISTER_METHOD(lldb::SectionType, SBSection, GetSectionType, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBSection, GetPermissions, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBSection, GetTargetByteSize, ());
+ LLDB_REGISTER_METHOD(bool, SBSection, operator==,(const lldb::SBSection &));
+ LLDB_REGISTER_METHOD(bool, SBSection, operator!=,(const lldb::SBSection &));
+ LLDB_REGISTER_METHOD(bool, SBSection, GetDescription, (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBSourceManager.cpp b/source/API/SBSourceManager.cpp
index 1d47cc034e351..9c4ce3c7f4e3a 100644
--- a/source/API/SBSourceManager.cpp
+++ b/source/API/SBSourceManager.cpp
@@ -1,13 +1,13 @@
//===-- SBSourceManager.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSourceManager.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTarget.h"
@@ -72,24 +72,36 @@ using namespace lldb;
using namespace lldb_private;
SBSourceManager::SBSourceManager(const SBDebugger &debugger) {
- m_opaque_ap.reset(new SourceManagerImpl(debugger.get_sp()));
+ LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &),
+ debugger);
+
+ m_opaque_up.reset(new SourceManagerImpl(debugger.get_sp()));
}
SBSourceManager::SBSourceManager(const SBTarget &target) {
- m_opaque_ap.reset(new SourceManagerImpl(target.GetSP()));
+ LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target);
+
+ m_opaque_up.reset(new SourceManagerImpl(target.GetSP()));
}
SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
+ LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &),
+ rhs);
+
if (&rhs == this)
return;
- m_opaque_ap.reset(new SourceManagerImpl(*(rhs.m_opaque_ap.get())));
+ m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
}
const lldb::SBSourceManager &SBSourceManager::
operator=(const lldb::SBSourceManager &rhs) {
- m_opaque_ap.reset(new SourceManagerImpl(*(rhs.m_opaque_ap.get())));
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBSourceManager &,
+ SBSourceManager, operator=,(const lldb::SBSourceManager &),
+ rhs);
+
+ m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
+ return LLDB_RECORD_RESULT(*this);
}
SBSourceManager::~SBSourceManager() {}
@@ -97,6 +109,12 @@ SBSourceManager::~SBSourceManager() {}
size_t SBSourceManager::DisplaySourceLinesWithLineNumbers(
const SBFileSpec &file, uint32_t line, uint32_t context_before,
uint32_t context_after, const char *current_line_cstr, SBStream &s) {
+ LLDB_RECORD_METHOD(size_t, SBSourceManager, DisplaySourceLinesWithLineNumbers,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t,
+ const char *, lldb::SBStream &),
+ file, line, context_before, context_after,
+ current_line_cstr, s);
+
const uint32_t column = 0;
return DisplaySourceLinesWithLineNumbersAndColumn(
file.ref(), line, column, context_before, context_after,
@@ -107,10 +125,40 @@ size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn(
const SBFileSpec &file, uint32_t line, uint32_t column,
uint32_t context_before, uint32_t context_after,
const char *current_line_cstr, SBStream &s) {
- if (m_opaque_ap == NULL)
+ LLDB_RECORD_METHOD(
+ size_t, SBSourceManager, DisplaySourceLinesWithLineNumbersAndColumn,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t, uint32_t, uint32_t,
+ const char *, lldb::SBStream &),
+ file, line, column, context_before, context_after, current_line_cstr, s);
+
+ if (m_opaque_up == nullptr)
return 0;
- return m_opaque_ap->DisplaySourceLinesWithLineNumbers(
+ return m_opaque_up->DisplaySourceLinesWithLineNumbers(
file.ref(), line, column, context_before, context_after,
current_line_cstr, s.get());
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBSourceManager>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &));
+ LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &));
+ LLDB_REGISTER_CONSTRUCTOR(SBSourceManager, (const lldb::SBSourceManager &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBSourceManager &,
+ SBSourceManager, operator=,(const lldb::SBSourceManager &));
+ LLDB_REGISTER_METHOD(size_t, SBSourceManager,
+ DisplaySourceLinesWithLineNumbers,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+ uint32_t, const char *, lldb::SBStream &));
+ LLDB_REGISTER_METHOD(size_t, SBSourceManager,
+ DisplaySourceLinesWithLineNumbersAndColumn,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+ uint32_t, uint32_t, const char *, lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp
index 876ef02170d2f..ae652338e1ea5 100644
--- a/source/API/SBStream.cpp
+++ b/source/API/SBStream.cpp
@@ -1,14 +1,14 @@
//===-- SBStream.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBStream.h"
+#include "SBReproducerPrivate.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Utility/Status.h"
@@ -18,31 +18,45 @@
using namespace lldb;
using namespace lldb_private;
-SBStream::SBStream() : m_opaque_ap(new StreamString()), m_is_file(false) {}
+SBStream::SBStream() : m_opaque_up(new StreamString()), m_is_file(false) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStream);
+}
SBStream::SBStream(SBStream &&rhs)
- : m_opaque_ap(std::move(rhs.m_opaque_ap)), m_is_file(rhs.m_is_file) {}
+ : m_opaque_up(std::move(rhs.m_opaque_up)), m_is_file(rhs.m_is_file) {}
SBStream::~SBStream() {}
-bool SBStream::IsValid() const { return (m_opaque_ap != NULL); }
+bool SBStream::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, IsValid);
+ return this->operator bool();
+}
+SBStream::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, operator bool);
+
+ return (m_opaque_up != nullptr);
+}
// 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 *SBStream::GetData() {
- if (m_is_file || m_opaque_ap == NULL)
- return NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBStream, GetData);
+
+ if (m_is_file || m_opaque_up == nullptr)
+ return nullptr;
- return static_cast<StreamString *>(m_opaque_ap.get())->GetData();
+ return static_cast<StreamString *>(m_opaque_up.get())->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 SBStream::GetSize() {
- if (m_is_file || m_opaque_ap == NULL)
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBStream, GetSize);
+
+ if (m_is_file || m_opaque_up == nullptr)
return 0;
- return static_cast<StreamString *>(m_opaque_ap.get())->GetSize();
+ return static_cast<StreamString *>(m_opaque_up.get())->GetSize();
}
void SBStream::Printf(const char *format, ...) {
@@ -55,15 +69,18 @@ void SBStream::Printf(const char *format, ...) {
}
void SBStream::RedirectToFile(const char *path, bool append) {
+ LLDB_RECORD_METHOD(void, SBStream, RedirectToFile, (const char *, bool), path,
+ append);
+
if (path == nullptr)
return;
std::string local_data;
- if (m_opaque_ap) {
+ if (m_opaque_up) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_ap.get())->GetString();
+ local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
StreamFile *stream_file = new StreamFile;
uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate;
@@ -74,81 +91,108 @@ void SBStream::RedirectToFile(const char *path, bool append) {
FileSystem::Instance().Open(stream_file->GetFile(), FileSpec(path),
open_options);
- m_opaque_ap.reset(stream_file);
+ m_opaque_up.reset(stream_file);
- if (m_opaque_ap) {
+ if (m_opaque_up) {
m_is_file = true;
// If we had any data locally in our StreamString, then pass that along to
// the to new file we are redirecting to.
if (!local_data.empty())
- m_opaque_ap->Write(&local_data[0], local_data.size());
+ m_opaque_up->Write(&local_data[0], local_data.size());
} else
m_is_file = false;
}
void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) {
+ LLDB_RECORD_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool), fh,
+ transfer_fh_ownership);
+
if (fh == nullptr)
return;
std::string local_data;
- if (m_opaque_ap) {
+ if (m_opaque_up) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_ap.get())->GetString();
+ local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
- m_opaque_ap.reset(new StreamFile(fh, transfer_fh_ownership));
+ m_opaque_up.reset(new StreamFile(fh, transfer_fh_ownership));
- if (m_opaque_ap) {
+ if (m_opaque_up) {
m_is_file = true;
// If we had any data locally in our StreamString, then pass that along to
// the to new file we are redirecting to.
if (!local_data.empty())
- m_opaque_ap->Write(&local_data[0], local_data.size());
+ m_opaque_up->Write(&local_data[0], local_data.size());
} else
m_is_file = false;
}
void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) {
+ LLDB_RECORD_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool), fd,
+ transfer_fh_ownership);
+
std::string local_data;
- if (m_opaque_ap) {
+ if (m_opaque_up) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (!m_is_file)
- local_data = static_cast<StreamString *>(m_opaque_ap.get())->GetString();
+ local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString();
}
- m_opaque_ap.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership));
- if (m_opaque_ap) {
+ m_opaque_up.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership));
+ if (m_opaque_up) {
m_is_file = true;
// If we had any data locally in our StreamString, then pass that along to
// the to new file we are redirecting to.
if (!local_data.empty())
- m_opaque_ap->Write(&local_data[0], local_data.size());
+ m_opaque_up->Write(&local_data[0], local_data.size());
} else
m_is_file = false;
}
-lldb_private::Stream *SBStream::operator->() { return m_opaque_ap.get(); }
+lldb_private::Stream *SBStream::operator->() { return m_opaque_up.get(); }
-lldb_private::Stream *SBStream::get() { return m_opaque_ap.get(); }
+lldb_private::Stream *SBStream::get() { return m_opaque_up.get(); }
lldb_private::Stream &SBStream::ref() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new StreamString());
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new StreamString());
+ return *m_opaque_up;
}
void SBStream::Clear() {
- if (m_opaque_ap) {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBStream, Clear);
+
+ if (m_opaque_up) {
// See if we have any locally backed data. If so, copy it so we can then
// redirect it to the file so we don't lose the data
if (m_is_file)
- m_opaque_ap.reset();
+ m_opaque_up.reset();
else
- static_cast<StreamString *>(m_opaque_ap.get())->Clear();
+ static_cast<StreamString *>(m_opaque_up.get())->Clear();
}
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBStream>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBStream, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBStream, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBStream, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBStream, GetData, ());
+ LLDB_REGISTER_METHOD(size_t, SBStream, GetSize, ());
+ LLDB_REGISTER_METHOD(void, SBStream, RedirectToFile, (const char *, bool));
+ LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool));
+ LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool));
+ LLDB_REGISTER_METHOD(void, SBStream, Clear, ());
+}
+
+}
+}
diff --git a/source/API/SBStringList.cpp b/source/API/SBStringList.cpp
index 6ed4d4b7fb824..2f8bd55855a11 100644
--- a/source/API/SBStringList.cpp
+++ b/source/API/SBStringList.cpp
@@ -1,109 +1,163 @@
//===-- SBStringList.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBStringList.h"
-
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/Utility/StringList.h"
using namespace lldb;
using namespace lldb_private;
-SBStringList::SBStringList() : m_opaque_ap() {}
+SBStringList::SBStringList() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStringList);
+}
SBStringList::SBStringList(const lldb_private::StringList *lldb_strings_ptr)
- : m_opaque_ap() {
+ : m_opaque_up() {
if (lldb_strings_ptr)
- m_opaque_ap.reset(new lldb_private::StringList(*lldb_strings_ptr));
+ m_opaque_up = llvm::make_unique<StringList>(*lldb_strings_ptr);
}
-SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_ap() {
- if (rhs.IsValid())
- m_opaque_ap.reset(new lldb_private::StringList(*rhs));
+SBStringList::SBStringList(const SBStringList &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
const SBStringList &SBStringList::operator=(const SBStringList &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- m_opaque_ap.reset(new lldb_private::StringList(*rhs));
- else
- m_opaque_ap.reset();
- }
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBStringList &,
+ SBStringList, operator=,(const lldb::SBStringList &), rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
SBStringList::~SBStringList() {}
const lldb_private::StringList *SBStringList::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::StringList &SBStringList::operator*() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
-bool SBStringList::IsValid() const { return (m_opaque_ap != NULL); }
+bool SBStringList::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, IsValid);
+ return this->operator bool();
+}
+SBStringList::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStringList, operator bool);
+
+ return (m_opaque_up != nullptr);
+}
void SBStringList::AppendString(const char *str) {
- if (str != NULL) {
+ LLDB_RECORD_METHOD(void, SBStringList, AppendString, (const char *), str);
+
+ if (str != nullptr) {
if (IsValid())
- m_opaque_ap->AppendString(str);
+ m_opaque_up->AppendString(str);
else
- m_opaque_ap.reset(new lldb_private::StringList(str));
+ m_opaque_up.reset(new lldb_private::StringList(str));
}
}
void SBStringList::AppendList(const char **strv, int strc) {
- if ((strv != NULL) && (strc > 0)) {
+ LLDB_RECORD_METHOD(void, SBStringList, AppendList, (const char **, int), strv,
+ strc);
+
+ if ((strv != nullptr) && (strc > 0)) {
if (IsValid())
- m_opaque_ap->AppendList(strv, strc);
+ m_opaque_up->AppendList(strv, strc);
else
- m_opaque_ap.reset(new lldb_private::StringList(strv, strc));
+ m_opaque_up.reset(new lldb_private::StringList(strv, strc));
}
}
void SBStringList::AppendList(const SBStringList &strings) {
+ LLDB_RECORD_METHOD(void, SBStringList, AppendList,
+ (const lldb::SBStringList &), strings);
+
if (strings.IsValid()) {
if (!IsValid())
- m_opaque_ap.reset(new lldb_private::StringList());
- m_opaque_ap->AppendList(*(strings.m_opaque_ap));
+ m_opaque_up.reset(new lldb_private::StringList());
+ m_opaque_up->AppendList(*(strings.m_opaque_up));
}
}
void SBStringList::AppendList(const StringList &strings) {
if (!IsValid())
- m_opaque_ap.reset(new lldb_private::StringList());
- m_opaque_ap->AppendList(strings);
+ m_opaque_up.reset(new lldb_private::StringList());
+ m_opaque_up->AppendList(strings);
}
uint32_t SBStringList::GetSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBStringList, GetSize);
+
if (IsValid()) {
- return m_opaque_ap->GetSize();
+ return m_opaque_up->GetSize();
}
return 0;
}
const char *SBStringList::GetStringAtIndex(size_t idx) {
+ LLDB_RECORD_METHOD(const char *, SBStringList, GetStringAtIndex, (size_t),
+ idx);
+
if (IsValid()) {
- return m_opaque_ap->GetStringAtIndex(idx);
+ return m_opaque_up->GetStringAtIndex(idx);
}
- return NULL;
+ return nullptr;
}
const char *SBStringList::GetStringAtIndex(size_t idx) const {
+ LLDB_RECORD_METHOD_CONST(const char *, SBStringList, GetStringAtIndex,
+ (size_t), idx);
+
if (IsValid()) {
- return m_opaque_ap->GetStringAtIndex(idx);
+ return m_opaque_up->GetStringAtIndex(idx);
}
- return NULL;
+ return nullptr;
}
void SBStringList::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBStringList, Clear);
+
if (IsValid()) {
- m_opaque_ap->Clear();
+ m_opaque_up->Clear();
}
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBStringList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBStringList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBStringList, (const lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(const lldb::SBStringList &,
+ SBStringList, operator=,(const lldb::SBStringList &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBStringList, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBStringList, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBStringList, AppendString, (const char *));
+ LLDB_REGISTER_METHOD(void, SBStringList, AppendList, (const char **, int));
+ LLDB_REGISTER_METHOD(void, SBStringList, AppendList,
+ (const lldb::SBStringList &));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBStringList, GetSize, ());
+ LLDB_REGISTER_METHOD(const char *, SBStringList, GetStringAtIndex,
+ (size_t));
+ LLDB_REGISTER_METHOD_CONST(const char *, SBStringList, GetStringAtIndex,
+ (size_t));
+ LLDB_REGISTER_METHOD(void, SBStringList, Clear, ());
+}
+
+}
+}
diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp
index 277193424e99b..6b973e82c858b 100644
--- a/source/API/SBStructuredData.cpp
+++ b/source/API/SBStructuredData.cpp
@@ -1,13 +1,13 @@
//===-- SBStructuredData.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBStructuredData.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
@@ -24,26 +24,43 @@ using namespace lldb_private;
#pragma mark--
#pragma mark SBStructuredData
-SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) {}
+SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStructuredData);
+}
SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs)
- : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) {}
+ : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) {
+ LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &),
+ rhs);
+}
SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp)
- : m_impl_up(new StructuredDataImpl(event_sp)) {}
+ : m_impl_up(new StructuredDataImpl(event_sp)) {
+ LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &), event_sp);
+}
SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl)
- : m_impl_up(impl) {}
+ : m_impl_up(impl) {
+ LLDB_RECORD_CONSTRUCTOR(SBStructuredData,
+ (lldb_private::StructuredDataImpl *), impl);
+}
SBStructuredData::~SBStructuredData() {}
SBStructuredData &SBStructuredData::
operator=(const lldb::SBStructuredData &rhs) {
+ LLDB_RECORD_METHOD(
+ lldb::SBStructuredData &,
+ SBStructuredData, operator=,(const lldb::SBStructuredData &), rhs);
+
*m_impl_up = *rhs.m_impl_up;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBStructuredData, SetFromJSON,
+ (lldb::SBStream &), stream);
+
lldb::SBError error;
std::string json_str(stream.GetData());
@@ -52,35 +69,61 @@ lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) {
if (!json_obj || json_obj->GetType() != eStructuredDataTypeDictionary)
error.SetErrorString("Invalid Syntax");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
-bool SBStructuredData::IsValid() const { return m_impl_up->IsValid(); }
+bool SBStructuredData::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, IsValid);
+ return this->operator bool();
+}
+SBStructuredData::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, operator bool);
+
+ return m_impl_up->IsValid();
+}
-void SBStructuredData::Clear() { m_impl_up->Clear(); }
+void SBStructuredData::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBStructuredData, Clear);
+
+ m_impl_up->Clear();
+}
SBError SBStructuredData::GetAsJSON(lldb::SBStream &stream) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON,
+ (lldb::SBStream &), stream);
+
SBError error;
error.SetError(m_impl_up->GetAsJSON(stream.ref()));
- return error;
+ return LLDB_RECORD_RESULT(error);
}
lldb::SBError SBStructuredData::GetDescription(lldb::SBStream &stream) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription,
+ (lldb::SBStream &), stream);
+
Status error = m_impl_up->GetDescription(stream.ref());
SBError sb_error;
sb_error.SetError(error);
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
StructuredDataType SBStructuredData::GetType() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::StructuredDataType, SBStructuredData,
+ GetType);
+
return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid);
}
size_t SBStructuredData::GetSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBStructuredData, GetSize);
+
return (m_impl_up ? m_impl_up->GetSize() : 0);
}
bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetKeys,
+ (lldb::SBStringList &), keys);
+
if (!m_impl_up)
return false;
@@ -108,35 +151,97 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
}
lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData,
+ GetValueForKey, (const char *), key);
+
if (!m_impl_up)
- return SBStructuredData();
+ return LLDB_RECORD_RESULT(SBStructuredData());
SBStructuredData result;
result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key));
- return result;
+ return LLDB_RECORD_RESULT(result);
}
lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData,
+ GetItemAtIndex, (size_t), idx);
+
if (!m_impl_up)
- return SBStructuredData();
+ return LLDB_RECORD_RESULT(SBStructuredData());
SBStructuredData result;
result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx));
- return result;
+ return LLDB_RECORD_RESULT(result);
}
uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const {
+ LLDB_RECORD_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue,
+ (uint64_t), fail_value);
+
return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value);
}
double SBStructuredData::GetFloatValue(double fail_value) const {
+ LLDB_RECORD_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double),
+ fail_value);
+
return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value);
}
bool SBStructuredData::GetBooleanValue(bool fail_value) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool),
+ fail_value);
+
return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value);
}
size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
+ LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
+ (char *, size_t), dst, dst_len);
+
return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBStructuredData>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBStructuredData,
+ (const lldb::SBStructuredData &));
+ LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBStructuredData,
+ (lldb_private::StructuredDataImpl *));
+ LLDB_REGISTER_METHOD(
+ lldb::SBStructuredData &,
+ SBStructuredData, operator=,(const lldb::SBStructuredData &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBStructuredData, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetAsJSON,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBError, SBStructuredData, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(lldb::StructuredDataType, SBStructuredData,
+ GetType, ());
+ LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetSize, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetKeys,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData,
+ GetValueForKey, (const char *));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBStructuredData,
+ GetItemAtIndex, (size_t));
+ LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue,
+ (uint64_t));
+ LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue,
+ (double));
+ LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool));
+ LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
+ (char *, size_t));
+}
+
+}
+}
diff --git a/source/API/SBSymbol.cpp b/source/API/SBSymbol.cpp
index 5be20a124982b..6cc90e0ee368b 100644
--- a/source/API/SBSymbol.cpp
+++ b/source/API/SBSymbol.cpp
@@ -1,96 +1,111 @@
//===-- SBSymbol.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSymbol.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-SBSymbol::SBSymbol() : m_opaque_ptr(NULL) {}
+SBSymbol::SBSymbol() : m_opaque_ptr(nullptr) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbol);
+}
SBSymbol::SBSymbol(lldb_private::Symbol *lldb_object_ptr)
: m_opaque_ptr(lldb_object_ptr) {}
-SBSymbol::SBSymbol(const lldb::SBSymbol &rhs)
- : m_opaque_ptr(rhs.m_opaque_ptr) {}
+SBSymbol::SBSymbol(const lldb::SBSymbol &rhs) : m_opaque_ptr(rhs.m_opaque_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBSymbol, (const lldb::SBSymbol &), rhs);
+}
const SBSymbol &SBSymbol::operator=(const SBSymbol &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBSymbol &,
+ SBSymbol, operator=,(const lldb::SBSymbol &), rhs);
+
m_opaque_ptr = rhs.m_opaque_ptr;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-SBSymbol::~SBSymbol() { m_opaque_ptr = NULL; }
+SBSymbol::~SBSymbol() { m_opaque_ptr = nullptr; }
void SBSymbol::SetSymbol(lldb_private::Symbol *lldb_object_ptr) {
m_opaque_ptr = lldb_object_ptr;
}
-bool SBSymbol::IsValid() const { return m_opaque_ptr != NULL; }
+bool SBSymbol::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbol, IsValid);
+ return this->operator bool();
+}
+SBSymbol::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbol, operator bool);
+
+ return m_opaque_ptr != nullptr;
+}
const char *SBSymbol::GetName() const {
- const char *name = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetName);
+
+ const char *name = nullptr;
if (m_opaque_ptr)
name = m_opaque_ptr->GetName().AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBSymbol(%p)::GetName () => \"%s\"",
- static_cast<void *>(m_opaque_ptr), name ? name : "");
return name;
}
const char *SBSymbol::GetDisplayName() const {
- const char *name = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetDisplayName);
+
+ const char *name = nullptr;
if (m_opaque_ptr)
name = m_opaque_ptr->GetMangled()
.GetDisplayDemangledName(m_opaque_ptr->GetLanguage())
.AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBSymbol(%p)::GetDisplayName () => \"%s\"",
- static_cast<void *>(m_opaque_ptr), name ? name : "");
return name;
}
const char *SBSymbol::GetMangledName() const {
- const char *name = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBSymbol, GetMangledName);
+
+ const char *name = nullptr;
if (m_opaque_ptr)
name = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBSymbol(%p)::GetMangledName () => \"%s\"",
- static_cast<void *>(m_opaque_ptr), name ? name : "");
-
return name;
}
bool SBSymbol::operator==(const SBSymbol &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBSymbol, operator==,(const lldb::SBSymbol &),
+ rhs);
+
return m_opaque_ptr == rhs.m_opaque_ptr;
}
bool SBSymbol::operator!=(const SBSymbol &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBSymbol, operator!=,(const lldb::SBSymbol &),
+ rhs);
+
return m_opaque_ptr != rhs.m_opaque_ptr;
}
bool SBSymbol::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBSymbol, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
if (m_opaque_ptr) {
- m_opaque_ptr->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
+ m_opaque_ptr->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr);
} else
strm.PutCString("No value");
@@ -98,11 +113,17 @@ bool SBSymbol::GetDescription(SBStream &description) {
}
SBInstructionList SBSymbol::GetInstructions(SBTarget target) {
- return GetInstructions(target, NULL);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions,
+ (lldb::SBTarget), target);
+
+ return LLDB_RECORD_RESULT(GetInstructions(target, nullptr));
}
SBInstructionList SBSymbol::GetInstructions(SBTarget target,
const char *flavor_string) {
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions,
+ (lldb::SBTarget, const char *), target, flavor_string);
+
SBInstructionList sb_instructions;
if (m_opaque_ptr) {
ExecutionContext exe_ctx;
@@ -120,12 +141,12 @@ SBInstructionList SBSymbol::GetInstructions(SBTarget target,
AddressRange symbol_range(symbol_addr, m_opaque_ptr->GetByteSize());
const bool prefer_file_cache = false;
sb_instructions.SetDisassembler(Disassembler::DisassembleRange(
- module_sp->GetArchitecture(), NULL, flavor_string, exe_ctx,
+ module_sp->GetArchitecture(), nullptr, flavor_string, exe_ctx,
symbol_range, prefer_file_cache));
}
}
}
- return sb_instructions;
+ return LLDB_RECORD_RESULT(sb_instructions);
}
lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; }
@@ -133,14 +154,18 @@ lldb_private::Symbol *SBSymbol::get() { return m_opaque_ptr; }
void SBSymbol::reset(lldb_private::Symbol *symbol) { m_opaque_ptr = symbol; }
SBAddress SBSymbol::GetStartAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBSymbol, GetStartAddress);
+
SBAddress addr;
if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) {
addr.SetAddress(&m_opaque_ptr->GetAddressRef());
}
- return addr;
+ return LLDB_RECORD_RESULT(addr);
}
SBAddress SBSymbol::GetEndAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBSymbol, GetEndAddress);
+
SBAddress addr;
if (m_opaque_ptr && m_opaque_ptr->ValueIsAddress()) {
lldb::addr_t range_size = m_opaque_ptr->GetByteSize();
@@ -149,29 +174,71 @@ SBAddress SBSymbol::GetEndAddress() {
addr->Slide(m_opaque_ptr->GetByteSize());
}
}
- return addr;
+ return LLDB_RECORD_RESULT(addr);
}
uint32_t SBSymbol::GetPrologueByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBSymbol, GetPrologueByteSize);
+
if (m_opaque_ptr)
return m_opaque_ptr->GetPrologueByteSize();
return 0;
}
SymbolType SBSymbol::GetType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SymbolType, SBSymbol, GetType);
+
if (m_opaque_ptr)
return m_opaque_ptr->GetType();
return eSymbolTypeInvalid;
}
bool SBSymbol::IsExternal() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBSymbol, IsExternal);
+
if (m_opaque_ptr)
return m_opaque_ptr->IsExternal();
return false;
}
bool SBSymbol::IsSynthetic() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBSymbol, IsSynthetic);
+
if (m_opaque_ptr)
return m_opaque_ptr->IsSynthetic();
return false;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBSymbol>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbol, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbol, (const lldb::SBSymbol &));
+ LLDB_REGISTER_METHOD(const lldb::SBSymbol &,
+ SBSymbol, operator=,(const lldb::SBSymbol &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBSymbol, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBSymbol, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetName, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetDisplayName, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBSymbol, GetMangledName, ());
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBSymbol, operator==,(const lldb::SBSymbol &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBSymbol, operator!=,(const lldb::SBSymbol &));
+ LLDB_REGISTER_METHOD(bool, SBSymbol, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions,
+ (lldb::SBTarget));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBSymbol, GetInstructions,
+ (lldb::SBTarget, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBSymbol, GetStartAddress, ());
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBSymbol, GetEndAddress, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBSymbol, GetPrologueByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::SymbolType, SBSymbol, GetType, ());
+ LLDB_REGISTER_METHOD(bool, SBSymbol, IsExternal, ());
+ LLDB_REGISTER_METHOD(bool, SBSymbol, IsSynthetic, ());
+}
+
+}
+}
diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp
index ab70c6f6ca68f..365f0ccc2fbf1 100644
--- a/source/API/SBSymbolContext.cpp
+++ b/source/API/SBSymbolContext.cpp
@@ -1,161 +1,166 @@
//===-- SBSymbolContext.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSymbolContext.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
-#include "lldb/Utility/Log.h"
using namespace lldb;
using namespace lldb_private;
-SBSymbolContext::SBSymbolContext() : m_opaque_ap() {}
+SBSymbolContext::SBSymbolContext() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContext);
+}
+
+SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBSymbolContext,
+ (const lldb_private::SymbolContext *), sc_ptr);
-SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_ap() {
if (sc_ptr)
- m_opaque_ap.reset(new SymbolContext(*sc_ptr));
+ m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr);
}
-SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_ap() {
- if (rhs.IsValid()) {
- if (m_opaque_ap)
- *m_opaque_ap = *rhs.m_opaque_ap;
- else
- ref() = *rhs.m_opaque_ap;
- }
+SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBSymbolContext, (const lldb::SBSymbolContext &),
+ rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBSymbolContext::~SBSymbolContext() {}
const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- m_opaque_ap.reset(new lldb_private::SymbolContext(*rhs.m_opaque_ap));
- }
- return *this;
+ LLDB_RECORD_METHOD(const lldb::SBSymbolContext &,
+ SBSymbolContext, operator=,(const lldb::SBSymbolContext &),
+ rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) {
- if (sc_ptr) {
- if (m_opaque_ap)
- *m_opaque_ap = *sc_ptr;
- else
- m_opaque_ap.reset(new SymbolContext(*sc_ptr));
- } else {
- if (m_opaque_ap)
- m_opaque_ap->Clear(true);
- }
+ if (sc_ptr)
+ m_opaque_up = llvm::make_unique<SymbolContext>(*sc_ptr);
+ else
+ m_opaque_up->Clear(true);
+}
+
+bool SBSymbolContext::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContext, IsValid);
+ return this->operator bool();
}
+SBSymbolContext::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContext, operator bool);
-bool SBSymbolContext::IsValid() const { return m_opaque_ap != NULL; }
+ return m_opaque_up != nullptr;
+}
SBModule SBSymbolContext::GetModule() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBModule, SBSymbolContext, GetModule);
SBModule sb_module;
ModuleSP module_sp;
- if (m_opaque_ap) {
- module_sp = m_opaque_ap->module_sp;
+ if (m_opaque_up) {
+ module_sp = m_opaque_up->module_sp;
sb_module.SetSP(module_sp);
}
- if (log) {
- SBStream sstr;
- sb_module.GetDescription(sstr);
- log->Printf("SBSymbolContext(%p)::GetModule () => SBModule(%p): %s",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<void *>(module_sp.get()), sstr.GetData());
- }
-
- return sb_module;
+ return LLDB_RECORD_RESULT(sb_module);
}
SBCompileUnit SBSymbolContext::GetCompileUnit() {
- return SBCompileUnit(m_opaque_ap ? m_opaque_ap->comp_unit : NULL);
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBCompileUnit, SBSymbolContext,
+ GetCompileUnit);
+
+ return LLDB_RECORD_RESULT(
+ SBCompileUnit(m_opaque_up ? m_opaque_up->comp_unit : nullptr));
}
SBFunction SBSymbolContext::GetFunction() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFunction, SBSymbolContext, GetFunction);
- Function *function = NULL;
+ Function *function = nullptr;
- if (m_opaque_ap)
- function = m_opaque_ap->function;
+ if (m_opaque_up)
+ function = m_opaque_up->function;
SBFunction sb_function(function);
- if (log)
- log->Printf("SBSymbolContext(%p)::GetFunction () => SBFunction(%p)",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<void *>(function));
-
- return sb_function;
+ return LLDB_RECORD_RESULT(sb_function);
}
SBBlock SBSymbolContext::GetBlock() {
- return SBBlock(m_opaque_ap ? m_opaque_ap->block : NULL);
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBlock, SBSymbolContext, GetBlock);
+
+ return LLDB_RECORD_RESULT(
+ SBBlock(m_opaque_up ? m_opaque_up->block : nullptr));
}
SBLineEntry SBSymbolContext::GetLineEntry() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBLineEntry, SBSymbolContext, GetLineEntry);
SBLineEntry sb_line_entry;
- if (m_opaque_ap)
- sb_line_entry.SetLineEntry(m_opaque_ap->line_entry);
-
- if (log) {
- log->Printf("SBSymbolContext(%p)::GetLineEntry () => SBLineEntry(%p)",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<void *>(sb_line_entry.get()));
- }
+ if (m_opaque_up)
+ sb_line_entry.SetLineEntry(m_opaque_up->line_entry);
- return sb_line_entry;
+ return LLDB_RECORD_RESULT(sb_line_entry);
}
SBSymbol SBSymbolContext::GetSymbol() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSymbol, SBSymbolContext, GetSymbol);
- Symbol *symbol = NULL;
+ Symbol *symbol = nullptr;
- if (m_opaque_ap)
- symbol = m_opaque_ap->symbol;
+ if (m_opaque_up)
+ symbol = m_opaque_up->symbol;
SBSymbol sb_symbol(symbol);
- if (log)
- log->Printf("SBSymbolContext(%p)::GetSymbol () => SBSymbol(%p)",
- static_cast<void *>(m_opaque_ap.get()),
- static_cast<void *>(symbol));
-
- return sb_symbol;
+ return LLDB_RECORD_RESULT(sb_symbol);
}
void SBSymbolContext::SetModule(lldb::SBModule module) {
+ LLDB_RECORD_METHOD(void, SBSymbolContext, SetModule, (lldb::SBModule),
+ module);
+
ref().module_sp = module.GetSP();
}
void SBSymbolContext::SetCompileUnit(lldb::SBCompileUnit compile_unit) {
+ LLDB_RECORD_METHOD(void, SBSymbolContext, SetCompileUnit,
+ (lldb::SBCompileUnit), compile_unit);
+
ref().comp_unit = compile_unit.get();
}
void SBSymbolContext::SetFunction(lldb::SBFunction function) {
+ LLDB_RECORD_METHOD(void, SBSymbolContext, SetFunction, (lldb::SBFunction),
+ function);
+
ref().function = function.get();
}
void SBSymbolContext::SetBlock(lldb::SBBlock block) {
+ LLDB_RECORD_METHOD(void, SBSymbolContext, SetBlock, (lldb::SBBlock), block);
+
ref().block = block.GetPtr();
}
void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) {
+ LLDB_RECORD_METHOD(void, SBSymbolContext, SetLineEntry, (lldb::SBLineEntry),
+ line_entry);
+
if (line_entry.IsValid())
ref().line_entry = line_entry.ref();
else
@@ -163,39 +168,45 @@ void SBSymbolContext::SetLineEntry(lldb::SBLineEntry line_entry) {
}
void SBSymbolContext::SetSymbol(lldb::SBSymbol symbol) {
+ LLDB_RECORD_METHOD(void, SBSymbolContext, SetSymbol, (lldb::SBSymbol),
+ symbol);
+
ref().symbol = symbol.get();
}
lldb_private::SymbolContext *SBSymbolContext::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::SymbolContext &SBSymbolContext::operator*() const {
- assert(m_opaque_ap.get());
- return *m_opaque_ap;
+ assert(m_opaque_up.get());
+ return *m_opaque_up;
}
lldb_private::SymbolContext &SBSymbolContext::operator*() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new SymbolContext);
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new SymbolContext);
+ return *m_opaque_up;
}
lldb_private::SymbolContext &SBSymbolContext::ref() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new SymbolContext);
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new SymbolContext);
+ return *m_opaque_up;
}
lldb_private::SymbolContext *SBSymbolContext::get() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
bool SBSymbolContext::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBSymbolContext, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
- if (m_opaque_ap) {
- m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
+ if (m_opaque_up) {
+ m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr);
} else
strm.PutCString("No value");
@@ -205,11 +216,56 @@ bool SBSymbolContext::GetDescription(SBStream &description) {
SBSymbolContext
SBSymbolContext::GetParentOfInlinedScope(const SBAddress &curr_frame_pc,
SBAddress &parent_frame_addr) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBSymbolContext, SBSymbolContext,
+ GetParentOfInlinedScope,
+ (const lldb::SBAddress &, lldb::SBAddress &),
+ curr_frame_pc, parent_frame_addr);
+
SBSymbolContext sb_sc;
- if (m_opaque_ap.get() && curr_frame_pc.IsValid()) {
- if (m_opaque_ap->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(),
+ if (m_opaque_up.get() && curr_frame_pc.IsValid()) {
+ if (m_opaque_up->GetParentOfInlinedScope(curr_frame_pc.ref(), sb_sc.ref(),
parent_frame_addr.ref()))
- return sb_sc;
+ return LLDB_RECORD_RESULT(sb_sc);
}
- return SBSymbolContext();
+ return LLDB_RECORD_RESULT(SBSymbolContext());
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBSymbolContext>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext,
+ (const lldb_private::SymbolContext *));
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbolContext, (const lldb::SBSymbolContext &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBSymbolContext &,
+ SBSymbolContext, operator=,(const lldb::SBSymbolContext &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContext, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBSymbolContext, GetModule, ());
+ LLDB_REGISTER_METHOD(lldb::SBCompileUnit, SBSymbolContext, GetCompileUnit,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBFunction, SBSymbolContext, GetFunction, ());
+ LLDB_REGISTER_METHOD(lldb::SBBlock, SBSymbolContext, GetBlock, ());
+ LLDB_REGISTER_METHOD(lldb::SBLineEntry, SBSymbolContext, GetLineEntry, ());
+ LLDB_REGISTER_METHOD(lldb::SBSymbol, SBSymbolContext, GetSymbol, ());
+ LLDB_REGISTER_METHOD(void, SBSymbolContext, SetModule, (lldb::SBModule));
+ LLDB_REGISTER_METHOD(void, SBSymbolContext, SetCompileUnit,
+ (lldb::SBCompileUnit));
+ LLDB_REGISTER_METHOD(void, SBSymbolContext, SetFunction,
+ (lldb::SBFunction));
+ LLDB_REGISTER_METHOD(void, SBSymbolContext, SetBlock, (lldb::SBBlock));
+ LLDB_REGISTER_METHOD(void, SBSymbolContext, SetLineEntry,
+ (lldb::SBLineEntry));
+ LLDB_REGISTER_METHOD(void, SBSymbolContext, SetSymbol, (lldb::SBSymbol));
+ LLDB_REGISTER_METHOD(bool, SBSymbolContext, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBSymbolContext, SBSymbolContext,
+ GetParentOfInlinedScope,
+ (const lldb::SBAddress &, lldb::SBAddress &));
+}
+
+}
}
diff --git a/source/API/SBSymbolContextList.cpp b/source/API/SBSymbolContextList.cpp
index b07ab2afd554c..915d04a0282a2 100644
--- a/source/API/SBSymbolContextList.cpp
+++ b/source/API/SBSymbolContextList.cpp
@@ -1,13 +1,14 @@
//===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBSymbolContextList.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -15,67 +16,129 @@ using namespace lldb;
using namespace lldb_private;
SBSymbolContextList::SBSymbolContextList()
- : m_opaque_ap(new SymbolContextList()) {}
+ : m_opaque_up(new SymbolContextList()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbolContextList);
+}
SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs)
- : m_opaque_ap(new SymbolContextList(*rhs.m_opaque_ap)) {}
+ : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBSymbolContextList,
+ (const lldb::SBSymbolContextList &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
+}
SBSymbolContextList::~SBSymbolContextList() {}
const SBSymbolContextList &SBSymbolContextList::
operator=(const SBSymbolContextList &rhs) {
- if (this != &rhs) {
- *m_opaque_ap = *rhs.m_opaque_ap;
- }
- return *this;
+ LLDB_RECORD_METHOD(
+ const lldb::SBSymbolContextList &,
+ SBSymbolContextList, operator=,(const lldb::SBSymbolContextList &), rhs);
+
+ if (this != &rhs)
+ m_opaque_up = clone(rhs.m_opaque_up);
+ return LLDB_RECORD_RESULT(*this);
}
uint32_t SBSymbolContextList::GetSize() const {
- if (m_opaque_ap)
- return m_opaque_ap->GetSize();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBSymbolContextList, GetSize);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetSize();
return 0;
}
SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBSymbolContextList,
+ GetContextAtIndex, (uint32_t), idx);
+
SBSymbolContext sb_sc;
- if (m_opaque_ap) {
+ if (m_opaque_up) {
SymbolContext sc;
- if (m_opaque_ap->GetContextAtIndex(idx, sc)) {
+ if (m_opaque_up->GetContextAtIndex(idx, sc)) {
sb_sc.SetSymbolContext(&sc);
}
}
- return sb_sc;
+ return LLDB_RECORD_RESULT(sb_sc);
}
void SBSymbolContextList::Clear() {
- if (m_opaque_ap)
- m_opaque_ap->Clear();
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBSymbolContextList, Clear);
+
+ if (m_opaque_up)
+ m_opaque_up->Clear();
}
void SBSymbolContextList::Append(SBSymbolContext &sc) {
- if (sc.IsValid() && m_opaque_ap.get())
- m_opaque_ap->Append(*sc);
+ LLDB_RECORD_METHOD(void, SBSymbolContextList, Append,
+ (lldb::SBSymbolContext &), sc);
+
+ if (sc.IsValid() && m_opaque_up.get())
+ m_opaque_up->Append(*sc);
}
void SBSymbolContextList::Append(SBSymbolContextList &sc_list) {
- if (sc_list.IsValid() && m_opaque_ap.get())
- m_opaque_ap->Append(*sc_list);
+ LLDB_RECORD_METHOD(void, SBSymbolContextList, Append,
+ (lldb::SBSymbolContextList &), sc_list);
+
+ if (sc_list.IsValid() && m_opaque_up.get())
+ m_opaque_up->Append(*sc_list);
}
-bool SBSymbolContextList::IsValid() const { return m_opaque_ap != NULL; }
+bool SBSymbolContextList::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList, IsValid);
+ return this->operator bool();
+}
+SBSymbolContextList::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSymbolContextList, operator bool);
+
+ return m_opaque_up != nullptr;
+}
lldb_private::SymbolContextList *SBSymbolContextList::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
lldb_private::SymbolContextList &SBSymbolContextList::operator*() const {
- assert(m_opaque_ap.get());
- return *m_opaque_ap;
+ assert(m_opaque_up.get());
+ return *m_opaque_up;
}
bool SBSymbolContextList::GetDescription(lldb::SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBSymbolContextList, GetDescription,
+ (lldb::SBStream &), description);
+
Stream &strm = description.ref();
- if (m_opaque_ap)
- m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL);
+ if (m_opaque_up)
+ m_opaque_up->GetDescription(&strm, lldb::eDescriptionLevelFull, nullptr);
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBSymbolContextList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBSymbolContextList,
+ (const lldb::SBSymbolContextList &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBSymbolContextList &,
+ SBSymbolContextList, operator=,(const lldb::SBSymbolContextList &));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBSymbolContextList, GetSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBSymbolContextList,
+ GetContextAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBSymbolContextList, Clear, ());
+ LLDB_REGISTER_METHOD(void, SBSymbolContextList, Append,
+ (lldb::SBSymbolContext &));
+ LLDB_REGISTER_METHOD(void, SBSymbolContextList, Append,
+ (lldb::SBSymbolContextList &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBSymbolContextList, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBSymbolContextList, GetDescription,
+ (lldb::SBStream &));
+}
+
+}
+}
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 98587e7d7677c..5e87eb6273b3d 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -1,13 +1,13 @@
//===-- SBTarget.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTarget.h"
+#include "SBReproducerPrivate.h"
#include "lldb/lldb-public.h"
@@ -53,7 +53,6 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -61,7 +60,7 @@
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/RegularExpression.h"
#include "Commands/CommandObjectBreakpoint.h"
@@ -97,35 +96,50 @@ Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
} // namespace
-//----------------------------------------------------------------------
// SBTarget constructor
-//----------------------------------------------------------------------
-SBTarget::SBTarget() : m_opaque_sp() {}
+SBTarget::SBTarget() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTarget);
+}
-SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {}
+SBTarget::SBTarget(const SBTarget &rhs) : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &), rhs);
+}
-SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {}
+SBTarget::SBTarget(const TargetSP &target_sp) : m_opaque_sp(target_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &), target_sp);
+}
const SBTarget &SBTarget::operator=(const SBTarget &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBTarget &,
+ SBTarget, operator=,(const lldb::SBTarget &), rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SBTarget::~SBTarget() {}
bool SBTarget::EventIsTargetEvent(const SBEvent &event) {
- return Target::TargetEventData::GetEventDataFromEvent(event.get()) != NULL;
+ LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
+ (const lldb::SBEvent &), event);
+
+ return Target::TargetEventData::GetEventDataFromEvent(event.get()) != nullptr;
}
SBTarget SBTarget::GetTargetFromEvent(const SBEvent &event) {
- return Target::TargetEventData::GetTargetFromEvent(event.get());
+ LLDB_RECORD_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
+ (const lldb::SBEvent &), event);
+
+ return LLDB_RECORD_RESULT(
+ Target::TargetEventData::GetTargetFromEvent(event.get()));
}
uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
+ (const lldb::SBEvent &), event);
+
const ModuleList module_list =
Target::TargetEventData::GetModuleListFromEvent(event.get());
return module_list.GetSize();
@@ -133,20 +147,35 @@ uint32_t SBTarget::GetNumModulesFromEvent(const SBEvent &event) {
SBModule SBTarget::GetModuleAtIndexFromEvent(const uint32_t idx,
const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndexFromEvent,
+ (const uint32_t, const lldb::SBEvent &), idx,
+ event);
+
const ModuleList module_list =
Target::TargetEventData::GetModuleListFromEvent(event.get());
- return SBModule(module_list.GetModuleAtIndex(idx));
+ return LLDB_RECORD_RESULT(SBModule(module_list.GetModuleAtIndex(idx)));
}
const char *SBTarget::GetBroadcasterClassName() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBTarget,
+ GetBroadcasterClassName);
+
return Target::GetStaticBroadcasterClass().AsCString();
}
bool SBTarget::IsValid() const {
- return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, IsValid);
+ return this->operator bool();
+}
+SBTarget::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTarget, operator bool);
+
+ return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid();
}
SBProcess SBTarget::GetProcess() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBTarget, GetProcess);
+
SBProcess sb_process;
ProcessSP process_sp;
TargetSP target_sp(GetSP());
@@ -155,39 +184,39 @@ SBProcess SBTarget::GetProcess() {
sb_process.SetSP(process_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBTarget(%p)::GetProcess () => SBProcess(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<void *>(process_sp.get()));
-
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
SBPlatform SBTarget::GetPlatform() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBPlatform, SBTarget, GetPlatform);
+
TargetSP target_sp(GetSP());
if (!target_sp)
- return SBPlatform();
+ return LLDB_RECORD_RESULT(SBPlatform());
SBPlatform platform;
platform.m_opaque_sp = target_sp->GetPlatform();
- return platform;
+ return LLDB_RECORD_RESULT(platform);
}
SBDebugger SBTarget::GetDebugger() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBDebugger, SBTarget, GetDebugger);
+
SBDebugger debugger;
TargetSP target_sp(GetSP());
if (target_sp)
debugger.reset(target_sp->GetDebugger().shared_from_this());
- return debugger;
+ return LLDB_RECORD_RESULT(debugger);
}
SBStructuredData SBTarget::GetStatistics() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBTarget, GetStatistics);
+
SBStructuredData data;
TargetSP target_sp(GetSP());
if (!target_sp)
- return data;
+ return LLDB_RECORD_RESULT(data);
auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
int i = 0;
@@ -199,10 +228,12 @@ SBStructuredData SBTarget::GetStatistics() {
}
data.m_impl_up->SetObjectSP(std::move(stats_up));
- return data;
+ return LLDB_RECORD_RESULT(data);
}
void SBTarget::SetCollectingStats(bool v) {
+ LLDB_RECORD_METHOD(void, SBTarget, SetCollectingStats, (bool), v);
+
TargetSP target_sp(GetSP());
if (!target_sp)
return;
@@ -210,19 +241,26 @@ void SBTarget::SetCollectingStats(bool v) {
}
bool SBTarget::GetCollectingStats() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, GetCollectingStats);
+
TargetSP target_sp(GetSP());
if (!target_sp)
return false;
return target_sp->GetCollectingStats();
}
-
SBProcess SBTarget::LoadCore(const char *core_file) {
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *),
+ core_file);
+
lldb::SBError error; // Ignored
- return LoadCore(core_file, error);
+ return LLDB_RECORD_RESULT(LoadCore(core_file, error));
}
SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LoadCore,
+ (const char *, lldb::SBError &), core_file, error);
+
SBProcess sb_process;
TargetSP target_sp(GetSP());
if (target_sp) {
@@ -240,30 +278,37 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
} else {
error.SetErrorString("SBTarget is invalid");
}
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
SBProcess SBTarget::LaunchSimple(char const **argv, char const **envp,
const char *working_directory) {
- char *stdin_path = NULL;
- char *stdout_path = NULL;
- char *stderr_path = NULL;
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, LaunchSimple,
+ (const char **, const char **, const char *), argv, envp,
+ working_directory);
+
+ char *stdin_path = nullptr;
+ char *stdout_path = nullptr;
+ char *stderr_path = nullptr;
uint32_t launch_flags = 0;
bool stop_at_entry = false;
SBError error;
SBListener listener = GetDebugger().GetListener();
- return Launch(listener, argv, envp, stdin_path, stdout_path, stderr_path,
- working_directory, launch_flags, stop_at_entry, error);
+ return LLDB_RECORD_RESULT(Launch(listener, argv, envp, stdin_path,
+ stdout_path, stderr_path, working_directory,
+ launch_flags, stop_at_entry, error));
}
SBError SBTarget::Install() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBTarget, Install);
+
SBError sb_error;
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
- sb_error.ref() = target_sp->Install(NULL);
+ sb_error.ref() = target_sp->Install(nullptr);
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
@@ -272,23 +317,17 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
const char *working_directory,
uint32_t launch_flags, // See LaunchFlags
bool stop_at_entry, lldb::SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch,
+ (lldb::SBListener &, const char **, const char **,
+ const char *, const char *, const char *, const char *,
+ uint32_t, bool, lldb::SBError &),
+ listener, argv, envp, stdin_path, stdout_path, stderr_path,
+ working_directory, launch_flags, stop_at_entry, error);
SBProcess sb_process;
ProcessSP process_sp;
TargetSP target_sp(GetSP());
- if (log)
- log->Printf("SBTarget(%p)::Launch (argv=%p, envp=%p, stdin=%s, stdout=%s, "
- "stderr=%s, working-dir=%s, launch_flags=0x%x, "
- "stop_at_entry=%i, &error (%p))...",
- static_cast<void *>(target_sp.get()), static_cast<void *>(argv),
- static_cast<void *>(envp), stdin_path ? stdin_path : "NULL",
- stdout_path ? stdout_path : "NULL",
- stderr_path ? stderr_path : "NULL",
- working_directory ? working_directory : "NULL", launch_flags,
- stop_at_entry, static_cast<void *>(error.get()));
-
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -308,7 +347,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
error.SetErrorString("process attach is in progress");
else
error.SetErrorString("a process is already being debugged");
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
}
@@ -319,7 +358,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
if (listener.IsValid()) {
error.SetErrorString("process is connected and already has a listener, "
"pass empty listener");
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
}
@@ -341,33 +380,25 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
if (listener.IsValid())
launch_info.SetListener(listener.GetSP());
- error.SetError(target_sp->Launch(launch_info, NULL));
+ error.SetError(target_sp->Launch(launch_info, nullptr));
sb_process.SetSP(target_sp->GetProcessSP());
} else {
error.SetErrorString("SBTarget is invalid");
}
- log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
- if (log)
- log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p), SBError(%s)",
- static_cast<void *>(target_sp.get()),
- static_cast<void *>(sb_process.GetSP().get()),
- error.GetCString());
-
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Launch,
+ (lldb::SBLaunchInfo &, lldb::SBError &), sb_launch_info,
+ error);
+
SBProcess sb_process;
TargetSP target_sp(GetSP());
- if (log)
- log->Printf("SBTarget(%p)::Launch (launch_info, error)...",
- static_cast<void *>(target_sp.get()));
-
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
StateType state = eStateInvalid;
@@ -381,7 +412,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
error.SetErrorString("process attach is in progress");
else
error.SetErrorString("a process is already being debugged");
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
}
}
@@ -398,32 +429,24 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
if (arch_spec.IsValid())
launch_info.GetArchitecture() = arch_spec;
- error.SetError(target_sp->Launch(launch_info, NULL));
+ error.SetError(target_sp->Launch(launch_info, nullptr));
sb_launch_info.set_ref(launch_info);
sb_process.SetSP(target_sp->GetProcessSP());
} else {
error.SetErrorString("SBTarget is invalid");
}
- log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
- if (log)
- log->Printf("SBTarget(%p)::Launch (...) => SBProcess(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<void *>(sb_process.GetSP().get()));
-
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, Attach,
+ (lldb::SBAttachInfo &, lldb::SBError &), sb_attach_info,
+ error);
SBProcess sb_process;
TargetSP target_sp(GetSP());
- if (log)
- log->Printf("SBTarget(%p)::Attach (sb_attach_info, error)...",
- static_cast<void *>(target_sp.get()));
-
if (target_sp) {
ProcessAttachInfo &attach_info = sb_attach_info.ref();
if (attach_info.ProcessIDIsValid() && !attach_info.UserIDIsValid()) {
@@ -437,12 +460,7 @@ lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
} else {
error.ref().SetErrorStringWithFormat(
"no process found with process ID %" PRIu64, attach_pid);
- if (log) {
- log->Printf("SBTarget(%p)::Attach (...) => error %s",
- static_cast<void *>(target_sp.get()),
- error.GetCString());
- }
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
}
}
@@ -453,28 +471,21 @@ lldb::SBProcess SBTarget::Attach(SBAttachInfo &sb_attach_info, SBError &error) {
error.SetErrorString("SBTarget is invalid");
}
- if (log)
- log->Printf("SBTarget(%p)::Attach (...) => SBProcess(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<void *>(sb_process.GetSP().get()));
-
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
lldb::SBProcess SBTarget::AttachToProcessWithID(
SBListener &listener,
lldb::pid_t pid, // The process ID to attach to
SBError &error // An error explaining what went wrong if attach fails
- ) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+) {
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
+ (lldb::SBListener &, lldb::pid_t, lldb::SBError &),
+ listener, pid, error);
SBProcess sb_process;
TargetSP target_sp(GetSP());
- if (log)
- log->Printf("SBTarget(%p)::%s (listener, pid=%" PRId64 ", error)...",
- static_cast<void *>(target_sp.get()), __FUNCTION__, pid);
-
if (target_sp) {
ProcessAttachInfo attach_info;
attach_info.SetProcessID(pid);
@@ -491,11 +502,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithID(
} else
error.SetErrorString("SBTarget is invalid");
- if (log)
- log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
- static_cast<void *>(target_sp.get()), __FUNCTION__,
- static_cast<void *>(sb_process.GetSP().get()));
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
lldb::SBProcess SBTarget::AttachToProcessWithName(
@@ -503,17 +510,14 @@ lldb::SBProcess SBTarget::AttachToProcessWithName(
const char *name, // basename of process to attach to
bool wait_for, // if true wait for a new instance of "name" to be launched
SBError &error // An error explaining what went wrong if attach fails
- ) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+) {
+ LLDB_RECORD_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithName,
+ (lldb::SBListener &, const char *, bool, lldb::SBError &),
+ listener, name, wait_for, error);
SBProcess sb_process;
TargetSP target_sp(GetSP());
- if (log)
- log->Printf("SBTarget(%p)::%s (listener, name=%s, wait_for=%s, error)...",
- static_cast<void *>(target_sp.get()), __FUNCTION__, name,
- wait_for ? "true" : "false");
-
if (name && target_sp) {
ProcessAttachInfo attach_info;
attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native);
@@ -527,39 +531,33 @@ lldb::SBProcess SBTarget::AttachToProcessWithName(
} else
error.SetErrorString("SBTarget is invalid");
- if (log)
- log->Printf("SBTarget(%p)::%s (...) => SBProcess(%p)",
- static_cast<void *>(target_sp.get()), __FUNCTION__,
- static_cast<void *>(sb_process.GetSP().get()));
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
const char *plugin_name,
SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(
+ lldb::SBProcess, SBTarget, ConnectRemote,
+ (lldb::SBListener &, const char *, const char *, lldb::SBError &),
+ listener, url, plugin_name, error);
SBProcess sb_process;
ProcessSP process_sp;
TargetSP target_sp(GetSP());
- if (log)
- log->Printf("SBTarget(%p)::ConnectRemote (listener, url=%s, "
- "plugin_name=%s, error)...",
- static_cast<void *>(target_sp.get()), url, plugin_name);
-
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (listener.IsValid())
process_sp =
- target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, NULL);
+ target_sp->CreateProcess(listener.m_opaque_sp, plugin_name, nullptr);
else
process_sp = target_sp->CreateProcess(
- target_sp->GetDebugger().GetListener(), plugin_name, NULL);
+ target_sp->GetDebugger().GetListener(), plugin_name, nullptr);
if (process_sp) {
sb_process.SetSP(process_sp);
- error.SetError(process_sp->ConnectRemote(NULL, url));
+ error.SetError(process_sp->ConnectRemote(nullptr, url));
} else {
error.SetErrorString("unable to create lldb_private::Process");
}
@@ -567,14 +565,11 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url,
error.SetErrorString("SBTarget is invalid");
}
- if (log)
- log->Printf("SBTarget(%p)::ConnectRemote (...) => SBProcess(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<void *>(process_sp.get()));
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
SBFileSpec SBTarget::GetExecutable() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBTarget, GetExecutable);
SBFileSpec exe_file_spec;
TargetSP target_sp(GetSP());
@@ -584,21 +579,20 @@ SBFileSpec SBTarget::GetExecutable() {
exe_file_spec.SetFileSpec(exe_module->GetFileSpec());
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- log->Printf("SBTarget(%p)::GetExecutable () => SBFileSpec(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<const void *>(exe_file_spec.get()));
- }
-
- return exe_file_spec;
+ return LLDB_RECORD_RESULT(exe_file_spec);
}
bool SBTarget::operator==(const SBTarget &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator==,(const lldb::SBTarget &),
+ rhs);
+
return m_opaque_sp.get() == rhs.m_opaque_sp.get();
}
bool SBTarget::operator!=(const SBTarget &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBTarget, operator!=,(const lldb::SBTarget &),
+ rhs);
+
return m_opaque_sp.get() != rhs.m_opaque_sp.get();
}
@@ -609,55 +603,68 @@ void SBTarget::SetSP(const lldb::TargetSP &target_sp) {
}
lldb::SBAddress SBTarget::ResolveLoadAddress(lldb::addr_t vm_addr) {
+ LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
+ (lldb::addr_t), vm_addr);
+
lldb::SBAddress sb_addr;
Address &addr = sb_addr.ref();
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (target_sp->ResolveLoadAddress(vm_addr, addr))
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
// We have a load address that isn't in a section, just return an address
// with the offset filled in (the address) and the section set to NULL
addr.SetRawAddress(vm_addr);
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
lldb::SBAddress SBTarget::ResolveFileAddress(lldb::addr_t file_addr) {
+ LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
+ (lldb::addr_t), file_addr);
+
lldb::SBAddress sb_addr;
Address &addr = sb_addr.ref();
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (target_sp->ResolveFileAddress(file_addr, addr))
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
addr.SetRawAddress(file_addr);
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
lldb::SBAddress SBTarget::ResolvePastLoadAddress(uint32_t stop_id,
lldb::addr_t vm_addr) {
+ LLDB_RECORD_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
+ (uint32_t, lldb::addr_t), stop_id, vm_addr);
+
lldb::SBAddress sb_addr;
Address &addr = sb_addr.ref();
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
if (target_sp->ResolveLoadAddress(vm_addr, addr))
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
// We have a load address that isn't in a section, just return an address
// with the offset filled in (the address) and the section set to NULL
addr.SetRawAddress(vm_addr);
- return sb_addr;
+ return LLDB_RECORD_RESULT(sb_addr);
}
SBSymbolContext
SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
uint32_t resolve_scope) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContext, SBTarget,
+ ResolveSymbolContextForAddress,
+ (const lldb::SBAddress &, uint32_t), addr, resolve_scope);
+
SBSymbolContext sc;
SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
if (addr.IsValid()) {
@@ -666,11 +673,15 @@ SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr,
target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope,
sc.ref());
}
- return sc;
+ return LLDB_RECORD_RESULT(sc);
}
size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
lldb::SBError &error) {
+ LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory,
+ (const lldb::SBAddress, void *, size_t, lldb::SBError &),
+ addr, buf, size, error);
+
SBError sb_error;
size_t bytes_read = 0;
TargetSP target_sp(GetSP());
@@ -687,35 +698,54 @@ size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size,
SBBreakpoint SBTarget::BreakpointCreateByLocation(const char *file,
uint32_t line) {
- return SBBreakpoint(
- BreakpointCreateByLocation(SBFileSpec(file, false), line));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const char *, uint32_t), file, line);
+
+ return LLDB_RECORD_RESULT(
+ SBBreakpoint(BreakpointCreateByLocation(SBFileSpec(file, false), line)));
}
SBBreakpoint
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
uint32_t line) {
- return BreakpointCreateByLocation(sb_file_spec, line, 0);
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t), sb_file_spec, line);
+
+ return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0));
}
SBBreakpoint
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
uint32_t line, lldb::addr_t offset) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, lldb::addr_t),
+ sb_file_spec, line, offset);
+
SBFileSpecList empty_list;
- return BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list);
+ return LLDB_RECORD_RESULT(
+ BreakpointCreateByLocation(sb_file_spec, line, offset, empty_list));
}
SBBreakpoint
SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec,
uint32_t line, lldb::addr_t offset,
SBFileSpecList &sb_module_list) {
- return BreakpointCreateByLocation(sb_file_spec, line, 0, offset,
- sb_module_list);
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, lldb::addr_t,
+ lldb::SBFileSpecList &),
+ sb_file_spec, line, offset, sb_module_list);
+
+ return LLDB_RECORD_RESULT(BreakpointCreateByLocation(sb_file_spec, line, 0,
+ offset, sb_module_list));
}
SBBreakpoint SBTarget::BreakpointCreateByLocation(
const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column,
lldb::addr_t offset, SBFileSpecList &sb_module_list) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+ lldb::addr_t, lldb::SBFileSpecList &),
+ sb_file_spec, line, column, offset, sb_module_list);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -736,23 +766,13 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(
skip_prologue, internal, hardware, move_to_nearest_code);
}
- if (log) {
- SBStream sstr;
- sb_bp.GetDescription(sstr);
- char path[PATH_MAX];
- sb_file_spec->GetPath(path, sizeof(path));
- log->Printf("SBTarget(%p)::BreakpointCreateByLocation ( %s:%u ) => "
- "SBBreakpoint(%p): %s",
- static_cast<void *>(target_sp.get()), path, line,
- static_cast<void *>(sb_bp.GetSP().get()), sstr.GetData());
- }
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
const char *module_name) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, const char *), symbol_name, module_name);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -767,47 +787,56 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name,
FileSpecList module_spec_list;
module_spec_list.Append(FileSpec(module_name));
sb_bp = target_sp->CreateBreakpoint(
- &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto,
+ &module_spec_list, nullptr, symbol_name, eFunctionNameTypeAuto,
eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
} else {
sb_bp = target_sp->CreateBreakpoint(
- NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown,
- offset, skip_prologue, internal, hardware);
+ nullptr, nullptr, symbol_name, eFunctionNameTypeAuto,
+ eLanguageTypeUnknown, offset, skip_prologue, internal, hardware);
}
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
- "module=\"%s\") => SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()), symbol_name, module_name,
- static_cast<void *>(sb_bp.GetSP().get()));
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
lldb::SBBreakpoint
SBTarget::BreakpointCreateByName(const char *symbol_name,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_name, module_list, comp_unit_list);
+
lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto;
- return BreakpointCreateByName(symbol_name, name_type_mask,
- eLanguageTypeUnknown, module_list,
- comp_unit_list);
+ return LLDB_RECORD_RESULT(
+ BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
+ module_list, comp_unit_list));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
const char *symbol_name, uint32_t name_type_mask,
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
- return BreakpointCreateByName(symbol_name, name_type_mask,
- eLanguageTypeUnknown, module_list,
- comp_unit_list);
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, uint32_t, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_name, name_type_mask, module_list, comp_unit_list);
+
+ return LLDB_RECORD_RESULT(
+ BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown,
+ module_list, comp_unit_list));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
const char *symbol_name, uint32_t name_type_mask,
LanguageType symbol_language, const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, uint32_t, lldb::LanguageType,
+ const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_name, name_type_mask, symbol_language, module_list,
+ comp_unit_list);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -822,37 +851,49 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName(
skip_prologue, internal, hardware);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateByName (symbol=\"%s\", "
- "name_type: %d) => SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()), symbol_name,
- name_type_mask, static_cast<void *>(sb_bp.GetSP().get()));
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
- return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
- eLanguageTypeUnknown, module_list,
- comp_unit_list);
+ LLDB_RECORD_METHOD(
+ lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
+ (const char **, uint32_t, uint32_t, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_names, num_names, name_type_mask, module_list, comp_unit_list);
+
+ return LLDB_RECORD_RESULT(BreakpointCreateByNames(
+ symbol_names, num_names, name_type_mask, eLanguageTypeUnknown,
+ module_list, comp_unit_list));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
LanguageType symbol_language, const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list) {
- return BreakpointCreateByNames(symbol_names, num_names, name_type_mask,
- eLanguageTypeUnknown, 0, module_list,
- comp_unit_list);
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
+ (const char **, uint32_t, uint32_t, lldb::LanguageType,
+ const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_names, num_names, name_type_mask, symbol_language,
+ module_list, comp_unit_list);
+
+ return LLDB_RECORD_RESULT(BreakpointCreateByNames(
+ symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, 0,
+ module_list, comp_unit_list));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
const char *symbol_names[], uint32_t num_names, uint32_t name_type_mask,
LanguageType symbol_language, lldb::addr_t offset,
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
+ (const char **, uint32_t, uint32_t, lldb::LanguageType,
+ lldb::addr_t, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_names, num_names, name_type_mask, symbol_language,
+ offset, module_list, comp_unit_list);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -867,50 +908,47 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames(
symbol_language, offset, skip_prologue, internal, hardware);
}
- if (log) {
- log->Printf("SBTarget(%p)::BreakpointCreateByName (symbols={",
- static_cast<void *>(target_sp.get()));
- for (uint32_t i = 0; i < num_names; i++) {
- char sep;
- if (i < num_names - 1)
- sep = ',';
- else
- sep = '}';
- if (symbol_names[i] != NULL)
- log->Printf("\"%s\"%c ", symbol_names[i], sep);
- else
- log->Printf("\"<NULL>\"%c ", sep);
- }
- log->Printf("name_type: %d) => SBBreakpoint(%p)", name_type_mask,
- static_cast<void *>(sb_bp.GetSP().get()));
- }
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
const char *module_name) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
+ (const char *, const char *), symbol_name_regex,
+ module_name);
+
SBFileSpecList module_spec_list;
SBFileSpecList comp_unit_list;
if (module_name && module_name[0]) {
module_spec_list.Append(FileSpec(module_name));
}
- return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
- module_spec_list, comp_unit_list);
+ return LLDB_RECORD_RESULT(
+ BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
+ module_spec_list, comp_unit_list));
}
lldb::SBBreakpoint
SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex,
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list) {
- return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown,
- module_list, comp_unit_list);
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_name_regex, module_list, comp_unit_list);
+
+ return LLDB_RECORD_RESULT(BreakpointCreateByRegex(
+ symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
const char *symbol_name_regex, LanguageType symbol_language,
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(
+ lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
+ (const char *, lldb::LanguageType, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ symbol_name_regex, symbol_language, module_list, comp_unit_list);
+
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -926,17 +964,12 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByRegex(
skip_prologue, internal, hardware);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") "
- "=> SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()), symbol_name_regex,
- static_cast<void *>(sb_bp.GetSP().get()));
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByAddress,
+ (lldb::addr_t), address);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -946,27 +979,17 @@ SBBreakpoint SBTarget::BreakpointCreateByAddress(addr_t address) {
sb_bp = target_sp->CreateBreakpoint(address, false, hardware);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64
- ") => SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<uint64_t>(address),
- static_cast<void *>(sb_bp.GetSP().get()));
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateBySBAddress,
+ (lldb::SBAddress &), sb_address);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
if (!sb_address.IsValid()) {
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress called with "
- "invalid address",
- static_cast<void *>(target_sp.get()));
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
if (target_sp) {
@@ -975,22 +998,18 @@ SBBreakpoint SBTarget::BreakpointCreateBySBAddress(SBAddress &sb_address) {
sb_bp = target_sp->CreateBreakpoint(sb_address.ref(), false, hardware);
}
- if (log) {
- SBStream s;
- sb_address.GetDescription(s);
- log->Printf("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => "
- "SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()), s.GetData(),
- static_cast<void *>(sb_bp.GetSP().get()));
- }
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
lldb::SBBreakpoint
SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
const lldb::SBFileSpec &source_file,
const char *module_name) {
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateBySourceRegex,
+ (const char *, const lldb::SBFileSpec &, const char *),
+ source_regex, source_file, module_name);
+
SBFileSpecList module_spec_list;
if (module_name && module_name[0]) {
@@ -1002,22 +1021,32 @@ SBTarget::BreakpointCreateBySourceRegex(const char *source_regex,
source_file_list.Append(source_file);
}
- return BreakpointCreateBySourceRegex(source_regex, module_spec_list,
- source_file_list);
+ return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
+ source_regex, module_spec_list, source_file_list));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
const char *source_regex, const SBFileSpecList &module_list,
const lldb::SBFileSpecList &source_file_list) {
- return BreakpointCreateBySourceRegex(source_regex, module_list,
- source_file_list, SBStringList());
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateBySourceRegex,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &),
+ source_regex, module_list, source_file_list);
+
+ return LLDB_RECORD_RESULT(BreakpointCreateBySourceRegex(
+ source_regex, module_list, source_file_list, SBStringList()));
}
lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
const char *source_regex, const SBFileSpecList &module_list,
const lldb::SBFileSpecList &source_file_list,
const SBStringList &func_names) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateBySourceRegex,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &, const lldb::SBStringList &),
+ source_regex, module_list, source_file_list, func_names);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1036,19 +1065,15 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateBySourceRegex(
false, hardware, move_to_nearest_code);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateByRegex (source_regex=\"%s\") "
- "=> SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()), source_regex,
- static_cast<void *>(sb_bp.GetSP().get()));
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
lldb::SBBreakpoint
SBTarget::BreakpointCreateForException(lldb::LanguageType language,
bool catch_bp, bool throw_bp) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateForException,
+ (lldb::LanguageType, bool, bool), language, catch_bp,
+ throw_bp);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
@@ -1059,32 +1084,25 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language,
hardware);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateForException (Language: %s, catch: "
- "%s throw: %s) => SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()),
- Language::GetNameForLanguageType(language),
- catch_bp ? "on" : "off", throw_bp ? "on" : "off",
- static_cast<void *>(sb_bp.GetSP().get()));
-
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
-lldb::SBBreakpoint
-SBTarget::BreakpointCreateFromScript(const char *class_name,
- SBStructuredData &extra_args,
- const SBFileSpecList &module_list,
- const SBFileSpecList &file_list,
- bool request_hardware)
-{
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+lldb::SBBreakpoint SBTarget::BreakpointCreateFromScript(
+ const char *class_name, SBStructuredData &extra_args,
+ const SBFileSpecList &module_list, const SBFileSpecList &file_list,
+ bool request_hardware) {
+ LLDB_RECORD_METHOD(
+ lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
+ (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &, bool),
+ class_name, extra_args, module_list, file_list, request_hardware);
SBBreakpoint sb_bp;
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
Status error;
-
+
StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP();
sb_bp =
target_sp->CreateScriptedBreakpoint(class_name,
@@ -1095,18 +1113,13 @@ SBTarget::BreakpointCreateFromScript(const char *class_name,
obj_sp,
&error);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointCreateFromScript (class name: %s) "
- " => SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()),
- class_name,
- static_cast<void *>(sb_bp.GetSP().get()));
- return sb_bp;
+ return LLDB_RECORD_RESULT(sb_bp);
}
-
uint32_t SBTarget::GetNumBreakpoints() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumBreakpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
// The breakpoint list is thread safe, no need to lock
@@ -1116,17 +1129,21 @@ uint32_t SBTarget::GetNumBreakpoints() const {
}
SBBreakpoint SBTarget::GetBreakpointAtIndex(uint32_t idx) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBBreakpoint, SBTarget, GetBreakpointAtIndex,
+ (uint32_t), idx);
+
SBBreakpoint sb_breakpoint;
TargetSP target_sp(GetSP());
if (target_sp) {
// The breakpoint list is thread safe, no need to lock
sb_breakpoint = target_sp->GetBreakpointList().GetBreakpointAtIndex(idx);
}
- return sb_breakpoint;
+ return LLDB_RECORD_RESULT(sb_breakpoint);
}
bool SBTarget::BreakpointDelete(break_id_t bp_id) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t),
+ bp_id);
bool result = false;
TargetSP target_sp(GetSP());
@@ -1135,16 +1152,12 @@ bool SBTarget::BreakpointDelete(break_id_t bp_id) {
result = target_sp->RemoveBreakpointByID(bp_id);
}
- if (log)
- log->Printf("SBTarget(%p)::BreakpointDelete (bp_id=%d) => %i",
- static_cast<void *>(target_sp.get()),
- static_cast<uint32_t>(bp_id), result);
-
return result;
}
SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
+ (lldb::break_id_t), bp_id);
SBBreakpoint sb_breakpoint;
TargetSP target_sp(GetSP());
@@ -1153,17 +1166,14 @@ SBBreakpoint SBTarget::FindBreakpointByID(break_id_t bp_id) {
sb_breakpoint = target_sp->GetBreakpointByID(bp_id);
}
- if (log)
- log->Printf(
- "SBTarget(%p)::FindBreakpointByID (bp_id=%d) => SBBreakpoint(%p)",
- static_cast<void *>(target_sp.get()), static_cast<uint32_t>(bp_id),
- static_cast<void *>(sb_breakpoint.GetSP().get()));
-
- return sb_breakpoint;
+ return LLDB_RECORD_RESULT(sb_breakpoint);
}
bool SBTarget::FindBreakpointsByName(const char *name,
SBBreakpointList &bkpts) {
+ LLDB_RECORD_METHOD(bool, SBTarget, FindBreakpointsByName,
+ (const char *, lldb::SBBreakpointList &), name, bkpts);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1179,8 +1189,10 @@ bool SBTarget::FindBreakpointsByName(const char *name,
return true;
}
-void SBTarget::GetBreakpointNames(SBStringList &names)
-{
+void SBTarget::GetBreakpointNames(SBStringList &names) {
+ LLDB_RECORD_METHOD(void, SBTarget, GetBreakpointNames, (lldb::SBStringList &),
+ names);
+
names.Clear();
TargetSP target_sp(GetSP());
@@ -1194,8 +1206,10 @@ void SBTarget::GetBreakpointNames(SBStringList &names)
}
}
-void SBTarget::DeleteBreakpointName(const char *name)
-{
+void SBTarget::DeleteBreakpointName(const char *name) {
+ LLDB_RECORD_METHOD(void, SBTarget, DeleteBreakpointName, (const char *),
+ name);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1204,6 +1218,8 @@ void SBTarget::DeleteBreakpointName(const char *name)
}
bool SBTarget::EnableAllBreakpoints() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllBreakpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1214,6 +1230,8 @@ bool SBTarget::EnableAllBreakpoints() {
}
bool SBTarget::DisableAllBreakpoints() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllBreakpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1224,6 +1242,8 @@ bool SBTarget::DisableAllBreakpoints() {
}
bool SBTarget::DeleteAllBreakpoints() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllBreakpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1235,19 +1255,29 @@ bool SBTarget::DeleteAllBreakpoints() {
lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
SBBreakpointList &new_bps) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
+ (lldb::SBFileSpec &, lldb::SBBreakpointList &),
+ source_file, new_bps);
+
SBStringList empty_name_list;
- return BreakpointsCreateFromFile(source_file, empty_name_list, new_bps);
+ return LLDB_RECORD_RESULT(
+ BreakpointsCreateFromFile(source_file, empty_name_list, new_bps));
}
lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
SBStringList &matching_names,
SBBreakpointList &new_bps) {
+ LLDB_RECORD_METHOD(
+ lldb::SBError, SBTarget, BreakpointsCreateFromFile,
+ (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &),
+ source_file, matching_names, new_bps);
+
SBError sberr;
TargetSP target_sp(GetSP());
if (!target_sp) {
sberr.SetErrorString(
"BreakpointCreateFromFile called with invalid target.");
- return sberr;
+ return LLDB_RECORD_RESULT(sberr);
}
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1261,35 +1291,42 @@ lldb::SBError SBTarget::BreakpointsCreateFromFile(SBFileSpec &source_file,
sberr.ref() = target_sp->CreateBreakpointsFromFile(source_file.ref(),
name_vector, bp_ids);
if (sberr.Fail())
- return sberr;
+ return LLDB_RECORD_RESULT(sberr);
size_t num_bkpts = bp_ids.GetSize();
for (size_t i = 0; i < num_bkpts; i++) {
BreakpointID bp_id = bp_ids.GetBreakpointIDAtIndex(i);
new_bps.AppendByID(bp_id.GetBreakpointID());
}
- return sberr;
+ return LLDB_RECORD_RESULT(sberr);
}
lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
+ (lldb::SBFileSpec &), dest_file);
+
SBError sberr;
TargetSP target_sp(GetSP());
if (!target_sp) {
sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
- return sberr;
+ return LLDB_RECORD_RESULT(sberr);
}
SBBreakpointList bkpt_list(*this);
- return BreakpointsWriteToFile(dest_file, bkpt_list);
+ return LLDB_RECORD_RESULT(BreakpointsWriteToFile(dest_file, bkpt_list));
}
lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
SBBreakpointList &bkpt_list,
bool append) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
+ (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool),
+ dest_file, bkpt_list, append);
+
SBError sberr;
TargetSP target_sp(GetSP());
if (!target_sp) {
sberr.SetErrorString("BreakpointWriteToFile called with invalid target.");
- return sberr;
+ return LLDB_RECORD_RESULT(sberr);
}
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1297,10 +1334,12 @@ lldb::SBError SBTarget::BreakpointsWriteToFile(SBFileSpec &dest_file,
bkpt_list.CopyToBreakpointIDList(bp_id_list);
sberr.ref() = target_sp->SerializeBreakpointsToFile(dest_file.ref(),
bp_id_list, append);
- return sberr;
+ return LLDB_RECORD_RESULT(sberr);
}
uint32_t SBTarget::GetNumWatchpoints() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumWatchpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
// The watchpoint list is thread safe, no need to lock
@@ -1310,17 +1349,22 @@ uint32_t SBTarget::GetNumWatchpoints() const {
}
SBWatchpoint SBTarget::GetWatchpointAtIndex(uint32_t idx) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBWatchpoint, SBTarget, GetWatchpointAtIndex,
+ (uint32_t), idx);
+
SBWatchpoint sb_watchpoint;
TargetSP target_sp(GetSP());
if (target_sp) {
// The watchpoint list is thread safe, no need to lock
sb_watchpoint.SetSP(target_sp->GetWatchpointList().GetByIndex(idx));
}
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
}
bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t),
+ wp_id);
+
bool result = false;
TargetSP target_sp(GetSP());
@@ -1331,16 +1375,13 @@ bool SBTarget::DeleteWatchpoint(watch_id_t wp_id) {
result = target_sp->RemoveWatchpointByID(wp_id);
}
- if (log)
- log->Printf("SBTarget(%p)::WatchpointDelete (wp_id=%d) => %i",
- static_cast<void *>(target_sp.get()),
- static_cast<uint32_t>(wp_id), result);
-
return result;
}
SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
+ (lldb::watch_id_t), wp_id);
+
SBWatchpoint sb_watchpoint;
lldb::WatchpointSP watchpoint_sp;
@@ -1353,19 +1394,15 @@ SBWatchpoint SBTarget::FindWatchpointByID(lldb::watch_id_t wp_id) {
sb_watchpoint.SetSP(watchpoint_sp);
}
- if (log)
- log->Printf(
- "SBTarget(%p)::FindWatchpointByID (bp_id=%d) => SBWatchpoint(%p)",
- static_cast<void *>(target_sp.get()), static_cast<uint32_t>(wp_id),
- static_cast<void *>(watchpoint_sp.get()));
-
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
}
lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
bool read, bool write,
SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
+ (lldb::addr_t, size_t, bool, bool, lldb::SBError &), addr,
+ size, read, write, error);
SBWatchpoint sb_watchpoint;
lldb::WatchpointSP watchpoint_sp;
@@ -1381,30 +1418,25 @@ lldb::SBWatchpoint SBTarget::WatchAddress(lldb::addr_t addr, size_t size,
if (watch_type == 0) {
error.SetErrorString(
"Can't create a watchpoint that is neither read nor write.");
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
}
// Target::CreateWatchpoint() is thread safe.
Status cw_error;
// This API doesn't take in a type, so we can't figure out what it is.
- CompilerType *type = NULL;
+ CompilerType *type = nullptr;
watchpoint_sp =
target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error);
error.SetError(cw_error);
sb_watchpoint.SetSP(watchpoint_sp);
}
- if (log)
- log->Printf("SBTarget(%p)::WatchAddress (addr=0x%" PRIx64
- ", 0x%u) => SBWatchpoint(%p)",
- static_cast<void *>(target_sp.get()), addr,
- static_cast<uint32_t>(size),
- static_cast<void *>(watchpoint_sp.get()));
-
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
}
bool SBTarget::EnableAllWatchpoints() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, EnableAllWatchpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1417,6 +1449,8 @@ bool SBTarget::EnableAllWatchpoints() {
}
bool SBTarget::DisableAllWatchpoints() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DisableAllWatchpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1430,6 +1464,10 @@ bool SBTarget::DisableAllWatchpoints() {
SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
SBType type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
+ (const char *, lldb::SBAddress, lldb::SBType), name, addr,
+ type);
+
SBValue sb_value;
lldb::ValueObjectSP new_value_sp;
if (IsValid() && name && *name && addr.IsValid() && type.IsValid()) {
@@ -1441,21 +1479,15 @@ SBValue SBTarget::CreateValueFromAddress(const char *name, SBAddress addr,
exe_ctx, ast_type);
}
sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (new_value_sp)
- log->Printf("SBTarget(%p)::CreateValueFromAddress => \"%s\"",
- static_cast<void *>(m_opaque_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf("SBTarget(%p)::CreateValueFromAddress => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
lldb::SBType type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
+ (const char *, lldb::SBData, lldb::SBType), name, data,
+ type);
+
SBValue sb_value;
lldb::ValueObjectSP new_value_sp;
if (IsValid() && name && *name && data.IsValid() && type.IsValid()) {
@@ -1467,21 +1499,14 @@ lldb::SBValue SBTarget::CreateValueFromData(const char *name, lldb::SBData data,
exe_ctx, ast_type);
}
sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (new_value_sp)
- log->Printf("SBTarget(%p)::CreateValueFromData => \"%s\"",
- static_cast<void *>(m_opaque_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf("SBTarget(%p)::CreateValueFromData => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
const char *expr) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
+ (const char *, const char *), name, expr);
+
SBValue sb_value;
lldb::ValueObjectSP new_value_sp;
if (IsValid() && name && *name && expr && *expr) {
@@ -1491,20 +1516,12 @@ lldb::SBValue SBTarget::CreateValueFromExpression(const char *name,
ValueObject::CreateValueObjectFromExpression(name, expr, exe_ctx);
}
sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (new_value_sp)
- log->Printf("SBTarget(%p)::CreateValueFromExpression => \"%s\"",
- static_cast<void *>(m_opaque_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf("SBTarget(%p)::CreateValueFromExpression => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
bool SBTarget::DeleteAllWatchpoints() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTarget, DeleteAllWatchpoints);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
@@ -1518,6 +1535,10 @@ bool SBTarget::DeleteAllWatchpoints() {
void SBTarget::AppendImageSearchPath(const char *from, const char *to,
lldb::SBError &error) {
+ LLDB_RECORD_METHOD(void, SBTarget, AppendImageSearchPath,
+ (const char *, const char *, lldb::SBError &), from, to,
+ error);
+
TargetSP target_sp(GetSP());
if (!target_sp)
return error.SetErrorString("invalid target");
@@ -1528,21 +1549,24 @@ void SBTarget::AppendImageSearchPath(const char *from, const char *to,
if (!csTo)
return error.SetErrorString("<to> path can't be empty");
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBTarget(%p)::%s: '%s' -> '%s'",
- static_cast<void *>(target_sp.get()), __FUNCTION__,
- from, to);
target_sp->GetImageSearchPathList().Append(csFrom, csTo, true);
}
lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
const char *uuid_cstr) {
- return AddModule(path, triple, uuid_cstr, NULL);
+ LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
+ (const char *, const char *, const char *), path, triple,
+ uuid_cstr);
+
+ return LLDB_RECORD_RESULT(AddModule(path, triple, uuid_cstr, nullptr));
}
lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
const char *uuid_cstr, const char *symfile) {
+ LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
+ (const char *, const char *, const char *, const char *),
+ path, triple, uuid_cstr, symfile);
+
lldb::SBModule sb_module;
TargetSP target_sp(GetSP());
if (target_sp) {
@@ -1562,20 +1586,26 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
if (symfile)
module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native);
- sb_module.SetSP(target_sp->GetSharedModule(module_spec));
+ sb_module.SetSP(target_sp->GetOrCreateModule(module_spec, true /* notify */));
}
- return sb_module;
+ return LLDB_RECORD_RESULT(sb_module);
}
lldb::SBModule SBTarget::AddModule(const SBModuleSpec &module_spec) {
+ LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, AddModule,
+ (const lldb::SBModuleSpec &), module_spec);
+
lldb::SBModule sb_module;
TargetSP target_sp(GetSP());
if (target_sp)
- sb_module.SetSP(target_sp->GetSharedModule(*module_spec.m_opaque_ap));
- return sb_module;
+ sb_module.SetSP(target_sp->GetOrCreateModule(*module_spec.m_opaque_up,
+ true /* notify */));
+ return LLDB_RECORD_RESULT(sb_module);
}
bool SBTarget::AddModule(lldb::SBModule &module) {
+ LLDB_RECORD_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &), module);
+
TargetSP target_sp(GetSP());
if (target_sp) {
target_sp->GetImages().AppendIfNeeded(module.GetSP());
@@ -1585,7 +1615,7 @@ bool SBTarget::AddModule(lldb::SBModule &module) {
}
uint32_t SBTarget::GetNumModules() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBTarget, GetNumModules);
uint32_t num = 0;
TargetSP target_sp(GetSP());
@@ -1594,24 +1624,19 @@ uint32_t SBTarget::GetNumModules() const {
num = target_sp->GetImages().GetSize();
}
- if (log)
- log->Printf("SBTarget(%p)::GetNumModules () => %d",
- static_cast<void *>(target_sp.get()), num);
-
return num;
}
void SBTarget::Clear() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log)
- log->Printf("SBTarget(%p)::Clear ()",
- static_cast<void *>(m_opaque_sp.get()));
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBTarget, Clear);
m_opaque_sp.reset();
}
SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
+ LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, FindModule,
+ (const lldb::SBFileSpec &), sb_file_spec);
+
SBModule sb_module;
TargetSP target_sp(GetSP());
if (target_sp && sb_file_spec.IsValid()) {
@@ -1619,11 +1644,13 @@ SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
// The module list is thread safe, no need to lock
sb_module.SetSP(target_sp->GetImages().FindFirstModule(module_spec));
}
- return sb_module;
+ return LLDB_RECORD_RESULT(sb_module);
}
-SBSymbolContextList
-SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
+SBSymbolContextList SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
+ (const lldb::SBFileSpec &), sb_file_spec);
+
SBSymbolContextList sb_sc_list;
const TargetSP target_sp(GetSP());
if (target_sp && sb_file_spec.IsValid()) {
@@ -1631,10 +1658,12 @@ SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
target_sp->GetImages().FindCompileUnits(*sb_file_spec,
append, *sb_sc_list);
}
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
lldb::ByteOrder SBTarget::GetByteOrder() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::ByteOrder, SBTarget, GetByteOrder);
+
TargetSP target_sp(GetSP());
if (target_sp)
return target_sp->GetArchitecture().GetByteOrder();
@@ -1642,6 +1671,8 @@ lldb::ByteOrder SBTarget::GetByteOrder() {
}
const char *SBTarget::GetTriple() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTarget, GetTriple);
+
TargetSP target_sp(GetSP());
if (target_sp) {
std::string triple(target_sp->GetArchitecture().GetTriple().str());
@@ -1651,10 +1682,12 @@ const char *SBTarget::GetTriple() {
ConstString const_triple(triple.c_str());
return const_triple.GetCString();
}
- return NULL;
+ return nullptr;
}
uint32_t SBTarget::GetDataByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetDataByteSize);
+
TargetSP target_sp(GetSP());
if (target_sp) {
return target_sp->GetArchitecture().GetDataByteSize();
@@ -1663,6 +1696,8 @@ uint32_t SBTarget::GetDataByteSize() {
}
uint32_t SBTarget::GetCodeByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetCodeByteSize);
+
TargetSP target_sp(GetSP());
if (target_sp) {
return target_sp->GetArchitecture().GetCodeByteSize();
@@ -1671,6 +1706,8 @@ uint32_t SBTarget::GetCodeByteSize() {
}
uint32_t SBTarget::GetAddressByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTarget, GetAddressByteSize);
+
TargetSP target_sp(GetSP());
if (target_sp)
return target_sp->GetArchitecture().GetAddressByteSize();
@@ -1678,7 +1715,8 @@ uint32_t SBTarget::GetAddressByteSize() {
}
SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex, (uint32_t),
+ idx);
SBModule sb_module;
ModuleSP module_sp;
@@ -1689,15 +1727,12 @@ SBModule SBTarget::GetModuleAtIndex(uint32_t idx) {
sb_module.SetSP(module_sp);
}
- if (log)
- log->Printf("SBTarget(%p)::GetModuleAtIndex (idx=%d) => SBModule(%p)",
- static_cast<void *>(target_sp.get()), idx,
- static_cast<void *>(module_sp.get()));
-
- return sb_module;
+ return LLDB_RECORD_RESULT(sb_module);
}
bool SBTarget::RemoveModule(lldb::SBModule module) {
+ LLDB_RECORD_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule), module);
+
TargetSP target_sp(GetSP());
if (target_sp)
return target_sp->GetImages().Remove(module.GetSP());
@@ -1705,21 +1740,23 @@ bool SBTarget::RemoveModule(lldb::SBModule module) {
}
SBBroadcaster SBTarget::GetBroadcaster() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBBroadcaster, SBTarget,
+ GetBroadcaster);
+
TargetSP target_sp(GetSP());
SBBroadcaster broadcaster(target_sp.get(), false);
- if (log)
- log->Printf("SBTarget(%p)::GetBroadcaster () => SBBroadcaster(%p)",
- static_cast<void *>(target_sp.get()),
- static_cast<void *>(broadcaster.get()));
- return broadcaster;
+ return LLDB_RECORD_RESULT(broadcaster);
}
bool SBTarget::GetDescription(SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTarget, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
Stream &strm = description.ref();
TargetSP target_sp(GetSP());
@@ -1733,13 +1770,16 @@ bool SBTarget::GetDescription(SBStream &description,
lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
uint32_t name_type_mask) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions,
+ (const char *, uint32_t), name, name_type_mask);
+
lldb::SBSymbolContextList sb_sc_list;
if (!name | !name[0])
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
TargetSP target_sp(GetSP());
if (!target_sp)
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
const bool symbols_ok = true;
const bool inlines_ok = true;
@@ -1747,12 +1787,16 @@ lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name,
FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask);
target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok,
inlines_ok, append, *sb_sc_list);
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
uint32_t max_matches,
MatchType matchtype) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindGlobalFunctions,
+ (const char *, uint32_t, lldb::MatchType), name,
+ max_matches, matchtype);
+
lldb::SBSymbolContextList sb_sc_list;
if (name && name[0]) {
llvm::StringRef name_ref(name);
@@ -1777,10 +1821,13 @@ lldb::SBSymbolContextList SBTarget::FindGlobalFunctions(const char *name,
}
}
}
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *),
+ typename_cstr);
+
TargetSP target_sp(GetSP());
if (typename_cstr && typename_cstr[0] && target_sp) {
ConstString const_typename(typename_cstr);
@@ -1795,30 +1842,17 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
TypeSP type_sp(
module_sp->FindFirstType(sc, const_typename, exact_match));
if (type_sp)
- return SBType(type_sp);
+ return LLDB_RECORD_RESULT(SBType(type_sp));
}
}
- // Didn't find the type in the symbols; try the Objective-C runtime if one
- // is installed
-
- ProcessSP process_sp(target_sp->GetProcessSP());
-
- if (process_sp) {
- ObjCLanguageRuntime *objc_language_runtime =
- process_sp->GetObjCLanguageRuntime();
-
- if (objc_language_runtime) {
- DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
-
- if (objc_decl_vendor) {
- std::vector<clang::NamedDecl *> decls;
-
- if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
- if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) {
- return SBType(type);
- }
- }
+ // Didn't find the type in the symbols; Try the loaded language runtimes
+ if (auto process_sp = target_sp->GetProcessSP()) {
+ for (auto *runtime : process_sp->GetLanguageRuntimes()) {
+ if (auto vendor = runtime->GetDeclVendor()) {
+ auto types = vendor->FindTypes(const_typename, /*max_matches*/ 1);
+ if (!types.empty())
+ return LLDB_RECORD_RESULT(SBType(types.front()));
}
}
}
@@ -1826,24 +1860,30 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
// No matches, search for basic typename matches
ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
if (clang_ast)
- return SBType(ClangASTContext::GetBasicType(clang_ast->getASTContext(),
- const_typename));
+ return LLDB_RECORD_RESULT(SBType(ClangASTContext::GetBasicType(
+ clang_ast->getASTContext(), const_typename)));
}
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
}
SBType SBTarget::GetBasicType(lldb::BasicType type) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBTarget, GetBasicType, (lldb::BasicType),
+ type);
+
TargetSP target_sp(GetSP());
if (target_sp) {
ClangASTContext *clang_ast = target_sp->GetScratchClangASTContext();
if (clang_ast)
- return SBType(
- ClangASTContext::GetBasicType(clang_ast->getASTContext(), type));
+ return LLDB_RECORD_RESULT(SBType(
+ ClangASTContext::GetBasicType(clang_ast->getASTContext(), type)));
}
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
}
lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
+ LLDB_RECORD_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *),
+ typename_cstr);
+
SBTypeList sb_type_list;
TargetSP target_sp(GetSP());
if (typename_cstr && typename_cstr[0] && target_sp) {
@@ -1864,27 +1904,14 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
}
}
- // Try the Objective-C runtime if one is installed
-
- ProcessSP process_sp(target_sp->GetProcessSP());
-
- if (process_sp) {
- ObjCLanguageRuntime *objc_language_runtime =
- process_sp->GetObjCLanguageRuntime();
-
- if (objc_language_runtime) {
- DeclVendor *objc_decl_vendor = objc_language_runtime->GetDeclVendor();
-
- if (objc_decl_vendor) {
- std::vector<clang::NamedDecl *> decls;
-
- if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) {
- for (clang::NamedDecl *decl : decls) {
- if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) {
- sb_type_list.Append(SBType(type));
- }
- }
- }
+ // Try the loaded language runtimes
+ if (auto process_sp = target_sp->GetProcessSP()) {
+ for (auto *runtime : process_sp->GetLanguageRuntimes()) {
+ if (auto *vendor = runtime->GetDeclVendor()) {
+ auto types =
+ vendor->FindTypes(const_typename, /*max_matches*/ UINT32_MAX);
+ for (auto type : types)
+ sb_type_list.Append(SBType(type));
}
}
}
@@ -1897,11 +1924,14 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
clang_ast->getASTContext(), const_typename)));
}
}
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
}
SBValueList SBTarget::FindGlobalVariables(const char *name,
uint32_t max_matches) {
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
+ (const char *, uint32_t), name, max_matches);
+
SBValueList sb_value_list;
TargetSP target_sp(GetSP());
@@ -1912,7 +1942,7 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
- if (exe_scope == NULL)
+ if (exe_scope == nullptr)
exe_scope = target_sp.get();
for (uint32_t i = 0; i < match_count; ++i) {
lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
@@ -1923,12 +1953,16 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
}
}
- return sb_value_list;
+ return LLDB_RECORD_RESULT(sb_value_list);
}
SBValueList SBTarget::FindGlobalVariables(const char *name,
uint32_t max_matches,
MatchType matchtype) {
+ LLDB_RECORD_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
+ (const char *, uint32_t, lldb::MatchType), name,
+ max_matches, matchtype);
+
SBValueList sb_value_list;
TargetSP target_sp(GetSP());
@@ -1956,7 +1990,7 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
- if (exe_scope == NULL)
+ if (exe_scope == nullptr)
exe_scope = target_sp.get();
for (uint32_t i = 0; i < match_count; ++i) {
lldb::ValueObjectSP valobj_sp(ValueObjectVariable::Create(
@@ -1967,29 +2001,41 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
}
}
- return sb_value_list;
+ return LLDB_RECORD_RESULT(sb_value_list);
}
lldb::SBValue SBTarget::FindFirstGlobalVariable(const char *name) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
+ (const char *), name);
+
SBValueList sb_value_list(FindGlobalVariables(name, 1));
if (sb_value_list.IsValid() && sb_value_list.GetSize() > 0)
- return sb_value_list.GetValueAtIndex(0);
- return SBValue();
+ return LLDB_RECORD_RESULT(sb_value_list.GetValueAtIndex(0));
+ return LLDB_RECORD_RESULT(SBValue());
}
SBSourceManager SBTarget::GetSourceManager() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBSourceManager, SBTarget, GetSourceManager);
+
SBSourceManager source_manager(*this);
- return source_manager;
+ return LLDB_RECORD_RESULT(source_manager);
}
lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
uint32_t count) {
- return ReadInstructions(base_addr, count, NULL);
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
+ (lldb::SBAddress, uint32_t), base_addr, count);
+
+ return LLDB_RECORD_RESULT(ReadInstructions(base_addr, count, nullptr));
}
lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
uint32_t count,
const char *flavor_string) {
+ LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
+ (lldb::SBAddress, uint32_t, const char *), base_addr,
+ count, flavor_string);
+
SBInstructionList sb_instructions;
TargetSP target_sp(GetSP());
@@ -2007,24 +2053,33 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr,
data.GetByteSize(), error, &load_addr);
const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS;
sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
- target_sp->GetArchitecture(), NULL, flavor_string, *addr_ptr,
+ target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr,
data.GetBytes(), bytes_read, count, data_from_file));
}
}
- return sb_instructions;
+ return LLDB_RECORD_RESULT(sb_instructions);
}
lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr,
const void *buf,
size_t size) {
- return GetInstructionsWithFlavor(base_addr, NULL, buf, size);
+ LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
+ (lldb::SBAddress, const void *, size_t), base_addr, buf,
+ size);
+
+ return GetInstructionsWithFlavor(base_addr, nullptr, buf, size);
}
lldb::SBInstructionList
SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
const char *flavor_string, const void *buf,
size_t size) {
+ LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
+ GetInstructionsWithFlavor,
+ (lldb::SBAddress, const char *, const void *, size_t),
+ base_addr, flavor_string, buf, size);
+
SBInstructionList sb_instructions;
TargetSP target_sp(GetSP());
@@ -2037,7 +2092,7 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
const bool data_from_file = true;
sb_instructions.SetDisassembler(Disassembler::DisassembleBytes(
- target_sp->GetArchitecture(), NULL, flavor_string, addr, buf, size,
+ target_sp->GetArchitecture(), nullptr, flavor_string, addr, buf, size,
UINT32_MAX, data_from_file));
}
@@ -2047,7 +2102,10 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr,
lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr,
const void *buf,
size_t size) {
- return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), NULL, buf,
+ LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions,
+ (lldb::addr_t, const void *, size_t), base_addr, buf, size);
+
+ return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf,
size);
}
@@ -2055,12 +2113,21 @@ lldb::SBInstructionList
SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr,
const char *flavor_string, const void *buf,
size_t size) {
+ LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget,
+ GetInstructionsWithFlavor,
+ (lldb::addr_t, const char *, const void *, size_t),
+ base_addr, flavor_string, buf, size);
+
return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string,
buf, size);
}
SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
lldb::addr_t section_base_addr) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
+ (lldb::SBSection, lldb::addr_t), section,
+ section_base_addr);
+
SBError sb_error;
TargetSP target_sp(GetSP());
if (target_sp) {
@@ -2091,10 +2158,13 @@ SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section,
} else {
sb_error.SetErrorString("invalid target");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
+ (lldb::SBSection), section);
+
SBError sb_error;
TargetSP target_sp(GetSP());
@@ -2123,11 +2193,14 @@ SBError SBTarget::ClearSectionLoadAddress(lldb::SBSection section) {
} else {
sb_error.SetErrorStringWithFormat("invalid target");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
int64_t slide_offset) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
+ (lldb::SBModule, int64_t), module, slide_offset);
+
SBError sb_error;
TargetSP target_sp(GetSP());
@@ -2155,10 +2228,13 @@ SBError SBTarget::SetModuleLoadAddress(lldb::SBModule module,
} else {
sb_error.SetErrorStringWithFormat("invalid target");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
+ (lldb::SBModule), module);
+
SBError sb_error;
char path[PATH_MAX];
@@ -2204,11 +2280,14 @@ SBError SBTarget::ClearModuleLoadAddress(lldb::SBModule module) {
} else {
sb_error.SetErrorStringWithFormat("invalid target");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
lldb::SymbolType symbol_type) {
+ LLDB_RECORD_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
+ (const char *, lldb::SymbolType), name, symbol_type);
+
SBSymbolContextList sb_sc_list;
if (name && name[0]) {
TargetSP target_sp(GetSP());
@@ -2218,46 +2297,44 @@ lldb::SBSymbolContextList SBTarget::FindSymbols(const char *name,
ConstString(name), symbol_type, *sb_sc_list, append);
}
}
- return sb_sc_list;
+ return LLDB_RECORD_RESULT(sb_sc_list);
}
lldb::SBValue SBTarget::EvaluateExpression(const char *expr) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
+ (const char *), expr);
+
TargetSP target_sp(GetSP());
if (!target_sp)
- return SBValue();
+ return LLDB_RECORD_RESULT(SBValue());
SBExpressionOptions options;
lldb::DynamicValueType fetch_dynamic_value =
target_sp->GetPreferDynamicValue();
options.SetFetchDynamicValue(fetch_dynamic_value);
options.SetUnwindOnError(true);
- return EvaluateExpression(expr, options);
+ return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
}
lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
const SBExpressionOptions &options) {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-#if !defined(LLDB_DISABLE_PYTHON)
+ LLDB_RECORD_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &), expr,
+ options);
+
Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-#endif
SBValue expr_result;
- ExpressionResults exe_results = eExpressionSetupError;
ValueObjectSP expr_value_sp;
TargetSP target_sp(GetSP());
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
if (target_sp) {
- if (expr == NULL || expr[0] == '\0') {
- if (log)
- log->Printf(
- "SBTarget::EvaluateExpression called with an empty expression");
- return expr_result;
+ if (expr == nullptr || expr[0] == '\0') {
+ return LLDB_RECORD_RESULT(expr_result);
}
std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
ExecutionContext exe_ctx(m_opaque_sp.get());
- if (log)
- log->Printf("SBTarget()::EvaluateExpression (expr=\"%s\")...", expr);
frame = exe_ctx.GetFramePtr();
Target *target = exe_ctx.GetTargetPtr();
@@ -2273,33 +2350,21 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr,
expr, options.GetFetchDynamicValue(),
frame_description.GetString().str().c_str());
#endif
- exe_results =
- target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
+ target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
- } else {
- if (log)
- log->Printf("SBTarget::EvaluateExpression () => error: could not "
- "reconstruct frame object for this SBTarget.");
}
}
-#ifndef LLDB_DISABLE_PYTHON
if (expr_log)
expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is "
"%s, summary %s **",
expr_result.GetValue(), expr_result.GetSummary());
-
- if (log)
- log->Printf("SBTarget(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) "
- "(execution result=%d)",
- static_cast<void *>(frame), expr,
- static_cast<void *>(expr_value_sp.get()), exe_results);
-#endif
-
- return expr_result;
+ return LLDB_RECORD_RESULT(expr_result);
}
lldb::addr_t SBTarget::GetStackRedZoneSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBTarget, GetStackRedZoneSize);
+
TargetSP target_sp(GetSP());
if (target_sp) {
ABISP abi_sp;
@@ -2315,15 +2380,267 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() {
}
lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
- lldb::SBLaunchInfo launch_info(NULL);
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo);
+
+ lldb::SBLaunchInfo launch_info(nullptr);
TargetSP target_sp(GetSP());
if (target_sp)
launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
- return launch_info;
+ return LLDB_RECORD_RESULT(launch_info);
}
void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) {
+ LLDB_RECORD_METHOD(void, SBTarget, SetLaunchInfo,
+ (const lldb::SBLaunchInfo &), launch_info);
+
TargetSP target_sp(GetSP());
if (target_sp)
m_opaque_sp->SetProcessLaunchInfo(launch_info.ref());
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTarget>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTarget, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::SBTarget &));
+ LLDB_REGISTER_CONSTRUCTOR(SBTarget, (const lldb::TargetSP &));
+ LLDB_REGISTER_METHOD(const lldb::SBTarget &,
+ SBTarget, operator=,(const lldb::SBTarget &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBTarget, SBTarget, GetTargetFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(uint32_t, SBTarget, GetNumModulesFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBModule, SBTarget,
+ GetModuleAtIndexFromEvent,
+ (const uint32_t, const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBTarget, GetBroadcasterClassName,
+ ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTarget, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, GetProcess, ());
+ LLDB_REGISTER_METHOD(lldb::SBPlatform, SBTarget, GetPlatform, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBDebugger, SBTarget, GetDebugger, ());
+ LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTarget, GetStatistics, ());
+ LLDB_REGISTER_METHOD(void, SBTarget, SetCollectingStats, (bool));
+ LLDB_REGISTER_METHOD(bool, SBTarget, GetCollectingStats, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LoadCore,
+ (const char *, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, LaunchSimple,
+ (const char **, const char **, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, Install, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch,
+ (lldb::SBListener &, const char **, const char **,
+ const char *, const char *, const char *,
+ const char *, uint32_t, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Launch,
+ (lldb::SBLaunchInfo &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, Attach,
+ (lldb::SBAttachInfo &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBTarget, AttachToProcessWithID,
+ (lldb::SBListener &, lldb::pid_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBProcess, SBTarget, AttachToProcessWithName,
+ (lldb::SBListener &, const char *, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBProcess, SBTarget, ConnectRemote,
+ (lldb::SBListener &, const char *, const char *, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBTarget, GetExecutable, ());
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBTarget, operator==,(const lldb::SBTarget &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBTarget, operator!=,(const lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveLoadAddress,
+ (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolveFileAddress,
+ (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBTarget, ResolvePastLoadAddress,
+ (uint32_t, lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContext, SBTarget,
+ ResolveSymbolContextForAddress,
+ (const lldb::SBAddress &, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateByLocation, (const char *, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, lldb::addr_t,
+ lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateByLocation,
+ (const lldb::SBFileSpec &, uint32_t, uint32_t,
+ lldb::addr_t, lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, uint32_t, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByName,
+ (const char *, uint32_t, lldb::LanguageType,
+ const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
+ (const char **, uint32_t, uint32_t,
+ const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
+ (const char **, uint32_t, uint32_t, lldb::LanguageType,
+ const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByNames,
+ (const char **, uint32_t, uint32_t, lldb::LanguageType,
+ lldb::addr_t, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, BreakpointCreateByRegex,
+ (const char *, lldb::LanguageType,
+ const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateByAddress, (lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateBySBAddress, (lldb::SBAddress &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
+ (const char *, const lldb::SBFileSpec &, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateBySourceRegex,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBBreakpoint, SBTarget, BreakpointCreateBySourceRegex,
+ (const char *, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &, const lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget,
+ BreakpointCreateForException,
+ (lldb::LanguageType, bool, bool));
+ LLDB_REGISTER_METHOD(
+ lldb::SBBreakpoint, SBTarget, BreakpointCreateFromScript,
+ (const char *, lldb::SBStructuredData &, const lldb::SBFileSpecList &,
+ const lldb::SBFileSpecList &, bool));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumBreakpoints, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBBreakpoint, SBTarget,
+ GetBreakpointAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTarget, BreakpointDelete, (lldb::break_id_t));
+ LLDB_REGISTER_METHOD(lldb::SBBreakpoint, SBTarget, FindBreakpointByID,
+ (lldb::break_id_t));
+ LLDB_REGISTER_METHOD(bool, SBTarget, FindBreakpointsByName,
+ (const char *, lldb::SBBreakpointList &));
+ LLDB_REGISTER_METHOD(void, SBTarget, GetBreakpointNames,
+ (lldb::SBStringList &));
+ LLDB_REGISTER_METHOD(void, SBTarget, DeleteBreakpointName, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllBreakpoints, ());
+ LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllBreakpoints, ());
+ LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllBreakpoints, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsCreateFromFile,
+ (lldb::SBFileSpec &, lldb::SBBreakpointList &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBError, SBTarget, BreakpointsCreateFromFile,
+ (lldb::SBFileSpec &, lldb::SBStringList &, lldb::SBBreakpointList &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
+ (lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, BreakpointsWriteToFile,
+ (lldb::SBFileSpec &, lldb::SBBreakpointList &, bool));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumWatchpoints, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBWatchpoint, SBTarget,
+ GetWatchpointAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTarget, DeleteWatchpoint, (lldb::watch_id_t));
+ LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, FindWatchpointByID,
+ (lldb::watch_id_t));
+ LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBTarget, WatchAddress,
+ (lldb::addr_t, size_t, bool, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(bool, SBTarget, EnableAllWatchpoints, ());
+ LLDB_REGISTER_METHOD(bool, SBTarget, DisableAllWatchpoints, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromAddress,
+ (const char *, lldb::SBAddress, lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromData,
+ (const char *, lldb::SBData, lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, CreateValueFromExpression,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(bool, SBTarget, DeleteAllWatchpoints, ());
+ LLDB_REGISTER_METHOD(void, SBTarget, AppendImageSearchPath,
+ (const char *, const char *, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule,
+ (const char *, const char *, const char *));
+ LLDB_REGISTER_METHOD(
+ lldb::SBModule, SBTarget, AddModule,
+ (const char *, const char *, const char *, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, AddModule,
+ (const lldb::SBModuleSpec &));
+ LLDB_REGISTER_METHOD(bool, SBTarget, AddModule, (lldb::SBModule &));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBTarget, GetNumModules, ());
+ LLDB_REGISTER_METHOD(void, SBTarget, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, FindModule,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindCompileUnits,
+ (const lldb::SBFileSpec &));
+ LLDB_REGISTER_METHOD(lldb::ByteOrder, SBTarget, GetByteOrder, ());
+ LLDB_REGISTER_METHOD(const char *, SBTarget, GetTriple, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetDataByteSize, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetCodeByteSize, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTarget, GetAddressByteSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBModule, SBTarget, GetModuleAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTarget, RemoveModule, (lldb::SBModule));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBBroadcaster, SBTarget, GetBroadcaster,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBTarget, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindFunctions,
+ (const char *, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget,
+ FindGlobalFunctions,
+ (const char *, uint32_t, lldb::MatchType));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, FindFirstType, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTarget, GetBasicType,
+ (lldb::BasicType));
+ LLDB_REGISTER_METHOD(lldb::SBTypeList, SBTarget, FindTypes, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
+ (const char *, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBValueList, SBTarget, FindGlobalVariables,
+ (const char *, uint32_t, lldb::MatchType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, FindFirstGlobalVariable,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBSourceManager, SBTarget, GetSourceManager, ());
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
+ (lldb::SBAddress, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, ReadInstructions,
+ (lldb::SBAddress, uint32_t, const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetSectionLoadAddress,
+ (lldb::SBSection, lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearSectionLoadAddress,
+ (lldb::SBSection));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, SetModuleLoadAddress,
+ (lldb::SBModule, int64_t));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBTarget, ClearModuleLoadAddress,
+ (lldb::SBModule));
+ LLDB_REGISTER_METHOD(lldb::SBSymbolContextList, SBTarget, FindSymbols,
+ (const char *, lldb::SymbolType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &));
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ());
+ LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo,
+ (const lldb::SBLaunchInfo &));
+}
+
+}
+}
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index 2c859d5222d6c..85e9a6b47955a 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -1,17 +1,25 @@
//===-- SBThread.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBThread.h"
-
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
+#include "lldb/API/SBAddress.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBEvent.h"
#include "lldb/API/SBFileSpec.h"
+#include "lldb/API/SBFrame.h"
+#include "lldb/API/SBProcess.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBSymbolContext.h"
+#include "lldb/API/SBThreadCollection.h"
+#include "lldb/API/SBThreadPlan.h"
+#include "lldb/API/SBValue.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/StreamFile.h"
@@ -34,57 +42,58 @@
#include "lldb/Utility/State.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StructuredData.h"
-
-#include "lldb/API/SBAddress.h"
-#include "lldb/API/SBDebugger.h"
-#include "lldb/API/SBEvent.h"
-#include "lldb/API/SBFrame.h"
-#include "lldb/API/SBProcess.h"
-#include "lldb/API/SBThreadCollection.h"
-#include "lldb/API/SBThreadPlan.h"
-#include "lldb/API/SBValue.h"
#include "lldb/lldb-enumerations.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
const char *SBThread::GetBroadcasterClassName() {
+ LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBThread,
+ GetBroadcasterClassName);
+
return Thread::GetStaticBroadcasterClass().AsCString();
}
-//----------------------------------------------------------------------
// Constructors
-//----------------------------------------------------------------------
-SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {}
+SBThread::SBThread() : m_opaque_sp(new ExecutionContextRef()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThread);
+}
SBThread::SBThread(const ThreadSP &lldb_object_sp)
- : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {}
+ : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
+ LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &), lldb_object_sp);
+}
-SBThread::SBThread(const SBThread &rhs)
- : m_opaque_sp(new ExecutionContextRef(*rhs.m_opaque_sp)) {}
+SBThread::SBThread(const SBThread &rhs) : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBThread, (const lldb::SBThread &), rhs);
+
+ m_opaque_sp = clone(rhs.m_opaque_sp);
+}
-//----------------------------------------------------------------------
// Assignment operator
-//----------------------------------------------------------------------
const lldb::SBThread &SBThread::operator=(const SBThread &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBThread &,
+ SBThread, operator=,(const lldb::SBThread &), rhs);
+
if (this != &rhs)
- *m_opaque_sp = *rhs.m_opaque_sp;
- return *this;
+ m_opaque_sp = clone(rhs.m_opaque_sp);
+ return LLDB_RECORD_RESULT(*this);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SBThread::~SBThread() {}
lldb::SBQueue SBThread::GetQueue() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue);
+
SBQueue sb_queue;
QueueSP queue_sp;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope()) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
@@ -92,22 +101,19 @@ lldb::SBQueue SBThread::GetQueue() const {
if (queue_sp) {
sb_queue.SetQueue(queue_sp);
}
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetQueue() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetQueue () => SBQueue(%p)",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- static_cast<void *>(queue_sp.get()));
-
- return sb_queue;
+ return LLDB_RECORD_RESULT(sb_queue);
}
bool SBThread::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, IsValid);
+ return this->operator bool();
+}
+SBThread::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThread, operator bool);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -116,16 +122,20 @@ bool SBThread::IsValid() const {
if (target && process) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock()))
- return m_opaque_sp->GetThreadSP().get() != NULL;
+ return m_opaque_sp->GetThreadSP().get() != nullptr;
}
// Without a valid target & process, this thread can't be valid.
return false;
}
-void SBThread::Clear() { m_opaque_sp->Clear(); }
+void SBThread::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, Clear);
+
+ m_opaque_sp->Clear();
+}
StopReason SBThread::GetStopReason() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThread, GetStopReason);
StopReason reason = eStopReasonInvalid;
std::unique_lock<std::recursive_mutex> lock;
@@ -135,23 +145,15 @@ StopReason SBThread::GetStopReason() {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
return exe_ctx.GetThreadPtr()->GetStopReason();
- } else {
- if (log)
- log->Printf(
- "SBThread(%p)::GetStopReason() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetStopReason () => %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- Thread::StopReasonAsCString(reason));
-
return reason;
}
size_t SBThread::GetStopReasonDataCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThread, GetStopReasonDataCount);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -193,18 +195,15 @@ size_t SBThread::GetStopReasonDataCount() {
return 1;
}
}
- } else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBThread(%p)::GetStopReasonDataCount() => error: process "
- "is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
return 0;
}
uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex, (uint32_t),
+ idx);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -258,18 +257,15 @@ uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) {
return stop_info_sp->GetValue();
}
}
- } else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBThread(%p)::GetStopReasonDataAtIndex() => error: "
- "process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
return 0;
}
bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) {
+ LLDB_RECORD_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON,
+ (lldb::SBStream &), stream);
+
Stream &strm = stream.ref();
std::unique_lock<std::recursive_mutex> lock;
@@ -290,28 +286,33 @@ bool SBThread::GetStopReasonExtendedInfoAsJSON(lldb::SBStream &stream) {
SBThreadCollection
SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {
+ LLDB_RECORD_METHOD(lldb::SBThreadCollection, SBThread,
+ GetStopReasonExtendedBacktraces,
+ (lldb::InstrumentationRuntimeType), type);
+
ThreadCollectionSP threads;
- threads.reset(new ThreadCollection());
+ threads = std::make_shared<ThreadCollection>();
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (!exe_ctx.HasThreadScope())
- return threads;
+ return LLDB_RECORD_RESULT(threads);
ProcessSP process_sp = exe_ctx.GetProcessSP();
StopInfoSP stop_info = exe_ctx.GetThreadPtr()->GetStopInfo();
StructuredData::ObjectSP info = stop_info->GetExtendedInfo();
if (!info)
- return threads;
+ return LLDB_RECORD_RESULT(threads);
- return process_sp->GetInstrumentationRuntime(type)
- ->GetBacktracesFromExtendedStopInfo(info);
+ return LLDB_RECORD_RESULT(process_sp->GetInstrumentationRuntime(type)
+ ->GetBacktracesFromExtendedStopInfo(info));
}
size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t),
+ dst, dst_len);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -324,10 +325,6 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
if (stop_info_sp) {
const char *stop_desc = stop_info_sp->GetDescription();
if (stop_desc) {
- if (log)
- log->Printf(
- "SBThread(%p)::GetStopDescription (dst, dst_len) => \"%s\"",
- static_cast<void *>(exe_ctx.GetThreadPtr()), stop_desc);
if (dst)
return ::snprintf(dst, dst_len, "%s", stop_desc);
else {
@@ -362,7 +359,7 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
stop_desc =
exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
stop_info_sp->GetValue());
- if (stop_desc == NULL || stop_desc[0] == '\0') {
+ if (stop_desc == nullptr || stop_desc[0] == '\0') {
static char signal_desc[] = "signal";
stop_desc = signal_desc;
stop_desc_len =
@@ -392,11 +389,6 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
}
if (stop_desc && stop_desc[0]) {
- if (log)
- log->Printf(
- "SBThread(%p)::GetStopDescription (dst, dst_len) => '%s'",
- static_cast<void *>(exe_ctx.GetThreadPtr()), stop_desc);
-
if (dst)
return ::snprintf(dst, dst_len, "%s", stop_desc) +
1; // Include the NULL byte
@@ -408,12 +400,6 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
}
}
}
- } else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf(
- "SBThread(%p)::GetStopDescription() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
if (dst)
@@ -422,7 +408,8 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {
}
SBValue SBThread::GetStopReturnValue() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetStopReturnValue);
+
ValueObjectSP return_valobj_sp;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -434,21 +421,10 @@ SBValue SBThread::GetStopReturnValue() {
if (stop_info_sp) {
return_valobj_sp = StopInfo::GetReturnValueObject(stop_info_sp);
}
- } else {
- if (log)
- log->Printf(
- "SBThread(%p)::GetStopReturnValue() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetStopReturnValue () => %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- return_valobj_sp.get() ? return_valobj_sp->GetValueAsCString()
- : "<no return value>");
-
- return SBValue(return_valobj_sp);
+ return LLDB_RECORD_RESULT(SBValue(return_valobj_sp));
}
void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
@@ -456,6 +432,8 @@ void SBThread::SetThread(const ThreadSP &lldb_object_sp) {
}
lldb::tid_t SBThread::GetThreadID() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::tid_t, SBThread, GetThreadID);
+
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)
return thread_sp->GetID();
@@ -463,6 +441,8 @@ lldb::tid_t SBThread::GetThreadID() const {
}
uint32_t SBThread::GetIndexID() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBThread, GetIndexID);
+
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)
return thread_sp->GetIndexID();
@@ -470,8 +450,9 @@ uint32_t SBThread::GetIndexID() const {
}
const char *SBThread::GetName() const {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *name = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetName);
+
+ const char *name = nullptr;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -479,72 +460,50 @@ const char *SBThread::GetName() const {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
name = exe_ctx.GetThreadPtr()->GetName();
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetName() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetName () => %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- name ? name : "NULL");
-
return name;
}
const char *SBThread::GetQueueName() const {
- const char *name = NULL;
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBThread, GetQueueName);
+
+ const char *name = nullptr;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope()) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
name = exe_ctx.GetThreadPtr()->GetQueueName();
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetQueueName() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetQueueName () => %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- name ? name : "NULL");
-
return name;
}
lldb::queue_id_t SBThread::GetQueueID() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::queue_id_t, SBThread, GetQueueID);
+
queue_id_t id = LLDB_INVALID_QUEUE_ID;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (exe_ctx.HasThreadScope()) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
id = exe_ctx.GetThreadPtr()->GetQueueID();
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetQueueID() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetQueueID () => 0x%" PRIx64,
- static_cast<void *>(exe_ctx.GetThreadPtr()), id);
-
return id;
}
bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBThread, GetInfoItemByPathAsString,
+ (const char *, lldb::SBStream &), path, strm);
+
bool success = false;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -583,18 +542,9 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) {
}
}
}
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetInfoItemByPathAsString() => error: "
- "process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetInfoItemByPathAsString (\"%s\") => \"%s\"",
- static_cast<void *>(exe_ctx.GetThreadPtr()), path, strm.GetData());
-
return success;
}
@@ -616,7 +566,7 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
// User level plans should be Master Plans so they can be interrupted, other
// plans executed, and then a "continue" will resume the plan.
- if (new_plan != NULL) {
+ if (new_plan != nullptr) {
new_plan->SetIsMasterPlan(true);
new_plan->SetOkayToDiscard(false);
}
@@ -627,27 +577,26 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
if (process->GetTarget().GetDebugger().GetAsyncExecution())
sb_error.ref() = process->Resume();
else
- sb_error.ref() = process->ResumeSynchronous(NULL);
+ sb_error.ref() = process->ResumeSynchronous(nullptr);
return sb_error;
}
void SBThread::StepOver(lldb::RunMode stop_other_threads) {
+ LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode),
+ stop_other_threads);
+
SBError error; // Ignored
StepOver(stop_other_threads, error);
}
void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBThread, StepOver, (lldb::RunMode, lldb::SBError &),
+ stop_other_threads, error);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::StepOver (stop_other_threads='%s')",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- Thread::RunModeAsCString(stop_other_threads));
-
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
return;
@@ -675,29 +624,31 @@ void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
}
void SBThread::StepInto(lldb::RunMode stop_other_threads) {
- StepInto(NULL, stop_other_threads);
+ LLDB_RECORD_METHOD(void, SBThread, StepInto, (lldb::RunMode),
+ stop_other_threads);
+
+ StepInto(nullptr, stop_other_threads);
}
void SBThread::StepInto(const char *target_name,
lldb::RunMode stop_other_threads) {
+ LLDB_RECORD_METHOD(void, SBThread, StepInto, (const char *, lldb::RunMode),
+ target_name, stop_other_threads);
+
SBError error; // Ignored
StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
}
void SBThread::StepInto(const char *target_name, uint32_t end_line,
SBError &error, lldb::RunMode stop_other_threads) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBThread, StepInto,
+ (const char *, uint32_t, lldb::SBError &, lldb::RunMode),
+ target_name, end_line, error, stop_other_threads);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf(
- "SBThread(%p)::StepInto (target_name='%s', stop_other_threads='%s')",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- target_name ? target_name : "<NULL>",
- Thread::RunModeAsCString(stop_other_threads));
-
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
return;
@@ -740,20 +691,18 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line,
}
void SBThread::StepOut() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBThread, StepOut);
+
SBError error; // Ignored
StepOut(error);
}
void SBThread::StepOut(SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBThread, StepOut, (lldb::SBError &), error);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::StepOut ()",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
-
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
return;
@@ -767,7 +716,7 @@ void SBThread::StepOut(SBError &error) {
const LazyBool avoid_no_debug = eLazyBoolCalculate;
Status new_plan_status;
ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
- abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
+ abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
eVoteNoOpinion, 0, new_plan_status, avoid_no_debug));
if (new_plan_status.Success())
@@ -777,33 +726,27 @@ void SBThread::StepOut(SBError &error) {
}
void SBThread::StepOutOfFrame(SBFrame &sb_frame) {
+ LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &),
+ sb_frame);
+
SBError error; // Ignored
StepOutOfFrame(sb_frame, error);
}
void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBThread, StepOutOfFrame,
+ (lldb::SBFrame &, lldb::SBError &), sb_frame, error);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
if (!sb_frame.IsValid()) {
- if (log)
- log->Printf(
- "SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
error.SetErrorString("passed invalid SBFrame object");
return;
}
StackFrameSP frame_sp(sb_frame.GetFrameSP());
- if (log) {
- SBStream frame_desc_strm;
- sb_frame.GetDescription(frame_desc_strm);
- log->Printf("SBThread(%p)::StepOutOfFrame (frame = SBFrame(%p): %s)",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
- }
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
@@ -814,17 +757,13 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
bool stop_other_threads = false;
Thread *thread = exe_ctx.GetThreadPtr();
if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
- log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another "
- "thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- sb_frame.GetThread().GetThreadID(), thread->GetID());
error.SetErrorString("passed a frame from another thread");
return;
}
Status new_plan_status;
ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
- abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
+ abort_other_plans, nullptr, false, stop_other_threads, eVoteYes,
eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status));
if (new_plan_status.Success())
@@ -834,20 +773,19 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
}
void SBThread::StepInstruction(bool step_over) {
+ LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool), step_over);
+
SBError error; // Ignored
StepInstruction(step_over, error);
}
void SBThread::StepInstruction(bool step_over, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBThread, StepInstruction, (bool, lldb::SBError &),
+ step_over, error);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::StepInstruction (step_over=%i)",
- static_cast<void *>(exe_ctx.GetThreadPtr()), step_over);
-
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
return;
@@ -865,20 +803,19 @@ void SBThread::StepInstruction(bool step_over, SBError &error) {
}
void SBThread::RunToAddress(lldb::addr_t addr) {
+ LLDB_RECORD_METHOD(void, SBThread, RunToAddress, (lldb::addr_t), addr);
+
SBError error; // Ignored
RunToAddress(addr, error);
}
void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(void, SBThread, RunToAddress,
+ (lldb::addr_t, lldb::SBError &), addr, error);
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")",
- static_cast<void *>(exe_ctx.GetThreadPtr()), addr);
-
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
return;
@@ -903,8 +840,11 @@ void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) {
SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
lldb::SBFileSpec &sb_file_spec, uint32_t line) {
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepOverUntil,
+ (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t), sb_frame,
+ sb_file_spec, line);
+
SBError sb_error;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
char path[PATH_MAX];
std::unique_lock<std::recursive_mutex> lock;
@@ -912,24 +852,13 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
StackFrameSP frame_sp(sb_frame.GetFrameSP());
- if (log) {
- SBStream frame_desc_strm;
- sb_frame.GetDescription(frame_desc_strm);
- sb_file_spec->GetPath(path, sizeof(path));
- log->Printf("SBThread(%p)::StepOverUntil (frame = SBFrame(%p): %s, "
- "file+line = %s:%u)",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData(),
- path, line);
- }
-
if (exe_ctx.HasThreadScope()) {
Target *target = exe_ctx.GetTargetPtr();
Thread *thread = exe_ctx.GetThreadPtr();
if (line == 0) {
sb_error.SetErrorString("invalid line argument");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
if (!frame_sp) {
@@ -941,7 +870,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
SymbolContext frame_sc;
if (!frame_sp) {
sb_error.SetErrorString("no valid frames in thread to step");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
// If we have a frame, get its line
@@ -949,10 +878,10 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
eSymbolContextCompUnit | eSymbolContextFunction |
eSymbolContextLineEntry | eSymbolContextSymbol);
- if (frame_sc.comp_unit == NULL) {
+ if (frame_sc.comp_unit == nullptr) {
sb_error.SetErrorStringWithFormat(
"frame %u doesn't have debug information", frame_sp->GetFrameIndex());
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
FileSpec step_file_spec;
@@ -964,7 +893,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
step_file_spec = frame_sc.line_entry.file;
else {
sb_error.SetErrorString("invalid file argument or no file for frame");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
}
@@ -1024,29 +953,31 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
} else {
sb_error.SetErrorString("this SBThread object is invalid");
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) {
- return StepUsingScriptedThreadPlan(script_class_name, true);
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *), script_class_name);
+
+ return LLDB_RECORD_RESULT(
+ StepUsingScriptedThreadPlan(script_class_name, true));
}
SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
bool resume_immediately) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *, bool), script_class_name,
+ resume_immediately);
+
SBError error;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log) {
- log->Printf("SBThread(%p)::StepUsingScriptedThreadPlan: class name: %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()), script_class_name);
- }
-
if (!exe_ctx.HasThreadScope()) {
error.SetErrorString("this SBThread object is invalid");
- return error;
+ return LLDB_RECORD_RESULT(error);
}
Thread *thread = exe_ctx.GetThreadPtr();
@@ -1056,78 +987,68 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name,
if (new_plan_status.Fail()) {
error.SetErrorString(new_plan_status.AsCString());
- return error;
+ return LLDB_RECORD_RESULT(error);
}
if (!resume_immediately)
- return error;
+ return LLDB_RECORD_RESULT(error);
if (new_plan_status.Success())
error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
else
error.SetErrorString(new_plan_status.AsCString());
- return error;
+ return LLDB_RECORD_RESULT(error);
}
SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, JumpToLine,
+ (lldb::SBFileSpec &, uint32_t), file_spec, line);
+
SBError sb_error;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::JumpToLine (file+line = %s:%u)",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- file_spec->GetPath().c_str(), line);
-
if (!exe_ctx.HasThreadScope()) {
sb_error.SetErrorString("this SBThread object is invalid");
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
Thread *thread = exe_ctx.GetThreadPtr();
Status err = thread->JumpToLine(file_spec.get(), line, true);
sb_error.SetError(err);
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBThread::ReturnFromFrame(SBFrame &frame, SBValue &return_value) {
- SBError sb_error;
+ LLDB_RECORD_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
+ (lldb::SBFrame &, lldb::SBValue &), frame, return_value);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ SBError sb_error;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::ReturnFromFrame (frame=%d)",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- frame.GetFrameID());
-
if (exe_ctx.HasThreadScope()) {
Thread *thread = exe_ctx.GetThreadPtr();
sb_error.SetError(
thread->ReturnFromFrame(frame.GetFrameSP(), return_value.GetSP()));
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
SBError SBThread::UnwindInnermostExpression() {
- SBError sb_error;
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBThread,
+ UnwindInnermostExpression);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ SBError sb_error;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
- if (log)
- log->Printf("SBThread(%p)::UnwindExpressionEvaluation",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
-
if (exe_ctx.HasThreadScope()) {
Thread *thread = exe_ctx.GetThreadPtr();
sb_error.SetError(thread->UnwindInnermostExpression());
@@ -1135,16 +1056,19 @@ SBError SBThread::UnwindInnermostExpression() {
thread->SetSelectedFrameByIndex(0, false);
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
bool SBThread::Suspend() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Suspend);
+
SBError error; // Ignored
return Suspend(error);
}
bool SBThread::Suspend(SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBThread, Suspend, (lldb::SBError &), error);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1156,25 +1080,22 @@ bool SBThread::Suspend(SBError &error) {
result = true;
} else {
error.SetErrorString("process is running");
- if (log)
- log->Printf("SBThread(%p)::Suspend() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
} else
error.SetErrorString("this SBThread object is invalid");
- if (log)
- log->Printf("SBThread(%p)::Suspend() => %i",
- static_cast<void *>(exe_ctx.GetThreadPtr()), result);
return result;
}
bool SBThread::Resume() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, Resume);
+
SBError error; // Ignored
return Resume(error);
}
bool SBThread::Resume(SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBThread, Resume, (lldb::SBError &), error);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1187,19 +1108,15 @@ bool SBThread::Resume(SBError &error) {
result = true;
} else {
error.SetErrorString("process is running");
- if (log)
- log->Printf("SBThread(%p)::Resume() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
} else
error.SetErrorString("this SBThread object is invalid");
- if (log)
- log->Printf("SBThread(%p)::Resume() => %i",
- static_cast<void *>(exe_ctx.GetThreadPtr()), result);
return result;
}
bool SBThread::IsSuspended() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsSuspended);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1209,6 +1126,8 @@ bool SBThread::IsSuspended() {
}
bool SBThread::IsStopped() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, IsStopped);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1218,6 +1137,8 @@ bool SBThread::IsStopped() {
}
SBProcess SBThread::GetProcess() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBThread, GetProcess);
+
SBProcess sb_process;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1228,21 +1149,11 @@ SBProcess SBThread::GetProcess() {
sb_process.SetSP(exe_ctx.GetProcessSP());
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- SBStream frame_desc_strm;
- sb_process.GetDescription(frame_desc_strm);
- log->Printf("SBThread(%p)::GetProcess () => SBProcess(%p): %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- static_cast<void *>(sb_process.GetSP().get()),
- frame_desc_strm.GetData());
- }
-
- return sb_process;
+ return LLDB_RECORD_RESULT(sb_process);
}
uint32_t SBThread::GetNumFrames() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread, GetNumFrames);
uint32_t num_frames = 0;
std::unique_lock<std::recursive_mutex> lock;
@@ -1252,22 +1163,14 @@ uint32_t SBThread::GetNumFrames() {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
num_frames = exe_ctx.GetThreadPtr()->GetStackFrameCount();
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetNumFrames() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log)
- log->Printf("SBThread(%p)::GetNumFrames () => %u",
- static_cast<void *>(exe_ctx.GetThreadPtr()), num_frames);
-
return num_frames;
}
SBFrame SBThread::GetFrameAtIndex(uint32_t idx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t), idx);
SBFrame sb_frame;
StackFrameSP frame_sp;
@@ -1279,27 +1182,14 @@ SBFrame SBThread::GetFrameAtIndex(uint32_t idx) {
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
frame_sp = exe_ctx.GetThreadPtr()->GetStackFrameAtIndex(idx);
sb_frame.SetFrameSP(frame_sp);
- } else {
- if (log)
- log->Printf(
- "SBThread(%p)::GetFrameAtIndex() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log) {
- SBStream frame_desc_strm;
- sb_frame.GetDescription(frame_desc_strm);
- log->Printf("SBThread(%p)::GetFrameAtIndex (idx=%d) => SBFrame(%p): %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()), idx,
- static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
- }
-
- return sb_frame;
+ return LLDB_RECORD_RESULT(sb_frame);
}
lldb::SBFrame SBThread::GetSelectedFrame() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBThread, GetSelectedFrame);
SBFrame sb_frame;
StackFrameSP frame_sp;
@@ -1311,27 +1201,15 @@ lldb::SBFrame SBThread::GetSelectedFrame() {
if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
frame_sp = exe_ctx.GetThreadPtr()->GetSelectedFrame();
sb_frame.SetFrameSP(frame_sp);
- } else {
- if (log)
- log->Printf(
- "SBThread(%p)::GetSelectedFrame() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log) {
- SBStream frame_desc_strm;
- sb_frame.GetDescription(frame_desc_strm);
- log->Printf("SBThread(%p)::GetSelectedFrame () => SBFrame(%p): %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
- }
-
- return sb_frame;
+ return LLDB_RECORD_RESULT(sb_frame);
}
lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t),
+ idx);
SBFrame sb_frame;
StackFrameSP frame_sp;
@@ -1347,47 +1225,55 @@ lldb::SBFrame SBThread::SetSelectedFrame(uint32_t idx) {
thread->SetSelectedFrame(frame_sp.get());
sb_frame.SetFrameSP(frame_sp);
}
- } else {
- if (log)
- log->Printf(
- "SBThread(%p)::SetSelectedFrame() => error: process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log) {
- SBStream frame_desc_strm;
- sb_frame.GetDescription(frame_desc_strm);
- log->Printf("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s",
- static_cast<void *>(exe_ctx.GetThreadPtr()), idx,
- static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
- }
- return sb_frame;
+ return LLDB_RECORD_RESULT(sb_frame);
}
bool SBThread::EventIsThreadEvent(const SBEvent &event) {
- return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != NULL;
+ LLDB_RECORD_STATIC_METHOD(bool, SBThread, EventIsThreadEvent,
+ (const lldb::SBEvent &), event);
+
+ return Thread::ThreadEventData::GetEventDataFromEvent(event.get()) != nullptr;
}
SBFrame SBThread::GetStackFrameFromEvent(const SBEvent &event) {
- return Thread::ThreadEventData::GetStackFrameFromEvent(event.get());
+ LLDB_RECORD_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent,
+ (const lldb::SBEvent &), event);
+
+ return LLDB_RECORD_RESULT(
+ Thread::ThreadEventData::GetStackFrameFromEvent(event.get()));
}
SBThread SBThread::GetThreadFromEvent(const SBEvent &event) {
- return Thread::ThreadEventData::GetThreadFromEvent(event.get());
+ LLDB_RECORD_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent,
+ (const lldb::SBEvent &), event);
+
+ return LLDB_RECORD_RESULT(
+ Thread::ThreadEventData::GetThreadFromEvent(event.get()));
}
bool SBThread::operator==(const SBThread &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBThread, operator==,(const lldb::SBThread &),
+ rhs);
+
return m_opaque_sp->GetThreadSP().get() ==
rhs.m_opaque_sp->GetThreadSP().get();
}
bool SBThread::operator!=(const SBThread &rhs) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBThread, operator!=,(const lldb::SBThread &),
+ rhs);
+
return m_opaque_sp->GetThreadSP().get() !=
rhs.m_opaque_sp->GetThreadSP().get();
}
bool SBThread::GetStatus(SBStream &status) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &),
+ status);
+
Stream &strm = status.ref();
std::unique_lock<std::recursive_mutex> lock;
@@ -1402,10 +1288,16 @@ bool SBThread::GetStatus(SBStream &status) const {
}
bool SBThread::GetDescription(SBStream &description) const {
- return GetDescription(description, false);
+ LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription, (lldb::SBStream &),
+ description);
+
+ return GetDescription(description, false);
}
bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBThread, GetDescription,
+ (lldb::SBStream &, bool), description, stop_format);
+
Stream &strm = description.ref();
std::unique_lock<std::recursive_mutex> lock;
@@ -1424,14 +1316,16 @@ bool SBThread::GetDescription(SBStream &description, bool stop_format) const {
}
SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread,
+ (const char *), type);
+
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
SBThread sb_origin_thread;
- if (exe_ctx.HasThreadScope()) {
- Process::StopLocker stop_locker;
- if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+ if (exe_ctx.HasThreadScope()) {
ThreadSP real_thread(exe_ctx.GetThreadSP());
if (real_thread) {
ConstString type_const(type);
@@ -1446,38 +1340,20 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
// pointer retains the object.
process->GetExtendedThreadList().AddThread(new_thread_sp);
sb_origin_thread.SetThread(new_thread_sp);
- if (log) {
- const char *queue_name = new_thread_sp->GetQueueName();
- if (queue_name == NULL)
- queue_name = "";
- log->Printf("SBThread(%p)::GetExtendedBacktraceThread() => new "
- "extended Thread "
- "created (%p) with queue_id 0x%" PRIx64
- " queue name '%s'",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- static_cast<void *>(new_thread_sp.get()),
- new_thread_sp->GetQueueID(), queue_name);
- }
}
}
}
}
- } else {
- if (log)
- log->Printf("SBThread(%p)::GetExtendedBacktraceThread() => error: "
- "process is running",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
}
}
- if (log && !sb_origin_thread.IsValid())
- log->Printf("SBThread(%p)::GetExtendedBacktraceThread() is not returning a "
- "Valid thread",
- static_cast<void *>(exe_ctx.GetThreadPtr()));
- return sb_origin_thread;
+ return LLDB_RECORD_RESULT(sb_origin_thread);
}
uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBThread,
+ GetExtendedBacktraceOriginatingIndexID);
+
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)
return thread_sp->GetExtendedBacktraceOriginatingIndexID();
@@ -1485,20 +1361,30 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() {
}
SBValue SBThread::GetCurrentException() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBThread, GetCurrentException);
+
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (!thread_sp) return SBValue();
+ if (!thread_sp)
+ return LLDB_RECORD_RESULT(SBValue());
- return SBValue(thread_sp->GetCurrentException());
+ return LLDB_RECORD_RESULT(SBValue(thread_sp->GetCurrentException()));
}
SBThread SBThread::GetCurrentExceptionBacktrace() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBThread,
+ GetCurrentExceptionBacktrace);
+
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (!thread_sp) return SBThread();
+ if (!thread_sp)
+ return LLDB_RECORD_RESULT(SBThread());
- return SBThread(thread_sp->GetCurrentExceptionBacktrace());
+ return LLDB_RECORD_RESULT(
+ SBThread(thread_sp->GetCurrentExceptionBacktrace()));
}
bool SBThread::SafeToCallFunctions() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThread, SafeToCallFunctions);
+
ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
if (thread_sp)
return thread_sp->SafeToCallFunctions();
@@ -1506,17 +1392,115 @@ bool SBThread::SafeToCallFunctions() {
}
lldb_private::Thread *SBThread::operator->() {
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp.get();
- else
- return NULL;
+ return get();
}
lldb_private::Thread *SBThread::get() {
- ThreadSP thread_sp(m_opaque_sp->GetThreadSP());
- if (thread_sp)
- return thread_sp.get();
- else
- return NULL;
+ return m_opaque_sp->GetThreadSP().get();
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBThread>(Registry &R) {
+ LLDB_REGISTER_STATIC_METHOD(const char *, SBThread, GetBroadcasterClassName,
+ ());
+ LLDB_REGISTER_CONSTRUCTOR(SBThread, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::ThreadSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBThread, (const lldb::SBThread &));
+ LLDB_REGISTER_METHOD(const lldb::SBThread &,
+ SBThread, operator=,(const lldb::SBThread &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBQueue, SBThread, GetQueue, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBThread, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBThread, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBThread, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::StopReason, SBThread, GetStopReason, ());
+ LLDB_REGISTER_METHOD(size_t, SBThread, GetStopReasonDataCount, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBThread, GetStopReasonDataAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBThread, GetStopReasonExtendedInfoAsJSON,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread,
+ GetStopReasonExtendedBacktraces,
+ (lldb::InstrumentationRuntimeType));
+ LLDB_REGISTER_METHOD(size_t, SBThread, GetStopDescription,
+ (char *, size_t));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ());
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetName, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBThread, GetQueueName, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::queue_id_t, SBThread, GetQueueID, ());
+ LLDB_REGISTER_METHOD(bool, SBThread, GetInfoItemByPathAsString,
+ (const char *, lldb::SBStream &));
+ LLDB_REGISTER_METHOD(void, SBThread, StepOver, (lldb::RunMode));
+ LLDB_REGISTER_METHOD(void, SBThread, StepOver,
+ (lldb::RunMode, lldb::SBError &));
+ LLDB_REGISTER_METHOD(void, SBThread, StepInto, (lldb::RunMode));
+ LLDB_REGISTER_METHOD(void, SBThread, StepInto,
+ (const char *, lldb::RunMode));
+ LLDB_REGISTER_METHOD(
+ void, SBThread, StepInto,
+ (const char *, uint32_t, lldb::SBError &, lldb::RunMode));
+ LLDB_REGISTER_METHOD(void, SBThread, StepOut, ());
+ LLDB_REGISTER_METHOD(void, SBThread, StepOut, (lldb::SBError &));
+ LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame, (lldb::SBFrame &));
+ LLDB_REGISTER_METHOD(void, SBThread, StepOutOfFrame,
+ (lldb::SBFrame &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(void, SBThread, StepInstruction, (bool));
+ LLDB_REGISTER_METHOD(void, SBThread, StepInstruction,
+ (bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(void, SBThread, RunToAddress, (lldb::addr_t));
+ LLDB_REGISTER_METHOD(void, SBThread, RunToAddress,
+ (lldb::addr_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepOverUntil,
+ (lldb::SBFrame &, lldb::SBFileSpec &, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan,
+ (const char *, bool));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, JumpToLine,
+ (lldb::SBFileSpec &, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, ReturnFromFrame,
+ (lldb::SBFrame &, lldb::SBValue &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBThread, UnwindInnermostExpression,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBThread, Suspend, ());
+ LLDB_REGISTER_METHOD(bool, SBThread, Suspend, (lldb::SBError &));
+ LLDB_REGISTER_METHOD(bool, SBThread, Resume, ());
+ LLDB_REGISTER_METHOD(bool, SBThread, Resume, (lldb::SBError &));
+ LLDB_REGISTER_METHOD(bool, SBThread, IsSuspended, ());
+ LLDB_REGISTER_METHOD(bool, SBThread, IsStopped, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBThread, GetProcess, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBThread, GetNumFrames, ());
+ LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetFrameAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, GetSelectedFrame, ());
+ LLDB_REGISTER_METHOD(lldb::SBFrame, SBThread, SetSelectedFrame, (uint32_t));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBThread, EventIsThreadEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBFrame, SBThread, GetStackFrameFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBThread, SBThread, GetThreadFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBThread, operator==,(const lldb::SBThread &));
+ LLDB_REGISTER_METHOD_CONST(bool,
+ SBThread, operator!=,(const lldb::SBThread &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetStatus, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBThread, GetDescription,
+ (lldb::SBStream &, bool));
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetExtendedBacktraceThread,
+ (const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBThread,
+ GetExtendedBacktraceOriginatingIndexID, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetCurrentException, ());
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace,
+ ());
+ LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ());
+}
+
+}
}
diff --git a/source/API/SBThreadCollection.cpp b/source/API/SBThreadCollection.cpp
index c424d47b40981..3c1cf98650620 100644
--- a/source/API/SBThreadCollection.cpp
+++ b/source/API/SBThreadCollection.cpp
@@ -1,29 +1,38 @@
//===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBThreadCollection.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBThread.h"
#include "lldb/Target/ThreadList.h"
using namespace lldb;
using namespace lldb_private;
-SBThreadCollection::SBThreadCollection() : m_opaque_sp() {}
+SBThreadCollection::SBThreadCollection() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadCollection);
+}
SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBThreadCollection,
+ (const lldb::SBThreadCollection &), rhs);
+}
const SBThreadCollection &SBThreadCollection::
operator=(const SBThreadCollection &rhs) {
+ LLDB_RECORD_METHOD(
+ const lldb::SBThreadCollection &,
+ SBThreadCollection, operator=,(const lldb::SBThreadCollection &), rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)
@@ -51,17 +60,51 @@ const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const {
return m_opaque_sp;
}
-bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBThreadCollection::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, IsValid);
+ return this->operator bool();
+}
+SBThreadCollection::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
size_t SBThreadCollection::GetSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadCollection, GetSize);
+
if (m_opaque_sp)
return m_opaque_sp->GetSize();
return 0;
}
SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex,
+ (size_t), idx);
+
SBThread thread;
if (m_opaque_sp && idx < m_opaque_sp->GetSize())
thread = m_opaque_sp->GetThreadAtIndex(idx);
- return thread;
+ return LLDB_RECORD_RESULT(thread);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBThreadCollection>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection,
+ (const lldb::SBThreadCollection &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBThreadCollection &,
+ SBThreadCollection, operator=,(const lldb::SBThreadCollection &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, operator bool, ());
+ LLDB_REGISTER_METHOD(size_t, SBThreadCollection, GetSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex,
+ (size_t));
+}
+
+}
}
diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp
index fc54f5b5f87e4..8f6802fe9cef4 100644
--- a/source/API/SBThreadPlan.cpp
+++ b/source/API/SBThreadPlan.cpp
@@ -1,12 +1,12 @@
//===-- SBThreadPlan.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBThread.h"
#include "lldb/API/SBFileSpec.h"
@@ -42,60 +42,98 @@
#include "lldb/API/SBThreadPlan.h"
#include "lldb/API/SBValue.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Constructors
-//----------------------------------------------------------------------
-SBThreadPlan::SBThreadPlan() {}
+SBThreadPlan::SBThreadPlan() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadPlan); }
SBThreadPlan::SBThreadPlan(const ThreadPlanSP &lldb_object_sp)
- : m_opaque_sp(lldb_object_sp) {}
+ : m_opaque_sp(lldb_object_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &),
+ lldb_object_sp);
+}
SBThreadPlan::SBThreadPlan(const SBThreadPlan &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &), rhs);
+}
SBThreadPlan::SBThreadPlan(lldb::SBThread &sb_thread, const char *class_name) {
+ LLDB_RECORD_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *),
+ sb_thread, class_name);
+
Thread *thread = sb_thread.get();
if (thread)
- m_opaque_sp.reset(new ThreadPlanPython(*thread, class_name));
+ m_opaque_sp = std::make_shared<ThreadPlanPython>(*thread, class_name);
}
-//----------------------------------------------------------------------
// Assignment operator
-//----------------------------------------------------------------------
const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBThreadPlan &,
+ SBThreadPlan, operator=,(const lldb::SBThreadPlan &), rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SBThreadPlan::~SBThreadPlan() {}
lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); }
-bool SBThreadPlan::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBThreadPlan::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, IsValid);
+ return this->operator bool();
+}
+SBThreadPlan::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadPlan, operator bool);
-void SBThreadPlan::Clear() { m_opaque_sp.reset(); }
+ return m_opaque_sp.get() != nullptr;
+}
-lldb::StopReason SBThreadPlan::GetStopReason() { return eStopReasonNone; }
+void SBThreadPlan::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBThreadPlan, Clear);
-size_t SBThreadPlan::GetStopReasonDataCount() { return 0; }
+ m_opaque_sp.reset();
+}
-uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) { return 0; }
+lldb::StopReason SBThreadPlan::GetStopReason() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::StopReason, SBThreadPlan, GetStopReason);
+
+ return eStopReasonNone;
+}
+
+size_t SBThreadPlan::GetStopReasonDataCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadPlan, GetStopReasonDataCount);
+
+ return 0;
+}
+
+uint64_t SBThreadPlan::GetStopReasonDataAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
+ (uint32_t), idx);
+
+ return 0;
+}
SBThread SBThreadPlan::GetThread() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBThread, SBThreadPlan, GetThread);
+
if (m_opaque_sp) {
- return SBThread(m_opaque_sp->GetThread().shared_from_this());
+ return LLDB_RECORD_RESULT(
+ SBThread(m_opaque_sp->GetThread().shared_from_this()));
} else
- return SBThread();
+ return LLDB_RECORD_RESULT(SBThread());
}
bool SBThreadPlan::GetDescription(lldb::SBStream &description) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBThreadPlan, GetDescription,
+ (lldb::SBStream &), description);
+
if (m_opaque_sp) {
m_opaque_sp->GetDescription(description.get(), eDescriptionLevelFull);
} else {
@@ -109,11 +147,15 @@ void SBThreadPlan::SetThreadPlan(const ThreadPlanSP &lldb_object_sp) {
}
void SBThreadPlan::SetPlanComplete(bool success) {
+ LLDB_RECORD_METHOD(void, SBThreadPlan, SetPlanComplete, (bool), success);
+
if (m_opaque_sp)
m_opaque_sp->SetPlanComplete(success);
}
bool SBThreadPlan::IsPlanComplete() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanComplete);
+
if (m_opaque_sp)
return m_opaque_sp->IsPlanComplete();
else
@@ -121,6 +163,8 @@ bool SBThreadPlan::IsPlanComplete() {
}
bool SBThreadPlan::IsPlanStale() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsPlanStale);
+
if (m_opaque_sp)
return m_opaque_sp->IsPlanStale();
else
@@ -128,6 +172,8 @@ bool SBThreadPlan::IsPlanStale() {
}
bool SBThreadPlan::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBThreadPlan, IsValid);
+
if (m_opaque_sp)
return m_opaque_sp->ValidatePlan(nullptr);
else
@@ -143,16 +189,26 @@ bool SBThreadPlan::IsValid() {
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
lldb::addr_t size) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOverRange,
+ (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
+
SBError error;
- return QueueThreadPlanForStepOverRange(sb_start_address, size, error);
+ return LLDB_RECORD_RESULT(
+ QueueThreadPlanForStepOverRange(sb_start_address, size, error));
}
SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
SBAddress &sb_start_address, lldb::addr_t size, SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOverRange,
+ (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
+ sb_start_address, size, error);
+
if (m_opaque_sp) {
Address *start_address = sb_start_address.get();
if (!start_address) {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
AddressRange range(*start_address, size);
@@ -167,26 +223,36 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
- return plan;
+ return LLDB_RECORD_RESULT(plan);
} else {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
lldb::addr_t size) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepInRange,
+ (lldb::SBAddress &, lldb::addr_t), sb_start_address, size);
+
SBError error;
- return QueueThreadPlanForStepInRange(sb_start_address, size, error);
+ return LLDB_RECORD_RESULT(
+ QueueThreadPlanForStepInRange(sb_start_address, size, error));
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
lldb::addr_t size, SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepInRange,
+ (lldb::SBAddress &, lldb::addr_t, lldb::SBError &),
+ sb_start_address, size, error);
+
if (m_opaque_sp) {
Address *start_address = sb_start_address.get();
if (!start_address) {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
AddressRange range(*start_address, size);
@@ -196,27 +262,37 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address,
Status plan_status;
SBThreadPlan plan =
SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange(
- false, range, sc, NULL, eAllThreads, plan_status));
+ false, range, sc, nullptr, eAllThreads, plan_status));
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
- return plan;
+ return LLDB_RECORD_RESULT(plan);
} else {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
bool first_insn) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOut, (uint32_t, bool),
+ frame_idx_to_step_to, first_insn);
+
SBError error;
- return QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error);
+ return LLDB_RECORD_RESULT(
+ QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error));
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
bool first_insn, SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOut,
+ (uint32_t, bool, lldb::SBError &), frame_idx_to_step_to,
+ first_insn, error);
+
if (m_opaque_sp) {
SymbolContext sc;
sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext(
@@ -231,24 +307,32 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
- return plan;
+ return LLDB_RECORD_RESULT(plan);
} else {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForRunToAddress, (lldb::SBAddress),
+ sb_address);
+
SBError error;
- return QueueThreadPlanForRunToAddress(sb_address, error);
+ return LLDB_RECORD_RESULT(QueueThreadPlanForRunToAddress(sb_address, error));
}
SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForRunToAddress,
+ (lldb::SBAddress, lldb::SBError &), sb_address, error);
+
if (m_opaque_sp) {
Address *address = sb_address.get();
if (!address)
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
Status plan_status;
SBThreadPlan plan =
@@ -258,21 +342,30 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
- return plan;
+ return LLDB_RECORD_RESULT(plan);
} else {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepScripted, (const char *),
+ script_class_name);
+
SBError error;
- return QueueThreadPlanForStepScripted(script_class_name, error);
+ return LLDB_RECORD_RESULT(
+ QueueThreadPlanForStepScripted(script_class_name, error));
}
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepScripted,
+ (const char *, lldb::SBError &), script_class_name, error);
+
if (m_opaque_sp) {
Status plan_status;
SBThreadPlan plan =
@@ -282,8 +375,65 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name,
if (plan_status.Fail())
error.SetErrorString(plan_status.AsCString());
- return plan;
+ return LLDB_RECORD_RESULT(plan);
} else {
- return SBThreadPlan();
+ return LLDB_RECORD_RESULT(SBThreadPlan());
}
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBThreadPlan>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::ThreadPlanSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (const lldb::SBThreadPlan &));
+ LLDB_REGISTER_CONSTRUCTOR(SBThreadPlan, (lldb::SBThread &, const char *));
+ LLDB_REGISTER_METHOD(const lldb::SBThreadPlan &,
+ SBThreadPlan, operator=,(const lldb::SBThreadPlan &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBThreadPlan, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::StopReason, SBThreadPlan, GetStopReason, ());
+ LLDB_REGISTER_METHOD(size_t, SBThreadPlan, GetStopReasonDataCount, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBThreadPlan, GetStopReasonDataAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBThread, SBThreadPlan, GetThread, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBThreadPlan, GetDescription,
+ (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(void, SBThreadPlan, SetPlanComplete, (bool));
+ LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanComplete, ());
+ LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsPlanStale, ());
+ LLDB_REGISTER_METHOD(bool, SBThreadPlan, IsValid, ());
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOverRange,
+ (lldb::SBAddress &, lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOverRange,
+ (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepInRange,
+ (lldb::SBAddress &, lldb::addr_t));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepInRange,
+ (lldb::SBAddress &, lldb::addr_t, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOut, (uint32_t, bool));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepOut,
+ (uint32_t, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForRunToAddress, (lldb::SBAddress));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForRunToAddress,
+ (lldb::SBAddress, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepScripted, (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBThreadPlan, SBThreadPlan,
+ QueueThreadPlanForStepScripted,
+ (const char *, lldb::SBError &));
+}
+
+}
+}
diff --git a/source/API/SBTrace.cpp b/source/API/SBTrace.cpp
index 9a5fa4ed4f462..9b871e6781d9b 100644
--- a/source/API/SBTrace.cpp
+++ b/source/API/SBTrace.cpp
@@ -1,18 +1,19 @@
//===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "SBReproducerPrivate.h"
#include "lldb/Target/Process.h"
-#include "lldb/Utility/Log.h"
#include "lldb/API/SBTrace.h"
#include "lldb/API/SBTraceOptions.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -25,8 +26,11 @@ lldb::ProcessSP SBTrace::GetSP() const { return m_opaque_wp.lock(); }
size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size,
size_t offset, lldb::tid_t thread_id) {
+ LLDB_RECORD_DUMMY(size_t, SBTrace, GetTraceData,
+ (lldb::SBError &, void *, size_t, size_t, lldb::tid_t),
+ error, buf, size, offset, thread_id);
+
ProcessSP process_sp(GetSP());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size);
error.Clear();
@@ -35,30 +39,33 @@ size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size,
} else {
error.SetError(
process_sp->GetData(GetTraceUID(), thread_id, buffer, offset));
- LLDB_LOG(log, "SBTrace::bytes_read - {0}", buffer.size());
}
return buffer.size();
}
size_t SBTrace::GetMetaData(SBError &error, void *buf, size_t size,
size_t offset, lldb::tid_t thread_id) {
+ LLDB_RECORD_DUMMY(size_t, SBTrace, GetMetaData,
+ (lldb::SBError &, void *, size_t, size_t, lldb::tid_t),
+ error, buf, size, offset, thread_id);
+
ProcessSP process_sp(GetSP());
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size);
error.Clear();
if (!process_sp) {
error.SetErrorString("invalid process");
} else {
-
error.SetError(
process_sp->GetMetaData(GetTraceUID(), thread_id, buffer, offset));
- LLDB_LOG(log, "SBTrace::bytes_read - {0}", buffer.size());
}
return buffer.size();
}
void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) {
+ LLDB_RECORD_METHOD(void, SBTrace, StopTrace, (lldb::SBError &, lldb::tid_t),
+ error, thread_id);
+
ProcessSP process_sp(GetSP());
error.Clear();
@@ -70,6 +77,9 @@ void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) {
}
void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) {
+ LLDB_RECORD_METHOD(void, SBTrace, GetTraceConfig,
+ (lldb::SBTraceOptions &, lldb::SBError &), options, error);
+
ProcessSP process_sp(GetSP());
error.Clear();
@@ -82,6 +92,8 @@ void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) {
}
lldb::user_id_t SBTrace::GetTraceUID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBTrace, GetTraceUID);
+
if (m_trace_impl_sp)
return m_trace_impl_sp->uid;
return LLDB_INVALID_UID;
@@ -93,7 +105,9 @@ void SBTrace::SetTraceUID(lldb::user_id_t uid) {
}
SBTrace::SBTrace() {
- m_trace_impl_sp.reset(new TraceImpl);
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTrace);
+
+ m_trace_impl_sp = std::make_shared<TraceImpl>();
if (m_trace_impl_sp)
m_trace_impl_sp->uid = LLDB_INVALID_UID;
}
@@ -101,9 +115,33 @@ SBTrace::SBTrace() {
void SBTrace::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; }
bool SBTrace::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTrace, IsValid);
+ return this->operator bool();
+}
+SBTrace::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTrace, operator bool);
+
if (!m_trace_impl_sp)
return false;
if (!GetSP())
return false;
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTrace>(Registry &R) {
+ LLDB_REGISTER_METHOD(void, SBTrace, StopTrace,
+ (lldb::SBError &, lldb::tid_t));
+ LLDB_REGISTER_METHOD(void, SBTrace, GetTraceConfig,
+ (lldb::SBTraceOptions &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::user_id_t, SBTrace, GetTraceUID, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTrace, ());
+ LLDB_REGISTER_METHOD(bool, SBTrace, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTrace, operator bool, ());
+}
+
+}
+}
diff --git a/source/API/SBTraceOptions.cpp b/source/API/SBTraceOptions.cpp
index 20a8f25a768b1..a24cdd59af0bf 100644
--- a/source/API/SBTraceOptions.cpp
+++ b/source/API/SBTraceOptions.cpp
@@ -1,39 +1,51 @@
//===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTraceOptions.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBError.h"
#include "lldb/API/SBStructuredData.h"
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/TraceOptions.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
SBTraceOptions::SBTraceOptions() {
- m_traceoptions_sp.reset(new TraceOptions());
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTraceOptions);
+
+ m_traceoptions_sp = std::make_shared<TraceOptions>();
}
lldb::TraceType SBTraceOptions::getType() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::TraceType, SBTraceOptions, getType);
+
if (m_traceoptions_sp)
return m_traceoptions_sp->getType();
return lldb::TraceType::eTraceTypeNone;
}
uint64_t SBTraceOptions::getTraceBufferSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions,
+ getTraceBufferSize);
+
if (m_traceoptions_sp)
return m_traceoptions_sp->getTraceBufferSize();
return 0;
}
lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams,
+ (lldb::SBError &), error);
+
error.Clear();
const lldb_private::StructuredData::DictionarySP dict_obj =
m_traceoptions_sp->getTraceParams();
@@ -42,16 +54,22 @@ lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) {
structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this());
else
error.SetErrorString("Empty trace params");
- return structData;
+ return LLDB_RECORD_RESULT(structData);
}
uint64_t SBTraceOptions::getMetaDataBufferSize() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions,
+ getMetaDataBufferSize);
+
if (m_traceoptions_sp)
return m_traceoptions_sp->getTraceBufferSize();
return 0;
}
void SBTraceOptions::setTraceParams(lldb::SBStructuredData &params) {
+ LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceParams,
+ (lldb::SBStructuredData &), params);
+
if (m_traceoptions_sp && params.m_impl_up) {
StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP();
if (obj_sp && obj_sp->GetAsDictionary() != nullptr)
@@ -62,33 +80,80 @@ void SBTraceOptions::setTraceParams(lldb::SBStructuredData &params) {
}
void SBTraceOptions::setType(lldb::TraceType type) {
+ LLDB_RECORD_METHOD(void, SBTraceOptions, setType, (lldb::TraceType), type);
+
if (m_traceoptions_sp)
m_traceoptions_sp->setType(type);
}
void SBTraceOptions::setTraceBufferSize(uint64_t size) {
+ LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t),
+ size);
+
if (m_traceoptions_sp)
m_traceoptions_sp->setTraceBufferSize(size);
}
void SBTraceOptions::setMetaDataBufferSize(uint64_t size) {
+ LLDB_RECORD_METHOD(void, SBTraceOptions, setMetaDataBufferSize, (uint64_t),
+ size);
+
if (m_traceoptions_sp)
m_traceoptions_sp->setMetaDataBufferSize(size);
}
bool SBTraceOptions::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTraceOptions, IsValid);
+ return this->operator bool();
+}
+SBTraceOptions::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTraceOptions, operator bool);
+
if (m_traceoptions_sp)
return true;
return false;
}
void SBTraceOptions::setThreadID(lldb::tid_t thread_id) {
+ LLDB_RECORD_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t),
+ thread_id);
+
if (m_traceoptions_sp)
m_traceoptions_sp->setThreadID(thread_id);
}
lldb::tid_t SBTraceOptions::getThreadID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBTraceOptions, getThreadID);
+
if (m_traceoptions_sp)
return m_traceoptions_sp->getThreadID();
return LLDB_INVALID_THREAD_ID;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTraceOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTraceOptions, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::TraceType, SBTraceOptions, getType, ());
+ LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getTraceBufferSize,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams,
+ (lldb::SBError &));
+ LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getMetaDataBufferSize,
+ ());
+ LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceParams,
+ (lldb::SBStructuredData &));
+ LLDB_REGISTER_METHOD(void, SBTraceOptions, setType, (lldb::TraceType));
+ LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t));
+ LLDB_REGISTER_METHOD(void, SBTraceOptions, setMetaDataBufferSize,
+ (uint64_t));
+ LLDB_REGISTER_METHOD(bool, SBTraceOptions, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTraceOptions, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t));
+ LLDB_REGISTER_METHOD(lldb::tid_t, SBTraceOptions, getThreadID, ());
+}
+
+}
+}
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index 77d7dc654100a..5402128b3faeb 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -1,13 +1,13 @@
//===-- SBType.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBType.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeEnumMember.h"
@@ -16,15 +16,16 @@
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/APSInt.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-SBType::SBType() : m_opaque_sp() {}
+SBType::SBType() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBType); }
SBType::SBType(const CompilerType &type)
: m_opaque_sp(new TypeImpl(
@@ -37,16 +38,20 @@ SBType::SBType(const lldb::TypeImplSP &type_impl_sp)
: m_opaque_sp(type_impl_sp) {}
SBType::SBType(const SBType &rhs) : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBType, (const lldb::SBType &), rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
}
// SBType::SBType (TypeImpl* impl) :
-// m_opaque_ap(impl)
+// m_opaque_up(impl)
//{}
//
bool SBType::operator==(SBType &rhs) {
+ LLDB_RECORD_METHOD(bool, SBType, operator==,(lldb::SBType &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -57,6 +62,8 @@ bool SBType::operator==(SBType &rhs) {
}
bool SBType::operator!=(SBType &rhs) {
+ LLDB_RECORD_METHOD(bool, SBType, operator!=,(lldb::SBType &), rhs);
+
if (!IsValid())
return rhs.IsValid();
@@ -73,17 +80,20 @@ void SBType::SetSP(const lldb::TypeImplSP &type_impl_sp) {
}
SBType &SBType::operator=(const SBType &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBType &, SBType, operator=,(const lldb::SBType &),
+ rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBType::~SBType() {}
TypeImpl &SBType::ref() {
- if (m_opaque_sp.get() == NULL)
- m_opaque_sp.reset(new TypeImpl());
+ if (m_opaque_sp.get() == nullptr)
+ m_opaque_sp = std::make_shared<TypeImpl>();
return *m_opaque_sp;
}
@@ -96,13 +106,21 @@ const TypeImpl &SBType::ref() const {
}
bool SBType::IsValid() const {
- if (m_opaque_sp.get() == NULL)
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType, IsValid);
+ return this->operator bool();
+}
+SBType::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBType, operator bool);
+
+ if (m_opaque_sp.get() == nullptr)
return false;
return m_opaque_sp->IsValid();
}
uint64_t SBType::GetByteSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBType, GetByteSize);
+
if (IsValid())
if (llvm::Optional<uint64_t> size =
m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr))
@@ -111,12 +129,16 @@ uint64_t SBType::GetByteSize() {
}
bool SBType::IsPointerType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPointerType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsPointerType();
}
bool SBType::IsArrayType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsArrayType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr,
@@ -124,63 +146,88 @@ bool SBType::IsArrayType() {
}
bool SBType::IsVectorType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsVectorType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr);
}
bool SBType::IsReferenceType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsReferenceType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsReferenceType();
}
SBType SBType::GetPointerType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointerType);
+
if (!IsValid())
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType())));
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointerType()))));
}
SBType SBType::GetPointeeType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetPointeeType);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType())));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetPointeeType()))));
}
SBType SBType::GetReferenceType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetReferenceType);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType())));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetReferenceType()))));
}
SBType SBType::GetTypedefedType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetTypedefedType);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType())));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType()))));
}
SBType SBType::GetDereferencedType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetDereferencedType);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType())));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetDereferencedType()))));
}
SBType SBType::GetArrayElementType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetArrayElementType);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(
- new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType())));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(SBType(TypeImplSP(
+ new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType()))));
}
SBType SBType::GetArrayType(uint64_t size) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBType, GetArrayType, (uint64_t), size);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(
- new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size))));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(SBType(TypeImplSP(
+ new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayType(size)))));
}
SBType SBType::GetVectorElementType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetVectorElementType);
+
SBType type_sb;
if (IsValid()) {
CompilerType vector_element_type;
@@ -188,44 +235,57 @@ SBType SBType::GetVectorElementType() {
nullptr))
type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
}
- return type_sb;
+ return LLDB_RECORD_RESULT(type_sb);
}
bool SBType::IsFunctionType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsFunctionType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsFunctionType();
}
bool SBType::IsPolymorphicClass() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsPolymorphicClass);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass();
}
bool SBType::IsTypedefType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypedefType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsTypedefType();
}
bool SBType::IsAnonymousType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsAnonymousType);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(true).IsAnonymousType();
}
lldb::SBType SBType::GetFunctionReturnType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetFunctionReturnType);
+
if (IsValid()) {
CompilerType return_type(
m_opaque_sp->GetCompilerType(true).GetFunctionReturnType());
if (return_type.IsValid())
- return SBType(return_type);
+ return LLDB_RECORD_RESULT(SBType(return_type));
}
- return lldb::SBType();
+ return LLDB_RECORD_RESULT(lldb::SBType());
}
lldb::SBTypeList SBType::GetFunctionArgumentTypes() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeList, SBType,
+ GetFunctionArgumentTypes);
+
SBTypeList sb_type_list;
if (IsValid()) {
CompilerType func_type(m_opaque_sp->GetCompilerType(true));
@@ -234,10 +294,12 @@ lldb::SBTypeList SBType::GetFunctionArgumentTypes() {
sb_type_list.Append(SBType(func_type.GetFunctionArgumentAtIndex(i)));
}
}
- return sb_type_list;
+ return LLDB_RECORD_RESULT(sb_type_list);
}
uint32_t SBType::GetNumberOfMemberFunctions() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfMemberFunctions);
+
if (IsValid()) {
return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions();
}
@@ -245,51 +307,71 @@ uint32_t SBType::GetNumberOfMemberFunctions() {
}
lldb::SBTypeMemberFunction SBType::GetMemberFunctionAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBTypeMemberFunction, SBType,
+ GetMemberFunctionAtIndex, (uint32_t), idx);
+
SBTypeMemberFunction sb_func_type;
if (IsValid())
sb_func_type.reset(new TypeMemberFunctionImpl(
m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx)));
- return sb_func_type;
+ return LLDB_RECORD_RESULT(sb_func_type);
}
lldb::SBType SBType::GetUnqualifiedType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetUnqualifiedType);
+
if (!IsValid())
- return SBType();
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType())));
+ return LLDB_RECORD_RESULT(SBType());
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetUnqualifiedType()))));
}
lldb::SBType SBType::GetCanonicalType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBType, GetCanonicalType);
+
if (IsValid())
- return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType())));
- return SBType();
+ return LLDB_RECORD_RESULT(
+ SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCanonicalType()))));
+ return LLDB_RECORD_RESULT(SBType());
}
lldb::BasicType SBType::GetBasicType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::BasicType, SBType, GetBasicType);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration();
return eBasicTypeInvalid;
}
SBType SBType::GetBasicType(lldb::BasicType basic_type) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType),
+ basic_type);
+
if (IsValid() && m_opaque_sp->IsValid())
- return SBType(
- m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type));
- return SBType();
+ return LLDB_RECORD_RESULT(SBType(
+ m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type)));
+ return LLDB_RECORD_RESULT(SBType());
}
uint32_t SBType::GetNumberOfDirectBaseClasses() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfDirectBaseClasses);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses();
return 0;
}
uint32_t SBType::GetNumberOfVirtualBaseClasses() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfVirtualBaseClasses);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses();
return 0;
}
uint32_t SBType::GetNumberOfFields() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfFields);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(true).GetNumFields();
return 0;
@@ -297,6 +379,10 @@ uint32_t SBType::GetNumberOfFields() {
bool SBType::GetDescription(SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBType, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
Stream &strm = description.ref();
if (m_opaque_sp) {
@@ -308,6 +394,9 @@ bool SBType::GetDescription(SBStream &description,
}
SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex,
+ (uint32_t), idx);
+
SBTypeMember sb_type_member;
if (IsValid()) {
uint32_t bit_offset = 0;
@@ -318,10 +407,13 @@ SBTypeMember SBType::GetDirectBaseClassAtIndex(uint32_t idx) {
sb_type_member.reset(new TypeMemberImpl(
TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
}
- return sb_type_member;
+ return LLDB_RECORD_RESULT(sb_type_member);
}
SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex,
+ (uint32_t), idx);
+
SBTypeMember sb_type_member;
if (IsValid()) {
uint32_t bit_offset = 0;
@@ -332,17 +424,20 @@ SBTypeMember SBType::GetVirtualBaseClassAtIndex(uint32_t idx) {
sb_type_member.reset(new TypeMemberImpl(
TypeImplSP(new TypeImpl(base_class_type)), bit_offset));
}
- return sb_type_member;
+ return LLDB_RECORD_RESULT(sb_type_member);
}
SBTypeEnumMemberList SBType::GetEnumMembers() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeEnumMemberList, SBType,
+ GetEnumMembers);
+
SBTypeEnumMemberList sb_enum_member_list;
if (IsValid()) {
CompilerType this_type(m_opaque_sp->GetCompilerType(true));
if (this_type.IsValid()) {
this_type.ForEachEnumerator([&sb_enum_member_list](
const CompilerType &integer_type,
- const ConstString &name,
+ ConstString name,
const llvm::APSInt &value) -> bool {
SBTypeEnumMember enum_member(
lldb::TypeEnumMemberImplSP(new TypeEnumMemberImpl(
@@ -352,10 +447,13 @@ SBTypeEnumMemberList SBType::GetEnumMembers() {
});
}
}
- return sb_enum_member_list;
+ return LLDB_RECORD_RESULT(sb_enum_member_list);
}
SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex, (uint32_t),
+ idx);
+
SBTypeMember sb_type_member;
if (IsValid()) {
CompilerType this_type(m_opaque_sp->GetCompilerType(false));
@@ -376,48 +474,63 @@ SBTypeMember SBType::GetFieldAtIndex(uint32_t idx) {
}
}
}
- return sb_type_member;
+ return LLDB_RECORD_RESULT(sb_type_member);
}
bool SBType::IsTypeComplete() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBType, IsTypeComplete);
+
if (!IsValid())
return false;
return m_opaque_sp->GetCompilerType(false).IsCompleteType();
}
uint32_t SBType::GetTypeFlags() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetTypeFlags);
+
if (!IsValid())
return 0;
return m_opaque_sp->GetCompilerType(true).GetTypeInfo();
}
const char *SBType::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetName);
+
if (!IsValid())
return "";
return m_opaque_sp->GetName().GetCString();
}
const char *SBType::GetDisplayTypeName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBType, GetDisplayTypeName);
+
if (!IsValid())
return "";
return m_opaque_sp->GetDisplayTypeName().GetCString();
}
lldb::TypeClass SBType::GetTypeClass() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeClass, SBType, GetTypeClass);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(true).GetTypeClass();
return lldb::eTypeClassInvalid;
}
uint32_t SBType::GetNumberOfTemplateArguments() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBType, GetNumberOfTemplateArguments);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments();
return 0;
}
lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBType, GetTemplateArgumentType, (uint32_t),
+ idx);
+
if (!IsValid())
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
CompilerType type;
switch(GetTemplateArgumentKind(idx)) {
@@ -433,132 +546,190 @@ lldb::SBType SBType::GetTemplateArgumentType(uint32_t idx) {
break;
}
if (type.IsValid())
- return SBType(type);
- return SBType();
+ return LLDB_RECORD_RESULT(SBType(type));
+ return LLDB_RECORD_RESULT(SBType());
}
lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::TemplateArgumentKind, SBType,
+ GetTemplateArgumentKind, (uint32_t), idx);
+
if (IsValid())
return m_opaque_sp->GetCompilerType(false).GetTemplateArgumentKind(idx);
return eTemplateArgumentKindNull;
}
-SBTypeList::SBTypeList() : m_opaque_ap(new TypeListImpl()) {}
+SBTypeList::SBTypeList() : m_opaque_up(new TypeListImpl()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeList);
+}
SBTypeList::SBTypeList(const SBTypeList &rhs)
- : m_opaque_ap(new TypeListImpl()) {
+ : m_opaque_up(new TypeListImpl()) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeList, (const lldb::SBTypeList &), rhs);
+
for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
i < rhs_size; i++)
Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
}
-bool SBTypeList::IsValid() { return (m_opaque_ap != NULL); }
+bool SBTypeList::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeList, IsValid);
+ return this->operator bool();
+}
+SBTypeList::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeList, operator bool);
+
+ return (m_opaque_up != nullptr);
+}
SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeList &,
+ SBTypeList, operator=,(const lldb::SBTypeList &), rhs);
+
if (this != &rhs) {
- m_opaque_ap.reset(new TypeListImpl());
+ m_opaque_up.reset(new TypeListImpl());
for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
i < rhs_size; i++)
Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
void SBTypeList::Append(SBType type) {
+ LLDB_RECORD_METHOD(void, SBTypeList, Append, (lldb::SBType), type);
+
if (type.IsValid())
- m_opaque_ap->Append(type.m_opaque_sp);
+ m_opaque_up->Append(type.m_opaque_sp);
}
SBType SBTypeList::GetTypeAtIndex(uint32_t index) {
- if (m_opaque_ap)
- return SBType(m_opaque_ap->GetTypeAtIndex(index));
- return SBType();
+ LLDB_RECORD_METHOD(lldb::SBType, SBTypeList, GetTypeAtIndex, (uint32_t),
+ index);
+
+ if (m_opaque_up)
+ return LLDB_RECORD_RESULT(SBType(m_opaque_up->GetTypeAtIndex(index)));
+ return LLDB_RECORD_RESULT(SBType());
}
-uint32_t SBTypeList::GetSize() { return m_opaque_ap->GetSize(); }
+uint32_t SBTypeList::GetSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeList, GetSize);
+
+ return m_opaque_up->GetSize();
+}
SBTypeList::~SBTypeList() {}
-SBTypeMember::SBTypeMember() : m_opaque_ap() {}
+SBTypeMember::SBTypeMember() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMember);
+}
SBTypeMember::~SBTypeMember() {}
-SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_ap() {
+SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &), rhs);
+
if (this != &rhs) {
if (rhs.IsValid())
- m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
+ m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
}
}
lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeMember &,
+ SBTypeMember, operator=,(const lldb::SBTypeMember &), rhs);
+
if (this != &rhs) {
if (rhs.IsValid())
- m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
+ m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-bool SBTypeMember::IsValid() const { return m_opaque_ap.get(); }
+bool SBTypeMember::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember, IsValid);
+ return this->operator bool();
+}
+SBTypeMember::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMember, operator bool);
+
+ return m_opaque_up.get();
+}
const char *SBTypeMember::GetName() {
- if (m_opaque_ap)
- return m_opaque_ap->GetName().GetCString();
- return NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMember, GetName);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetName().GetCString();
+ return nullptr;
}
SBType SBTypeMember::GetType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMember, GetType);
+
SBType sb_type;
- if (m_opaque_ap) {
- sb_type.SetSP(m_opaque_ap->GetTypeImpl());
+ if (m_opaque_up) {
+ sb_type.SetSP(m_opaque_up->GetTypeImpl());
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
uint64_t SBTypeMember::GetOffsetInBytes() {
- if (m_opaque_ap)
- return m_opaque_ap->GetBitOffset() / 8u;
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBytes);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetBitOffset() / 8u;
return 0;
}
uint64_t SBTypeMember::GetOffsetInBits() {
- if (m_opaque_ap)
- return m_opaque_ap->GetBitOffset();
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeMember, GetOffsetInBits);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetBitOffset();
return 0;
}
bool SBTypeMember::IsBitfield() {
- if (m_opaque_ap)
- return m_opaque_ap->GetIsBitfield();
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeMember, IsBitfield);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetIsBitfield();
return false;
}
uint32_t SBTypeMember::GetBitfieldSizeInBits() {
- if (m_opaque_ap)
- return m_opaque_ap->GetBitfieldBitSize();
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMember, GetBitfieldSizeInBits);
+
+ if (m_opaque_up)
+ return m_opaque_up->GetBitfieldBitSize();
return 0;
}
bool SBTypeMember::GetDescription(lldb::SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeMember, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
Stream &strm = description.ref();
- if (m_opaque_ap) {
- const uint32_t bit_offset = m_opaque_ap->GetBitOffset();
+ if (m_opaque_up) {
+ const uint32_t bit_offset = m_opaque_up->GetBitOffset();
const uint32_t byte_offset = bit_offset / 8u;
const uint32_t byte_bit_offset = bit_offset % 8u;
- const char *name = m_opaque_ap->GetName().GetCString();
+ const char *name = m_opaque_up->GetName().GetCString();
if (byte_bit_offset)
strm.Printf("+%u + %u bits: (", byte_offset, byte_bit_offset);
else
strm.Printf("+%u: (", byte_offset);
- TypeImplSP type_impl_sp(m_opaque_ap->GetTypeImpl());
+ TypeImplSP type_impl_sp(m_opaque_up->GetTypeImpl());
if (type_impl_sp)
type_impl_sp->GetDescription(strm, description_level);
strm.Printf(") %s", name);
- if (m_opaque_ap->GetIsBitfield()) {
- const uint32_t bitfield_bit_size = m_opaque_ap->GetBitfieldBitSize();
+ if (m_opaque_up->GetIsBitfield()) {
+ const uint32_t bitfield_bit_size = m_opaque_up->GetBitfieldBitSize();
strm.Printf(" : %u", bitfield_bit_size);
}
} else {
@@ -568,40 +739,63 @@ bool SBTypeMember::GetDescription(lldb::SBStream &description,
}
void SBTypeMember::reset(TypeMemberImpl *type_member_impl) {
- m_opaque_ap.reset(type_member_impl);
+ m_opaque_up.reset(type_member_impl);
}
TypeMemberImpl &SBTypeMember::ref() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new TypeMemberImpl());
- return *m_opaque_ap;
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new TypeMemberImpl());
+ return *m_opaque_up;
}
-const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap; }
+const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_up; }
-SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {}
+SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMemberFunction);
+}
SBTypeMemberFunction::~SBTypeMemberFunction() {}
SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeMemberFunction,
+ (const lldb::SBTypeMemberFunction &), rhs);
+}
lldb::SBTypeMemberFunction &SBTypeMemberFunction::
operator=(const lldb::SBTypeMemberFunction &rhs) {
+ LLDB_RECORD_METHOD(
+ lldb::SBTypeMemberFunction &,
+ SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &),
+ rhs);
+
if (this != &rhs)
m_opaque_sp = rhs.m_opaque_sp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-bool SBTypeMemberFunction::IsValid() const { return m_opaque_sp.get(); }
+bool SBTypeMemberFunction::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction, IsValid);
+ return this->operator bool();
+}
+SBTypeMemberFunction::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeMemberFunction, operator bool);
+
+ return m_opaque_sp.get();
+}
const char *SBTypeMemberFunction::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction, GetName);
+
if (m_opaque_sp)
return m_opaque_sp->GetName().GetCString();
- return NULL;
+ return nullptr;
}
const char *SBTypeMemberFunction::GetDemangledName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction,
+ GetDemangledName);
+
if (m_opaque_sp) {
ConstString mangled_str = m_opaque_sp->GetMangledName();
if (mangled_str) {
@@ -609,47 +803,63 @@ const char *SBTypeMemberFunction::GetDemangledName() {
return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString();
}
}
- return NULL;
+ return nullptr;
}
const char *SBTypeMemberFunction::GetMangledName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeMemberFunction,
+ GetMangledName);
+
if (m_opaque_sp)
return m_opaque_sp->GetMangledName().GetCString();
- return NULL;
+ return nullptr;
}
SBType SBTypeMemberFunction::GetType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetType);
+
SBType sb_type;
if (m_opaque_sp) {
sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetType())));
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
lldb::SBType SBTypeMemberFunction::GetReturnType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeMemberFunction, GetReturnType);
+
SBType sb_type;
if (m_opaque_sp) {
sb_type.SetSP(lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetReturnType())));
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
uint32_t SBTypeMemberFunction::GetNumberOfArguments() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeMemberFunction,
+ GetNumberOfArguments);
+
if (m_opaque_sp)
return m_opaque_sp->GetNumArguments();
return 0;
}
lldb::SBType SBTypeMemberFunction::GetArgumentTypeAtIndex(uint32_t i) {
+ LLDB_RECORD_METHOD(lldb::SBType, SBTypeMemberFunction, GetArgumentTypeAtIndex,
+ (uint32_t), i);
+
SBType sb_type;
if (m_opaque_sp) {
sb_type.SetSP(
lldb::TypeImplSP(new TypeImpl(m_opaque_sp->GetArgumentAtIndex(i))));
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::MemberFunctionKind, SBTypeMemberFunction,
+ GetKind);
+
if (m_opaque_sp)
return m_opaque_sp->GetKind();
return lldb::eMemberFunctionKindUnknown;
@@ -657,6 +867,10 @@ lldb::MemberFunctionKind SBTypeMemberFunction::GetKind() {
bool SBTypeMemberFunction::GetDescription(
lldb::SBStream &description, lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeMemberFunction, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
Stream &strm = description.ref();
if (m_opaque_sp)
@@ -671,10 +885,124 @@ void SBTypeMemberFunction::reset(TypeMemberFunctionImpl *type_member_impl) {
TypeMemberFunctionImpl &SBTypeMemberFunction::ref() {
if (!m_opaque_sp)
- m_opaque_sp.reset(new TypeMemberFunctionImpl());
+ m_opaque_sp = std::make_shared<TypeMemberFunctionImpl>();
return *m_opaque_sp.get();
}
const TypeMemberFunctionImpl &SBTypeMemberFunction::ref() const {
return *m_opaque_sp.get();
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBType>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBType, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBType, (const lldb::SBType &));
+ LLDB_REGISTER_METHOD(bool, SBType, operator==,(lldb::SBType &));
+ LLDB_REGISTER_METHOD(bool, SBType, operator!=,(lldb::SBType &));
+ LLDB_REGISTER_METHOD(lldb::SBType &,
+ SBType, operator=,(const lldb::SBType &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBType, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBType, operator bool, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBType, GetByteSize, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsPointerType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsArrayType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsVectorType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsReferenceType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetPointerType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetPointeeType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetReferenceType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetTypedefedType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetDereferencedType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetArrayElementType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetArrayType, (uint64_t));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetVectorElementType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsFunctionType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsPolymorphicClass, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsTypedefType, ());
+ LLDB_REGISTER_METHOD(bool, SBType, IsAnonymousType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetFunctionReturnType, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeList, SBType, GetFunctionArgumentTypes,
+ ());
+ LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfMemberFunctions, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeMemberFunction, SBType,
+ GetMemberFunctionAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetUnqualifiedType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetCanonicalType, ());
+ LLDB_REGISTER_METHOD(lldb::BasicType, SBType, GetBasicType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetBasicType, (lldb::BasicType));
+ LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfDirectBaseClasses, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfVirtualBaseClasses, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfFields, ());
+ LLDB_REGISTER_METHOD(bool, SBType, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetDirectBaseClassAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetVirtualBaseClassAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeEnumMemberList, SBType, GetEnumMembers,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeMember, SBType, GetFieldAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBType, IsTypeComplete, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBType, GetTypeFlags, ());
+ LLDB_REGISTER_METHOD(const char *, SBType, GetName, ());
+ LLDB_REGISTER_METHOD(const char *, SBType, GetDisplayTypeName, ());
+ LLDB_REGISTER_METHOD(lldb::TypeClass, SBType, GetTypeClass, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBType, GetNumberOfTemplateArguments, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBType, GetTemplateArgumentType,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::TemplateArgumentKind, SBType,
+ GetTemplateArgumentKind, (uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeList, (const lldb::SBTypeList &));
+ LLDB_REGISTER_METHOD(bool, SBTypeList, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeList, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeList &,
+ SBTypeList, operator=,(const lldb::SBTypeList &));
+ LLDB_REGISTER_METHOD(void, SBTypeList, Append, (lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeList, GetTypeAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeList, GetSize, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeMember, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &));
+ LLDB_REGISTER_METHOD(lldb::SBTypeMember &,
+ SBTypeMember, operator=,(const lldb::SBTypeMember &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeMember, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeMember, GetName, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMember, GetType, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBTypeMember, GetOffsetInBytes, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBTypeMember, GetOffsetInBits, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeMember, IsBitfield, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeMember, GetBitfieldSizeInBits, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeMember, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeMemberFunction,
+ (const lldb::SBTypeMemberFunction &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeMemberFunction &,
+ SBTypeMemberFunction, operator=,(const lldb::SBTypeMemberFunction &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeMemberFunction, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetName, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetDemangledName,
+ ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeMemberFunction, GetMangledName,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetType, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction, GetReturnType, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeMemberFunction, GetNumberOfArguments,
+ ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeMemberFunction,
+ GetArgumentTypeAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::MemberFunctionKind, SBTypeMemberFunction,
+ GetKind, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeMemberFunction, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+}
+
+}
+}
diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp
index 7c2a37e7cf215..43d5a3ab140fb 100644
--- a/source/API/SBTypeCategory.cpp
+++ b/source/API/SBTypeCategory.cpp
@@ -1,14 +1,14 @@
//===-- SBTypeCategory.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeCategory.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBTypeFilter.h"
@@ -27,26 +27,42 @@ using namespace lldb_private;
typedef std::pair<lldb::TypeCategoryImplSP, user_id_t> ImplType;
-SBTypeCategory::SBTypeCategory() : m_opaque_sp() {}
+SBTypeCategory::SBTypeCategory() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeCategory);
+}
SBTypeCategory::SBTypeCategory(const char *name) : m_opaque_sp() {
DataVisualization::Categories::GetCategory(ConstString(name), m_opaque_sp);
}
SBTypeCategory::SBTypeCategory(const lldb::SBTypeCategory &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &), rhs);
+}
SBTypeCategory::~SBTypeCategory() {}
-bool SBTypeCategory::IsValid() const { return (m_opaque_sp.get() != NULL); }
+bool SBTypeCategory::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, IsValid);
+ return this->operator bool();
+}
+SBTypeCategory::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, operator bool);
+
+ return (m_opaque_sp.get() != nullptr);
+}
bool SBTypeCategory::GetEnabled() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeCategory, GetEnabled);
+
if (!IsValid())
return false;
return m_opaque_sp->IsEnabled();
}
void SBTypeCategory::SetEnabled(bool enabled) {
+ LLDB_RECORD_METHOD(void, SBTypeCategory, SetEnabled, (bool), enabled);
+
if (!IsValid())
return;
if (enabled)
@@ -56,29 +72,41 @@ void SBTypeCategory::SetEnabled(bool enabled) {
}
const char *SBTypeCategory::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeCategory, GetName);
+
if (!IsValid())
- return NULL;
+ return nullptr;
return m_opaque_sp->GetName();
}
lldb::LanguageType SBTypeCategory::GetLanguageAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::LanguageType, SBTypeCategory, GetLanguageAtIndex,
+ (uint32_t), idx);
+
if (IsValid())
return m_opaque_sp->GetLanguageAtIndex(idx);
return lldb::eLanguageTypeUnknown;
}
uint32_t SBTypeCategory::GetNumLanguages() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumLanguages);
+
if (IsValid())
return m_opaque_sp->GetNumLanguages();
return 0;
}
void SBTypeCategory::AddLanguage(lldb::LanguageType language) {
+ LLDB_RECORD_METHOD(void, SBTypeCategory, AddLanguage, (lldb::LanguageType),
+ language);
+
if (IsValid())
m_opaque_sp->AddLanguage(language);
}
uint32_t SBTypeCategory::GetNumFormats() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumFormats);
+
if (!IsValid())
return 0;
@@ -87,6 +115,8 @@ uint32_t SBTypeCategory::GetNumFormats() {
}
uint32_t SBTypeCategory::GetNumSummaries() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSummaries);
+
if (!IsValid())
return 0;
return m_opaque_sp->GetTypeSummariesContainer()->GetCount() +
@@ -94,61 +124,77 @@ uint32_t SBTypeCategory::GetNumSummaries() {
}
uint32_t SBTypeCategory::GetNumFilters() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumFilters);
+
if (!IsValid())
return 0;
return m_opaque_sp->GetTypeFiltersContainer()->GetCount() +
m_opaque_sp->GetRegexTypeFiltersContainer()->GetCount();
}
-#ifndef LLDB_DISABLE_PYTHON
uint32_t SBTypeCategory::GetNumSynthetics() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSynthetics);
+
if (!IsValid())
return 0;
return m_opaque_sp->GetTypeSyntheticsContainer()->GetCount() +
m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetCount();
}
-#endif
lldb::SBTypeNameSpecifier
SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForFilterAtIndex, (uint32_t), index);
+
if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(
- m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index));
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier());
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForFilterAtIndex(index)));
}
lldb::SBTypeNameSpecifier
SBTypeCategory::GetTypeNameSpecifierForFormatAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForFormatAtIndex, (uint32_t), index);
+
if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(
- m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index));
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier());
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForFormatAtIndex(index)));
}
lldb::SBTypeNameSpecifier
SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForSummaryAtIndex, (uint32_t), index);
+
if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(
- m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index));
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier());
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index)));
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::SBTypeNameSpecifier
SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t),
+ index);
+
if (!IsValid())
- return SBTypeNameSpecifier();
- return SBTypeNameSpecifier(
- m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index));
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier());
+ return LLDB_RECORD_RESULT(SBTypeNameSpecifier(
+ m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index)));
}
-#endif
SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType,
+ (lldb::SBTypeNameSpecifier), spec);
+
if (!IsValid())
- return SBTypeFilter();
+ return LLDB_RECORD_RESULT(SBTypeFilter());
if (!spec.IsValid())
- return SBTypeFilter();
+ return LLDB_RECORD_RESULT(SBTypeFilter());
lldb::TypeFilterImplSP children_sp;
@@ -160,19 +206,22 @@ SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) {
ConstString(spec.GetName()), children_sp);
if (!children_sp)
- return lldb::SBTypeFilter();
+ return LLDB_RECORD_RESULT(lldb::SBTypeFilter());
TypeFilterImplSP filter_sp =
std::static_pointer_cast<TypeFilterImpl>(children_sp);
- return lldb::SBTypeFilter(filter_sp);
+ return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp));
}
SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatForType,
+ (lldb::SBTypeNameSpecifier), spec);
+
if (!IsValid())
- return SBTypeFormat();
+ return LLDB_RECORD_RESULT(SBTypeFormat());
if (!spec.IsValid())
- return SBTypeFormat();
+ return LLDB_RECORD_RESULT(SBTypeFormat());
lldb::TypeFormatImplSP format_sp;
@@ -184,18 +233,20 @@ SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) {
ConstString(spec.GetName()), format_sp);
if (!format_sp)
- return lldb::SBTypeFormat();
+ return LLDB_RECORD_RESULT(lldb::SBTypeFormat());
- return lldb::SBTypeFormat(format_sp);
+ return LLDB_RECORD_RESULT(lldb::SBTypeFormat(format_sp));
}
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType,
+ (lldb::SBTypeNameSpecifier), spec);
+
if (!IsValid())
- return SBTypeSummary();
+ return LLDB_RECORD_RESULT(SBTypeSummary());
if (!spec.IsValid())
- return SBTypeSummary();
+ return LLDB_RECORD_RESULT(SBTypeSummary());
lldb::TypeSummaryImplSP summary_sp;
@@ -207,19 +258,20 @@ SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) {
ConstString(spec.GetName()), summary_sp);
if (!summary_sp)
- return lldb::SBTypeSummary();
+ return LLDB_RECORD_RESULT(lldb::SBTypeSummary());
- return lldb::SBTypeSummary(summary_sp);
+ return LLDB_RECORD_RESULT(lldb::SBTypeSummary(summary_sp));
}
-#endif // LLDB_DISABLE_PYTHON
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticForType,
+ (lldb::SBTypeNameSpecifier), spec);
+
if (!IsValid())
- return SBTypeSynthetic();
+ return LLDB_RECORD_RESULT(SBTypeSynthetic());
if (!spec.IsValid())
- return SBTypeSynthetic();
+ return LLDB_RECORD_RESULT(SBTypeSynthetic());
lldb::SyntheticChildrenSP children_sp;
@@ -231,65 +283,76 @@ SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) {
ConstString(spec.GetName()), children_sp);
if (!children_sp)
- return lldb::SBTypeSynthetic();
+ return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic());
ScriptedSyntheticChildrenSP synth_sp =
std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
- return lldb::SBTypeSynthetic(synth_sp);
+ return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp));
}
-#endif
-#ifndef LLDB_DISABLE_PYTHON
SBTypeFilter SBTypeCategory::GetFilterAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex,
+ (uint32_t), index);
+
if (!IsValid())
- return SBTypeFilter();
+ return LLDB_RECORD_RESULT(SBTypeFilter());
lldb::SyntheticChildrenSP children_sp =
m_opaque_sp->GetSyntheticAtIndex((index));
if (!children_sp.get())
- return lldb::SBTypeFilter();
+ return LLDB_RECORD_RESULT(lldb::SBTypeFilter());
TypeFilterImplSP filter_sp =
std::static_pointer_cast<TypeFilterImpl>(children_sp);
- return lldb::SBTypeFilter(filter_sp);
+ return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp));
}
-#endif
SBTypeFormat SBTypeCategory::GetFormatAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex,
+ (uint32_t), index);
+
if (!IsValid())
- return SBTypeFormat();
- return SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)));
+ return LLDB_RECORD_RESULT(SBTypeFormat());
+ return LLDB_RECORD_RESULT(
+ SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index))));
}
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSummary SBTypeCategory::GetSummaryAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex,
+ (uint32_t), index);
+
if (!IsValid())
- return SBTypeSummary();
- return SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index)));
+ return LLDB_RECORD_RESULT(SBTypeSummary());
+ return LLDB_RECORD_RESULT(
+ SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index))));
}
-#endif
-#ifndef LLDB_DISABLE_PYTHON
SBTypeSynthetic SBTypeCategory::GetSyntheticAtIndex(uint32_t index) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticAtIndex,
+ (uint32_t), index);
+
if (!IsValid())
- return SBTypeSynthetic();
+ return LLDB_RECORD_RESULT(SBTypeSynthetic());
lldb::SyntheticChildrenSP children_sp =
m_opaque_sp->GetSyntheticAtIndex((index));
if (!children_sp.get())
- return lldb::SBTypeSynthetic();
+ return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic());
ScriptedSyntheticChildrenSP synth_sp =
std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
- return lldb::SBTypeSynthetic(synth_sp);
+ return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp));
}
-#endif
bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name,
SBTypeFormat format) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeFormat,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeFormat), type_name,
+ format);
+
if (!IsValid())
return false;
@@ -312,6 +375,9 @@ bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name,
}
bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeFormat,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!IsValid())
return false;
@@ -326,9 +392,12 @@ bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) {
ConstString(type_name.GetName()));
}
-#ifndef LLDB_DISABLE_PYTHON
bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
SBTypeSummary summary) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSummary,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeSummary),
+ type_name, summary);
+
if (!IsValid())
return false;
@@ -356,7 +425,7 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
if (debugger_sp) {
ScriptInterpreter *interpreter_ptr =
- debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
+ debugger_sp->GetScriptInterpreter();
if (interpreter_ptr) {
std::string output;
if (interpreter_ptr->GenerateTypeScriptFunction(input, output,
@@ -383,9 +452,11 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
return true;
}
-#endif
bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSummary,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!IsValid())
return false;
@@ -402,6 +473,10 @@ bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) {
bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name,
SBTypeFilter filter) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeFilter,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeFilter), type_name,
+ filter);
+
if (!IsValid())
return false;
@@ -424,6 +499,9 @@ bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name,
}
bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeFilter,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!IsValid())
return false;
@@ -438,9 +516,12 @@ bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) {
ConstString(type_name.GetName()));
}
-#ifndef LLDB_DISABLE_PYTHON
bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
SBTypeSynthetic synth) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSynthetic,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic),
+ type_name, synth);
+
if (!IsValid())
return false;
@@ -468,7 +549,7 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
DebuggerSP debugger_sp = lldb_private::Debugger::GetDebuggerAtIndex(j);
if (debugger_sp) {
ScriptInterpreter *interpreter_ptr =
- debugger_sp->GetCommandInterpreter().GetScriptInterpreter();
+ debugger_sp->GetScriptInterpreter();
if (interpreter_ptr) {
std::string output;
if (interpreter_ptr->GenerateTypeSynthClass(input, output,
@@ -497,6 +578,9 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
}
bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic,
+ (lldb::SBTypeNameSpecifier), type_name);
+
if (!IsValid())
return false;
@@ -510,10 +594,13 @@ bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) {
return m_opaque_sp->GetTypeSyntheticsContainer()->Delete(
ConstString(type_name.GetName()));
}
-#endif // LLDB_DISABLE_PYTHON
bool SBTypeCategory::GetDescription(lldb::SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
if (!IsValid())
return false;
description.Printf("Category name: %s\n", GetName());
@@ -522,13 +609,20 @@ bool SBTypeCategory::GetDescription(lldb::SBStream &description,
lldb::SBTypeCategory &SBTypeCategory::
operator=(const lldb::SBTypeCategory &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeCategory &,
+ SBTypeCategory, operator=,(const lldb::SBTypeCategory &),
+ rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, operator==,(lldb::SBTypeCategory &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -536,6 +630,9 @@ bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) {
}
bool SBTypeCategory::operator!=(lldb::SBTypeCategory &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeCategory, operator!=,(lldb::SBTypeCategory &),
+ rhs);
+
if (!IsValid())
return rhs.IsValid();
@@ -563,3 +660,78 @@ bool SBTypeCategory::IsDefaultCategory() {
return (strcmp(m_opaque_sp->GetName(), "default") == 0);
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeCategory>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeCategory, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeCategory, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeCategory, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, GetEnabled, ());
+ LLDB_REGISTER_METHOD(void, SBTypeCategory, SetEnabled, (bool));
+ LLDB_REGISTER_METHOD(const char *, SBTypeCategory, GetName, ());
+ LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeCategory, GetLanguageAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumLanguages, ());
+ LLDB_REGISTER_METHOD(void, SBTypeCategory, AddLanguage,
+ (lldb::LanguageType));
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFormats, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSummaries, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFilters, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSynthetics, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBTypeCategory,
+ GetSyntheticForType, (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBTypeCategory,
+ GetSyntheticAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeSummary,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeSummary));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeSynthetic,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForFilterAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForFormatAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory,
+ GetTypeNameSpecifierForSummaryAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatForType,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeFormat,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeFormat));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeFormat,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSummary,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, AddTypeFilter,
+ (lldb::SBTypeNameSpecifier, lldb::SBTypeFilter));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeFilter,
+ (lldb::SBTypeNameSpecifier));
+ LLDB_REGISTER_METHOD(bool, SBTypeCategory, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeCategory &,
+ SBTypeCategory, operator=,(const lldb::SBTypeCategory &));
+ LLDB_REGISTER_METHOD(bool,
+ SBTypeCategory, operator==,(lldb::SBTypeCategory &));
+ LLDB_REGISTER_METHOD(bool,
+ SBTypeCategory, operator!=,(lldb::SBTypeCategory &));
+}
+
+}
+}
diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp
index 87be40e8b1418..bd0755a140c33 100644
--- a/source/API/SBTypeEnumMember.cpp
+++ b/source/API/SBTypeEnumMember.cpp
@@ -1,13 +1,14 @@
//===-- SBTypeEnumMember.cpp ---------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeEnumMember.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBType.h"
@@ -15,58 +16,81 @@
#include "lldb/Symbol/Type.h"
#include "lldb/Utility/Stream.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() {}
+SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMember);
+}
SBTypeEnumMember::~SBTypeEnumMember() {}
+
SBTypeEnumMember::SBTypeEnumMember(
const lldb::TypeEnumMemberImplSP &enum_member_sp)
: m_opaque_sp(enum_member_sp) {}
SBTypeEnumMember::SBTypeEnumMember(const SBTypeEnumMember &rhs)
: m_opaque_sp() {
- if (this != &rhs) {
- if (rhs.IsValid())
- m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref()));
- }
+ LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMember, (const lldb::SBTypeEnumMember &),
+ rhs);
+
+ m_opaque_sp = clone(rhs.m_opaque_sp);
}
SBTypeEnumMember &SBTypeEnumMember::operator=(const SBTypeEnumMember &rhs) {
- if (this != &rhs) {
- if (rhs.IsValid())
- m_opaque_sp.reset(new TypeEnumMemberImpl(rhs.ref()));
- }
- return *this;
+ LLDB_RECORD_METHOD(
+ SBTypeEnumMember &,
+ SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &), rhs);
+
+ if (this != &rhs)
+ m_opaque_sp = clone(rhs.m_opaque_sp);
+ return LLDB_RECORD_RESULT(*this);
+}
+
+bool SBTypeEnumMember::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMember, IsValid);
+ return this->operator bool();
}
+SBTypeEnumMember::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMember, operator bool);
-bool SBTypeEnumMember::IsValid() const { return m_opaque_sp.get(); }
+ return m_opaque_sp.get();
+}
const char *SBTypeEnumMember::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeEnumMember, GetName);
+
if (m_opaque_sp.get())
return m_opaque_sp->GetName().GetCString();
- return NULL;
+ return nullptr;
}
int64_t SBTypeEnumMember::GetValueAsSigned() {
+ LLDB_RECORD_METHOD_NO_ARGS(int64_t, SBTypeEnumMember, GetValueAsSigned);
+
if (m_opaque_sp.get())
return m_opaque_sp->GetValueAsSigned();
return 0;
}
uint64_t SBTypeEnumMember::GetValueAsUnsigned() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBTypeEnumMember, GetValueAsUnsigned);
+
if (m_opaque_sp.get())
return m_opaque_sp->GetValueAsUnsigned();
return 0;
}
SBType SBTypeEnumMember::GetType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeEnumMember, GetType);
+
SBType sb_type;
if (m_opaque_sp.get()) {
sb_type.SetSP(m_opaque_sp->GetIntegerType());
}
- return sb_type;
+ return LLDB_RECORD_RESULT(sb_type);
}
void SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl) {
@@ -74,8 +98,8 @@ void SBTypeEnumMember::reset(TypeEnumMemberImpl *type_member_impl) {
}
TypeEnumMemberImpl &SBTypeEnumMember::ref() {
- if (m_opaque_sp.get() == NULL)
- m_opaque_sp.reset(new TypeEnumMemberImpl());
+ if (m_opaque_sp.get() == nullptr)
+ m_opaque_sp = std::make_shared<TypeEnumMemberImpl>();
return *m_opaque_sp.get();
}
@@ -84,49 +108,82 @@ const TypeEnumMemberImpl &SBTypeEnumMember::ref() const {
}
SBTypeEnumMemberList::SBTypeEnumMemberList()
- : m_opaque_ap(new TypeEnumMemberListImpl()) {}
+ : m_opaque_up(new TypeEnumMemberListImpl()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMemberList);
+}
SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs)
- : m_opaque_ap(new TypeEnumMemberListImpl()) {
+ : m_opaque_up(new TypeEnumMemberListImpl()) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeEnumMemberList,
+ (const lldb::SBTypeEnumMemberList &), rhs);
+
for (uint32_t i = 0,
rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
i < rhs_size; i++)
Append(const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
}
-bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap != NULL); }
+bool SBTypeEnumMemberList::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeEnumMemberList, IsValid);
+ return this->operator bool();
+}
+SBTypeEnumMemberList::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeEnumMemberList, operator bool);
+
+ return (m_opaque_up != nullptr);
+}
SBTypeEnumMemberList &SBTypeEnumMemberList::
operator=(const SBTypeEnumMemberList &rhs) {
+ LLDB_RECORD_METHOD(
+ lldb::SBTypeEnumMemberList &,
+ SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &),
+ rhs);
+
if (this != &rhs) {
- m_opaque_ap.reset(new TypeEnumMemberListImpl());
+ m_opaque_up.reset(new TypeEnumMemberListImpl());
for (uint32_t i = 0,
rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
i < rhs_size; i++)
Append(
const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i));
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) {
+ LLDB_RECORD_METHOD(void, SBTypeEnumMemberList, Append,
+ (lldb::SBTypeEnumMember), enum_member);
+
if (enum_member.IsValid())
- m_opaque_ap->Append(enum_member.m_opaque_sp);
+ m_opaque_up->Append(enum_member.m_opaque_sp);
}
SBTypeEnumMember
SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index) {
- if (m_opaque_ap)
- return SBTypeEnumMember(m_opaque_ap->GetTypeEnumMemberAtIndex(index));
- return SBTypeEnumMember();
+ LLDB_RECORD_METHOD(lldb::SBTypeEnumMember, SBTypeEnumMemberList,
+ GetTypeEnumMemberAtIndex, (uint32_t), index);
+
+ if (m_opaque_up)
+ return LLDB_RECORD_RESULT(
+ SBTypeEnumMember(m_opaque_up->GetTypeEnumMemberAtIndex(index)));
+ return LLDB_RECORD_RESULT(SBTypeEnumMember());
}
-uint32_t SBTypeEnumMemberList::GetSize() { return m_opaque_ap->GetSize(); }
+uint32_t SBTypeEnumMemberList::GetSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeEnumMemberList, GetSize);
+
+ return m_opaque_up->GetSize();
+}
SBTypeEnumMemberList::~SBTypeEnumMemberList() {}
bool SBTypeEnumMember::GetDescription(
lldb::SBStream &description, lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeEnumMember, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
Stream &strm = description.ref();
if (m_opaque_sp.get()) {
@@ -139,3 +196,40 @@ bool SBTypeEnumMember::GetDescription(
}
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeEnumMember>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMember, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMember,
+ (const lldb::SBTypeEnumMember &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeEnumMember &,
+ SBTypeEnumMember, operator=,(const lldb::SBTypeEnumMember &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMember, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeEnumMember, GetName, ());
+ LLDB_REGISTER_METHOD(int64_t, SBTypeEnumMember, GetValueAsSigned, ());
+ LLDB_REGISTER_METHOD(uint64_t, SBTypeEnumMember, GetValueAsUnsigned, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeEnumMember, GetType, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMemberList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeEnumMemberList,
+ (const lldb::SBTypeEnumMemberList &));
+ LLDB_REGISTER_METHOD(bool, SBTypeEnumMemberList, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeEnumMemberList, operator bool, ());
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeEnumMemberList &,
+ SBTypeEnumMemberList, operator=,(const lldb::SBTypeEnumMemberList &));
+ LLDB_REGISTER_METHOD(void, SBTypeEnumMemberList, Append,
+ (lldb::SBTypeEnumMember));
+ LLDB_REGISTER_METHOD(lldb::SBTypeEnumMember, SBTypeEnumMemberList,
+ GetTypeEnumMemberAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeEnumMemberList, GetSize, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeEnumMember, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+}
+
+}
+}
diff --git a/source/API/SBTypeFilter.cpp b/source/API/SBTypeFilter.cpp
index 9709d2e5da101..d40301b4c1538 100644
--- a/source/API/SBTypeFilter.cpp
+++ b/source/API/SBTypeFilter.cpp
@@ -1,14 +1,14 @@
//===-- SBTypeFilter.cpp ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeFilter.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
@@ -17,31 +17,53 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeFilter::SBTypeFilter() : m_opaque_sp() {}
+SBTypeFilter::SBTypeFilter() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeFilter);
+}
SBTypeFilter::SBTypeFilter(uint32_t options)
- : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {}
+ : m_opaque_sp(TypeFilterImplSP(new TypeFilterImpl(options))) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (uint32_t), options);
+}
SBTypeFilter::SBTypeFilter(const lldb::SBTypeFilter &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &), rhs);
+}
SBTypeFilter::~SBTypeFilter() {}
-bool SBTypeFilter::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBTypeFilter::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, IsValid);
+ return this->operator bool();
+}
+SBTypeFilter::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
uint32_t SBTypeFilter::GetOptions() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFilter, GetOptions);
+
if (IsValid())
return m_opaque_sp->GetOptions();
return 0;
}
void SBTypeFilter::SetOptions(uint32_t value) {
+ LLDB_RECORD_METHOD(void, SBTypeFilter, SetOptions, (uint32_t), value);
+
if (CopyOnWrite_Impl())
m_opaque_sp->SetOptions(value);
}
bool SBTypeFilter::GetDescription(lldb::SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeFilter, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
if (!IsValid())
return false;
else {
@@ -51,27 +73,38 @@ bool SBTypeFilter::GetDescription(lldb::SBStream &description,
}
void SBTypeFilter::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBTypeFilter, Clear);
+
if (CopyOnWrite_Impl())
m_opaque_sp->Clear();
}
uint32_t SBTypeFilter::GetNumberOfExpressionPaths() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFilter,
+ GetNumberOfExpressionPaths);
+
if (IsValid())
return m_opaque_sp->GetCount();
return 0;
}
const char *SBTypeFilter::GetExpressionPathAtIndex(uint32_t i) {
+ LLDB_RECORD_METHOD(const char *, SBTypeFilter, GetExpressionPathAtIndex,
+ (uint32_t), i);
+
if (IsValid()) {
const char *item = m_opaque_sp->GetExpressionPathAtIndex(i);
if (item && *item == '.')
item++;
return item;
}
- return NULL;
+ return nullptr;
}
bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) {
+ LLDB_RECORD_METHOD(bool, SBTypeFilter, ReplaceExpressionPathAtIndex,
+ (uint32_t, const char *), i, item);
+
if (CopyOnWrite_Impl())
return m_opaque_sp->SetExpressionPathAtIndex(i, item);
else
@@ -79,18 +112,27 @@ bool SBTypeFilter::ReplaceExpressionPathAtIndex(uint32_t i, const char *item) {
}
void SBTypeFilter::AppendExpressionPath(const char *item) {
+ LLDB_RECORD_METHOD(void, SBTypeFilter, AppendExpressionPath, (const char *),
+ item);
+
if (CopyOnWrite_Impl())
m_opaque_sp->AddExpressionPath(item);
}
lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFilter &,
+ SBTypeFilter, operator=,(const lldb::SBTypeFilter &), rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -98,6 +140,9 @@ bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) {
}
bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeFilter, IsEqualTo, (lldb::SBTypeFilter &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -113,6 +158,9 @@ bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) {
}
bool SBTypeFilter::operator!=(lldb::SBTypeFilter &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -143,3 +191,36 @@ bool SBTypeFilter::CopyOnWrite_Impl() {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeFilter>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, (uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeFilter, operator bool, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeFilter, GetOptions, ());
+ LLDB_REGISTER_METHOD(void, SBTypeFilter, SetOptions, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTypeFilter, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(void, SBTypeFilter, Clear, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeFilter, GetNumberOfExpressionPaths,
+ ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeFilter, GetExpressionPathAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTypeFilter, ReplaceExpressionPathAtIndex,
+ (uint32_t, const char *));
+ LLDB_REGISTER_METHOD(void, SBTypeFilter, AppendExpressionPath,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFilter &,
+ SBTypeFilter, operator=,(const lldb::SBTypeFilter &));
+ LLDB_REGISTER_METHOD(bool, SBTypeFilter, operator==,(lldb::SBTypeFilter &));
+ LLDB_REGISTER_METHOD(bool, SBTypeFilter, IsEqualTo, (lldb::SBTypeFilter &));
+ LLDB_REGISTER_METHOD(bool, SBTypeFilter, operator!=,(lldb::SBTypeFilter &));
+}
+
+}
+}
diff --git a/source/API/SBTypeFormat.cpp b/source/API/SBTypeFormat.cpp
index 66bfd36717361..6024631e7054f 100644
--- a/source/API/SBTypeFormat.cpp
+++ b/source/API/SBTypeFormat.cpp
@@ -1,14 +1,14 @@
//===-- SBTypeFormat.cpp ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeFormat.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
@@ -17,30 +17,52 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeFormat::SBTypeFormat() : m_opaque_sp() {}
+SBTypeFormat::SBTypeFormat() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeFormat);
+}
SBTypeFormat::SBTypeFormat(lldb::Format format, uint32_t options)
: m_opaque_sp(
- TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) {}
+ TypeFormatImplSP(new TypeFormatImpl_Format(format, options))) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (lldb::Format, uint32_t), format,
+ options);
+}
SBTypeFormat::SBTypeFormat(const char *type, uint32_t options)
: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_EnumType(
- ConstString(type ? type : ""), options))) {}
+ ConstString(type ? type : ""), options))) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const char *, uint32_t), type,
+ options);
+}
SBTypeFormat::SBTypeFormat(const lldb::SBTypeFormat &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &), rhs);
+}
SBTypeFormat::~SBTypeFormat() {}
-bool SBTypeFormat::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBTypeFormat::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, IsValid);
+ return this->operator bool();
+}
+SBTypeFormat::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
lldb::Format SBTypeFormat::GetFormat() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBTypeFormat, GetFormat);
+
if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat)
return ((TypeFormatImpl_Format *)m_opaque_sp.get())->GetFormat();
return lldb::eFormatInvalid;
}
const char *SBTypeFormat::GetTypeName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeFormat, GetTypeName);
+
if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)
return ((TypeFormatImpl_EnumType *)m_opaque_sp.get())
->GetTypeName()
@@ -49,29 +71,41 @@ const char *SBTypeFormat::GetTypeName() {
}
uint32_t SBTypeFormat::GetOptions() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeFormat, GetOptions);
+
if (IsValid())
return m_opaque_sp->GetOptions();
return 0;
}
void SBTypeFormat::SetFormat(lldb::Format fmt) {
+ LLDB_RECORD_METHOD(void, SBTypeFormat, SetFormat, (lldb::Format), fmt);
+
if (CopyOnWrite_Impl(Type::eTypeFormat))
((TypeFormatImpl_Format *)m_opaque_sp.get())->SetFormat(fmt);
}
void SBTypeFormat::SetTypeName(const char *type) {
+ LLDB_RECORD_METHOD(void, SBTypeFormat, SetTypeName, (const char *), type);
+
if (CopyOnWrite_Impl(Type::eTypeEnum))
((TypeFormatImpl_EnumType *)m_opaque_sp.get())
->SetTypeName(ConstString(type ? type : ""));
}
void SBTypeFormat::SetOptions(uint32_t value) {
+ LLDB_RECORD_METHOD(void, SBTypeFormat, SetOptions, (uint32_t), value);
+
if (CopyOnWrite_Impl(Type::eTypeKeepSame))
m_opaque_sp->SetOptions(value);
}
bool SBTypeFormat::GetDescription(lldb::SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeFormat, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
if (!IsValid())
return false;
else {
@@ -81,19 +115,28 @@ bool SBTypeFormat::GetDescription(lldb::SBStream &description,
}
lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeFormat &,
+ SBTypeFormat, operator=,(const lldb::SBTypeFormat &), rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeFormat, operator==,(lldb::SBTypeFormat &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp == rhs.m_opaque_sp;
}
bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeFormat, IsEqualTo, (lldb::SBTypeFormat &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -104,6 +147,9 @@ bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) {
}
bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeFormat, operator!=,(lldb::SBTypeFormat &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp != rhs.m_opaque_sp;
@@ -146,3 +192,32 @@ bool SBTypeFormat::CopyOnWrite_Impl(Type type) {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeFormat>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (lldb::Format, uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (const char *, uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeFormat, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeFormat, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::Format, SBTypeFormat, GetFormat, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeFormat, GetTypeName, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeFormat, GetOptions, ());
+ LLDB_REGISTER_METHOD(void, SBTypeFormat, SetFormat, (lldb::Format));
+ LLDB_REGISTER_METHOD(void, SBTypeFormat, SetTypeName, (const char *));
+ LLDB_REGISTER_METHOD(void, SBTypeFormat, SetOptions, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTypeFormat, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFormat &,
+ SBTypeFormat, operator=,(const lldb::SBTypeFormat &));
+ LLDB_REGISTER_METHOD(bool, SBTypeFormat, operator==,(lldb::SBTypeFormat &));
+ LLDB_REGISTER_METHOD(bool, SBTypeFormat, IsEqualTo, (lldb::SBTypeFormat &));
+ LLDB_REGISTER_METHOD(bool, SBTypeFormat, operator!=,(lldb::SBTypeFormat &));
+}
+
+}
+}
diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp
index 5ffb3d98a0f2f..895f697756598 100644
--- a/source/API/SBTypeNameSpecifier.cpp
+++ b/source/API/SBTypeNameSpecifier.cpp
@@ -1,14 +1,14 @@
//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeNameSpecifier.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBType.h"
@@ -18,44 +18,68 @@
using namespace lldb;
using namespace lldb_private;
-SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() {}
+SBTypeNameSpecifier::SBTypeNameSpecifier() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeNameSpecifier);
+}
SBTypeNameSpecifier::SBTypeNameSpecifier(const char *name, bool is_regex)
: m_opaque_sp(new TypeNameSpecifierImpl(name, is_regex)) {
- if (name == NULL || (*name) == 0)
+ LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool), name,
+ is_regex);
+
+ if (name == nullptr || (*name) == 0)
m_opaque_sp.reset();
}
SBTypeNameSpecifier::SBTypeNameSpecifier(SBType type) : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType), type);
+
if (type.IsValid())
m_opaque_sp = TypeNameSpecifierImplSP(
new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true)));
}
SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeNameSpecifier,
+ (const lldb::SBTypeNameSpecifier &), rhs);
+}
SBTypeNameSpecifier::~SBTypeNameSpecifier() {}
-bool SBTypeNameSpecifier::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBTypeNameSpecifier::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, IsValid);
+ return this->operator bool();
+}
+SBTypeNameSpecifier::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
const char *SBTypeNameSpecifier::GetName() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeNameSpecifier, GetName);
+
if (!IsValid())
- return NULL;
+ return nullptr;
return m_opaque_sp->GetName();
}
SBType SBTypeNameSpecifier::GetType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBTypeNameSpecifier, GetType);
+
if (!IsValid())
- return SBType();
+ return LLDB_RECORD_RESULT(SBType());
lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType();
if (c_type.IsValid())
- return SBType(c_type);
- return SBType();
+ return LLDB_RECORD_RESULT(SBType(c_type));
+ return LLDB_RECORD_RESULT(SBType());
}
bool SBTypeNameSpecifier::IsRegex() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeNameSpecifier, IsRegex);
+
if (!IsValid())
return false;
@@ -64,6 +88,10 @@ bool SBTypeNameSpecifier::IsRegex() {
bool SBTypeNameSpecifier::GetDescription(
lldb::SBStream &description, lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
if (!IsValid())
return false;
description.Printf("SBTypeNameSpecifier(%s,%s)", GetName(),
@@ -73,31 +101,44 @@ bool SBTypeNameSpecifier::GetDescription(
lldb::SBTypeNameSpecifier &SBTypeNameSpecifier::
operator=(const lldb::SBTypeNameSpecifier &rhs) {
+ LLDB_RECORD_METHOD(
+ lldb::SBTypeNameSpecifier &,
+ SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &), rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp == rhs.m_opaque_sp;
}
bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeNameSpecifier, IsEqualTo,
+ (lldb::SBTypeNameSpecifier &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
if (IsRegex() != rhs.IsRegex())
return false;
- if (GetName() == NULL || rhs.GetName() == NULL)
+ if (GetName() == nullptr || rhs.GetName() == nullptr)
return false;
return (strcmp(GetName(), rhs.GetName()) == 0);
}
bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp != rhs.m_opaque_sp;
@@ -115,3 +156,34 @@ void SBTypeNameSpecifier::SetSP(
SBTypeNameSpecifier::SBTypeNameSpecifier(
const lldb::TypeNameSpecifierImplSP &type_namespec_sp)
: m_opaque_sp(type_namespec_sp) {}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeNameSpecifier>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (const char *, bool));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier, (lldb::SBType));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeNameSpecifier,
+ (const lldb::SBTypeNameSpecifier &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeNameSpecifier, operator bool, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeNameSpecifier, GetName, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBTypeNameSpecifier, GetType, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsRegex, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeNameSpecifier &,
+ SBTypeNameSpecifier, operator=,(const lldb::SBTypeNameSpecifier &));
+ LLDB_REGISTER_METHOD(
+ bool, SBTypeNameSpecifier, operator==,(lldb::SBTypeNameSpecifier &));
+ LLDB_REGISTER_METHOD(bool, SBTypeNameSpecifier, IsEqualTo,
+ (lldb::SBTypeNameSpecifier &));
+ LLDB_REGISTER_METHOD(
+ bool, SBTypeNameSpecifier, operator!=,(lldb::SBTypeNameSpecifier &));
+}
+
+}
+}
diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp
index 76c94ae834443..8ffb234357572 100644
--- a/source/API/SBTypeSummary.cpp
+++ b/source/API/SBTypeSummary.cpp
@@ -1,14 +1,15 @@
//===-- SBTypeSummary.cpp -----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeSummary.h"
+#include "SBReproducerPrivate.h"
+#include "Utils.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBValue.h"
#include "lldb/DataFormatters/DataVisualization.h"
@@ -19,109 +20,154 @@ using namespace lldb;
using namespace lldb_private;
SBTypeSummaryOptions::SBTypeSummaryOptions() {
- m_opaque_ap.reset(new TypeSummaryOptions());
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions);
+
+ m_opaque_up.reset(new TypeSummaryOptions());
}
SBTypeSummaryOptions::SBTypeSummaryOptions(
const lldb::SBTypeSummaryOptions &rhs) {
- if (rhs.m_opaque_ap)
- m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap));
- else
- m_opaque_ap.reset(new TypeSummaryOptions());
+ LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions,
+ (const lldb::SBTypeSummaryOptions &), rhs);
+
+ m_opaque_up = clone(rhs.m_opaque_up);
}
SBTypeSummaryOptions::~SBTypeSummaryOptions() {}
-bool SBTypeSummaryOptions::IsValid() { return m_opaque_ap.get(); }
+bool SBTypeSummaryOptions::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummaryOptions, IsValid);
+ return this->operator bool();
+}
+SBTypeSummaryOptions::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummaryOptions, operator bool);
+
+ return m_opaque_up.get();
+}
lldb::LanguageType SBTypeSummaryOptions::GetLanguage() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::LanguageType, SBTypeSummaryOptions,
+ GetLanguage);
+
if (IsValid())
- return m_opaque_ap->GetLanguage();
+ return m_opaque_up->GetLanguage();
return lldb::eLanguageTypeUnknown;
}
lldb::TypeSummaryCapping SBTypeSummaryOptions::GetCapping() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::TypeSummaryCapping, SBTypeSummaryOptions,
+ GetCapping);
+
if (IsValid())
- return m_opaque_ap->GetCapping();
+ return m_opaque_up->GetCapping();
return eTypeSummaryCapped;
}
void SBTypeSummaryOptions::SetLanguage(lldb::LanguageType l) {
+ LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetLanguage,
+ (lldb::LanguageType), l);
+
if (IsValid())
- m_opaque_ap->SetLanguage(l);
+ m_opaque_up->SetLanguage(l);
}
void SBTypeSummaryOptions::SetCapping(lldb::TypeSummaryCapping c) {
+ LLDB_RECORD_METHOD(void, SBTypeSummaryOptions, SetCapping,
+ (lldb::TypeSummaryCapping), c);
+
if (IsValid())
- m_opaque_ap->SetCapping(c);
+ m_opaque_up->SetCapping(c);
}
lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::operator->() {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
const lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::
operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::get() {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
SBTypeSummaryOptions::SBTypeSummaryOptions(
const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeSummaryOptions,
+ (const lldb_private::TypeSummaryOptions *),
+ lldb_object_ptr);
+
SetOptions(lldb_object_ptr);
}
void SBTypeSummaryOptions::SetOptions(
const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
if (lldb_object_ptr)
- m_opaque_ap.reset(new TypeSummaryOptions(*lldb_object_ptr));
+ m_opaque_up.reset(new TypeSummaryOptions(*lldb_object_ptr));
else
- m_opaque_ap.reset(new TypeSummaryOptions());
+ m_opaque_up.reset(new TypeSummaryOptions());
}
-SBTypeSummary::SBTypeSummary() : m_opaque_sp() {}
+SBTypeSummary::SBTypeSummary() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummary);
+}
SBTypeSummary SBTypeSummary::CreateWithSummaryString(const char *data,
uint32_t options) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
+ CreateWithSummaryString, (const char *, uint32_t),
+ data, options);
+
if (!data || data[0] == 0)
- return SBTypeSummary();
+ return LLDB_RECORD_RESULT(SBTypeSummary());
- return SBTypeSummary(
- TypeSummaryImplSP(new StringSummaryFormat(options, data)));
+ return LLDB_RECORD_RESULT(
+ SBTypeSummary(TypeSummaryImplSP(new StringSummaryFormat(options, data))));
}
SBTypeSummary SBTypeSummary::CreateWithFunctionName(const char *data,
uint32_t options) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
+ CreateWithFunctionName, (const char *, uint32_t),
+ data, options);
+
if (!data || data[0] == 0)
- return SBTypeSummary();
+ return LLDB_RECORD_RESULT(SBTypeSummary());
- return SBTypeSummary(
- TypeSummaryImplSP(new ScriptSummaryFormat(options, data)));
+ return LLDB_RECORD_RESULT(
+ SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, data))));
}
SBTypeSummary SBTypeSummary::CreateWithScriptCode(const char *data,
uint32_t options) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
+ CreateWithScriptCode, (const char *, uint32_t),
+ data, options);
+
if (!data || data[0] == 0)
- return SBTypeSummary();
+ return LLDB_RECORD_RESULT(SBTypeSummary());
- return SBTypeSummary(
- TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data)));
+ return LLDB_RECORD_RESULT(SBTypeSummary(
+ TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))));
}
SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb,
uint32_t options,
const char *description) {
+ LLDB_RECORD_DUMMY(
+ lldb::SBTypeSummary, SBTypeSummary, CreateWithCallback,
+ (lldb::SBTypeSummary::FormatCallback, uint32_t, const char *), cb,
+ options, description);
+
SBTypeSummary retval;
if (cb) {
retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat(
@@ -143,13 +189,25 @@ SBTypeSummary SBTypeSummary::CreateWithCallback(FormatCallback cb,
}
SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &), rhs);
+}
SBTypeSummary::~SBTypeSummary() {}
-bool SBTypeSummary::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBTypeSummary::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, IsValid);
+ return this->operator bool();
+}
+SBTypeSummary::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
bool SBTypeSummary::IsFunctionCode() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionCode);
+
if (!IsValid())
return false;
if (ScriptSummaryFormat *script_summary_ptr =
@@ -161,6 +219,8 @@ bool SBTypeSummary::IsFunctionCode() {
}
bool SBTypeSummary::IsFunctionName() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsFunctionName);
+
if (!IsValid())
return false;
if (ScriptSummaryFormat *script_summary_ptr =
@@ -172,6 +232,8 @@ bool SBTypeSummary::IsFunctionName() {
}
bool SBTypeSummary::IsSummaryString() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummary, IsSummaryString);
+
if (!IsValid())
return false;
@@ -179,8 +241,10 @@ bool SBTypeSummary::IsSummaryString() {
}
const char *SBTypeSummary::GetData() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSummary, GetData);
+
if (!IsValid())
- return NULL;
+ return nullptr;
if (ScriptSummaryFormat *script_summary_ptr =
llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) {
const char *fname = script_summary_ptr->GetFunctionName();
@@ -195,18 +259,25 @@ const char *SBTypeSummary::GetData() {
}
uint32_t SBTypeSummary::GetOptions() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSummary, GetOptions);
+
if (!IsValid())
return lldb::eTypeOptionNone;
return m_opaque_sp->GetOptions();
}
void SBTypeSummary::SetOptions(uint32_t value) {
+ LLDB_RECORD_METHOD(void, SBTypeSummary, SetOptions, (uint32_t), value);
+
if (!CopyOnWrite_Impl())
return;
m_opaque_sp->SetOptions(value);
}
void SBTypeSummary::SetSummaryString(const char *data) {
+ LLDB_RECORD_METHOD(void, SBTypeSummary, SetSummaryString, (const char *),
+ data);
+
if (!IsValid())
return;
if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get()))
@@ -217,6 +288,9 @@ void SBTypeSummary::SetSummaryString(const char *data) {
}
void SBTypeSummary::SetFunctionName(const char *data) {
+ LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionName, (const char *),
+ data);
+
if (!IsValid())
return;
if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
@@ -227,6 +301,9 @@ void SBTypeSummary::SetFunctionName(const char *data) {
}
void SBTypeSummary::SetFunctionCode(const char *data) {
+ LLDB_RECORD_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *),
+ data);
+
if (!IsValid())
return;
if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get()))
@@ -238,6 +315,10 @@ void SBTypeSummary::SetFunctionCode(const char *data) {
bool SBTypeSummary::GetDescription(lldb::SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeSummary, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
if (!CopyOnWrite_Impl())
return false;
else {
@@ -247,6 +328,9 @@ bool SBTypeSummary::GetDescription(lldb::SBStream &description,
}
bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) {
+ LLDB_RECORD_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue),
+ value);
+
if (!IsValid())
return false;
lldb::ValueObjectSP value_sp = value.GetSP();
@@ -254,19 +338,29 @@ bool SBTypeSummary::DoesPrintValue(lldb::SBValue value) {
}
lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSummary &,
+ SBTypeSummary, operator=,(const lldb::SBTypeSummary &),
+ rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeSummary, operator==,(lldb::SBTypeSummary &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp == rhs.m_opaque_sp;
}
bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeSummary, IsEqualTo, (lldb::SBTypeSummary &),
+ rhs);
+
if (IsValid()) {
// valid and invalid are different
if (!rhs.IsValid())
@@ -305,6 +399,9 @@ bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) {
}
bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeSummary, operator!=,(lldb::SBTypeSummary &),
+ rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp != rhs.m_opaque_sp;
@@ -376,3 +473,65 @@ bool SBTypeSummary::ChangeSummaryType(bool want_script) {
return true;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeSummaryOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions,
+ (const lldb::SBTypeSummaryOptions &));
+ LLDB_REGISTER_METHOD(bool, SBTypeSummaryOptions, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummaryOptions, operator bool, ());
+ LLDB_REGISTER_METHOD(lldb::LanguageType, SBTypeSummaryOptions, GetLanguage,
+ ());
+ LLDB_REGISTER_METHOD(lldb::TypeSummaryCapping, SBTypeSummaryOptions,
+ GetCapping, ());
+ LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetLanguage,
+ (lldb::LanguageType));
+ LLDB_REGISTER_METHOD(void, SBTypeSummaryOptions, SetCapping,
+ (lldb::TypeSummaryCapping));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSummaryOptions,
+ (const lldb_private::TypeSummaryOptions *));
+}
+
+template <>
+void RegisterMethods<SBTypeSummary>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
+ CreateWithSummaryString,
+ (const char *, uint32_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
+ CreateWithFunctionName,
+ (const char *, uint32_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSummary, SBTypeSummary,
+ CreateWithScriptCode, (const char *, uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeSummary, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionCode, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsFunctionName, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsSummaryString, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeSummary, GetData, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeSummary, GetOptions, ());
+ LLDB_REGISTER_METHOD(void, SBTypeSummary, SetOptions, (uint32_t));
+ LLDB_REGISTER_METHOD(void, SBTypeSummary, SetSummaryString, (const char *));
+ LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionName, (const char *));
+ LLDB_REGISTER_METHOD(void, SBTypeSummary, SetFunctionCode, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBTypeSummary, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(bool, SBTypeSummary, DoesPrintValue, (lldb::SBValue));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeSummary &,
+ SBTypeSummary, operator=,(const lldb::SBTypeSummary &));
+ LLDB_REGISTER_METHOD(bool,
+ SBTypeSummary, operator==,(lldb::SBTypeSummary &));
+ LLDB_REGISTER_METHOD(bool, SBTypeSummary, IsEqualTo,
+ (lldb::SBTypeSummary &));
+ LLDB_REGISTER_METHOD(bool,
+ SBTypeSummary, operator!=,(lldb::SBTypeSummary &));
+}
+
+}
+}
diff --git a/source/API/SBTypeSynthetic.cpp b/source/API/SBTypeSynthetic.cpp
index 750d917e67f15..df6fce1269f09 100644
--- a/source/API/SBTypeSynthetic.cpp
+++ b/source/API/SBTypeSynthetic.cpp
@@ -1,14 +1,14 @@
//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBTypeSynthetic.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
@@ -17,34 +17,55 @@
using namespace lldb;
using namespace lldb_private;
-#ifndef LLDB_DISABLE_PYTHON
-
-SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() {}
+SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSynthetic);
+}
SBTypeSynthetic SBTypeSynthetic::CreateWithClassName(const char *data,
uint32_t options) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic,
+ CreateWithClassName, (const char *, uint32_t), data,
+ options);
+
if (!data || data[0] == 0)
- return SBTypeSynthetic();
- return SBTypeSynthetic(ScriptedSyntheticChildrenSP(
- new ScriptedSyntheticChildren(options, data, "")));
+ return LLDB_RECORD_RESULT(SBTypeSynthetic());
+ return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP(
+ new ScriptedSyntheticChildren(options, data, ""))));
}
SBTypeSynthetic SBTypeSynthetic::CreateWithScriptCode(const char *data,
uint32_t options) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic,
+ CreateWithScriptCode, (const char *, uint32_t),
+ data, options);
+
if (!data || data[0] == 0)
- return SBTypeSynthetic();
- return SBTypeSynthetic(ScriptedSyntheticChildrenSP(
- new ScriptedSyntheticChildren(options, "", data)));
+ return LLDB_RECORD_RESULT(SBTypeSynthetic());
+ return LLDB_RECORD_RESULT(SBTypeSynthetic(ScriptedSyntheticChildrenSP(
+ new ScriptedSyntheticChildren(options, "", data))));
}
SBTypeSynthetic::SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs)
- : m_opaque_sp(rhs.m_opaque_sp) {}
+ : m_opaque_sp(rhs.m_opaque_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBTypeSynthetic, (const lldb::SBTypeSynthetic &),
+ rhs);
+}
SBTypeSynthetic::~SBTypeSynthetic() {}
-bool SBTypeSynthetic::IsValid() const { return m_opaque_sp.get() != NULL; }
+bool SBTypeSynthetic::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, IsValid);
+ return this->operator bool();
+}
+SBTypeSynthetic::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, operator bool);
+
+ return m_opaque_sp.get() != nullptr;
+}
bool SBTypeSynthetic::IsClassCode() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSynthetic, IsClassCode);
+
if (!IsValid())
return false;
const char *code = m_opaque_sp->GetPythonCode();
@@ -52,14 +73,18 @@ bool SBTypeSynthetic::IsClassCode() {
}
bool SBTypeSynthetic::IsClassName() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSynthetic, IsClassName);
+
if (!IsValid())
return false;
return !IsClassCode();
}
const char *SBTypeSynthetic::GetData() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTypeSynthetic, GetData);
+
if (!IsValid())
- return NULL;
+ return nullptr;
if (IsClassCode())
return m_opaque_sp->GetPythonCode();
else
@@ -67,22 +92,30 @@ const char *SBTypeSynthetic::GetData() {
}
void SBTypeSynthetic::SetClassName(const char *data) {
+ LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassName, (const char *), data);
+
if (IsValid() && data && *data)
m_opaque_sp->SetPythonClassName(data);
}
void SBTypeSynthetic::SetClassCode(const char *data) {
+ LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *), data);
+
if (IsValid() && data && *data)
m_opaque_sp->SetPythonCode(data);
}
uint32_t SBTypeSynthetic::GetOptions() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeSynthetic, GetOptions);
+
if (!IsValid())
return lldb::eTypeOptionNone;
return m_opaque_sp->GetOptions();
}
void SBTypeSynthetic::SetOptions(uint32_t value) {
+ LLDB_RECORD_METHOD(void, SBTypeSynthetic, SetOptions, (uint32_t), value);
+
if (!CopyOnWrite_Impl())
return;
m_opaque_sp->SetOptions(value);
@@ -90,6 +123,10 @@ void SBTypeSynthetic::SetOptions(uint32_t value) {
bool SBTypeSynthetic::GetDescription(lldb::SBStream &description,
lldb::DescriptionLevel description_level) {
+ LLDB_RECORD_METHOD(bool, SBTypeSynthetic, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ description_level);
+
if (m_opaque_sp) {
description.Printf("%s\n", m_opaque_sp->GetDescription().c_str());
return true;
@@ -99,19 +136,29 @@ bool SBTypeSynthetic::GetDescription(lldb::SBStream &description,
lldb::SBTypeSynthetic &SBTypeSynthetic::
operator=(const lldb::SBTypeSynthetic &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBTypeSynthetic &,
+ SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &),
+ rhs);
+
if (this != &rhs) {
m_opaque_sp = rhs.m_opaque_sp;
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp == rhs.m_opaque_sp;
}
bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) {
+ LLDB_RECORD_METHOD(bool, SBTypeSynthetic, IsEqualTo,
+ (lldb::SBTypeSynthetic &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
@@ -128,6 +175,9 @@ bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) {
}
bool SBTypeSynthetic::operator!=(lldb::SBTypeSynthetic &rhs) {
+ LLDB_RECORD_METHOD(
+ bool, SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &), rhs);
+
if (!IsValid())
return !rhs.IsValid();
return m_opaque_sp != rhs.m_opaque_sp;
@@ -161,4 +211,38 @@ bool SBTypeSynthetic::CopyOnWrite_Impl() {
return true;
}
-#endif // LLDB_DISABLE_PYTHON
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBTypeSynthetic>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, ());
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic,
+ CreateWithClassName, (const char *, uint32_t));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic,
+ CreateWithScriptCode, (const char *, uint32_t));
+ LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, (const lldb::SBTypeSynthetic &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBTypeSynthetic, operator bool, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsClassCode, ());
+ LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsClassName, ());
+ LLDB_REGISTER_METHOD(const char *, SBTypeSynthetic, GetData, ());
+ LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassName, (const char *));
+ LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetClassCode, (const char *));
+ LLDB_REGISTER_METHOD(uint32_t, SBTypeSynthetic, GetOptions, ());
+ LLDB_REGISTER_METHOD(void, SBTypeSynthetic, SetOptions, (uint32_t));
+ LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(
+ lldb::SBTypeSynthetic &,
+ SBTypeSynthetic, operator=,(const lldb::SBTypeSynthetic &));
+ LLDB_REGISTER_METHOD(bool,
+ SBTypeSynthetic, operator==,(lldb::SBTypeSynthetic &));
+ LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, IsEqualTo,
+ (lldb::SBTypeSynthetic &));
+ LLDB_REGISTER_METHOD(bool,
+ SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &));
+}
+
+}
+}
diff --git a/source/API/SBUnixSignals.cpp b/source/API/SBUnixSignals.cpp
index 14bdd39919c3c..277a92d21ae98 100644
--- a/source/API/SBUnixSignals.cpp
+++ b/source/API/SBUnixSignals.cpp
@@ -1,17 +1,16 @@
//===-- SBUnixSignals.cpp -------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include "SBReproducerPrivate.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/UnixSignals.h"
-#include "lldb/Utility/Log.h"
#include "lldb/lldb-defines.h"
#include "lldb/API/SBUnixSignals.h"
@@ -19,10 +18,14 @@
using namespace lldb;
using namespace lldb_private;
-SBUnixSignals::SBUnixSignals() {}
+SBUnixSignals::SBUnixSignals() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBUnixSignals);
+}
SBUnixSignals::SBUnixSignals(const SBUnixSignals &rhs)
- : m_opaque_wp(rhs.m_opaque_wp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {
+ LLDB_RECORD_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &), rhs);
+}
SBUnixSignals::SBUnixSignals(ProcessSP &process_sp)
: m_opaque_wp(process_sp ? process_sp->GetUnixSignals() : nullptr) {}
@@ -31,9 +34,13 @@ SBUnixSignals::SBUnixSignals(PlatformSP &platform_sp)
: m_opaque_wp(platform_sp ? platform_sp->GetUnixSignals() : nullptr) {}
const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBUnixSignals &,
+ SBUnixSignals, operator=,(const lldb::SBUnixSignals &),
+ rhs);
+
if (this != &rhs)
m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBUnixSignals::~SBUnixSignals() {}
@@ -44,11 +51,26 @@ void SBUnixSignals::SetSP(const UnixSignalsSP &signals_sp) {
m_opaque_wp = signals_sp;
}
-void SBUnixSignals::Clear() { m_opaque_wp.reset(); }
+void SBUnixSignals::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBUnixSignals, Clear);
+
+ m_opaque_wp.reset();
+}
+
+bool SBUnixSignals::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, IsValid);
+ return this->operator bool();
+}
+SBUnixSignals::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBUnixSignals, operator bool);
-bool SBUnixSignals::IsValid() const { return static_cast<bool>(GetSP()); }
+ return static_cast<bool>(GetSP());
+}
const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
+ LLDB_RECORD_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString,
+ (int32_t), signo);
+
if (auto signals_sp = GetSP())
return signals_sp->GetSignalAsCString(signo);
@@ -56,6 +78,9 @@ const char *SBUnixSignals::GetSignalAsCString(int32_t signo) const {
}
int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
+ LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName,
+ (const char *), name);
+
if (auto signals_sp = GetSP())
return signals_sp->GetSignalNumberFromName(name);
@@ -63,6 +88,9 @@ int32_t SBUnixSignals::GetSignalNumberFromName(const char *name) const {
}
bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress, (int32_t),
+ signo);
+
if (auto signals_sp = GetSP())
return signals_sp->GetShouldSuppress(signo);
@@ -70,13 +98,10 @@ bool SBUnixSignals::GetShouldSuppress(int32_t signo) const {
}
bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- auto signals_sp = GetSP();
+ LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldSuppress, (int32_t, bool),
+ signo, value);
- if (log) {
- log->Printf("SBUnixSignals(%p)::SetShouldSuppress (signo=%d, value=%d)",
- static_cast<void *>(signals_sp.get()), signo, value);
- }
+ auto signals_sp = GetSP();
if (signals_sp)
return signals_sp->SetShouldSuppress(signo, value);
@@ -85,6 +110,9 @@ bool SBUnixSignals::SetShouldSuppress(int32_t signo, bool value) {
}
bool SBUnixSignals::GetShouldStop(int32_t signo) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t),
+ signo);
+
if (auto signals_sp = GetSP())
return signals_sp->GetShouldStop(signo);
@@ -92,13 +120,10 @@ bool SBUnixSignals::GetShouldStop(int32_t signo) const {
}
bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- auto signals_sp = GetSP();
+ LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool), signo,
+ value);
- if (log) {
- log->Printf("SBUnixSignals(%p)::SetShouldStop (signo=%d, value=%d)",
- static_cast<void *>(signals_sp.get()), signo, value);
- }
+ auto signals_sp = GetSP();
if (signals_sp)
return signals_sp->SetShouldStop(signo, value);
@@ -107,6 +132,9 @@ bool SBUnixSignals::SetShouldStop(int32_t signo, bool value) {
}
bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
+ LLDB_RECORD_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t),
+ signo);
+
if (auto signals_sp = GetSP())
return signals_sp->GetShouldNotify(signo);
@@ -114,13 +142,10 @@ bool SBUnixSignals::GetShouldNotify(int32_t signo) const {
}
bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- auto signals_sp = GetSP();
+ LLDB_RECORD_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool),
+ signo, value);
- if (log) {
- log->Printf("SBUnixSignals(%p)::SetShouldNotify (signo=%d, value=%d)",
- static_cast<void *>(signals_sp.get()), signo, value);
- }
+ auto signals_sp = GetSP();
if (signals_sp)
return signals_sp->SetShouldNotify(signo, value);
@@ -129,6 +154,8 @@ bool SBUnixSignals::SetShouldNotify(int32_t signo, bool value) {
}
int32_t SBUnixSignals::GetNumSignals() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(int32_t, SBUnixSignals, GetNumSignals);
+
if (auto signals_sp = GetSP())
return signals_sp->GetNumSignals();
@@ -136,8 +163,44 @@ int32_t SBUnixSignals::GetNumSignals() const {
}
int32_t SBUnixSignals::GetSignalAtIndex(int32_t index) const {
+ LLDB_RECORD_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex, (int32_t),
+ index);
+
if (auto signals_sp = GetSP())
return signals_sp->GetSignalAtIndex(index);
return LLDB_INVALID_SIGNAL_NUMBER;
}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBUnixSignals>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &));
+ LLDB_REGISTER_METHOD(
+ const lldb::SBUnixSignals &,
+ SBUnixSignals, operator=,(const lldb::SBUnixSignals &));
+ LLDB_REGISTER_METHOD(void, SBUnixSignals, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(const char *, SBUnixSignals, GetSignalAsCString,
+ (int32_t));
+ LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalNumberFromName,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldSuppress,
+ (int32_t));
+ LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldSuppress,
+ (int32_t, bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldStop, (int32_t));
+ LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldStop, (int32_t, bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBUnixSignals, GetShouldNotify, (int32_t));
+ LLDB_REGISTER_METHOD(bool, SBUnixSignals, SetShouldNotify, (int32_t, bool));
+ LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetNumSignals, ());
+ LLDB_REGISTER_METHOD_CONST(int32_t, SBUnixSignals, GetSignalAtIndex,
+ (int32_t));
+}
+
+}
+}
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index a61a2a19a6216..8383007635229 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -1,13 +1,13 @@
//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBValue.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBDeclaration.h"
#include "lldb/API/SBStream.h"
@@ -36,7 +36,6 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Scalar.h"
#include "lldb/Utility/Stream.h"
@@ -47,6 +46,8 @@
#include "lldb/API/SBTarget.h"
#include "lldb/API/SBThread.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -56,7 +57,7 @@ public:
ValueImpl(lldb::ValueObjectSP in_valobj_sp,
lldb::DynamicValueType use_dynamic, bool use_synthetic,
- const char *name = NULL)
+ const char *name = nullptr)
: m_valobj_sp(), m_use_dynamic(use_dynamic),
m_use_synthetic(use_synthetic), m_name(name) {
if (in_valobj_sp) {
@@ -83,7 +84,7 @@ public:
}
bool IsValid() {
- if (m_valobj_sp.get() == NULL)
+ if (m_valobj_sp.get() == nullptr)
return false;
else {
// FIXME: This check is necessary but not sufficient. We for sure don't
@@ -107,7 +108,6 @@ public:
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker,
std::unique_lock<std::recursive_mutex> &lock,
Status &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (!m_valobj_sp) {
error.SetErrorString("invalid value object");
return m_valobj_sp;
@@ -126,9 +126,6 @@ public:
// We don't allow people to play around with ValueObject if the process
// is running. If you want to look at values, pause the process, then
// look.
- if (log)
- log->Printf("SBValue(%p)::GetSP() => error: process is running",
- static_cast<void *>(value_sp.get()));
error.SetErrorString("process must be stopped.");
return ValueObjectSP();
}
@@ -218,32 +215,55 @@ private:
Status m_lock_error;
};
-SBValue::SBValue() : m_opaque_sp() {}
+SBValue::SBValue() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValue); }
+
+SBValue::SBValue(const lldb::ValueObjectSP &value_sp) {
+ LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &), value_sp);
-SBValue::SBValue(const lldb::ValueObjectSP &value_sp) { SetSP(value_sp); }
+ SetSP(value_sp);
+}
+
+SBValue::SBValue(const SBValue &rhs) {
+ LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::SBValue &), rhs);
-SBValue::SBValue(const SBValue &rhs) { SetSP(rhs.m_opaque_sp); }
+ SetSP(rhs.m_opaque_sp);
+}
SBValue &SBValue::operator=(const SBValue &rhs) {
+ LLDB_RECORD_METHOD(lldb::SBValue &,
+ SBValue, operator=,(const lldb::SBValue &), rhs);
+
if (this != &rhs) {
SetSP(rhs.m_opaque_sp);
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBValue::~SBValue() {}
bool SBValue::IsValid() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsValid);
+ return this->operator bool();
+}
+SBValue::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValue, operator bool);
+
// If this function ever changes to anything that does more than just check
// if the opaque shared pointer is non NULL, then we need to update all "if
// (m_opaque_sp)" code in this file.
- return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() &&
- m_opaque_sp->GetRootSP().get() != NULL;
+ return m_opaque_sp.get() != nullptr && m_opaque_sp->IsValid() &&
+ m_opaque_sp->GetRootSP().get() != nullptr;
}
-void SBValue::Clear() { m_opaque_sp.reset(); }
+void SBValue::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBValue, Clear);
+
+ m_opaque_sp.reset();
+}
SBError SBValue::GetError() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBValue, GetError);
+
SBError sb_error;
ValueLocker locker;
@@ -254,10 +274,12 @@ SBError SBValue::GetError() {
sb_error.SetErrorStringWithFormat("error: %s",
locker.GetError().AsCString());
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
user_id_t SBValue::GetID() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBValue, GetID);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -266,69 +288,46 @@ user_id_t SBValue::GetID() {
}
const char *SBValue::GetName() {
- const char *name = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetName);
+
+ const char *name = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
name = value_sp->GetName().GetCString();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (name)
- log->Printf("SBValue(%p)::GetName () => \"%s\"",
- static_cast<void *>(value_sp.get()), name);
- else
- log->Printf("SBValue(%p)::GetName () => NULL",
- static_cast<void *>(value_sp.get()));
- }
-
return name;
}
const char *SBValue::GetTypeName() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *name = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeName);
+
+ const char *name = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
name = value_sp->GetQualifiedTypeName().GetCString();
}
- if (log) {
- if (name)
- log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
- static_cast<void *>(value_sp.get()), name);
- else
- log->Printf("SBValue(%p)::GetTypeName () => NULL",
- static_cast<void *>(value_sp.get()));
- }
-
return name;
}
const char *SBValue::GetDisplayTypeName() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *name = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetDisplayTypeName);
+
+ const char *name = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
name = value_sp->GetDisplayTypeName().GetCString();
}
- if (log) {
- if (name)
- log->Printf("SBValue(%p)::GetTypeName () => \"%s\"",
- static_cast<void *>(value_sp.get()), name);
- else
- log->Printf("SBValue(%p)::GetTypeName () => NULL",
- static_cast<void *>(value_sp.get()));
- }
-
return name;
}
size_t SBValue::GetByteSize() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBValue, GetByteSize);
+
size_t result = 0;
ValueLocker locker;
@@ -337,15 +336,12 @@ size_t SBValue::GetByteSize() {
result = value_sp->GetByteSize();
}
- if (log)
- log->Printf("SBValue(%p)::GetByteSize () => %" PRIu64,
- static_cast<void *>(value_sp.get()),
- static_cast<uint64_t>(result));
-
return result;
}
bool SBValue::IsInScope() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsInScope);
+
bool result = false;
ValueLocker locker;
@@ -354,109 +350,51 @@ bool SBValue::IsInScope() {
result = value_sp->IsInScope();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::IsInScope () => %i",
- static_cast<void *>(value_sp.get()), result);
-
return result;
}
const char *SBValue::GetValue() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetValue);
- const char *cstr = NULL;
+ const char *cstr = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
cstr = value_sp->GetValueAsCString();
}
- if (log) {
- if (cstr)
- log->Printf("SBValue(%p)::GetValue() => \"%s\"",
- static_cast<void *>(value_sp.get()), cstr);
- else
- log->Printf("SBValue(%p)::GetValue() => NULL",
- static_cast<void *>(value_sp.get()));
- }
return cstr;
}
ValueType SBValue::GetValueType() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::ValueType, SBValue, GetValueType);
+
ValueType result = eValueTypeInvalid;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
result = value_sp->GetValueType();
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- switch (result) {
- case eValueTypeInvalid:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeInvalid",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeVariableGlobal:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeVariableStatic:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableStatic",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeVariableArgument:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableArgument",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeVariableLocal:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeVariableLocal",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeRegister:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegister",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeRegisterSet:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeRegisterSet",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeConstResult:
- log->Printf("SBValue(%p)::GetValueType () => eValueTypeConstResult",
- static_cast<void *>(value_sp.get()));
- break;
- case eValueTypeVariableThreadLocal:
- log->Printf(
- "SBValue(%p)::GetValueType () => eValueTypeVariableThreadLocal",
- static_cast<void *>(value_sp.get()));
- break;
- }
- }
return result;
}
const char *SBValue::GetObjectDescription() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetObjectDescription);
+
+ const char *cstr = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
cstr = value_sp->GetObjectDescription();
}
- if (log) {
- if (cstr)
- log->Printf("SBValue(%p)::GetObjectDescription() => \"%s\"",
- static_cast<void *>(value_sp.get()), cstr);
- else
- log->Printf("SBValue(%p)::GetObjectDescription() => NULL",
- static_cast<void *>(value_sp.get()));
- }
+
return cstr;
}
const char *SBValue::GetTypeValidatorResult() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetTypeValidatorResult);
+
+ const char *cstr = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -468,41 +406,28 @@ const char *SBValue::GetTypeValidatorResult() {
cstr = validation.second.c_str();
}
}
- if (log) {
- if (cstr)
- log->Printf("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
- static_cast<void *>(value_sp.get()), cstr);
- else
- log->Printf("SBValue(%p)::GetTypeValidatorResult() => NULL",
- static_cast<void *>(value_sp.get()));
- }
+
return cstr;
}
SBType SBValue::GetType() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBType, SBValue, GetType);
+
SBType sb_type;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
TypeImplSP type_sp;
if (value_sp) {
- type_sp.reset(new TypeImpl(value_sp->GetTypeImpl()));
+ type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl());
sb_type.SetSP(type_sp);
}
- if (log) {
- if (type_sp)
- log->Printf("SBValue(%p)::GetType => SBType(%p)",
- static_cast<void *>(value_sp.get()),
- static_cast<void *>(type_sp.get()));
- else
- log->Printf("SBValue(%p)::GetType => NULL",
- static_cast<void *>(value_sp.get()));
- }
- return sb_type;
+
+ return LLDB_RECORD_RESULT(sb_type);
}
bool SBValue::GetValueDidChange() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetValueDidChange);
+
bool result = false;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -510,35 +435,29 @@ bool SBValue::GetValueDidChange() {
if (value_sp->UpdateValueIfNeeded(false))
result = value_sp->GetValueDidChange();
}
- if (log)
- log->Printf("SBValue(%p)::GetValueDidChange() => %i",
- static_cast<void *>(value_sp.get()), result);
return result;
}
const char *SBValue::GetSummary() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetSummary);
+
+ const char *cstr = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
cstr = value_sp->GetSummaryAsCString();
}
- if (log) {
- if (cstr)
- log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
- static_cast<void *>(value_sp.get()), cstr);
- else
- log->Printf("SBValue(%p)::GetSummary() => NULL",
- static_cast<void *>(value_sp.get()));
- }
+
return cstr;
}
const char *SBValue::GetSummary(lldb::SBStream &stream,
lldb::SBTypeSummaryOptions &options) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(const char *, SBValue, GetSummary,
+ (lldb::SBStream &, lldb::SBTypeSummaryOptions &), stream,
+ options);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -547,61 +466,49 @@ const char *SBValue::GetSummary(lldb::SBStream &stream,
stream.Printf("%s", buffer.c_str());
}
const char *cstr = stream.GetData();
- if (log) {
- if (cstr)
- log->Printf("SBValue(%p)::GetSummary() => \"%s\"",
- static_cast<void *>(value_sp.get()), cstr);
- else
- log->Printf("SBValue(%p)::GetSummary() => NULL",
- static_cast<void *>(value_sp.get()));
- }
return cstr;
}
const char *SBValue::GetLocation() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- const char *cstr = NULL;
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBValue, GetLocation);
+
+ const char *cstr = nullptr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
cstr = value_sp->GetLocationAsCString();
}
- if (log) {
- if (cstr)
- log->Printf("SBValue(%p)::GetLocation() => \"%s\"",
- static_cast<void *>(value_sp.get()), cstr);
- else
- log->Printf("SBValue(%p)::GetLocation() => NULL",
- static_cast<void *>(value_sp.get()));
- }
return cstr;
}
// Deprecated - use the one that takes an lldb::SBError
bool SBValue::SetValueFromCString(const char *value_str) {
+ LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, (const char *),
+ value_str);
+
lldb::SBError dummy;
return SetValueFromCString(value_str, dummy);
}
bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
+ LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString,
+ (const char *, lldb::SBError &), value_str, error);
+
bool success = false;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
if (value_sp) {
success = value_sp->SetValueFromCString(value_str, error.ref());
} else
error.SetErrorStringWithFormat("Could not get value: %s",
locker.GetError().AsCString());
- if (log)
- log->Printf("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
- static_cast<void *>(value_sp.get()), value_str, success);
-
return success;
}
lldb::SBTypeFormat SBValue::GetTypeFormat() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFormat, SBValue, GetTypeFormat);
+
lldb::SBTypeFormat format;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -612,10 +519,12 @@ lldb::SBTypeFormat SBValue::GetTypeFormat() {
format.SetSP(format_sp);
}
}
- return format;
+ return LLDB_RECORD_RESULT(format);
}
lldb::SBTypeSummary SBValue::GetTypeSummary() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSummary, SBValue, GetTypeSummary);
+
lldb::SBTypeSummary summary;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -626,10 +535,12 @@ lldb::SBTypeSummary SBValue::GetTypeSummary() {
summary.SetSP(summary_sp);
}
}
- return summary;
+ return LLDB_RECORD_RESULT(summary);
}
lldb::SBTypeFilter SBValue::GetTypeFilter() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeFilter, SBValue, GetTypeFilter);
+
lldb::SBTypeFilter filter;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -644,11 +555,12 @@ lldb::SBTypeFilter SBValue::GetTypeFilter() {
}
}
}
- return filter;
+ return LLDB_RECORD_RESULT(filter);
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic);
+
lldb::SBTypeSynthetic synthetic;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -663,12 +575,15 @@ lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() {
}
}
}
- return synthetic;
+ return LLDB_RECORD_RESULT(synthetic);
}
-#endif
lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
SBType type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset,
+ (const char *, uint32_t, lldb::SBType), name, offset,
+ type);
+
lldb::SBValue sb_value;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -681,20 +596,12 @@ lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset,
GetPreferDynamicValue(), GetPreferSyntheticValue(), name);
}
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (new_value_sp)
- log->Printf("SBValue(%p)::CreateChildAtOffset => \"%s\"",
- static_cast<void *>(value_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf("SBValue(%p)::CreateChildAtOffset => NULL",
- static_cast<void *>(value_sp.get()));
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBValue::Cast(SBType type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType), type);
+
lldb::SBValue sb_value;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -702,20 +609,27 @@ lldb::SBValue SBValue::Cast(SBType type) {
if (value_sp && type_sp)
sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
GetPreferDynamicValue(), GetPreferSyntheticValue());
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
const char *expression) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression,
+ (const char *, const char *), name, expression);
+
SBExpressionOptions options;
options.ref().SetKeepInMemory(true);
- return CreateValueFromExpression(name, expression, options);
+ return LLDB_RECORD_RESULT(
+ CreateValueFromExpression(name, expression, options));
}
lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
const char *expression,
SBExpressionOptions &options) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression,
+ (const char *, const char *, lldb::SBExpressionOptions &),
+ name, expression, options);
+
lldb::SBValue sb_value;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -728,23 +642,16 @@ lldb::SBValue SBValue::CreateValueFromExpression(const char *name,
new_value_sp->SetName(ConstString(name));
}
sb_value.SetSP(new_value_sp);
- if (log) {
- if (new_value_sp)
- log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
- "expression=\"%s\") => SBValue (%p)",
- static_cast<void *>(value_sp.get()), name, expression,
- static_cast<void *>(new_value_sp.get()));
- else
- log->Printf("SBValue(%p)::CreateValueFromExpression(name=\"%s\", "
- "expression=\"%s\") => NULL",
- static_cast<void *>(value_sp.get()), name, expression);
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBValue::CreateValueFromAddress(const char *name,
lldb::addr_t address,
SBType sb_type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress,
+ (const char *, lldb::addr_t, lldb::SBType), name, address,
+ sb_type);
+
lldb::SBValue sb_value;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -757,21 +664,15 @@ lldb::SBValue SBValue::CreateValueFromAddress(const char *name,
exe_ctx, ast_type);
}
sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (new_value_sp)
- log->Printf("SBValue(%p)::CreateValueFromAddress => \"%s\"",
- static_cast<void *>(value_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf("SBValue(%p)::CreateValueFromAddress => NULL",
- static_cast<void *>(value_sp.get()));
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data,
SBType sb_type) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, CreateValueFromData,
+ (const char *, lldb::SBData, lldb::SBType), name, data,
+ sb_type);
+
lldb::SBValue sb_value;
lldb::ValueObjectSP new_value_sp;
ValueLocker locker;
@@ -784,20 +685,12 @@ lldb::SBValue SBValue::CreateValueFromData(const char *name, SBData data,
new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
}
sb_value.SetSP(new_value_sp);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (new_value_sp)
- log->Printf("SBValue(%p)::CreateValueFromData => \"%s\"",
- static_cast<void *>(value_sp.get()),
- new_value_sp->GetName().AsCString());
- else
- log->Printf("SBValue(%p)::CreateValueFromData => NULL",
- static_cast<void *>(value_sp.get()));
- }
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
SBValue SBValue::GetChildAtIndex(uint32_t idx) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t), idx);
+
const bool can_create_synthetic = false;
lldb::DynamicValueType use_dynamic = eNoDynamicValues;
TargetSP target_sp;
@@ -807,14 +700,18 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx) {
if (target_sp)
use_dynamic = target_sp->GetPreferDynamicValue();
- return GetChildAtIndex(idx, use_dynamic, can_create_synthetic);
+ return LLDB_RECORD_RESULT(
+ GetChildAtIndex(idx, use_dynamic, can_create_synthetic));
}
SBValue SBValue::GetChildAtIndex(uint32_t idx,
lldb::DynamicValueType use_dynamic,
bool can_create_synthetic) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildAtIndex,
+ (uint32_t, lldb::DynamicValueType, bool), idx, use_dynamic,
+ can_create_synthetic);
+
lldb::ValueObjectSP child_sp;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -828,35 +725,27 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx,
SBValue sb_value;
sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
- if (log)
- log->Printf("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
- static_cast<void *>(value_sp.get()), idx,
- static_cast<void *>(value_sp.get()));
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
+ LLDB_RECORD_METHOD(uint32_t, SBValue, GetIndexOfChildWithName, (const char *),
+ name);
+
uint32_t idx = UINT32_MAX;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
idx = value_sp->GetIndexOfChildWithName(ConstString(name));
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (idx == UINT32_MAX)
- log->Printf(
- "SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
- static_cast<void *>(value_sp.get()), name);
- else
- log->Printf("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
- static_cast<void *>(value_sp.get()), name, idx);
- }
return idx;
}
SBValue SBValue::GetChildMemberWithName(const char *name) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
+ (const char *), name);
+
lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
TargetSP target_sp;
if (m_opaque_sp)
@@ -864,17 +753,19 @@ SBValue SBValue::GetChildMemberWithName(const char *name) {
if (target_sp)
use_dynamic_value = target_sp->GetPreferDynamicValue();
- return GetChildMemberWithName(name, use_dynamic_value);
+ return LLDB_RECORD_RESULT(GetChildMemberWithName(name, use_dynamic_value));
}
SBValue
SBValue::GetChildMemberWithName(const char *name,
lldb::DynamicValueType use_dynamic_value) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
+ (const char *, lldb::DynamicValueType), name,
+ use_dynamic_value);
+
lldb::ValueObjectSP child_sp;
const ConstString str_name(name);
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -884,26 +775,25 @@ SBValue::GetChildMemberWithName(const char *name,
SBValue sb_value;
sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
- if (log)
- log->Printf(
- "SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
- static_cast<void *>(value_sp.get()), name,
- static_cast<void *>(value_sp.get()));
-
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::SBValue SBValue::GetDynamicValue(lldb::DynamicValueType use_dynamic) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetDynamicValue,
+ (lldb::DynamicValueType), use_dynamic);
+
SBValue value_sb;
if (IsValid()) {
ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
m_opaque_sp->GetUseSynthetic()));
value_sb.SetSP(proxy_sp);
}
- return value_sb;
+ return LLDB_RECORD_RESULT(value_sb);
}
lldb::SBValue SBValue::GetStaticValue() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetStaticValue);
+
SBValue value_sb;
if (IsValid()) {
ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
@@ -911,42 +801,57 @@ lldb::SBValue SBValue::GetStaticValue() {
m_opaque_sp->GetUseSynthetic()));
value_sb.SetSP(proxy_sp);
}
- return value_sb;
+ return LLDB_RECORD_RESULT(value_sb);
}
lldb::SBValue SBValue::GetNonSyntheticValue() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, GetNonSyntheticValue);
+
SBValue value_sb;
if (IsValid()) {
ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
m_opaque_sp->GetUseDynamic(), false));
value_sb.SetSP(proxy_sp);
}
- return value_sb;
+ return LLDB_RECORD_RESULT(value_sb);
}
lldb::DynamicValueType SBValue::GetPreferDynamicValue() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::DynamicValueType, SBValue,
+ GetPreferDynamicValue);
+
if (!IsValid())
return eNoDynamicValues;
return m_opaque_sp->GetUseDynamic();
}
void SBValue::SetPreferDynamicValue(lldb::DynamicValueType use_dynamic) {
+ LLDB_RECORD_METHOD(void, SBValue, SetPreferDynamicValue,
+ (lldb::DynamicValueType), use_dynamic);
+
if (IsValid())
return m_opaque_sp->SetUseDynamic(use_dynamic);
}
bool SBValue::GetPreferSyntheticValue() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, GetPreferSyntheticValue);
+
if (!IsValid())
return false;
return m_opaque_sp->GetUseSynthetic();
}
void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
+ LLDB_RECORD_METHOD(void, SBValue, SetPreferSyntheticValue, (bool),
+ use_synthetic);
+
if (IsValid())
return m_opaque_sp->SetUseSynthetic(use_synthetic);
}
bool SBValue::IsDynamic() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsDynamic);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -955,6 +860,8 @@ bool SBValue::IsDynamic() {
}
bool SBValue::IsSynthetic() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSynthetic);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -963,6 +870,8 @@ bool SBValue::IsSynthetic() {
}
bool SBValue::IsSyntheticChildrenGenerated() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsSyntheticChildrenGenerated);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -971,6 +880,8 @@ bool SBValue::IsSyntheticChildrenGenerated() {
}
void SBValue::SetSyntheticChildrenGenerated(bool is) {
+ LLDB_RECORD_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool), is);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -978,7 +889,9 @@ void SBValue::SetSyntheticChildrenGenerated(bool is) {
}
lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath,
+ (const char *), expr_path);
+
lldb::ValueObjectSP child_sp;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -990,16 +903,13 @@ lldb::SBValue SBValue::GetValueForExpressionPath(const char *expr_path) {
SBValue sb_value;
sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
- if (log)
- log->Printf("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => "
- "SBValue(%p)",
- static_cast<void *>(value_sp.get()), expr_path,
- static_cast<void *>(value_sp.get()));
-
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
+ LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned,
+ (lldb::SBError &, int64_t), error, fail_value);
+
error.Clear();
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1018,6 +928,9 @@ int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
}
uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
+ LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned,
+ (lldb::SBError &, uint64_t), error, fail_value);
+
error.Clear();
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1036,6 +949,8 @@ uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
}
int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
+ LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t), fail_value);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -1045,6 +960,9 @@ int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
}
uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
+ LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t),
+ fail_value);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -1054,52 +972,51 @@ uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
}
bool SBValue::MightHaveChildren() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, MightHaveChildren);
+
bool has_children = false;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
has_children = value_sp->MightHaveChildren();
- if (log)
- log->Printf("SBValue(%p)::MightHaveChildren() => %i",
- static_cast<void *>(value_sp.get()), has_children);
return has_children;
}
bool SBValue::IsRuntimeSupportValue() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsRuntimeSupportValue);
+
bool is_support = false;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
is_support = value_sp->IsRuntimeSupportValue();
- if (log)
- log->Printf("SBValue(%p)::IsRuntimeSupportValue() => %i",
- static_cast<void *>(value_sp.get()), is_support);
return is_support;
}
-uint32_t SBValue::GetNumChildren() { return GetNumChildren(UINT32_MAX); }
+uint32_t SBValue::GetNumChildren() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBValue, GetNumChildren);
+
+ return GetNumChildren(UINT32_MAX);
+}
uint32_t SBValue::GetNumChildren(uint32_t max) {
+ LLDB_RECORD_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t), max);
+
uint32_t num_children = 0;
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
num_children = value_sp->GetNumChildren(max);
- if (log)
- log->Printf("SBValue(%p)::GetNumChildren (%u) => %u",
- static_cast<void *>(value_sp.get()), max, num_children);
-
return num_children;
}
SBValue SBValue::Dereference() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Dereference);
+
SBValue sb_value;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1107,104 +1024,77 @@ SBValue SBValue::Dereference() {
Status error;
sb_value = value_sp->Dereference(error);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::Dereference () => SBValue(%p)",
- static_cast<void *>(value_sp.get()),
- static_cast<void *>(value_sp.get()));
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
// Deprecated - please use GetType().IsPointerType() instead.
-bool SBValue::TypeIsPointerType() { return GetType().IsPointerType(); }
+bool SBValue::TypeIsPointerType() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, TypeIsPointerType);
+
+ return GetType().IsPointerType();
+}
void *SBValue::GetOpaqueType() {
+ LLDB_RECORD_METHOD_NO_ARGS(void *, SBValue, GetOpaqueType);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
return value_sp->GetCompilerType().GetOpaqueQualType();
- return NULL;
+ return nullptr;
}
lldb::SBTarget SBValue::GetTarget() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTarget, SBValue, GetTarget);
+
SBTarget sb_target;
TargetSP target_sp;
if (m_opaque_sp) {
target_sp = m_opaque_sp->GetTargetSP();
sb_target.SetSP(target_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (target_sp.get() == NULL)
- log->Printf("SBValue(%p)::GetTarget () => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- else
- log->Printf("SBValue(%p)::GetTarget () => %p",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(target_sp.get()));
- }
- return sb_target;
+
+ return LLDB_RECORD_RESULT(sb_target);
}
lldb::SBProcess SBValue::GetProcess() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBProcess, SBValue, GetProcess);
+
SBProcess sb_process;
ProcessSP process_sp;
if (m_opaque_sp) {
process_sp = m_opaque_sp->GetProcessSP();
sb_process.SetSP(process_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (process_sp.get() == NULL)
- log->Printf("SBValue(%p)::GetProcess () => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- else
- log->Printf("SBValue(%p)::GetProcess () => %p",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(process_sp.get()));
- }
- return sb_process;
+
+ return LLDB_RECORD_RESULT(sb_process);
}
lldb::SBThread SBValue::GetThread() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBThread, SBValue, GetThread);
+
SBThread sb_thread;
ThreadSP thread_sp;
if (m_opaque_sp) {
thread_sp = m_opaque_sp->GetThreadSP();
sb_thread.SetThread(thread_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (thread_sp.get() == NULL)
- log->Printf("SBValue(%p)::GetThread () => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- else
- log->Printf("SBValue(%p)::GetThread () => %p",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(thread_sp.get()));
- }
- return sb_thread;
+
+ return LLDB_RECORD_RESULT(sb_thread);
}
lldb::SBFrame SBValue::GetFrame() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFrame, SBValue, GetFrame);
+
SBFrame sb_frame;
StackFrameSP frame_sp;
if (m_opaque_sp) {
frame_sp = m_opaque_sp->GetFrameSP();
sb_frame.SetFrameSP(frame_sp);
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log) {
- if (frame_sp.get() == NULL)
- log->Printf("SBValue(%p)::GetFrame () => NULL",
- static_cast<void *>(m_opaque_sp.get()));
- else
- log->Printf("SBValue(%p)::GetFrame () => %p",
- static_cast<void *>(m_opaque_sp.get()),
- static_cast<void *>(frame_sp.get()));
- }
- return sb_frame;
+
+ return LLDB_RECORD_RESULT(sb_frame);
}
lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
@@ -1216,8 +1106,10 @@ lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
}
lldb::ValueObjectSP SBValue::GetSP() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ValueObjectSP, SBValue, GetSP);
+
ValueLocker locker;
- return GetSP(locker);
+ return LLDB_RECORD_RESULT(GetSP(locker));
}
void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
@@ -1275,6 +1167,9 @@ void SBValue::SetSP(const lldb::ValueObjectSP &sp,
}
bool SBValue::GetExpressionPath(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &),
+ description);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -1286,6 +1181,9 @@ bool SBValue::GetExpressionPath(SBStream &description) {
bool SBValue::GetExpressionPath(SBStream &description,
bool qualify_cxx_base_classes) {
+ LLDB_RECORD_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &, bool),
+ description, qualify_cxx_base_classes);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
@@ -1295,7 +1193,86 @@ bool SBValue::GetExpressionPath(SBStream &description,
return false;
}
+lldb::SBValue SBValue::EvaluateExpression(const char *expr) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression,
+ (const char *), expr);
+
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (!value_sp)
+ return LLDB_RECORD_RESULT(SBValue());
+
+ lldb::TargetSP target_sp = value_sp->GetTargetSP();
+ if (!target_sp)
+ return LLDB_RECORD_RESULT(SBValue());
+
+ lldb::SBExpressionOptions options;
+ options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue());
+ options.SetUnwindOnError(true);
+ options.SetIgnoreBreakpoints(true);
+
+ return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr));
+}
+
+lldb::SBValue
+SBValue::EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &),
+ expr, options);
+
+ return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr));
+}
+
+lldb::SBValue SBValue::EvaluateExpression(const char *expr,
+ const SBExpressionOptions &options,
+ const char *name) const {
+ LLDB_RECORD_METHOD_CONST(
+ lldb::SBValue, SBValue, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &, const char *), expr,
+ options, name);
+
+
+ if (!expr || expr[0] == '\0') {
+ return LLDB_RECORD_RESULT(SBValue());
+ }
+
+
+ ValueLocker locker;
+ lldb::ValueObjectSP value_sp(GetSP(locker));
+ if (!value_sp) {
+ return LLDB_RECORD_RESULT(SBValue());
+ }
+
+ lldb::TargetSP target_sp = value_sp->GetTargetSP();
+ if (!target_sp) {
+ return LLDB_RECORD_RESULT(SBValue());
+ }
+
+ std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
+ ExecutionContext exe_ctx(target_sp.get());
+
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (!frame) {
+ return LLDB_RECORD_RESULT(SBValue());
+ }
+
+ ValueObjectSP res_val_sp;
+ target_sp->EvaluateExpression(expr, frame, res_val_sp, options.ref(), nullptr,
+ value_sp.get());
+
+ if (name)
+ res_val_sp->SetName(ConstString(name));
+
+ SBValue result;
+ result.SetSP(res_val_sp, options.GetFetchDynamicValue());
+ return LLDB_RECORD_RESULT(result);
+}
+
bool SBValue::GetDescription(SBStream &description) {
+ LLDB_RECORD_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &),
+ description);
+
Stream &strm = description.ref();
ValueLocker locker;
@@ -1309,6 +1286,8 @@ bool SBValue::GetDescription(SBStream &description) {
}
lldb::Format SBValue::GetFormat() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::Format, SBValue, GetFormat);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -1317,6 +1296,8 @@ lldb::Format SBValue::GetFormat() {
}
void SBValue::SetFormat(lldb::Format format) {
+ LLDB_RECORD_METHOD(void, SBValue, SetFormat, (lldb::Format), format);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp)
@@ -1324,6 +1305,8 @@ void SBValue::SetFormat(lldb::Format format) {
}
lldb::SBValue SBValue::AddressOf() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, AddressOf);
+
SBValue sb_value;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1332,16 +1315,13 @@ lldb::SBValue SBValue::AddressOf() {
sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
GetPreferSyntheticValue());
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::AddressOf () => SBValue(%p)",
- static_cast<void *>(value_sp.get()),
- static_cast<void *>(value_sp.get()));
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
lldb::addr_t SBValue::GetLoadAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBValue, GetLoadAddress);
+
lldb::addr_t value = LLDB_INVALID_ADDRESS;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1365,15 +1345,13 @@ lldb::addr_t SBValue::GetLoadAddress() {
value = LLDB_INVALID_ADDRESS;
}
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
- static_cast<void *>(value_sp.get()), value);
return value;
}
lldb::SBAddress SBValue::GetAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBAddress, SBValue, GetAddress);
+
Address addr;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1396,18 +1374,14 @@ lldb::SBAddress SBValue::GetAddress() {
}
}
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
- static_cast<void *>(value_sp.get()),
- (addr.GetSection() ? addr.GetSection()->GetName().GetCString()
- : "NULL"),
- addr.GetOffset());
- return SBAddress(new Address(addr));
+
+ return LLDB_RECORD_RESULT(SBAddress(new Address(addr)));
}
lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(lldb::SBData, SBValue, GetPointeeData,
+ (uint32_t, uint32_t), item_idx, item_count);
+
lldb::SBData sb_data;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1420,16 +1394,13 @@ lldb::SBData SBValue::GetPointeeData(uint32_t item_idx, uint32_t item_count) {
*sb_data = data_sp;
}
}
- if (log)
- log->Printf("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
- static_cast<void *>(value_sp.get()), item_idx, item_count,
- static_cast<void *>(sb_data.get()));
- return sb_data;
+ return LLDB_RECORD_RESULT(sb_data);
}
lldb::SBData SBValue::GetData() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBData, SBValue, GetData);
+
lldb::SBData sb_data;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
@@ -1440,16 +1411,14 @@ lldb::SBData SBValue::GetData() {
if (error.Success())
*sb_data = data_sp;
}
- if (log)
- log->Printf("SBValue(%p)::GetData () => SBData(%p)",
- static_cast<void *>(value_sp.get()),
- static_cast<void *>(sb_data.get()));
- return sb_data;
+ return LLDB_RECORD_RESULT(sb_data);
}
bool SBValue::SetData(lldb::SBData &data, SBError &error) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD(bool, SBValue, SetData, (lldb::SBData &, lldb::SBError &),
+ data, error);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
bool ret = true;
@@ -1458,10 +1427,6 @@ bool SBValue::SetData(lldb::SBData &data, SBError &error) {
DataExtractor *data_extractor = data.get();
if (!data_extractor) {
- if (log)
- log->Printf("SBValue(%p)::SetData() => error: no data to set",
- static_cast<void *>(value_sp.get()));
-
error.SetErrorString("No data to set");
ret = false;
} else {
@@ -1482,14 +1447,12 @@ bool SBValue::SetData(lldb::SBData &data, SBError &error) {
ret = false;
}
- if (log)
- log->Printf("SBValue(%p)::SetData (%p) => %s",
- static_cast<void *>(value_sp.get()),
- static_cast<void *>(data.get()), ret ? "true" : "false");
return ret;
}
lldb::SBDeclaration SBValue::GetDeclaration() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBDeclaration, SBValue, GetDeclaration);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
SBDeclaration decl_sb;
@@ -1498,11 +1461,15 @@ lldb::SBDeclaration SBValue::GetDeclaration() {
if (value_sp->GetDeclaration(decl))
decl_sb.SetDeclaration(decl);
}
- return decl_sb;
+ return LLDB_RECORD_RESULT(decl_sb);
}
lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch,
+ (bool, bool, bool, lldb::SBError &), resolve_location,
+ read, write, error);
+
SBWatchpoint sb_watchpoint;
// If the SBValue is not valid, there's no point in even trying to watch it.
@@ -1512,18 +1479,18 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
if (value_sp && target_sp) {
// Read and Write cannot both be false.
if (!read && !write)
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
// If the value is not in scope, don't try and watch and invalid value
if (!IsInScope())
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
addr_t addr = GetLoadAddress();
if (addr == LLDB_INVALID_ADDRESS)
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
size_t byte_size = GetByteSize();
if (byte_size == 0)
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
uint32_t watch_type = 0;
if (read)
@@ -1550,23 +1517,13 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
}
}
} else if (target_sp) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::Watch() => error getting SBValue: %s",
- static_cast<void *>(value_sp.get()),
- locker.GetError().AsCString());
-
error.SetErrorStringWithFormat("could not get SBValue: %s",
locker.GetError().AsCString());
} else {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBValue(%p)::Watch() => error getting SBValue: no target",
- static_cast<void *>(value_sp.get()));
error.SetErrorString("could not set watchpoint, a target is required");
}
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
}
// FIXME: Remove this method impl (as well as the decl in .h) once it is no
@@ -1574,24 +1531,160 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
// Backward compatibility fix in the interim.
lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
bool write) {
+ LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, (bool, bool, bool),
+ resolve_location, read, write);
+
SBError error;
- return Watch(resolve_location, read, write, error);
+ return LLDB_RECORD_RESULT(Watch(resolve_location, read, write, error));
}
lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
bool write, SBError &error) {
+ LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee,
+ (bool, bool, bool, lldb::SBError &), resolve_location,
+ read, write, error);
+
SBWatchpoint sb_watchpoint;
if (IsInScope() && GetType().IsPointerType())
sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
}
lldb::SBValue SBValue::Persist() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBValue, SBValue, Persist);
+
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
SBValue persisted_sb;
if (value_sp) {
persisted_sb.SetSP(value_sp->Persist());
}
- return persisted_sb;
+ return LLDB_RECORD_RESULT(persisted_sb);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBValue>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBValue, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::SBValue &));
+ LLDB_REGISTER_METHOD(lldb::SBValue &,
+ SBValue, operator=,(const lldb::SBValue &));
+ LLDB_REGISTER_METHOD(bool, SBValue, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBValue, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBValue, Clear, ());
+ LLDB_REGISTER_METHOD(lldb::SBError, SBValue, GetError, ());
+ LLDB_REGISTER_METHOD(lldb::user_id_t, SBValue, GetID, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetName, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeName, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetDisplayTypeName, ());
+ LLDB_REGISTER_METHOD(size_t, SBValue, GetByteSize, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, IsInScope, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ());
+ LLDB_REGISTER_METHOD(lldb::ValueType, SBValue, GetValueType, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetObjectDescription, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeValidatorResult, ());
+ LLDB_REGISTER_METHOD(lldb::SBType, SBValue, GetType, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, GetValueDidChange, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ());
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary,
+ (lldb::SBStream &, lldb::SBTypeSummaryOptions &));
+ LLDB_REGISTER_METHOD(const char *, SBValue, GetLocation, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString,
+ (const char *, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBValue, GetTypeFormat, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBValue, GetTypeSummary, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBValue, GetTypeFilter, ());
+ LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset,
+ (const char *, uint32_t, lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromExpression,
+ (const char *, const char *));
+ LLDB_REGISTER_METHOD(
+ lldb::SBValue, SBValue, CreateValueFromExpression,
+ (const char *, const char *, lldb::SBExpressionOptions &));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromAddress,
+ (const char *, lldb::addr_t, lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateValueFromData,
+ (const char *, lldb::SBData, lldb::SBType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildAtIndex,
+ (uint32_t, lldb::DynamicValueType, bool));
+ LLDB_REGISTER_METHOD(uint32_t, SBValue, GetIndexOfChildWithName,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
+ (const char *));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetChildMemberWithName,
+ (const char *, lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetDynamicValue,
+ (lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetStaticValue, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetNonSyntheticValue, ());
+ LLDB_REGISTER_METHOD(lldb::DynamicValueType, SBValue, GetPreferDynamicValue,
+ ());
+ LLDB_REGISTER_METHOD(void, SBValue, SetPreferDynamicValue,
+ (lldb::DynamicValueType));
+ LLDB_REGISTER_METHOD(bool, SBValue, GetPreferSyntheticValue, ());
+ LLDB_REGISTER_METHOD(void, SBValue, SetPreferSyntheticValue, (bool));
+ LLDB_REGISTER_METHOD(bool, SBValue, IsDynamic, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, IsSynthetic, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, IsSyntheticChildrenGenerated, ());
+ LLDB_REGISTER_METHOD(void, SBValue, SetSyntheticChildrenGenerated, (bool));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, GetValueForExpressionPath,
+ (const char *));
+ LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned,
+ (lldb::SBError &, int64_t));
+ LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned,
+ (lldb::SBError &, uint64_t));
+ LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t));
+ LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t));
+ LLDB_REGISTER_METHOD(bool, SBValue, MightHaveChildren, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, IsRuntimeSupportValue, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBValue, GetNumChildren, (uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Dereference, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, TypeIsPointerType, ());
+ LLDB_REGISTER_METHOD(void *, SBValue, GetOpaqueType, ());
+ LLDB_REGISTER_METHOD(lldb::SBTarget, SBValue, GetTarget, ());
+ LLDB_REGISTER_METHOD(lldb::SBProcess, SBValue, GetProcess, ());
+ LLDB_REGISTER_METHOD(lldb::SBThread, SBValue, GetThread, ());
+ LLDB_REGISTER_METHOD(lldb::SBFrame, SBValue, GetFrame, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::ValueObjectSP, SBValue, GetSP, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(bool, SBValue, GetExpressionPath,
+ (lldb::SBStream &, bool));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValue, EvaluateExpression,
+ (const char *));
+ LLDB_REGISTER_METHOD_CONST(
+ lldb::SBValue, SBValue, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &));
+ LLDB_REGISTER_METHOD_CONST(
+ lldb::SBValue, SBValue, EvaluateExpression,
+ (const char *, const lldb::SBExpressionOptions &, const char *));
+ LLDB_REGISTER_METHOD(bool, SBValue, GetDescription, (lldb::SBStream &));
+ LLDB_REGISTER_METHOD(lldb::Format, SBValue, GetFormat, ());
+ LLDB_REGISTER_METHOD(void, SBValue, SetFormat, (lldb::Format));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, AddressOf, ());
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBValue, GetLoadAddress, ());
+ LLDB_REGISTER_METHOD(lldb::SBAddress, SBValue, GetAddress, ());
+ LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetPointeeData,
+ (uint32_t, uint32_t));
+ LLDB_REGISTER_METHOD(lldb::SBData, SBValue, GetData, ());
+ LLDB_REGISTER_METHOD(bool, SBValue, SetData,
+ (lldb::SBData &, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBDeclaration, SBValue, GetDeclaration, ());
+ LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch,
+ (bool, bool, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, Watch,
+ (bool, bool, bool));
+ LLDB_REGISTER_METHOD(lldb::SBWatchpoint, SBValue, WatchPointee,
+ (bool, bool, bool, lldb::SBError &));
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Persist, ());
+}
+
+}
}
diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp
index 82b464bab9b90..7e909df260d7d 100644
--- a/source/API/SBValueList.cpp
+++ b/source/API/SBValueList.cpp
@@ -1,17 +1,16 @@
//===-- SBValueList.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBValueList.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBValue.h"
#include "lldb/Core/ValueObjectList.h"
-#include "lldb/Utility/Log.h"
#include <vector>
@@ -68,142 +67,165 @@ private:
std::vector<lldb::SBValue> m_values;
};
-SBValueList::SBValueList() : m_opaque_ap() {}
+SBValueList::SBValueList() : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBValueList);
+}
-SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_ap() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() {
+ LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs);
if (rhs.IsValid())
- m_opaque_ap.reset(new ValueListImpl(*rhs));
-
- if (log) {
- log->Printf(
- "SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p",
- static_cast<void *>(rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL),
- static_cast<void *>(m_opaque_ap.get()));
- }
+ m_opaque_up.reset(new ValueListImpl(*rhs));
}
-SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_ap() {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
+SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() {
if (lldb_object_ptr)
- m_opaque_ap.reset(new ValueListImpl(*lldb_object_ptr));
-
- if (log) {
- log->Printf("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p",
- static_cast<const void *>(lldb_object_ptr),
- static_cast<void *>(m_opaque_ap.get()));
- }
+ m_opaque_up.reset(new ValueListImpl(*lldb_object_ptr));
}
SBValueList::~SBValueList() {}
-bool SBValueList::IsValid() const { return (m_opaque_ap != NULL); }
+bool SBValueList::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, IsValid);
+ return this->operator bool();
+}
+SBValueList::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, operator bool);
+
+ return (m_opaque_up != nullptr);
+}
-void SBValueList::Clear() { m_opaque_ap.reset(); }
+void SBValueList::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBValueList, Clear);
+
+ m_opaque_up.reset();
+}
const SBValueList &SBValueList::operator=(const SBValueList &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBValueList &,
+ SBValueList, operator=,(const lldb::SBValueList &), rhs);
+
if (this != &rhs) {
if (rhs.IsValid())
- m_opaque_ap.reset(new ValueListImpl(*rhs));
+ m_opaque_up.reset(new ValueListImpl(*rhs));
else
- m_opaque_ap.reset();
+ m_opaque_up.reset();
}
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
-ValueListImpl *SBValueList::operator->() { return m_opaque_ap.get(); }
+ValueListImpl *SBValueList::operator->() { return m_opaque_up.get(); }
-ValueListImpl &SBValueList::operator*() { return *m_opaque_ap; }
+ValueListImpl &SBValueList::operator*() { return *m_opaque_up; }
const ValueListImpl *SBValueList::operator->() const {
- return m_opaque_ap.get();
+ return m_opaque_up.get();
}
-const ValueListImpl &SBValueList::operator*() const { return *m_opaque_ap; }
+const ValueListImpl &SBValueList::operator*() const { return *m_opaque_up; }
void SBValueList::Append(const SBValue &val_obj) {
+ LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValue &),
+ val_obj);
+
CreateIfNeeded();
- m_opaque_ap->Append(val_obj);
+ m_opaque_up->Append(val_obj);
}
void SBValueList::Append(lldb::ValueObjectSP &val_obj_sp) {
if (val_obj_sp) {
CreateIfNeeded();
- m_opaque_ap->Append(SBValue(val_obj_sp));
+ m_opaque_up->Append(SBValue(val_obj_sp));
}
}
void SBValueList::Append(const lldb::SBValueList &value_list) {
+ LLDB_RECORD_METHOD(void, SBValueList, Append, (const lldb::SBValueList &),
+ value_list);
+
if (value_list.IsValid()) {
CreateIfNeeded();
- m_opaque_ap->Append(*value_list);
+ m_opaque_up->Append(*value_list);
}
}
SBValue SBValueList::GetValueAtIndex(uint32_t idx) const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex,
+ (uint32_t), idx);
- // if (log)
- // log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d",
- // idx);
SBValue sb_value;
- if (m_opaque_ap)
- sb_value = m_opaque_ap->GetValueAtIndex(idx);
-
- if (log) {
- SBStream sstr;
- sb_value.GetDescription(sstr);
- log->Printf("SBValueList::GetValueAtIndex (this.ap=%p, idx=%d) => SBValue "
- "(this.sp = %p, '%s')",
- static_cast<void *>(m_opaque_ap.get()), idx,
- static_cast<void *>(sb_value.GetSP().get()), sstr.GetData());
- }
+ if (m_opaque_up)
+ sb_value = m_opaque_up->GetValueAtIndex(idx);
- return sb_value;
+ return LLDB_RECORD_RESULT(sb_value);
}
uint32_t SBValueList::GetSize() const {
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- // if (log)
- // log->Printf ("SBValueList::GetSize ()");
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(uint32_t, SBValueList, GetSize);
uint32_t size = 0;
- if (m_opaque_ap)
- size = m_opaque_ap->GetSize();
-
- if (log)
- log->Printf("SBValueList::GetSize (this.ap=%p) => %d",
- static_cast<void *>(m_opaque_ap.get()), size);
+ if (m_opaque_up)
+ size = m_opaque_up->GetSize();
return size;
}
void SBValueList::CreateIfNeeded() {
- if (m_opaque_ap == NULL)
- m_opaque_ap.reset(new ValueListImpl());
+ if (m_opaque_up == nullptr)
+ m_opaque_up.reset(new ValueListImpl());
}
SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) {
+ LLDB_RECORD_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID,
+ (lldb::user_id_t), uid);
+
SBValue sb_value;
- if (m_opaque_ap)
- sb_value = m_opaque_ap->FindValueByUID(uid);
- return sb_value;
+ if (m_opaque_up)
+ sb_value = m_opaque_up->FindValueByUID(uid);
+ return LLDB_RECORD_RESULT(sb_value);
}
SBValue SBValueList::GetFirstValueByName(const char *name) const {
+ LLDB_RECORD_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName,
+ (const char *), name);
+
SBValue sb_value;
- if (m_opaque_ap)
- sb_value = m_opaque_ap->GetFirstValueByName(name);
- return sb_value;
+ if (m_opaque_up)
+ sb_value = m_opaque_up->GetFirstValueByName(name);
+ return LLDB_RECORD_RESULT(sb_value);
}
-void *SBValueList::opaque_ptr() { return m_opaque_ap.get(); }
+void *SBValueList::opaque_ptr() { return m_opaque_up.get(); }
ValueListImpl &SBValueList::ref() {
CreateIfNeeded();
- return *m_opaque_ap;
+ return *m_opaque_up;
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBValueList>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBValueList, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBValueList, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBValueList, operator bool, ());
+ LLDB_REGISTER_METHOD(void, SBValueList, Clear, ());
+ LLDB_REGISTER_METHOD(const lldb::SBValueList &,
+ SBValueList, operator=,(const lldb::SBValueList &));
+ LLDB_REGISTER_METHOD(void, SBValueList, Append, (const lldb::SBValue &));
+ LLDB_REGISTER_METHOD(void, SBValueList, Append,
+ (const lldb::SBValueList &));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetValueAtIndex,
+ (uint32_t));
+ LLDB_REGISTER_METHOD_CONST(uint32_t, SBValueList, GetSize, ());
+ LLDB_REGISTER_METHOD(lldb::SBValue, SBValueList, FindValueObjectByUID,
+ (lldb::user_id_t));
+ LLDB_REGISTER_METHOD_CONST(lldb::SBValue, SBValueList, GetFirstValueByName,
+ (const char *));
+}
+
+}
}
diff --git a/source/API/SBVariablesOptions.cpp b/source/API/SBVariablesOptions.cpp
index 2651ce11d02a8..bf0197cd960bd 100644
--- a/source/API/SBVariablesOptions.cpp
+++ b/source/API/SBVariablesOptions.cpp
@@ -1,14 +1,14 @@
//===-- SBVariablesOptions.cpp --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBVariablesOptions.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBTarget.h"
#include "lldb/Target/Target.h"
@@ -81,98 +81,196 @@ private:
};
SBVariablesOptions::SBVariablesOptions()
- : m_opaque_ap(new VariablesOptionsImpl()) {}
+ : m_opaque_up(new VariablesOptionsImpl()) {
+ LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBVariablesOptions);
+}
SBVariablesOptions::SBVariablesOptions(const SBVariablesOptions &options)
- : m_opaque_ap(new VariablesOptionsImpl(options.ref())) {}
+ : m_opaque_up(new VariablesOptionsImpl(options.ref())) {
+ LLDB_RECORD_CONSTRUCTOR(SBVariablesOptions,
+ (const lldb::SBVariablesOptions &), options);
+}
SBVariablesOptions &SBVariablesOptions::
operator=(const SBVariablesOptions &options) {
- m_opaque_ap.reset(new VariablesOptionsImpl(options.ref()));
- return *this;
+ LLDB_RECORD_METHOD(
+ lldb::SBVariablesOptions &,
+ SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &),
+ options);
+
+ m_opaque_up.reset(new VariablesOptionsImpl(options.ref()));
+ return LLDB_RECORD_RESULT(*this);
}
SBVariablesOptions::~SBVariablesOptions() = default;
-bool SBVariablesOptions::IsValid() const { return m_opaque_ap != nullptr; }
+bool SBVariablesOptions::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, IsValid);
+ return this->operator bool();
+}
+SBVariablesOptions::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, operator bool);
+
+ return m_opaque_up != nullptr;
+}
bool SBVariablesOptions::GetIncludeArguments() const {
- return m_opaque_ap->GetIncludeArguments();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
+ GetIncludeArguments);
+
+ return m_opaque_up->GetIncludeArguments();
}
void SBVariablesOptions::SetIncludeArguments(bool arguments) {
- m_opaque_ap->SetIncludeArguments(arguments);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool),
+ arguments);
+
+ m_opaque_up->SetIncludeArguments(arguments);
}
bool SBVariablesOptions::GetIncludeRecognizedArguments(
const lldb::SBTarget &target) const {
- return m_opaque_ap->GetIncludeRecognizedArguments(target.GetSP());
+ LLDB_RECORD_METHOD_CONST(bool, SBVariablesOptions,
+ GetIncludeRecognizedArguments,
+ (const lldb::SBTarget &), target);
+
+ return m_opaque_up->GetIncludeRecognizedArguments(target.GetSP());
}
void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) {
- m_opaque_ap->SetIncludeRecognizedArguments(arguments);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRecognizedArguments,
+ (bool), arguments);
+
+ m_opaque_up->SetIncludeRecognizedArguments(arguments);
}
bool SBVariablesOptions::GetIncludeLocals() const {
- return m_opaque_ap->GetIncludeLocals();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeLocals);
+
+ return m_opaque_up->GetIncludeLocals();
}
void SBVariablesOptions::SetIncludeLocals(bool locals) {
- m_opaque_ap->SetIncludeLocals(locals);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool),
+ locals);
+
+ m_opaque_up->SetIncludeLocals(locals);
}
bool SBVariablesOptions::GetIncludeStatics() const {
- return m_opaque_ap->GetIncludeStatics();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetIncludeStatics);
+
+ return m_opaque_up->GetIncludeStatics();
}
void SBVariablesOptions::SetIncludeStatics(bool statics) {
- m_opaque_ap->SetIncludeStatics(statics);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool),
+ statics);
+
+ m_opaque_up->SetIncludeStatics(statics);
}
bool SBVariablesOptions::GetInScopeOnly() const {
- return m_opaque_ap->GetInScopeOnly();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions, GetInScopeOnly);
+
+ return m_opaque_up->GetInScopeOnly();
}
void SBVariablesOptions::SetInScopeOnly(bool in_scope_only) {
- m_opaque_ap->SetInScopeOnly(in_scope_only);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool),
+ in_scope_only);
+
+ m_opaque_up->SetInScopeOnly(in_scope_only);
}
bool SBVariablesOptions::GetIncludeRuntimeSupportValues() const {
- return m_opaque_ap->GetIncludeRuntimeSupportValues();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBVariablesOptions,
+ GetIncludeRuntimeSupportValues);
+
+ return m_opaque_up->GetIncludeRuntimeSupportValues();
}
void SBVariablesOptions::SetIncludeRuntimeSupportValues(
bool runtime_support_values) {
- m_opaque_ap->SetIncludeRuntimeSupportValues(runtime_support_values);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetIncludeRuntimeSupportValues,
+ (bool), runtime_support_values);
+
+ m_opaque_up->SetIncludeRuntimeSupportValues(runtime_support_values);
}
lldb::DynamicValueType SBVariablesOptions::GetUseDynamic() const {
- return m_opaque_ap->GetUseDynamic();
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::DynamicValueType, SBVariablesOptions,
+ GetUseDynamic);
+
+ return m_opaque_up->GetUseDynamic();
}
void SBVariablesOptions::SetUseDynamic(lldb::DynamicValueType dynamic) {
- m_opaque_ap->SetUseDynamic(dynamic);
+ LLDB_RECORD_METHOD(void, SBVariablesOptions, SetUseDynamic,
+ (lldb::DynamicValueType), dynamic);
+
+ m_opaque_up->SetUseDynamic(dynamic);
}
VariablesOptionsImpl *SBVariablesOptions::operator->() {
- return m_opaque_ap.operator->();
+ return m_opaque_up.operator->();
}
const VariablesOptionsImpl *SBVariablesOptions::operator->() const {
- return m_opaque_ap.operator->();
+ return m_opaque_up.operator->();
}
-VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_ap.get(); }
+VariablesOptionsImpl *SBVariablesOptions::get() { return m_opaque_up.get(); }
-VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_ap; }
+VariablesOptionsImpl &SBVariablesOptions::ref() { return *m_opaque_up; }
const VariablesOptionsImpl &SBVariablesOptions::ref() const {
- return *m_opaque_ap;
+ return *m_opaque_up;
}
SBVariablesOptions::SBVariablesOptions(VariablesOptionsImpl *lldb_object_ptr)
- : m_opaque_ap(std::move(lldb_object_ptr)) {}
+ : m_opaque_up(std::move(lldb_object_ptr)) {}
void SBVariablesOptions::SetOptions(VariablesOptionsImpl *lldb_object_ptr) {
- m_opaque_ap.reset(std::move(lldb_object_ptr));
+ m_opaque_up.reset(std::move(lldb_object_ptr));
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBVariablesOptions>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBVariablesOptions,
+ (const lldb::SBVariablesOptions &));
+ LLDB_REGISTER_METHOD(
+ lldb::SBVariablesOptions &,
+ SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &));
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeArguments,
+ ());
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeArguments, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions,
+ GetIncludeRecognizedArguments,
+ (const lldb::SBTarget &));
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions,
+ SetIncludeRecognizedArguments, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeLocals, ());
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeLocals, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetIncludeStatics, ());
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetIncludeStatics, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions, GetInScopeOnly, ());
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetInScopeOnly, (bool));
+ LLDB_REGISTER_METHOD_CONST(bool, SBVariablesOptions,
+ GetIncludeRuntimeSupportValues, ());
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions,
+ SetIncludeRuntimeSupportValues, (bool));
+ LLDB_REGISTER_METHOD_CONST(lldb::DynamicValueType, SBVariablesOptions,
+ GetUseDynamic, ());
+ LLDB_REGISTER_METHOD(void, SBVariablesOptions, SetUseDynamic,
+ (lldb::DynamicValueType));
+}
+
+}
}
diff --git a/source/API/SBWatchpoint.cpp b/source/API/SBWatchpoint.cpp
index b7755373abc94..d0a36b71e5c18 100644
--- a/source/API/SBWatchpoint.cpp
+++ b/source/API/SBWatchpoint.cpp
@@ -1,13 +1,13 @@
//===-- SBWatchpoint.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/API/SBWatchpoint.h"
+#include "SBReproducerPrivate.h"
#include "lldb/API/SBAddress.h"
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBDefines.h"
@@ -19,7 +19,6 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
-#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "lldb/lldb-defines.h"
#include "lldb/lldb-types.h"
@@ -27,61 +26,78 @@
using namespace lldb;
using namespace lldb_private;
-SBWatchpoint::SBWatchpoint() {}
+SBWatchpoint::SBWatchpoint() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBWatchpoint); }
SBWatchpoint::SBWatchpoint(const lldb::WatchpointSP &wp_sp)
: m_opaque_wp(wp_sp) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
-
- if (log) {
- SBStream sstr;
- GetDescription(sstr, lldb::eDescriptionLevelBrief);
- LLDB_LOG(log, "watchpoint = {0} ({1})", wp_sp.get(), sstr.GetData());
- }
+ LLDB_RECORD_CONSTRUCTOR(SBWatchpoint, (const lldb::WatchpointSP &), wp_sp);
}
SBWatchpoint::SBWatchpoint(const SBWatchpoint &rhs)
- : m_opaque_wp(rhs.m_opaque_wp) {}
+ : m_opaque_wp(rhs.m_opaque_wp) {
+ LLDB_RECORD_CONSTRUCTOR(SBWatchpoint, (const lldb::SBWatchpoint &), rhs);
+}
const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) {
+ LLDB_RECORD_METHOD(const lldb::SBWatchpoint &,
+ SBWatchpoint, operator=,(const lldb::SBWatchpoint &), rhs);
+
m_opaque_wp = rhs.m_opaque_wp;
- return *this;
+ return LLDB_RECORD_RESULT(*this);
}
SBWatchpoint::~SBWatchpoint() {}
watch_id_t SBWatchpoint::GetID() {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::watch_id_t, SBWatchpoint, GetID);
+
watch_id_t watch_id = LLDB_INVALID_WATCH_ID;
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp)
watch_id = watchpoint_sp->GetID();
- if (log) {
- if (watch_id == LLDB_INVALID_WATCH_ID)
- log->Printf("SBWatchpoint(%p)::GetID () => LLDB_INVALID_WATCH_ID",
- static_cast<void *>(watchpoint_sp.get()));
- else
- log->Printf("SBWatchpoint(%p)::GetID () => %u",
- static_cast<void *>(watchpoint_sp.get()), watch_id);
- }
-
return watch_id;
}
-bool SBWatchpoint::IsValid() const { return bool(m_opaque_wp.lock()); }
+bool SBWatchpoint::IsValid() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBWatchpoint, IsValid);
+ return this->operator bool();
+}
+SBWatchpoint::operator bool() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBWatchpoint, operator bool);
+
+ return bool(m_opaque_wp.lock());
+}
+
+bool SBWatchpoint::operator==(const SBWatchpoint &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBWatchpoint, operator==,(const SBWatchpoint &), rhs);
+
+ return GetSP() == rhs.GetSP();
+}
+
+bool SBWatchpoint::operator!=(const SBWatchpoint &rhs) const {
+ LLDB_RECORD_METHOD_CONST(
+ bool, SBWatchpoint, operator!=,(const SBWatchpoint &), rhs);
+
+ return !(*this == rhs);
+}
SBError SBWatchpoint::GetError() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBWatchpoint, GetError);
+
SBError sb_error;
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
sb_error.SetError(watchpoint_sp->GetError());
}
- return sb_error;
+ return LLDB_RECORD_RESULT(sb_error);
}
int32_t SBWatchpoint::GetHardwareIndex() {
+ LLDB_RECORD_METHOD_NO_ARGS(int32_t, SBWatchpoint, GetHardwareIndex);
+
int32_t hw_index = -1;
lldb::WatchpointSP watchpoint_sp(GetSP());
@@ -95,6 +111,8 @@ int32_t SBWatchpoint::GetHardwareIndex() {
}
addr_t SBWatchpoint::GetWatchAddress() {
+ LLDB_RECORD_METHOD_NO_ARGS(lldb::addr_t, SBWatchpoint, GetWatchAddress);
+
addr_t ret_addr = LLDB_INVALID_ADDRESS;
lldb::WatchpointSP watchpoint_sp(GetSP());
@@ -108,6 +126,8 @@ addr_t SBWatchpoint::GetWatchAddress() {
}
size_t SBWatchpoint::GetWatchSize() {
+ LLDB_RECORD_METHOD_NO_ARGS(size_t, SBWatchpoint, GetWatchSize);
+
size_t watch_size = 0;
lldb::WatchpointSP watchpoint_sp(GetSP());
@@ -121,6 +141,8 @@ size_t SBWatchpoint::GetWatchSize() {
}
void SBWatchpoint::SetEnabled(bool enabled) {
+ LLDB_RECORD_METHOD(void, SBWatchpoint, SetEnabled, (bool), enabled);
+
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
Target &target = watchpoint_sp->GetTarget();
@@ -139,6 +161,8 @@ void SBWatchpoint::SetEnabled(bool enabled) {
}
bool SBWatchpoint::IsEnabled() {
+ LLDB_RECORD_METHOD_NO_ARGS(bool, SBWatchpoint, IsEnabled);
+
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -149,6 +173,8 @@ bool SBWatchpoint::IsEnabled() {
}
uint32_t SBWatchpoint::GetHitCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBWatchpoint, GetHitCount);
+
uint32_t count = 0;
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
@@ -157,15 +183,12 @@ uint32_t SBWatchpoint::GetHitCount() {
count = watchpoint_sp->GetHitCount();
}
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
- if (log)
- log->Printf("SBWatchpoint(%p)::GetHitCount () => %u",
- static_cast<void *>(watchpoint_sp.get()), count);
-
return count;
}
uint32_t SBWatchpoint::GetIgnoreCount() {
+ LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBWatchpoint, GetIgnoreCount);
+
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -176,6 +199,8 @@ uint32_t SBWatchpoint::GetIgnoreCount() {
}
void SBWatchpoint::SetIgnoreCount(uint32_t n) {
+ LLDB_RECORD_METHOD(void, SBWatchpoint, SetIgnoreCount, (uint32_t), n);
+
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -185,16 +210,21 @@ void SBWatchpoint::SetIgnoreCount(uint32_t n) {
}
const char *SBWatchpoint::GetCondition() {
+ LLDB_RECORD_METHOD_NO_ARGS(const char *, SBWatchpoint, GetCondition);
+
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
std::lock_guard<std::recursive_mutex> guard(
watchpoint_sp->GetTarget().GetAPIMutex());
return watchpoint_sp->GetConditionText();
}
- return NULL;
+ return nullptr;
}
void SBWatchpoint::SetCondition(const char *condition) {
+ LLDB_RECORD_METHOD(void, SBWatchpoint, SetCondition, (const char *),
+ condition);
+
lldb::WatchpointSP watchpoint_sp(GetSP());
if (watchpoint_sp) {
std::lock_guard<std::recursive_mutex> guard(
@@ -205,6 +235,10 @@ void SBWatchpoint::SetCondition(const char *condition) {
bool SBWatchpoint::GetDescription(SBStream &description,
DescriptionLevel level) {
+ LLDB_RECORD_METHOD(bool, SBWatchpoint, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel), description,
+ level);
+
Stream &strm = description.ref();
lldb::WatchpointSP watchpoint_sp(GetSP());
@@ -219,19 +253,39 @@ bool SBWatchpoint::GetDescription(SBStream &description,
return true;
}
-void SBWatchpoint::Clear() { m_opaque_wp.reset(); }
+void SBWatchpoint::Clear() {
+ LLDB_RECORD_METHOD_NO_ARGS(void, SBWatchpoint, Clear);
+
+ m_opaque_wp.reset();
+}
+
+lldb::WatchpointSP SBWatchpoint::GetSP() const {
+ LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::WatchpointSP, SBWatchpoint, GetSP);
-lldb::WatchpointSP SBWatchpoint::GetSP() const { return m_opaque_wp.lock(); }
+ return LLDB_RECORD_RESULT(m_opaque_wp.lock());
+}
+
+void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) {
+ LLDB_RECORD_METHOD(void, SBWatchpoint, SetSP, (const lldb::WatchpointSP &),
+ sp);
-void SBWatchpoint::SetSP(const lldb::WatchpointSP &sp) { m_opaque_wp = sp; }
+ m_opaque_wp = sp;
+}
bool SBWatchpoint::EventIsWatchpointEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(bool, SBWatchpoint, EventIsWatchpointEvent,
+ (const lldb::SBEvent &), event);
+
return Watchpoint::WatchpointEventData::GetEventDataFromEvent(event.get()) !=
- NULL;
+ nullptr;
}
WatchpointEventType
SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(lldb::WatchpointEventType, SBWatchpoint,
+ GetWatchpointEventTypeFromEvent,
+ (const lldb::SBEvent &), event);
+
if (event.IsValid())
return Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent(
event.GetSP());
@@ -239,9 +293,60 @@ SBWatchpoint::GetWatchpointEventTypeFromEvent(const SBEvent &event) {
}
SBWatchpoint SBWatchpoint::GetWatchpointFromEvent(const lldb::SBEvent &event) {
+ LLDB_RECORD_STATIC_METHOD(lldb::SBWatchpoint, SBWatchpoint,
+ GetWatchpointFromEvent, (const lldb::SBEvent &),
+ event);
+
SBWatchpoint sb_watchpoint;
if (event.IsValid())
sb_watchpoint =
Watchpoint::WatchpointEventData::GetWatchpointFromEvent(event.GetSP());
- return sb_watchpoint;
+ return LLDB_RECORD_RESULT(sb_watchpoint);
+}
+
+namespace lldb_private {
+namespace repro {
+
+template <>
+void RegisterMethods<SBWatchpoint>(Registry &R) {
+ LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, ());
+ LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, (const lldb::WatchpointSP &));
+ LLDB_REGISTER_CONSTRUCTOR(SBWatchpoint, (const lldb::SBWatchpoint &));
+ LLDB_REGISTER_METHOD(const lldb::SBWatchpoint &,
+ SBWatchpoint, operator=,(const lldb::SBWatchpoint &));
+ LLDB_REGISTER_METHOD(lldb::watch_id_t, SBWatchpoint, GetID, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBWatchpoint, IsValid, ());
+ LLDB_REGISTER_METHOD_CONST(bool, SBWatchpoint, operator bool, ());
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBWatchpoint, operator==,(const lldb::SBWatchpoint &));
+ LLDB_REGISTER_METHOD_CONST(
+ bool, SBWatchpoint, operator!=,(const lldb::SBWatchpoint &));
+ LLDB_REGISTER_METHOD(lldb::SBError, SBWatchpoint, GetError, ());
+ LLDB_REGISTER_METHOD(int32_t, SBWatchpoint, GetHardwareIndex, ());
+ LLDB_REGISTER_METHOD(lldb::addr_t, SBWatchpoint, GetWatchAddress, ());
+ LLDB_REGISTER_METHOD(size_t, SBWatchpoint, GetWatchSize, ());
+ LLDB_REGISTER_METHOD(void, SBWatchpoint, SetEnabled, (bool));
+ LLDB_REGISTER_METHOD(bool, SBWatchpoint, IsEnabled, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBWatchpoint, GetHitCount, ());
+ LLDB_REGISTER_METHOD(uint32_t, SBWatchpoint, GetIgnoreCount, ());
+ LLDB_REGISTER_METHOD(void, SBWatchpoint, SetIgnoreCount, (uint32_t));
+ LLDB_REGISTER_METHOD(const char *, SBWatchpoint, GetCondition, ());
+ LLDB_REGISTER_METHOD(void, SBWatchpoint, SetCondition, (const char *));
+ LLDB_REGISTER_METHOD(bool, SBWatchpoint, GetDescription,
+ (lldb::SBStream &, lldb::DescriptionLevel));
+ LLDB_REGISTER_METHOD(void, SBWatchpoint, Clear, ());
+ LLDB_REGISTER_METHOD_CONST(lldb::WatchpointSP, SBWatchpoint, GetSP, ());
+ LLDB_REGISTER_METHOD(void, SBWatchpoint, SetSP,
+ (const lldb::WatchpointSP &));
+ LLDB_REGISTER_STATIC_METHOD(bool, SBWatchpoint, EventIsWatchpointEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::WatchpointEventType, SBWatchpoint,
+ GetWatchpointEventTypeFromEvent,
+ (const lldb::SBEvent &));
+ LLDB_REGISTER_STATIC_METHOD(lldb::SBWatchpoint, SBWatchpoint,
+ GetWatchpointFromEvent,
+ (const lldb::SBEvent &));
+}
+
+}
}
diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp
index 42dea6a01abad..e7f2206b9a59d 100644
--- a/source/API/SystemInitializerFull.cpp
+++ b/source/API/SystemInitializerFull.cpp
@@ -1,16 +1,11 @@
//===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#if !defined(LLDB_DISABLE_PYTHON)
-#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
-#endif
-
#include "SystemInitializerFull.h"
#include "lldb/API/SBCommandInterpreter.h"
@@ -39,6 +34,7 @@
#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h"
#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h"
#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h"
+#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h"
#include "Plugins/Architecture/Arm/ArchitectureArm.h"
#include "Plugins/Architecture/Mips/ArchitectureMips.h"
#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h"
@@ -48,7 +44,10 @@
#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
+#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
+#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
+#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
@@ -63,6 +62,8 @@
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h"
+#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
+#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h"
@@ -70,7 +71,6 @@
#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h"
#include "Plugins/Platform/Android/PlatformAndroid.h"
#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
-#include "Plugins/Platform/Kalimba/PlatformKalimba.h"
#include "Plugins/Platform/Linux/PlatformLinux.h"
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
@@ -98,9 +98,9 @@
#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h"
#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h"
#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
-#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h"
#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
@@ -118,157 +118,21 @@
#include "llvm/Support/TargetSelect.h"
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+#include "llvm/ExecutionEngine/MCJIT.h"
+#pragma clang diagnostic pop
+
#include <string>
using namespace lldb_private;
-#ifndef LLDB_DISABLE_PYTHON
-
-// Defined in the SWIG source file
-#if PY_MAJOR_VERSION >= 3
-extern "C" PyObject *PyInit__lldb(void);
-
-#define LLDBSwigPyInit PyInit__lldb
-
-#else
-extern "C" void init_lldb(void);
-
-#define LLDBSwigPyInit init_lldb
-#endif
-
-// these are the Pythonic implementations of the required callbacks these are
-// scripting-language specific, which is why they belong here we still need to
-// use function pointers to them instead of relying on linkage-time resolution
-// because the SWIG stuff and this file get built at different times
-extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
- const char *python_function_name, const char *session_dictionary_name,
- const lldb::StackFrameSP &sb_frame,
- const lldb::BreakpointLocationSP &sb_bp_loc);
-
-extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
- const char *python_function_name, const char *session_dictionary_name,
- const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp);
-
-extern "C" bool LLDBSwigPythonCallTypeScript(
- const char *python_function_name, void *session_dictionary,
- const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
- const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval);
-
-extern "C" void *
-LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ValueObjectSP &valobj_sp);
-
-extern "C" void *
-LLDBSwigPythonCreateCommandObject(const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::DebuggerSP debugger_sp);
-
-extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::ThreadPlanSP &thread_plan_sp);
-
-extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
- const char *method_name,
- Event *event_sp, bool &got_error);
-
-extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
- const char *python_class_name,
- const char *session_dictionary_name,
- lldb_private::StructuredDataImpl *args,
- lldb::BreakpointSP &bkpt_sp);
-
-extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver(
- void *implementor,
- const char *method_name,
- lldb_private::SymbolContext *sym_ctx
-);
-
-extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
- uint32_t max);
-
-extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
- uint32_t idx);
-
-extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
- const char *child_name);
-
-extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
-
-extern lldb::ValueObjectSP
-LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
-
-extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor);
-
-extern "C" bool
-LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor);
-
-extern "C" void *
-LLDBSwigPython_GetValueSynthProviderInstance(void *implementor);
-
-extern "C" bool
-LLDBSwigPythonCallCommand(const char *python_function_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP &debugger, const char *args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
-extern "C" bool
-LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
- const char *args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
-extern "C" bool
-LLDBSwigPythonCallModuleInit(const char *python_module_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP &debugger);
-
-extern "C" void *
-LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ProcessSP &process_sp);
-
-extern "C" void *LLDBSWIGPython_CreateFrameRecognizer(
- const char *python_class_name,
- const char *session_dictionary_name);
-
-extern "C" void *LLDBSwigPython_GetRecognizedArguments(void *implementor,
- const lldb::StackFrameSP& frame_sp);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ProcessSP &process, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ThreadSP &thread, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::TargetSP &target, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::StackFrameSP &frame, std::string &output);
-
-extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ValueObjectSP &value, std::string &output);
-
-extern "C" void *
-LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
- const lldb::TargetSP &target_sp);
-
-#endif
-
SystemInitializerFull::SystemInitializerFull() {}
SystemInitializerFull::~SystemInitializerFull() {}
-llvm::Error
-SystemInitializerFull::Initialize(const InitializerOptions &options) {
- if (auto e = SystemInitializerCommon::Initialize(options))
+llvm::Error SystemInitializerFull::Initialize() {
+ if (auto e = SystemInitializerCommon::Initialize())
return e;
breakpad::ObjectFileBreakpad::Initialize();
@@ -276,6 +140,9 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
ObjectFileMachO::Initialize();
ObjectFilePECOFF::Initialize();
+ ObjectContainerBSDArchive::Initialize();
+ ObjectContainerUniversalMachO::Initialize();
+
ScriptInterpreterNone::Initialize();
#ifndef LLDB_DISABLE_PYTHON
@@ -283,11 +150,6 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
#endif
#if !defined(LLDB_DISABLE_PYTHON)
- InitializeSWIG();
-
- // ScriptInterpreterPython::Initialize() depends on things like HostInfo
- // being initialized so it can compute the python directory etc, so we need
- // to do this after SystemInitializerCommon::Initialize().
ScriptInterpreterPython::Initialize();
#endif
@@ -296,7 +158,6 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
platform_netbsd::PlatformNetBSD::Initialize();
platform_openbsd::PlatformOpenBSD::Initialize();
PlatformWindows::Initialize();
- PlatformKalimba::Initialize();
platform_android::PlatformAndroid::Initialize();
PlatformRemoteiOS::Initialize();
PlatformMacOSX::Initialize();
@@ -326,6 +187,7 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
ABISysV_mips::Initialize();
ABISysV_mips64::Initialize();
ABISysV_s390x::Initialize();
+ ABIWindows_x86_64::Initialize();
ArchitectureArm::Initialize();
ArchitectureMips::Initialize();
@@ -350,8 +212,13 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
SymbolFileSymtab::Initialize();
UnwindAssemblyInstEmulation::Initialize();
UnwindAssembly_x86::Initialize();
+
+ EmulateInstructionARM::Initialize();
EmulateInstructionARM64::Initialize();
+ EmulateInstructionMIPS::Initialize();
+ EmulateInstructionMIPS64::Initialize();
EmulateInstructionPPC64::Initialize();
+
SymbolFileDWARFDebugMap::Initialize();
ItaniumABILanguageRuntime::Initialize();
AppleObjCRuntimeV2::Initialize();
@@ -384,9 +251,7 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
// shouldn't be limited to __APPLE__.
StructuredDataDarwinLog::Initialize();
- //----------------------------------------------------------------------
// Platform agnostic plugins
- //----------------------------------------------------------------------
platform_gdb_server::PlatformRemoteGDBServer::Initialize();
process_gdb_remote::ProcessGDBRemote::Initialize();
@@ -408,31 +273,6 @@ SystemInitializerFull::Initialize(const InitializerOptions &options) {
return llvm::Error::success();
}
-void SystemInitializerFull::InitializeSWIG() {
-#if !defined(LLDB_DISABLE_PYTHON)
- ScriptInterpreterPython::InitializeInterpreter(
- LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction,
- LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript,
- LLDBSwigPythonCreateSyntheticProvider, LLDBSwigPythonCreateCommandObject,
- LLDBSwigPython_CalculateNumChildren, LLDBSwigPython_GetChildAtIndex,
- LLDBSwigPython_GetIndexOfChildWithName,
- LLDBSWIGPython_CastPyObjectToSBValue,
- LLDBSWIGPython_GetValueObjectSPFromSBValue,
- LLDBSwigPython_UpdateSynthProviderInstance,
- LLDBSwigPython_MightHaveChildrenSynthProviderInstance,
- LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand,
- LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit,
- LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPython_CreateFrameRecognizer,
- LLDBSwigPython_GetRecognizedArguments,
- LLDBSWIGPythonRunScriptKeywordProcess,
- LLDBSWIGPythonRunScriptKeywordThread,
- LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame,
- LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting,
- LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan,
- LLDBSwigPythonCreateScriptedBreakpointResolver, LLDBSwigPythonCallBreakpointResolver);
-#endif
-}
-
void SystemInitializerFull::Terminate() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
@@ -461,6 +301,7 @@ void SystemInitializerFull::Terminate() {
ABISysV_mips::Terminate();
ABISysV_mips64::Terminate();
ABISysV_s390x::Terminate();
+ ABIWindows_x86_64::Terminate();
DisassemblerLLVMC::Terminate();
JITLoaderGDB::Terminate();
@@ -479,8 +320,13 @@ void SystemInitializerFull::Terminate() {
SymbolFileSymtab::Terminate();
UnwindAssembly_x86::Terminate();
UnwindAssemblyInstEmulation::Terminate();
+
+ EmulateInstructionARM::Terminate();
EmulateInstructionARM64::Terminate();
+ EmulateInstructionMIPS::Terminate();
+ EmulateInstructionMIPS64::Terminate();
EmulateInstructionPPC64::Terminate();
+
SymbolFileDWARFDebugMap::Terminate();
ItaniumABILanguageRuntime::Terminate();
AppleObjCRuntimeV2::Terminate();
@@ -527,7 +373,6 @@ void SystemInitializerFull::Terminate() {
platform_netbsd::PlatformNetBSD::Terminate();
platform_openbsd::PlatformOpenBSD::Terminate();
PlatformWindows::Terminate();
- PlatformKalimba::Terminate();
platform_android::PlatformAndroid::Terminate();
PlatformMacOSX::Terminate();
PlatformRemoteiOS::Terminate();
@@ -541,6 +386,9 @@ void SystemInitializerFull::Terminate() {
ObjectFileMachO::Terminate();
ObjectFilePECOFF::Terminate();
+ ObjectContainerBSDArchive::Terminate();
+ ObjectContainerUniversalMachO::Terminate();
+
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
}
diff --git a/source/API/SystemInitializerFull.h b/source/API/SystemInitializerFull.h
index b0cf476e91936..cd88bae978585 100644
--- a/source/API/SystemInitializerFull.h
+++ b/source/API/SystemInitializerFull.h
@@ -1,9 +1,8 @@
//===-- SystemInitializerFull.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,24 +12,19 @@
#include "lldb/Initialization/SystemInitializerCommon.h"
namespace lldb_private {
-//------------------------------------------------------------------
/// Initializes lldb.
///
/// This class is responsible for initializing all of lldb system
/// services needed to use the full LLDB application. This class is
/// 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;
- llvm::Error Initialize(const InitializerOptions &options) override;
+ llvm::Error Initialize() override;
void Terminate() override;
-
-private:
- void InitializeSWIG();
};
} // namespace lldb_private
diff --git a/source/API/Utils.h b/source/API/Utils.h
new file mode 100644
index 0000000000000..b1975e5421ddf
--- /dev/null
+++ b/source/API/Utils.h
@@ -0,0 +1,30 @@
+//===-- Utils.h -------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_UTILS_H
+#define LLDB_API_UTILS_H
+
+#include "llvm/ADT/STLExtras.h"
+#include <memory>
+
+namespace lldb_private {
+
+template <typename T> std::unique_ptr<T> clone(const std::unique_ptr<T> &src) {
+ if (src)
+ return llvm::make_unique<T>(*src);
+ return nullptr;
+}
+
+template <typename T> std::shared_ptr<T> clone(const std::shared_ptr<T> &src) {
+ if (src)
+ return std::make_shared<T>(*src);
+ return nullptr;
+}
+
+} // namespace lldb_private
+#endif
diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp
index 131d2a707d447..3c3841949b91d 100644
--- a/source/Breakpoint/Breakpoint.cpp
+++ b/source/Breakpoint/Breakpoint.cpp
@@ -1,9 +1,8 @@
//===-- Breakpoint.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointLocationCollection.h"
+#include "lldb/Breakpoint/BreakpointPrecondition.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
#include "lldb/Core/Address.h"
@@ -30,11 +30,13 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
using namespace llvm;
-const ConstString &Breakpoint::GetEventIdentifier() {
+ConstString Breakpoint::GetEventIdentifier() {
static ConstString g_identifier("event-identifier.breakpoint.changed");
return g_identifier;
}
@@ -42,9 +44,7 @@ const ConstString &Breakpoint::GetEventIdentifier() {
const char *Breakpoint::g_option_names[static_cast<uint32_t>(
Breakpoint::OptionNames::LastOptionName)]{"Names", "Hardware"};
-//----------------------------------------------------------------------
// Breakpoint constructor
-//----------------------------------------------------------------------
Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
BreakpointResolverSP &resolver_sp, bool hardware,
bool resolve_indirect_symbols)
@@ -58,7 +58,7 @@ Breakpoint::Breakpoint(Target &target, SearchFilterSP &filter_sp,
Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
: m_being_created(true), m_hardware(source_bp.m_hardware),
m_target(new_target), m_name_list(source_bp.m_name_list),
- m_options_up(new BreakpointOptions(*source_bp.m_options_up.get())),
+ m_options_up(new BreakpointOptions(*source_bp.m_options_up)),
m_locations(*this),
m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
m_hit_count(0) {
@@ -67,14 +67,10 @@ Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Breakpoint::~Breakpoint() = default;
-//----------------------------------------------------------------------
// Serialization
-//----------------------------------------------------------------------
StructuredData::ObjectSP Breakpoint::SerializeToStructuredData() {
// Serialize the resolver:
StructuredData::DictionarySP breakpoint_dict_sp(
@@ -159,8 +155,8 @@ lldb::BreakpointSP Breakpoint::CreateFromStructuredData(
SearchFilter::GetSerializationKey(), filter_dict);
SearchFilterSP filter_sp;
if (!success)
- filter_sp.reset(
- new SearchFilterForUnconstrainedSearches(target.shared_from_this()));
+ filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
+ target.shared_from_this());
else {
filter_sp = SearchFilter::CreateFromStructuredData(target, *filter_dict,
create_error);
@@ -495,9 +491,7 @@ void Breakpoint::ClearAllBreakpointSites() {
m_locations.ClearAllBreakpointSites();
}
-//----------------------------------------------------------------------
// ModulesChanged: Pass in a list of new modules, and
-//----------------------------------------------------------------------
void Breakpoint::ModulesChanged(ModuleList &module_list, bool load,
bool delete_locations) {
@@ -971,7 +965,7 @@ void Breakpoint::GetResolverDescription(Stream *s) {
m_resolver_sp->GetDescription(s);
}
-bool Breakpoint::GetMatchingFileLine(const ConstString &filename,
+bool Breakpoint::GetMatchingFileLine(ConstString filename,
uint32_t line_number,
BreakpointLocationCollection &loc_coll) {
// TODO: To be correct, this method needs to fill the breakpoint location
@@ -1002,21 +996,6 @@ bool Breakpoint::EvaluatePrecondition(StoppointCallbackContext &context) {
return m_precondition_sp->EvaluatePrecondition(context);
}
-bool Breakpoint::BreakpointPrecondition::EvaluatePrecondition(
- StoppointCallbackContext &context) {
- return true;
-}
-
-void Breakpoint::BreakpointPrecondition::GetDescription(
- Stream &stream, lldb::DescriptionLevel level) {}
-
-Status
-Breakpoint::BreakpointPrecondition::ConfigurePrecondition(Args &options) {
- Status error;
- error.SetErrorString("Base breakpoint precondition has no options.");
- return error;
-}
-
void Breakpoint::SendBreakpointChangedEvent(
lldb::BreakpointEventType eventKind) {
if (!m_being_created && !IsInternal() &&
@@ -1047,12 +1026,12 @@ Breakpoint::BreakpointEventData::BreakpointEventData(
Breakpoint::BreakpointEventData::~BreakpointEventData() = default;
-const ConstString &Breakpoint::BreakpointEventData::GetFlavorString() {
+ConstString Breakpoint::BreakpointEventData::GetFlavorString() {
static ConstString g_flavor("Breakpoint::BreakpointEventData");
return g_flavor;
}
-const ConstString &Breakpoint::BreakpointEventData::GetFlavor() const {
+ConstString Breakpoint::BreakpointEventData::GetFlavor() const {
return BreakpointEventData::GetFlavorString();
}
diff --git a/source/Breakpoint/BreakpointID.cpp b/source/Breakpoint/BreakpointID.cpp
index eb12e09abcf1c..dc2e57cb085d9 100644
--- a/source/Breakpoint/BreakpointID.cpp
+++ b/source/Breakpoint/BreakpointID.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointID.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Breakpoint/BreakpointIDList.cpp b/source/Breakpoint/BreakpointIDList.cpp
index b86f276a5c476..1e695fae69951 100644
--- a/source/Breakpoint/BreakpointIDList.cpp
+++ b/source/Breakpoint/BreakpointIDList.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointIDList.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// class BreakpointIDList
-//----------------------------------------------------------------------
BreakpointIDList::BreakpointIDList()
: m_invalid_id(LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) {}
diff --git a/source/Breakpoint/BreakpointList.cpp b/source/Breakpoint/BreakpointList.cpp
index 370da10d82b45..c80fb917b4903 100644
--- a/source/Breakpoint/BreakpointList.cpp
+++ b/source/Breakpoint/BreakpointList.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointList.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp
index 5d3763a367c37..b718e2aeea5c8 100644
--- a/source/Breakpoint/BreakpointLocation.cpp
+++ b/source/Breakpoint/BreakpointLocation.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointLocation.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,7 +35,7 @@ BreakpointLocation::BreakpointLocation(break_id_t loc_id, Breakpoint &owner,
hardware),
m_being_created(true), m_should_resolve_indirect_functions(false),
m_is_reexported(false), m_is_indirect(false), m_address(addr),
- m_owner(owner), m_options_ap(), m_bp_site_sp(), m_condition_mutex() {
+ m_owner(owner), m_options_up(), m_bp_site_sp(), m_condition_mutex() {
if (check_for_resolver) {
Symbol *symbol = m_address.CalculateSymbolContextSymbol();
if (symbol && symbol->IsIndirect()) {
@@ -57,10 +56,10 @@ lldb::addr_t BreakpointLocation::GetLoadAddress() const {
const BreakpointOptions *
BreakpointLocation::GetOptionsSpecifyingKind(BreakpointOptions::OptionKind kind)
const {
- if (m_options_ap && m_options_ap->IsOptionSet(kind))
- return m_options_ap.get();
- else
- return m_owner.GetOptions();
+ if (m_options_up && m_options_up->IsOptionSet(kind))
+ return m_options_up.get();
+ else
+ return m_owner.GetOptions();
}
Address &BreakpointLocation::GetAddress() { return m_address; }
@@ -72,8 +71,8 @@ Target &BreakpointLocation::GetTarget() { return m_owner.GetTarget(); }
bool BreakpointLocation::IsEnabled() const {
if (!m_owner.IsEnabled())
return false;
- else if (m_options_ap.get() != nullptr)
- return m_options_ap->IsEnabled();
+ else if (m_options_up != nullptr)
+ return m_options_up->IsEnabled();
else
return true;
}
@@ -90,9 +89,9 @@ void BreakpointLocation::SetEnabled(bool enabled) {
}
bool BreakpointLocation::IsAutoContinue() const {
- if (m_options_ap
- && m_options_ap->IsOptionSet(BreakpointOptions::eAutoContinue))
- return m_options_ap->IsAutoContinue();
+ if (m_options_up &&
+ m_options_up->IsOptionSet(BreakpointOptions::eAutoContinue))
+ return m_options_up->IsAutoContinue();
else
return m_owner.IsAutoContinue();
}
@@ -108,8 +107,8 @@ void BreakpointLocation::SetThreadID(lldb::tid_t thread_id) {
else {
// If we're resetting this to an invalid thread id, then don't make an
// options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->SetThreadID(thread_id);
+ if (m_options_up != nullptr)
+ m_options_up->SetThreadID(thread_id);
}
SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
@@ -130,8 +129,8 @@ void BreakpointLocation::SetThreadIndex(uint32_t index) {
else {
// If we're resetting this to an invalid thread id, then don't make an
// options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetIndex(index);
+ if (m_options_up != nullptr)
+ m_options_up->GetThreadSpec()->SetIndex(index);
}
SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
@@ -152,8 +151,8 @@ void BreakpointLocation::SetThreadName(const char *thread_name) {
else {
// If we're resetting this to an invalid thread id, then don't make an
// options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetName(thread_name);
+ if (m_options_up != nullptr)
+ m_options_up->GetThreadSpec()->SetName(thread_name);
}
SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
@@ -174,8 +173,8 @@ void BreakpointLocation::SetQueueName(const char *queue_name) {
else {
// If we're resetting this to an invalid thread id, then don't make an
// options pointer just to do that.
- if (m_options_ap.get() != nullptr)
- m_options_ap->GetThreadSpec()->SetQueueName(queue_name);
+ if (m_options_up != nullptr)
+ m_options_up->GetThreadSpec()->SetQueueName(queue_name);
}
SendBreakpointLocationChangedEvent(eBreakpointEventTypeThreadChanged);
}
@@ -191,8 +190,8 @@ const char *BreakpointLocation::GetQueueName() const {
}
bool BreakpointLocation::InvokeCallback(StoppointCallbackContext *context) {
- if (m_options_ap.get() != nullptr && m_options_ap->HasCallback())
- return m_options_ap->InvokeCallback(context, m_owner.GetID(), GetID());
+ if (m_options_up != nullptr && m_options_up->HasCallback())
+ return m_options_up->InvokeCallback(context, m_owner.GetID(), GetID());
else
return m_owner.InvokeCallback(context, GetID());
}
@@ -256,7 +255,7 @@ bool BreakpointLocation::ConditionSaysStop(ExecutionContext &exe_ctx,
m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(
condition_text, llvm::StringRef(), language, Expression::eResultTypeAny,
- EvaluateExpressionOptions(), error));
+ EvaluateExpressionOptions(), nullptr, error));
if (error.Fail()) {
if (log)
log->Printf("Error getting condition expression: %s.",
@@ -345,16 +344,16 @@ void BreakpointLocation::SetIgnoreCount(uint32_t n) {
}
void BreakpointLocation::DecrementIgnoreCount() {
- if (m_options_ap.get() != nullptr) {
- uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+ if (m_options_up != nullptr) {
+ uint32_t loc_ignore = m_options_up->GetIgnoreCount();
if (loc_ignore != 0)
- m_options_ap->SetIgnoreCount(loc_ignore - 1);
+ m_options_up->SetIgnoreCount(loc_ignore - 1);
}
}
bool BreakpointLocation::IgnoreCountShouldStop() {
- if (m_options_ap.get() != nullptr) {
- uint32_t loc_ignore = m_options_ap->GetIgnoreCount();
+ if (m_options_up != nullptr) {
+ uint32_t loc_ignore = m_options_up->GetIgnoreCount();
if (loc_ignore != 0) {
m_owner.DecrementIgnoreCount();
DecrementIgnoreCount(); // Have to decrement our owners' ignore count,
@@ -370,11 +369,10 @@ BreakpointOptions *BreakpointLocation::GetLocationOptions() {
// If we make the copy we don't copy the callbacks because that is
// potentially expensive and we don't want to do that for the simple case
// where someone is just disabling the location.
- if (m_options_ap.get() == nullptr)
- m_options_ap.reset(
- new BreakpointOptions(false));
+ if (m_options_up == nullptr)
+ m_options_up.reset(new BreakpointOptions(false));
- return m_options_ap.get();
+ return m_options_up.get();
}
bool BreakpointLocation::ValidForThisThread(Thread *thread) {
@@ -455,13 +453,11 @@ bool BreakpointLocation::ResolveBreakpointSite() {
if (new_id == LLDB_INVALID_BREAK_ID) {
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
if (log)
- log->Warning("Tried to add breakpoint site at 0x%" PRIx64
- " but it was already present.\n",
+ log->Warning("Failed to add breakpoint site at 0x%" PRIx64,
m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()));
- return false;
}
- return true;
+ return IsResolved();
}
bool BreakpointLocation::SetBreakpointSite(BreakpointSiteSP &bp_site_sp) {
@@ -606,17 +602,17 @@ void BreakpointLocation::GetDescription(Stream *s,
s->Indent();
s->Printf("hit count = %-4u\n", GetHitCount());
- if (m_options_ap.get()) {
+ if (m_options_up) {
s->Indent();
- m_options_ap->GetDescription(s, level);
+ m_options_up->GetDescription(s, level);
s->EOL();
}
s->IndentLess();
} else if (level != eDescriptionLevelInitial) {
s->Printf(", %sresolved, hit count = %u ", (IsResolved() ? "" : "un"),
GetHitCount());
- if (m_options_ap.get()) {
- m_options_ap->GetDescription(s, level);
+ if (m_options_up) {
+ m_options_up->GetDescription(s, level);
}
}
}
@@ -627,18 +623,18 @@ void BreakpointLocation::Dump(Stream *s) const {
lldb::tid_t tid = GetOptionsSpecifyingKind(BreakpointOptions::eThreadSpec)
->GetThreadSpecNoCreate()->GetTID();
- s->Printf(
- "BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64
- " state = %s type = %s breakpoint "
- "hw_index = %i hit_count = %-4u ignore_count = %-4u",
- GetID(), tid,
- (uint64_t)m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()),
- (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled())
- ? "enabled "
- : "disabled",
- IsHardware() ? "hardware" : "software", GetHardwareIndex(), GetHitCount(),
- GetOptionsSpecifyingKind(BreakpointOptions::eIgnoreCount)
- ->GetIgnoreCount());
+ s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64
+ " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint "
+ "hw_index = %i hit_count = %-4u ignore_count = %-4u",
+ GetID(), tid,
+ (uint64_t)m_address.GetOpcodeLoadAddress(&m_owner.GetTarget()),
+ (m_options_up ? m_options_up->IsEnabled() : m_owner.IsEnabled())
+ ? "enabled "
+ : "disabled",
+ IsHardware() ? "hardware" : "software", GetHardwareIndex(),
+ GetHitCount(),
+ GetOptionsSpecifyingKind(BreakpointOptions::eIgnoreCount)
+ ->GetIgnoreCount());
}
void BreakpointLocation::SendBreakpointLocationChangedEvent(
diff --git a/source/Breakpoint/BreakpointLocationCollection.cpp b/source/Breakpoint/BreakpointLocationCollection.cpp
index 27957a50d2b00..76084adbd2aaf 100644
--- a/source/Breakpoint/BreakpointLocationCollection.cpp
+++ b/source/Breakpoint/BreakpointLocationCollection.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointLocationCollection.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,15 +16,11 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// BreakpointLocationCollection constructor
-//----------------------------------------------------------------------
BreakpointLocationCollection::BreakpointLocationCollection()
: m_break_loc_collection(), m_collection_mutex() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
BreakpointLocationCollection::~BreakpointLocationCollection() {}
void BreakpointLocationCollection::Add(const BreakpointLocationSP &bp_loc) {
@@ -179,3 +174,14 @@ void BreakpointLocationCollection::GetDescription(
(*pos)->GetDescription(s, level);
}
}
+
+BreakpointLocationCollection &BreakpointLocationCollection::operator=(
+ const BreakpointLocationCollection &rhs) {
+ if (this != &rhs) {
+ std::lock(m_collection_mutex, rhs.m_collection_mutex);
+ std::lock_guard<std::mutex> lhs_guard(m_collection_mutex, std::adopt_lock);
+ std::lock_guard<std::mutex> rhs_guard(rhs.m_collection_mutex, std::adopt_lock);
+ m_break_loc_collection = rhs.m_break_loc_collection;
+ }
+ return *this;
+}
diff --git a/source/Breakpoint/BreakpointLocationList.cpp b/source/Breakpoint/BreakpointLocationList.cpp
index 6a3280e961cc7..ee586127ee783 100644
--- a/source/Breakpoint/BreakpointLocationList.cpp
+++ b/source/Breakpoint/BreakpointLocationList.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointLocationList.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -130,7 +129,7 @@ void BreakpointLocationList::Dump(Stream *s) const {
s->IndentMore();
collection::const_iterator pos, end = m_locations.end();
for (pos = m_locations.begin(); pos != end; ++pos)
- (*pos).get()->Dump(s);
+ (*pos)->Dump(s);
s->IndentLess();
}
diff --git a/source/Breakpoint/BreakpointName.cpp b/source/Breakpoint/BreakpointName.cpp
index baf871ebbae1f..749fa86bca9dd 100644
--- a/source/Breakpoint/BreakpointName.cpp
+++ b/source/Breakpoint/BreakpointName.cpp
@@ -1,9 +1,8 @@
-//===-- Breakpoint.cpp ------------------------------------------*- C++ -*-===//
+//===-- BreakpointName.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details->
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,7 +28,7 @@ const Flags::ValueType BreakpointName::Permissions::permissions_mask
(0x5u)
};
-BreakpointName::BreakpointName(const ConstString &name, const Breakpoint &bkpt,
+BreakpointName::BreakpointName(ConstString name, const Breakpoint &bkpt,
const char *help) :
m_name(name), m_options(bkpt.GetOptions())
{
diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp
index ff497c5633b06..f6f279dc382a2 100644
--- a/source/Breakpoint/BreakpointOptions.cpp
+++ b/source/Breakpoint/BreakpointOptions.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointOptions.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -120,18 +119,16 @@ bool BreakpointOptions::NullCallback(void *baton,
return true;
}
-//----------------------------------------------------------------------
// BreakpointOptions constructor
-//----------------------------------------------------------------------
BreakpointOptions::BreakpointOptions(bool all_flags_set)
: m_callback(BreakpointOptions::NullCallback), m_callback_baton_sp(),
m_baton_is_command_baton(false), m_callback_is_synchronous(false),
- m_enabled(true), m_one_shot(false), m_ignore_count(0), m_thread_spec_ap(),
+ m_enabled(true), m_one_shot(false), m_ignore_count(0), m_thread_spec_up(),
m_condition_text(), m_condition_text_hash(0), m_auto_continue(false),
m_set_flags(0) {
- if (all_flags_set)
- m_set_flags.Set(~((Flags::ValueType) 0));
- }
+ if (all_flags_set)
+ m_set_flags.Set(~((Flags::ValueType)0));
+}
BreakpointOptions::BreakpointOptions(const char *condition, bool enabled,
int32_t ignore, bool one_shot,
@@ -148,26 +145,21 @@ BreakpointOptions::BreakpointOptions(const char *condition, bool enabled,
}
}
-//----------------------------------------------------------------------
// BreakpointOptions copy constructor
-//----------------------------------------------------------------------
BreakpointOptions::BreakpointOptions(const BreakpointOptions &rhs)
: m_callback(rhs.m_callback), m_callback_baton_sp(rhs.m_callback_baton_sp),
m_baton_is_command_baton(rhs.m_baton_is_command_baton),
m_callback_is_synchronous(rhs.m_callback_is_synchronous),
m_enabled(rhs.m_enabled), m_one_shot(rhs.m_one_shot),
- m_ignore_count(rhs.m_ignore_count), m_thread_spec_ap(),
- m_auto_continue(rhs.m_auto_continue),
- m_set_flags(rhs.m_set_flags) {
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ m_ignore_count(rhs.m_ignore_count), m_thread_spec_up(),
+ m_auto_continue(rhs.m_auto_continue), m_set_flags(rhs.m_set_flags) {
+ if (rhs.m_thread_spec_up != nullptr)
+ m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
}
-//----------------------------------------------------------------------
// BreakpointOptions assignment operator
-//----------------------------------------------------------------------
const BreakpointOptions &BreakpointOptions::
operator=(const BreakpointOptions &rhs) {
m_callback = rhs.m_callback;
@@ -177,8 +169,8 @@ operator=(const BreakpointOptions &rhs) {
m_enabled = rhs.m_enabled;
m_one_shot = rhs.m_one_shot;
m_ignore_count = rhs.m_ignore_count;
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ if (rhs.m_thread_spec_up != nullptr)
+ m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
m_condition_text = rhs.m_condition_text;
m_condition_text_hash = rhs.m_condition_text_hash;
m_auto_continue = rhs.m_auto_continue;
@@ -229,19 +221,16 @@ void BreakpointOptions::CopyOverSetOptions(const BreakpointOptions &incoming)
m_auto_continue = incoming.m_auto_continue;
m_set_flags.Set(eAutoContinue);
}
- if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_ap)
- {
- if (!m_thread_spec_ap)
- m_thread_spec_ap.reset(new ThreadSpec(*incoming.m_thread_spec_ap.get()));
+ if (incoming.m_set_flags.Test(eThreadSpec) && incoming.m_thread_spec_up) {
+ if (!m_thread_spec_up)
+ m_thread_spec_up.reset(new ThreadSpec(*incoming.m_thread_spec_up));
else
- *m_thread_spec_ap.get() = *incoming.m_thread_spec_ap.get();
+ *m_thread_spec_up = *incoming.m_thread_spec_up;
m_set_flags.Set(eThreadSpec);
}
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
BreakpointOptions::~BreakpointOptions() = default;
std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
@@ -256,55 +245,50 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
const char *key = GetKey(OptionNames::EnabledState);
bool success;
- if (key) {
+ if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsBoolean(key, enabled);
if (!success) {
- error.SetErrorStringWithFormat("%s key is not a boolean.",
- GetKey(OptionNames::EnabledState));
+ error.SetErrorStringWithFormat("%s key is not a boolean.", key);
return nullptr;
}
set_options.Set(eEnabled);
}
key = GetKey(OptionNames::OneShotState);
- if (key) {
+ if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsBoolean(key, one_shot);
if (!success) {
- error.SetErrorStringWithFormat("%s key is not a boolean.",
- GetKey(OptionNames::OneShotState));
+ error.SetErrorStringWithFormat("%s key is not a boolean.", key);
return nullptr;
}
set_options.Set(eOneShot);
}
key = GetKey(OptionNames::AutoContinue);
- if (key) {
+ if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsBoolean(key, auto_continue);
if (!success) {
- error.SetErrorStringWithFormat("%s key is not a boolean.",
- GetKey(OptionNames::AutoContinue));
+ error.SetErrorStringWithFormat("%s key is not a boolean.", key);
return nullptr;
}
set_options.Set(eAutoContinue);
}
key = GetKey(OptionNames::IgnoreCount);
- if (key) {
+ if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsInteger(key, ignore_count);
if (!success) {
- error.SetErrorStringWithFormat("%s key is not an integer.",
- GetKey(OptionNames::IgnoreCount));
+ error.SetErrorStringWithFormat("%s key is not an integer.", key);
return nullptr;
}
set_options.Set(eIgnoreCount);
}
key = GetKey(OptionNames::ConditionText);
- if (key) {
+ if (key && options_dict.HasKey(key)) {
success = options_dict.GetValueForKeyAsString(key, condition_ref);
if (!success) {
- error.SetErrorStringWithFormat("%s key is not an string.",
- GetKey(OptionNames::ConditionText));
+ error.SetErrorStringWithFormat("%s key is not an string.", key);
return nullptr;
}
set_options.Set(eCondition);
@@ -328,12 +312,11 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
auto bp_options = llvm::make_unique<BreakpointOptions>(
condition_ref.str().c_str(), enabled,
ignore_count, one_shot, auto_continue);
- if (cmd_data_up.get()) {
+ if (cmd_data_up) {
if (cmd_data_up->interpreter == eScriptLanguageNone)
bp_options->SetCommandDataCallback(cmd_data_up);
else {
- ScriptInterpreter *interp =
- target.GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *interp = target.GetDebugger().GetScriptInterpreter();
if (!interp) {
error.SetErrorStringWithFormat(
"Can't set script commands - no script interpreter");
@@ -405,18 +388,16 @@ StructuredData::ObjectSP BreakpointOptions::SerializeToStructuredData() {
BreakpointOptions::CommandData::GetSerializationKey(), commands_sp);
}
}
- if (m_set_flags.Test(eThreadSpec) && m_thread_spec_ap) {
+ if (m_set_flags.Test(eThreadSpec) && m_thread_spec_up) {
StructuredData::ObjectSP thread_spec_sp =
- m_thread_spec_ap->SerializeToStructuredData();
+ m_thread_spec_up->SerializeToStructuredData();
options_dict_sp->AddItem(ThreadSpec::GetSerializationKey(), thread_spec_sp);
}
return options_dict_sp;
}
-//------------------------------------------------------------------
// Callbacks
-//------------------------------------------------------------------
void BreakpointOptions::SetCallback(BreakpointHitCallback callback,
const lldb::BatonSP &callback_baton_sp,
bool callback_is_synchronous) {
@@ -522,17 +503,16 @@ const char *BreakpointOptions::GetConditionText(size_t *hash) const {
}
const ThreadSpec *BreakpointOptions::GetThreadSpecNoCreate() const {
- return m_thread_spec_ap.get();
+ return m_thread_spec_up.get();
}
ThreadSpec *BreakpointOptions::GetThreadSpec() {
- if (m_thread_spec_ap.get() == nullptr)
- {
+ if (m_thread_spec_up == nullptr) {
m_set_flags.Set(eThreadSpec);
- m_thread_spec_ap.reset(new ThreadSpec());
+ m_thread_spec_up.reset(new ThreadSpec());
}
- return m_thread_spec_ap.get();
+ return m_thread_spec_up.get();
}
void BreakpointOptions::SetThreadID(lldb::tid_t thread_id) {
@@ -542,7 +522,7 @@ void BreakpointOptions::SetThreadID(lldb::tid_t thread_id) {
void BreakpointOptions::SetThreadSpec(
std::unique_ptr<ThreadSpec> &thread_spec_up) {
- m_thread_spec_ap = std::move(thread_spec_up);
+ m_thread_spec_up = std::move(thread_spec_up);
m_set_flags.Set(eThreadSpec);
}
@@ -574,8 +554,8 @@ void BreakpointOptions::GetDescription(Stream *s,
if (m_auto_continue)
s->Printf("auto-continue ");
- if (m_thread_spec_ap.get())
- m_thread_spec_ap->GetDescription(s, level);
+ if (m_thread_spec_up)
+ m_thread_spec_up->GetDescription(s, level);
if (level == lldb::eDescriptionLevelFull) {
s->IndentLess();
@@ -666,6 +646,7 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction(
options.SetStopOnError(data->stop_on_error);
options.SetEchoCommands(true);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetAddToHistory(false);
debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx,
@@ -680,7 +661,7 @@ bool BreakpointOptions::BreakpointOptionsCallbackFunction(
void BreakpointOptions::Clear()
{
m_set_flags.Clear();
- m_thread_spec_ap.release();
+ m_thread_spec_up.release();
m_one_shot = false;
m_ignore_count = 0;
m_auto_continue = false;
diff --git a/source/Breakpoint/BreakpointPrecondition.cpp b/source/Breakpoint/BreakpointPrecondition.cpp
new file mode 100644
index 0000000000000..a387c75c83567
--- /dev/null
+++ b/source/Breakpoint/BreakpointPrecondition.cpp
@@ -0,0 +1,26 @@
+//===-- BreakpointPrecondition.cpp ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Breakpoint/BreakpointPrecondition.h"
+#include "lldb/Utility/Status.h"
+
+using namespace lldb_private;
+
+bool BreakpointPrecondition::EvaluatePrecondition(
+ StoppointCallbackContext &context) {
+ return false;
+}
+
+void BreakpointPrecondition::GetDescription(Stream &stream,
+ lldb::DescriptionLevel level) {}
+
+Status BreakpointPrecondition::ConfigurePrecondition(Args &args) {
+ Status error;
+ error.SetErrorString("Base breakpoint precondition has no options.");
+ return error;
+}
diff --git a/source/Breakpoint/BreakpointResolver.cpp b/source/Breakpoint/BreakpointResolver.cpp
index 0a1eeed289543..b3224aa91753d 100644
--- a/source/Breakpoint/BreakpointResolver.cpp
+++ b/source/Breakpoint/BreakpointResolver.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointResolver.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,7 @@
using namespace lldb_private;
using namespace lldb;
-//----------------------------------------------------------------------
// BreakpointResolver:
-//----------------------------------------------------------------------
const char *BreakpointResolver::g_ty_to_name[] = {"FileAndLine", "Address",
"SymbolName", "SourceRegex",
"Exception", "Unknown"};
diff --git a/source/Breakpoint/BreakpointResolverAddress.cpp b/source/Breakpoint/BreakpointResolverAddress.cpp
index 3084ce41e8e3d..8a6fd6a2692c8 100644
--- a/source/Breakpoint/BreakpointResolverAddress.cpp
+++ b/source/Breakpoint/BreakpointResolverAddress.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointResolverAddress.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,9 +20,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// BreakpointResolverAddress:
-//----------------------------------------------------------------------
BreakpointResolverAddress::BreakpointResolverAddress(
Breakpoint *bkpt, const Address &addr, const FileSpec &module_spec)
: BreakpointResolver(bkpt, BreakpointResolver::AddressResolver),
@@ -127,7 +124,7 @@ Searcher::CallbackReturn
BreakpointResolverAddress::SearchCallback(SearchFilter &filter,
SymbolContext &context, Address *addr,
bool containing) {
- assert(m_breakpoint != NULL);
+ assert(m_breakpoint != nullptr);
if (filter.AddressPasses(m_addr)) {
if (m_breakpoint->GetNumLocations() == 0) {
diff --git a/source/Breakpoint/BreakpointResolverFileLine.cpp b/source/Breakpoint/BreakpointResolverFileLine.cpp
index 438f430bd2a52..a6095be316471 100644
--- a/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointResolverFileLine.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// BreakpointResolverFileLine:
-//----------------------------------------------------------------------
BreakpointResolverFileLine::BreakpointResolverFileLine(
Breakpoint *bkpt, const FileSpec &file_spec, uint32_t line_no,
uint32_t column, lldb::addr_t offset, bool check_inlines,
@@ -207,7 +204,7 @@ BreakpointResolverFileLine::SearchCallback(SearchFilter &filter,
Address *addr, bool containing) {
SymbolContextList sc_list;
- assert(m_breakpoint != NULL);
+ assert(m_breakpoint != nullptr);
// There is a tricky bit here. You can have two compilation units that
// #include the same file, and in one of them the function at m_line_number
diff --git a/source/Breakpoint/BreakpointResolverFileRegex.cpp b/source/Breakpoint/BreakpointResolverFileRegex.cpp
index 62cf9553c82c3..0b2485245b726 100644
--- a/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ b/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointResolverFileRegex.cpp -------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// BreakpointResolverFileRegex:
-//----------------------------------------------------------------------
BreakpointResolverFileRegex::BreakpointResolverFileRegex(
Breakpoint *bkpt, RegularExpression &regex,
const std::unordered_set<std::string> &func_names, bool exact_match)
@@ -101,7 +98,7 @@ BreakpointResolverFileRegex::SearchCallback(SearchFilter &filter,
SymbolContext &context,
Address *addr, bool containing) {
- assert(m_breakpoint != NULL);
+ assert(m_breakpoint != nullptr);
if (!context.target_sp)
return eCallbackReturnContinue;
@@ -148,7 +145,7 @@ BreakpointResolverFileRegex::SearchCallback(SearchFilter &filter,
BreakpointResolver::SetSCMatchesByLine(filter, sc_list, skip_prologue,
m_regex.GetText());
}
- assert(m_breakpoint != NULL);
+ assert(m_breakpoint != nullptr);
return Searcher::eCallbackReturnContinue;
}
diff --git a/source/Breakpoint/BreakpointResolverName.cpp b/source/Breakpoint/BreakpointResolverName.cpp
index 43f7cb85a574e..3ad2e8867f2a8 100644
--- a/source/Breakpoint/BreakpointResolverName.cpp
+++ b/source/Breakpoint/BreakpointResolverName.cpp
@@ -1,16 +1,13 @@
//===-- BreakpointResolverName.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Breakpoint/BreakpointResolverName.h"
-#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Architecture.h"
#include "lldb/Core/Module.h"
@@ -19,6 +16,7 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Target.h"
+#include "lldb/Target/Language.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
@@ -218,22 +216,29 @@ StructuredData::ObjectSP BreakpointResolverName::SerializeToStructuredData() {
return WrapOptionsDict(options_dict_sp);
}
-void BreakpointResolverName::AddNameLookup(const ConstString &name,
+void BreakpointResolverName::AddNameLookup(ConstString name,
FunctionNameType name_type_mask) {
- ObjCLanguage::MethodName objc_method(name.GetCString(), false);
- if (objc_method.IsValid(false)) {
- std::vector<ConstString> objc_names;
- objc_method.GetFullNames(objc_names, true);
- for (ConstString objc_name : objc_names) {
- Module::LookupInfo lookup;
- lookup.SetName(name);
- lookup.SetLookupName(objc_name);
- lookup.SetNameTypeMask(eFunctionNameTypeFull);
- m_lookups.push_back(lookup);
+
+ Module::LookupInfo lookup(name, name_type_mask, m_language);
+ m_lookups.emplace_back(lookup);
+
+ auto add_variant_funcs = [&](Language *lang) {
+ for (ConstString variant_name : lang->GetMethodNameVariants(name)) {
+ Module::LookupInfo variant_lookup(name, name_type_mask,
+ lang->GetLanguageType());
+ variant_lookup.SetLookupName(variant_name);
+ m_lookups.emplace_back(variant_lookup);
}
+ return true;
+ };
+
+ if (Language *lang = Language::FindPlugin(m_language)) {
+ add_variant_funcs(lang);
} else {
- Module::LookupInfo lookup(name, name_type_mask, m_language);
- m_lookups.push_back(lookup);
+ // Most likely m_language is eLanguageTypeUnknown. We check each language for
+ // possible variants or more qualified names and create lookups for those as
+ // well.
+ Language::ForEach(add_variant_funcs);
}
}
diff --git a/source/Breakpoint/BreakpointResolverScripted.cpp b/source/Breakpoint/BreakpointResolverScripted.cpp
index 47940ef607036..8363795a4d7f4 100644
--- a/source/Breakpoint/BreakpointResolverScripted.cpp
+++ b/source/Breakpoint/BreakpointResolverScripted.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointResolverScripted.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// BreakpointResolverScripted:
-//----------------------------------------------------------------------
BreakpointResolverScripted::BreakpointResolverScripted(
Breakpoint *bkpt,
const llvm::StringRef class_name,
@@ -49,7 +46,6 @@ void BreakpointResolverScripted::CreateImplementationIfNeeded() {
if (m_breakpoint) {
TargetSP target_sp = m_breakpoint->GetTargetSP();
ScriptInterpreter *script_interp = target_sp->GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (!script_interp)
return;
@@ -108,7 +104,6 @@ BreakpointResolverScripted::CreateFromStructuredData(
}
ScriptInterpreter *script_interp = bkpt->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
return new BreakpointResolverScripted(bkpt, class_name, depth, args_data_impl,
*script_interp);
@@ -125,15 +120,14 @@ BreakpointResolverScripted::SerializeToStructuredData() {
}
ScriptInterpreter *BreakpointResolverScripted::GetScriptInterpreter() {
- return m_breakpoint->GetTarget().GetDebugger().GetCommandInterpreter()
- .GetScriptInterpreter();
+ return m_breakpoint->GetTarget().GetDebugger().GetScriptInterpreter();
}
Searcher::CallbackReturn
BreakpointResolverScripted::SearchCallback(SearchFilter &filter,
SymbolContext &context, Address *addr,
bool containing) {
- assert(m_breakpoint != NULL);
+ assert(m_breakpoint != nullptr);
bool should_continue = true;
if (!m_implementation_sp)
return Searcher::eCallbackReturnStop;
@@ -150,7 +144,7 @@ BreakpointResolverScripted::SearchCallback(SearchFilter &filter,
lldb::SearchDepth
BreakpointResolverScripted::GetDepth() {
- assert(m_breakpoint != NULL);
+ assert(m_breakpoint != nullptr);
lldb::SearchDepth depth = lldb::eSearchDepthModule;
if (m_implementation_sp) {
ScriptInterpreter *interp = GetScriptInterpreter();
diff --git a/source/Breakpoint/BreakpointSite.cpp b/source/Breakpoint/BreakpointSite.cpp
index 73c1357ce9639..a757a01824c76 100644
--- a/source/Breakpoint/BreakpointSite.cpp
+++ b/source/Breakpoint/BreakpointSite.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointSite.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -49,9 +48,17 @@ break_id_t BreakpointSite::GetNextID() {
// should continue.
bool BreakpointSite::ShouldStop(StoppointCallbackContext *context) {
- std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
IncrementHitCount();
- return m_owners.ShouldStop(context);
+ // ShouldStop can do a lot of work, and might even come come back and hit
+ // this breakpoint site again. So don't hold the m_owners_mutex the whole
+ // while. Instead make a local copy of the collection and call ShouldStop on
+ // the copy.
+ BreakpointLocationCollection owners_copy;
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
+ owners_copy = m_owners;
+ }
+ return owners_copy.ShouldStop(context);
}
bool BreakpointSite::IsBreakpointAtThisSite(lldb::break_id_t bp_id) {
diff --git a/source/Breakpoint/BreakpointSiteList.cpp b/source/Breakpoint/BreakpointSiteList.cpp
index 2fe107ee3e301..7a986fd83983f 100644
--- a/source/Breakpoint/BreakpointSiteList.cpp
+++ b/source/Breakpoint/BreakpointSiteList.cpp
@@ -1,9 +1,8 @@
//===-- BreakpointSiteList.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -86,7 +85,7 @@ public:
BreakpointSiteIDMatches(lldb::break_id_t break_id) : m_break_id(break_id) {}
bool operator()(std::pair<lldb::addr_t, BreakpointSiteSP> val_pair) const {
- return m_break_id == val_pair.second.get()->GetID();
+ return m_break_id == val_pair.second->GetID();
}
private:
@@ -158,7 +157,7 @@ void BreakpointSiteList::Dump(Stream *s) const {
collection::const_iterator pos;
collection::const_iterator end = m_bp_site_list.end();
for (pos = m_bp_site_list.begin(); pos != end; ++pos)
- pos->second.get()->Dump(s);
+ pos->second->Dump(s);
s->IndentLess();
}
diff --git a/source/Breakpoint/Stoppoint.cpp b/source/Breakpoint/Stoppoint.cpp
index 13a8b837469f4..4cab975fe320c 100644
--- a/source/Breakpoint/Stoppoint.cpp
+++ b/source/Breakpoint/Stoppoint.cpp
@@ -1,9 +1,8 @@
//===-- Stoppoint.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,14 +13,10 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Stoppoint constructor
-//----------------------------------------------------------------------
Stoppoint::Stoppoint() : m_bid(LLDB_INVALID_BREAK_ID) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Stoppoint::~Stoppoint() {}
break_id_t Stoppoint::GetID() const { return m_bid; }
diff --git a/source/Breakpoint/StoppointCallbackContext.cpp b/source/Breakpoint/StoppointCallbackContext.cpp
index 828ff18c433fd..584bf0060a4a5 100644
--- a/source/Breakpoint/StoppointCallbackContext.cpp
+++ b/source/Breakpoint/StoppointCallbackContext.cpp
@@ -1,9 +1,8 @@
//===-- StoppointCallbackContext.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Breakpoint/StoppointLocation.cpp b/source/Breakpoint/StoppointLocation.cpp
index 73394668508bb..8cc6791fa6808 100644
--- a/source/Breakpoint/StoppointLocation.cpp
+++ b/source/Breakpoint/StoppointLocation.cpp
@@ -1,9 +1,8 @@
//===-- StoppointLocation.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// StoppointLocation constructor
-//----------------------------------------------------------------------
StoppointLocation::StoppointLocation(break_id_t bid, addr_t addr, bool hardware)
: m_loc_id(bid), m_addr(addr), m_hardware(hardware),
m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(0), m_hit_count(0) {}
@@ -26,9 +23,7 @@ StoppointLocation::StoppointLocation(break_id_t bid, addr_t addr,
m_hardware_index(LLDB_INVALID_INDEX32), m_byte_size(byte_size),
m_hit_count(0) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
StoppointLocation::~StoppointLocation() {}
void StoppointLocation::DecrementHitCount() {
diff --git a/source/Breakpoint/Watchpoint.cpp b/source/Breakpoint/Watchpoint.cpp
index 34daaee64ccd5..e8a926527d24b 100644
--- a/source/Breakpoint/Watchpoint.cpp
+++ b/source/Breakpoint/Watchpoint.cpp
@@ -1,9 +1,8 @@
//===-- Watchpoint.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -273,25 +272,26 @@ bool Watchpoint::InvokeCallback(StoppointCallbackContext *context) {
void Watchpoint::SetCondition(const char *condition) {
if (condition == nullptr || condition[0] == '\0') {
- if (m_condition_ap.get())
- m_condition_ap.reset();
+ if (m_condition_up)
+ m_condition_up.reset();
} else {
// Pass nullptr for expr_prefix (no translation-unit level definitions).
Status error;
- m_condition_ap.reset(m_target.GetUserExpressionForLanguage(
+ m_condition_up.reset(m_target.GetUserExpressionForLanguage(
condition, llvm::StringRef(), lldb::eLanguageTypeUnknown,
- UserExpression::eResultTypeAny, EvaluateExpressionOptions(), error));
+ UserExpression::eResultTypeAny, EvaluateExpressionOptions(), nullptr,
+ error));
if (error.Fail()) {
// FIXME: Log something...
- m_condition_ap.reset();
+ m_condition_up.reset();
}
}
SendWatchpointChangedEvent(eWatchpointEventTypeConditionChanged);
}
const char *Watchpoint::GetConditionText() const {
- if (m_condition_ap.get())
- return m_condition_ap->GetUserText();
+ if (m_condition_up)
+ return m_condition_up->GetUserText();
else
return nullptr;
}
@@ -325,12 +325,12 @@ Watchpoint::WatchpointEventData::WatchpointEventData(
Watchpoint::WatchpointEventData::~WatchpointEventData() = default;
-const ConstString &Watchpoint::WatchpointEventData::GetFlavorString() {
+ConstString Watchpoint::WatchpointEventData::GetFlavorString() {
static ConstString g_flavor("Watchpoint::WatchpointEventData");
return g_flavor;
}
-const ConstString &Watchpoint::WatchpointEventData::GetFlavor() const {
+ConstString Watchpoint::WatchpointEventData::GetFlavor() const {
return WatchpointEventData::GetFlavorString();
}
diff --git a/source/Breakpoint/WatchpointList.cpp b/source/Breakpoint/WatchpointList.cpp
index e1e2864ba0eb9..b1c1e6f253ebe 100644
--- a/source/Breakpoint/WatchpointList.cpp
+++ b/source/Breakpoint/WatchpointList.cpp
@@ -1,9 +1,8 @@
//===-- WatchpointList.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Breakpoint/WatchpointOptions.cpp b/source/Breakpoint/WatchpointOptions.cpp
index 033eb66014b93..7dd130a3072c7 100644
--- a/source/Breakpoint/WatchpointOptions.cpp
+++ b/source/Breakpoint/WatchpointOptions.cpp
@@ -1,9 +1,8 @@
//===-- WatchpointOptions.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,34 +25,28 @@ bool WatchpointOptions::NullCallback(void *baton,
return true;
}
-//----------------------------------------------------------------------
// WatchpointOptions constructor
-//----------------------------------------------------------------------
WatchpointOptions::WatchpointOptions()
: m_callback(WatchpointOptions::NullCallback), m_callback_baton_sp(),
- m_callback_is_synchronous(false), m_thread_spec_ap() {}
+ m_callback_is_synchronous(false), m_thread_spec_up() {}
-//----------------------------------------------------------------------
// WatchpointOptions copy constructor
-//----------------------------------------------------------------------
WatchpointOptions::WatchpointOptions(const WatchpointOptions &rhs)
: m_callback(rhs.m_callback), m_callback_baton_sp(rhs.m_callback_baton_sp),
m_callback_is_synchronous(rhs.m_callback_is_synchronous),
- m_thread_spec_ap() {
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ m_thread_spec_up() {
+ if (rhs.m_thread_spec_up != nullptr)
+ m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
}
-//----------------------------------------------------------------------
// WatchpointOptions assignment operator
-//----------------------------------------------------------------------
const WatchpointOptions &WatchpointOptions::
operator=(const WatchpointOptions &rhs) {
m_callback = rhs.m_callback;
m_callback_baton_sp = rhs.m_callback_baton_sp;
m_callback_is_synchronous = rhs.m_callback_is_synchronous;
- if (rhs.m_thread_spec_ap.get() != nullptr)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ if (rhs.m_thread_spec_up != nullptr)
+ m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
return *this;
}
@@ -71,14 +64,10 @@ WatchpointOptions::CopyOptionsNoCallback(WatchpointOptions &orig) {
return ret_val;
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
WatchpointOptions::~WatchpointOptions() = default;
-//------------------------------------------------------------------
// Callbacks
-//------------------------------------------------------------------
void WatchpointOptions::SetCallback(WatchpointHitCallback callback,
const BatonSP &callback_baton_sp,
bool callback_is_synchronous) {
@@ -114,14 +103,14 @@ bool WatchpointOptions::HasCallback() {
}
const ThreadSpec *WatchpointOptions::GetThreadSpecNoCreate() const {
- return m_thread_spec_ap.get();
+ return m_thread_spec_up.get();
}
ThreadSpec *WatchpointOptions::GetThreadSpec() {
- if (m_thread_spec_ap.get() == nullptr)
- m_thread_spec_ap.reset(new ThreadSpec());
+ if (m_thread_spec_up == nullptr)
+ m_thread_spec_up.reset(new ThreadSpec());
- return m_thread_spec_ap.get();
+ return m_thread_spec_up.get();
}
void WatchpointOptions::SetThreadID(lldb::tid_t thread_id) {
@@ -153,8 +142,8 @@ void WatchpointOptions::GetDescription(Stream *s,
} else
s->PutCString(" Options: ");
- if (m_thread_spec_ap.get())
- m_thread_spec_ap->GetDescription(s, level);
+ if (m_thread_spec_up)
+ m_thread_spec_up->GetDescription(s, level);
else if (level == eDescriptionLevelBrief)
s->PutCString("thread spec: no ");
if (level == lldb::eDescriptionLevelFull) {
diff --git a/source/Commands/CommandCompletions.cpp b/source/Commands/CommandCompletions.cpp
index 705e87651a8ca..5d2fb3d67f575 100644
--- a/source/Commands/CommandCompletions.cpp
+++ b/source/Commands/CommandCompletions.cpp
@@ -1,9 +1,8 @@
//===-- CommandCompletions.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -350,9 +349,7 @@ CommandCompletions::Completer::Completer(CommandInterpreter &interpreter,
CommandCompletions::Completer::~Completer() = default;
-//----------------------------------------------------------------------
// SourceFileCompleter
-//----------------------------------------------------------------------
CommandCompletions::SourceFileCompleter::SourceFileCompleter(
CommandInterpreter &interpreter, bool include_support_files,
@@ -425,9 +422,7 @@ CommandCompletions::SourceFileCompleter::DoCompletion(SearchFilter *filter) {
return m_request.GetNumberOfMatches();
}
-//----------------------------------------------------------------------
// SymbolCompleter
-//----------------------------------------------------------------------
static bool regex_chars(const char comp) {
return (comp == '[' || comp == ']' || comp == '(' || comp == ')' ||
@@ -493,9 +488,7 @@ size_t CommandCompletions::SymbolCompleter::DoCompletion(SearchFilter *filter) {
return m_request.GetNumberOfMatches();
}
-//----------------------------------------------------------------------
// ModuleCompleter
-//----------------------------------------------------------------------
CommandCompletions::ModuleCompleter::ModuleCompleter(
CommandInterpreter &interpreter, CompletionRequest &request)
: CommandCompletions::Completer(interpreter, request) {
diff --git a/source/Commands/CommandObjectApropos.cpp b/source/Commands/CommandObjectApropos.cpp
index 69c2760ded4e7..957de475569cb 100644
--- a/source/Commands/CommandObjectApropos.cpp
+++ b/source/Commands/CommandObjectApropos.cpp
@@ -1,10 +1,9 @@
//===-- CommandObjectApropos.cpp ---------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectApropos
-//-------------------------------------------------------------------------
CommandObjectApropos::CommandObjectApropos(CommandInterpreter &interpreter)
: CommandObjectParsed(
@@ -83,7 +80,7 @@ bool CommandObjectApropos::DoExecute(Args &args, CommandReturnObject &result) {
std::vector<const Property *> properties;
const size_t num_properties =
- m_interpreter.GetDebugger().Apropos(search_word, properties);
+ GetDebugger().Apropos(search_word, properties);
if (num_properties) {
const bool dump_qualified_name = true;
result.AppendMessageWithFormatv(
diff --git a/source/Commands/CommandObjectApropos.h b/source/Commands/CommandObjectApropos.h
index acd4cedfe9fdc..37d86b17d1a26 100644
--- a/source/Commands/CommandObjectApropos.h
+++ b/source/Commands/CommandObjectApropos.h
@@ -1,10 +1,9 @@
//===-- CommandObjectApropos.h -----------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectApropos
-//-------------------------------------------------------------------------
class CommandObjectApropos : public CommandObjectParsed {
public:
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 8eb6a5fa5a026..c33f3834cb13b 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -1,14 +1,11 @@
//===-- CommandObjectBreakpoint.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <vector>
-
#include "CommandObjectBreakpoint.h"
#include "CommandObjectBreakpointCommand.h"
#include "lldb/Breakpoint/Breakpoint.h"
@@ -31,6 +28,9 @@
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/StreamString.h"
+#include <memory>
+#include <vector>
+
using namespace lldb;
using namespace lldb_private;
@@ -42,9 +42,7 @@ static void AddBreakpointDescription(Stream *s, Breakpoint *bp,
s->EOL();
}
-//-------------------------------------------------------------------------
// Modifiable Breakpoint Options
-//-------------------------------------------------------------------------
#pragma mark Modify::CommandOptions
static constexpr OptionDefinition g_breakpoint_modify_options[] = {
// clang-format off
@@ -322,13 +320,11 @@ static constexpr OptionDefinition g_breakpoint_set_options[] = {
// clang-format on
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointSet
-//-------------------------------------------------------------------------
class CommandObjectBreakpointSet : public CommandObjectParsed {
public:
- typedef enum BreakpointSetType {
+ enum BreakpointSetType {
eSetTypeInvalid,
eSetTypeFileAndLine,
eSetTypeAddress,
@@ -337,7 +333,7 @@ public:
eSetTypeSourceRegexp,
eSetTypeException,
eSetTypeScripted,
- } BreakpointSetType;
+ };
CommandObjectBreakpointSet(CommandInterpreter &interpreter)
: CommandObjectParsed(
@@ -616,7 +612,7 @@ public:
m_move_to_nearest_code = eLazyBoolCalculate;
m_source_regex_func_names.clear();
m_python_class.clear();
- m_extra_args_sp.reset(new StructuredData::Dictionary());
+ m_extra_args_sp = std::make_shared<StructuredData::Dictionary>();
m_current_key.clear();
}
@@ -901,7 +897,7 @@ protected:
const bool show_locations = false;
bp_sp->GetDescription(&output_stream, lldb::eDescriptionLevelInitial,
show_locations);
- if (target == m_interpreter.GetDebugger().GetDummyTarget())
+ if (target == GetDebugger().GetDummyTarget())
output_stream.Printf("Breakpoint set in dummy target, will get copied "
"into future targets.\n");
else {
@@ -962,9 +958,7 @@ private:
OptionGroupOptions m_all_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointModify
-//-------------------------------------------------------------------------
#pragma mark Modify
class CommandObjectBreakpointModify : public CommandObjectParsed {
@@ -1046,9 +1040,7 @@ private:
OptionGroupOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointEnable
-//-------------------------------------------------------------------------
#pragma mark Enable
class CommandObjectBreakpointEnable : public CommandObjectParsed {
@@ -1137,9 +1129,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointDisable
-//-------------------------------------------------------------------------
#pragma mark Disable
class CommandObjectBreakpointDisable : public CommandObjectParsed {
@@ -1252,21 +1242,14 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointList
-//-------------------------------------------------------------------------
#pragma mark List::CommandOptions
static constexpr OptionDefinition g_breakpoint_list_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "internal", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Show debugger internal breakpoints" },
- { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a brief description of the breakpoint (no location info)." },
- // FIXME: We need to add an "internal" command, and then add this sort of thing to it.
- // But I need to see it for now, and don't want to wait.
- { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a full description of the breakpoint and its locations." },
- { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Explain everything we know about the breakpoint (for debugging debugger bugs)." },
- { LLDB_OPT_SET_ALL, false, "dummy-breakpoints", 'D', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "List Dummy breakpoints - i.e. breakpoints set before a file is provided, which prime new targets." },
- // clang-format on
+ // FIXME: We need to add an "internal" command, and then add this sort of
+ // thing to it. But I need to see it for now, and don't want to wait.
+#define LLDB_OPTIONS_breakpoint_list
+#include "CommandOptions.inc"
};
#pragma mark List
@@ -1418,9 +1401,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointClear
-//-------------------------------------------------------------------------
#pragma mark Clear::CommandOptions
static constexpr OptionDefinition g_breakpoint_clear_options[] = {
@@ -1434,10 +1415,7 @@ static constexpr OptionDefinition g_breakpoint_clear_options[] = {
class CommandObjectBreakpointClear : public CommandObjectParsed {
public:
- typedef enum BreakpointClearType {
- eClearTypeInvalid,
- eClearTypeFileAndLine
- } BreakpointClearType;
+ enum BreakpointClearType { eClearTypeInvalid, eClearTypeFileAndLine };
CommandObjectBreakpointClear(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "breakpoint clear",
@@ -1578,9 +1556,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointDelete
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_breakpoint_delete_options[] = {
// clang-format off
{ LLDB_OPT_SET_1, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete all breakpoints without querying for confirmation." },
@@ -1734,9 +1710,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointName
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_breakpoint_name_options[] = {
// clang-format off
@@ -2245,9 +2219,7 @@ private:
OptionGroupOptions m_option_group;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointName
-//-------------------------------------------------------------------------
class CommandObjectBreakpointName : public CommandObjectMultiword {
public:
CommandObjectBreakpointName(CommandInterpreter &interpreter)
@@ -2272,9 +2244,7 @@ public:
~CommandObjectBreakpointName() override = default;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointRead
-//-------------------------------------------------------------------------
#pragma mark Read::CommandOptions
static constexpr OptionDefinition g_breakpoint_read_options[] = {
// clang-format off
@@ -2403,9 +2373,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointWrite
-//-------------------------------------------------------------------------
#pragma mark Write::CommandOptions
static constexpr OptionDefinition g_breakpoint_write_options[] = {
// clang-format off
@@ -2517,9 +2485,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectMultiwordBreakpoint
-//-------------------------------------------------------------------------
#pragma mark MultiwordBreakpoint
CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint(
diff --git a/source/Commands/CommandObjectBreakpoint.h b/source/Commands/CommandObjectBreakpoint.h
index d0026f90e30c2..cba1f3f774eee 100644
--- a/source/Commands/CommandObjectBreakpoint.h
+++ b/source/Commands/CommandObjectBreakpoint.h
@@ -1,9 +1,8 @@
//===-- CommandObjectBreakpoint.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordBreakpoint
-//-------------------------------------------------------------------------
class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp
index 991b174980e19..3f9d83cd86a8d 100644
--- a/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectBreakpointCommand.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,9 +26,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectBreakpointCommandAdd
-//-------------------------------------------------------------------------
// FIXME: "script-type" needs to have its contents determined dynamically, so
// somebody can add a new scripting
@@ -223,9 +220,9 @@ are no syntax errors may indicate that a function was declared but never called.
Options *GetOptions() override { return &m_options; }
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(g_reader_instructions);
output_sp->Flush();
}
@@ -425,7 +422,7 @@ protected:
// to set or collect command callback. Otherwise, call the methods
// associated with this object.
if (m_options.m_use_script_language) {
- ScriptInterpreter *script_interp = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter();
// Special handling for one-liner specified inline.
if (m_options.m_use_one_liner) {
script_interp->SetBreakpointCommandCallback(
@@ -470,9 +467,7 @@ private:
const char *CommandObjectBreakpointCommandAdd::g_reader_instructions =
"Enter your debugger command(s). Type 'DONE' to end.\n";
-//-------------------------------------------------------------------------
// CommandObjectBreakpointCommandDelete
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_breakpoint_delete_options[] = {
// clang-format off
@@ -607,9 +602,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointCommandList
-//-------------------------------------------------------------------------
class CommandObjectBreakpointCommandList : public CommandObjectParsed {
public:
@@ -637,7 +630,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -727,9 +720,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectBreakpointCommand
-//-------------------------------------------------------------------------
CommandObjectBreakpointCommand::CommandObjectBreakpointCommand(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectBreakpointCommand.h b/source/Commands/CommandObjectBreakpointCommand.h
index 96d2121382826..b18e003368bed 100644
--- a/source/Commands/CommandObjectBreakpointCommand.h
+++ b/source/Commands/CommandObjectBreakpointCommand.h
@@ -1,9 +1,8 @@
//===-- CommandObjectBreakpointCommand.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordBreakpoint
-//-------------------------------------------------------------------------
class CommandObjectBreakpointCommand : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectBugreport.cpp b/source/Commands/CommandObjectBugreport.cpp
index dc4b9ef302c0f..515cc9a113b16 100644
--- a/source/Commands/CommandObjectBugreport.cpp
+++ b/source/Commands/CommandObjectBugreport.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectBugreport.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// "bugreport unwind"
-//-------------------------------------------------------------------------
class CommandObjectBugreportUnwind : public CommandObjectParsed {
public:
@@ -97,6 +94,7 @@ protected:
options.SetStopOnError(false);
options.SetEchoCommands(true);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetAddToHistory(false);
m_interpreter.HandleCommands(commands, &m_exe_ctx, options, result);
@@ -110,9 +108,7 @@ private:
#pragma mark CommandObjectMultiwordBugreport
-//-------------------------------------------------------------------------
// CommandObjectMultiwordBugreport
-//-------------------------------------------------------------------------
CommandObjectMultiwordBugreport::CommandObjectMultiwordBugreport(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectBugreport.h b/source/Commands/CommandObjectBugreport.h
index 1d9aea59925a5..24ce6d237d56d 100644
--- a/source/Commands/CommandObjectBugreport.h
+++ b/source/Commands/CommandObjectBugreport.h
@@ -1,9 +1,8 @@
//===-- CommandObjectBugreport.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordBugreport
-//-------------------------------------------------------------------------
class CommandObjectMultiwordBugreport : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp
index 01e1c4269bba7..4092e76be6ac8 100644
--- a/source/Commands/CommandObjectCommands.cpp
+++ b/source/Commands/CommandObjectCommands.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectCommands.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,9 +29,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectCommandsSource
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_history_options[] = {
// clang-format off
@@ -189,9 +186,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsSource
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_source_options[] = {
// clang-format off
@@ -314,14 +309,20 @@ protected:
m_options.m_stop_on_continue.OptionWasSet()) {
// Use user set settings
CommandInterpreterRunOptions options;
- options.SetStopOnContinue(m_options.m_stop_on_continue.GetCurrentValue());
- options.SetStopOnError(m_options.m_stop_on_error.GetCurrentValue());
+
+ if (m_options.m_stop_on_continue.OptionWasSet())
+ options.SetStopOnContinue(
+ m_options.m_stop_on_continue.GetCurrentValue());
+
+ if (m_options.m_stop_on_error.OptionWasSet())
+ options.SetStopOnError(m_options.m_stop_on_error.GetCurrentValue());
// Individual silent setting is override for global command echo settings.
if (m_options.m_silent_run.GetCurrentValue()) {
options.SetSilent(true);
} else {
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetEchoCommands(m_interpreter.GetEchoCommands());
options.SetEchoCommentCommands(m_interpreter.GetEchoCommentCommands());
}
@@ -340,9 +341,7 @@ protected:
};
#pragma mark CommandObjectCommandsAlias
-//-------------------------------------------------------------------------
// CommandObjectCommandsAlias
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_alias_options[] = {
// clang-format off
@@ -766,9 +765,7 @@ protected:
};
#pragma mark CommandObjectCommandsUnalias
-//-------------------------------------------------------------------------
// CommandObjectCommandsUnalias
-//-------------------------------------------------------------------------
class CommandObjectCommandsUnalias : public CommandObjectParsed {
public:
@@ -849,9 +846,7 @@ protected:
};
#pragma mark CommandObjectCommandsDelete
-//-------------------------------------------------------------------------
// CommandObjectCommandsDelete
-//-------------------------------------------------------------------------
class CommandObjectCommandsDelete : public CommandObjectParsed {
public:
@@ -891,11 +886,11 @@ protected:
auto command_name = args[0].ref;
if (!m_interpreter.CommandExists(command_name)) {
StreamString error_msg_stream;
- const bool generate_apropos = true;
+ const bool generate_upropos = true;
const bool generate_type_lookup = false;
CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(
&error_msg_stream, command_name, llvm::StringRef(), llvm::StringRef(),
- generate_apropos, generate_type_lookup);
+ generate_upropos, generate_type_lookup);
result.AppendError(error_msg_stream.GetString());
result.SetStatus(eReturnStatusFailed);
return false;
@@ -914,9 +909,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsAddRegex
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_regex_options[] = {
// clang-format off
@@ -976,10 +969,10 @@ a number follows 'f':"
~CommandObjectCommandsAddRegex() override = default;
protected:
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
- output_sp->PutCString("Enter one of more sed substitution commands in "
+ if (output_sp && interactive) {
+ output_sp->PutCString("Enter one or more sed substitution commands in "
"the form: 's/<regex>/<subst>/'.\nTerminate the "
"substitution list with an empty line.\n");
output_sp->Flush();
@@ -989,7 +982,7 @@ protected:
void IOHandlerInputComplete(IOHandler &io_handler,
std::string &data) override {
io_handler.SetIsDone(true);
- if (m_regex_cmd_ap) {
+ if (m_regex_cmd_up) {
StringList lines;
if (lines.SplitIntoLines(data)) {
const size_t num_lines = lines.GetSize();
@@ -998,18 +991,15 @@ protected:
llvm::StringRef bytes_strref(lines[i]);
Status error = AppendRegexSubstitution(bytes_strref, check_only);
if (error.Fail()) {
- if (!m_interpreter.GetDebugger()
- .GetCommandInterpreter()
- .GetBatchCommandMode()) {
- StreamSP out_stream =
- m_interpreter.GetDebugger().GetAsyncOutputStream();
+ if (!GetDebugger().GetCommandInterpreter().GetBatchCommandMode()) {
+ StreamSP out_stream = GetDebugger().GetAsyncOutputStream();
out_stream->Printf("error: %s\n", error.AsCString());
}
}
}
}
- if (m_regex_cmd_ap->HasRegexEntries()) {
- CommandObjectSP cmd_sp(m_regex_cmd_ap.release());
+ if (m_regex_cmd_up->HasRegexEntries()) {
+ CommandObjectSP cmd_sp(m_regex_cmd_up.release());
m_interpreter.AddCommand(cmd_sp->GetCommandName(), cmd_sp, true);
}
}
@@ -1026,12 +1016,12 @@ protected:
Status error;
auto name = command[0].ref;
- m_regex_cmd_ap = llvm::make_unique<CommandObjectRegexCommand>(
+ m_regex_cmd_up = llvm::make_unique<CommandObjectRegexCommand>(
m_interpreter, name, m_options.GetHelp(), m_options.GetSyntax(), 10, 0,
true);
if (argc == 1) {
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = GetDebugger();
bool color_prompt = debugger.GetUseColor();
const bool multiple_lines = true; // Get multiple lines
IOHandlerSP io_handler_sp(new IOHandlerEditline(
@@ -1041,7 +1031,7 @@ protected:
llvm::StringRef(), // Continuation prompt
multiple_lines, color_prompt,
0, // Don't show line numbers
- *this));
+ *this, nullptr));
if (io_handler_sp) {
debugger.PushIOHandler(io_handler_sp);
@@ -1071,7 +1061,7 @@ protected:
bool check_only) {
Status error;
- if (!m_regex_cmd_ap) {
+ if (!m_regex_cmd_up) {
error.SetErrorStringWithFormat(
"invalid regular expression command object for: '%.*s'",
(int)regex_sed.size(), regex_sed.data());
@@ -1157,22 +1147,22 @@ protected:
std::string subst(regex_sed.substr(second_separator_char_pos + 1,
third_separator_char_pos -
second_separator_char_pos - 1));
- m_regex_cmd_ap->AddRegexCommand(regex.c_str(), subst.c_str());
+ m_regex_cmd_up->AddRegexCommand(regex.c_str(), subst.c_str());
}
return error;
}
void AddRegexCommandToInterpreter() {
- if (m_regex_cmd_ap) {
- if (m_regex_cmd_ap->HasRegexEntries()) {
- CommandObjectSP cmd_sp(m_regex_cmd_ap.release());
+ if (m_regex_cmd_up) {
+ if (m_regex_cmd_up->HasRegexEntries()) {
+ CommandObjectSP cmd_sp(m_regex_cmd_up.release());
m_interpreter.AddCommand(cmd_sp->GetCommandName(), cmd_sp, true);
}
}
}
private:
- std::unique_ptr<CommandObjectRegexCommand> m_regex_cmd_ap;
+ std::unique_ptr<CommandObjectRegexCommand> m_regex_cmd_up;
class CommandOptions : public Options {
public:
@@ -1259,7 +1249,7 @@ public:
if (m_fetched_help_long)
return CommandObjectRaw::GetHelpLong();
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
if (!scripter)
return CommandObjectRaw::GetHelpLong();
@@ -1274,7 +1264,7 @@ public:
protected:
bool DoExecute(llvm::StringRef raw_command_line,
CommandReturnObject &result) override {
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
Status error;
@@ -1317,7 +1307,7 @@ public:
StreamString stream;
stream.Printf("For more information run 'help %s'", name.c_str());
SetHelp(stream.GetString());
- if (ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter())
+ if (ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter())
GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp));
}
@@ -1332,7 +1322,7 @@ public:
llvm::StringRef GetHelp() override {
if (m_fetched_help_short)
return CommandObjectRaw::GetHelp();
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
if (!scripter)
return CommandObjectRaw::GetHelp();
std::string docstring;
@@ -1348,7 +1338,7 @@ public:
if (m_fetched_help_long)
return CommandObjectRaw::GetHelpLong();
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
if (!scripter)
return CommandObjectRaw::GetHelpLong();
@@ -1363,7 +1353,7 @@ public:
protected:
bool DoExecute(llvm::StringRef raw_command_line,
CommandReturnObject &result) override {
- ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *scripter = GetDebugger().GetScriptInterpreter();
Status error;
@@ -1394,9 +1384,7 @@ private:
bool m_fetched_help_long : 1;
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsScriptImport
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_script_import_options[] = {
// clang-format off
@@ -1477,8 +1465,7 @@ protected:
};
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (m_interpreter.GetDebugger().GetScriptLanguage() !=
- lldb::eScriptLanguagePython) {
+ if (GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) {
result.AppendError("only scripting language supported for module "
"importing is currently Python");
result.SetStatus(eReturnStatusFailed);
@@ -1504,7 +1491,7 @@ protected:
// won't stomp on each other (wrt to execution contents, options, and
// more)
m_exe_ctx.Clear();
- if (m_interpreter.GetScriptInterpreter()->LoadScriptingModule(
+ if (GetDebugger().GetScriptInterpreter()->LoadScriptingModule(
entry.c_str(), m_options.m_allow_reload, init_session, error)) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
@@ -1520,9 +1507,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsScriptAdd
-//-------------------------------------------------------------------------
static constexpr OptionEnumValueElement g_script_synchro_type[] = {
{eScriptedCommandSynchronicitySynchronous, "synchronous",
"Run synchronous"},
@@ -1635,9 +1620,9 @@ protected:
ScriptedCommandSynchronicity m_synchronicity;
};
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(g_python_command_instructions);
output_sp->Flush();
}
@@ -1647,7 +1632,7 @@ protected:
std::string &data) override {
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
StringList lines;
@@ -1693,8 +1678,7 @@ protected:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- if (m_interpreter.GetDebugger().GetScriptLanguage() !=
- lldb::eScriptLanguagePython) {
+ if (GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) {
result.AppendError("only scripting language supported for scripted "
"commands is currently Python");
result.SetStatus(eReturnStatusFailed);
@@ -1732,8 +1716,7 @@ protected:
}
}
} else {
- ScriptInterpreter *interpreter =
- GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (!interpreter) {
result.AppendError("cannot find ScriptInterpreter");
result.SetStatus(eReturnStatusFailed);
@@ -1767,9 +1750,7 @@ protected:
ScriptedCommandSynchronicity m_synchronicity;
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsScriptList
-//-------------------------------------------------------------------------
class CommandObjectCommandsScriptList : public CommandObjectParsed {
public:
@@ -1788,9 +1769,7 @@ public:
}
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsScriptClear
-//-------------------------------------------------------------------------
class CommandObjectCommandsScriptClear : public CommandObjectParsed {
public:
@@ -1810,9 +1789,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectCommandsScriptDelete
-//-------------------------------------------------------------------------
class CommandObjectCommandsScriptDelete : public CommandObjectParsed {
public:
@@ -1862,9 +1839,7 @@ protected:
#pragma mark CommandObjectMultiwordCommandsScript
-//-------------------------------------------------------------------------
// CommandObjectMultiwordCommandsScript
-//-------------------------------------------------------------------------
class CommandObjectMultiwordCommandsScript : public CommandObjectMultiword {
public:
@@ -1894,9 +1869,7 @@ public:
#pragma mark CommandObjectMultiwordCommands
-//-------------------------------------------------------------------------
// CommandObjectMultiwordCommands
-//-------------------------------------------------------------------------
CommandObjectMultiwordCommands::CommandObjectMultiwordCommands(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectCommands.h b/source/Commands/CommandObjectCommands.h
index 57ae8f27efecb..468ee53344f17 100644
--- a/source/Commands/CommandObjectCommands.h
+++ b/source/Commands/CommandObjectCommands.h
@@ -1,10 +1,9 @@
//===-- CommandObjectCommands.h -----------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordCommands
-//-------------------------------------------------------------------------
class CommandObjectMultiwordCommands : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index f8ee461218517..5972555b2499d 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectDisassemble.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -230,9 +229,7 @@ CommandObjectDisassemble::CommandOptions::GetDefinitions() {
return llvm::makeArrayRef(g_disassemble_options);
}
-//-------------------------------------------------------------------------
// CommandObjectDisassemble
-//-------------------------------------------------------------------------
CommandObjectDisassemble::CommandObjectDisassemble(
CommandInterpreter &interpreter)
@@ -248,7 +245,7 @@ CommandObjectDisassemble::~CommandObjectDisassemble() = default;
bool CommandObjectDisassemble::DoExecute(Args &command,
CommandReturnObject &result) {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -323,8 +320,8 @@ bool CommandObjectDisassemble::DoExecute(Args &command,
ConstString name(m_options.func_name.c_str());
if (Disassembler::Disassemble(
- m_interpreter.GetDebugger(), m_options.arch, plugin_name,
- flavor_string, m_exe_ctx, name,
+ GetDebugger(), m_options.arch, plugin_name, flavor_string,
+ m_exe_ctx, name,
nullptr, // Module *
m_options.num_instructions, m_options.show_mixed,
m_options.show_mixed ? m_options.num_lines_context : 0, options,
@@ -487,8 +484,8 @@ bool CommandObjectDisassemble::DoExecute(Args &command,
bool print_sc_header = ranges.size() > 1;
for (AddressRange cur_range : ranges) {
if (Disassembler::Disassemble(
- m_interpreter.GetDebugger(), m_options.arch, plugin_name,
- flavor_string, m_exe_ctx, cur_range.GetBaseAddress(),
+ GetDebugger(), m_options.arch, plugin_name, flavor_string,
+ m_exe_ctx, cur_range.GetBaseAddress(),
m_options.num_instructions, m_options.show_mixed,
m_options.show_mixed ? m_options.num_lines_context : 0, options,
result.GetOutputStream())) {
@@ -535,8 +532,8 @@ bool CommandObjectDisassemble::DoExecute(Args &command,
cur_range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE);
if (Disassembler::Disassemble(
- m_interpreter.GetDebugger(), m_options.arch, plugin_name,
- flavor_string, m_exe_ctx, cur_range, m_options.num_instructions,
+ GetDebugger(), m_options.arch, plugin_name, flavor_string,
+ m_exe_ctx, cur_range, m_options.num_instructions,
m_options.show_mixed,
m_options.show_mixed ? m_options.num_lines_context : 0, options,
result.GetOutputStream())) {
diff --git a/source/Commands/CommandObjectDisassemble.h b/source/Commands/CommandObjectDisassemble.h
index 04c4cc247ee98..70193e914c7f6 100644
--- a/source/Commands/CommandObjectDisassemble.h
+++ b/source/Commands/CommandObjectDisassemble.h
@@ -1,9 +1,8 @@
//===-- CommandObjectDisassemble.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectDisassemble
-//-------------------------------------------------------------------------
class CommandObjectDisassemble : public CommandObjectParsed {
public:
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index e87d68a53da44..29e4ab6955225 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectExpression.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "llvm/ADT/StringRef.h"
#include "CommandObjectExpression.h"
-#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
@@ -235,7 +233,7 @@ Single and multi-line expressions:
with no newlines. To evaluate a multi-line expression, \
hit a return after an empty expression, and lldb will enter the multi-line expression editor. \
Hit return on an empty line to end the multi-line expression."
-
+
R"(
Timeouts:
@@ -364,7 +362,7 @@ int CommandObjectExpression::HandleCompletion(CompletionRequest &request) {
Status error;
lldb::UserExpressionSP expr(target->GetUserExpressionForLanguage(
code, llvm::StringRef(), language, UserExpression::eResultTypeAny,
- options, error));
+ options, nullptr, error));
if (error.Fail())
return 0;
@@ -483,8 +481,7 @@ bool CommandObjectExpression::EvaluateExpression(llvm::StringRef expr,
} else {
if (result_valobj_sp->GetError().GetError() ==
UserExpression::kNoResult) {
- if (format != eFormatVoid &&
- m_interpreter.GetDebugger().GetNotifyVoid()) {
+ if (format != eFormatVoid && GetDebugger().GetNotifyVoid()) {
error_stream->PutCString("(void)\n");
}
@@ -561,7 +558,7 @@ void CommandObjectExpression::GetMultilineExpression() {
llvm::StringRef(), // Continuation prompt
multiple_lines, color_prompt,
1, // Show line numbers starting at 1
- *this));
+ *this, nullptr));
StreamFileSP output_sp(io_handler_sp->GetOutputStreamFile());
if (output_sp) {
@@ -572,6 +569,29 @@ void CommandObjectExpression::GetMultilineExpression() {
debugger.PushIOHandler(io_handler_sp);
}
+static EvaluateExpressionOptions
+GetExprOptions(ExecutionContext &ctx,
+ CommandObjectExpression::CommandOptions command_options) {
+ command_options.OptionParsingStarting(&ctx);
+
+ // Default certain settings for REPL regardless of the global settings.
+ command_options.unwind_on_error = false;
+ command_options.ignore_breakpoints = false;
+ command_options.debug = false;
+
+ EvaluateExpressionOptions expr_options;
+ expr_options.SetUnwindOnError(command_options.unwind_on_error);
+ expr_options.SetIgnoreBreakpoints(command_options.ignore_breakpoints);
+ expr_options.SetTryAllThreads(command_options.try_all_threads);
+
+ if (command_options.timeout > 0)
+ expr_options.SetTimeout(std::chrono::microseconds(command_options.timeout));
+ else
+ expr_options.SetTimeout(llvm::None);
+
+ return expr_options;
+}
+
bool CommandObjectExpression::DoExecute(llvm::StringRef command,
CommandReturnObject &result) {
m_fixed_expression.clear();
@@ -627,7 +647,8 @@ bool CommandObjectExpression::DoExecute(llvm::StringRef command,
if (repl_sp) {
if (initialize) {
- repl_sp->SetCommandOptions(m_command_options);
+ repl_sp->SetEvaluateOptions(
+ GetExprOptions(exe_ctx, m_command_options));
repl_sp->SetFormatOptions(m_format_options);
repl_sp->SetValueObjectDisplayOptions(m_varobj_options);
}
diff --git a/source/Commands/CommandObjectExpression.h b/source/Commands/CommandObjectExpression.h
index 2eeca0da05781..89c8e1dbecebd 100644
--- a/source/Commands/CommandObjectExpression.h
+++ b/source/Commands/CommandObjectExpression.h
@@ -1,9 +1,8 @@
//===-- CommandObjectExpression.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -58,9 +57,7 @@ public:
int HandleCompletion(CompletionRequest &request) override;
protected:
- //------------------------------------------------------------------
// IOHandler::Delegate functions
- //------------------------------------------------------------------
void IOHandlerInputComplete(IOHandler &io_handler,
std::string &line) override;
@@ -71,7 +68,7 @@ protected:
bool EvaluateExpression(llvm::StringRef expr, Stream *output_stream,
Stream *error_stream,
- CommandReturnObject *result = NULL);
+ CommandReturnObject *result = nullptr);
void GetMultilineExpression();
diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp
index f8318a38e28d8..ab6a07952f194 100644
--- a/source/Commands/CommandObjectFrame.cpp
+++ b/source/Commands/CommandObjectFrame.cpp
@@ -1,14 +1,10 @@
//===-- CommandObjectFrame.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-
-#include <string>
-
#include "CommandObjectFrame.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
@@ -46,18 +42,17 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+#include <memory>
+#include <string>
+
using namespace lldb;
using namespace lldb_private;
#pragma mark CommandObjectFrameDiagnose
-//-------------------------------------------------------------------------
// CommandObjectFrameInfo
-//-------------------------------------------------------------------------
-//-------------------------------------------------------------------------
// CommandObjectFrameDiagnose
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_frame_diag_options[] = {
// clang-format off
@@ -217,9 +212,7 @@ protected:
#pragma mark CommandObjectFrameInfo
-//-------------------------------------------------------------------------
// CommandObjectFrameInfo
-//-------------------------------------------------------------------------
class CommandObjectFrameInfo : public CommandObjectParsed {
public:
@@ -243,9 +236,7 @@ protected:
#pragma mark CommandObjectFrameSelect
-//-------------------------------------------------------------------------
// CommandObjectFrameSelect
-//-------------------------------------------------------------------------
static OptionDefinition g_frame_select_options[] = {
// clang-format off
@@ -413,9 +404,7 @@ protected:
};
#pragma mark CommandObjectFrameVariable
-//----------------------------------------------------------------------
// List images with associated information
-//----------------------------------------------------------------------
class CommandObjectFrameVariable : public CommandObjectParsed {
public:
CommandObjectFrameVariable(CommandInterpreter &interpreter)
@@ -527,9 +516,9 @@ protected:
ConstString(m_option_variable.summary.GetCurrentValue()),
summary_format_sp);
else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
- summary_format_sp.reset(new StringSummaryFormat(
+ summary_format_sp = std::make_shared<StringSummaryFormat>(
TypeSummaryImpl::Flags(),
- m_option_variable.summary_string.GetCurrentValue()));
+ m_option_variable.summary_string.GetCurrentValue());
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(
eLanguageRuntimeDescriptionDisplayVerbosityFull, eFormatDefault,
@@ -901,7 +890,7 @@ bool CommandObjectFrameRecognizerAdd::DoExecute(Args &command,
return false;
}
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter &&
!interpreter->CheckObjectExists(m_options.m_class_name.c_str())) {
@@ -1119,9 +1108,7 @@ class CommandObjectFrameRecognizer : public CommandObjectMultiword {
#pragma mark CommandObjectMultiwordFrame
-//-------------------------------------------------------------------------
// CommandObjectMultiwordFrame
-//-------------------------------------------------------------------------
CommandObjectMultiwordFrame::CommandObjectMultiwordFrame(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectFrame.h b/source/Commands/CommandObjectFrame.h
index 3199399163df3..46a59f71733be 100644
--- a/source/Commands/CommandObjectFrame.h
+++ b/source/Commands/CommandObjectFrame.h
@@ -1,9 +1,8 @@
//===-- CommandObjectFrame.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordFrame
-//-------------------------------------------------------------------------
class CommandObjectMultiwordFrame : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectGUI.cpp b/source/Commands/CommandObjectGUI.cpp
index ed834dcbe4fb7..21ed510d1264c 100644
--- a/source/Commands/CommandObjectGUI.cpp
+++ b/source/Commands/CommandObjectGUI.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectGUI.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectGUI
-//-------------------------------------------------------------------------
CommandObjectGUI::CommandObjectGUI(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "gui",
@@ -29,7 +26,7 @@ CommandObjectGUI::~CommandObjectGUI() {}
bool CommandObjectGUI::DoExecute(Args &args, CommandReturnObject &result) {
#ifndef LLDB_DISABLE_CURSES
if (args.GetArgumentCount() == 0) {
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = GetDebugger();
lldb::StreamFileSP input_sp = debugger.GetInputFile();
if (input_sp && input_sp->GetFile().GetIsRealTerminal() &&
diff --git a/source/Commands/CommandObjectGUI.h b/source/Commands/CommandObjectGUI.h
index b20c3a7191abc..a19aad18ec357 100644
--- a/source/Commands/CommandObjectGUI.h
+++ b/source/Commands/CommandObjectGUI.h
@@ -1,9 +1,8 @@
//===-- CommandObjectGUI.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectGUI
-//-------------------------------------------------------------------------
class CommandObjectGUI : public CommandObjectParsed {
public:
diff --git a/source/Commands/CommandObjectHelp.cpp b/source/Commands/CommandObjectHelp.cpp
index 1f1d63d72903f..ab557919d0a06 100644
--- a/source/Commands/CommandObjectHelp.cpp
+++ b/source/Commands/CommandObjectHelp.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectHelp.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,13 +15,12 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectHelp
-//-------------------------------------------------------------------------
void CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(
- Stream *s, llvm::StringRef command, llvm::StringRef prefix, llvm::StringRef subcommand,
- bool include_apropos, bool include_type_lookup) {
+ Stream *s, llvm::StringRef command, llvm::StringRef prefix,
+ llvm::StringRef subcommand, bool include_upropos,
+ bool include_type_lookup) {
if (!s || command.empty())
return;
@@ -33,7 +31,7 @@ void CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage(
s->Printf("'%s' is not a known command.\n", command_str.c_str());
s->Printf("Try '%shelp' to see a current list of commands.\n",
prefix.str().c_str());
- if (include_apropos) {
+ if (include_upropos) {
s->Printf("Try '%sapropos %s' for a list of related commands.\n",
prefix_str.c_str(), lookup_str.c_str());
}
@@ -68,11 +66,8 @@ CommandObjectHelp::CommandObjectHelp(CommandInterpreter &interpreter)
CommandObjectHelp::~CommandObjectHelp() = default;
static constexpr OptionDefinition g_help_options[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
- {LLDB_OPT_SET_ALL, false, "hide-user-commands", 'u', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide user-defined commands from the list."},
- {LLDB_OPT_SET_ALL, false, "show-hidden-commands", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Include commands prefixed with an underscore."},
- // clang-format on
+#define LLDB_OPTIONS_help
+#include "CommandOptions.inc"
};
llvm::ArrayRef<OptionDefinition>
diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h
index 5d5b672a5fbde..a641b19a46d09 100644
--- a/source/Commands/CommandObjectHelp.h
+++ b/source/Commands/CommandObjectHelp.h
@@ -1,9 +1,8 @@
//===-- CommandObjectHelp.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectHelp
-//-------------------------------------------------------------------------
class CommandObjectHelp : public CommandObjectParsed {
public:
@@ -30,7 +27,7 @@ public:
static void GenerateAdditionalHelpAvenuesMessage(
Stream *s, llvm::StringRef command, llvm::StringRef prefix,
- llvm::StringRef subcommand, bool include_apropos = true,
+ llvm::StringRef subcommand, bool include_upropos = true,
bool include_type_lookup = true);
class CommandOptions : public Options {
diff --git a/source/Commands/CommandObjectLanguage.cpp b/source/Commands/CommandObjectLanguage.cpp
index f0028d65da37f..47c9e2a52023e 100644
--- a/source/Commands/CommandObjectLanguage.cpp
+++ b/source/Commands/CommandObjectLanguage.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectLanguage.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectLanguage.h b/source/Commands/CommandObjectLanguage.h
index ef8e11863e7e4..b86457c99af37 100644
--- a/source/Commands/CommandObjectLanguage.h
+++ b/source/Commands/CommandObjectLanguage.h
@@ -1,9 +1,8 @@
//===-- CommandObjectLanguage.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp
index b019336bdc92a..2ad61de1a3e9f 100644
--- a/source/Commands/CommandObjectLog.cpp
+++ b/source/Commands/CommandObjectLog.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectLog.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -49,9 +48,7 @@ static constexpr OptionDefinition g_log_options[] = {
class CommandObjectLogEnable : public CommandObjectParsed {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectLogEnable(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "log enable",
"Enable logging for a single log channel.",
@@ -171,9 +168,9 @@ protected:
std::string error;
llvm::raw_string_ostream error_stream(error);
- bool success = m_interpreter.GetDebugger().EnableLog(
- channel, args.GetArgumentArrayRef(), log_file, m_options.log_options,
- error_stream);
+ bool success =
+ GetDebugger().EnableLog(channel, args.GetArgumentArrayRef(), log_file,
+ m_options.log_options, error_stream);
result.GetErrorStream() << error_stream.str();
if (success)
@@ -188,9 +185,7 @@ protected:
class CommandObjectLogDisable : public CommandObjectParsed {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectLogDisable(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "log disable",
"Disable one or more log channel categories.",
@@ -248,9 +243,7 @@ protected:
class CommandObjectLogList : public CommandObjectParsed {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectLogList(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "log list",
"List the log categories for one or more log "
@@ -295,9 +288,7 @@ protected:
class CommandObjectLogTimer : public CommandObjectParsed {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectLogTimer(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "log timers",
"Enable, disable, dump, and reset LLDB internal "
diff --git a/source/Commands/CommandObjectLog.h b/source/Commands/CommandObjectLog.h
index f02a7be514acf..b2da900e21edb 100644
--- a/source/Commands/CommandObjectLog.h
+++ b/source/Commands/CommandObjectLog.h
@@ -1,9 +1,8 @@
//===-- CommandObjectLog.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,23 +16,17 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectLog
-//-------------------------------------------------------------------------
class CommandObjectLog : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectLog(CommandInterpreter &interpreter);
~CommandObjectLog() override;
private:
- //------------------------------------------------------------------
// For CommandObjectLog only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(CommandObjectLog);
};
diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp
index b1edb1afa5d2c..1afcac71318df 100644
--- a/source/Commands/CommandObjectMemory.cpp
+++ b/source/Commands/CommandObjectMemory.cpp
@@ -1,24 +1,19 @@
//===-- CommandObjectMemory.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <inttypes.h>
-
-#include "clang/AST/Decl.h"
-
#include "CommandObjectMemory.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/DumpDataExtractor.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/ValueObjectMemory.h"
#include "lldb/DataFormatters/ValueObjectPrinter.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
@@ -26,15 +21,17 @@
#include "lldb/Interpreter/OptionGroupFormat.h"
#include "lldb/Interpreter/OptionGroupOutputFile.h"
#include "lldb/Interpreter/OptionGroupValueObjectDisplay.h"
+#include "lldb/Interpreter/OptionValueLanguage.h"
#include "lldb/Interpreter/OptionValueString.h"
#include "lldb/Interpreter/Options.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeList.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/MemoryHistory.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -43,6 +40,9 @@
#include "lldb/lldb-private.h"
+#include <cinttypes>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -51,7 +51,9 @@ static constexpr OptionDefinition g_read_memory_options[] = {
{LLDB_OPT_SET_1, false, "num-per-line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNumberPerLine, "The number of items per line to display." },
{LLDB_OPT_SET_2, false, "binary", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that "
"uses the format, size, count and number per line settings." },
- {LLDB_OPT_SET_3, true , "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeNone, "The name of a type to view memory as." },
+ {LLDB_OPT_SET_3 |
+ LLDB_OPT_SET_4, true , "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "The name of a type to view memory as." },
+ {LLDB_OPT_SET_4, false, "language", 'x', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "The language of the type to view memory as."},
{LLDB_OPT_SET_3, false, "offset", 'E', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many elements of the specified type to skip before starting to display data." },
{LLDB_OPT_SET_1 |
LLDB_OPT_SET_2 |
@@ -63,7 +65,7 @@ class OptionGroupReadMemory : public OptionGroup {
public:
OptionGroupReadMemory()
: m_num_per_line(1, 1), m_output_as_binary(false), m_view_as_type(),
- m_offset(0, 0) {}
+ m_offset(0, 0), m_language_for_type(eLanguageTypeUnknown) {}
~OptionGroupReadMemory() override = default;
@@ -97,6 +99,10 @@ public:
m_force = true;
break;
+ case 'x':
+ error = m_language_for_type.SetValueFromString(option_value);
+ break;
+
case 'E':
error = m_offset.SetValueFromString(option_value);
break;
@@ -115,6 +121,7 @@ public:
m_view_as_type.Clear();
m_force = false;
m_offset.Clear();
+ m_language_for_type.Clear();
}
Status FinalizeSettings(Target *target, OptionGroupFormat &format_options) {
@@ -277,7 +284,8 @@ public:
bool AnyOptionWasSet() const {
return m_num_per_line.OptionWasSet() || m_output_as_binary ||
- m_view_as_type.OptionWasSet() || m_offset.OptionWasSet();
+ m_view_as_type.OptionWasSet() || m_offset.OptionWasSet() ||
+ m_language_for_type.OptionWasSet();
}
OptionValueUInt64 m_num_per_line;
@@ -285,11 +293,10 @@ public:
OptionValueString m_view_as_type;
bool m_force;
OptionValueUInt64 m_offset;
+ OptionValueLanguage m_language_for_type;
};
-//----------------------------------------------------------------------
// Read memory from the inferior process
-//----------------------------------------------------------------------
class CommandObjectMemoryRead : public CommandObjectParsed {
public:
CommandObjectMemoryRead(CommandInterpreter &interpreter)
@@ -374,7 +381,7 @@ protected:
return false;
}
- CompilerType clang_ast_type;
+ CompilerType compiler_type;
Status error;
const char *view_as_type_cstr =
@@ -474,26 +481,43 @@ protected:
exact_match, 1, searched_symbol_files,
type_list);
- if (type_list.GetSize() == 0 && lookup_type_name.GetCString() &&
- *lookup_type_name.GetCString() == '$') {
- if (ClangPersistentVariables *persistent_vars =
- llvm::dyn_cast_or_null<ClangPersistentVariables>(
- target->GetPersistentExpressionStateForLanguage(
- lldb::eLanguageTypeC))) {
- clang::TypeDecl *tdecl = llvm::dyn_cast_or_null<clang::TypeDecl>(
- persistent_vars->GetPersistentDecl(
- ConstString(lookup_type_name)));
-
- if (tdecl) {
- clang_ast_type.SetCompilerType(
- ClangASTContext::GetASTContext(&tdecl->getASTContext()),
- reinterpret_cast<lldb::opaque_compiler_type_t>(
- const_cast<clang::Type *>(tdecl->getTypeForDecl())));
+ if (type_list.GetSize() == 0 && lookup_type_name.GetCString()) {
+ LanguageType language_for_type =
+ m_memory_options.m_language_for_type.GetCurrentValue();
+ std::set<LanguageType> languages_to_check;
+ if (language_for_type != eLanguageTypeUnknown) {
+ languages_to_check.insert(language_for_type);
+ } else {
+ languages_to_check = Language::GetSupportedLanguages();
+ }
+
+ std::set<CompilerType> user_defined_types;
+ for (auto lang : languages_to_check) {
+ if (auto *persistent_vars =
+ target->GetPersistentExpressionStateForLanguage(lang)) {
+ if (llvm::Optional<CompilerType> type =
+ persistent_vars->GetCompilerTypeFromPersistentDecl(
+ lookup_type_name)) {
+ user_defined_types.emplace(*type);
+ }
}
}
+
+ if (user_defined_types.size() > 1) {
+ result.AppendErrorWithFormat(
+ "Mutiple types found matching raw type '%s', please disambiguate "
+ "by specifying the language with -x",
+ lookup_type_name.GetCString());
+ result.SetStatus(eReturnStatusFailed);
+ return false;
+ }
+
+ if (user_defined_types.size() == 1) {
+ compiler_type = *user_defined_types.begin();
+ }
}
- if (!clang_ast_type.IsValid()) {
+ if (!compiler_type.IsValid()) {
if (type_list.GetSize() == 0) {
result.AppendErrorWithFormat("unable to find any types that match "
"the raw type '%s' for full type '%s'\n",
@@ -503,14 +527,14 @@ protected:
return false;
} else {
TypeSP type_sp(type_list.GetTypeAtIndex(0));
- clang_ast_type = type_sp->GetFullCompilerType();
+ compiler_type = type_sp->GetFullCompilerType();
}
}
while (pointer_count > 0) {
- CompilerType pointer_type = clang_ast_type.GetPointerType();
+ CompilerType pointer_type = compiler_type.GetPointerType();
if (pointer_type.IsValid())
- clang_ast_type = pointer_type;
+ compiler_type = pointer_type;
else {
result.AppendError("unable make a pointer type\n");
result.SetStatus(eReturnStatusFailed);
@@ -519,7 +543,7 @@ protected:
--pointer_count;
}
- llvm::Optional<uint64_t> size = clang_ast_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> size = compiler_type.GetByteSize(nullptr);
if (!size) {
result.AppendErrorWithFormat(
"unable to get the byte size of the type '%s'\n",
@@ -549,7 +573,7 @@ protected:
// options have been set
addr = m_next_addr;
total_byte_size = m_prev_byte_size;
- clang_ast_type = m_prev_clang_ast_type;
+ compiler_type = m_prev_compiler_type;
if (!m_format_options.AnyOptionWasSet() &&
!m_memory_options.AnyOptionWasSet() &&
!m_outfile_options.AnyOptionWasSet() &&
@@ -636,13 +660,13 @@ protected:
DataBufferSP data_sp;
size_t bytes_read = 0;
- if (clang_ast_type.GetOpaqueQualType()) {
+ if (compiler_type.GetOpaqueQualType()) {
// Make sure we don't display our type as ASCII bytes like the default
// memory read
if (!m_format_options.GetFormatValue().OptionWasSet())
m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
- llvm::Optional<uint64_t> size = clang_ast_type.GetByteSize(nullptr);
+ llvm::Optional<uint64_t> size = compiler_type.GetByteSize(nullptr);
if (!size) {
result.AppendError("can't get size of type");
return false;
@@ -653,7 +677,7 @@ protected:
addr = addr + (*size * m_memory_options.m_offset.GetCurrentValue());
} else if (m_format_options.GetFormatValue().GetCurrentValue() !=
eFormatCString) {
- data_sp.reset(new DataBufferHeap(total_byte_size, '\0'));
+ data_sp = std::make_shared<DataBufferHeap>(total_byte_size, '\0');
if (data_sp->GetBytes() == nullptr) {
result.AppendErrorWithFormat(
"can't allocate 0x%" PRIx32
@@ -693,8 +717,9 @@ protected:
item_byte_size = target->GetMaximumSizeOfStringSummary();
if (!m_format_options.GetCountValue().OptionWasSet())
item_count = 1;
- data_sp.reset(new DataBufferHeap((item_byte_size + 1) * item_count,
- '\0')); // account for NULLs as necessary
+ data_sp = std::make_shared<DataBufferHeap>(
+ (item_byte_size + 1) * item_count,
+ '\0'); // account for NULLs as necessary
if (data_sp->GetBytes() == nullptr) {
result.AppendErrorWithFormat(
"can't allocate 0x%" PRIx64
@@ -741,7 +766,8 @@ protected:
if (break_on_no_NULL)
break;
}
- data_sp.reset(new DataBufferHeap(data_sp->GetBytes(), bytes_read + 1));
+ data_sp =
+ std::make_shared<DataBufferHeap>(data_sp->GetBytes(), bytes_read + 1);
}
m_next_addr = addr + bytes_read;
@@ -750,7 +776,7 @@ protected:
m_prev_memory_options = m_memory_options;
m_prev_outfile_options = m_outfile_options;
m_prev_varobj_options = m_varobj_options;
- m_prev_clang_ast_type = clang_ast_type;
+ m_prev_compiler_type = compiler_type;
StreamFile outfile_stream;
Stream *output_stream = nullptr;
@@ -800,14 +826,14 @@ protected:
}
ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
- if (clang_ast_type.GetOpaqueQualType()) {
+ if (compiler_type.GetOpaqueQualType()) {
for (uint32_t i = 0; i < item_count; ++i) {
addr_t item_addr = addr + (i * item_byte_size);
Address address(item_addr);
StreamString name_strm;
name_strm.Printf("0x%" PRIx64, item_addr);
ValueObjectSP valobj_sp(ValueObjectMemory::Create(
- exe_scope, name_strm.GetString(), address, clang_ast_type));
+ exe_scope, name_strm.GetString(), address, compiler_type));
if (valobj_sp) {
Format format = m_format_options.GetFormat();
if (format != eFormatDefault)
@@ -877,7 +903,7 @@ protected:
OptionGroupReadMemory m_prev_memory_options;
OptionGroupOutputFile m_prev_outfile_options;
OptionGroupValueObjectDisplay m_prev_varobj_options;
- CompilerType m_prev_clang_ast_type;
+ CompilerType m_prev_compiler_type;
};
static constexpr OptionDefinition g_memory_find_option_table[] = {
@@ -889,9 +915,7 @@ static constexpr OptionDefinition g_memory_find_option_table[] = {
// clang-format on
};
-//----------------------------------------------------------------------
// Find the specified data in memory
-//----------------------------------------------------------------------
class CommandObjectMemoryFind : public CommandObjectParsed {
public:
class OptionGroupFindMemory : public OptionGroup {
@@ -1186,9 +1210,7 @@ static constexpr OptionDefinition g_memory_write_option_table[] = {
// clang-format on
};
-//----------------------------------------------------------------------
// Write memory to the inferior process
-//----------------------------------------------------------------------
class CommandObjectMemoryWrite : public CommandObjectParsed {
public:
class OptionGroupWriteMemory : public OptionGroup {
@@ -1595,9 +1617,7 @@ protected:
OptionGroupWriteMemory m_memory_options;
};
-//----------------------------------------------------------------------
// Get malloc/free history of a memory address.
-//----------------------------------------------------------------------
class CommandObjectMemoryHistory : public CommandObjectParsed {
public:
CommandObjectMemoryHistory(CommandInterpreter &interpreter)
@@ -1677,9 +1697,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectMemoryRegion
-//-------------------------------------------------------------------------
#pragma mark CommandObjectMemoryRegion
class CommandObjectMemoryRegion : public CommandObjectParsed {
@@ -1770,9 +1788,7 @@ protected:
lldb::addr_t m_prev_end_addr;
};
-//-------------------------------------------------------------------------
// CommandObjectMemory
-//-------------------------------------------------------------------------
CommandObjectMemory::CommandObjectMemory(CommandInterpreter &interpreter)
: CommandObjectMultiword(
diff --git a/source/Commands/CommandObjectMemory.h b/source/Commands/CommandObjectMemory.h
index 0fa5251e82ff9..f94cdf3287aa2 100644
--- a/source/Commands/CommandObjectMemory.h
+++ b/source/Commands/CommandObjectMemory.h
@@ -1,9 +1,8 @@
//===-- CommandObjectMemory.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp
index 64c4f6686e6ba..4011cceb8a26b 100644
--- a/source/Commands/CommandObjectMultiword.cpp
+++ b/source/Commands/CommandObjectMultiword.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectMultiword.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectMultiword
-//-------------------------------------------------------------------------
CommandObjectMultiword::CommandObjectMultiword(CommandInterpreter &interpreter,
const char *name,
diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp
index fc442f5f4d5db..53549cdeee326 100644
--- a/source/Commands/CommandObjectPlatform.cpp
+++ b/source/Commands/CommandObjectPlatform.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -154,9 +153,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(OptionPermissions);
};
-//----------------------------------------------------------------------
// "platform select <platform-name>"
-//----------------------------------------------------------------------
class CommandObjectPlatformSelect : public CommandObjectParsed {
public:
CommandObjectPlatformSelect(CommandInterpreter &interpreter)
@@ -194,8 +191,7 @@ protected:
PlatformSP platform_sp(m_platform_options.CreatePlatformWithOptions(
m_interpreter, ArchSpec(), select, error, platform_arch));
if (platform_sp) {
- m_interpreter.GetDebugger().GetPlatformList().SetSelectedPlatform(
- platform_sp);
+ GetDebugger().GetPlatformList().SetSelectedPlatform(platform_sp);
platform_sp->GetStatus(result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -219,9 +215,7 @@ protected:
OptionGroupPlatform m_platform_options;
};
-//----------------------------------------------------------------------
// "platform list"
-//----------------------------------------------------------------------
class CommandObjectPlatformList : public CommandObjectParsed {
public:
CommandObjectPlatformList(CommandInterpreter &interpreter)
@@ -241,7 +235,7 @@ protected:
host_platform_sp->GetDescription());
uint32_t idx;
- for (idx = 0; 1; ++idx) {
+ for (idx = 0; true; ++idx) {
const char *plugin_name =
PluginManager::GetPlatformPluginNameAtIndex(idx);
if (plugin_name == nullptr)
@@ -262,9 +256,7 @@ protected:
}
};
-//----------------------------------------------------------------------
// "platform status"
-//----------------------------------------------------------------------
class CommandObjectPlatformStatus : public CommandObjectParsed {
public:
CommandObjectPlatformStatus(CommandInterpreter &interpreter)
@@ -278,14 +270,13 @@ protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
Stream &ostrm = result.GetOutputStream();
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
if (target) {
platform_sp = target->GetPlatform();
}
if (!platform_sp) {
- platform_sp =
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform();
}
if (platform_sp) {
platform_sp->GetStatus(ostrm);
@@ -298,9 +289,7 @@ protected:
}
};
-//----------------------------------------------------------------------
// "platform connect <connect-url>"
-//----------------------------------------------------------------------
class CommandObjectPlatformConnect : public CommandObjectParsed {
public:
CommandObjectPlatformConnect(CommandInterpreter &interpreter)
@@ -316,15 +305,14 @@ protected:
Stream &ostrm = result.GetOutputStream();
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
Status error(platform_sp->ConnectRemote(args));
if (error.Success()) {
platform_sp->GetStatus(ostrm);
result.SetStatus(eReturnStatusSuccessFinishResult);
- platform_sp->ConnectToWaitingProcesses(m_interpreter.GetDebugger(),
- error);
+ platform_sp->ConnectToWaitingProcesses(GetDebugger(), error);
if (error.Fail()) {
result.AppendError(error.AsCString());
result.SetStatus(eReturnStatusFailed);
@@ -342,7 +330,7 @@ protected:
Options *GetOptions() override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
OptionGroupOptions *m_platform_options = nullptr;
if (platform_sp) {
m_platform_options = platform_sp->GetConnectionOptions(m_interpreter);
@@ -353,9 +341,7 @@ protected:
}
};
-//----------------------------------------------------------------------
// "platform disconnect"
-//----------------------------------------------------------------------
class CommandObjectPlatformDisconnect : public CommandObjectParsed {
public:
CommandObjectPlatformDisconnect(CommandInterpreter &interpreter)
@@ -368,7 +354,7 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
if (args.GetArgumentCount() == 0) {
Status error;
@@ -415,9 +401,7 @@ protected:
}
};
-//----------------------------------------------------------------------
// "platform settings"
-//----------------------------------------------------------------------
class CommandObjectPlatformSettings : public CommandObjectParsed {
public:
CommandObjectPlatformSettings(CommandInterpreter &interpreter)
@@ -437,7 +421,7 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
if (m_option_working_dir.GetOptionValue().OptionWasSet())
platform_sp->SetWorkingDirectory(
@@ -460,9 +444,7 @@ protected:
OptionGroupFile m_option_working_dir;
};
-//----------------------------------------------------------------------
// "platform mkdir"
-//----------------------------------------------------------------------
class CommandObjectPlatformMkDir : public CommandObjectParsed {
public:
CommandObjectPlatformMkDir(CommandInterpreter &interpreter)
@@ -475,7 +457,7 @@ public:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
std::string cmd_line;
args.GetCommandString(cmd_line);
@@ -512,9 +494,7 @@ public:
OptionGroupOptions m_options;
};
-//----------------------------------------------------------------------
// "platform fopen"
-//----------------------------------------------------------------------
class CommandObjectPlatformFOpen : public CommandObjectParsed {
public:
CommandObjectPlatformFOpen(CommandInterpreter &interpreter)
@@ -526,7 +506,7 @@ public:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
Status error;
std::string cmd_line;
@@ -569,9 +549,7 @@ public:
OptionGroupOptions m_options;
};
-//----------------------------------------------------------------------
// "platform fclose"
-//----------------------------------------------------------------------
class CommandObjectPlatformFClose : public CommandObjectParsed {
public:
CommandObjectPlatformFClose(CommandInterpreter &interpreter)
@@ -582,7 +560,7 @@ public:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
std::string cmd_line;
args.GetCommandString(cmd_line);
@@ -605,9 +583,7 @@ public:
}
};
-//----------------------------------------------------------------------
// "platform fread"
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_platform_fread_options[] = {
// clang-format off
@@ -628,7 +604,7 @@ public:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
std::string cmd_line;
args.GetCommandString(cmd_line);
@@ -700,9 +676,7 @@ protected:
CommandOptions m_options;
};
-//----------------------------------------------------------------------
// "platform fwrite"
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_platform_fwrite_options[] = {
// clang-format off
@@ -723,7 +697,7 @@ public:
bool DoExecute(Args &args, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
std::string cmd_line;
args.GetCommandString(cmd_line);
@@ -794,9 +768,7 @@ protected:
class CommandObjectPlatformFile : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectPlatformFile(CommandInterpreter &interpreter)
: CommandObjectMultiword(
interpreter, "platform file",
@@ -815,15 +787,11 @@ public:
~CommandObjectPlatformFile() override = default;
private:
- //------------------------------------------------------------------
// For CommandObjectPlatform only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatformFile);
};
-//----------------------------------------------------------------------
// "platform get-file remote-file-path host-file-path"
-//----------------------------------------------------------------------
class CommandObjectPlatformGetFile : public CommandObjectParsed {
public:
CommandObjectPlatformGetFile(CommandInterpreter &interpreter)
@@ -874,7 +842,7 @@ public:
}
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
const char *remote_file_path = args.GetArgumentAtIndex(0);
const char *local_file_path = args.GetArgumentAtIndex(1);
@@ -898,9 +866,7 @@ public:
}
};
-//----------------------------------------------------------------------
// "platform get-size remote-file-path"
-//----------------------------------------------------------------------
class CommandObjectPlatformGetSize : public CommandObjectParsed {
public:
CommandObjectPlatformGetSize(CommandInterpreter &interpreter)
@@ -941,7 +907,7 @@ public:
}
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
std::string remote_file_path(args.GetArgumentAtIndex(0));
user_id_t size = platform_sp->GetFileSize(FileSpec(remote_file_path));
@@ -964,9 +930,7 @@ public:
}
};
-//----------------------------------------------------------------------
// "platform put-file"
-//----------------------------------------------------------------------
class CommandObjectPlatformPutFile : public CommandObjectParsed {
public:
CommandObjectPlatformPutFile(CommandInterpreter &interpreter)
@@ -986,7 +950,7 @@ public:
FileSpec dst_fs(dst ? dst : src_fs.GetFilename().GetCString());
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
Status error(platform_sp->PutFile(src_fs, dst_fs));
if (error.Success()) {
@@ -1003,9 +967,7 @@ public:
}
};
-//----------------------------------------------------------------------
// "platform process launch"
-//----------------------------------------------------------------------
class CommandObjectPlatformProcessLaunch : public CommandObjectParsed {
public:
CommandObjectPlatformProcessLaunch(CommandInterpreter &interpreter)
@@ -1021,14 +983,13 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
if (target) {
platform_sp = target->GetPlatform();
}
if (!platform_sp) {
- platform_sp =
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform();
}
if (platform_sp) {
@@ -1059,7 +1020,7 @@ protected:
}
if (m_options.launch_info.GetExecutableFile()) {
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = GetDebugger();
if (argc == 0)
target->GetRunArguments(m_options.launch_info.GetArguments());
@@ -1093,9 +1054,7 @@ protected:
ProcessLaunchCommandOptions m_options;
};
-//----------------------------------------------------------------------
// "platform process list"
-//----------------------------------------------------------------------
static OptionDefinition g_platform_process_list_options[] = {
// clang-format off
@@ -1131,14 +1090,13 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
if (target) {
platform_sp = target->GetPlatform();
}
if (!platform_sp) {
- platform_sp =
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform();
}
if (platform_sp) {
@@ -1152,10 +1110,9 @@ protected:
if (pid != LLDB_INVALID_PROCESS_ID) {
ProcessInstanceInfo proc_info;
if (platform_sp->GetProcessInfo(pid, proc_info)) {
- ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(),
- m_options.show_args,
+ ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
- proc_info.DumpAsTableRow(ostrm, platform_sp.get(),
+ proc_info.DumpAsTableRow(ostrm, platform_sp->GetUserIDResolver(),
m_options.show_args, m_options.verbose);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else {
@@ -1213,13 +1170,12 @@ protected:
result.AppendMessageWithFormat(" whose name %s \"%s\"",
match_desc, match_name);
result.AppendMessageWithFormat("\n");
- ProcessInstanceInfo::DumpTableHeader(ostrm, platform_sp.get(),
- m_options.show_args,
+ ProcessInstanceInfo::DumpTableHeader(ostrm, m_options.show_args,
m_options.verbose);
for (uint32_t i = 0; i < matches; ++i) {
proc_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(
- ostrm, platform_sp.get(), m_options.show_args,
- m_options.verbose);
+ ostrm, platform_sp->GetUserIDResolver(),
+ m_options.show_args, m_options.verbose);
}
}
}
@@ -1396,9 +1352,7 @@ protected:
CommandOptions m_options;
};
-//----------------------------------------------------------------------
// "platform process info"
-//----------------------------------------------------------------------
class CommandObjectPlatformProcessInfo : public CommandObjectParsed {
public:
CommandObjectPlatformProcessInfo(CommandInterpreter &interpreter)
@@ -1425,14 +1379,13 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
PlatformSP platform_sp;
if (target) {
platform_sp = target->GetPlatform();
}
if (!platform_sp) {
- platform_sp =
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform();
+ platform_sp = GetDebugger().GetPlatformList().GetSelectedPlatform();
}
if (platform_sp) {
@@ -1454,7 +1407,7 @@ protected:
if (platform_sp->GetProcessInfo(pid, proc_info)) {
ostrm.Printf("Process information for process %" PRIu64 ":\n",
pid);
- proc_info.Dump(ostrm, platform_sp.get());
+ proc_info.Dump(ostrm, platform_sp->GetUserIDResolver());
} else {
ostrm.Printf("error: no process information is available for "
"process %" PRIu64 "\n",
@@ -1608,11 +1561,11 @@ public:
bool DoExecute(Args &command, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp) {
Status err;
ProcessSP remote_process_sp = platform_sp->Attach(
- m_options.attach_info, m_interpreter.GetDebugger(), nullptr, err);
+ m_options.attach_info, GetDebugger(), nullptr, err);
if (err.Fail()) {
result.AppendError(err.AsCString());
result.SetStatus(eReturnStatusFailed);
@@ -1636,9 +1589,7 @@ protected:
class CommandObjectPlatformProcess : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectPlatformProcess(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "platform process",
"Commands to query, launch and attach to "
@@ -1659,15 +1610,11 @@ public:
~CommandObjectPlatformProcess() override = default;
private:
- //------------------------------------------------------------------
// For CommandObjectPlatform only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(CommandObjectPlatformProcess);
};
-//----------------------------------------------------------------------
// "platform shell"
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_platform_shell_options[] = {
// clang-format off
{ LLDB_OPT_SET_ALL, false, "timeout", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeValue, "Seconds to wait for the remote host to finish running the command." },
@@ -1746,7 +1693,7 @@ public:
return false;
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
Status error;
if (platform_sp) {
FileSpec working_dir{};
@@ -1791,9 +1738,7 @@ public:
CommandOptions m_options;
};
-//----------------------------------------------------------------------
// "platform install" - install a target to a remote end
-//----------------------------------------------------------------------
class CommandObjectPlatformInstall : public CommandObjectParsed {
public:
CommandObjectPlatformInstall(CommandInterpreter &interpreter)
@@ -1820,7 +1765,7 @@ public:
return false;
}
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
if (!platform_sp) {
result.AppendError("no platform currently selected");
result.SetStatus(eReturnStatusFailed);
diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h
index e15df5a0441fa..c94d2ea2cc4d1 100644
--- a/source/Commands/CommandObjectPlatform.h
+++ b/source/Commands/CommandObjectPlatform.h
@@ -1,9 +1,8 @@
//===-- CommandObjectPlatform.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectPlatform
-//-------------------------------------------------------------------------
class CommandObjectPlatform : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp
index 2e805bab9d6f3..89e01ba520273 100644
--- a/source/Commands/CommandObjectPlugin.cpp
+++ b/source/Commands/CommandObjectPlugin.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectPlugin.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -62,7 +61,7 @@ protected:
FileSpec dylib_fspec(command[0].ref);
FileSystem::Instance().Resolve(dylib_fspec);
- if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error))
+ if (GetDebugger().LoadPlugin(dylib_fspec, error))
result.SetStatus(eReturnStatusSuccessFinishResult);
else {
result.AppendError(error.AsCString());
diff --git a/source/Commands/CommandObjectPlugin.h b/source/Commands/CommandObjectPlugin.h
index cd39eb19b49d7..0aabb13994079 100644
--- a/source/Commands/CommandObjectPlugin.h
+++ b/source/Commands/CommandObjectPlugin.h
@@ -1,9 +1,8 @@
//===-- CommandObjectPlugin.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp
index 5b0e6d784a026..b20a2d5333327 100644
--- a/source/Commands/CommandObjectProcess.cpp
+++ b/source/Commands/CommandObjectProcess.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -101,9 +100,7 @@ protected:
std::string m_new_process_action;
};
-//-------------------------------------------------------------------------
// CommandObjectProcessLaunch
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessLaunch
class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach {
public:
@@ -150,7 +147,7 @@ public:
protected:
bool DoExecute(Args &launch_args, CommandReturnObject &result) override {
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = GetDebugger();
Target *target = debugger.GetSelectedTarget().get();
// If our listener is nullptr, users aren't allows to launch
ModuleSP exe_module_sp = target->GetExecutableModule();
@@ -196,7 +193,10 @@ protected:
if (target->GetDisableSTDIO())
m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
- m_options.launch_info.GetEnvironment() = target->GetEnvironment();
+ // Merge the launch info environment with the target environment.
+ Environment target_env = target->GetEnvironment();
+ m_options.launch_info.GetEnvironment().insert(target_env.begin(),
+ target_env.end());
if (!target_settings_argv0.empty()) {
m_options.launch_info.GetArguments().AppendArgument(
@@ -255,51 +255,6 @@ protected:
ProcessLaunchCommandOptions m_options;
};
-//#define SET1 LLDB_OPT_SET_1
-//#define SET2 LLDB_OPT_SET_2
-//#define SET3 LLDB_OPT_SET_3
-//
-// OptionDefinition
-// CommandObjectProcessLaunch::CommandOptions::g_option_table[] =
-//{
-// // clang-format off
-// {SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument,
-// nullptr, 0, eArgTypeNone, "Stop at the entry point of the program
-// when launching a process."},
-// {SET1, false, "stdin", 'i',
-// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName,
-// "Redirect stdin for the process to <path>."},
-// {SET1, false, "stdout", 'o',
-// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName,
-// "Redirect stdout for the process to <path>."},
-// {SET1, false, "stderr", 'e',
-// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName,
-// "Redirect stderr for the process to <path>."},
-// {SET1 | SET2 | SET3, false, "plugin", 'p',
-// OptionParser::eRequiredArgument, nullptr, 0, eArgTypePlugin, "Name of
-// the process plugin you want to use."},
-// { SET2, false, "tty", 't',
-// OptionParser::eOptionalArgument, nullptr, 0, eArgTypeDirectoryName, "Start
-// the process in a terminal. If <path> is specified, look for a terminal whose
-// name contains <path>, else start the process in a new terminal."},
-// { SET3, false, "no-stdio", 'n', OptionParser::eNoArgument,
-// nullptr, 0, eArgTypeNone, "Do not set up for terminal I/O to go to
-// running process."},
-// {SET1 | SET2 | SET3, false, "working-dir", 'w',
-// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Set the
-// current working directory to <path> when running the inferior."},
-// {0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr}
-// // clang-format on
-//};
-//
-//#undef SET1
-//#undef SET2
-//#undef SET3
-
-//-------------------------------------------------------------------------
-// CommandObjectProcessAttach
-//-------------------------------------------------------------------------
-
static constexpr OptionDefinition g_process_attach_options[] = {
// clang-format off
{ LLDB_OPT_SET_ALL, false, "continue", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Immediately continue the process once attached." },
@@ -435,9 +390,9 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
PlatformSP platform_sp(
- m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+ GetDebugger().GetPlatformList().GetSelectedPlatform());
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
// N.B. The attach should be synchronous. It doesn't help much to get the
// prompt back between initiating the attach and the target actually
// stopping. So even if the interpreter is set to be asynchronous, we wait
@@ -454,8 +409,8 @@ protected:
TargetSP new_target_sp;
Status error;
- error = m_interpreter.GetDebugger().GetTargetList().CreateTarget(
- m_interpreter.GetDebugger(), "", "", eLoadDependentsNo,
+ error = GetDebugger().GetTargetList().CreateTarget(
+ GetDebugger(), "", "", eLoadDependentsNo,
nullptr, // No platform options
new_target_sp);
target = new_target_sp.get();
@@ -463,7 +418,7 @@ protected:
result.AppendError(error.AsCString("Error creating target"));
return false;
}
- m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target);
+ GetDebugger().GetTargetList().SetSelectedTarget(target);
}
// Record the old executable module, we want to issue a warning if the
@@ -548,9 +503,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectProcessContinue
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_process_continue_options[] = {
// clang-format off
@@ -712,9 +665,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectProcessDetach
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_process_detach_options[] = {
// clang-format off
{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." },
@@ -810,9 +761,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectProcessConnect
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_process_connect_options[] = {
// clang-format off
@@ -900,7 +849,7 @@ protected:
plugin_name = m_options.plugin_name.c_str();
Status error;
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = GetDebugger();
PlatformSP platform_sp = m_interpreter.GetPlatform(true);
ProcessSP process_sp = platform_sp->ConnectProcess(
command.GetArgumentAtIndex(0), plugin_name, debugger,
@@ -916,9 +865,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectProcessPlugin
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessPlugin
class CommandObjectProcessPlugin : public CommandObjectProxy {
@@ -939,9 +886,7 @@ public:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessLoad
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_process_load_options[] = {
// clang-format off
@@ -1055,9 +1000,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectProcessUnload
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessUnload
class CommandObjectProcessUnload : public CommandObjectParsed {
@@ -1103,9 +1046,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessSignal
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessSignal
class CommandObjectProcessSignal : public CommandObjectParsed {
@@ -1170,9 +1111,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessInterrupt
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessInterrupt
class CommandObjectProcessInterrupt : public CommandObjectParsed {
@@ -1214,9 +1153,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessKill
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessKill
class CommandObjectProcessKill : public CommandObjectParsed {
@@ -1257,9 +1194,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessSaveCore
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessSaveCore
class CommandObjectProcessSaveCore : public CommandObjectParsed {
@@ -1303,9 +1238,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessStatus
-//-------------------------------------------------------------------------
#pragma mark CommandObjectProcessStatus
class CommandObjectProcessStatus : public CommandObjectParsed {
@@ -1337,9 +1270,7 @@ public:
}
};
-//-------------------------------------------------------------------------
// CommandObjectProcessHandle
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_process_handle_options[] = {
// clang-format off
@@ -1489,7 +1420,7 @@ public:
protected:
bool DoExecute(Args &signal_args, CommandReturnObject &result) override {
- TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
+ TargetSP target_sp = GetDebugger().GetSelectedTarget();
if (!target_sp) {
result.AppendError("No current target;"
@@ -1596,9 +1527,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectMultiwordProcess
-//-------------------------------------------------------------------------
CommandObjectMultiwordProcess::CommandObjectMultiwordProcess(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectProcess.h b/source/Commands/CommandObjectProcess.h
index 7325dce496839..3b1ff26dbb050 100644
--- a/source/Commands/CommandObjectProcess.h
+++ b/source/Commands/CommandObjectProcess.h
@@ -1,9 +1,8 @@
//===-- CommandObjectProcess.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordProcess
-//-------------------------------------------------------------------------
class CommandObjectMultiwordProcess : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectQuit.cpp b/source/Commands/CommandObjectQuit.cpp
index 2c5b20bf58460..70ee336f8a1bd 100644
--- a/source/Commands/CommandObjectQuit.cpp
+++ b/source/Commands/CommandObjectQuit.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectQuit.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectQuit
-//-------------------------------------------------------------------------
CommandObjectQuit::CommandObjectQuit(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "quit", "Quit the LLDB debugger.",
diff --git a/source/Commands/CommandObjectQuit.h b/source/Commands/CommandObjectQuit.h
index 0f9da62278d99..458ef2456fcaa 100644
--- a/source/Commands/CommandObjectQuit.h
+++ b/source/Commands/CommandObjectQuit.h
@@ -1,9 +1,8 @@
//===-- CommandObjectQuit.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectQuit
-//-------------------------------------------------------------------------
class CommandObjectQuit : public CommandObjectParsed {
public:
diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp
index ae8b5d0027c7e..34482a8b1e4f9 100644
--- a/source/Commands/CommandObjectRegister.cpp
+++ b/source/Commands/CommandObjectRegister.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectRegister.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// "register read"
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_register_read_options[] = {
// clang-format off
@@ -299,9 +296,7 @@ protected:
CommandOptions m_command_options;
};
-//----------------------------------------------------------------------
// "register write"
-//----------------------------------------------------------------------
class CommandObjectRegisterWrite : public CommandObjectParsed {
public:
CommandObjectRegisterWrite(CommandInterpreter &interpreter)
@@ -394,9 +389,7 @@ protected:
}
};
-//----------------------------------------------------------------------
// CommandObjectRegister constructor
-//----------------------------------------------------------------------
CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "register",
"Commands to access registers for the current "
diff --git a/source/Commands/CommandObjectRegister.h b/source/Commands/CommandObjectRegister.h
index 96fc47af0a21b..6fc47cf386a34 100644
--- a/source/Commands/CommandObjectRegister.h
+++ b/source/Commands/CommandObjectRegister.h
@@ -1,9 +1,8 @@
//===-- CommandObjectRegister.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,23 +13,17 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectRegister
-//-------------------------------------------------------------------------
class CommandObjectRegister : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectRegister(CommandInterpreter &interpreter);
~CommandObjectRegister() override;
private:
- //------------------------------------------------------------------
// For CommandObjectRegister only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(CommandObjectRegister);
};
diff --git a/source/Commands/CommandObjectReproducer.cpp b/source/Commands/CommandObjectReproducer.cpp
index f393f17d9aec4..4b0e9e36d202b 100644
--- a/source/Commands/CommandObjectReproducer.cpp
+++ b/source/Commands/CommandObjectReproducer.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectReproducer.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,8 +21,12 @@ using namespace lldb_private;
class CommandObjectReproducerGenerate : public CommandObjectParsed {
public:
CommandObjectReproducerGenerate(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "reproducer generate",
- "Generate reproducer on disk.", nullptr) {}
+ : CommandObjectParsed(
+ interpreter, "reproducer generate",
+ "Generate reproducer on disk. When the debugger is in capture "
+ "mode, this command will output the reproducer to a directory on "
+ "disk. In replay mode this command in a no-op.",
+ nullptr) {}
~CommandObjectReproducerGenerate() override = default;
@@ -38,13 +41,21 @@ protected:
auto &r = repro::Reproducer::Instance();
if (auto generator = r.GetGenerator()) {
generator->Keep();
+ } else if (r.GetLoader()) {
+ // Make this operation a NOP in replay mode.
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return result.Succeeded();
} else {
result.AppendErrorWithFormat("Unable to get the reproducer generator");
+ result.SetStatus(eReturnStatusFailed);
return false;
}
result.GetOutputStream()
<< "Reproducer written to '" << r.GetReproducerPath() << "'\n";
+ result.GetOutputStream()
+ << "Please have a look at the directory to assess if you're willing to "
+ "share the contained information.\n";
result.SetStatus(eReturnStatusSuccessFinishResult);
return result.Succeeded();
@@ -54,8 +65,14 @@ protected:
class CommandObjectReproducerStatus : public CommandObjectParsed {
public:
CommandObjectReproducerStatus(CommandInterpreter &interpreter)
- : CommandObjectParsed(interpreter, "reproducer status",
- "Show the current reproducer status.", nullptr) {}
+ : CommandObjectParsed(
+ interpreter, "reproducer status",
+ "Show the current reproducer status. In capture mode the debugger "
+ "is collecting all the information it needs to create a "
+ "reproducer. In replay mode the reproducer is replaying a "
+ "reproducer. When the reproducers are off, no data is collected "
+ "and no reproducer can be generated.",
+ nullptr) {}
~CommandObjectReproducerStatus() override = default;
@@ -68,12 +85,11 @@ protected:
}
auto &r = repro::Reproducer::Instance();
- if (auto generator = r.GetGenerator()) {
+ if (r.GetGenerator()) {
result.GetOutputStream() << "Reproducer is in capture mode.\n";
- } else if (auto generator = r.GetLoader()) {
+ } else if (r.GetLoader()) {
result.GetOutputStream() << "Reproducer is in replay mode.\n";
} else {
-
result.GetOutputStream() << "Reproducer is off.\n";
}
@@ -84,9 +100,10 @@ protected:
CommandObjectReproducer::CommandObjectReproducer(
CommandInterpreter &interpreter)
- : CommandObjectMultiword(interpreter, "reproducer",
- "Commands controlling LLDB reproducers.",
- "log <subcommand> [<command-options>]") {
+ : CommandObjectMultiword(
+ interpreter, "reproducer",
+ "Commands to inspect and manipulate the reproducer functionality.",
+ "log <subcommand> [<command-options>]") {
LoadSubCommand(
"generate",
CommandObjectSP(new CommandObjectReproducerGenerate(interpreter)));
diff --git a/source/Commands/CommandObjectReproducer.h b/source/Commands/CommandObjectReproducer.h
index 6691e8a8e626d..ad377241f814c 100644
--- a/source/Commands/CommandObjectReproducer.h
+++ b/source/Commands/CommandObjectReproducer.h
@@ -1,9 +1,8 @@
//===-- CommandObjectReproducer.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectReproducer
-//-------------------------------------------------------------------------
class CommandObjectReproducer : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp
index 967a009189e44..55a0002c59973 100644
--- a/source/Commands/CommandObjectSettings.cpp
+++ b/source/Commands/CommandObjectSettings.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectSettings.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,15 +19,11 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectSettingsSet
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_settings_set_options[] = {
- // clang-format off
- { LLDB_OPT_SET_2, false, "global", 'g', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Apply the new value to the global default value." },
- { LLDB_OPT_SET_2, false, "force", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Force an empty value to be accepted as the default." }
- // clang-format on
+#define LLDB_OPTIONS_settings_set
+#include "CommandOptions.inc"
};
class CommandObjectSettingsSet : public CommandObjectRaw {
@@ -164,9 +159,8 @@ insert-before or insert-after.");
const char *setting_var_name =
request.GetParsedLine().GetArgumentAtIndex(setting_var_idx);
Status error;
- lldb::OptionValueSP value_sp(
- m_interpreter.GetDebugger().GetPropertyValue(
- &m_exe_ctx, setting_var_name, false, error));
+ lldb::OptionValueSP value_sp(GetDebugger().GetPropertyValue(
+ &m_exe_ctx, setting_var_name, false, error));
if (value_sp) {
value_sp->AutoComplete(m_interpreter, request);
}
@@ -205,7 +199,7 @@ protected:
// A missing value corresponds to clearing the setting when "force" is
// specified.
if (argc == 1 && m_options.m_force) {
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef()));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -223,8 +217,8 @@ protected:
Status error;
if (m_options.m_global) {
- error = m_interpreter.GetDebugger().SetPropertyValue(
- nullptr, eVarSetOperationAssign, var_name, var_value_cstr);
+ error = GetDebugger().SetPropertyValue(nullptr, eVarSetOperationAssign,
+ var_name, var_value_cstr);
}
if (error.Success()) {
@@ -235,8 +229,8 @@ protected:
// if we did not clear the command's exe_ctx first
ExecutionContext exe_ctx(m_exe_ctx);
m_exe_ctx.Clear();
- error = m_interpreter.GetDebugger().SetPropertyValue(
- &exe_ctx, eVarSetOperationAssign, var_name, var_value_cstr);
+ error = GetDebugger().SetPropertyValue(&exe_ctx, eVarSetOperationAssign,
+ var_name, var_value_cstr);
}
if (error.Fail()) {
@@ -254,9 +248,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsShow -- Show current values
-//-------------------------------------------------------------------------
class CommandObjectSettingsShow : public CommandObjectParsed {
public:
@@ -297,7 +289,7 @@ protected:
if (!args.empty()) {
for (const auto &arg : args) {
- Status error(m_interpreter.GetDebugger().DumpPropertyValue(
+ Status error(GetDebugger().DumpPropertyValue(
&m_exe_ctx, result.GetOutputStream(), arg.ref,
OptionValue::eDumpGroupValue));
if (error.Success()) {
@@ -308,23 +300,19 @@ protected:
}
}
} else {
- m_interpreter.GetDebugger().DumpAllPropertyValues(
- &m_exe_ctx, result.GetOutputStream(), OptionValue::eDumpGroupValue);
+ GetDebugger().DumpAllPropertyValues(&m_exe_ctx, result.GetOutputStream(),
+ OptionValue::eDumpGroupValue);
}
return result.Succeeded();
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsWrite -- Write settings to file
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_settings_write_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, true, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file into which to write the settings." },
- { LLDB_OPT_SET_ALL, false, "append",'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Append to saved settings file if it exists."},
- // clang-format on
+#define LLDB_OPTIONS_settings_write
+#include "CommandOptions.inc"
};
class CommandObjectSettingsWrite : public CommandObjectParsed {
@@ -422,13 +410,13 @@ protected:
ExecutionContext clean_ctx;
if (args.empty()) {
- m_interpreter.GetDebugger().DumpAllPropertyValues(
- &clean_ctx, out_file, OptionValue::eDumpGroupExport);
+ GetDebugger().DumpAllPropertyValues(&clean_ctx, out_file,
+ OptionValue::eDumpGroupExport);
return result.Succeeded();
}
for (const auto &arg : args) {
- Status error(m_interpreter.GetDebugger().DumpPropertyValue(
+ Status error(GetDebugger().DumpPropertyValue(
&clean_ctx, out_file, arg.ref, OptionValue::eDumpGroupExport));
if (!error.Success()) {
result.AppendError(error.AsCString());
@@ -443,14 +431,11 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsRead -- Read settings from file
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_settings_read_options[] = {
- // clang-format off
- {LLDB_OPT_SET_ALL, true, "file",'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eDiskFileCompletion, eArgTypeFilename, "The file from which to read the breakpoints." },
- // clang-format on
+#define LLDB_OPTIONS_settings_read
+#include "CommandOptions.inc"
};
class CommandObjectSettingsRead : public CommandObjectParsed {
@@ -511,6 +496,7 @@ protected:
options.SetAddToHistory(false);
options.SetEchoCommands(false);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetStopOnError(false);
m_interpreter.HandleCommandsFromFile(file, &clean_ctx, options, result);
return result.Succeeded();
@@ -520,9 +506,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsList -- List settable variables
-//-------------------------------------------------------------------------
class CommandObjectSettingsList : public CommandObjectParsed {
public:
@@ -576,7 +560,7 @@ protected:
const char *property_path = args.GetArgumentAtIndex(i);
const Property *property =
- m_interpreter.GetDebugger().GetValueProperties()->GetPropertyAtPath(
+ GetDebugger().GetValueProperties()->GetPropertyAtPath(
&m_exe_ctx, will_modify, property_path);
if (property) {
@@ -589,17 +573,15 @@ protected:
}
}
} else {
- m_interpreter.GetDebugger().DumpAllDescriptions(m_interpreter,
- result.GetOutputStream());
+ GetDebugger().DumpAllDescriptions(m_interpreter,
+ result.GetOutputStream());
}
return result.Succeeded();
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsRemove
-//-------------------------------------------------------------------------
class CommandObjectSettingsRemove : public CommandObjectRaw {
public:
@@ -685,7 +667,7 @@ protected:
const char *var_value_cstr =
Args::StripSpaces(var_value_string, true, true, false);
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationRemove, var_name, var_value_cstr));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -697,9 +679,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsReplace
-//-------------------------------------------------------------------------
class CommandObjectSettingsReplace : public CommandObjectRaw {
public:
@@ -787,7 +767,7 @@ protected:
const char *var_value_cstr =
Args::StripSpaces(var_value_string, true, true, false);
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationReplace, var_name, var_value_cstr));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -801,9 +781,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsInsertBefore
-//-------------------------------------------------------------------------
class CommandObjectSettingsInsertBefore : public CommandObjectRaw {
public:
@@ -895,7 +873,7 @@ protected:
const char *var_value_cstr =
Args::StripSpaces(var_value_string, true, true, false);
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationInsertBefore, var_name, var_value_cstr));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -907,9 +885,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingInsertAfter
-//-------------------------------------------------------------------------
class CommandObjectSettingsInsertAfter : public CommandObjectRaw {
public:
@@ -1000,7 +976,7 @@ protected:
const char *var_value_cstr =
Args::StripSpaces(var_value_string, true, true, false);
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationInsertAfter, var_name, var_value_cstr));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -1012,9 +988,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsAppend
-//-------------------------------------------------------------------------
class CommandObjectSettingsAppend : public CommandObjectRaw {
public:
@@ -1096,7 +1070,7 @@ protected:
const char *var_value_cstr =
Args::StripSpaces(var_value_string, true, true, false);
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationAppend, var_name, var_value_cstr));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -1108,9 +1082,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectSettingsClear
-//-------------------------------------------------------------------------
class CommandObjectSettingsClear : public CommandObjectParsed {
public:
@@ -1166,7 +1138,7 @@ protected:
return false;
}
- Status error(m_interpreter.GetDebugger().SetPropertyValue(
+ Status error(GetDebugger().SetPropertyValue(
&m_exe_ctx, eVarSetOperationClear, var_name, llvm::StringRef()));
if (error.Fail()) {
result.AppendError(error.AsCString());
@@ -1178,9 +1150,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectMultiwordSettings
-//-------------------------------------------------------------------------
CommandObjectMultiwordSettings::CommandObjectMultiwordSettings(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectSettings.h b/source/Commands/CommandObjectSettings.h
index df13386004568..730425953ea70 100644
--- a/source/Commands/CommandObjectSettings.h
+++ b/source/Commands/CommandObjectSettings.h
@@ -1,9 +1,8 @@
//===-- CommandObjectSettings.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordSettings
-//-------------------------------------------------------------------------
class CommandObjectMultiwordSettings : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp
index 2fce34f9846ef..1b515d0f1099c 100644
--- a/source/Commands/CommandObjectSource.cpp
+++ b/source/Commands/CommandObjectSource.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectSource.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,9 +32,7 @@ using namespace lldb;
using namespace lldb_private;
#pragma mark CommandObjectSourceInfo
-//----------------------------------------------------------------------
// CommandObjectSourceInfo - debug line entries dumping command
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_source_info_options[] = {
// clang-format off
@@ -195,7 +192,7 @@ protected:
continue;
// Print a new header if the module changed.
- const ConstString &module_file_name =
+ ConstString module_file_name =
module->GetFileSpec().GetFilename();
assert(module_file_name);
if (module_file_name != last_module_file_name) {
@@ -241,8 +238,8 @@ protected:
// Dump all matching lines at or above start_line for the file in the
// CU.
- const ConstString &file_spec_name = file_spec.GetFilename();
- const ConstString &module_file_name =
+ ConstString file_spec_name = file_spec.GetFilename();
+ ConstString module_file_name =
module->GetFileSpec().GetFilename();
bool cu_header_printed = false;
uint32_t line = start_line;
@@ -575,7 +572,7 @@ protected:
Target *target = m_exe_ctx.GetTargetPtr();
if (target == nullptr) {
- target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command.");
@@ -645,9 +642,7 @@ protected:
};
#pragma mark CommandObjectSourceList
-//-------------------------------------------------------------------------
// CommandObjectSourceList
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_source_list_options[] = {
// clang-format off
@@ -781,7 +776,7 @@ protected:
ConstString function;
LineEntry line_entry;
- SourceInfo(const ConstString &name, const LineEntry &line_entry)
+ SourceInfo(ConstString name, const LineEntry &line_entry)
: function(name), line_entry(line_entry) {}
SourceInfo() : function(), line_entry() {}
@@ -902,7 +897,7 @@ protected:
// these somewhere, there should probably be a module-filter-list that can be
// passed to the various ModuleList::Find* calls, which would either be a
// vector of string names or a ModuleSpecList.
- size_t FindMatchingFunctions(Target *target, const ConstString &name,
+ size_t FindMatchingFunctions(Target *target, ConstString name,
SymbolContextList &sc_list) {
// Displaying the source for a symbol:
bool include_inlines = true;
@@ -935,7 +930,7 @@ protected:
return num_matches;
}
- size_t FindMatchingFunctionSymbols(Target *target, const ConstString &name,
+ size_t FindMatchingFunctionSymbols(Target *target, ConstString name,
SymbolContextList &sc_list) {
size_t num_matches = 0;
const size_t num_modules = m_options.modules.size();
@@ -1137,8 +1132,7 @@ protected:
m_options.num_lines >= 10 ? 5 : m_options.num_lines / 2;
const uint32_t column =
- (m_interpreter.GetDebugger().GetStopShowColumn() !=
- eStopShowColumnNone)
+ (GetDebugger().GetStopShowColumn() != eStopShowColumnNone)
? sc.line_entry.column
: 0;
target->GetSourceManager().DisplaySourceLinesWithLineNumbers(
@@ -1293,9 +1287,7 @@ protected:
};
#pragma mark CommandObjectMultiwordSource
-//-------------------------------------------------------------------------
// CommandObjectMultiwordSource
-//-------------------------------------------------------------------------
CommandObjectMultiwordSource::CommandObjectMultiwordSource(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectSource.h b/source/Commands/CommandObjectSource.h
index b2553832210d6..d72122d55dc74 100644
--- a/source/Commands/CommandObjectSource.h
+++ b/source/Commands/CommandObjectSource.h
@@ -1,10 +1,9 @@
//===-- CommandObjectSource.h.h -----------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordSource
-//-------------------------------------------------------------------------
class CommandObjectMultiwordSource : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectStats.cpp b/source/Commands/CommandObjectStats.cpp
index 9225a94b70d38..a73c2a8e04094 100644
--- a/source/Commands/CommandObjectStats.cpp
+++ b/source/Commands/CommandObjectStats.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectStats.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectStats.h b/source/Commands/CommandObjectStats.h
index 3c5c2c04db1f6..27e9a6ff865a2 100644
--- a/source/Commands/CommandObjectStats.h
+++ b/source/Commands/CommandObjectStats.h
@@ -1,9 +1,8 @@
//===-- CommandObjectStats.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index ee55b22c5ea28..e913a28501f23 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectTarget.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "lldb/DataFormatters/ValueObjectPrinter.h"
#include "lldb/Host/OptionParser.h"
#include "lldb/Host/StringConvert.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "lldb/Interpreter/OptionArgParser.h"
@@ -36,6 +34,7 @@
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
@@ -202,9 +201,7 @@ private:
#pragma mark CommandObjectTargetCreate
-//-------------------------------------------------------------------------
// "target create"
-//-------------------------------------------------------------------------
class CommandObjectTargetCreate : public CommandObjectParsed {
public:
@@ -317,7 +314,7 @@ protected:
bool must_set_platform_path = false;
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = GetDebugger();
TargetSP target_sp;
llvm::StringRef arch_cstr = m_arch_option.GetArchitectureName();
@@ -396,7 +393,8 @@ protected:
debugger.GetTargetList().SetSelectedTarget(target_sp.get());
if (must_set_platform_path) {
ModuleSpec main_module_spec(file_spec);
- ModuleSP module_sp = target_sp->GetSharedModule(main_module_spec);
+ ModuleSP module_sp = target_sp->GetOrCreateModule(main_module_spec,
+ true /* notify */);
if (module_sp)
module_sp->SetPlatformFileSpec(remote_file);
}
@@ -412,11 +410,10 @@ protected:
}
FileSpec core_file_dir;
core_file_dir.GetDirectory() = core_file.GetDirectory();
- target_sp->GetExecutableSearchPaths().Append(core_file_dir);
+ target_sp->AppendExecutableSearchPaths(core_file_dir);
ProcessSP process_sp(target_sp->CreateProcess(
- m_interpreter.GetDebugger().GetListener(), llvm::StringRef(),
- &core_file));
+ GetDebugger().GetListener(), llvm::StringRef(), &core_file));
if (process_sp) {
// Seems weird that we Launch a core file, but that is what we
@@ -476,9 +473,7 @@ private:
#pragma mark CommandObjectTargetList
-//----------------------------------------------------------------------
// "target list"
-//----------------------------------------------------------------------
class CommandObjectTargetList : public CommandObjectParsed {
public:
@@ -496,7 +491,7 @@ protected:
Stream &strm = result.GetOutputStream();
bool show_stopped_process_status = false;
- if (DumpTargetList(m_interpreter.GetDebugger().GetTargetList(),
+ if (DumpTargetList(GetDebugger().GetTargetList(),
show_stopped_process_status, strm) == 0) {
strm.PutCString("No targets.\n");
}
@@ -511,9 +506,7 @@ protected:
#pragma mark CommandObjectTargetSelect
-//----------------------------------------------------------------------
// "target select"
-//----------------------------------------------------------------------
class CommandObjectTargetSelect : public CommandObjectParsed {
public:
@@ -533,7 +526,7 @@ protected:
uint32_t target_idx =
StringConvert::ToUInt32(target_idx_arg, UINT32_MAX, 0, &success);
if (success) {
- TargetList &target_list = m_interpreter.GetDebugger().GetTargetList();
+ TargetList &target_list = GetDebugger().GetTargetList();
const uint32_t num_targets = target_list.GetNumTargets();
if (target_idx < num_targets) {
TargetSP target_sp(target_list.GetTargetAtIndex(target_idx));
@@ -576,9 +569,7 @@ protected:
#pragma mark CommandObjectTargetSelect
-//----------------------------------------------------------------------
// "target delete"
-//----------------------------------------------------------------------
class CommandObjectTargetDelete : public CommandObjectParsed {
public:
@@ -611,7 +602,7 @@ protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
const size_t argc = args.GetArgumentCount();
std::vector<TargetSP> delete_target_list;
- TargetList &target_list = m_interpreter.GetDebugger().GetTargetList();
+ TargetList &target_list = GetDebugger().GetTargetList();
TargetSP target_sp;
if (m_all_option.GetOptionValue()) {
@@ -689,9 +680,7 @@ protected:
#pragma mark CommandObjectTargetVariable
-//----------------------------------------------------------------------
// "target variable"
-//----------------------------------------------------------------------
class CommandObjectTargetVariable : public CommandObjectParsed {
static const uint32_t SHORT_OPTION_FILE = 0x66696c65; // 'file'
@@ -1064,7 +1053,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target) {
const size_t argc = command.GetArgumentCount();
if (argc & 1) {
@@ -1118,7 +1107,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target) {
bool notify = true;
target->GetImageSearchPathList().Clear(notify);
@@ -1179,7 +1168,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target) {
size_t argc = command.GetArgumentCount();
// check for at least 3 arguments and an odd number of parameters
@@ -1247,7 +1236,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target) {
if (command.GetArgumentCount() != 0) {
result.AppendError("list takes no arguments\n");
@@ -1293,7 +1282,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target) {
if (command.GetArgumentCount() != 1) {
result.AppendError("query requires one argument\n");
@@ -1317,9 +1306,7 @@ protected:
}
};
-//----------------------------------------------------------------------
// Static Helper functions
-//----------------------------------------------------------------------
static void DumpModuleArchitecture(Stream &strm, Module *module,
bool full_triple, uint32_t width) {
if (module) {
@@ -1348,7 +1335,7 @@ static void DumpModuleUUID(Stream &strm, Module *module) {
static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter,
Stream &strm, Module *module,
const FileSpec &file_spec,
- bool load_addresses) {
+ lldb::DescriptionLevel desc_level) {
uint32_t num_matches = 0;
if (module) {
SymbolContextList sc_list;
@@ -1367,7 +1354,7 @@ static uint32_t DumpCompileUnitLineTable(CommandInterpreter &interpreter,
if (line_table)
line_table->GetDescription(
&strm, interpreter.GetExecutionContext().GetTargetPtr(),
- lldb::eDescriptionLevelBrief);
+ desc_level);
else
strm << "No line table";
}
@@ -1829,10 +1816,8 @@ static size_t FindModulesByName(Target *target, const char *module_name,
#pragma mark CommandObjectTargetModulesModuleAutoComplete
-//----------------------------------------------------------------------
// A base command object class that can auto complete with module file
// paths
-//----------------------------------------------------------------------
class CommandObjectTargetModulesModuleAutoComplete
: public CommandObjectParsed {
@@ -1871,10 +1856,8 @@ public:
#pragma mark CommandObjectTargetModulesSourceFileAutoComplete
-//----------------------------------------------------------------------
// A base command object class that can auto complete with module source
// file paths
-//----------------------------------------------------------------------
class CommandObjectTargetModulesSourceFileAutoComplete
: public CommandObjectParsed {
@@ -1925,7 +1908,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -1984,9 +1967,8 @@ static constexpr OptionEnumValueElement g_sort_option_enumeration[] = {
{eSortOrderByName, "name", "Sort output by symbol name."} };
static constexpr OptionDefinition g_target_modules_dump_symtab_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "sort", 's', OptionParser::eRequiredArgument, nullptr, OptionEnumValues(g_sort_option_enumeration), 0, eArgTypeSortOrder, "Supply a sort order when dumping the symbol table." }
- // clang-format on
+#define LLDB_OPTIONS_target_modules_dump_symtab
+#include "CommandOptions.inc"
};
class CommandObjectTargetModulesDumpSymtab
@@ -2041,7 +2023,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -2126,9 +2108,7 @@ protected:
#pragma mark CommandObjectTargetModulesDumpSections
-//----------------------------------------------------------------------
// Image section dumping command
-//----------------------------------------------------------------------
class CommandObjectTargetModulesDumpSections
: public CommandObjectTargetModulesModuleAutoComplete {
@@ -2144,7 +2124,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -2221,9 +2201,7 @@ protected:
#pragma mark CommandObjectTargetModulesDumpSections
-//----------------------------------------------------------------------
// Clang AST dumping command
-//----------------------------------------------------------------------
class CommandObjectTargetModulesDumpClangAST
: public CommandObjectTargetModulesModuleAutoComplete {
@@ -2239,7 +2217,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -2300,9 +2278,7 @@ protected:
#pragma mark CommandObjectTargetModulesDumpSymfile
-//----------------------------------------------------------------------
// Image debug symbol dumping command
-//----------------------------------------------------------------------
class CommandObjectTargetModulesDumpSymfile
: public CommandObjectTargetModulesModuleAutoComplete {
@@ -2318,7 +2294,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -2391,9 +2367,7 @@ protected:
#pragma mark CommandObjectTargetModulesDumpLineTable
-//----------------------------------------------------------------------
// Image debug line table dumping command
-//----------------------------------------------------------------------
class CommandObjectTargetModulesDumpLineTable
: public CommandObjectTargetModulesSourceFileAutoComplete {
@@ -2406,6 +2380,8 @@ public:
~CommandObjectTargetModulesDumpLineTable() override = default;
+ Options *GetOptions() override { return &m_options; }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Target *target = m_exe_ctx.GetTargetPtr();
@@ -2438,8 +2414,9 @@ protected:
if (DumpCompileUnitLineTable(
m_interpreter, result.GetOutputStream(),
target_modules.GetModulePointerAtIndexUnlocked(i),
- file_spec, m_exe_ctx.GetProcessPtr() &&
- m_exe_ctx.GetProcessRef().IsAlive()))
+ file_spec,
+ m_options.m_verbose ? eDescriptionLevelFull
+ : eDescriptionLevelBrief))
num_dumped++;
}
if (num_dumped == 0)
@@ -2459,19 +2436,52 @@ protected:
}
return result.Succeeded();
}
+
+ class CommandOptions : public Options {
+ public:
+ CommandOptions() : Options() { OptionParsingStarting(nullptr); }
+
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ assert(option_idx == 0 && "We only have one option.");
+ m_verbose = true;
+
+ return Status();
+ }
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_verbose = false;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ static constexpr OptionDefinition g_options[] = {
+ {LLDB_OPT_SET_ALL,
+ false,
+ "verbose",
+ 'v',
+ OptionParser::eNoArgument,
+ nullptr,
+ {},
+ 0,
+ eArgTypeNone,
+ "Enable verbose dump."},
+ };
+ return llvm::makeArrayRef(g_options);
+ }
+
+ bool m_verbose;
+ };
+
+ CommandOptions m_options;
};
#pragma mark CommandObjectTargetModulesDump
-//----------------------------------------------------------------------
// Dump multi-word command for target modules
-//----------------------------------------------------------------------
class CommandObjectTargetModulesDump : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectTargetModulesDump(CommandInterpreter &interpreter)
: CommandObjectMultiword(
interpreter, "target modules dump",
@@ -2539,7 +2549,7 @@ protected:
OptionGroupFile m_symbol_file;
bool DoExecute(Args &args, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -2559,7 +2569,8 @@ protected:
module_spec.GetSymbolFileSpec() =
m_symbol_file.GetOptionValue().GetCurrentValue();
if (Symbols::DownloadObjectAndSymbolFile(module_spec)) {
- ModuleSP module_sp(target->GetSharedModule(module_spec));
+ ModuleSP module_sp(target->GetOrCreateModule(module_spec,
+ true /* notify */));
if (module_sp) {
result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
@@ -2621,7 +2632,8 @@ protected:
if (!module_spec.GetArchitecture().IsValid())
module_spec.GetArchitecture() = target->GetArchitecture();
Status error;
- ModuleSP module_sp(target->GetSharedModule(module_spec, &error));
+ ModuleSP module_sp(target->GetOrCreateModule(module_spec,
+ true /* notify */, &error));
if (!module_sp) {
const char *error_cstr = error.AsCString();
if (error_cstr)
@@ -2700,7 +2712,7 @@ public:
protected:
bool DoExecute(Args &args, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
const bool load = m_load_option.GetOptionValue().GetCurrentValue();
const bool set_pc = m_pc_option.GetOptionValue().GetCurrentValue();
if (target == nullptr) {
@@ -2955,9 +2967,7 @@ protected:
OptionGroupUInt64 m_slide_option;
};
-//----------------------------------------------------------------------
// List images with associated information
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_target_modules_list_options[] = {
// clang-format off
@@ -3037,7 +3047,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
const bool use_global_module_list = m_options.m_use_global_module_list;
// Define a local module list here to ensure it lives longer than any
// "locker" object which might lock its contents below (through the
@@ -3321,9 +3331,7 @@ protected:
#pragma mark CommandObjectTargetModulesShowUnwind
-//----------------------------------------------------------------------
// Lookup unwind information in images
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_target_modules_show_unwind_options[] = {
// clang-format off
@@ -3494,8 +3502,7 @@ protected:
start_addr = abi->FixCodeAddress(start_addr);
FuncUnwindersSP func_unwinders_sp(
- sc.module_sp->GetObjectFile()
- ->GetUnwindTable()
+ sc.module_sp->GetUnwindTable()
.GetUncachedFuncUnwindersContainingAddress(start_addr, sc));
if (!func_unwinders_sp)
continue;
@@ -3506,14 +3513,14 @@ protected:
funcname.AsCString(), start_addr);
UnwindPlanSP non_callsite_unwind_plan =
- func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread, -1);
+ func_unwinders_sp->GetUnwindPlanAtNonCallSite(*target, *thread);
if (non_callsite_unwind_plan) {
result.GetOutputStream().Printf(
"Asynchronous (not restricted to call-sites) UnwindPlan is '%s'\n",
non_callsite_unwind_plan->GetSourceName().AsCString());
}
UnwindPlanSP callsite_unwind_plan =
- func_unwinders_sp->GetUnwindPlanAtCallSite(*target, -1);
+ func_unwinders_sp->GetUnwindPlanAtCallSite(*target, *thread);
if (callsite_unwind_plan) {
result.GetOutputStream().Printf(
"Synchronous (restricted to call-sites) UnwindPlan is '%s'\n",
@@ -3530,7 +3537,7 @@ protected:
result.GetOutputStream().Printf("\n");
UnwindPlanSP assembly_sp =
- func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread, 0);
+ func_unwinders_sp->GetAssemblyUnwindPlan(*target, *thread);
if (assembly_sp) {
result.GetOutputStream().Printf(
"Assembly language inspection UnwindPlan:\n");
@@ -3540,7 +3547,7 @@ protected:
}
UnwindPlanSP ehframe_sp =
- func_unwinders_sp->GetEHFrameUnwindPlan(*target, 0);
+ func_unwinders_sp->GetEHFrameUnwindPlan(*target);
if (ehframe_sp) {
result.GetOutputStream().Printf("eh_frame UnwindPlan:\n");
ehframe_sp->Dump(result.GetOutputStream(), thread.get(),
@@ -3549,7 +3556,7 @@ protected:
}
UnwindPlanSP ehframe_augmented_sp =
- func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread, 0);
+ func_unwinders_sp->GetEHFrameAugmentedUnwindPlan(*target, *thread);
if (ehframe_augmented_sp) {
result.GetOutputStream().Printf("eh_frame augmented UnwindPlan:\n");
ehframe_augmented_sp->Dump(result.GetOutputStream(), thread.get(),
@@ -3558,7 +3565,7 @@ protected:
}
if (UnwindPlanSP plan_sp =
- func_unwinders_sp->GetDebugFrameUnwindPlan(*target, 0)) {
+ func_unwinders_sp->GetDebugFrameUnwindPlan(*target)) {
result.GetOutputStream().Printf("debug_frame UnwindPlan:\n");
plan_sp->Dump(result.GetOutputStream(), thread.get(),
LLDB_INVALID_ADDRESS);
@@ -3567,7 +3574,7 @@ protected:
if (UnwindPlanSP plan_sp =
func_unwinders_sp->GetDebugFrameAugmentedUnwindPlan(*target,
- *thread, 0)) {
+ *thread)) {
result.GetOutputStream().Printf("debug_frame augmented UnwindPlan:\n");
plan_sp->Dump(result.GetOutputStream(), thread.get(),
LLDB_INVALID_ADDRESS);
@@ -3575,7 +3582,7 @@ protected:
}
UnwindPlanSP arm_unwind_sp =
- func_unwinders_sp->GetArmUnwindUnwindPlan(*target, 0);
+ func_unwinders_sp->GetArmUnwindUnwindPlan(*target);
if (arm_unwind_sp) {
result.GetOutputStream().Printf("ARM.exidx unwind UnwindPlan:\n");
arm_unwind_sp->Dump(result.GetOutputStream(), thread.get(),
@@ -3583,8 +3590,16 @@ protected:
result.GetOutputStream().Printf("\n");
}
+ if (UnwindPlanSP symfile_plan_sp =
+ func_unwinders_sp->GetSymbolFileUnwindPlan(*thread)) {
+ result.GetOutputStream().Printf("Symbol file UnwindPlan:\n");
+ symfile_plan_sp->Dump(result.GetOutputStream(), thread.get(),
+ LLDB_INVALID_ADDRESS);
+ result.GetOutputStream().Printf("\n");
+ }
+
UnwindPlanSP compact_unwind_sp =
- func_unwinders_sp->GetCompactUnwindUnwindPlan(*target, 0);
+ func_unwinders_sp->GetCompactUnwindUnwindPlan(*target);
if (compact_unwind_sp) {
result.GetOutputStream().Printf("Compact unwind UnwindPlan:\n");
compact_unwind_sp->Dump(result.GetOutputStream(), thread.get(),
@@ -3627,9 +3642,7 @@ protected:
CommandOptions m_options;
};
-//----------------------------------------------------------------------
// Lookup information in images
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_target_modules_lookup_options[] = {
// clang-format off
@@ -3726,7 +3739,7 @@ public:
break;
case 'v':
- m_verbose = 1;
+ m_verbose = true;
break;
case 'A':
@@ -3922,7 +3935,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -4015,9 +4028,7 @@ protected:
#pragma mark CommandObjectMultiwordImageSearchPaths
-//-------------------------------------------------------------------------
// CommandObjectMultiwordImageSearchPaths
-//-------------------------------------------------------------------------
class CommandObjectTargetModulesImageSearchPaths
: public CommandObjectMultiword {
@@ -4050,15 +4061,11 @@ public:
#pragma mark CommandObjectTargetModules
-//-------------------------------------------------------------------------
// CommandObjectTargetModules
-//-------------------------------------------------------------------------
class CommandObjectTargetModules : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectTargetModules(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "target modules",
"Commands for accessing information for one or "
@@ -4087,9 +4094,7 @@ public:
~CommandObjectTargetModules() override = default;
private:
- //------------------------------------------------------------------
// For CommandObjectTargetModules only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(CommandObjectTargetModules);
};
@@ -4482,15 +4487,11 @@ protected:
#pragma mark CommandObjectTargetSymbols
-//-------------------------------------------------------------------------
// CommandObjectTargetSymbols
-//-------------------------------------------------------------------------
class CommandObjectTargetSymbols : public CommandObjectMultiword {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CommandObjectTargetSymbols(CommandInterpreter &interpreter)
: CommandObjectMultiword(
interpreter, "target symbols",
@@ -4503,21 +4504,17 @@ public:
~CommandObjectTargetSymbols() override = default;
private:
- //------------------------------------------------------------------
// For CommandObjectTargetModules only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(CommandObjectTargetSymbols);
};
#pragma mark CommandObjectTargetStopHookAdd
-//-------------------------------------------------------------------------
// CommandObjectTargetStopHookAdd
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_target_stop_hook_add_options[] = {
// clang-format off
- { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line breakpoint command inline. Be sure to surround it with quotes." },
+ { LLDB_OPT_SET_ALL, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Add a command for the stop hook. Can be specified more than once, and commands will be run in the order they appear." },
{ LLDB_OPT_SET_ALL, false, "shlib", 's', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eModuleCompletion, eArgTypeShlibName, "Set the module within which the stop-hook is to be run." },
{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "The stop hook is run only for the thread whose index matches this argument." },
{ LLDB_OPT_SET_ALL, false, "thread-id", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadID, "The stop hook is run only for the thread whose TID matches this argument." },
@@ -4528,6 +4525,7 @@ static constexpr OptionDefinition g_target_stop_hook_add_options[] = {
{ LLDB_OPT_SET_1, false, "end-line", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Set the end of the line range for which the stop-hook is to be run." },
{ LLDB_OPT_SET_2, false, "classname", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeClassName, "Specify the class within which the stop-hook is to be run." },
{ LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the function name within which the stop hook will be run." },
+ { LLDB_OPT_SET_ALL, false, "auto-continue",'G', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "The breakpoint will auto-continue after running its commands." },
// clang-format on
};
@@ -4568,6 +4566,17 @@ public:
m_sym_ctx_specified = true;
break;
+ case 'G': {
+ bool value, success;
+ value = OptionArgParser::ToBoolean(option_arg, false, &success);
+ if (success) {
+ m_auto_continue = value;
+ } else
+ error.SetErrorStringWithFormat(
+ "invalid boolean value '%s' passed for -G option",
+ option_arg.str().c_str());
+ }
+ break;
case 'l':
if (option_arg.getAsInteger(0, m_line_start)) {
error.SetErrorStringWithFormat("invalid start line number: \"%s\"",
@@ -4623,7 +4632,7 @@ public:
case 'o':
m_use_one_liner = true;
- m_one_liner = option_arg;
+ m_one_liner.push_back(option_arg);
break;
default:
@@ -4652,6 +4661,7 @@ public:
m_use_one_liner = false;
m_one_liner.clear();
+ m_auto_continue = false;
}
std::string m_class_name;
@@ -4670,7 +4680,8 @@ public:
bool m_thread_specified;
// Instance variables to hold the values for one_liner options.
bool m_use_one_liner;
- std::string m_one_liner;
+ std::vector<std::string> m_one_liner;
+ bool m_auto_continue;
};
CommandObjectTargetStopHookAdd(CommandInterpreter &interpreter)
@@ -4686,9 +4697,9 @@ public:
Options *GetOptions() override { return &m_options; }
protected:
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(
"Enter your stop hook command(s). Type 'DONE' to end.\n");
output_sp->Flush();
@@ -4706,7 +4717,7 @@ protected:
m_stop_hook_sp->GetID());
error_sp->Flush();
}
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target)
target->RemoveStopHookByID(m_stop_hook_sp->GetID());
} else {
@@ -4731,49 +4742,49 @@ protected:
Target::StopHookSP new_hook_sp = target->CreateStopHook();
// First step, make the specifier.
- std::unique_ptr<SymbolContextSpecifier> specifier_ap;
+ std::unique_ptr<SymbolContextSpecifier> specifier_up;
if (m_options.m_sym_ctx_specified) {
- specifier_ap.reset(new SymbolContextSpecifier(
- m_interpreter.GetDebugger().GetSelectedTarget()));
+ specifier_up.reset(
+ new SymbolContextSpecifier(GetDebugger().GetSelectedTarget()));
if (!m_options.m_module_name.empty()) {
- specifier_ap->AddSpecification(
+ specifier_up->AddSpecification(
m_options.m_module_name.c_str(),
SymbolContextSpecifier::eModuleSpecified);
}
if (!m_options.m_class_name.empty()) {
- specifier_ap->AddSpecification(
+ specifier_up->AddSpecification(
m_options.m_class_name.c_str(),
SymbolContextSpecifier::eClassOrNamespaceSpecified);
}
if (!m_options.m_file_name.empty()) {
- specifier_ap->AddSpecification(
+ specifier_up->AddSpecification(
m_options.m_file_name.c_str(),
SymbolContextSpecifier::eFileSpecified);
}
if (m_options.m_line_start != 0) {
- specifier_ap->AddLineSpecification(
+ specifier_up->AddLineSpecification(
m_options.m_line_start,
SymbolContextSpecifier::eLineStartSpecified);
}
if (m_options.m_line_end != UINT_MAX) {
- specifier_ap->AddLineSpecification(
+ specifier_up->AddLineSpecification(
m_options.m_line_end, SymbolContextSpecifier::eLineEndSpecified);
}
if (!m_options.m_function_name.empty()) {
- specifier_ap->AddSpecification(
+ specifier_up->AddSpecification(
m_options.m_function_name.c_str(),
SymbolContextSpecifier::eFunctionSpecified);
}
}
- if (specifier_ap)
- new_hook_sp->SetSpecifier(specifier_ap.release());
+ if (specifier_up)
+ new_hook_sp->SetSpecifier(specifier_up.release());
// Next see if any of the thread options have been entered:
@@ -4795,10 +4806,13 @@ protected:
new_hook_sp->SetThreadSpecifier(thread_spec);
}
+
+ new_hook_sp->SetAutoContinue(m_options.m_auto_continue);
if (m_options.m_use_one_liner) {
- // Use one-liner.
- new_hook_sp->GetCommandPointer()->AppendString(
- m_options.m_one_liner.c_str());
+ // Use one-liners.
+ for (auto cmd : m_options.m_one_liner)
+ new_hook_sp->GetCommandPointer()->AppendString(
+ cmd.c_str());
result.AppendMessageWithFormat("Stop hook #%" PRIu64 " added.\n",
new_hook_sp->GetID());
} else {
@@ -4826,9 +4840,7 @@ private:
#pragma mark CommandObjectTargetStopHookDelete
-//-------------------------------------------------------------------------
// CommandObjectTargetStopHookDelete
-//-------------------------------------------------------------------------
class CommandObjectTargetStopHookDelete : public CommandObjectParsed {
public:
@@ -4884,9 +4896,7 @@ protected:
#pragma mark CommandObjectTargetStopHookEnableDisable
-//-------------------------------------------------------------------------
// CommandObjectTargetStopHookEnableDisable
-//-------------------------------------------------------------------------
class CommandObjectTargetStopHookEnableDisable : public CommandObjectParsed {
public:
@@ -4941,9 +4951,7 @@ private:
#pragma mark CommandObjectTargetStopHookList
-//-------------------------------------------------------------------------
// CommandObjectTargetStopHookList
-//-------------------------------------------------------------------------
class CommandObjectTargetStopHookList : public CommandObjectParsed {
public:
@@ -4982,9 +4990,7 @@ protected:
#pragma mark CommandObjectMultiwordTargetStopHooks
-//-------------------------------------------------------------------------
// CommandObjectMultiwordTargetStopHooks
-//-------------------------------------------------------------------------
class CommandObjectMultiwordTargetStopHooks : public CommandObjectMultiword {
public:
@@ -5015,9 +5021,7 @@ public:
#pragma mark CommandObjectMultiwordTarget
-//-------------------------------------------------------------------------
// CommandObjectMultiwordTarget
-//-------------------------------------------------------------------------
CommandObjectMultiwordTarget::CommandObjectMultiwordTarget(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectTarget.h b/source/Commands/CommandObjectTarget.h
index 643ce547dcb62..86d554c8a3101 100644
--- a/source/Commands/CommandObjectTarget.h
+++ b/source/Commands/CommandObjectTarget.h
@@ -1,9 +1,8 @@
//===-- CommandObjectTarget.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordTarget
-//-------------------------------------------------------------------------
class CommandObjectMultiwordTarget : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index e792887d4ff37..ed7cf0a1a48d7 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectThread.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,9 +37,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectIterateOverThreads
-//-------------------------------------------------------------------------
class CommandObjectIterateOverThreads : public CommandObjectParsed {
@@ -239,16 +236,11 @@ protected:
bool m_add_return = true;
};
-//-------------------------------------------------------------------------
// CommandObjectThreadBacktrace
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_thread_backtrace_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "How many frames to display (-1 for all)" },
- { LLDB_OPT_SET_1, false, "start", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame in which to start the backtrace" },
- { LLDB_OPT_SET_1, false, "extended", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Show the extended backtrace, if available" }
- // clang-format on
+#define LLDB_OPTIONS_thread_backtrace
+#include "CommandOptions.inc"
};
class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads {
@@ -322,7 +314,10 @@ public:
"indexes can be specified as arguments.\n"
"Use the thread-index \"all\" to see all threads.\n"
"Use the thread-index \"unique\" to see threads grouped by unique "
- "call stacks.",
+ "call stacks.\n"
+ "Use 'settings set frame-format' to customize the printing of "
+ "frames in the backtrace and 'settings set thread-format' to "
+ "customize the thread header.",
nullptr,
eCommandRequiresProcess | eCommandRequiresThread |
eCommandTryTargetAPILock | eCommandProcessMustBeLaunched |
@@ -409,16 +404,8 @@ static constexpr OptionEnumValues TriRunningModes() {
}
static constexpr OptionDefinition g_thread_step_scope_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "step-in-avoids-no-debug", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value that sets whether stepping into functions will step over functions with no debug information." },
- { LLDB_OPT_SET_1, false, "step-out-avoids-no-debug", 'A', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "A boolean value, if true stepping out of functions will continue to step out till it hits a function with debug information." },
- { LLDB_OPT_SET_1, false, "count", 'c', OptionParser::eRequiredArgument, nullptr, {}, 1, eArgTypeCount, "How many times to perform the stepping operation - currently only supported for step-inst and next-inst." },
- { LLDB_OPT_SET_1, false, "end-linenumber", 'e', OptionParser::eRequiredArgument, nullptr, {}, 1, eArgTypeLineNum, "The line at which to stop stepping - defaults to the next line and only supported for step-in and step-over. You can also pass the string 'block' to step to the end of the current block. This is particularly useful in conjunction with --step-target to step through a complex calling sequence." },
- { LLDB_OPT_SET_1, false, "run-mode", 'm', OptionParser::eRequiredArgument, nullptr, TriRunningModes(), 0, eArgTypeRunMode, "Determine how to run other threads while stepping the current thread." },
- { LLDB_OPT_SET_1, false, "step-over-regexp", 'r', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeRegularExpression, "A regular expression that defines function names to not to stop at when stepping in." },
- { LLDB_OPT_SET_1, false, "step-in-target", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFunctionName, "The name of the directly called function step in should stop at when stepping into." },
- { LLDB_OPT_SET_2, false, "python-class", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "The name of the class that will manage this step - only supported for Scripted Step." }
- // clang-format on
+#define LLDB_OPTIONS_thread_step_scope
+#include "CommandOptions.inc"
};
class CommandObjectThreadStepWithTypeAndScope : public CommandObjectParsed {
@@ -484,7 +471,7 @@ public:
case 'e':
if (option_arg == "block") {
- m_end_line_is_block_end = 1;
+ m_end_line_is_block_end = true;
break;
}
if (option_arg.getAsInteger(0, m_end_line))
@@ -617,7 +604,7 @@ protected:
result.AppendErrorWithFormat("empty class name for scripted step.");
result.SetStatus(eReturnStatusFailed);
return false;
- } else if (!m_interpreter.GetScriptInterpreter()->CheckObjectExists(
+ } else if (!GetDebugger().GetScriptInterpreter()->CheckObjectExists(
m_options.m_class_name.c_str())) {
result.AppendErrorWithFormat(
"class for scripted step: \"%s\" does not exist.",
@@ -808,9 +795,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectThreadContinue
-//-------------------------------------------------------------------------
class CommandObjectThreadContinue : public CommandObjectParsed {
public:
@@ -843,7 +828,7 @@ public:
bool DoExecute(Args &command, CommandReturnObject &result) override {
bool synchronous_execution = m_interpreter.GetSynchronous();
- if (!m_interpreter.GetDebugger().GetSelectedTarget()) {
+ if (!GetDebugger().GetSelectedTarget()) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
result.SetStatus(eReturnStatusFailed);
@@ -988,9 +973,7 @@ public:
}
};
-//-------------------------------------------------------------------------
// CommandObjectThreadUntil
-//-------------------------------------------------------------------------
static constexpr OptionEnumValueElement g_duo_running_mode[] = {
{eOnlyThisThread, "this-thread", "Run only this thread"},
@@ -1001,12 +984,8 @@ static constexpr OptionEnumValues DuoRunningModes() {
}
static constexpr OptionDefinition g_thread_until_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "frame", 'f', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeFrameIndex, "Frame index for until operation - defaults to 0" },
- { LLDB_OPT_SET_1, false, "thread", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeThreadIndex, "Thread index for the thread for until operation" },
- { LLDB_OPT_SET_1, false, "run-mode",'m', OptionParser::eRequiredArgument, nullptr, DuoRunningModes(), 0, eArgTypeRunMode, "Determine how to run other threads while stepping this one" },
- { LLDB_OPT_SET_1, false, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Run until we reach the specified address, or leave the function - can be specified multiple times." }
- // clang-format on
+#define LLDB_OPTIONS_thread_until
+#include "CommandOptions.inc"
};
class CommandObjectThreadUntil : public CommandObjectParsed {
@@ -1125,7 +1104,7 @@ protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
bool synchronous_execution = m_interpreter.GetSynchronous();
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("invalid target, create a debug target using the "
"'target create' command");
@@ -1329,9 +1308,7 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectThreadSelect
-//-------------------------------------------------------------------------
class CommandObjectThreadSelect : public CommandObjectParsed {
public:
@@ -1392,16 +1369,16 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectThreadList
-//-------------------------------------------------------------------------
class CommandObjectThreadList : public CommandObjectParsed {
public:
CommandObjectThreadList(CommandInterpreter &interpreter)
: CommandObjectParsed(
interpreter, "thread list",
- "Show a summary of each thread in the current target process.",
+ "Show a summary of each thread in the current target process. "
+ "Use 'settings set thread-format' to customize the individual "
+ "thread listings.",
"thread list",
eCommandRequiresProcess | eCommandTryTargetAPILock |
eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
@@ -1424,15 +1401,11 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectThreadInfo
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_thread_info_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "json", 'j', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the thread info in JSON format." },
- { LLDB_OPT_SET_ALL, false, "stop-info", 's', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display the extended stop info in JSON format." }
- // clang-format on
+#define LLDB_OPTIONS_thread_info
+#include "CommandOptions.inc"
};
class CommandObjectThreadInfo : public CommandObjectIterateOverThreads {
@@ -1519,9 +1492,7 @@ public:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectThreadException
-//-------------------------------------------------------------------------
class CommandObjectThreadException : public CommandObjectIterateOverThreads {
public:
@@ -1564,14 +1535,11 @@ class CommandObjectThreadException : public CommandObjectIterateOverThreads {
}
};
-//-------------------------------------------------------------------------
// CommandObjectThreadReturn
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_thread_return_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "from-expression", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Return from the innermost expression evaluation." }
- // clang-format on
+#define LLDB_OPTIONS_thread_return
+#include "CommandOptions.inc"
};
class CommandObjectThreadReturn : public CommandObjectRaw {
@@ -1742,18 +1710,11 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectThreadJump
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_thread_jump_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "file", 'f', OptionParser::eRequiredArgument, nullptr, {}, CommandCompletions::eSourceFileCompletion, eArgTypeFilename, "Specifies the source file to jump to." },
- { LLDB_OPT_SET_1, true, "line", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLineNum, "Specifies the line number to jump to." },
- { LLDB_OPT_SET_2, true, "by", 'b', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOffset, "Jumps by a relative line offset from the current line." },
- { LLDB_OPT_SET_3, true, "address", 'a', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, "Jumps to a specific address." },
- { LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "force", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Allows the PC to leave the current function." }
- // clang-format on
+#define LLDB_OPTIONS_thread_jump
+#include "CommandOptions.inc"
};
class CommandObjectThreadJump : public CommandObjectParsed {
@@ -1890,19 +1851,13 @@ protected:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// Next are the subcommands of CommandObjectMultiwordThreadPlan
-//-------------------------------------------------------------------------
-//-------------------------------------------------------------------------
// CommandObjectThreadPlanList
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_thread_plan_list_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display more information about the thread plans" },
- { LLDB_OPT_SET_1, false, "internal", 'i', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display internal as well as user thread plans" }
- // clang-format on
+#define LLDB_OPTIONS_thread_plan_list
+#include "CommandOptions.inc"
};
class CommandObjectThreadPlanList : public CommandObjectIterateOverThreads {
@@ -2062,9 +2017,7 @@ public:
}
};
-//-------------------------------------------------------------------------
// CommandObjectMultiwordThreadPlan
-//-------------------------------------------------------------------------
class CommandObjectMultiwordThreadPlan : public CommandObjectMultiword {
public:
@@ -2083,9 +2036,7 @@ public:
~CommandObjectMultiwordThreadPlan() override = default;
};
-//-------------------------------------------------------------------------
// CommandObjectMultiwordThread
-//-------------------------------------------------------------------------
CommandObjectMultiwordThread::CommandObjectMultiwordThread(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectThread.h b/source/Commands/CommandObjectThread.h
index 5da31cec58e1a..77729ceecd631 100644
--- a/source/Commands/CommandObjectThread.h
+++ b/source/Commands/CommandObjectThread.h
@@ -1,9 +1,8 @@
//===-- CommandObjectThread.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectType.cpp b/source/Commands/CommandObjectType.cpp
index 815e563197b0c..98a43f50b1b1f 100644
--- a/source/Commands/CommandObjectType.cpp
+++ b/source/Commands/CommandObjectType.cpp
@@ -1,18 +1,13 @@
//===-- CommandObjectType.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "CommandObjectType.h"
-#include <algorithm>
-#include <cctype>
-#include <functional>
-
#include "lldb/Core/Debugger.h"
#include "lldb/Core/IOHandler.h"
#include "lldb/DataFormatters/DataVisualization.h"
@@ -40,6 +35,11 @@
#include "llvm/ADT/STLExtras.h"
+#include <algorithm>
+#include <cctype>
+#include <functional>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -52,7 +52,7 @@ public:
std::string m_category;
ScriptAddOptions(const TypeSummaryImpl::Flags &flags, bool regx,
- const ConstString &name, std::string catg)
+ ConstString name, std::string catg)
: m_flags(flags), m_regex(regx), m_name(name), m_category(catg) {}
typedef std::shared_ptr<ScriptAddOptions> SharedPointer;
@@ -96,23 +96,8 @@ static bool WarnOnPotentialUnquotedUnsignedType(Args &command,
}
static constexpr OptionDefinition g_type_summary_add_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
- { LLDB_OPT_SET_ALL, false, "no-value", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't show the value, just show the summary, for this type." },
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." },
- { LLDB_OPT_SET_1, true, "inline-children", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, inline all child values into summary string." },
- { LLDB_OPT_SET_1, false, "omit-names", 'O', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If true, omit value names in the summary display." },
- { LLDB_OPT_SET_2, true, "summary-string", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeSummaryString, "Summary string used to display text and object contents." },
- { LLDB_OPT_SET_3, false, "python-script", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonScript, "Give a one-liner Python script as part of the command." },
- { LLDB_OPT_SET_3, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to use for this type." },
- { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Input Python code to use for this type manually." },
- { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "expand", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Expand aggregate data types to show children on separate lines." },
- { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "hide-empty", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Do not expand aggregate data types with no children." },
- { LLDB_OPT_SET_2 | LLDB_OPT_SET_3, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "A name for this summary string." }
- // clang-format on
+#define LLDB_OPTIONS_type_summary_add
+#include "CommandOptions.inc"
};
class CommandObjectTypeSummaryAdd : public CommandObjectParsed,
@@ -160,7 +145,7 @@ public:
~CommandObjectTypeSummaryAdd() override = default;
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
static const char *g_summary_addreader_instructions =
"Enter your Python command(s). Type 'DONE' to end.\n"
"def function (valobj,internal_dict):\n"
@@ -169,7 +154,7 @@ public:
" internal_dict: an LLDB support object not to be used\"\"\"\n";
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(g_summary_addreader_instructions);
output_sp->Flush();
}
@@ -180,7 +165,7 @@ public:
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
StringList lines;
lines.SplitIntoLines(data);
@@ -192,7 +177,7 @@ public:
options_ptr); // this will ensure that we get rid of the pointer
// when going out of scope
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
std::string funct_name_str;
if (interpreter->GenerateTypeScriptFunction(lines,
@@ -206,9 +191,9 @@ public:
// for every type in the list
TypeSummaryImplSP script_format;
- script_format.reset(new ScriptSummaryFormat(
+ script_format = std::make_shared<ScriptSummaryFormat>(
options->m_flags, funct_name_str.c_str(),
- lines.CopyList(" ").c_str()));
+ lines.CopyList(" ").c_str());
Status error;
@@ -298,15 +283,8 @@ static const char *g_synth_addreader_instructions =
"class synthProvider:\n";
static constexpr OptionDefinition g_type_synth_add_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
- { LLDB_OPT_SET_2, false, "python-class", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonClass, "Use this Python class to produce synthetic children." },
- { LLDB_OPT_SET_3, false, "input-python", 'P', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type Python code to generate a class that provides synthetic children." },
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." }
- // clang-format on
+#define LLDB_OPTIONS_type_synth_add
+#include "CommandOptions.inc"
};
class CommandObjectTypeSynthAdd : public CommandObjectParsed,
@@ -412,9 +390,9 @@ protected:
}
}
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(g_synth_addreader_instructions);
output_sp->Flush();
}
@@ -425,7 +403,7 @@ protected:
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
#ifndef LLDB_DISABLE_PYTHON
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
StringList lines;
lines.SplitIntoLines(data);
@@ -437,7 +415,7 @@ protected:
options_ptr); // this will ensure that we get rid of the pointer
// when going out of scope
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter) {
std::string class_name_str;
if (interpreter->GenerateTypeSynthClass(lines, class_name_str)) {
@@ -450,12 +428,12 @@ protected:
// class
SyntheticChildrenSP synth_provider;
- synth_provider.reset(new ScriptedSyntheticChildren(
+ synth_provider = std::make_shared<ScriptedSyntheticChildren>(
SyntheticChildren::Flags()
.SetCascades(options->m_cascade)
.SetSkipPointers(options->m_skip_pointers)
.SetSkipReferences(options->m_skip_references),
- class_name_str.c_str()));
+ class_name_str.c_str());
lldb::TypeCategoryImplSP category;
DataVisualization::Categories::GetCategory(
@@ -523,19 +501,11 @@ public:
Status *error);
};
-//-------------------------------------------------------------------------
// CommandObjectTypeFormatAdd
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_type_format_add_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." },
- { LLDB_OPT_SET_2, false, "type", 't', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Format variables as if they were of this type." }
- // clang-format on
+#define LLDB_OPTIONS_type_format_add
+#include "CommandOptions.inc"
};
class CommandObjectTypeFormatAdd : public CommandObjectParsed {
@@ -700,18 +670,18 @@ protected:
TypeFormatImplSP entry;
if (m_command_options.m_custom_type_name.empty())
- entry.reset(new TypeFormatImpl_Format(
+ entry = std::make_shared<TypeFormatImpl_Format>(
format, TypeFormatImpl::Flags()
.SetCascades(m_command_options.m_cascade)
.SetSkipPointers(m_command_options.m_skip_pointers)
- .SetSkipReferences(m_command_options.m_skip_references)));
+ .SetSkipReferences(m_command_options.m_skip_references));
else
- entry.reset(new TypeFormatImpl_EnumType(
+ entry = std::make_shared<TypeFormatImpl_EnumType>(
ConstString(m_command_options.m_custom_type_name.c_str()),
TypeFormatImpl::Flags()
.SetCascades(m_command_options.m_cascade)
.SetSkipPointers(m_command_options.m_skip_pointers)
- .SetSkipReferences(m_command_options.m_skip_references)));
+ .SetSkipReferences(m_command_options.m_skip_references));
// now I have a valid format, let's add it to every type
@@ -751,11 +721,8 @@ protected:
};
static constexpr OptionDefinition g_type_formatter_delete_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "all", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Delete from every category." },
- { LLDB_OPT_SET_2, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Delete from given category." },
- { LLDB_OPT_SET_3, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Delete from given language's category." }
- // clang-format on
+#define LLDB_OPTIONS_type_formatter_delete
+#include "CommandOptions.inc"
};
class CommandObjectTypeFormatterDelete : public CommandObjectParsed {
@@ -893,9 +860,8 @@ protected:
};
static constexpr OptionDefinition g_type_formatter_clear_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "all", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Clear every category." }
- // clang-format on
+#define LLDB_OPTIONS_type_formatter_clear
+#include "CommandOptions.inc"
};
class CommandObjectTypeFormatterClear : public CommandObjectParsed {
@@ -980,9 +946,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeFormatDelete
-//-------------------------------------------------------------------------
class CommandObjectTypeFormatDelete : public CommandObjectTypeFormatterDelete {
public:
@@ -996,9 +960,7 @@ public:
~CommandObjectTypeFormatDelete() override = default;
};
-//-------------------------------------------------------------------------
// CommandObjectTypeFormatClear
-//-------------------------------------------------------------------------
class CommandObjectTypeFormatClear : public CommandObjectTypeFormatterClear {
public:
@@ -1011,10 +973,8 @@ public:
static constexpr OptionDefinition g_type_formatter_list_options[] = {
- // clang-format off
- {LLDB_OPT_SET_1, false, "category-regex", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Only show categories matching this filter."},
- {LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Only show the category for a specific language."}
- // clang-format on
+#define LLDB_OPTIONS_type_formatter_list
+#include "CommandOptions.inc"
};
template <typename FormatterType>
@@ -1222,9 +1182,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeFormatList
-//-------------------------------------------------------------------------
class CommandObjectTypeFormatList
: public CommandObjectTypeFormatterList<TypeFormatImpl> {
@@ -1236,9 +1194,7 @@ public:
#ifndef LLDB_DISABLE_PYTHON
-//-------------------------------------------------------------------------
// CommandObjectTypeSummaryAdd
-//-------------------------------------------------------------------------
#endif // LLDB_DISABLE_PYTHON
@@ -1353,10 +1309,10 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
std::string code =
(" " + m_options.m_python_function + "(valobj,internal_dict)");
- script_format.reset(
- new ScriptSummaryFormat(m_options.m_flags, funct_name, code.c_str()));
+ script_format = std::make_shared<ScriptSummaryFormat>(
+ m_options.m_flags, funct_name, code.c_str());
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter && !interpreter->CheckObjectExists(funct_name))
result.AppendWarningWithFormat(
@@ -1366,7 +1322,7 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
} else if (!m_options.m_python_script
.empty()) // we have a quick 1-line script, just use it
{
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (!interpreter) {
result.AppendError("script interpreter missing - unable to generate "
"function wrapper.\n");
@@ -1390,8 +1346,8 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
std::string code = " " + m_options.m_python_script;
- script_format.reset(new ScriptSummaryFormat(
- m_options.m_flags, funct_name_str.c_str(), code.c_str()));
+ script_format = std::make_shared<ScriptSummaryFormat>(
+ m_options.m_flags, funct_name_str.c_str(), code.c_str());
} else {
// Use an IOHandler to grab Python code from the user
ScriptAddOptions *options =
@@ -1713,9 +1669,7 @@ bool CommandObjectTypeSummaryAdd::AddSummary(ConstString type_name,
}
}
-//-------------------------------------------------------------------------
// CommandObjectTypeSummaryDelete
-//-------------------------------------------------------------------------
class CommandObjectTypeSummaryDelete : public CommandObjectTypeFormatterDelete {
public:
@@ -1749,9 +1703,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeSummaryList
-//-------------------------------------------------------------------------
class CommandObjectTypeSummaryList
: public CommandObjectTypeFormatterList<TypeSummaryImpl> {
@@ -1778,15 +1730,11 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeCategoryDefine
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_type_category_define_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "enabled", 'e', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "If specified, this category will be created enabled." },
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Specify the language that this category is supported for." }
- // clang-format on
+#define LLDB_OPTIONS_type_category_define
+#include "CommandOptions.inc"
};
class CommandObjectTypeCategoryDefine : public CommandObjectParsed {
@@ -1885,14 +1833,11 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeCategoryEnable
-//-------------------------------------------------------------------------
static constexpr OptionDefinition g_type_category_enable_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Enable the category for this language." },
- // clang-format on
+#define LLDB_OPTIONS_type_category_enable
+#include "CommandOptions.inc"
};
class CommandObjectTypeCategoryEnable : public CommandObjectParsed {
@@ -2002,9 +1947,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeCategoryDelete
-//-------------------------------------------------------------------------
class CommandObjectTypeCategoryDelete : public CommandObjectParsed {
public:
@@ -2062,14 +2005,11 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeCategoryDisable
-//-------------------------------------------------------------------------
OptionDefinition constexpr g_type_category_disable_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Enable the category for this language." }
- // clang-format on
+#define LLDB_OPTIONS_type_category_disable
+#include "CommandOptions.inc"
};
class CommandObjectTypeCategoryDisable : public CommandObjectParsed {
@@ -2174,9 +2114,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeCategoryList
-//-------------------------------------------------------------------------
class CommandObjectTypeCategoryList : public CommandObjectParsed {
public:
@@ -2245,9 +2183,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectTypeFilterList
-//-------------------------------------------------------------------------
class CommandObjectTypeFilterList
: public CommandObjectTypeFormatterList<TypeFilterImpl> {
@@ -2259,9 +2195,7 @@ public:
#ifndef LLDB_DISABLE_PYTHON
-//-------------------------------------------------------------------------
// CommandObjectTypeSynthList
-//-------------------------------------------------------------------------
class CommandObjectTypeSynthList
: public CommandObjectTypeFormatterList<SyntheticChildren> {
@@ -2274,9 +2208,7 @@ public:
#endif // LLDB_DISABLE_PYTHON
-//-------------------------------------------------------------------------
// CommandObjectTypeFilterDelete
-//-------------------------------------------------------------------------
class CommandObjectTypeFilterDelete : public CommandObjectTypeFormatterDelete {
public:
@@ -2291,9 +2223,7 @@ public:
#ifndef LLDB_DISABLE_PYTHON
-//-------------------------------------------------------------------------
// CommandObjectTypeSynthDelete
-//-------------------------------------------------------------------------
class CommandObjectTypeSynthDelete : public CommandObjectTypeFormatterDelete {
public:
@@ -2309,9 +2239,7 @@ public:
#endif // LLDB_DISABLE_PYTHON
-//-------------------------------------------------------------------------
// CommandObjectTypeFilterClear
-//-------------------------------------------------------------------------
class CommandObjectTypeFilterClear : public CommandObjectTypeFormatterClear {
public:
@@ -2323,9 +2251,7 @@ public:
};
#ifndef LLDB_DISABLE_PYTHON
-//-------------------------------------------------------------------------
// CommandObjectTypeSynthClear
-//-------------------------------------------------------------------------
class CommandObjectTypeSynthClear : public CommandObjectTypeFormatterClear {
public:
@@ -2393,7 +2319,7 @@ bool CommandObjectTypeSynthAdd::Execute_PythonClass(
entry.reset(impl);
- ScriptInterpreter *interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *interpreter = GetDebugger().GetScriptInterpreter();
if (interpreter &&
!interpreter->CheckObjectExists(impl->GetPythonClassName()))
@@ -2491,14 +2417,8 @@ bool CommandObjectTypeSynthAdd::AddSynth(ConstString type_name,
#endif // LLDB_DISABLE_PYTHON
static constexpr OptionDefinition g_type_filter_add_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "cascade", 'C', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "If true, cascade through typedef chains." },
- { LLDB_OPT_SET_ALL, false, "skip-pointers", 'p', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for pointers-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "skip-references", 'r', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Don't use this format for references-to-type objects." },
- { LLDB_OPT_SET_ALL, false, "category", 'w', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeName, "Add this to the given category instead of the default one." },
- { LLDB_OPT_SET_ALL, false, "child", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeExpressionPath, "Include this expression path in the synthetic view." },
- { LLDB_OPT_SET_ALL, false, "regex", 'x', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Type names are actually regular expressions." }
- // clang-format on
+#define LLDB_OPTIONS_type_filter_add
+#include "CommandOptions.inc"
};
class CommandObjectTypeFilterAdd : public CommandObjectParsed {
@@ -2742,14 +2662,10 @@ protected:
}
};
-//----------------------------------------------------------------------
// "type lookup"
-//----------------------------------------------------------------------
static constexpr OptionDefinition g_type_lookup_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "show-help", 'h', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Display available help for types" },
- { LLDB_OPT_SET_ALL, false, "language", 'l', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeLanguage, "Which language's types should the search scope be" }
- // clang-format on
+#define LLDB_OPTIONS_type_lookup
+#include "CommandOptions.inc"
};
class CommandObjectTypeLookup : public CommandObjectRaw {
@@ -2844,17 +2760,11 @@ public:
return m_cmd_help_long;
StreamString stream;
- // FIXME: hardcoding languages is not good
- lldb::LanguageType languages[] = {eLanguageTypeObjC,
- eLanguageTypeC_plus_plus};
-
- for (const auto lang_type : languages) {
- if (auto language = Language::FindPlugin(lang_type)) {
- if (const char *help = language->GetLanguageSpecificTypeLookupHelp()) {
- stream.Printf("%s\n", help);
- }
- }
- }
+ Language::ForEach([&](Language *lang) {
+ if (const char *help = lang->GetLanguageSpecificTypeLookupHelp())
+ stream.Printf("%s\n", help);
+ return true;
+ });
m_cmd_help_long = stream.GetString();
return m_cmd_help_long;
@@ -2879,10 +2789,6 @@ public:
exe_ctx))
return false;
- // TargetSP
- // target_sp(GetCommandInterpreter().GetDebugger().GetSelectedTarget());
- // const bool fill_all_in = true;
- // ExecutionContext exe_ctx(target_sp.get(), fill_all_in);
ExecutionContextScope *best_scope = exe_ctx.GetBestExecutionContextScope();
bool any_found = false;
@@ -2894,9 +2800,10 @@ public:
if ((is_global_search =
(m_command_options.m_language == eLanguageTypeUnknown))) {
- // FIXME: hardcoding languages is not good
- languages.push_back(Language::FindPlugin(eLanguageTypeObjC));
- languages.push_back(Language::FindPlugin(eLanguageTypeC_plus_plus));
+ Language::ForEach([&](Language *lang) {
+ languages.push_back(lang);
+ return true;
+ });
} else {
languages.push_back(Language::FindPlugin(m_command_options.m_language));
}
@@ -2994,7 +2901,7 @@ public:
protected:
bool DoExecute(llvm::StringRef command,
CommandReturnObject &result) override {
- TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget();
+ TargetSP target_sp = GetDebugger().GetSelectedTarget();
Thread *thread = GetDefaultThread();
if (!thread) {
result.AppendError("no default thread");
@@ -3168,9 +3075,7 @@ public:
~CommandObjectTypeSummary() override = default;
};
-//-------------------------------------------------------------------------
// CommandObjectType
-//-------------------------------------------------------------------------
CommandObjectType::CommandObjectType(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "type",
diff --git a/source/Commands/CommandObjectType.h b/source/Commands/CommandObjectType.h
index a9223f842b305..ebb19039e5033 100644
--- a/source/Commands/CommandObjectType.h
+++ b/source/Commands/CommandObjectType.h
@@ -1,9 +1,8 @@
//===-- CommandObjectType.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Commands/CommandObjectVersion.cpp b/source/Commands/CommandObjectVersion.cpp
index 6155f49e97627..904baf5b7d446 100644
--- a/source/Commands/CommandObjectVersion.cpp
+++ b/source/Commands/CommandObjectVersion.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectVersion.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectVersion
-//-------------------------------------------------------------------------
CommandObjectVersion::CommandObjectVersion(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "version",
diff --git a/source/Commands/CommandObjectVersion.h b/source/Commands/CommandObjectVersion.h
index d1afafc69bf87..30f44aeb16581 100644
--- a/source/Commands/CommandObjectVersion.h
+++ b/source/Commands/CommandObjectVersion.h
@@ -1,9 +1,8 @@
//===-- CommandObjectVersion.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectVersion
-//-------------------------------------------------------------------------
class CommandObjectVersion : public CommandObjectParsed {
public:
diff --git a/source/Commands/CommandObjectWatchpoint.cpp b/source/Commands/CommandObjectWatchpoint.cpp
index d2600a4622032..98e758b7ef6a7 100644
--- a/source/Commands/CommandObjectWatchpoint.cpp
+++ b/source/Commands/CommandObjectWatchpoint.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectWatchpoint.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -143,21 +142,14 @@ bool CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(
return !in_range;
}
-//-------------------------------------------------------------------------
// CommandObjectWatchpointList
-//-------------------------------------------------------------------------
-//-------------------------------------------------------------------------
// CommandObjectWatchpointList::Options
-//-------------------------------------------------------------------------
#pragma mark List::CommandOptions
static constexpr OptionDefinition g_watchpoint_list_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "brief", 'b', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a brief description of the watchpoint (no location info)." },
- { LLDB_OPT_SET_2, false, "full", 'f', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Give a full description of the watchpoint and its locations." },
- { LLDB_OPT_SET_3, false, "verbose", 'v', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Explain everything we know about the watchpoint (for debugging debugger bugs)." }
- // clang-format on
+#define LLDB_OPTIONS_watchpoint_list
+#include "CommandOptions.inc"
};
#pragma mark List
@@ -230,7 +222,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("Invalid target. No current target or watchpoints.");
result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -296,9 +288,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointEnable
-//-------------------------------------------------------------------------
#pragma mark Enable
class CommandObjectWatchpointEnable : public CommandObjectParsed {
@@ -320,7 +310,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
@@ -367,9 +357,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointDisable
-//-------------------------------------------------------------------------
#pragma mark Disable
class CommandObjectWatchpointDisable : public CommandObjectParsed {
@@ -392,7 +380,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
@@ -442,9 +430,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointDelete
-//-------------------------------------------------------------------------
#pragma mark Delete
class CommandObjectWatchpointDelete : public CommandObjectParsed {
@@ -466,7 +452,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
@@ -518,15 +504,12 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointIgnore
-//-------------------------------------------------------------------------
#pragma mark Ignore::CommandOptions
static constexpr OptionDefinition g_watchpoint_ignore_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, true, "ignore-count", 'i', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeCount, "Set the number of times this watchpoint is skipped before stopping." }
- // clang-format on
+#define LLDB_OPTIONS_watchpoint_ignore
+#include "CommandOptions.inc"
};
class CommandObjectWatchpointIgnore : public CommandObjectParsed {
@@ -590,7 +573,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
@@ -639,16 +622,13 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointModify
-//-------------------------------------------------------------------------
#pragma mark Modify::CommandOptions
static constexpr OptionDefinition g_watchpoint_modify_options[] = {
- // clang-format off
- { LLDB_OPT_SET_ALL, false, "condition", 'c', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeExpression, "The watchpoint stops only if this condition expression evaluates to true." }
- // clang-format on
+#define LLDB_OPTIONS_watchpoint_modify
+#include "CommandOptions.inc"
};
#pragma mark Modify
@@ -719,7 +699,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
@@ -770,9 +750,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointSetVariable
-//-------------------------------------------------------------------------
#pragma mark SetVariable
class CommandObjectWatchpointSetVariable : public CommandObjectParsed {
@@ -839,7 +817,7 @@ protected:
}
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
StackFrame *frame = m_exe_ctx.GetFramePtr();
// If no argument is present, issue an error message. There's no way to
@@ -960,9 +938,7 @@ private:
OptionGroupWatchpoint m_option_watchpoint;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointSetExpression
-//-------------------------------------------------------------------------
#pragma mark Set
class CommandObjectWatchpointSetExpression : public CommandObjectRaw {
@@ -1026,7 +1002,7 @@ protected:
m_option_group.NotifyOptionParsingStarting(
&exe_ctx); // This is a raw command, so notify the option group
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
StackFrame *frame = m_exe_ctx.GetFramePtr();
OptionsWithRaw args(raw_command);
@@ -1128,9 +1104,7 @@ private:
OptionGroupWatchpoint m_option_watchpoint;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointSet
-//-------------------------------------------------------------------------
#pragma mark Set
class CommandObjectWatchpointSet : public CommandObjectMultiword {
@@ -1151,9 +1125,7 @@ public:
~CommandObjectWatchpointSet() override = default;
};
-//-------------------------------------------------------------------------
// CommandObjectMultiwordWatchpoint
-//-------------------------------------------------------------------------
#pragma mark MultiwordWatchpoint
CommandObjectMultiwordWatchpoint::CommandObjectMultiwordWatchpoint(
diff --git a/source/Commands/CommandObjectWatchpoint.h b/source/Commands/CommandObjectWatchpoint.h
index bc0a2c0c6a7d2..f21796e6bc8dd 100644
--- a/source/Commands/CommandObjectWatchpoint.h
+++ b/source/Commands/CommandObjectWatchpoint.h
@@ -1,9 +1,8 @@
//===-- CommandObjectWatchpoint.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordWatchpoint
-//-------------------------------------------------------------------------
class CommandObjectMultiwordWatchpoint : public CommandObjectMultiword {
public:
diff --git a/source/Commands/CommandObjectWatchpointCommand.cpp b/source/Commands/CommandObjectWatchpointCommand.cpp
index 3a9ebfbd15d00..2be0b5b154e0f 100644
--- a/source/Commands/CommandObjectWatchpointCommand.cpp
+++ b/source/Commands/CommandObjectWatchpointCommand.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectWatchpointCommand.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommandAdd
-//-------------------------------------------------------------------------
// FIXME: "script-type" needs to have its contents determined dynamically, so
// somebody can add a new scripting
@@ -46,12 +43,8 @@ static constexpr OptionEnumValues ScriptOptionEnum() {
}
static constexpr OptionDefinition g_watchpoint_command_add_options[] = {
- // clang-format off
- { LLDB_OPT_SET_1, false, "one-liner", 'o', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeOneLiner, "Specify a one-line watchpoint command inline. Be sure to surround it with quotes." },
- { LLDB_OPT_SET_ALL, false, "stop-on-error", 'e', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Specify whether watchpoint command execution should terminate on error." },
- { LLDB_OPT_SET_ALL, false, "script-type", 's', OptionParser::eRequiredArgument, nullptr, ScriptOptionEnum(), 0, eArgTypeNone, "Specify the language for the commands - if none is specified, the lldb command interpreter will be used." },
- { LLDB_OPT_SET_2, false, "python-function", 'F', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypePythonFunction, "Give the name of a Python function to run as command for this watchpoint. Be sure to give a module name if appropriate." }
- // clang-format on
+#define LLDB_OPTIONS_watchpoint_command_add
+#include "CommandOptions.inc"
};
class CommandObjectWatchpointCommandAdd : public CommandObjectParsed,
@@ -208,9 +201,9 @@ are no syntax errors may indicate that a function was declared but never called.
Options *GetOptions() override { return &m_options; }
- void IOHandlerActivated(IOHandler &io_handler) override {
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(
"Enter your debugger command(s). Type 'DONE' to end.\n");
output_sp->Flush();
@@ -226,12 +219,12 @@ are no syntax errors may indicate that a function was declared but never called.
WatchpointOptions *wp_options =
(WatchpointOptions *)io_handler.GetUserData();
if (wp_options) {
- std::unique_ptr<WatchpointOptions::CommandData> data_ap(
+ std::unique_ptr<WatchpointOptions::CommandData> data_up(
new WatchpointOptions::CommandData());
- if (data_ap) {
- data_ap->user_source.SplitIntoLines(line);
+ if (data_up) {
+ data_up->user_source.SplitIntoLines(line);
auto baton_sp = std::make_shared<WatchpointOptions::CommandBaton>(
- std::move(data_ap));
+ std::move(data_up));
wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp);
}
}
@@ -250,19 +243,19 @@ are no syntax errors may indicate that a function was declared but never called.
/// Set a one-liner as the callback for the watchpoint.
void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
const char *oneliner) {
- std::unique_ptr<WatchpointOptions::CommandData> data_ap(
+ std::unique_ptr<WatchpointOptions::CommandData> data_up(
new WatchpointOptions::CommandData());
// It's necessary to set both user_source and script_source to the
// oneliner. The former is used to generate callback description (as in
// watchpoint command list) while the latter is used for Python to
// interpret during the actual callback.
- data_ap->user_source.AppendString(oneliner);
- data_ap->script_source.assign(oneliner);
- data_ap->stop_on_error = m_options.m_stop_on_error;
+ data_up->user_source.AppendString(oneliner);
+ data_up->script_source.assign(oneliner);
+ data_up->stop_on_error = m_options.m_stop_on_error;
auto baton_sp =
- std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_ap));
+ std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_up));
wp_options->SetCallback(WatchpointOptionsCallbackFunction, baton_sp);
}
@@ -298,6 +291,7 @@ are no syntax errors may indicate that a function was declared but never called.
options.SetStopOnError(data->stop_on_error);
options.SetEchoCommands(false);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetAddToHistory(false);
debugger.GetCommandInterpreter().HandleCommands(commands, &exe_ctx,
@@ -390,7 +384,7 @@ are no syntax errors may indicate that a function was declared but never called.
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -445,7 +439,7 @@ protected:
if (m_options.m_use_script_language) {
// Special handling for one-liner specified inline.
if (m_options.m_use_one_liner) {
- m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback(
+ GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
wp_options, m_options.m_one_liner.c_str());
}
// Special handling for using a Python function by name instead of
@@ -455,10 +449,11 @@ protected:
else if (!m_options.m_function_name.empty()) {
std::string oneliner(m_options.m_function_name);
oneliner += "(frame, wp, internal_dict)";
- m_interpreter.GetScriptInterpreter()->SetWatchpointCommandCallback(
+ GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback(
wp_options, oneliner.c_str());
} else {
- m_interpreter.GetScriptInterpreter()
+ GetDebugger()
+ .GetScriptInterpreter()
->CollectDataForWatchpointCommandCallback(wp_options, result);
}
} else {
@@ -479,9 +474,7 @@ private:
CommandOptions m_options;
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommandDelete
-//-------------------------------------------------------------------------
class CommandObjectWatchpointCommandDelete : public CommandObjectParsed {
public:
@@ -508,7 +501,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -559,9 +552,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommandList
-//-------------------------------------------------------------------------
class CommandObjectWatchpointCommandList : public CommandObjectParsed {
public:
@@ -589,7 +580,7 @@ public:
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
- Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ Target *target = GetDebugger().GetSelectedTarget().get();
if (target == nullptr) {
result.AppendError("There is not a current executable; there are no "
@@ -659,9 +650,7 @@ protected:
}
};
-//-------------------------------------------------------------------------
// CommandObjectWatchpointCommand
-//-------------------------------------------------------------------------
CommandObjectWatchpointCommand::CommandObjectWatchpointCommand(
CommandInterpreter &interpreter)
diff --git a/source/Commands/CommandObjectWatchpointCommand.h b/source/Commands/CommandObjectWatchpointCommand.h
index e079220d0efef..f2f15ef50b0f5 100644
--- a/source/Commands/CommandObjectWatchpointCommand.h
+++ b/source/Commands/CommandObjectWatchpointCommand.h
@@ -1,9 +1,8 @@
//===-- CommandObjectWatchpointCommand.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectMultiwordWatchpoint
-//-------------------------------------------------------------------------
class CommandObjectWatchpointCommand : public CommandObjectMultiword {
public:
diff --git a/source/Commands/Options.td b/source/Commands/Options.td
new file mode 100644
index 0000000000000..9cfbcd2d4ebfe
--- /dev/null
+++ b/source/Commands/Options.td
@@ -0,0 +1,308 @@
+include "OptionsBase.td"
+
+let Command = "target modules dump symtab" in {
+ def tm_sort : Option<"sort", "s">, Group<1>,
+ Desc<"Supply a sort order when dumping the symbol table.">,
+ EnumArg<"SortOrder", "OptionEnumValues(g_sort_option_enumeration)">;
+}
+
+let Command = "help" in {
+ def help_hide_aliases : Option<"hide-aliases", "a">,
+ Desc<"Hide aliases in the command list.">;
+ def help_hide_user : Option<"hide-user-commands", "u">,
+ Desc<"Hide user-defined commands from the list.">;
+ def help_show_hidden : Option<"show-hidden-commands", "h">,
+ Desc<"Include commands prefixed with an underscore.">;
+}
+
+let Command = "settings set" in {
+ def setset_global : Option<"global", "g">, Arg<"Filename">,
+ Completion<"DiskFile">,
+ Desc<"Apply the new value to the global default value.">;
+ def setset_force : Option<"force", "f">,
+ Desc<"Force an empty value to be accepted as the default.">;
+}
+
+let Command = "settings write" in {
+ def setwrite_file : Option<"file", "f">, Required, Arg<"Filename">,
+ Completion<"DiskFile">,
+ Desc<"The file into which to write the settings.">;
+ def setwrite_append : Option<"append", "a">,
+ Desc<"Append to saved settings file if it exists.">;
+}
+
+let Command = "settings read" in {
+ def setread_file : Option<"file", "f">, Required, Arg<"Filename">,
+ Completion<"DiskFile">,
+ Desc<"The file from which to read the settings.">;
+}
+
+let Command = "breakpoint list" in {
+ def blist_internal : Option<"internal", "i">,
+ Desc<"Show debugger internal breakpoints">;
+ def blist_brief : Option<"brief", "b">, Group<1>,
+ Desc<"Give a brief description of the breakpoint (no location info).">;
+ def blist_full : Option<"full", "f">, Group<2>,
+ Desc<"Give a full description of the breakpoint and its locations.">;
+ def blist_verbose : Option<"verbose", "v">, Group<3>,
+ Desc<"Explain everything we know about the breakpoint (for debugging "
+ "debugger bugs).">;
+ def blist_dummy_bp : Option<"dummy-breakpoints", "D">,
+ Desc<"List Dummy breakpoints - i.e. breakpoints set before a file is "
+ "provided, which prime new targets.">;
+}
+
+let Command = "thread backtrace" in {
+ def thread_backtrace_count : Option<"count", "c">, Group<1>, Arg<"Count">,
+ Desc<"How many frames to display (-1 for all)">;
+ def thread_backtrace_start : Option<"start", "s">, Group<1>,
+ Arg<"FrameIndex">, Desc<"Frame in which to start the backtrace">;
+ def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
+ Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
+}
+
+let Command = "thread step scope" in {
+ def thread_step_scope_step_in_avoids_no_debug :
+ Option<"step-in-avoids-no-debug", "a">, Group<1>, Arg<"Boolean">,
+ Desc<"A boolean value that sets whether stepping into functions will step "
+ "over functions with no debug information.">;
+ def thread_step_scope_step_out_avoids_no_debug :
+ Option<"step-out-avoids-no-debug", "A">, Group<1>, Arg<"Boolean">,
+ Desc<"A boolean value, if true stepping out of functions will continue to"
+ " step out till it hits a function with debug information.">;
+ def thread_step_scope_count : Option<"count", "c">, Group<1>, Arg<"Count">,
+ Desc<"How many times to perform the stepping operation - currently only "
+ "supported for step-inst and next-inst.">;
+ def thread_step_scope_end_linenumber : Option<"end-linenumber", "e">,
+ Group<1>, Arg<"LineNum">, Desc<"The line at which to stop stepping - "
+ "defaults to the next line and only supported for step-in and step-over."
+ " You can also pass the string 'block' to step to the end of the current"
+ " block. This is particularly use in conjunction with --step-target to"
+ " step through a complex calling sequence.">;
+ def thread_step_scope_run_mode : Option<"run-mode", "m">, Group<1>,
+ EnumArg<"RunMode", "TriRunningModes()">, Desc<"Determine how to run other "
+ "threads while stepping the current thread.">;
+ def thread_step_scope_step_over_regexp : Option<"step-over-regexp", "r">,
+ Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that defines"
+ "function names to not to stop at when stepping in.">;
+ def thread_step_scope_step_in_target : Option<"step-in-target", "t">,
+ Group<1>, Arg<"FunctionName">, Desc<"The name of the directly called "
+ "function step in should stop at when stepping into.">;
+ def thread_step_scope_python_class : Option<"python-class", "C">, Group<2>,
+ Arg<"PythonClass">, Desc<"The name of the class that will manage this step "
+ "- only supported for Scripted Step.">;
+}
+
+let Command = "thread until" in {
+ def thread_until_frame : Option<"frame", "f">, Group<1>, Arg<"FrameIndex">,
+ Desc<"Frame index for until operation - defaults to 0">;
+ def thread_until_thread : Option<"thread", "t">, Group<1>, Arg<"ThreadIndex">,
+ Desc<"Thread index for the thread for until operation">;
+ def thread_until_run_mode : Option<"run-mode", "m">, Group<1>,
+ EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other"
+ "threads while stepping this one">;
+ def thread_until_address : Option<"address", "a">, Group<1>,
+ Arg<"AddressOrExpression">, Desc<"Run until we reach the specified address,"
+ "or leave the function - can be specified multiple times.">;
+}
+
+let Command = "thread info" in {
+ def thread_info_json : Option<"json", "j">, Desc<"Display the thread info in"
+ " JSON format.">;
+ def thread_info_stop_info : Option<"stop-info", "s">, Desc<"Display the "
+ "extended stop info in JSON format.">;
+}
+
+let Command = "thread return" in {
+ def thread_return_from_expression : Option<"from-expression", "x">,
+ Desc<"Return from the innermost expression evaluation.">;
+}
+
+let Command = "thread jump" in {
+ def thread_jump_file : Option<"file", "f">, Group<1>, Arg<"Filename">,
+ Completion<"SourceFile">, Desc<"Specifies the source file to jump to.">;
+ def thread_jump_line : Option<"line", "l">, Group<1>, Arg<"LineNum">,
+ Required, Desc<"Specifies the line number to jump to.">;
+ def thread_jump_by : Option<"by", "b">, Group<2>, Arg<"Offset">, Required,
+ Desc<"Jumps by a relative line offset from the current line.">;
+ def thread_jump_address : Option<"address", "a">, Group<3>,
+ Arg<"AddressOrExpression">, Required, Desc<"Jumps to a specific address.">;
+ def thread_jump_force : Option<"force", "r">, Groups<[1,2,3]>,
+ Desc<"Allows the PC to leave the current function.">;
+}
+
+let Command = "thread plan list" in {
+ def thread_plan_list_verbose : Option<"verbose", "v">, Group<1>,
+ Desc<"Display more information about the thread plans">;
+ def thread_plan_list_internal : Option<"internal", "i">, Group<1>,
+ Desc<"Display internal as well as user thread plans">;
+}
+
+let Command = "type summary add" in {
+ def type_summary_add_category : Option<"category", "w">, Arg<"Name">,
+ Desc<"Add this to the given category instead of the default one.">;
+ def type_summary_add_cascade : Option<"cascade", "C">, Arg<"Boolean">,
+ Desc<"If true, cascade through typedef chains.">;
+ def type_summary_add_no_value : Option<"no-value", "v">,
+ Desc<"Don't show the value, just show the summary, for this type.">;
+ def type_summary_add_skip_pointers : Option<"skip-pointers", "p">,
+ Desc<"Don't use this format for pointers-to-type objects.">;
+ def type_summary_add_skip_references : Option<"skip-references", "r">,
+ Desc<"Don't use this format for references-to-type objects.">;
+ def type_summary_add_regex : Option<"regex", "x">,
+ Desc<"Type names are actually regular expressions.">;
+ def type_summary_add_inline_children : Option<"inline-children", "c">,
+ Group<1>, Required,
+ Desc<"If true, inline all child values into summary string.">;
+ def type_summary_add_omit_names : Option<"omit-names", "O">, Group<1>,
+ Desc<"If true, omit value names in the summary display.">;
+ def type_summary_add_summary_string : Option<"summary-string", "s">, Group<2>,
+ Arg<"SummaryString">, Required,
+ Desc<"Summary string used to display text and object contents.">;
+ def type_summary_add_python_script : Option<"python-script", "o">, Group<3>,
+ Arg<"PythonScript">,
+ Desc<"Give a one-liner Python script as part of the command.">;
+ def type_summary_add_python_function : Option<"python-function", "F">,
+ Group<3>, Arg<"PythonFunction">,
+ Desc<"Give the name of a Python function to use for this type.">;
+ def type_summary_add_input_python : Option<"input-python", "P">, Group<3>,
+ Desc<"Input Python code to use for this type manually.">;
+ def type_summary_add_expand : Option<"expand", "e">, Groups<[2,3]>,
+ Desc<"Expand aggregate data types to show children on separate lines.">;
+ def type_summary_add_hide_empty : Option<"hide-empty", "h">, Groups<[2,3]>,
+ Desc<"Do not expand aggregate data types with no children.">;
+ def type_summary_add_name : Option<"name", "n">, Groups<[2,3]>, Arg<"Name">,
+ Desc<"A name for this summary string.">;
+}
+
+let Command = "type synth add" in {
+ def type_synth_add_cascade : Option<"cascade", "C">, Arg<"Boolean">,
+ Desc<"If true, cascade through typedef chains.">;
+ def type_synth_add_skip_pointers : Option<"skip-pointers", "p">,
+ Desc<"Don't use this format for pointers-to-type objects.">;
+ def type_synth_add_skip_references : Option<"skip-references", "r">,
+ Desc<"Don't use this format for references-to-type objects.">;
+ def type_synth_add_category : Option<"category", "w">, Arg<"Name">,
+ Desc<"Add this to the given category instead of the default one.">;
+ def type_synth_add_python_class : Option<"python-class", "l">, Group<2>,
+ Arg<"PythonClass">,
+ Desc<"Use this Python class to produce synthetic children.">;
+ def type_synth_add_input_python : Option<"input-python", "P">, Group<3>,
+ Desc<"Type Python code to generate a class that provides synthetic "
+ "children.">;
+ def type_synth_add_regex : Option<"regex", "x">,
+ Desc<"Type names are actually regular expressions.">;
+}
+
+let Command = "type format add" in {
+ def type_format_add_category : Option<"category", "w">, Arg<"Name">,
+ Desc<"Add this to the given category instead of the default one.">;
+ def type_format_add_cascade : Option<"cascade", "C">, Arg<"Boolean">,
+ Desc<"If true, cascade through typedef chains.">;
+ def type_format_add_skip_pointers : Option<"skip-pointers", "p">,
+ Desc<"Don't use this format for pointers-to-type objects.">;
+ def type_format_add_skip_references : Option<"skip-references", "r">,
+ Desc<"Don't use this format for references-to-type objects.">;
+ def type_format_add_regex : Option<"regex", "x">,
+ Desc<"Type names are actually regular expressions.">;
+ def type_format_add_type : Option<"type", "t">, Group<2>, Arg<"Name">,
+ Desc<"Format variables as if they were of this type.">;
+}
+
+let Command = "type formatter delete" in {
+ def type_formatter_delete_all : Option<"all", "a">, Group<1>,
+ Desc<"Delete from every category.">;
+ def type_formatter_delete_category : Option<"category", "w">, Group<2>,
+ Arg<"Name">, Desc<"Delete from given category.">;
+ def type_formatter_delete_language : Option<"language", "l">, Group<3>,
+ Arg<"Language">, Desc<"Delete from given language's category.">;
+}
+
+let Command = "type formatter clear" in {
+ def type_formatter_clear_all : Option<"all", "a">,
+ Desc<"Clear every category.">;
+}
+
+let Command = "type formatter list" in {
+ def type_formatter_list_category_regex : Option<"category-regex", "w">,
+ Group<1>, Arg<"Name">, Desc<"Only show categories matching this filter.">;
+ def type_formatter_list_language : Option<"language", "l">, Group<2>,
+ Arg<"Language">, Desc<"Only show the category for a specific language.">;
+}
+
+let Command = "type category define" in {
+ def type_category_define_enabled : Option<"enabled", "e">,
+ Desc<"If specified, this category will be created enabled.">;
+ def type_category_define_language : Option<"language", "l">, Arg<"Language">,
+ Desc<"Specify the language that this category is supported for.">;
+}
+
+let Command = "type category enable" in {
+ def type_category_enable_language : Option<"language", "l">, Arg<"Language">,
+ Desc<"Enable the category for this language.">;
+}
+
+let Command = "type category disable" in {
+ def type_category_disable_language : Option<"language", "l">, Arg<"Language">,
+ Desc<"Enable the category for this language.">;
+}
+
+let Command = "type filter add" in {
+ def type_filter_add_cascade : Option<"cascade", "C">, Arg<"Boolean">,
+ Desc<"If true, cascade through typedef chains.">;
+ def type_filter_add_skip_pointers : Option<"skip-pointers", "p">,
+ Desc<"Don't use this format for pointers-to-type objects.">;
+ def type_filter_add_skip_references : Option<"skip-references", "r">,
+ Desc<"Don't use this format for references-to-type objects.">;
+ def type_filter_add_category : Option<"category", "w">, Arg<"Name">,
+ Desc<"Add this to the given category instead of the default one.">;
+ def type_filter_add_child : Option<"child", "c">, Arg<"ExpressionPath">,
+ Desc<"Include this expression path in the synthetic view.">;
+ def type_filter_add_regex : Option<"regex", "x">,
+ Desc<"Type names are actually regular expressions.">;
+}
+
+let Command = "type lookup" in {
+ def type_lookup_show_help : Option<"show-help", "h">,
+ Desc<"Display available help for types">;
+ def type_lookup_language : Option<"language", "l">, Arg<"Language">,
+ Desc<"Which language's types should the search scope be">;
+}
+
+let Command = "watchpoint list" in {
+ def watchpoint_list_brief : Option<"brief", "b">, Group<1>, Desc<"Give a "
+ "brief description of the watchpoint (no location info).">;
+ def watchpoint_list_full : Option<"full", "f">, Group<2>, Desc<"Give a full "
+ "description of the watchpoint and its locations.">;
+ def watchpoint_list_verbose : Option<"verbose", "v">, Group<3>, Desc<"Explain"
+ "everything we know about the watchpoint (for debugging debugger bugs).">;
+}
+
+let Command = "watchpoint ignore" in {
+ def watchpoint_ignore_ignore_count : Option<"ignore-count", "i">,
+ Arg<"Count">, Required, Desc<"Set the number of times this watchpoint is"
+ " skipped before stopping.">;
+}
+
+let Command = "watchpoint modify" in {
+ def watchpoint_modify_condition : Option<"condition", "c">, Arg<"Expression">,
+ Desc<"The watchpoint stops only if this condition expression evaluates "
+ "to true.">;
+}
+
+let Command = "watchpoint command add" in {
+ def watchpoint_command_add_one_liner : Option<"one-liner", "o">, Group<1>,
+ Arg<"OneLiner">, Desc<"Specify a one-line watchpoint command inline. Be "
+ "sure to surround it with quotes.">;
+ def watchpoint_command_add_stop_on_error : Option<"stop-on-error", "e">,
+ Arg<"Boolean">, Desc<"Specify whether watchpoint command execution should "
+ "terminate on error.">;
+ def watchpoint_command_add_script_type : Option<"script-type", "s">,
+ EnumArg<"None", "ScriptOptionEnum()">, Desc<"Specify the language for the"
+ " commands - if none is specified, the lldb command interpreter will be "
+ "used.">;
+ def watchpoint_command_add_python_function : Option<"python-function", "F">,
+ Group<2>, Arg<"PythonFunction">, Desc<"Give the name of a Python function "
+ "to run as command for this watchpoint. Be sure to give a module name if "
+ "appropriate.">;
+}
diff --git a/source/Commands/OptionsBase.td b/source/Commands/OptionsBase.td
new file mode 100644
index 0000000000000..a81563ed28c2b
--- /dev/null
+++ b/source/Commands/OptionsBase.td
@@ -0,0 +1,160 @@
+
+// The fields below describe how the fields of `OptionDefinition` struct are
+// initialized by different definitions in the Options.td and this file.
+////////////////////////////////////////////////////////////////////////////////
+// Field: usage_mask
+// Default value: LLDB_OPT_SET_ALL (Option allowed in all groups)
+// Set by:
+// - `Group`: Sets a single group to this option.
+// Example: def foo : Option<"foo", "f">, Group<1>;
+// - `Groups`: Sets a given list of group numbers.
+// Example: def foo : Option<"foo", "f">, Groups<[1,4,6]>;
+// - `GroupRange`: Sets an interval of groups. Start and end are inclusive.
+// Example: def foo : Option<"foo", "f">, GroupRange<1, 4>;
+// Sets group 1, 2, 3, 4 for the option.
+////////////////////////////////////////////////////////////////////////////////
+// Field: required
+// Default value: false (Not required)
+// Set by:
+// - `Required`: Marks the option as required.
+// Example: def foo : Option<"foo", "f">, Required;
+////////////////////////////////////////////////////////////////////////////////
+// Field: long_option
+// Default value: not available (has to be defined in Option)
+// Set by:
+// - `Option` constructor: Already set by constructor.
+// Example: def foo : Option<"long-option", "l">
+// ^
+// long option value
+////////////////////////////////////////////////////////////////////////////////
+// Field: short_option
+// Default value: not available (has to be defined in Option)
+// Set by:
+// - `Option` constructor: Already set by constructor.
+// Example: def foo : Option<"long-option", "l">
+// ^
+// short option
+////////////////////////////////////////////////////////////////////////////////
+// Field: option_has_arg
+// Default value: OptionParser::eNoArgument (No argument allowed)
+// Set by:
+// - `OptionalArg`: Sets the argument type and marks it as optional.
+// - `Arg`: Sets the argument type and marks it as required.
+// - `EnumArg`: Sets the argument type to an enum and marks it as required.
+// See argument_type field for more info.
+////////////////////////////////////////////////////////////////////////////////
+// Field: validator
+// Default value: 0 (No validator for option)
+// Set by: Nothing. This is currently only set after initialization in LLDB.
+////////////////////////////////////////////////////////////////////////////////
+// Field: enum_values
+// Default value: {} (No enum associated with this option)
+// Set by:
+// - `EnumArg`: Sets the argument type and assigns it a enum holding the valid
+// values. The enum needs to be a variable in the including code.
+// Marks the option as required (see option_has_arg).
+// Example: def foo : Option<"foo", "f">,
+// EnumArg<"SortOrder",
+// "OptionEnumValues(g_sort_option_enumeration)">;
+////////////////////////////////////////////////////////////////////////////////
+// Field: completion_type
+// Default value: CommandCompletions::eNoCompletion (no tab completion)
+// Set by:
+// - `Completion`: Gives the option a single completion kind.
+// Example: def foo : Option<"foo", "f">,
+// Completion<"DiskFile">;
+// Sets the completion to eDiskFileCompletion
+//
+// - `Completions`: Sets a given kinds of completions.
+// Example: def foo : Option<"foo", "f">,
+// Completions<["DiskFile", "DiskDirectory"]>;
+// Sets the completion to
+// `eDiskFileCompletion | eDiskDirectoryCompletion`.
+////////////////////////////////////////////////////////////////////////////////
+// Field: argument_type
+// Default value: eArgTypeNone
+// Set by:
+// - `OptionalArg`: Sets the argument type and marks it as optional.
+// Example: def foo : Option<"foo", "f">, OptionalArg<"Pid">;
+// Sets the argument type to eArgTypePid and marks option as
+// optional (see option_has_arg).
+// - `Arg`: Sets the argument type and marks it as required.
+// Example: def foo : Option<"foo", "f">, Arg<"Pid">;
+// Sets the argument type to eArgTypePid and marks option as
+// required (see option_has_arg).
+// - `EnumArg`: Sets the argument type and assigns it a enum holding the valid
+// values. The enum needs to be a variable in the including code.
+// Marks the option as required (see option_has_arg).
+// Example: def foo : Option<"foo", "f">,
+// EnumArg<"SortOrder",
+// "OptionEnumValues(g_sort_option_enumeration)">;
+////////////////////////////////////////////////////////////////////////////////
+// Field: usage_text
+// Default value: ""
+// Set by:
+// - `Desc`: Sets the description for the given option.
+// Example: def foo : Option<"foo", "f">, Desc<"does nothing.">;
+// Sets the description to "does nothing.".
+
+// Base class for all options.
+class Option<string fullname, string shortname> {
+ string FullName = fullname;
+ string ShortName = shortname;
+ // The full associated command/subcommand such as "settings set".
+ string Command;
+}
+
+// Moves the option into a list of option groups.
+class Groups<list<int> groups> {
+ list<int> Groups = groups;
+}
+
+// Moves the option in all option groups in a range.
+// Start and end values are inclusive.
+class GroupRange<int start, int end> {
+ int GroupStart = start;
+ int GroupEnd = end;
+}
+// Moves the option in a single option group.
+class Group<int group> {
+ int GroupStart = group;
+ int GroupEnd = group;
+}
+
+// Sets the description for the option that should be
+// displayed to the user.
+class Desc<string description> {
+ string Description = description;
+}
+
+// Marks the option as required when calling the
+// associated command.
+class Required {
+ bit Required = 1;
+}
+
+// Gives the option an optional argument.
+class OptionalArg<string type> {
+ string ArgType = type;
+ bit OptionalArg = 1;
+}
+
+// Gives the option an required argument.
+class Arg<string type> {
+ string ArgType = type;
+}
+
+// Gives the option an required argument.
+class EnumArg<string type, string enum> {
+ string ArgType = type;
+ string ArgEnum = enum;
+}
+
+// Sets the available completions for the given option.
+class Completions<list<string> completions> {
+ list<string> Completions = completions;
+}
+// Sets a single completion for the given option.
+class Completion<string completion> {
+ list<string> Completions = [completion];
+}
diff --git a/source/Core/Address.cpp b/source/Core/Address.cpp
index a4dc364b701bd..0da83eb98edb1 100644
--- a/source/Core/Address.cpp
+++ b/source/Core/Address.cpp
@@ -1,9 +1,8 @@
//===-- Address.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -162,7 +161,7 @@ static bool ReadAddress(ExecutionContextScope *exe_scope,
static bool DumpUInt(ExecutionContextScope *exe_scope, const Address &address,
uint32_t byte_size, Stream *strm) {
if (exe_scope == nullptr || byte_size == 0)
- return 0;
+ return false;
std::vector<uint8_t> buf(byte_size, 0);
if (ReadBytes(exe_scope, address, &buf[0], buf.size()) == buf.size()) {
@@ -928,7 +927,6 @@ size_t Address::MemorySize() const {
return sizeof(Address);
}
-//----------------------------------------------------------------------
// 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
@@ -940,7 +938,6 @@ size_t Address::MemorySize() const {
// address results to make much sense
//
// This basically lets Address objects be used in ordered collection classes.
-//----------------------------------------------------------------------
bool lldb_private::operator<(const Address &lhs, const Address &rhs) {
ModuleSP lhs_module_sp(lhs.GetModule());
diff --git a/source/Core/AddressRange.cpp b/source/Core/AddressRange.cpp
index 1afe4fa223db9..71eec3c196072 100644
--- a/source/Core/AddressRange.cpp
+++ b/source/Core/AddressRange.cpp
@@ -1,9 +1,8 @@
//===-- AddressRange.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -123,6 +122,24 @@ bool AddressRange::ContainsLoadAddress(addr_t load_addr, Target *target) const {
return false;
}
+bool AddressRange::Extend(const AddressRange &rhs_range) {
+ addr_t lhs_end_addr = GetBaseAddress().GetFileAddress() + GetByteSize();
+ addr_t rhs_base_addr = rhs_range.GetBaseAddress().GetFileAddress();
+
+ if (!ContainsFileAddress(rhs_range.GetBaseAddress()) &&
+ lhs_end_addr != rhs_base_addr)
+ // The ranges don't intersect at all on the right side of this range.
+ return false;
+
+ addr_t rhs_end_addr = rhs_base_addr + rhs_range.GetByteSize();
+ if (lhs_end_addr >= rhs_end_addr)
+ // The rhs range totally overlaps this one, nothing to add.
+ return false;
+
+ m_byte_size += rhs_end_addr - lhs_end_addr;
+ return true;
+}
+
void AddressRange::Clear() {
m_base_addr.Clear();
m_byte_size = 0;
diff --git a/source/Core/AddressResolver.cpp b/source/Core/AddressResolver.cpp
index 8d7cc9f6a4281..974d99b620655 100644
--- a/source/Core/AddressResolver.cpp
+++ b/source/Core/AddressResolver.cpp
@@ -1,9 +1,8 @@
//===-- AddressResolver.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@ class ModuleList;
using namespace lldb_private;
-//----------------------------------------------------------------------
// AddressResolver:
-//----------------------------------------------------------------------
AddressResolver::AddressResolver() {}
AddressResolver::~AddressResolver() {}
diff --git a/source/Core/AddressResolverFileLine.cpp b/source/Core/AddressResolverFileLine.cpp
index 203ab2787fe3e..24c0222d6ec2f 100644
--- a/source/Core/AddressResolverFileLine.cpp
+++ b/source/Core/AddressResolverFileLine.cpp
@@ -1,9 +1,8 @@
//===-- AddressResolverFileLine.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,9 +27,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// AddressResolverFileLine:
-//----------------------------------------------------------------------
AddressResolverFileLine::AddressResolverFileLine(const FileSpec &file_spec,
uint32_t line_no,
bool check_inlines)
diff --git a/source/Core/AddressResolverName.cpp b/source/Core/AddressResolverName.cpp
index 7683e391e0cf9..e861368c0a25f 100644
--- a/source/Core/AddressResolverName.cpp
+++ b/source/Core/AddressResolverName.cpp
@@ -1,9 +1,8 @@
//===-- AddressResolverName.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Core/Communication.cpp b/source/Core/Communication.cpp
index afdabc0c7ce52..a67cb925d648f 100644
--- a/source/Core/Communication.cpp
+++ b/source/Core/Communication.cpp
@@ -1,9 +1,8 @@
//===-- Communication.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -205,10 +204,23 @@ bool Communication::StartReadThread(Status *error_ptr) {
m_read_thread_enabled = true;
m_read_thread_did_exit = false;
- m_read_thread = ThreadLauncher::LaunchThread(
- thread_name, Communication::ReadThread, this, error_ptr);
+ auto maybe_thread = ThreadLauncher::LaunchThread(
+ thread_name, Communication::ReadThread, this);
+ if (maybe_thread) {
+ m_read_thread = *maybe_thread;
+ } else {
+ if (error_ptr)
+ *error_ptr = Status(maybe_thread.takeError());
+ else {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(maybe_thread.takeError()));
+ }
+ }
+
if (!m_read_thread.IsJoinable())
m_read_thread_enabled = false;
+
return m_read_thread_enabled;
}
@@ -360,7 +372,7 @@ lldb::thread_result_t Communication::ReadThread(lldb::thread_arg_t p) {
// Let clients know that this thread is exiting
comm->BroadcastEvent(eBroadcastBitNoMorePendingInput);
comm->BroadcastEvent(eBroadcastBitReadThreadDidExit);
- return NULL;
+ return {};
}
void Communication::SetReadThreadBytesReceivedCallback(
diff --git a/source/Core/Debugger.cpp b/source/Core/Debugger.cpp
index 765b59c8865ed..1a69fc582d0c3 100644
--- a/source/Core/Debugger.cpp
+++ b/source/Core/Debugger.cpp
@@ -1,9 +1,8 @@
//===-- Debugger.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -122,7 +121,10 @@ static constexpr OptionEnumValueElement g_language_enumerators[] = {
"{${frame.no-debug}${function.pc-offset}}}}"
#define FILE_AND_LINE \
- "{ at ${line.file.basename}:${line.number}{:${line.column}}}"
+ "{ at ${ansi.fg.cyan}${line.file.basename}${ansi.normal}" \
+ ":${ansi.fg.yellow}${line.number}${ansi.normal}" \
+ "{:${ansi.fg.yellow}${line.column}${ansi.normal}}}"
+
#define IS_OPTIMIZED "{${function.is-optimized} [opt]}"
#define IS_ARTIFICIAL "{${frame.is-artificial} [artificial]}"
@@ -130,32 +132,36 @@ static constexpr OptionEnumValueElement g_language_enumerators[] = {
#define DEFAULT_THREAD_FORMAT \
"thread #${thread.index}: tid = ${thread.id%tid}" \
"{, ${frame.pc}}" MODULE_WITH_FUNC FILE_AND_LINE \
- "{, name = '${thread.name}'}" \
- "{, queue = '${thread.queue}'}" \
- "{, activity = '${thread.info.activity.name}'}" \
+ "{, name = ${ansi.fg.green}'${thread.name}'${ansi.normal}}" \
+ "{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}" \
+ "{, activity = " \
+ "${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}" \
"{, ${thread.info.trace_messages} messages}" \
- "{, stop reason = ${thread.stop-reason}}" \
+ "{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}" \
"{\\nReturn value: ${thread.return-value}}" \
"{\\nCompleted expression: ${thread.completed-expression}}" \
"\\n"
#define DEFAULT_THREAD_STOP_FORMAT \
"thread #${thread.index}{, name = '${thread.name}'}" \
- "{, queue = '${thread.queue}'}" \
- "{, activity = '${thread.info.activity.name}'}" \
+ "{, queue = ${ansi.fg.green}'${thread.queue}'${ansi.normal}}" \
+ "{, activity = " \
+ "${ansi.fg.green}'${thread.info.activity.name}'${ansi.normal}}" \
"{, ${thread.info.trace_messages} messages}" \
- "{, stop reason = ${thread.stop-reason}}" \
+ "{, stop reason = ${ansi.fg.red}${thread.stop-reason}${ansi.normal}}" \
"{\\nReturn value: ${thread.return-value}}" \
"{\\nCompleted expression: ${thread.completed-expression}}" \
"\\n"
#define DEFAULT_FRAME_FORMAT \
- "frame #${frame.index}: ${frame.pc}" MODULE_WITH_FUNC FILE_AND_LINE \
+ "frame #${frame.index}: " \
+ "${ansi.fg.yellow}${frame.pc}${ansi.normal}" MODULE_WITH_FUNC FILE_AND_LINE \
IS_OPTIMIZED IS_ARTIFICIAL "\\n"
#define DEFAULT_FRAME_FORMAT_NO_ARGS \
- "frame #${frame.index}: ${frame.pc}" MODULE_WITH_FUNC_NO_ARGS FILE_AND_LINE \
- IS_OPTIMIZED IS_ARTIFICIAL "\\n"
+ "frame #${frame.index}: " \
+ "${ansi.fg.yellow}${frame.pc}${ansi.normal}" MODULE_WITH_FUNC_NO_ARGS \
+ FILE_AND_LINE IS_OPTIMIZED IS_ARTIFICIAL "\\n"
// Three parts to this disassembly format specification:
// 1. If this is a new function/symbol (no previous symbol/function), print
@@ -712,7 +718,7 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
}
DebuggerSP
-Debugger::FindDebuggerWithInstanceName(const ConstString &instance_name) {
+Debugger::FindDebuggerWithInstanceName(ConstString instance_name) {
DebuggerSP debugger_sp;
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {
std::lock_guard<std::recursive_mutex> guard(*g_debugger_list_mutex_ptr);
@@ -761,14 +767,15 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_input_file_sp(std::make_shared<StreamFile>(stdin, false)),
m_output_file_sp(std::make_shared<StreamFile>(stdout, false)),
m_error_file_sp(std::make_shared<StreamFile>(stderr, false)),
+ m_input_recorder(nullptr),
m_broadcaster_manager_sp(BroadcasterManager::MakeBroadcasterManager()),
m_terminal_state(), m_target_list(*this), m_platform_list(),
m_listener_sp(Listener::MakeListener("lldb.Debugger")),
- m_source_manager_ap(), m_source_file_cache(),
- m_command_interpreter_ap(llvm::make_unique<CommandInterpreter>(
- *this, eScriptLanguageDefault, false)),
- m_input_reader_stack(), m_instance_name(), m_loaded_plugins(),
- m_event_handler_thread(), m_io_handler_thread(),
+ m_source_manager_up(), m_source_file_cache(),
+ m_command_interpreter_up(
+ llvm::make_unique<CommandInterpreter>(*this, false)),
+ m_script_interpreter_sp(), m_input_reader_stack(), m_instance_name(),
+ m_loaded_plugins(), m_event_handler_thread(), m_io_handler_thread(),
m_sync_broadcaster(nullptr, "lldb.debugger.sync"),
m_forward_listener_sp(), m_clear_once() {
char instance_cstr[256];
@@ -777,7 +784,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
if (log_callback)
m_log_callback_stream_sp =
std::make_shared<StreamCallback>(log_callback, baton);
- m_command_interpreter_ap->Initialize();
+ m_command_interpreter_up->Initialize();
// Always add our default platform to the platform list
PlatformSP default_platform_sp(Platform::GetHostPlatform());
assert(default_platform_sp);
@@ -794,11 +801,11 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
m_collection_sp->AppendProperty(
ConstString("symbols"), ConstString("Symbol lookup and cache settings."),
true, ModuleList::GetGlobalModuleListProperties().GetValueProperties());
- if (m_command_interpreter_ap) {
+ if (m_command_interpreter_up) {
m_collection_sp->AppendProperty(
ConstString("interpreter"),
ConstString("Settings specify to the debugger's command interpreter."),
- true, m_command_interpreter_ap->GetValueProperties());
+ true, m_command_interpreter_up->GetValueProperties());
}
OptionValueSInt64 *term_width =
m_collection_sp->GetPropertyAtIndexAsOptionValueSInt64(
@@ -824,7 +831,6 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton)
Debugger::~Debugger() { Clear(); }
void Debugger::Clear() {
- //----------------------------------------------------------------------
// Make sure we call this function only once. With the C++ global destructor
// chain having a list of debuggers and with code that can be running on
// other threads, we need to ensure this doesn't happen multiple times.
@@ -833,7 +839,6 @@ void Debugger::Clear() {
// Debugger::~Debugger();
// static void Debugger::Destroy(lldb::DebuggerSP &debugger_sp);
// static void Debugger::Terminate();
- //----------------------------------------------------------------------
llvm::call_once(m_clear_once, [this]() {
ClearIOHandlers();
StopIOHandlerThread();
@@ -857,7 +862,7 @@ void Debugger::Clear() {
if (m_input_file_sp)
m_input_file_sp->GetFile().Close();
- m_command_interpreter_ap->Clear();
+ m_command_interpreter_up->Clear();
});
}
@@ -871,14 +876,18 @@ void Debugger::SetCloseInputOnEOF(bool b) {
}
bool Debugger::GetAsyncExecution() {
- return !m_command_interpreter_ap->GetSynchronous();
+ return !m_command_interpreter_up->GetSynchronous();
}
void Debugger::SetAsyncExecution(bool async_execution) {
- m_command_interpreter_ap->SetSynchronous(!async_execution);
+ m_command_interpreter_up->SetSynchronous(!async_execution);
}
-void Debugger::SetInputFileHandle(FILE *fh, bool tranfer_ownership) {
+repro::DataRecorder *Debugger::GetInputRecorder() { return m_input_recorder; }
+
+void Debugger::SetInputFileHandle(FILE *fh, bool tranfer_ownership,
+ repro::DataRecorder *recorder) {
+ m_input_recorder = recorder;
if (m_input_file_sp)
m_input_file_sp->GetFile().SetStream(fh, tranfer_ownership);
else
@@ -903,12 +912,10 @@ void Debugger::SetOutputFileHandle(FILE *fh, bool tranfer_ownership) {
if (!out_file.IsValid())
out_file.SetStream(stdout, false);
- // do not create the ScriptInterpreter just for setting the output file
- // handle as the constructor will know how to do the right thing on its own
- const bool can_create = false;
- ScriptInterpreter *script_interpreter =
- GetCommandInterpreter().GetScriptInterpreter(can_create);
- if (script_interpreter)
+ // Do not create the ScriptInterpreter just for setting the output file
+ // handle as the constructor will know how to do the right thing on its own.
+ if (ScriptInterpreter *script_interpreter =
+ GetScriptInterpreter(/*can_create=*/false))
script_interpreter->ResetOutputFileHandle(fh);
}
@@ -1286,10 +1293,23 @@ bool Debugger::EnableLog(llvm::StringRef channel,
error_stream);
}
+ScriptInterpreter *Debugger::GetScriptInterpreter(bool can_create) {
+ std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
+
+ if (!m_script_interpreter_sp) {
+ if (!can_create)
+ return nullptr;
+ m_script_interpreter_sp = PluginManager::GetScriptInterpreterForLanguage(
+ GetScriptLanguage(), *this);
+ }
+
+ return m_script_interpreter_sp.get();
+}
+
SourceManager &Debugger::GetSourceManager() {
- if (!m_source_manager_ap)
- m_source_manager_ap = llvm::make_unique<SourceManager>(shared_from_this());
- return *m_source_manager_ap;
+ if (!m_source_manager_up)
+ m_source_manager_up = llvm::make_unique<SourceManager>(shared_from_this());
+ return *m_source_manager_up;
}
// This function handles events that were broadcast by the process.
@@ -1537,7 +1557,7 @@ void Debugger::DefaultEventHandler() {
listener_sp->StartListeningForEventSpec(m_broadcaster_manager_sp,
thread_event_spec);
listener_sp->StartListeningForEvents(
- m_command_interpreter_ap.get(),
+ m_command_interpreter_up.get(),
CommandInterpreter::eBroadcastBitQuitCommandReceived |
CommandInterpreter::eBroadcastBitAsynchronousOutputData |
CommandInterpreter::eBroadcastBitAsynchronousErrorData);
@@ -1564,7 +1584,7 @@ void Debugger::DefaultEventHandler() {
}
} else if (broadcaster_class == broadcaster_class_thread) {
HandleThreadEvent(event_sp);
- } else if (broadcaster == m_command_interpreter_ap.get()) {
+ } else if (broadcaster == m_command_interpreter_up.get()) {
if (event_type &
CommandInterpreter::eBroadcastBitQuitCommandReceived) {
done = true;
@@ -1603,7 +1623,7 @@ void Debugger::DefaultEventHandler() {
lldb::thread_result_t Debugger::EventHandlerThread(lldb::thread_arg_t arg) {
((Debugger *)arg)->DefaultEventHandler();
- return NULL;
+ return {};
}
bool Debugger::StartEventHandlerThread() {
@@ -1622,8 +1642,17 @@ bool Debugger::StartEventHandlerThread() {
full_name.AsCString() : "dbg.evt-handler";
// Use larger 8MB stack for this thread
- m_event_handler_thread = ThreadLauncher::LaunchThread(thread_name,
- EventHandlerThread, this, nullptr, g_debugger_event_thread_stack_bytes);
+ llvm::Expected<HostThread> event_handler_thread =
+ ThreadLauncher::LaunchThread(thread_name, EventHandlerThread, this,
+ g_debugger_event_thread_stack_bytes);
+
+ if (event_handler_thread) {
+ m_event_handler_thread = *event_handler_thread;
+ } else {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(event_handler_thread.takeError()));
+ }
// Make sure DefaultEventHandler() is running and listening to events
// before we return from this function. We are only listening for events of
@@ -1648,16 +1677,24 @@ lldb::thread_result_t Debugger::IOHandlerThread(lldb::thread_arg_t arg) {
Debugger *debugger = (Debugger *)arg;
debugger->ExecuteIOHandlers();
debugger->StopEventHandlerThread();
- return NULL;
+ return {};
}
bool Debugger::HasIOHandlerThread() { return m_io_handler_thread.IsJoinable(); }
bool Debugger::StartIOHandlerThread() {
- if (!m_io_handler_thread.IsJoinable())
- m_io_handler_thread = ThreadLauncher::LaunchThread(
- "lldb.debugger.io-handler", IOHandlerThread, this, nullptr,
+ if (!m_io_handler_thread.IsJoinable()) {
+ llvm::Expected<HostThread> io_handler_thread = ThreadLauncher::LaunchThread(
+ "lldb.debugger.io-handler", IOHandlerThread, this,
8 * 1024 * 1024); // Use larger 8MB stack for this thread
+ if (io_handler_thread) {
+ m_io_handler_thread = *io_handler_thread;
+ } else {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(io_handler_thread.takeError()));
+ }
+ }
return m_io_handler_thread.IsJoinable();
}
diff --git a/source/Core/Disassembler.cpp b/source/Core/Disassembler.cpp
index a34b8038c5892..af7cf82d470ad 100644
--- a/source/Core/Disassembler.cpp
+++ b/source/Core/Disassembler.cpp
@@ -1,9 +1,8 @@
//===-- Disassembler.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -162,7 +161,7 @@ size_t Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
bool Disassembler::Disassemble(Debugger &debugger, const ArchSpec &arch,
const char *plugin_name, const char *flavor,
const ExecutionContext &exe_ctx,
- const ConstString &name, Module *module,
+ ConstString name, Module *module,
uint32_t num_instructions,
bool mixed_source_and_assembly,
uint32_t num_mixed_context_lines,
@@ -742,11 +741,11 @@ void Instruction::Dump(lldb_private::Stream *s, uint32_t max_opcode_byte_size,
}
bool Instruction::DumpEmulation(const ArchSpec &arch) {
- std::unique_ptr<EmulateInstruction> insn_emulator_ap(
+ std::unique_ptr<EmulateInstruction> insn_emulator_up(
EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
- if (insn_emulator_ap) {
- insn_emulator_ap->SetInstruction(GetOpcode(), GetAddress(), nullptr);
- return insn_emulator_ap->EvaluateInstruction(0);
+ if (insn_emulator_up) {
+ insn_emulator_up->SetInstruction(GetOpcode(), GetAddress(), nullptr);
+ return insn_emulator_up->EvaluateInstruction(0);
}
return false;
@@ -993,11 +992,11 @@ bool Instruction::TestEmulation(Stream *out_stream, const char *file_name) {
arch.SetTriple(llvm::Triple(value_sp->GetStringValue()));
bool success = false;
- std::unique_ptr<EmulateInstruction> insn_emulator_ap(
+ std::unique_ptr<EmulateInstruction> insn_emulator_up(
EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
- if (insn_emulator_ap)
+ if (insn_emulator_up)
success =
- insn_emulator_ap->TestEmulation(out_stream, arch, data_dictionary);
+ insn_emulator_up->TestEmulation(out_stream, arch, data_dictionary);
if (success)
out_stream->Printf("Emulation test succeeded.");
@@ -1013,14 +1012,14 @@ bool Instruction::Emulate(
EmulateInstruction::WriteMemoryCallback write_mem_callback,
EmulateInstruction::ReadRegisterCallback read_reg_callback,
EmulateInstruction::WriteRegisterCallback write_reg_callback) {
- std::unique_ptr<EmulateInstruction> insn_emulator_ap(
+ std::unique_ptr<EmulateInstruction> insn_emulator_up(
EmulateInstruction::FindPlugin(arch, eInstructionTypeAny, nullptr));
- if (insn_emulator_ap) {
- insn_emulator_ap->SetBaton(baton);
- insn_emulator_ap->SetCallbacks(read_mem_callback, write_mem_callback,
+ if (insn_emulator_up) {
+ insn_emulator_up->SetBaton(baton);
+ insn_emulator_up->SetCallbacks(read_mem_callback, write_mem_callback,
read_reg_callback, write_reg_callback);
- insn_emulator_ap->SetInstruction(GetOpcode(), GetAddress(), nullptr);
- return insn_emulator_ap->EvaluateInstruction(evaluate_options);
+ insn_emulator_up->SetInstruction(GetOpcode(), GetAddress(), nullptr);
+ return insn_emulator_up->EvaluateInstruction(evaluate_options);
}
return false;
@@ -1088,13 +1087,16 @@ void InstructionList::Append(lldb::InstructionSP &inst_sp) {
uint32_t
InstructionList::GetIndexOfNextBranchInstruction(uint32_t start,
- Target &target) const {
+ Target &target,
+ bool ignore_calls) const {
size_t num_instructions = m_instructions.size();
uint32_t next_branch = UINT32_MAX;
size_t i;
for (i = start; i < num_instructions; i++) {
if (m_instructions[i]->DoesBranch()) {
+ if (ignore_calls && m_instructions[i]->IsCall())
+ continue;
next_branch = i;
break;
}
@@ -1238,9 +1240,7 @@ size_t Disassembler::ParseInstructions(const ExecutionContext *exe_ctx,
return m_instruction_list.GetSize();
}
-//----------------------------------------------------------------------
// Disassembler copy constructor
-//----------------------------------------------------------------------
Disassembler::Disassembler(const ArchSpec &arch, const char *flavor)
: m_arch(arch), m_instruction_list(), m_base_addr(LLDB_INVALID_ADDRESS),
m_flavor() {
@@ -1272,9 +1272,7 @@ const InstructionList &Disassembler::GetInstructionList() const {
return m_instruction_list;
}
-//----------------------------------------------------------------------
// Class PseudoInstruction
-//----------------------------------------------------------------------
PseudoInstruction::PseudoInstruction()
: Instruction(Address(), AddressClass::eUnknown), m_description() {}
diff --git a/source/Core/DumpDataExtractor.cpp b/source/Core/DumpDataExtractor.cpp
index 43a026d0dcb29..aa84370e223a5 100644
--- a/source/Core/DumpDataExtractor.cpp
+++ b/source/Core/DumpDataExtractor.cpp
@@ -1,9 +1,8 @@
//===-- DumpDataExtractor.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -552,7 +551,7 @@ lldb::offset_t lldb_private::DumpDataExtractor(
case eFormatFloat: {
TargetSP target_sp;
- bool used_apfloat = false;
+ bool used_upfloat = false;
if (exe_scope)
target_sp = exe_scope->CalculateTarget();
if (target_sp) {
@@ -601,13 +600,13 @@ lldb::offset_t lldb_private::DumpDataExtractor(
if (!sv.empty()) {
s->Printf("%*.*s", (int)sv.size(), (int)sv.size(), sv.data());
- used_apfloat = true;
+ used_upfloat = true;
}
}
}
}
- if (!used_apfloat) {
+ if (!used_upfloat) {
std::ostringstream ss;
if (item_byte_size == sizeof(float) || item_byte_size == 2) {
float f;
diff --git a/source/Core/DumpRegisterValue.cpp b/source/Core/DumpRegisterValue.cpp
index d7196a585667a..74b02413f1018 100644
--- a/source/Core/DumpRegisterValue.cpp
+++ b/source/Core/DumpRegisterValue.cpp
@@ -1,9 +1,8 @@
//===-- DumpRegisterValue.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Core/DynamicLoader.cpp b/source/Core/DynamicLoader.cpp
index 72ee3cfd6d5b6..57130d6fa57a1 100644
--- a/source/Core/DynamicLoader.cpp
+++ b/source/Core/DynamicLoader.cpp
@@ -1,9 +1,8 @@
//===-- DynamicLoader.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,10 +38,10 @@ DynamicLoader *DynamicLoader::FindPlugin(Process *process,
PluginManager::GetDynamicLoaderCreateCallbackForPluginName(
const_plugin_name);
if (create_callback) {
- std::unique_ptr<DynamicLoader> instance_ap(
+ std::unique_ptr<DynamicLoader> instance_up(
create_callback(process, true));
- if (instance_ap)
- return instance_ap.release();
+ if (instance_up)
+ return instance_up.release();
}
} else {
for (uint32_t idx = 0;
@@ -50,10 +49,10 @@ DynamicLoader *DynamicLoader::FindPlugin(Process *process,
PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) !=
nullptr;
++idx) {
- std::unique_ptr<DynamicLoader> instance_ap(
+ std::unique_ptr<DynamicLoader> instance_up(
create_callback(process, false));
- if (instance_ap)
- return instance_ap.release();
+ if (instance_up)
+ return instance_up.release();
}
}
return nullptr;
@@ -63,10 +62,8 @@ DynamicLoader::DynamicLoader(Process *process) : m_process(process) {}
DynamicLoader::~DynamicLoader() = default;
-//----------------------------------------------------------------------
// Accessosors to the global setting as to whether to stop at image (shared
// library) loading/unloading.
-//----------------------------------------------------------------------
bool DynamicLoader::GetStopWhenImagesChange() const {
return m_process->GetStopOnSharedLibraryEvents();
@@ -97,7 +94,7 @@ ModuleSP DynamicLoader::GetTargetExecutable() {
}
if (!executable) {
- executable = target.GetSharedModule(module_spec);
+ executable = target.GetOrCreateModule(module_spec, true /* notify */);
if (executable.get() != target.GetExecutableModulePointer()) {
// Don't load dependent images since we are in dyld where we will
// know and find out about all images that are loaded
@@ -167,7 +164,8 @@ ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
return module_sp;
}
- if ((module_sp = target.GetSharedModule(module_spec))) {
+ if ((module_sp = target.GetOrCreateModule(module_spec,
+ true /* notify */))) {
UpdateLoadedSections(module_sp, link_map_addr, base_addr,
base_addr_is_offset);
return module_sp;
@@ -203,7 +201,8 @@ ModuleSP DynamicLoader::LoadModuleAtAddress(const FileSpec &file,
return module_sp;
}
- if ((module_sp = target.GetSharedModule(new_module_spec))) {
+ if ((module_sp = target.GetOrCreateModule(new_module_spec,
+ true /* notify */))) {
UpdateLoadedSections(module_sp, link_map_addr, base_addr, false);
return module_sp;
}
diff --git a/source/Core/EmulateInstruction.cpp b/source/Core/EmulateInstruction.cpp
index 0fcb2eb7e8cea..62942fb715b3e 100644
--- a/source/Core/EmulateInstruction.cpp
+++ b/source/Core/EmulateInstruction.cpp
@@ -1,9 +1,8 @@
//===-- EmulateInstruction.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -72,14 +71,7 @@ EmulateInstruction::FindPlugin(const ArchSpec &arch,
return nullptr;
}
-EmulateInstruction::EmulateInstruction(const ArchSpec &arch)
- : m_arch(arch), m_baton(nullptr), m_read_mem_callback(&ReadMemoryDefault),
- m_write_mem_callback(&WriteMemoryDefault),
- m_read_reg_callback(&ReadRegisterDefault),
- m_write_reg_callback(&WriteRegisterDefault),
- m_addr(LLDB_INVALID_ADDRESS) {
- ::memset(&m_opcode, 0, sizeof(m_opcode));
-}
+EmulateInstruction::EmulateInstruction(const ArchSpec &arch) : m_arch(arch) {}
bool EmulateInstruction::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &reg_value) {
diff --git a/source/Core/FileLineResolver.cpp b/source/Core/FileLineResolver.cpp
index 0f4120711b246..3cba1c7e81432 100644
--- a/source/Core/FileLineResolver.cpp
+++ b/source/Core/FileLineResolver.cpp
@@ -1,9 +1,8 @@
//===-- FileLineResolver.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@ class Address;
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// FileLineResolver:
-//----------------------------------------------------------------------
FileLineResolver::FileLineResolver(const FileSpec &file_spec, uint32_t line_no,
bool check_inlines)
: Searcher(), m_file_spec(file_spec), m_line_number(line_no),
diff --git a/source/Core/FileSpecList.cpp b/source/Core/FileSpecList.cpp
index ae4831b6efa61..95133faf7502e 100644
--- a/source/Core/FileSpecList.cpp
+++ b/source/Core/FileSpecList.cpp
@@ -1,9 +1,8 @@
//===-- FileSpecList.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,32 +20,17 @@ using namespace std;
FileSpecList::FileSpecList() : m_files() {}
-FileSpecList::FileSpecList(const FileSpecList &rhs) = default;
-
FileSpecList::~FileSpecList() = default;
-//------------------------------------------------------------------
-// Assignment operator
-//------------------------------------------------------------------
-const FileSpecList &FileSpecList::operator=(const FileSpecList &rhs) {
- if (this != &rhs)
- m_files = rhs.m_files;
- return *this;
-}
-
-//------------------------------------------------------------------
// Append the "file_spec" to the end of the file spec list.
-//------------------------------------------------------------------
void FileSpecList::Append(const FileSpec &file_spec) {
m_files.push_back(file_spec);
}
-//------------------------------------------------------------------
// Only append the "file_spec" if this list doesn't already contain it.
//
// Returns true if "file_spec" was added, false if this list already contained
// a copy of "file_spec".
-//------------------------------------------------------------------
bool FileSpecList::AppendIfUnique(const FileSpec &file_spec) {
collection::iterator end = m_files.end();
if (find(m_files.begin(), end, file_spec) == end) {
@@ -56,14 +40,10 @@ bool FileSpecList::AppendIfUnique(const FileSpec &file_spec) {
return false;
}
-//------------------------------------------------------------------
// Clears the file list.
-//------------------------------------------------------------------
void FileSpecList::Clear() { m_files.clear(); }
-//------------------------------------------------------------------
// Dumps the file list to the supplied stream pointer "s".
-//------------------------------------------------------------------
void FileSpecList::Dump(Stream *s, const char *separator_cstr) const {
collection::const_iterator pos, end = m_files.end();
for (pos = m_files.begin(); pos != end; ++pos) {
@@ -73,13 +53,11 @@ void FileSpecList::Dump(Stream *s, const char *separator_cstr) const {
}
}
-//------------------------------------------------------------------
// Find the index of the file in the file spec list that matches "file_spec"
// starting "start_idx" entries into the file spec list.
//
// Returns the valid index of the file that matches "file_spec" if it is found,
// else std::numeric_limits<uint32_t>::max() is returned.
-//------------------------------------------------------------------
size_t FileSpecList::FindFileIndex(size_t start_idx, const FileSpec &file_spec,
bool full) const {
const size_t num_files = m_files.size();
@@ -104,10 +82,8 @@ size_t FileSpecList::FindFileIndex(size_t start_idx, const FileSpec &file_spec,
return UINT32_MAX;
}
-//------------------------------------------------------------------
// Returns the FileSpec object at index "idx". If "idx" is out of range, then
// an empty FileSpec object will be returned.
-//------------------------------------------------------------------
const FileSpec &FileSpecList::GetFileSpecAtIndex(size_t idx) const {
if (idx < m_files.size())
return m_files[idx];
@@ -121,12 +97,10 @@ const FileSpec *FileSpecList::GetFileSpecPointerAtIndex(size_t idx) const {
return nullptr;
}
-//------------------------------------------------------------------
// Return the size in bytes that this object takes in memory. This returns the
// size in bytes of this object's member variables and any FileSpec objects its
// member variables contain, the result doesn't not include the string values
// for the directories any filenames as those are in shared string pools.
-//------------------------------------------------------------------
size_t FileSpecList::MemorySize() const {
size_t mem_size = sizeof(FileSpecList);
collection::const_iterator pos, end = m_files.end();
@@ -137,9 +111,7 @@ size_t FileSpecList::MemorySize() const {
return mem_size;
}
-//------------------------------------------------------------------
// Return the number of files in the file spec list.
-//------------------------------------------------------------------
size_t FileSpecList::GetSize() const { return m_files.size(); }
size_t FileSpecList::GetFilesMatchingPartialPath(const char *path,
diff --git a/source/Core/FormatEntity.cpp b/source/Core/FormatEntity.cpp
index 200008dcff5fd..1ffbed2cd64e6 100644
--- a/source/Core/FormatEntity.cpp
+++ b/source/Core/FormatEntity.cpp
@@ -1,9 +1,8 @@
//===-- FormatEntity.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -80,108 +79,98 @@ using namespace lldb_private;
enum FileKind { FileError = 0, Basename, Dirname, Fullpath };
-#define ENTRY(n, t, f) \
- { \
- n, nullptr, FormatEntity::Entry::Type::t, \
- FormatEntity::Entry::FormatType::f, 0, 0, nullptr, false \
- }
-#define ENTRY_VALUE(n, t, f, v) \
+#define ENTRY(n, t) \
+ { n, nullptr, FormatEntity::Entry::Type::t, 0, 0, nullptr, false }
+#define ENTRY_VALUE(n, t, v) \
+ { n, nullptr, FormatEntity::Entry::Type::t, v, 0, nullptr, false }
+#define ENTRY_CHILDREN(n, t, c) \
{ \
- n, nullptr, FormatEntity::Entry::Type::t, \
- FormatEntity::Entry::FormatType::f, v, 0, nullptr, false \
- }
-#define ENTRY_CHILDREN(n, t, f, c) \
- { \
- n, nullptr, FormatEntity::Entry::Type::t, \
- FormatEntity::Entry::FormatType::f, 0, \
+ n, nullptr, FormatEntity::Entry::Type::t, 0, \
static_cast<uint32_t>(llvm::array_lengthof(c)), c, false \
}
-#define ENTRY_CHILDREN_KEEP_SEP(n, t, f, c) \
+#define ENTRY_CHILDREN_KEEP_SEP(n, t, c) \
{ \
- n, nullptr, FormatEntity::Entry::Type::t, \
- FormatEntity::Entry::FormatType::f, 0, \
+ n, nullptr, FormatEntity::Entry::Type::t, 0, \
static_cast<uint32_t>(llvm::array_lengthof(c)), c, true \
}
#define ENTRY_STRING(n, s) \
- { \
- n, s, FormatEntity::Entry::Type::InsertString, \
- FormatEntity::Entry::FormatType::None, 0, 0, nullptr, false \
- }
+ { n, s, FormatEntity::Entry::Type::EscapeCode, 0, 0, nullptr, false }
static FormatEntity::Entry::Definition g_string_entry[] = {
- ENTRY("*", ParentString, None)};
+ ENTRY("*", ParentString)};
static FormatEntity::Entry::Definition g_addr_entries[] = {
- ENTRY("load", AddressLoad, UInt64), ENTRY("file", AddressFile, UInt64),
- ENTRY("load", AddressLoadOrFile, UInt64),
+ ENTRY("load", AddressLoad),
+ ENTRY("file", AddressFile),
+ ENTRY("load", AddressLoadOrFile),
};
static FormatEntity::Entry::Definition g_file_child_entries[] = {
- ENTRY_VALUE("basename", ParentNumber, CString, FileKind::Basename),
- ENTRY_VALUE("dirname", ParentNumber, CString, FileKind::Dirname),
- ENTRY_VALUE("fullpath", ParentNumber, CString, FileKind::Fullpath)};
+ ENTRY_VALUE("basename", ParentNumber, FileKind::Basename),
+ ENTRY_VALUE("dirname", ParentNumber, FileKind::Dirname),
+ ENTRY_VALUE("fullpath", ParentNumber, FileKind::Fullpath)};
static FormatEntity::Entry::Definition g_frame_child_entries[] = {
- ENTRY("index", FrameIndex, UInt32),
- ENTRY("pc", FrameRegisterPC, UInt64),
- ENTRY("fp", FrameRegisterFP, UInt64),
- ENTRY("sp", FrameRegisterSP, UInt64),
- ENTRY("flags", FrameRegisterFlags, UInt64),
- ENTRY("no-debug", FrameNoDebug, None),
- ENTRY_CHILDREN("reg", FrameRegisterByName, UInt64, g_string_entry),
- ENTRY("is-artificial", FrameIsArtificial, UInt32),
+ ENTRY("index", FrameIndex),
+ ENTRY("pc", FrameRegisterPC),
+ ENTRY("fp", FrameRegisterFP),
+ ENTRY("sp", FrameRegisterSP),
+ ENTRY("flags", FrameRegisterFlags),
+ ENTRY("no-debug", FrameNoDebug),
+ ENTRY_CHILDREN("reg", FrameRegisterByName, g_string_entry),
+ ENTRY("is-artificial", FrameIsArtificial),
};
static FormatEntity::Entry::Definition g_function_child_entries[] = {
- ENTRY("id", FunctionID, UInt64), ENTRY("name", FunctionName, CString),
- ENTRY("name-without-args", FunctionNameNoArgs, CString),
- ENTRY("name-with-args", FunctionNameWithArgs, CString),
- ENTRY("addr-offset", FunctionAddrOffset, UInt64),
- ENTRY("concrete-only-addr-offset-no-padding", FunctionAddrOffsetConcrete,
- UInt64),
- ENTRY("line-offset", FunctionLineOffset, UInt64),
- ENTRY("pc-offset", FunctionPCOffset, UInt64),
- ENTRY("initial-function", FunctionInitial, None),
- ENTRY("changed", FunctionChanged, None),
- ENTRY("is-optimized", FunctionIsOptimized, None)};
+ ENTRY("id", FunctionID),
+ ENTRY("name", FunctionName),
+ ENTRY("name-without-args", FunctionNameNoArgs),
+ ENTRY("name-with-args", FunctionNameWithArgs),
+ ENTRY("addr-offset", FunctionAddrOffset),
+ ENTRY("concrete-only-addr-offset-no-padding", FunctionAddrOffsetConcrete),
+ ENTRY("line-offset", FunctionLineOffset),
+ ENTRY("pc-offset", FunctionPCOffset),
+ ENTRY("initial-function", FunctionInitial),
+ ENTRY("changed", FunctionChanged),
+ ENTRY("is-optimized", FunctionIsOptimized)};
static FormatEntity::Entry::Definition g_line_child_entries[] = {
- ENTRY_CHILDREN("file", LineEntryFile, None, g_file_child_entries),
- ENTRY("number", LineEntryLineNumber, UInt32),
- ENTRY("column", LineEntryColumn, UInt32),
- ENTRY("start-addr", LineEntryStartAddress, UInt64),
- ENTRY("end-addr", LineEntryEndAddress, UInt64),
+ ENTRY_CHILDREN("file", LineEntryFile, g_file_child_entries),
+ ENTRY("number", LineEntryLineNumber),
+ ENTRY("column", LineEntryColumn),
+ ENTRY("start-addr", LineEntryStartAddress),
+ ENTRY("end-addr", LineEntryEndAddress),
};
static FormatEntity::Entry::Definition g_module_child_entries[] = {
- ENTRY_CHILDREN("file", ModuleFile, None, g_file_child_entries),
+ ENTRY_CHILDREN("file", ModuleFile, g_file_child_entries),
};
static FormatEntity::Entry::Definition g_process_child_entries[] = {
- ENTRY("id", ProcessID, UInt64),
- ENTRY_VALUE("name", ProcessFile, CString, FileKind::Basename),
- ENTRY_CHILDREN("file", ProcessFile, None, g_file_child_entries),
+ ENTRY("id", ProcessID),
+ ENTRY_VALUE("name", ProcessFile, FileKind::Basename),
+ ENTRY_CHILDREN("file", ProcessFile, g_file_child_entries),
};
static FormatEntity::Entry::Definition g_svar_child_entries[] = {
- ENTRY("*", ParentString, None)};
+ ENTRY("*", ParentString)};
static FormatEntity::Entry::Definition g_var_child_entries[] = {
- ENTRY("*", ParentString, None)};
+ ENTRY("*", ParentString)};
static FormatEntity::Entry::Definition g_thread_child_entries[] = {
- ENTRY("id", ThreadID, UInt64),
- ENTRY("protocol_id", ThreadProtocolID, UInt64),
- ENTRY("index", ThreadIndexID, UInt32),
- ENTRY_CHILDREN("info", ThreadInfo, None, g_string_entry),
- ENTRY("queue", ThreadQueue, CString),
- ENTRY("name", ThreadName, CString),
- ENTRY("stop-reason", ThreadStopReason, CString),
- ENTRY("return-value", ThreadReturnValue, CString),
- ENTRY("completed-expression", ThreadCompletedExpression, CString),
+ ENTRY("id", ThreadID),
+ ENTRY("protocol_id", ThreadProtocolID),
+ ENTRY("index", ThreadIndexID),
+ ENTRY_CHILDREN("info", ThreadInfo, g_string_entry),
+ ENTRY("queue", ThreadQueue),
+ ENTRY("name", ThreadName),
+ ENTRY("stop-reason", ThreadStopReason),
+ ENTRY("return-value", ThreadReturnValue),
+ ENTRY("completed-expression", ThreadCompletedExpression),
};
static FormatEntity::Entry::Definition g_target_child_entries[] = {
- ENTRY("arch", TargetArch, CString),
+ ENTRY("arch", TargetArch),
};
#define _TO_STR2(_val) #_val
@@ -224,8 +213,8 @@ static FormatEntity::Entry::Definition g_ansi_bg_entries[] = {
};
static FormatEntity::Entry::Definition g_ansi_entries[] = {
- ENTRY_CHILDREN("fg", Invalid, None, g_ansi_fg_entries),
- ENTRY_CHILDREN("bg", Invalid, None, g_ansi_bg_entries),
+ ENTRY_CHILDREN("fg", Invalid, g_ansi_fg_entries),
+ ENTRY_CHILDREN("bg", Invalid, g_ansi_bg_entries),
ENTRY_STRING("normal",
ANSI_ESC_START _TO_STR(ANSI_CTRL_NORMAL) ANSI_ESC_END),
ENTRY_STRING("bold", ANSI_ESC_START _TO_STR(ANSI_CTRL_BOLD) ANSI_ESC_END),
@@ -247,37 +236,33 @@ static FormatEntity::Entry::Definition g_ansi_entries[] = {
};
static FormatEntity::Entry::Definition g_script_child_entries[] = {
- ENTRY("frame", ScriptFrame, None),
- ENTRY("process", ScriptProcess, None),
- ENTRY("target", ScriptTarget, None),
- ENTRY("thread", ScriptThread, None),
- ENTRY("var", ScriptVariable, None),
- ENTRY("svar", ScriptVariableSynthetic, None),
- ENTRY("thread", ScriptThread, None),
+ ENTRY("frame", ScriptFrame), ENTRY("process", ScriptProcess),
+ ENTRY("target", ScriptTarget), ENTRY("thread", ScriptThread),
+ ENTRY("var", ScriptVariable), ENTRY("svar", ScriptVariableSynthetic),
+ ENTRY("thread", ScriptThread),
};
static FormatEntity::Entry::Definition g_top_level_entries[] = {
- ENTRY_CHILDREN("addr", AddressLoadOrFile, UInt64, g_addr_entries),
- ENTRY("addr-file-or-load", AddressLoadOrFile, UInt64),
- ENTRY_CHILDREN("ansi", Invalid, None, g_ansi_entries),
- ENTRY("current-pc-arrow", CurrentPCArrow, CString),
- ENTRY_CHILDREN("file", File, CString, g_file_child_entries),
- ENTRY("language", Lang, CString),
- ENTRY_CHILDREN("frame", Invalid, None, g_frame_child_entries),
- ENTRY_CHILDREN("function", Invalid, None, g_function_child_entries),
- ENTRY_CHILDREN("line", Invalid, None, g_line_child_entries),
- ENTRY_CHILDREN("module", Invalid, None, g_module_child_entries),
- ENTRY_CHILDREN("process", Invalid, None, g_process_child_entries),
- ENTRY_CHILDREN("script", Invalid, None, g_script_child_entries),
- ENTRY_CHILDREN_KEEP_SEP("svar", VariableSynthetic, None,
- g_svar_child_entries),
- ENTRY_CHILDREN("thread", Invalid, None, g_thread_child_entries),
- ENTRY_CHILDREN("target", Invalid, None, g_target_child_entries),
- ENTRY_CHILDREN_KEEP_SEP("var", Variable, None, g_var_child_entries),
+ ENTRY_CHILDREN("addr", AddressLoadOrFile, g_addr_entries),
+ ENTRY("addr-file-or-load", AddressLoadOrFile),
+ ENTRY_CHILDREN("ansi", Invalid, g_ansi_entries),
+ ENTRY("current-pc-arrow", CurrentPCArrow),
+ ENTRY_CHILDREN("file", File, g_file_child_entries),
+ ENTRY("language", Lang),
+ ENTRY_CHILDREN("frame", Invalid, g_frame_child_entries),
+ ENTRY_CHILDREN("function", Invalid, g_function_child_entries),
+ ENTRY_CHILDREN("line", Invalid, g_line_child_entries),
+ ENTRY_CHILDREN("module", Invalid, g_module_child_entries),
+ ENTRY_CHILDREN("process", Invalid, g_process_child_entries),
+ ENTRY_CHILDREN("script", Invalid, g_script_child_entries),
+ ENTRY_CHILDREN_KEEP_SEP("svar", VariableSynthetic, g_svar_child_entries),
+ ENTRY_CHILDREN("thread", Invalid, g_thread_child_entries),
+ ENTRY_CHILDREN("target", Invalid, g_target_child_entries),
+ ENTRY_CHILDREN_KEEP_SEP("var", Variable, g_var_child_entries),
};
static FormatEntity::Entry::Definition g_root =
- ENTRY_CHILDREN("<root>", Root, None, g_top_level_entries);
+ ENTRY_CHILDREN("<root>", Root, g_top_level_entries);
FormatEntity::Entry::Entry(llvm::StringRef s)
: string(s.data(), s.size()), printf_format(), children(),
@@ -322,7 +307,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
ENUM_TO_CSTR(Invalid);
ENUM_TO_CSTR(ParentNumber);
ENUM_TO_CSTR(ParentString);
- ENUM_TO_CSTR(InsertString);
+ ENUM_TO_CSTR(EscapeCode);
ENUM_TO_CSTR(Root);
ENUM_TO_CSTR(String);
ENUM_TO_CSTR(Scope);
@@ -411,7 +396,7 @@ static bool RunScriptFormatKeyword(Stream &s, const SymbolContext *sc,
if (target) {
ScriptInterpreter *script_interpreter =
- target->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ target->GetDebugger().GetScriptInterpreter();
if (script_interpreter) {
Status error;
std::string script_output;
@@ -477,9 +462,8 @@ static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc,
// can be discontiguous.
Block *inline_block = sc->block->GetContainingInlinedBlock();
AddressRange inline_range;
- if (inline_block &&
- inline_block->GetRangeContainingAddress(format_addr,
- inline_range))
+ if (inline_block && inline_block->GetRangeContainingAddress(
+ format_addr, inline_range))
func_addr = inline_range.GetBaseAddress();
}
} else if (sc->symbol && sc->symbol->ValueIsAddress())
@@ -1118,9 +1102,18 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
// FormatEntity::Entry::Definition encoding
case Entry::Type::ParentString: // Only used for
// FormatEntity::Entry::Definition encoding
- case Entry::Type::InsertString: // Only used for
- // FormatEntity::Entry::Definition encoding
return false;
+ case Entry::Type::EscapeCode:
+ if (exe_ctx) {
+ if (Target *target = exe_ctx->GetTargetPtr()) {
+ Debugger &debugger = target->GetDebugger();
+ if (debugger.GetUseColor()) {
+ s.PutCString(entry.string);
+ }
+ }
+ }
+ // Always return true, so colors being disabled is transparent.
+ return true;
case Entry::Type::Root:
for (const auto &child : entry.children) {
@@ -1715,8 +1708,9 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
var_representation = buffer;
} else
var_value_sp->DumpPrintableRepresentation(
- ss, ValueObject::ValueObjectRepresentationStyle::
- eValueObjectRepresentationStyleSummary,
+ ss,
+ ValueObject::ValueObjectRepresentationStyle::
+ eValueObjectRepresentationStyleSummary,
eFormatDefault,
ValueObject::PrintableRepresentationSpecialCases::eAllow,
false);
@@ -1911,7 +1905,7 @@ static Status ParseEntry(const llvm::StringRef &format_str,
entry.number = entry_def->data;
return error; // Success
- case FormatEntity::Entry::Type::InsertString:
+ case FormatEntity::Entry::Type::EscapeCode:
entry.type = entry_def->type;
entry.string = entry_def->string;
return error; // Success
@@ -2280,13 +2274,7 @@ Status FormatEntity::ParseInternal(llvm::StringRef &format, Entry &parent_entry,
return error;
}
}
- // Check if this entry just wants to insert a constant string value
- // into the parent_entry, if so, insert the string with AppendText,
- // else append the entry to the parent_entry.
- if (entry.type == Entry::Type::InsertString)
- parent_entry.AppendText(entry.string.c_str());
- else
- parent_entry.AppendEntry(std::move(entry));
+ parent_entry.AppendEntry(std::move(entry));
}
}
break;
diff --git a/source/Core/Highlighter.cpp b/source/Core/Highlighter.cpp
index c7dd0db83645f..0b0aa969bf654 100644
--- a/source/Core/Highlighter.cpp
+++ b/source/Core/Highlighter.cpp
@@ -1,9 +1,8 @@
//===-- Highlighter.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Core/IOHandler.cpp b/source/Core/IOHandler.cpp
index 5c0eea5ea1a3f..b30308490cca5 100644
--- a/source/Core/IOHandler.cpp
+++ b/source/Core/IOHandler.cpp
@@ -1,9 +1,8 @@
//===-- IOHandler.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -77,16 +76,19 @@ IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type)
StreamFileSP(), // Adopt STDIN from top input reader
StreamFileSP(), // Adopt STDOUT from top input reader
StreamFileSP(), // Adopt STDERR from top input reader
- 0) // Flags
-{}
+ 0, // Flags
+ nullptr // Shadow file recorder
+ ) {}
IOHandler::IOHandler(Debugger &debugger, IOHandler::Type type,
const lldb::StreamFileSP &input_sp,
const lldb::StreamFileSP &output_sp,
- const lldb::StreamFileSP &error_sp, uint32_t flags)
+ const lldb::StreamFileSP &error_sp, uint32_t flags,
+ repro::DataRecorder *data_recorder)
: m_debugger(debugger), m_input_sp(input_sp), m_output_sp(output_sp),
- m_error_sp(error_sp), m_popped(false), m_flags(flags), m_type(type),
- m_user_data(nullptr), m_done(false), m_active(false) {
+ m_error_sp(error_sp), m_data_recorder(data_recorder), m_popped(false),
+ m_flags(flags), m_type(type), m_user_data(nullptr), m_done(false),
+ m_active(false) {
// If any files are not specified, then adopt them from the top input reader.
if (!m_input_sp || !m_output_sp || !m_error_sp)
debugger.AdoptTopIOHandlerFilesIfInvalid(m_input_sp, m_output_sp,
@@ -154,7 +156,7 @@ IOHandlerConfirm::IOHandlerConfirm(Debugger &debugger, llvm::StringRef prompt,
llvm::StringRef(), // No continuation prompt
false, // Multi-line
false, // Don't colorize the prompt (i.e. the confirm message.)
- 0, *this),
+ 0, *this, nullptr),
m_default_response(default_response), m_user_response(default_response) {
StreamString prompt_stream;
prompt_stream.PutCString(prompt);
@@ -265,7 +267,7 @@ IOHandlerEditline::IOHandlerEditline(
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,
- IOHandlerDelegate &delegate)
+ IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
: IOHandlerEditline(debugger, type,
StreamFileSP(), // Inherit input from top input reader
StreamFileSP(), // Inherit output from top input reader
@@ -273,7 +275,7 @@ IOHandlerEditline::IOHandlerEditline(
0, // Flags
editline_name, // Used for saving history files
prompt, continuation_prompt, multi_line, color_prompts,
- line_number_start, delegate) {}
+ line_number_start, delegate, data_recorder) {}
IOHandlerEditline::IOHandlerEditline(
Debugger &debugger, IOHandler::Type type,
@@ -282,10 +284,11 @@ IOHandlerEditline::IOHandlerEditline(
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,
- IOHandlerDelegate &delegate)
- : IOHandler(debugger, type, input_sp, output_sp, error_sp, flags),
+ IOHandlerDelegate &delegate, repro::DataRecorder *data_recorder)
+ : IOHandler(debugger, type, input_sp, output_sp, error_sp, flags,
+ data_recorder),
#ifndef LLDB_DISABLE_LIBEDIT
- m_editline_ap(),
+ m_editline_up(),
#endif
m_delegate(delegate), m_prompt(), m_continuation_prompt(),
m_current_lines_ptr(nullptr), m_base_line_number(line_number_start),
@@ -300,17 +303,17 @@ IOHandlerEditline::IOHandlerEditline(
use_editline = m_input_sp->GetFile().GetIsRealTerminal();
if (use_editline) {
- m_editline_ap.reset(new Editline(editline_name, GetInputFILE(),
+ m_editline_up.reset(new Editline(editline_name, GetInputFILE(),
GetOutputFILE(), GetErrorFILE(),
m_color_prompts));
- m_editline_ap->SetIsInputCompleteCallback(IsInputCompleteCallback, this);
- m_editline_ap->SetAutoCompleteCallback(AutoCompleteCallback, this);
+ m_editline_up->SetIsInputCompleteCallback(IsInputCompleteCallback, this);
+ m_editline_up->SetAutoCompleteCallback(AutoCompleteCallback, this);
// See if the delegate supports fixing indentation
const char *indent_chars = delegate.IOHandlerGetFixIndentationCharacters();
if (indent_chars) {
// The delegate does support indentation, hook it up so when any
// indentation character is typed, the delegate gets a chance to fix it
- m_editline_ap->SetFixIndentationCallback(FixIndentationCallback, this,
+ m_editline_up->SetFixIndentationCallback(FixIndentationCallback, this,
indent_chars);
}
}
@@ -322,13 +325,13 @@ IOHandlerEditline::IOHandlerEditline(
IOHandlerEditline::~IOHandlerEditline() {
#ifndef LLDB_DISABLE_LIBEDIT
- m_editline_ap.reset();
+ m_editline_up.reset();
#endif
}
void IOHandlerEditline::Activate() {
IOHandler::Activate();
- m_delegate.IOHandlerActivated(*this);
+ m_delegate.IOHandlerActivated(*this, GetIsInteractive());
}
void IOHandlerEditline::Deactivate() {
@@ -338,8 +341,11 @@ void IOHandlerEditline::Deactivate() {
bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap) {
- return m_editline_ap->GetLine(line, interrupted);
+ if (m_editline_up) {
+ bool b = m_editline_up->GetLine(line, interrupted);
+ if (m_data_recorder)
+ m_data_recorder->Record(line, true);
+ return b;
} else {
#endif
line.clear();
@@ -368,7 +374,18 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
bool got_line = false;
m_editing = true;
while (!done) {
+#ifdef _WIN32
+ // ReadFile on Windows is supposed to set ERROR_OPERATION_ABORTED
+ // according to the docs on MSDN. However, this has evidently been a
+ // known bug since Windows 8. Therefore, we can't detect if a signal
+ // interrupted in the fgets. So pressing ctrl-c causes the repl to end
+ // and the process to exit. A temporary workaround is just to attempt to
+ // fgets twice until this bug is fixed.
+ if (fgets(buffer, sizeof(buffer), in) == nullptr &&
+ fgets(buffer, sizeof(buffer), in) == nullptr) {
+#else
if (fgets(buffer, sizeof(buffer), in) == nullptr) {
+#endif
const int saved_errno = errno;
if (feof(in))
done = true;
@@ -395,6 +412,8 @@ bool IOHandlerEditline::GetLine(std::string &line, bool &interrupted) {
}
}
m_editing = false;
+ if (m_data_recorder && got_line)
+ m_data_recorder->Record(line, true);
// We might have gotten a newline on a line by itself make sure to return
// true in this case.
return got_line;
@@ -441,8 +460,8 @@ int IOHandlerEditline::AutoCompleteCallback(
const char *IOHandlerEditline::GetPrompt() {
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap) {
- return m_editline_ap->GetPrompt();
+ if (m_editline_up) {
+ return m_editline_up->GetPrompt();
} else {
#endif
if (m_prompt.empty())
@@ -457,8 +476,8 @@ bool IOHandlerEditline::SetPrompt(llvm::StringRef prompt) {
m_prompt = prompt;
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- m_editline_ap->SetPrompt(m_prompt.empty() ? nullptr : m_prompt.c_str());
+ if (m_editline_up)
+ m_editline_up->SetPrompt(m_prompt.empty() ? nullptr : m_prompt.c_str());
#endif
return true;
}
@@ -472,8 +491,8 @@ void IOHandlerEditline::SetContinuationPrompt(llvm::StringRef prompt) {
m_continuation_prompt = prompt;
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- m_editline_ap->SetContinuationPrompt(m_continuation_prompt.empty()
+ if (m_editline_up)
+ m_editline_up->SetContinuationPrompt(m_continuation_prompt.empty()
? nullptr
: m_continuation_prompt.c_str());
#endif
@@ -485,8 +504,8 @@ void IOHandlerEditline::SetBaseLineNumber(uint32_t line) {
uint32_t IOHandlerEditline::GetCurrentLineIndex() const {
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- return m_editline_ap->GetCurrentLine();
+ if (m_editline_up)
+ return m_editline_up->GetCurrentLine();
#endif
return m_curr_line_idx;
}
@@ -496,8 +515,8 @@ bool IOHandlerEditline::GetLines(StringList &lines, bool &interrupted) {
bool success = false;
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap) {
- return m_editline_ap->GetLines(m_base_line_number, lines, interrupted);
+ if (m_editline_up) {
+ return m_editline_up->GetLines(m_base_line_number, lines, interrupted);
} else {
#endif
bool done = false;
@@ -565,8 +584,8 @@ void IOHandlerEditline::Run() {
void IOHandlerEditline::Cancel() {
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- m_editline_ap->Cancel();
+ if (m_editline_up)
+ m_editline_up->Cancel();
#endif
}
@@ -576,23 +595,23 @@ bool IOHandlerEditline::Interrupt() {
return true;
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- return m_editline_ap->Interrupt();
+ if (m_editline_up)
+ return m_editline_up->Interrupt();
#endif
return false;
}
void IOHandlerEditline::GotEOF() {
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- m_editline_ap->Interrupt();
+ if (m_editline_up)
+ m_editline_up->Interrupt();
#endif
}
void IOHandlerEditline::PrintAsync(Stream *stream, const char *s, size_t len) {
#ifndef LLDB_DISABLE_LIBEDIT
- if (m_editline_ap)
- m_editline_ap->PrintAsync(stream, s, len);
+ if (m_editline_up)
+ m_editline_up->PrintAsync(stream, s, len);
else
#endif
{
@@ -994,20 +1013,15 @@ public:
WindowSP CreateSubWindow(const char *name, const Rect &bounds,
bool make_active) {
- WindowSP subwindow_sp;
- if (m_window) {
- subwindow_sp.reset(new Window(
- name, ::subwin(m_window, bounds.size.height, bounds.size.width,
- bounds.origin.y, bounds.origin.x),
- true));
- subwindow_sp->m_is_subwin = true;
- } else {
- subwindow_sp.reset(
- new Window(name, ::newwin(bounds.size.height, bounds.size.width,
- bounds.origin.y, bounds.origin.x),
- true));
- subwindow_sp->m_is_subwin = false;
- }
+ auto get_window = [this, &bounds]() {
+ return m_window
+ ? ::subwin(m_window, bounds.size.height, bounds.size.width,
+ bounds.origin.y, bounds.origin.x)
+ : ::newwin(bounds.size.height, bounds.size.width,
+ bounds.origin.y, bounds.origin.x);
+ };
+ WindowSP subwindow_sp = std::make_shared<Window>(name, get_window(), true);
+ subwindow_sp->m_is_subwin = subwindow_sp.operator bool();
subwindow_sp->m_parent = this;
if (make_active) {
m_prev_active_window_idx = m_curr_active_window_idx;
@@ -1075,9 +1089,7 @@ public:
operator WINDOW *() { return m_window; }
- //----------------------------------------------------------------------
// Window drawing utilities
- //----------------------------------------------------------------------
void DrawTitleBox(const char *title, const char *bottom_message = nullptr) {
attr_t attr = 0;
if (IsActive())
@@ -1128,10 +1140,10 @@ public:
const char *text = m_delegate_sp->WindowDelegateGetHelpText();
KeyHelp *key_help = m_delegate_sp->WindowDelegateGetKeyHelp();
if ((text && text[0]) || key_help) {
- std::unique_ptr<HelpDialogDelegate> help_delegate_ap(
+ std::unique_ptr<HelpDialogDelegate> help_delegate_up(
new HelpDialogDelegate(text, key_help));
- const size_t num_lines = help_delegate_ap->GetNumLines();
- const size_t max_length = help_delegate_ap->GetMaxLineLength();
+ const size_t num_lines = help_delegate_up->GetNumLines();
+ const size_t max_length = help_delegate_up->GetMaxLineLength();
Rect bounds = GetBounds();
bounds.Inset(1, 1);
if (max_length + 4 < static_cast<size_t>(bounds.size.width)) {
@@ -1162,7 +1174,7 @@ public:
else
help_window_sp = CreateSubWindow("Help", bounds, true);
help_window_sp->SetDelegate(
- WindowDelegateSP(help_delegate_ap.release()));
+ WindowDelegateSP(help_delegate_up.release()));
return true;
}
}
@@ -1882,7 +1894,7 @@ public:
WindowSP &GetMainWindow() {
if (!m_window_sp)
- m_window_sp.reset(new Window("main", stdscr, false));
+ m_window_sp = std::make_shared<Window>("main", stdscr, false);
return m_window_sp;
}
@@ -2509,7 +2521,7 @@ public:
return; // Children are already up to date
if (!m_frame_delegate_sp) {
// Always expand the thread item the first time we show it
- m_frame_delegate_sp.reset(new FrameTreeDelegate());
+ m_frame_delegate_sp = std::make_shared<FrameTreeDelegate>();
}
m_stop_id = process_sp->GetStopID();
@@ -2601,7 +2613,8 @@ public:
if (!m_thread_delegate_sp) {
// Always expand the thread item the first time we show it
// item.Expand();
- m_thread_delegate_sp.reset(new ThreadTreeDelegate(m_debugger));
+ m_thread_delegate_sp =
+ std::make_shared<ThreadTreeDelegate>(m_debugger);
}
TreeItem t(&item, *m_thread_delegate_sp, false);
@@ -3934,12 +3947,10 @@ public:
m_debugger.GetSourceManager().GetFile(m_sc.line_entry.file);
if (m_file_sp) {
const size_t num_lines = m_file_sp->GetNumLines();
- int m_line_width = 1;
+ m_line_width = 1;
for (size_t n = num_lines; n >= 10; n = n / 10)
++m_line_width;
- snprintf(m_line_format, sizeof(m_line_format), " %%%iu ",
- m_line_width);
if (num_lines < num_visible_lines ||
m_selected_line < num_visible_lines)
m_first_visible_line = 0;
@@ -4056,7 +4067,7 @@ public:
if (bp_attr)
window.AttributeOn(bp_attr);
- window.Printf(m_line_format, curr_line + 1);
+ window.Printf(" %*u ", m_line_width, curr_line + 1);
if (bp_attr)
window.AttributeOff(bp_attr);
@@ -4482,7 +4493,6 @@ protected:
AddressRange m_disassembly_range;
StreamString m_title;
lldb::user_id_t m_tid;
- char m_line_format[8];
int m_line_width;
uint32_t m_selected_line; // The selected line
uint32_t m_pc_line; // The line with the PC
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp
index 943df008edadd..c6759cc944ca9 100644
--- a/source/Core/Mangled.cpp
+++ b/source/Core/Mangled.cpp
@@ -1,9 +1,8 @@
//===-- Mangled.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -73,7 +72,7 @@ static inline bool cstring_is_mangled(const char *s) {
return cstring_mangling_scheme(s) != Mangled::eManglingSchemeNone;
}
-static const ConstString &
+static ConstString
get_demangled_name_without_arguments(ConstString mangled,
ConstString demangled) {
// This pair is <mangled name, demangled name without function arguments>
@@ -125,16 +124,12 @@ get_demangled_name_without_arguments(ConstString mangled,
}
#pragma mark Mangled
-//----------------------------------------------------------------------
// Default constructor
-//----------------------------------------------------------------------
Mangled::Mangled() : m_mangled(), m_demangled() {}
-//----------------------------------------------------------------------
// Constructor with an optional string and a boolean indicating if it is the
// mangled version.
-//----------------------------------------------------------------------
-Mangled::Mangled(const ConstString &s, bool mangled)
+Mangled::Mangled(ConstString s, bool mangled)
: m_mangled(), m_demangled() {
if (s)
SetValue(s, mangled);
@@ -145,7 +140,7 @@ Mangled::Mangled(llvm::StringRef name, bool is_mangled) {
SetValue(ConstString(name), is_mangled);
}
-Mangled::Mangled(const ConstString &s) : m_mangled(), m_demangled() {
+Mangled::Mangled(ConstString s) : m_mangled(), m_demangled() {
if (s)
SetValue(s);
}
@@ -155,55 +150,43 @@ Mangled::Mangled(llvm::StringRef name) {
SetValue(ConstString(name));
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Mangled::~Mangled() {}
-//----------------------------------------------------------------------
// Convert to pointer operator. This allows code to check any Mangled objects
// to see if they contain anything valid using code such as:
//
// Mangled mangled(...);
// if (mangled)
// { ...
-//----------------------------------------------------------------------
Mangled::operator void *() const {
- return (m_mangled) ? const_cast<Mangled *>(this) : NULL;
+ return (m_mangled) ? const_cast<Mangled *>(this) : nullptr;
}
-//----------------------------------------------------------------------
// Logical NOT operator. This allows code to check any Mangled objects to see
// if they are invalid using code such as:
//
// Mangled mangled(...);
// if (!file_spec)
// { ...
-//----------------------------------------------------------------------
bool Mangled::operator!() const { return !m_mangled; }
-//----------------------------------------------------------------------
// Clear the mangled and demangled values.
-//----------------------------------------------------------------------
void Mangled::Clear() {
m_mangled.Clear();
m_demangled.Clear();
}
-//----------------------------------------------------------------------
// Compare the string values.
-//----------------------------------------------------------------------
int Mangled::Compare(const Mangled &a, const Mangled &b) {
return ConstString::Compare(
a.GetName(lldb::eLanguageTypeUnknown, ePreferMangled),
b.GetName(lldb::eLanguageTypeUnknown, ePreferMangled));
}
-//----------------------------------------------------------------------
// Set the string value in this objects. If "mangled" is true, then the mangled
// named is set with the new value in "s", else the demangled name is set.
-//----------------------------------------------------------------------
-void Mangled::SetValue(const ConstString &s, bool mangled) {
+void Mangled::SetValue(ConstString s, bool mangled) {
if (s) {
if (mangled) {
m_demangled.Clear();
@@ -218,7 +201,7 @@ void Mangled::SetValue(const ConstString &s, bool mangled) {
}
}
-void Mangled::SetValue(const ConstString &name) {
+void Mangled::SetValue(ConstString name) {
if (name) {
if (cstring_is_mangled(name.GetCString())) {
m_demangled.Clear();
@@ -233,9 +216,7 @@ void Mangled::SetValue(const ConstString &name) {
}
}
-//----------------------------------------------------------------------
// Local helpers for different demangling implementations.
-//----------------------------------------------------------------------
static char *GetMSVCDemangledStr(const char *M) {
#if defined(_MSC_VER)
const size_t demangled_length = 2048;
@@ -288,10 +269,8 @@ static char *GetItaniumDemangledStr(const char *M) {
return demangled_cstr;
}
-//----------------------------------------------------------------------
// Explicit demangling for scheduled requests during batch processing. This
// makes use of ItaniumPartialDemangler's rich demangle info
-//----------------------------------------------------------------------
bool Mangled::DemangleWithRichManglingInfo(
RichManglingContext &context, SkipMangledNameFn *skip_mangled_name) {
// We need to generate and cache the demangled name.
@@ -357,13 +336,11 @@ bool Mangled::DemangleWithRichManglingInfo(
llvm_unreachable("Fully covered switch above!");
}
-//----------------------------------------------------------------------
// Generate the demangled name on demand using this accessor. Code in this
// class will need to use this accessor if it wishes to decode the demangled
// name. The result is cached and will be kept until a new string value is
// supplied to this object, or until the end of the object's lifetime.
-//----------------------------------------------------------------------
-const ConstString &
+ConstString
Mangled::GetDemangledName(lldb::LanguageType language) const {
// Check to make sure we have a valid mangled name and that we haven't
// already decoded our mangled name.
@@ -422,9 +399,7 @@ bool Mangled::NameMatches(const RegularExpression &regex,
return demangled && regex.Execute(demangled.AsCString());
}
-//----------------------------------------------------------------------
// Get the demangled name if there is one, else return the mangled name.
-//----------------------------------------------------------------------
ConstString Mangled::GetName(lldb::LanguageType language,
Mangled::NamePreference preference) const {
if (preference == ePreferMangled && m_mangled)
@@ -445,10 +420,8 @@ ConstString Mangled::GetName(lldb::LanguageType language,
return demangled;
}
-//----------------------------------------------------------------------
// Dump a Mangled object to stream "s". We don't force our demangled name to be
// computed currently (we don't use the accessor).
-//----------------------------------------------------------------------
void Mangled::Dump(Stream *s) const {
if (m_mangled) {
*s << ", mangled = " << m_mangled;
@@ -459,10 +432,8 @@ void Mangled::Dump(Stream *s) const {
}
}
-//----------------------------------------------------------------------
// Dumps a debug version of this string with extra object and state information
// to stream "s".
-//----------------------------------------------------------------------
void Mangled::DumpDebug(Stream *s) const {
s->Printf("%*p: Mangled mangled = ", static_cast<int>(sizeof(void *) * 2),
static_cast<const void *>(this));
@@ -471,33 +442,27 @@ void Mangled::DumpDebug(Stream *s) const {
m_demangled.DumpDebug(s);
}
-//----------------------------------------------------------------------
// Return the size in byte that this object takes in memory. The size includes
// the size of the objects it owns, and not the strings that it references
// because they are shared strings.
-//----------------------------------------------------------------------
size_t Mangled::MemorySize() const {
return m_mangled.MemorySize() + m_demangled.MemorySize();
}
-//----------------------------------------------------------------------
// We "guess" the language because we can't determine a symbol's language from
// it's name. For example, a Pascal symbol can be mangled using the C++
// Itanium scheme, and defined in a compilation unit within the same module as
// other C++ units. In addition, different targets could have different ways
// of mangling names from a given language, likewise the compilation units
// within those targets.
-//----------------------------------------------------------------------
lldb::LanguageType Mangled::GuessLanguage() const {
ConstString mangled = GetMangledName();
if (mangled) {
- if (GetDemangledName(lldb::eLanguageTypeUnknown)) {
- const char *mangled_name = mangled.GetCString();
- if (CPlusPlusLanguage::IsCPPMangledName(mangled_name))
- return lldb::eLanguageTypeC_plus_plus;
- else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name))
- return lldb::eLanguageTypeObjC;
- }
+ const char *mangled_name = mangled.GetCString();
+ if (CPlusPlusLanguage::IsCPPMangledName(mangled_name))
+ return lldb::eLanguageTypeC_plus_plus;
+ else if (ObjCLanguage::IsPossibleObjCMethodName(mangled_name))
+ return lldb::eLanguageTypeObjC;
} else {
// ObjC names aren't really mangled, so they won't necessarily be in the
// mangled name slot.
@@ -510,14 +475,12 @@ lldb::LanguageType Mangled::GuessLanguage() const {
return lldb::eLanguageTypeUnknown;
}
-//----------------------------------------------------------------------
// Dump OBJ to the supplied stream S.
-//----------------------------------------------------------------------
Stream &operator<<(Stream &s, const Mangled &obj) {
if (obj.GetMangledName())
s << "mangled = '" << obj.GetMangledName() << "'";
- const ConstString &demangled =
+ ConstString demangled =
obj.GetDemangledName(lldb::eLanguageTypeUnknown);
if (demangled)
s << ", demangled = '" << demangled << '\'';
diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp
index b48d3cca092b7..153d5a7409367 100644
--- a/source/Core/Module.cpp
+++ b/source/Core/Module.cpp
@@ -1,9 +1,8 @@
//===-- Module.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -278,8 +277,8 @@ Module::~Module() {
// function calls back into this module object. The ordering is important
// here because symbol files can require the module object file. So we tear
// down the symbol file first, then the object file.
- m_sections_ap.reset();
- m_symfile_ap.reset();
+ m_sections_up.reset();
+ m_symfile_up.reset();
m_objfile_sp.reset();
}
@@ -292,13 +291,13 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (process_sp) {
m_did_load_objfile = true;
- auto data_ap = llvm::make_unique<DataBufferHeap>(size_to_read, 0);
+ auto data_up = llvm::make_unique<DataBufferHeap>(size_to_read, 0);
Status readmem_error;
const size_t bytes_read =
- process_sp->ReadMemory(header_addr, data_ap->GetBytes(),
- data_ap->GetByteSize(), readmem_error);
+ process_sp->ReadMemory(header_addr, data_up->GetBytes(),
+ data_up->GetByteSize(), readmem_error);
if (bytes_read == size_to_read) {
- DataBufferSP data_sp(data_ap.release());
+ DataBufferSP data_sp(data_up.release());
m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp,
header_addr, data_sp);
if (m_objfile_sp) {
@@ -310,6 +309,10 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
// file's architecture since it might differ in vendor/os if some
// parts were unknown.
m_arch = m_objfile_sp->GetArchitecture();
+
+ // Augment the arch with the target's information in case
+ // we are unable to extract the os/environment from memory.
+ m_arch.MergeFrom(process_sp->GetTarget().GetArchitecture());
} else {
error.SetErrorString("unable to find suitable object file plug-in");
}
@@ -331,7 +334,7 @@ const lldb_private::UUID &Module::GetUUID() {
ObjectFile *obj_file = GetObjectFile();
if (obj_file != nullptr) {
- obj_file->GetUUID(&m_uuid);
+ m_uuid = obj_file->GetUUID();
m_did_set_uuid = true;
}
}
@@ -595,7 +598,7 @@ uint32_t Module::ResolveSymbolContextsForFileSpec(
return sc_list.GetSize() - initial_count;
}
-size_t Module::FindGlobalVariables(const ConstString &name,
+size_t Module::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
VariableList &variables) {
@@ -635,7 +638,7 @@ size_t Module::FindCompileUnits(const FileSpec &path, bool append,
return sc_list.GetSize() - start_size;
}
-Module::LookupInfo::LookupInfo(const ConstString &name,
+Module::LookupInfo::LookupInfo(ConstString name,
FunctionNameType name_type_mask,
LanguageType language)
: m_name(name), m_lookup_name(), m_language(language),
@@ -795,7 +798,7 @@ void Module::LookupInfo::Prune(SymbolContextList &sc_list,
}
}
-size_t Module::FindFunctions(const ConstString &name,
+size_t Module::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
@@ -943,7 +946,7 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
}
size_t Module::FindTypes_Impl(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -956,7 +959,7 @@ size_t Module::FindTypes_Impl(
return 0;
}
-size_t Module::FindTypesInNamespace(const ConstString &type_name,
+size_t Module::FindTypesInNamespace(ConstString type_name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, TypeList &type_list) {
const bool append = true;
@@ -974,7 +977,7 @@ size_t Module::FindTypesInNamespace(const ConstString &type_name,
}
lldb::TypeSP Module::FindFirstType(const SymbolContext &sc,
- const ConstString &name, bool exact_match) {
+ ConstString name, bool exact_match) {
TypeList type_list;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
const size_t num_matches =
@@ -985,7 +988,7 @@ lldb::TypeSP Module::FindFirstType(const SymbolContext &sc,
}
size_t Module::FindTypes(
- const ConstString &name, bool exact_match, size_t max_matches,
+ ConstString name, bool exact_match, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeList &types) {
size_t num_matches = 0;
@@ -1050,17 +1053,17 @@ SymbolVendor *Module::GetSymbolVendor(bool can_create,
if (obj_file != nullptr) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
- m_symfile_ap.reset(
+ m_symfile_up.reset(
SymbolVendor::FindPlugin(shared_from_this(), feedback_strm));
m_did_load_symbol_vendor = true;
}
}
}
- return m_symfile_ap.get();
+ return m_symfile_up.get();
}
void Module::SetFileSpecAndObjectName(const FileSpec &file,
- const ConstString &object_name) {
+ ConstString object_name) {
// Container objects whose paths do not specify a file directly can call this
// function to correct the file and object names.
m_file = file;
@@ -1117,7 +1120,7 @@ void Module::ReportError(const char *format, ...) {
const int format_len = strlen(format);
if (format_len > 0) {
const char last_char = format[format_len - 1];
- if (last_char != '\n' || last_char != '\r')
+ if (last_char != '\n' && last_char != '\r')
strm.EOL();
}
Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData());
@@ -1149,7 +1152,7 @@ void Module::ReportErrorIfModifyDetected(const char *format, ...) {
const int format_len = strlen(format);
if (format_len > 0) {
const char last_char = format[format_len - 1];
- if (last_char != '\n' || last_char != '\r')
+ if (last_char != '\n' && last_char != '\r')
strm.EOL();
}
strm.PutCString("The debug session should be aborted as the original "
@@ -1175,7 +1178,7 @@ void Module::ReportWarning(const char *format, ...) {
const int format_len = strlen(format);
if (format_len > 0) {
const char last_char = format[format_len - 1];
- if (last_char != '\n' || last_char != '\r')
+ if (last_char != '\n' && last_char != '\r')
strm.EOL();
}
Host::SystemLog(Host::eSystemLogWarning, "%s", strm.GetData());
@@ -1243,7 +1246,7 @@ TypeList *Module::GetTypeList() {
return nullptr;
}
-const ConstString &Module::GetObjectName() const { return m_object_name; }
+ConstString Module::GetObjectName() const { return m_object_name; }
ObjectFile *Module::GetObjectFile() {
if (!m_did_load_objfile.load()) {
@@ -1279,13 +1282,13 @@ ObjectFile *Module::GetObjectFile() {
}
SectionList *Module::GetSectionList() {
- // Populate m_sections_ap with sections from objfile.
- if (!m_sections_ap) {
+ // Populate m_sections_up with sections from objfile.
+ if (!m_sections_up) {
ObjectFile *obj_file = GetObjectFile();
if (obj_file != nullptr)
obj_file->CreateSections(*GetUnifiedSectionList());
}
- return m_sections_ap.get();
+ return m_sections_up.get();
}
void Module::SectionFileAddressesChanged() {
@@ -1297,13 +1300,19 @@ void Module::SectionFileAddressesChanged() {
sym_vendor->SectionFileAddressesChanged();
}
+UnwindTable &Module::GetUnwindTable() {
+ if (!m_unwind_table)
+ m_unwind_table.emplace(*this);
+ return *m_unwind_table;
+}
+
SectionList *Module::GetUnifiedSectionList() {
- if (!m_sections_ap)
- m_sections_ap = llvm::make_unique<SectionList>();
- return m_sections_ap.get();
+ if (!m_sections_up)
+ m_sections_up = llvm::make_unique<SectionList>();
+ return m_sections_up.get();
}
-const Symbol *Module::FindFirstSymbolWithNameAndType(const ConstString &name,
+const Symbol *Module::FindFirstSymbolWithNameAndType(ConstString name,
SymbolType symbol_type) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(
@@ -1336,7 +1345,7 @@ void Module::SymbolIndicesToSymbolContextList(
}
}
-size_t Module::FindFunctionSymbols(const ConstString &name,
+size_t Module::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
SymbolContextList &sc_list) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@@ -1352,7 +1361,7 @@ size_t Module::FindFunctionSymbols(const ConstString &name,
return 0;
}
-size_t Module::FindSymbolsWithNameAndType(const ConstString &name,
+size_t Module::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list) {
// No need to protect this call using m_mutex all other method calls are
@@ -1420,11 +1429,11 @@ void Module::PreloadSymbols() {
void Module::SetSymbolFileFileSpec(const FileSpec &file) {
if (!FileSystem::Instance().Exists(file))
return;
- if (m_symfile_ap) {
+ if (m_symfile_up) {
// Remove any sections in the unified section list that come from the
// current symbol vendor.
SectionList *section_list = GetSectionList();
- SymbolFile *symbol_file = m_symfile_ap->GetSymbolFile();
+ SymbolFile *symbol_file = m_symfile_up->GetSymbolFile();
if (section_list && symbol_file) {
ObjectFile *obj_file = symbol_file->GetObjectFile();
// Make sure we have an object file and that the symbol vendor's objfile
@@ -1443,6 +1452,10 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// one
obj_file->ClearSymtab();
+ // Clear the unwind table too, as that may also be affected by the
+ // symbol file information.
+ m_unwind_table.reset();
+
// The symbol file might be a directory bundle ("/tmp/a.out.dSYM")
// instead of a full path to the symbol file within the bundle
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
@@ -1472,10 +1485,10 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
}
// Keep all old symbol files around in case there are any lingering type
// references in any SBValue objects that might have been handed out.
- m_old_symfiles.push_back(std::move(m_symfile_ap));
+ m_old_symfiles.push_back(std::move(m_symfile_up));
}
m_symfile_spec = file;
- m_symfile_ap.reset();
+ m_symfile_up.reset();
m_did_load_symbol_vendor = false;
}
@@ -1532,8 +1545,7 @@ bool Module::LoadScriptingResourceInTarget(Target *target, Status &error,
const uint32_t num_specs = file_specs.GetSize();
if (num_specs) {
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
if (script_interpreter) {
for (uint32_t i = 0; i < num_specs; ++i) {
FileSpec scripting_fspec(file_specs.GetFileSpecAtIndex(i));
@@ -1622,7 +1634,7 @@ bool Module::MatchesModuleSpec(const ModuleSpec &module_ref) {
return false;
}
- const ConstString &object_name = module_ref.GetObjectName();
+ ConstString object_name = module_ref.GetObjectName();
if (object_name) {
if (object_name != GetObjectName())
return false;
diff --git a/source/Core/ModuleChild.cpp b/source/Core/ModuleChild.cpp
index 86495742754d8..2fcb2ffca137c 100644
--- a/source/Core/ModuleChild.cpp
+++ b/source/Core/ModuleChild.cpp
@@ -1,9 +1,8 @@
//===-- ModuleChild.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,6 @@ using namespace lldb_private;
ModuleChild::ModuleChild(const lldb::ModuleSP &module_sp)
: m_module_wp(module_sp) {}
-ModuleChild::ModuleChild(const ModuleChild &rhs)
- : m_module_wp(rhs.m_module_wp) {}
-
ModuleChild::~ModuleChild() {}
const ModuleChild &ModuleChild::operator=(const ModuleChild &rhs) {
diff --git a/source/Core/ModuleList.cpp b/source/Core/ModuleList.cpp
index b8de86f4eadca..9d795f9e55869 100644
--- a/source/Core/ModuleList.cpp
+++ b/source/Core/ModuleList.cpp
@@ -1,9 +1,8 @@
//===-- ModuleList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,10 +11,10 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/FileSystem.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/OptionValueFileSpec.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/VariableList.h"
@@ -88,7 +87,8 @@ enum { ePropertyEnableExternalLookup, ePropertyClangModulesCachePath };
} // namespace
ModuleListProperties::ModuleListProperties() {
- m_collection_sp.reset(new OptionValueProperties(ConstString("symbols")));
+ m_collection_sp =
+ std::make_shared<OptionValueProperties>(ConstString("symbols"));
m_collection_sp->Initialize(g_properties);
llvm::SmallString<128> path;
@@ -102,6 +102,11 @@ bool ModuleListProperties::GetEnableExternalLookup() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
+bool ModuleListProperties::SetEnableExternalLookup(bool new_value) {
+ return m_collection_sp->SetPropertyAtIndexAsBoolean(
+ nullptr, ePropertyEnableExternalLookup, new_value);
+}
+
FileSpec ModuleListProperties::GetClangModulesCachePath() const {
return m_collection_sp
->GetPropertyAtIndexAsOptionValueFileSpec(nullptr, false,
@@ -114,7 +119,6 @@ bool ModuleListProperties::SetClangModulesCachePath(llvm::StringRef path) {
nullptr, ePropertyClangModulesCachePath, path);
}
-
ModuleList::ModuleList()
: m_modules(), m_modules_mutex(), m_notifier(nullptr) {}
@@ -130,25 +134,12 @@ ModuleList::ModuleList(ModuleList::Notifier *notifier)
const ModuleList &ModuleList::operator=(const ModuleList &rhs) {
if (this != &rhs) {
- // That's probably me nit-picking, but in theoretical situation:
- //
- // * that two threads A B and
- // * two ModuleList's x y do opposite assignments ie.:
- //
- // in thread A: | in thread B:
- // x = y; | y = x;
- //
- // This establishes correct(same) lock taking order and thus avoids
- // priority inversion.
- if (uintptr_t(this) > uintptr_t(&rhs)) {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
- m_modules = rhs.m_modules;
- } else {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex);
- m_modules = rhs.m_modules;
- }
+ std::lock(m_modules_mutex, rhs.m_modules_mutex);
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_modules_mutex,
+ std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_modules_mutex,
+ std::adopt_lock);
+ m_modules = rhs.m_modules;
}
return *this;
}
@@ -160,11 +151,13 @@ void ModuleList::AppendImpl(const ModuleSP &module_sp, bool use_notifier) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
m_modules.push_back(module_sp);
if (use_notifier && m_notifier)
- m_notifier->ModuleAdded(*this, module_sp);
+ m_notifier->NotifyModuleAdded(*this, module_sp);
}
}
-void ModuleList::Append(const ModuleSP &module_sp) { AppendImpl(module_sp); }
+void ModuleList::Append(const ModuleSP &module_sp, bool notify) {
+ AppendImpl(module_sp, notify);
+}
void ModuleList::ReplaceEquivalent(const ModuleSP &module_sp) {
if (module_sp) {
@@ -190,7 +183,7 @@ void ModuleList::ReplaceEquivalent(const ModuleSP &module_sp) {
}
}
-bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp) {
+bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp, bool notify) {
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
collection::iterator pos, end = m_modules.end();
@@ -199,7 +192,7 @@ bool ModuleList::AppendIfNeeded(const ModuleSP &module_sp) {
return false; // Already in the list
}
// Only push module_sp on the list if it wasn't already in there.
- Append(module_sp);
+ Append(module_sp, notify);
return true;
}
return false;
@@ -227,7 +220,7 @@ bool ModuleList::RemoveImpl(const ModuleSP &module_sp, bool use_notifier) {
if (pos->get() == module_sp.get()) {
m_modules.erase(pos);
if (use_notifier && m_notifier)
- m_notifier->ModuleRemoved(*this, module_sp);
+ m_notifier->NotifyModuleRemoved(*this, module_sp);
return true;
}
}
@@ -241,12 +234,12 @@ ModuleList::RemoveImpl(ModuleList::collection::iterator pos,
ModuleSP module_sp(*pos);
collection::iterator retval = m_modules.erase(pos);
if (use_notifier && m_notifier)
- m_notifier->ModuleRemoved(*this, module_sp);
+ m_notifier->NotifyModuleRemoved(*this, module_sp);
return retval;
}
-bool ModuleList::Remove(const ModuleSP &module_sp) {
- return RemoveImpl(module_sp);
+bool ModuleList::Remove(const ModuleSP &module_sp, bool notify) {
+ return RemoveImpl(module_sp, notify);
}
bool ModuleList::ReplaceModule(const lldb::ModuleSP &old_module_sp,
@@ -255,7 +248,7 @@ bool ModuleList::ReplaceModule(const lldb::ModuleSP &old_module_sp,
return false;
AppendImpl(new_module_sp, false);
if (m_notifier)
- m_notifier->ModuleUpdated(*this, old_module_sp, new_module_sp);
+ m_notifier->NotifyModuleUpdated(*this, old_module_sp, new_module_sp);
return true;
}
@@ -304,9 +297,11 @@ size_t ModuleList::Remove(ModuleList &module_list) {
size_t num_removed = 0;
collection::iterator pos, end = module_list.m_modules.end();
for (pos = module_list.m_modules.begin(); pos != end; ++pos) {
- if (Remove(*pos))
+ if (Remove(*pos, false /* notify */))
++num_removed;
}
+ if (m_notifier)
+ m_notifier->NotifyModulesRemoved(module_list);
return num_removed;
}
@@ -317,7 +312,7 @@ void ModuleList::Destroy() { ClearImpl(); }
void ModuleList::ClearImpl(bool use_notifier) {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
if (use_notifier && m_notifier)
- m_notifier->WillClearList(*this);
+ m_notifier->NotifyWillClearList(*this);
m_modules.clear();
}
@@ -344,7 +339,7 @@ ModuleSP ModuleList::GetModuleAtIndexUnlocked(size_t idx) const {
return module_sp;
}
-size_t ModuleList::FindFunctions(const ConstString &name,
+size_t ModuleList::FindFunctions(ConstString name,
FunctionNameType name_type_mask,
bool include_symbols, bool include_inlines,
bool append,
@@ -380,7 +375,7 @@ size_t ModuleList::FindFunctions(const ConstString &name,
return sc_list.GetSize() - old_size;
}
-size_t ModuleList::FindFunctionSymbols(const ConstString &name,
+size_t ModuleList::FindFunctionSymbols(ConstString name,
lldb::FunctionNameType name_type_mask,
SymbolContextList &sc_list) {
const size_t old_size = sc_list.GetSize();
@@ -439,7 +434,7 @@ size_t ModuleList::FindCompileUnits(const FileSpec &path, bool append,
return sc_list.GetSize();
}
-size_t ModuleList::FindGlobalVariables(const ConstString &name,
+size_t ModuleList::FindGlobalVariables(ConstString name,
size_t max_matches,
VariableList &variable_list) const {
size_t initial_size = variable_list.GetSize();
@@ -463,7 +458,7 @@ size_t ModuleList::FindGlobalVariables(const RegularExpression &regex,
return variable_list.GetSize() - initial_size;
}
-size_t ModuleList::FindSymbolsWithNameAndType(const ConstString &name,
+size_t ModuleList::FindSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
SymbolContextList &sc_list,
bool append) const {
@@ -542,7 +537,7 @@ ModuleSP ModuleList::FindModule(const UUID &uuid) const {
}
size_t
-ModuleList::FindTypes(Module *search_first, const ConstString &name,
+ModuleList::FindTypes(Module *search_first, ConstString name,
bool name_is_fully_qualified, size_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeList &types) const {
@@ -830,7 +825,7 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
if (module_sp)
return error;
- module_sp.reset(new Module(module_spec));
+ module_sp = std::make_shared<Module>(module_spec);
// Make sure there are a module and an object file since we can specify a
// valid file path with an architecture that might not be in that file. By
// getting the object file we can guarantee that the architecture matches
@@ -872,7 +867,7 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
auto resolved_module_spec(module_spec);
resolved_module_spec.GetFileSpec() = search_path_spec;
- module_sp.reset(new Module(resolved_module_spec));
+ module_sp = std::make_shared<Module>(resolved_module_spec);
if (module_sp->GetObjectFile()) {
// If we get in here we got the correct arch, now we just need to
// verify the UUID if one was given
@@ -971,7 +966,7 @@ Status ModuleList::GetSharedModule(const ModuleSpec &module_spec,
}
if (!module_sp) {
- module_sp.reset(new Module(platform_module_spec));
+ module_sp = std::make_shared<Module>(platform_module_spec);
// Make sure there are a module and an object file since we can specify a
// valid file path with an architecture that might not be in that file.
// By getting the object file we can guarantee that the architecture
diff --git a/source/Core/Opcode.cpp b/source/Core/Opcode.cpp
index ed8be78a6d675..6ca46de40de24 100644
--- a/source/Core/Opcode.cpp
+++ b/source/Core/Opcode.cpp
@@ -1,9 +1,8 @@
//===-- Opcode.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Core/PluginManager.cpp b/source/Core/PluginManager.cpp
index fbb2580398821..24cadcd85bf51 100644
--- a/source/Core/PluginManager.cpp
+++ b/source/Core/PluginManager.cpp
@@ -1,9 +1,8 @@
//===-- PluginManager.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -220,7 +219,7 @@ static ABIInstances &GetABIInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(const ConstString &name,
+bool PluginManager::RegisterPlugin(ConstString name,
const char *description,
ABICreateInstance create_callback) {
if (create_callback) {
@@ -262,7 +261,7 @@ ABICreateInstance PluginManager::GetABICreateCallbackAtIndex(uint32_t idx) {
}
ABICreateInstance
-PluginManager::GetABICreateCallbackForPluginName(const ConstString &name) {
+PluginManager::GetABICreateCallbackForPluginName(ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetABIInstancesMutex());
ABIInstances &instances = GetABIInstances();
@@ -296,7 +295,7 @@ static ArchitectureInstances &GetArchitectureInstances() {
return g_instances;
}
-void PluginManager::RegisterPlugin(const ConstString &name,
+void PluginManager::RegisterPlugin(ConstString name,
llvm::StringRef description,
ArchitectureCreateInstance create_callback) {
std::lock_guard<std::mutex> guard(GetArchitectureMutex());
@@ -349,7 +348,7 @@ static DisassemblerInstances &GetDisassemblerInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(const ConstString &name,
+bool PluginManager::RegisterPlugin(ConstString name,
const char *description,
DisassemblerCreateInstance create_callback) {
if (create_callback) {
@@ -394,7 +393,7 @@ PluginManager::GetDisassemblerCreateCallbackAtIndex(uint32_t idx) {
DisassemblerCreateInstance
PluginManager::GetDisassemblerCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetDisassemblerMutex());
DisassemblerInstances &instances = GetDisassemblerInstances();
@@ -434,7 +433,7 @@ static DynamicLoaderInstances &GetDynamicLoaderInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
DynamicLoaderCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
if (create_callback) {
@@ -479,7 +478,7 @@ PluginManager::GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx) {
DynamicLoaderCreateInstance
PluginManager::GetDynamicLoaderCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetDynamicLoaderMutex());
DynamicLoaderInstances &instances = GetDynamicLoaderInstances();
@@ -519,7 +518,7 @@ static JITLoaderInstances &GetJITLoaderInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
JITLoaderCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
if (create_callback) {
@@ -562,7 +561,7 @@ PluginManager::GetJITLoaderCreateCallbackAtIndex(uint32_t idx) {
}
JITLoaderCreateInstance PluginManager::GetJITLoaderCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetJITLoaderMutex());
JITLoaderInstances &instances = GetJITLoaderInstances();
@@ -600,7 +599,7 @@ static EmulateInstructionInstances &GetEmulateInstructionInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
EmulateInstructionCreateInstance create_callback) {
if (create_callback) {
EmulateInstructionInstance instance;
@@ -643,7 +642,7 @@ PluginManager::GetEmulateInstructionCreateCallbackAtIndex(uint32_t idx) {
EmulateInstructionCreateInstance
PluginManager::GetEmulateInstructionCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetEmulateInstructionMutex());
EmulateInstructionInstances &instances = GetEmulateInstructionInstances();
@@ -683,7 +682,7 @@ static OperatingSystemInstances &GetOperatingSystemInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
OperatingSystemCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
if (create_callback) {
@@ -728,7 +727,7 @@ PluginManager::GetOperatingSystemCreateCallbackAtIndex(uint32_t idx) {
OperatingSystemCreateInstance
PluginManager::GetOperatingSystemCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetOperatingSystemMutex());
OperatingSystemInstances &instances = GetOperatingSystemInstances();
@@ -764,7 +763,7 @@ static LanguageInstances &GetLanguageInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(const ConstString &name,
+bool PluginManager::RegisterPlugin(ConstString name,
const char *description,
LanguageCreateInstance create_callback) {
if (create_callback) {
@@ -806,7 +805,7 @@ PluginManager::GetLanguageCreateCallbackAtIndex(uint32_t idx) {
}
LanguageCreateInstance
-PluginManager::GetLanguageCreateCallbackForPluginName(const ConstString &name) {
+PluginManager::GetLanguageCreateCallbackForPluginName(ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetLanguageMutex());
LanguageInstances &instances = GetLanguageInstances();
@@ -829,6 +828,7 @@ struct LanguageRuntimeInstance {
std::string description;
LanguageRuntimeCreateInstance create_callback;
LanguageRuntimeGetCommandObject command_callback;
+ LanguageRuntimeGetExceptionPrecondition precondition_callback;
};
typedef std::vector<LanguageRuntimeInstance> LanguageRuntimeInstances;
@@ -844,9 +844,10 @@ static LanguageRuntimeInstances &GetLanguageRuntimeInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
LanguageRuntimeCreateInstance create_callback,
- LanguageRuntimeGetCommandObject command_callback) {
+ LanguageRuntimeGetCommandObject command_callback,
+ LanguageRuntimeGetExceptionPrecondition precondition_callback) {
if (create_callback) {
LanguageRuntimeInstance instance;
assert((bool)name);
@@ -855,6 +856,7 @@ bool PluginManager::RegisterPlugin(
instance.description = description;
instance.create_callback = create_callback;
instance.command_callback = command_callback;
+ instance.precondition_callback = precondition_callback;
std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
GetLanguageRuntimeInstances().push_back(instance);
}
@@ -896,9 +898,18 @@ PluginManager::GetLanguageRuntimeGetCommandObjectAtIndex(uint32_t idx) {
return nullptr;
}
+LanguageRuntimeGetExceptionPrecondition
+PluginManager::GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx) {
+ std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
+ LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
+ if (idx < instances.size())
+ return instances[idx].precondition_callback;
+ return nullptr;
+}
+
LanguageRuntimeCreateInstance
PluginManager::GetLanguageRuntimeCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetLanguageRuntimeMutex());
LanguageRuntimeInstances &instances = GetLanguageRuntimeInstances();
@@ -935,7 +946,7 @@ static SystemRuntimeInstances &GetSystemRuntimeInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
SystemRuntimeCreateInstance create_callback) {
if (create_callback) {
SystemRuntimeInstance instance;
@@ -978,7 +989,7 @@ PluginManager::GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx) {
SystemRuntimeCreateInstance
PluginManager::GetSystemRuntimeCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetSystemRuntimeMutex());
SystemRuntimeInstances &instances = GetSystemRuntimeInstances();
@@ -1021,7 +1032,7 @@ static ObjectFileInstances &GetObjectFileInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
ObjectFileCreateInstance create_callback,
ObjectFileCreateMemoryInstance create_memory_callback,
ObjectFileGetModuleSpecifications get_module_specifications,
@@ -1088,7 +1099,7 @@ PluginManager::GetObjectFileGetModuleSpecificationsCallbackAtIndex(
ObjectFileCreateInstance
PluginManager::GetObjectFileCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
ObjectFileInstances &instances = GetObjectFileInstances();
@@ -1104,7 +1115,7 @@ PluginManager::GetObjectFileCreateCallbackForPluginName(
ObjectFileCreateMemoryInstance
PluginManager::GetObjectFileCreateMemoryCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetObjectFileMutex());
ObjectFileInstances &instances = GetObjectFileInstances();
@@ -1160,7 +1171,7 @@ static ObjectContainerInstances &GetObjectContainerInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
ObjectContainerCreateInstance create_callback,
ObjectFileGetModuleSpecifications get_module_specifications) {
if (create_callback) {
@@ -1205,7 +1216,7 @@ PluginManager::GetObjectContainerCreateCallbackAtIndex(uint32_t idx) {
ObjectContainerCreateInstance
PluginManager::GetObjectContainerCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetObjectContainerMutex());
ObjectContainerInstances &instances = GetObjectContainerInstances();
@@ -1255,7 +1266,7 @@ static PlatformInstances &GetPlatformInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
PlatformCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
if (create_callback) {
@@ -1316,7 +1327,7 @@ PluginManager::GetPlatformCreateCallbackAtIndex(uint32_t idx) {
}
PlatformCreateInstance
-PluginManager::GetPlatformCreateCallbackForPluginName(const ConstString &name) {
+PluginManager::GetPlatformCreateCallbackForPluginName(ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetPlatformInstancesMutex());
PlatformInstances &instances = GetPlatformInstances();
@@ -1374,7 +1385,7 @@ static ProcessInstances &GetProcessInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
ProcessCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
if (create_callback) {
@@ -1433,7 +1444,7 @@ PluginManager::GetProcessCreateCallbackAtIndex(uint32_t idx) {
}
ProcessCreateInstance
-PluginManager::GetProcessCreateCallbackForPluginName(const ConstString &name) {
+PluginManager::GetProcessCreateCallbackForPluginName(ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetProcessMutex());
ProcessInstances &instances = GetProcessInstances();
@@ -1473,7 +1484,7 @@ static ScriptInterpreterInstances &GetScriptInterpreterInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
lldb::ScriptLanguage script_language,
ScriptInterpreterCreateInstance create_callback) {
if (!create_callback)
@@ -1517,8 +1528,9 @@ PluginManager::GetScriptInterpreterCreateCallbackAtIndex(uint32_t idx) {
return nullptr;
}
-lldb::ScriptInterpreterSP PluginManager::GetScriptInterpreterForLanguage(
- lldb::ScriptLanguage script_lang, CommandInterpreter &interpreter) {
+lldb::ScriptInterpreterSP
+PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage script_lang,
+ Debugger &debugger) {
std::lock_guard<std::recursive_mutex> guard(GetScriptInterpreterMutex());
ScriptInterpreterInstances &instances = GetScriptInterpreterInstances();
@@ -1529,20 +1541,18 @@ lldb::ScriptInterpreterSP PluginManager::GetScriptInterpreterForLanguage(
none_instance = pos->create_callback;
if (script_lang == pos->language)
- return pos->create_callback(interpreter);
+ return pos->create_callback(debugger);
}
// If we didn't find one, return the ScriptInterpreter for the null language.
assert(none_instance != nullptr);
- return none_instance(interpreter);
+ return none_instance(debugger);
}
#pragma mark -
#pragma mark StructuredDataPlugin
-// -----------------------------------------------------------------------------
// StructuredDataPlugin
-// -----------------------------------------------------------------------------
struct StructuredDataPluginInstance {
StructuredDataPluginInstance()
@@ -1569,7 +1579,7 @@ static StructuredDataPluginInstances &GetStructuredDataPluginInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
StructuredDataPluginCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback,
StructuredDataFilterLaunchInfo filter_callback) {
@@ -1617,7 +1627,7 @@ PluginManager::GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx) {
StructuredDataPluginCreateInstance
PluginManager::GetStructuredDataPluginCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetStructuredDataPluginMutex());
StructuredDataPluginInstances &instances =
@@ -1672,7 +1682,7 @@ static SymbolFileInstances &GetSymbolFileInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
SymbolFileCreateInstance create_callback,
DebuggerInitializeCallback debugger_init_callback) {
if (create_callback) {
@@ -1716,7 +1726,7 @@ PluginManager::GetSymbolFileCreateCallbackAtIndex(uint32_t idx) {
SymbolFileCreateInstance
PluginManager::GetSymbolFileCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetSymbolFileMutex());
SymbolFileInstances &instances = GetSymbolFileInstances();
@@ -1752,7 +1762,7 @@ static SymbolVendorInstances &GetSymbolVendorInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(const ConstString &name,
+bool PluginManager::RegisterPlugin(ConstString name,
const char *description,
SymbolVendorCreateInstance create_callback) {
if (create_callback) {
@@ -1796,7 +1806,7 @@ PluginManager::GetSymbolVendorCreateCallbackAtIndex(uint32_t idx) {
SymbolVendorCreateInstance
PluginManager::GetSymbolVendorCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetSymbolVendorMutex());
SymbolVendorInstances &instances = GetSymbolVendorInstances();
@@ -1833,7 +1843,7 @@ static UnwindAssemblyInstances &GetUnwindAssemblyInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
UnwindAssemblyCreateInstance create_callback) {
if (create_callback) {
UnwindAssemblyInstance instance;
@@ -1876,7 +1886,7 @@ PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx) {
UnwindAssemblyCreateInstance
PluginManager::GetUnwindAssemblyCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetUnwindAssemblyMutex());
UnwindAssemblyInstances &instances = GetUnwindAssemblyInstances();
@@ -1913,7 +1923,7 @@ static MemoryHistoryInstances &GetMemoryHistoryInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
MemoryHistoryCreateInstance create_callback) {
if (create_callback) {
MemoryHistoryInstance instance;
@@ -1956,7 +1966,7 @@ PluginManager::GetMemoryHistoryCreateCallbackAtIndex(uint32_t idx) {
MemoryHistoryCreateInstance
PluginManager::GetMemoryHistoryCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetMemoryHistoryMutex());
MemoryHistoryInstances &instances = GetMemoryHistoryInstances();
@@ -1996,7 +2006,7 @@ static InstrumentationRuntimeInstances &GetInstrumentationRuntimeInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
InstrumentationRuntimeCreateInstance create_callback,
InstrumentationRuntimeGetType get_type_callback) {
if (create_callback) {
@@ -2055,7 +2065,7 @@ PluginManager::GetInstrumentationRuntimeCreateCallbackAtIndex(uint32_t idx) {
InstrumentationRuntimeCreateInstance
PluginManager::GetInstrumentationRuntimeCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(
GetInstrumentationRuntimeMutex());
@@ -2094,7 +2104,7 @@ static TypeSystemInstances &GetTypeSystemInstances() {
return g_instances;
}
-bool PluginManager::RegisterPlugin(const ConstString &name,
+bool PluginManager::RegisterPlugin(ConstString name,
const char *description,
TypeSystemCreateInstance create_callback,
TypeSystemEnumerateSupportedLanguages
@@ -2140,7 +2150,7 @@ PluginManager::GetTypeSystemCreateCallbackAtIndex(uint32_t idx) {
TypeSystemCreateInstance
PluginManager::GetTypeSystemCreateCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
TypeSystemInstances &instances = GetTypeSystemInstances();
@@ -2166,7 +2176,7 @@ PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackAtIndex(
TypeSystemEnumerateSupportedLanguages
PluginManager::GetTypeSystemEnumerateSupportedLanguagesCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetTypeSystemMutex());
TypeSystemInstances &instances = GetTypeSystemInstances();
@@ -2204,7 +2214,7 @@ static REPLInstances &GetREPLInstances() {
}
bool PluginManager::RegisterPlugin(
- const ConstString &name, const char *description,
+ ConstString name, const char *description,
REPLCreateInstance create_callback,
REPLEnumerateSupportedLanguages enumerate_languages_callback) {
if (create_callback) {
@@ -2246,7 +2256,7 @@ REPLCreateInstance PluginManager::GetREPLCreateCallbackAtIndex(uint32_t idx) {
}
REPLCreateInstance
-PluginManager::GetREPLCreateCallbackForPluginName(const ConstString &name) {
+PluginManager::GetREPLCreateCallbackForPluginName(ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
REPLInstances &instances = GetREPLInstances();
@@ -2271,7 +2281,7 @@ PluginManager::GetREPLEnumerateSupportedLanguagesCallbackAtIndex(uint32_t idx) {
REPLEnumerateSupportedLanguages
PluginManager::GetREPLSystemEnumerateSupportedLanguagesCallbackForPluginName(
- const ConstString &name) {
+ ConstString name) {
if (name) {
std::lock_guard<std::recursive_mutex> guard(GetREPLMutex());
REPLInstances &instances = GetREPLInstances();
@@ -2368,8 +2378,8 @@ void PluginManager::DebuggerInitialize(Debugger &debugger) {
// This will put a plugin's settings under e.g.
// "plugin.<plugin_type_name>.<plugin_type_desc>.SETTINGNAME".
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(
- Debugger &debugger, const ConstString &plugin_type_name,
- const ConstString &plugin_type_desc, bool can_create) {
+ Debugger &debugger, ConstString plugin_type_name,
+ ConstString plugin_type_desc, bool can_create) {
lldb::OptionValuePropertiesSP parent_properties_sp(
debugger.GetValueProperties());
if (parent_properties_sp) {
@@ -2404,8 +2414,8 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPlugins(
// "<plugin_type_name>.plugin.<plugin_type_desc>.SETTINGNAME" and Platform
// generic settings would be under "platform.SETTINGNAME".
static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
- Debugger &debugger, const ConstString &plugin_type_name,
- const ConstString &plugin_type_desc, bool can_create) {
+ Debugger &debugger, ConstString plugin_type_name,
+ ConstString plugin_type_desc, bool can_create) {
static ConstString g_property_name("plugin");
lldb::OptionValuePropertiesSP parent_properties_sp(
debugger.GetValueProperties());
@@ -2438,12 +2448,12 @@ static lldb::OptionValuePropertiesSP GetDebuggerPropertyForPluginsOldStyle(
namespace {
typedef lldb::OptionValuePropertiesSP
-GetDebuggerPropertyForPluginsPtr(Debugger &, const ConstString &,
- const ConstString &, bool can_create);
+GetDebuggerPropertyForPluginsPtr(Debugger &, ConstString ,
+ ConstString , bool can_create);
lldb::OptionValuePropertiesSP
-GetSettingForPlugin(Debugger &debugger, const ConstString &setting_name,
- const ConstString &plugin_type_name,
+GetSettingForPlugin(Debugger &debugger, ConstString setting_name,
+ ConstString plugin_type_name,
GetDebuggerPropertyForPluginsPtr get_debugger_property =
GetDebuggerPropertyForPlugins) {
lldb::OptionValuePropertiesSP properties_sp;
@@ -2458,10 +2468,10 @@ GetSettingForPlugin(Debugger &debugger, const ConstString &setting_name,
}
bool CreateSettingForPlugin(
- Debugger &debugger, const ConstString &plugin_type_name,
- const ConstString &plugin_type_desc,
+ Debugger &debugger, ConstString plugin_type_name,
+ ConstString plugin_type_desc,
const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property,
+ ConstString description, bool is_global_property,
GetDebuggerPropertyForPluginsPtr get_debugger_property =
GetDebuggerPropertyForPlugins) {
if (properties_sp) {
@@ -2488,14 +2498,14 @@ const char *kStructuredDataPluginName("structured-data");
} // anonymous namespace
lldb::OptionValuePropertiesSP PluginManager::GetSettingForDynamicLoaderPlugin(
- Debugger &debugger, const ConstString &setting_name) {
+ Debugger &debugger, ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kDynamicLoaderPluginName));
}
bool PluginManager::CreateSettingForDynamicLoaderPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
return CreateSettingForPlugin(
debugger, ConstString(kDynamicLoaderPluginName),
ConstString("Settings for dynamic loader plug-ins"), properties_sp,
@@ -2504,7 +2514,7 @@ bool PluginManager::CreateSettingForDynamicLoaderPlugin(
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForPlatformPlugin(Debugger &debugger,
- const ConstString &setting_name) {
+ ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kPlatformPluginName),
GetDebuggerPropertyForPluginsOldStyle);
@@ -2512,7 +2522,7 @@ PluginManager::GetSettingForPlatformPlugin(Debugger &debugger,
bool PluginManager::CreateSettingForPlatformPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
return CreateSettingForPlugin(debugger, ConstString(kPlatformPluginName),
ConstString("Settings for platform plug-ins"),
properties_sp, description, is_global_property,
@@ -2521,14 +2531,14 @@ bool PluginManager::CreateSettingForPlatformPlugin(
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForProcessPlugin(Debugger &debugger,
- const ConstString &setting_name) {
+ ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kProcessPluginName));
}
bool PluginManager::CreateSettingForProcessPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
return CreateSettingForPlugin(debugger, ConstString(kProcessPluginName),
ConstString("Settings for process plug-ins"),
properties_sp, description, is_global_property);
@@ -2536,14 +2546,14 @@ bool PluginManager::CreateSettingForProcessPlugin(
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForSymbolFilePlugin(Debugger &debugger,
- const ConstString &setting_name) {
+ ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kSymbolFilePluginName));
}
bool PluginManager::CreateSettingForSymbolFilePlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
return CreateSettingForPlugin(
debugger, ConstString(kSymbolFilePluginName),
ConstString("Settings for symbol file plug-ins"), properties_sp,
@@ -2552,14 +2562,14 @@ bool PluginManager::CreateSettingForSymbolFilePlugin(
lldb::OptionValuePropertiesSP
PluginManager::GetSettingForJITLoaderPlugin(Debugger &debugger,
- const ConstString &setting_name) {
+ ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kJITLoaderPluginName));
}
bool PluginManager::CreateSettingForJITLoaderPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
return CreateSettingForPlugin(debugger, ConstString(kJITLoaderPluginName),
ConstString("Settings for JIT loader plug-ins"),
properties_sp, description, is_global_property);
@@ -2568,7 +2578,7 @@ bool PluginManager::CreateSettingForJITLoaderPlugin(
static const char *kOperatingSystemPluginName("os");
lldb::OptionValuePropertiesSP PluginManager::GetSettingForOperatingSystemPlugin(
- Debugger &debugger, const ConstString &setting_name) {
+ Debugger &debugger, ConstString setting_name) {
lldb::OptionValuePropertiesSP properties_sp;
lldb::OptionValuePropertiesSP plugin_type_properties_sp(
GetDebuggerPropertyForPlugins(
@@ -2583,7 +2593,7 @@ lldb::OptionValuePropertiesSP PluginManager::GetSettingForOperatingSystemPlugin(
bool PluginManager::CreateSettingForOperatingSystemPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
if (properties_sp) {
lldb::OptionValuePropertiesSP plugin_type_properties_sp(
GetDebuggerPropertyForPlugins(
@@ -2600,14 +2610,14 @@ bool PluginManager::CreateSettingForOperatingSystemPlugin(
}
lldb::OptionValuePropertiesSP PluginManager::GetSettingForStructuredDataPlugin(
- Debugger &debugger, const ConstString &setting_name) {
+ Debugger &debugger, ConstString setting_name) {
return GetSettingForPlugin(debugger, setting_name,
ConstString(kStructuredDataPluginName));
}
bool PluginManager::CreateSettingForStructuredDataPlugin(
Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp,
- const ConstString &description, bool is_global_property) {
+ ConstString description, bool is_global_property) {
return CreateSettingForPlugin(
debugger, ConstString(kStructuredDataPluginName),
ConstString("Settings for structured data plug-ins"), properties_sp,
diff --git a/source/Core/RichManglingContext.cpp b/source/Core/RichManglingContext.cpp
index f5fbe38a49fb4..3d1941ebdd269 100644
--- a/source/Core/RichManglingContext.cpp
+++ b/source/Core/RichManglingContext.cpp
@@ -1,9 +1,8 @@
//===-- RichManglingContext.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// RichManglingContext
-//----------------------------------------------------------------------
void RichManglingContext::ResetProvider(InfoProvider new_provider) {
// If we want to support parsers for other languages some day, we need a
// switch here to delete the correct parser type.
@@ -35,7 +32,7 @@ void RichManglingContext::ResetProvider(InfoProvider new_provider) {
m_provider = new_provider;
}
-bool RichManglingContext::FromItaniumName(const ConstString &mangled) {
+bool RichManglingContext::FromItaniumName(ConstString mangled) {
bool err = m_ipd.partialDemangle(mangled.GetCString());
if (!err) {
ResetProvider(ItaniumPartialDemangler);
@@ -54,7 +51,7 @@ bool RichManglingContext::FromItaniumName(const ConstString &mangled) {
return !err; // true == success
}
-bool RichManglingContext::FromCxxMethodName(const ConstString &demangled) {
+bool RichManglingContext::FromCxxMethodName(ConstString demangled) {
ResetProvider(PluginCxxLanguage);
m_cxx_method_parser = new CPlusPlusLanguage::MethodName(demangled);
return true;
diff --git a/source/Core/SearchFilter.cpp b/source/Core/SearchFilter.cpp
index 5d26c715bec6a..531fa078de292 100644
--- a/source/Core/SearchFilter.cpp
+++ b/source/Core/SearchFilter.cpp
@@ -1,9 +1,8 @@
//===-- SearchFilter.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -73,10 +72,6 @@ void Searcher::GetDescription(Stream *s) {}
SearchFilter::SearchFilter(const TargetSP &target_sp, unsigned char filterType)
: m_target_sp(target_sp), SubclassID(filterType) {}
-SearchFilter::SearchFilter(const SearchFilter &rhs) = default;
-
-SearchFilter &SearchFilter::operator=(const SearchFilter &rhs) = default;
-
SearchFilter::~SearchFilter() = default;
SearchFilterSP SearchFilter::CreateFromStructuredData(
@@ -172,9 +167,7 @@ lldb::SearchFilterSP SearchFilter::CopyForBreakpoint(Breakpoint &breakpoint) {
return ret_sp;
}
-//----------------------------------------------------------------------
// Helper functions for serialization.
-//----------------------------------------------------------------------
StructuredData::DictionarySP
SearchFilter::WrapOptionsDict(StructuredData::DictionarySP options_dict_sp) {
@@ -205,10 +198,8 @@ void SearchFilter::SerializeFileSpecList(
options_dict_sp->AddItem(GetKey(name), module_array_sp);
}
-//----------------------------------------------------------------------
// UTILITY Functions to help iterate down through the elements of the
// SymbolContext.
-//----------------------------------------------------------------------
void SearchFilter::Search(Searcher &searcher) {
SymbolContext empty_sc;
@@ -364,11 +355,9 @@ Searcher::CallbackReturn SearchFilter::DoFunctionIteration(
return Searcher::eCallbackReturnContinue;
}
-//----------------------------------------------------------------------
// SearchFilterForUnconstrainedSearches:
// Selects a shared library matching a given file spec, consulting the targets
// "black list".
-//----------------------------------------------------------------------
SearchFilterSP SearchFilterForUnconstrainedSearches::CreateFromStructuredData(
Target &target, const StructuredData::Dictionary &data_dict,
Status &error) {
@@ -404,25 +393,13 @@ lldb::SearchFilterSP SearchFilterForUnconstrainedSearches::DoCopyForBreakpoint(
return std::make_shared<SearchFilterForUnconstrainedSearches>(*this);
}
-//----------------------------------------------------------------------
// SearchFilterByModule:
// Selects a shared library matching a given file spec
-//----------------------------------------------------------------------
SearchFilterByModule::SearchFilterByModule(const lldb::TargetSP &target_sp,
const FileSpec &module)
: SearchFilter(target_sp, FilterTy::ByModule), m_module_spec(module) {}
-SearchFilterByModule::SearchFilterByModule(const SearchFilterByModule &rhs) =
- default;
-
-SearchFilterByModule &SearchFilterByModule::
-operator=(const SearchFilterByModule &rhs) {
- m_target_sp = rhs.m_target_sp;
- m_module_spec = rhs.m_module_spec;
- return *this;
-}
-
SearchFilterByModule::~SearchFilterByModule() = default;
bool SearchFilterByModule::ModulePasses(const ModuleSP &module_sp) {
@@ -534,10 +511,8 @@ StructuredData::ObjectSP SearchFilterByModule::SerializeToStructuredData() {
return WrapOptionsDict(options_dict_sp);
}
-//----------------------------------------------------------------------
// SearchFilterByModuleList:
// Selects a shared library matching a given file spec
-//----------------------------------------------------------------------
SearchFilterByModuleList::SearchFilterByModuleList(
const lldb::TargetSP &target_sp, const FileSpecList &module_list)
@@ -549,9 +524,6 @@ SearchFilterByModuleList::SearchFilterByModuleList(
enum FilterTy filter_ty)
: SearchFilter(target_sp, filter_ty), m_module_spec_list(module_list) {}
-SearchFilterByModuleList::SearchFilterByModuleList(
- const SearchFilterByModuleList &rhs) = default;
-
SearchFilterByModuleList &SearchFilterByModuleList::
operator=(const SearchFilterByModuleList &rhs) {
m_target_sp = rhs.m_target_sp;
@@ -688,10 +660,8 @@ StructuredData::ObjectSP SearchFilterByModuleList::SerializeToStructuredData() {
return WrapOptionsDict(options_dict_sp);
}
-//----------------------------------------------------------------------
// SearchFilterByModuleListAndCU:
// Selects a shared library matching a given file spec
-//----------------------------------------------------------------------
SearchFilterByModuleListAndCU::SearchFilterByModuleListAndCU(
const lldb::TargetSP &target_sp, const FileSpecList &module_list,
diff --git a/source/Core/Section.cpp b/source/Core/Section.cpp
index 87f75e1f50ac4..f30ddd2c18c37 100644
--- a/source/Core/Section.cpp
+++ b/source/Core/Section.cpp
@@ -1,9 +1,8 @@
//===-- Section.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -105,6 +104,8 @@ const char *Section::GetTypeAsCString() const {
return "dwarf-str-offsets-dwo";
case eSectionTypeDWARFDebugTypes:
return "dwarf-types";
+ case eSectionTypeDWARFDebugTypesDwo:
+ return "dwarf-types-dwo";
case eSectionTypeDWARFDebugNames:
return "dwarf-names";
case eSectionTypeELFSymbolTable:
@@ -144,7 +145,7 @@ const char *Section::GetTypeAsCString() const {
}
Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
- user_id_t sect_id, const ConstString &name,
+ user_id_t sect_id, ConstString name,
SectionType sect_type, addr_t file_addr, addr_t byte_size,
lldb::offset_t file_offset, lldb::offset_t file_size,
uint32_t log2align, uint32_t flags,
@@ -166,7 +167,7 @@ Section::Section(const ModuleSP &module_sp, ObjectFile *obj_file,
Section::Section(const lldb::SectionSP &parent_section_sp,
const ModuleSP &module_sp, ObjectFile *obj_file,
- user_id_t sect_id, const ConstString &name,
+ user_id_t sect_id, ConstString name,
SectionType sect_type, addr_t file_addr, addr_t byte_size,
lldb::offset_t file_offset, lldb::offset_t file_size,
uint32_t log2align, uint32_t flags,
@@ -343,7 +344,7 @@ void Section::DumpName(Stream *s) const {
s->PutChar('.');
} else {
// The top most section prints the module basename
- const char *name = NULL;
+ const char *name = nullptr;
ModuleSP module_sp(GetModule());
if (m_obj_file) {
@@ -382,9 +383,7 @@ bool Section::Slide(addr_t slide_amount, bool slide_children) {
return false;
}
-//------------------------------------------------------------------
/// Get the permissions as OR'ed bits from lldb::Permissions
-//------------------------------------------------------------------
uint32_t Section::GetPermissions() const {
uint32_t permissions = 0;
if (m_readable)
@@ -396,9 +395,7 @@ uint32_t Section::GetPermissions() const {
return permissions;
}
-//------------------------------------------------------------------
/// Set the permissions using bits OR'ed from lldb::Permissions
-//------------------------------------------------------------------
void Section::SetPermissions(uint32_t permissions) {
m_readable = (permissions & ePermissionsReadable) != 0;
m_writable = (permissions & ePermissionsWritable) != 0;
@@ -507,14 +504,14 @@ SectionSP SectionList::GetSectionAtIndex(size_t idx) const {
}
SectionSP
-SectionList::FindSectionByName(const ConstString &section_dstr) const {
+SectionList::FindSectionByName(ConstString section_dstr) const {
SectionSP sect_sp;
// Check if we have a valid section string
if (section_dstr && !m_sections.empty()) {
const_iterator sect_iter;
const_iterator end = m_sections.end();
for (sect_iter = m_sections.begin();
- sect_iter != end && sect_sp.get() == NULL; ++sect_iter) {
+ sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
Section *child_section = sect_iter->get();
if (child_section) {
if (child_section->GetName() == section_dstr) {
@@ -535,7 +532,7 @@ SectionSP SectionList::FindSectionByID(user_id_t sect_id) const {
const_iterator sect_iter;
const_iterator end = m_sections.end();
for (sect_iter = m_sections.begin();
- sect_iter != end && sect_sp.get() == NULL; ++sect_iter) {
+ sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
if ((*sect_iter)->GetID() == sect_id) {
sect_sp = *sect_iter;
break;
@@ -572,7 +569,7 @@ SectionSP SectionList::FindSectionContainingFileAddress(addr_t vm_addr,
const_iterator sect_iter;
const_iterator end = m_sections.end();
for (sect_iter = m_sections.begin();
- sect_iter != end && sect_sp.get() == NULL; ++sect_iter) {
+ sect_iter != end && sect_sp.get() == nullptr; ++sect_iter) {
Section *sect = sect_iter->get();
if (sect->ContainsFileAddress(vm_addr)) {
// The file address is in this section. We need to make sure one of our
@@ -582,7 +579,7 @@ SectionSP SectionList::FindSectionContainingFileAddress(addr_t vm_addr,
sect_sp = sect->GetChildren().FindSectionContainingFileAddress(
vm_addr, depth - 1);
- if (sect_sp.get() == NULL && !sect->IsFake())
+ if (sect_sp.get() == nullptr && !sect->IsFake())
sect_sp = *sect_iter;
}
}
@@ -590,7 +587,7 @@ SectionSP SectionList::FindSectionContainingFileAddress(addr_t vm_addr,
}
bool SectionList::ContainsSection(user_id_t sect_id) const {
- return FindSectionByID(sect_id).get() != NULL;
+ return FindSectionByID(sect_id).get() != nullptr;
}
void SectionList::Dump(Stream *s, Target *target, bool show_header,
@@ -613,7 +610,7 @@ void SectionList::Dump(Stream *s, Target *target, bool show_header,
const_iterator sect_iter;
const_iterator end = m_sections.end();
for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) {
- (*sect_iter)->Dump(s, target_has_loaded_sections ? target : NULL, depth);
+ (*sect_iter)->Dump(s, target_has_loaded_sections ? target : nullptr, depth);
}
if (show_header && !m_sections.empty())
diff --git a/source/Core/SourceManager.cpp b/source/Core/SourceManager.cpp
index fe603c5a44e61..87065ab624251 100644
--- a/source/Core/SourceManager.cpp
+++ b/source/Core/SourceManager.cpp
@@ -1,9 +1,8 @@
//===-- SourceManager.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,9 +49,7 @@ using namespace lldb_private;
static inline bool is_newline_char(char ch) { return ch == '\n' || ch == '\r'; }
-//----------------------------------------------------------------------
// SourceManager constructor
-//----------------------------------------------------------------------
SourceManager::SourceManager(const TargetSP &target_sp)
: m_last_file_sp(), m_last_line(0), m_last_count(0), m_default_set(false),
m_target_wp(target_sp),
@@ -62,9 +59,7 @@ SourceManager::SourceManager(const DebuggerSP &debugger_sp)
: m_last_file_sp(), m_last_line(0), m_last_count(0), m_default_set(false),
m_target_wp(), m_debugger_wp(debugger_sp) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SourceManager::~SourceManager() {}
SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
@@ -331,7 +326,7 @@ bool SourceManager::GetDefaultFileAndLine(FileSpec &file_spec, uint32_t &line) {
bool inlines_okay = true;
bool append = false;
size_t num_matches = executable_ptr->FindFunctions(
- main_name, NULL, lldb::eFunctionNameTypeBase, inlines_okay,
+ main_name, nullptr, lldb::eFunctionNameTypeBase, inlines_okay,
symbols_okay, append, sc_list);
for (size_t idx = 0; idx < num_matches; idx++) {
SymbolContext sc;
@@ -404,7 +399,7 @@ void SourceManager::File::CommonInitializer(const FileSpec &file_spec,
if (num_matches != 0) {
if (num_matches > 1) {
SymbolContext sc;
- FileSpec *test_cu_spec = NULL;
+ FileSpec *test_cu_spec = nullptr;
for (unsigned i = 0; i < num_matches; i++) {
sc_list.GetContextAtIndex(i, sc);
@@ -466,12 +461,12 @@ uint32_t SourceManager::File::GetNumLines() {
const char *SourceManager::File::PeekLineData(uint32_t line) {
if (!LineIsValid(line))
- return NULL;
+ return nullptr;
size_t line_offset = GetLineOffset(line);
if (line_offset < m_data_sp->GetByteSize())
return (const char *)m_data_sp->GetBytes() + line_offset;
- return NULL;
+ return nullptr;
}
uint32_t SourceManager::File::GetLineLength(uint32_t line,
@@ -626,7 +621,7 @@ bool SourceManager::File::CalculateLineOffsets(uint32_t line) {
return true;
if (m_offsets.empty()) {
- if (m_data_sp.get() == NULL)
+ if (m_data_sp.get() == nullptr)
return false;
const char *start = (char *)m_data_sp->GetBytes();
diff --git a/source/Core/StreamAsynchronousIO.cpp b/source/Core/StreamAsynchronousIO.cpp
index b8938bd3fc4e3..d283749144e1e 100644
--- a/source/Core/StreamAsynchronousIO.cpp
+++ b/source/Core/StreamAsynchronousIO.cpp
@@ -1,9 +1,8 @@
//===-- StreamAsynchronousIO.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Core/StreamFile.cpp b/source/Core/StreamFile.cpp
index d24634598c36a..ce6e1ea2c18f5 100644
--- a/source/Core/StreamFile.cpp
+++ b/source/Core/StreamFile.cpp
@@ -1,9 +1,8 @@
//===-- StreamFile.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// StreamFile constructor
-//----------------------------------------------------------------------
StreamFile::StreamFile() : Stream(), m_file() {}
StreamFile::StreamFile(uint32_t flags, uint32_t addr_size, ByteOrder byte_order)
diff --git a/source/Core/UserSettingsController.cpp b/source/Core/UserSettingsController.cpp
index 4406057ca6b9a..3a656766dceca 100644
--- a/source/Core/UserSettingsController.cpp
+++ b/source/Core/UserSettingsController.cpp
@@ -1,9 +1,8 @@
//====-- UserSettingsController.cpp ------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -95,7 +94,7 @@ Properties::Apropos(llvm::StringRef keyword,
lldb::OptionValuePropertiesSP
Properties::GetSubProperty(const ExecutionContext *exe_ctx,
- const ConstString &name) {
+ ConstString name) {
OptionValuePropertiesSP properties_sp(GetValueProperties());
if (properties_sp)
return properties_sp->GetSubProperty(exe_ctx, name);
diff --git a/source/Core/Value.cpp b/source/Core/Value.cpp
index 8e18458b90c20..fdb4adb5f4314 100644
--- a/source/Core/Value.cpp
+++ b/source/Core/Value.cpp
@@ -1,9 +1,8 @@
//===-- Value.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,17 +39,17 @@ using namespace lldb;
using namespace lldb_private;
Value::Value()
- : m_value(), m_vector(), m_compiler_type(), m_context(NULL),
+ : m_value(), m_vector(), m_compiler_type(), m_context(nullptr),
m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid),
m_data_buffer() {}
Value::Value(const Scalar &scalar)
- : m_value(scalar), m_vector(), m_compiler_type(), m_context(NULL),
+ : m_value(scalar), m_vector(), m_compiler_type(), m_context(nullptr),
m_value_type(eValueTypeScalar), m_context_type(eContextTypeInvalid),
m_data_buffer() {}
Value::Value(const void *bytes, int len)
- : m_value(), m_vector(), m_compiler_type(), m_context(NULL),
+ : m_value(), m_vector(), m_compiler_type(), m_context(nullptr),
m_value_type(eValueTypeHostAddress), m_context_type(eContextTypeInvalid),
m_data_buffer() {
SetBytes(bytes, len);
@@ -132,13 +131,13 @@ AddressType Value::GetValueAddressType() const {
RegisterInfo *Value::GetRegisterInfo() const {
if (m_context_type == eContextTypeRegisterInfo)
return static_cast<RegisterInfo *>(m_context);
- return NULL;
+ return nullptr;
}
Type *Value::GetType() {
if (m_context_type == eContextTypeLLDBType)
return static_cast<Type *>(m_context);
- return NULL;
+ return nullptr;
}
size_t Value::AppendDataToHostBuffer(const Value &rhs) {
@@ -354,11 +353,11 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
break;
}
case eValueTypeLoadAddress:
- if (exe_ctx == NULL) {
+ if (exe_ctx == nullptr) {
error.SetErrorString("can't read load address (no execution context)");
} else {
Process *process = exe_ctx->GetProcessPtr();
- if (process == NULL || !process->IsAlive()) {
+ if (process == nullptr || !process->IsAlive()) {
Target *target = exe_ctx->GetTargetPtr();
if (target) {
// Allow expressions to run and evaluate things when the target has
@@ -391,16 +390,16 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
break;
case eValueTypeFileAddress:
- if (exe_ctx == NULL) {
+ if (exe_ctx == nullptr) {
error.SetErrorString("can't read file address (no execution context)");
- } else if (exe_ctx->GetTargetPtr() == NULL) {
+ } else if (exe_ctx->GetTargetPtr() == nullptr) {
error.SetErrorString("can't read file address (invalid target)");
} else {
address = m_value.ULongLong(LLDB_INVALID_ADDRESS);
if (address == LLDB_INVALID_ADDRESS) {
error.SetErrorString("invalid file address");
} else {
- if (module == NULL) {
+ if (module == nullptr) {
// The only thing we can currently lock down to a module so that we
// can resolve a file address, is a variable.
Variable *variable = GetVariable();
@@ -515,6 +514,10 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
if (error.Fail())
return error;
+ // No memory to read for zero-sized types.
+ if (byte_size == 0)
+ return error;
+
// Make sure we have enough room within "data", and if we don't make
// something large enough that does
if (!data.ValidOffsetForDataOfSize(data_offset, byte_size)) {
@@ -524,7 +527,7 @@ Status Value::GetValueAsData(ExecutionContext *exe_ctx, DataExtractor &data,
}
uint8_t *dst = const_cast<uint8_t *>(data.PeekData(data_offset, byte_size));
- if (dst != NULL) {
+ if (dst != nullptr) {
if (address_type == eAddressTypeHost) {
// The address is an address in this process, so just copy it.
if (address == 0) {
@@ -594,7 +597,7 @@ Scalar &Value::ResolveValue(ExecutionContext *exe_ctx) {
{
DataExtractor data;
lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS);
- Status error(GetValueAsData(exe_ctx, data, 0, NULL));
+ Status error(GetValueAsData(exe_ctx, data, 0, nullptr));
if (error.Success()) {
Scalar scalar;
if (compiler_type.GetValueAsScalar(data, 0, data.GetByteSize(),
@@ -622,7 +625,7 @@ Scalar &Value::ResolveValue(ExecutionContext *exe_ctx) {
Variable *Value::GetVariable() {
if (m_context_type == eContextTypeVariable)
return static_cast<Variable *>(m_context);
- return NULL;
+ return nullptr;
}
void Value::Clear() {
@@ -630,7 +633,7 @@ void Value::Clear() {
m_vector.Clear();
m_compiler_type.Clear();
m_value_type = eValueTypeScalar;
- m_context = NULL;
+ m_context = nullptr;
m_context_type = eContextTypeInvalid;
m_data_buffer.Clear();
}
@@ -699,7 +702,7 @@ Value *ValueList::GetValueAtIndex(size_t idx) {
if (idx < GetSize()) {
return &(m_values[idx]);
} else
- return NULL;
+ return nullptr;
}
void ValueList::Clear() { m_values.clear(); }
diff --git a/source/Core/ValueObject.cpp b/source/Core/ValueObject.cpp
index 95e944b22b873..297365b4ecbd6 100644
--- a/source/Core/ValueObject.cpp
+++ b/source/Core/ValueObject.cpp
@@ -1,9 +1,8 @@
//===-- ValueObject.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,10 +31,10 @@
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/Type.h"
+#include "lldb/Symbol/Variable.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
@@ -78,17 +77,16 @@ using namespace lldb_utility;
static user_id_t g_value_obj_uid = 0;
-//----------------------------------------------------------------------
// ValueObject constructor
-//----------------------------------------------------------------------
ValueObject::ValueObject(ValueObject &parent)
: UserID(++g_value_obj_uid), // Unique identifier for every value object
- m_parent(&parent), m_root(NULL), m_update_point(parent.GetUpdatePoint()),
- m_name(), m_data(), m_value(), m_error(), m_value_str(),
- m_old_value_str(), m_location_str(), m_summary_str(), m_object_desc_str(),
- m_validation_result(), m_manager(parent.GetManager()), m_children(),
- m_synthetic_children(), m_dynamic_value(NULL), m_synthetic_value(NULL),
- m_deref_valobj(NULL), m_format(eFormatDefault),
+ m_parent(&parent), m_root(nullptr),
+ m_update_point(parent.GetUpdatePoint()), m_name(), m_data(), m_value(),
+ m_error(), m_value_str(), m_old_value_str(), m_location_str(),
+ m_summary_str(), m_object_desc_str(), m_validation_result(),
+ m_manager(parent.GetManager()), m_children(), m_synthetic_children(),
+ m_dynamic_value(nullptr), m_synthetic_value(nullptr),
+ m_deref_valobj(nullptr), m_format(eFormatDefault),
m_last_format(eFormatDefault), m_last_format_mgr_revision(0),
m_type_summary_sp(), m_type_format_sp(), m_synthetic_children_sp(),
m_type_validator_sp(), m_user_id_of_forced_summary(),
@@ -106,21 +104,19 @@ ValueObject::ValueObject(ValueObject &parent)
m_manager->ManageObject(this);
}
-//----------------------------------------------------------------------
// ValueObject constructor
-//----------------------------------------------------------------------
ValueObject::ValueObject(ExecutionContextScope *exe_scope,
AddressType child_ptr_or_ref_addr_type)
: UserID(++g_value_obj_uid), // Unique identifier for every value object
- m_parent(NULL), m_root(NULL), m_update_point(exe_scope), m_name(),
+ m_parent(nullptr), m_root(nullptr), m_update_point(exe_scope), m_name(),
m_data(), m_value(), m_error(), m_value_str(), m_old_value_str(),
m_location_str(), m_summary_str(), m_object_desc_str(),
m_validation_result(), m_manager(), m_children(), m_synthetic_children(),
- m_dynamic_value(NULL), m_synthetic_value(NULL), m_deref_valobj(NULL),
- m_format(eFormatDefault), m_last_format(eFormatDefault),
- m_last_format_mgr_revision(0), m_type_summary_sp(), m_type_format_sp(),
- m_synthetic_children_sp(), m_type_validator_sp(),
- m_user_id_of_forced_summary(),
+ m_dynamic_value(nullptr), m_synthetic_value(nullptr),
+ m_deref_valobj(nullptr), m_format(eFormatDefault),
+ m_last_format(eFormatDefault), m_last_format_mgr_revision(0),
+ m_type_summary_sp(), m_type_format_sp(), m_synthetic_children_sp(),
+ m_type_validator_sp(), m_user_id_of_forced_summary(),
m_address_type_of_ptr_or_ref_children(child_ptr_or_ref_addr_type),
m_value_checksum(),
m_preferred_display_language(lldb::eLanguageTypeUnknown),
@@ -135,9 +131,7 @@ ValueObject::ValueObject(ExecutionContextScope *exe_scope,
m_manager->ManageObject(this);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ValueObject::~ValueObject() {}
bool ValueObject::UpdateValueIfNeeded(bool update_format) {
@@ -285,51 +279,21 @@ CompilerType ValueObject::MaybeCalculateCompleteType() {
return compiler_type;
}
- CompilerType class_type;
- bool is_pointer_type = false;
-
- if (ClangASTContext::IsObjCObjectPointerType(compiler_type, &class_type)) {
- is_pointer_type = true;
- } else if (ClangASTContext::IsObjCObjectOrInterfaceType(compiler_type)) {
- class_type = compiler_type;
- } else {
- return compiler_type;
- }
-
m_did_calculate_complete_objc_class_type = true;
- if (class_type) {
- ConstString class_name(class_type.GetConstTypeName());
-
- if (class_name) {
- ProcessSP process_sp(
- GetUpdatePoint().GetExecutionContextRef().GetProcessSP());
-
- if (process_sp) {
- ObjCLanguageRuntime *objc_language_runtime(
- process_sp->GetObjCLanguageRuntime());
+ ProcessSP process_sp(
+ GetUpdatePoint().GetExecutionContextRef().GetProcessSP());
- if (objc_language_runtime) {
- TypeSP complete_objc_class_type_sp =
- objc_language_runtime->LookupInCompleteClassCache(class_name);
-
- if (complete_objc_class_type_sp) {
- CompilerType complete_class(
- complete_objc_class_type_sp->GetFullCompilerType());
-
- if (complete_class.GetCompleteType()) {
- if (is_pointer_type) {
- m_override_type = complete_class.GetPointerType();
- } else {
- m_override_type = complete_class;
- }
+ if (!process_sp)
+ return compiler_type;
- if (m_override_type.IsValid())
- return m_override_type;
- }
- }
- }
- }
+ if (auto *runtime =
+ process_sp->GetLanguageRuntime(GetObjectRuntimeLanguage())) {
+ if (llvm::Optional<CompilerType> complete_type =
+ runtime->GetRuntimeType(compiler_type)) {
+ m_override_type = complete_type.getValue();
+ if (m_override_type.IsValid())
+ return m_override_type;
}
}
return compiler_type;
@@ -351,7 +315,7 @@ const Status &ValueObject::GetError() {
return m_error;
}
-const ConstString &ValueObject::GetName() const { return m_name; }
+ConstString ValueObject::GetName() const { return m_name; }
const char *ValueObject::GetLocationAsCString() {
return GetLocationAsCStringImpl(m_value, m_data);
@@ -471,7 +435,7 @@ ValueObjectSP ValueObject::GetChildAtIndex(size_t idx, bool can_create) {
}
ValueObject *child = m_children.GetChildAtIndex(idx);
- if (child != NULL)
+ if (child != nullptr)
return child->GetSP();
}
return child_sp;
@@ -544,13 +508,13 @@ lldb::ValueObjectSP ValueObject::GetChildAtNamePath(
return root;
}
-size_t ValueObject::GetIndexOfChildWithName(const ConstString &name) {
+size_t ValueObject::GetIndexOfChildWithName(ConstString name) {
bool omit_empty_base_classes = true;
return GetCompilerType().GetIndexOfChildWithName(name.GetCString(),
omit_empty_base_classes);
}
-ValueObjectSP ValueObject::GetChildMemberWithName(const ConstString &name,
+ValueObjectSP ValueObject::GetChildMemberWithName(ConstString name,
bool can_create) {
// when getting a child by name, it could be buried inside some base classes
// (which really aren't part of the expression path), so we need a vector of
@@ -618,12 +582,12 @@ void ValueObject::SetNumChildren(size_t num_children) {
m_children.SetChildrenCount(num_children);
}
-void ValueObject::SetName(const ConstString &name) { m_name = name; }
+void ValueObject::SetName(ConstString name) { m_name = name; }
ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
bool synthetic_array_member,
int32_t synthetic_index) {
- ValueObject *valobj = NULL;
+ ValueObject *valobj = nullptr;
bool omit_empty_base_classes = true;
bool ignore_array_bounds = synthetic_array_member;
@@ -716,7 +680,7 @@ const char *ValueObject::GetSummaryAsCString(lldb::LanguageType lang) {
summary_options);
}
if (m_summary_str.empty())
- return NULL;
+ return nullptr;
return m_summary_str.c_str();
}
@@ -769,12 +733,12 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
if (is_pointer_type) {
Status error;
ValueObjectSP pointee_sp = Dereference(error);
- if (error.Fail() || pointee_sp.get() == NULL)
+ if (error.Fail() || pointee_sp.get() == nullptr)
return 0;
return pointee_sp->GetData(data, error);
} else {
ValueObjectSP child_sp = GetChildAtIndex(0, true);
- if (child_sp.get() == NULL)
+ if (child_sp.get() == nullptr)
return 0;
Status error;
return child_sp->GetData(data, error);
@@ -783,7 +747,7 @@ size_t ValueObject::GetPointeeData(DataExtractor &data, uint32_t item_idx,
} else /* (items > 1) */
{
Status error;
- lldb_private::DataBufferHeap *heap_buf_ptr = NULL;
+ lldb_private::DataBufferHeap *heap_buf_ptr = nullptr;
lldb::DataBufferSP data_sp(heap_buf_ptr =
new lldb_private::DataBufferHeap());
@@ -929,7 +893,7 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
static bool CopyStringDataToBufferSP(const StreamString &source,
lldb::DataBufferSP &destination) {
- destination.reset(new DataBufferHeap(source.GetSize() + 1, 0));
+ destination = std::make_shared<DataBufferHeap>(source.GetSize() + 1, 0);
memcpy(destination->GetBytes(), source.GetString().data(), source.GetSize());
return true;
}
@@ -970,7 +934,7 @@ ValueObject::ReadPointedString(lldb::DataBufferSP &buffer_sp, Status &error,
if (is_array) {
// We have an array
uint64_t array_size = 0;
- if (compiler_type.IsArrayType(NULL, &array_size, NULL)) {
+ if (compiler_type.IsArrayType(nullptr, &array_size, nullptr)) {
cstr_len = array_size;
if (cstr_len > max_length) {
capped_data = true;
@@ -992,7 +956,7 @@ ValueObject::ReadPointedString(lldb::DataBufferSP &buffer_sp, Status &error,
CopyStringDataToBufferSP(s, buffer_sp);
return {0, was_capped};
}
- buffer_sp.reset(new DataBufferHeap(cstr_len, 0));
+ buffer_sp = std::make_shared<DataBufferHeap>(cstr_len, 0);
memcpy(buffer_sp->GetBytes(), cstr, cstr_len);
return {cstr_len, was_capped};
} else {
@@ -1092,44 +1056,40 @@ std::pair<TypeValidatorResult, std::string> ValueObject::GetValidationStatus() {
}
const char *ValueObject::GetObjectDescription() {
-
if (!UpdateValueIfNeeded(true))
- return NULL;
+ return nullptr;
+ // Return cached value.
if (!m_object_desc_str.empty())
return m_object_desc_str.c_str();
ExecutionContext exe_ctx(GetExecutionContextRef());
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
- return NULL;
-
- StreamString s;
-
- LanguageType language = GetObjectRuntimeLanguage();
- LanguageRuntime *runtime = process->GetLanguageRuntime(language);
+ if (!process)
+ return nullptr;
- if (runtime == NULL) {
- // Aw, hell, if the things a pointer, or even just an integer, let's try
- // ObjC anyway...
- CompilerType compiler_type = GetCompilerType();
- if (compiler_type) {
- bool is_signed;
- if (compiler_type.IsIntegerType(is_signed) ||
- compiler_type.IsPointerType()) {
- runtime = process->GetLanguageRuntime(eLanguageTypeObjC);
+ // Returns the object description produced by one language runtime.
+ auto get_object_description = [&](LanguageType language) -> const char * {
+ if (LanguageRuntime *runtime = process->GetLanguageRuntime(language)) {
+ StreamString s;
+ if (runtime->GetObjectDescription(s, *this)) {
+ m_object_desc_str.append(s.GetString());
+ return m_object_desc_str.c_str();
}
}
- }
+ return nullptr;
+ };
- if (runtime && runtime->GetObjectDescription(s, *this)) {
- m_object_desc_str.append(s.GetString());
- }
+ // Try the native language runtime first.
+ LanguageType native_language = GetObjectRuntimeLanguage();
+ if (const char *desc = get_object_description(native_language))
+ return desc;
- if (m_object_desc_str.empty())
- return NULL;
- else
- return m_object_desc_str.c_str();
+ // Try the Objective-C language runtime. This fallback is necessary
+ // for Objective-C++ and mixed Objective-C / C++ programs.
+ if (Language::LanguageIsCFamily(native_language))
+ return get_object_description(eLanguageTypeObjC);
+ return nullptr;
}
bool ValueObject::GetValueAsCString(const lldb_private::TypeFormatImpl &format,
@@ -1169,7 +1129,7 @@ const char *ValueObject::GetValueAsCString() {
if (my_format != m_last_format || m_value_str.empty()) {
m_last_format = my_format;
if (!format_sp)
- format_sp.reset(new TypeFormatImpl_Format(my_format));
+ format_sp = std::make_shared<TypeFormatImpl_Format>(my_format);
if (GetValueAsCString(*format_sp.get(), m_value_str)) {
if (!m_value_did_change && m_old_value_valid) {
// The value was gotten successfully, so we consider the value as
@@ -1180,7 +1140,7 @@ const char *ValueObject::GetValueAsCString() {
}
}
if (m_value_str.empty())
- return NULL;
+ return nullptr;
return m_value_str.c_str();
}
@@ -1291,7 +1251,7 @@ bool ValueObject::DumpPrintableRepresentation(
buffer_sp, lldb::eByteOrderInvalid,
8)); // none of this matters for a string - pass some defaults
options.SetStream(&s);
- options.SetPrefixToken(0);
+ options.SetPrefixToken(nullptr);
options.SetQuote('"');
options.SetSourceSize(buffer_sp->GetByteSize());
options.SetIsTruncated(read_string.second);
@@ -1658,12 +1618,12 @@ LanguageType ValueObject::GetObjectRuntimeLanguage() {
return GetCompilerType().GetMinimumLanguage();
}
-void ValueObject::AddSyntheticChild(const ConstString &key,
+void ValueObject::AddSyntheticChild(ConstString key,
ValueObject *valobj) {
m_synthetic_children[key] = valobj;
}
-ValueObjectSP ValueObject::GetSyntheticChild(const ConstString &key) const {
+ValueObjectSP ValueObject::GetSyntheticChild(ConstString key) const {
ValueObjectSP synthetic_child_sp;
std::map<ConstString, ValueObject *>::const_iterator pos =
m_synthetic_children.find(key);
@@ -1680,7 +1640,7 @@ ValueObject::GetTypeInfo(CompilerType *pointee_or_element_compiler_type) {
bool ValueObject::IsPointerType() { return GetCompilerType().IsPointerType(); }
bool ValueObject::IsArrayType() {
- return GetCompilerType().IsArrayType(NULL, NULL, NULL);
+ return GetCompilerType().IsArrayType(nullptr, nullptr, nullptr);
}
bool ValueObject::IsScalarType() { return GetCompilerType().IsScalarType(); }
@@ -1699,20 +1659,33 @@ bool ValueObject::IsPossibleDynamicType() {
if (process)
return process->IsPossibleDynamicValue(*this);
else
- return GetCompilerType().IsPossibleDynamicType(NULL, true, true);
+ return GetCompilerType().IsPossibleDynamicType(nullptr, true, true);
}
bool ValueObject::IsRuntimeSupportValue() {
Process *process(GetProcessSP().get());
- if (process) {
- LanguageRuntime *runtime =
- process->GetLanguageRuntime(GetObjectRuntimeLanguage());
- if (!runtime)
- runtime = process->GetObjCLanguageRuntime();
- if (runtime)
- return runtime->IsRuntimeSupportValue(*this);
+ if (!process)
+ return false;
+
+ // We trust the the compiler did the right thing and marked runtime support
+ // values as artificial.
+ if (!GetVariable() || !GetVariable()->IsArtificial())
+ return false;
+
+ LanguageType lang = eLanguageTypeUnknown;
+ if (auto *sym_ctx_scope = GetSymbolContextScope()) {
+ if (auto *func = sym_ctx_scope->CalculateSymbolContextFunction())
+ lang = func->GetLanguage();
+ else if (auto *comp_unit =
+ sym_ctx_scope->CalculateSymbolContextCompileUnit())
+ lang = comp_unit->GetLanguage();
}
- return false;
+
+ if (auto *runtime = process->GetLanguageRuntime(lang))
+ if (runtime->IsWhitelistedRuntimeValue(GetName()))
+ return false;
+
+ return true;
}
bool ValueObject::IsNilReference() {
@@ -1907,7 +1880,7 @@ ValueObject::GetSyntheticExpressionPathChild(const char *expression,
// We haven't made a synthetic array member for expression yet, so lets
// make one and cache it for any future reference.
synthetic_child_sp = GetValueForExpressionPath(
- expression, NULL, NULL,
+ expression, nullptr, nullptr,
GetValueForExpressionPathOptions().SetSyntheticChildrenTraversal(
GetValueForExpressionPathOptions::SyntheticChildrenTraversal::
None));
@@ -1930,7 +1903,7 @@ void ValueObject::CalculateSyntheticValue(bool use_synthetic) {
TargetSP target_sp(GetTargetSP());
if (target_sp && !target_sp->GetEnableSyntheticValue()) {
- m_synthetic_value = NULL;
+ m_synthetic_value = nullptr;
return;
}
@@ -1939,7 +1912,7 @@ void ValueObject::CalculateSyntheticValue(bool use_synthetic) {
if (!UpdateFormatsIfNeeded() && m_synthetic_value)
return;
- if (m_synthetic_children_sp.get() == NULL)
+ if (m_synthetic_children_sp.get() == nullptr)
return;
if (current_synth_sp == m_synthetic_children_sp && m_synthetic_value)
@@ -1966,7 +1939,7 @@ ValueObjectSP ValueObject::GetDynamicValue(DynamicValueType use_dynamic) {
if (use_dynamic == eNoDynamicValues)
return ValueObjectSP();
- if (!IsDynamic() && m_dynamic_value == NULL) {
+ if (!IsDynamic() && m_dynamic_value == nullptr) {
CalculateDynamicValue(use_dynamic);
}
if (m_dynamic_value)
@@ -1994,7 +1967,7 @@ ValueObjectSP ValueObject::GetSyntheticValue(bool use_synthetic) {
bool ValueObject::HasSyntheticValue() {
UpdateFormatsIfNeeded();
- if (m_synthetic_children_sp.get() == NULL)
+ if (m_synthetic_children_sp.get() == nullptr)
return false;
CalculateSyntheticValue(true);
@@ -2027,7 +2000,7 @@ ValueObject *ValueObject::GetNonBaseClassParent() {
else
return GetParent();
}
- return NULL;
+ return nullptr;
}
bool ValueObject::IsBaseClass(uint32_t &depth) {
@@ -2741,7 +2714,7 @@ void ValueObject::Dump(Stream &s, const DumpValueObjectOptions &options) {
printer.PrintValueObject();
}
-ValueObjectSP ValueObject::CreateConstantValue(const ConstString &name) {
+ValueObjectSP ValueObject::CreateConstantValue(ConstString name) {
ValueObjectSP valobj_sp;
if (UpdateValueIfNeeded(false) && m_error.Success()) {
@@ -2917,7 +2890,7 @@ ValueObjectSP ValueObject::Cast(const CompilerType &compiler_type) {
return ValueObjectCast::Create(*this, GetName(), compiler_type);
}
-lldb::ValueObjectSP ValueObject::Clone(const ConstString &new_name) {
+lldb::ValueObjectSP ValueObject::Clone(ConstString new_name) {
return ValueObjectCast::Create(*this, new_name, GetCompilerType());
}
@@ -3012,12 +2985,12 @@ bool ValueObject::EvaluationPoint::SyncWithProcessState(
ExecutionContext exe_ctx(
m_exe_ctx_ref.Lock(thread_and_frame_only_if_stopped));
- if (exe_ctx.GetTargetPtr() == NULL)
+ if (exe_ctx.GetTargetPtr() == nullptr)
return false;
// If we don't have a process nothing can change.
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return false;
// If our stop id is the current stop ID, nothing has changed:
@@ -3098,7 +3071,7 @@ void ValueObject::ClearUserVisibleData(uint32_t clear_mask) {
if ((clear_mask & eClearUserVisibleDataItemsSyntheticChildren) ==
eClearUserVisibleDataItemsSyntheticChildren) {
if (m_synthetic_value)
- m_synthetic_value = NULL;
+ m_synthetic_value = nullptr;
}
if ((clear_mask & eClearUserVisibleDataItemsValidator) ==
@@ -3111,7 +3084,7 @@ SymbolContextScope *ValueObject::GetSymbolContextScope() {
if (!m_parent->IsPointerOrReferenceType())
return m_parent->GetSymbolContextScope();
}
- return NULL;
+ return nullptr;
}
lldb::ValueObjectSP
@@ -3405,4 +3378,3 @@ lldb::StackFrameSP ValueObjectManager::GetFrameSP() const {
return m_root_valobj_sp->GetFrameSP();
return lldb::StackFrameSP();
}
-
diff --git a/source/Core/ValueObjectCast.cpp b/source/Core/ValueObjectCast.cpp
index fb0b55b6efdf9..6ccda8c32915e 100644
--- a/source/Core/ValueObjectCast.cpp
+++ b/source/Core/ValueObjectCast.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectCast.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,14 +22,14 @@ class ConstString;
using namespace lldb_private;
lldb::ValueObjectSP ValueObjectCast::Create(ValueObject &parent,
- const ConstString &name,
+ ConstString name,
const CompilerType &cast_type) {
ValueObjectCast *cast_valobj_ptr =
new ValueObjectCast(parent, name, cast_type);
return cast_valobj_ptr->GetSP();
}
-ValueObjectCast::ValueObjectCast(ValueObject &parent, const ConstString &name,
+ValueObjectCast::ValueObjectCast(ValueObject &parent, ConstString name,
const CompilerType &cast_type)
: ValueObject(parent), m_cast_type(cast_type) {
SetName(name);
diff --git a/source/Core/ValueObjectChild.cpp b/source/Core/ValueObjectChild.cpp
index 0f7be8317dec7..01f2e20dd0bcd 100644
--- a/source/Core/ValueObjectChild.cpp
+++ b/source/Core/ValueObjectChild.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectChild.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,7 +28,7 @@ using namespace lldb_private;
ValueObjectChild::ValueObjectChild(
ValueObject &parent, const CompilerType &compiler_type,
- const ConstString &name, uint64_t byte_size, int32_t byte_offset,
+ 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)
diff --git a/source/Core/ValueObjectConstResult.cpp b/source/Core/ValueObjectConstResult.cpp
index f6e32c03b0eb3..a1b2cac96874f 100644
--- a/source/Core/ValueObjectConstResult.cpp
+++ b/source/Core/ValueObjectConstResult.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResult.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,7 +49,7 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
const CompilerType &compiler_type,
- const ConstString &name,
+ ConstString name,
const DataExtractor &data,
lldb::addr_t address) {
return (new ValueObjectConstResult(exe_scope, compiler_type, name, data,
@@ -60,7 +59,7 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
ValueObjectConstResult::ValueObjectConstResult(
ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- const ConstString &name, const DataExtractor &data, lldb::addr_t address)
+ ConstString name, const DataExtractor &data, lldb::addr_t address)
: ValueObject(exe_scope), m_type_name(), m_byte_size(0),
m_impl(this, address) {
m_data = data;
@@ -82,7 +81,7 @@ ValueObjectConstResult::ValueObjectConstResult(
ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
const CompilerType &compiler_type,
- const ConstString &name,
+ ConstString name,
const lldb::DataBufferSP &data_sp,
lldb::ByteOrder data_byte_order,
uint32_t data_addr_size,
@@ -94,14 +93,14 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
Value &value,
- const ConstString &name,
+ ConstString name,
Module *module) {
return (new ValueObjectConstResult(exe_scope, value, name, module))->GetSP();
}
ValueObjectConstResult::ValueObjectConstResult(
ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- const ConstString &name, const lldb::DataBufferSP &data_sp,
+ ConstString name, const lldb::DataBufferSP &data_sp,
lldb::ByteOrder data_byte_order, uint32_t data_addr_size,
lldb::addr_t address)
: ValueObject(exe_scope), m_type_name(), m_byte_size(0),
@@ -121,7 +120,7 @@ ValueObjectConstResult::ValueObjectConstResult(
ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
const CompilerType &compiler_type,
- const ConstString &name,
+ ConstString name,
lldb::addr_t address,
AddressType address_type,
uint32_t addr_byte_size) {
@@ -132,7 +131,7 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
ValueObjectConstResult::ValueObjectConstResult(
ExecutionContextScope *exe_scope, const CompilerType &compiler_type,
- const ConstString &name, lldb::addr_t address, AddressType address_type,
+ ConstString name, lldb::addr_t address, AddressType address_type,
uint32_t addr_byte_size)
: ValueObject(exe_scope), m_type_name(), m_byte_size(0),
m_impl(this, address) {
@@ -176,7 +175,7 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
const Value &value,
- const ConstString &name,
+ ConstString name,
Module *module)
: ValueObject(exe_scope), m_type_name(), m_byte_size(0), m_impl(this) {
m_value = value;
diff --git a/source/Core/ValueObjectConstResultCast.cpp b/source/Core/ValueObjectConstResultCast.cpp
index c04043264af10..b47e699e30f10 100644
--- a/source/Core/ValueObjectConstResultCast.cpp
+++ b/source/Core/ValueObjectConstResultCast.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResultCast.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,7 @@ class ValueObject;
using namespace lldb_private;
ValueObjectConstResultCast::ValueObjectConstResultCast(
- ValueObject &parent, const ConstString &name, const CompilerType &cast_type,
+ ValueObject &parent, ConstString name, const CompilerType &cast_type,
lldb::addr_t live_address)
: ValueObjectCast(parent, name, cast_type), m_impl(this, live_address) {
m_name = name;
diff --git a/source/Core/ValueObjectConstResultChild.cpp b/source/Core/ValueObjectConstResultChild.cpp
index 441c16479f2c6..4e0b303b69d59 100644
--- a/source/Core/ValueObjectConstResultChild.cpp
+++ b/source/Core/ValueObjectConstResultChild.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResultChild.cpp --------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,7 +23,7 @@ using namespace lldb_private;
ValueObjectConstResultChild::ValueObjectConstResultChild(
ValueObject &parent, const CompilerType &compiler_type,
- const ConstString &name, uint32_t byte_size, int32_t byte_offset,
+ 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)
diff --git a/source/Core/ValueObjectConstResultImpl.cpp b/source/Core/ValueObjectConstResultImpl.cpp
index 6bf8e62db0679..de51735736b9c 100644
--- a/source/Core/ValueObjectConstResultImpl.cpp
+++ b/source/Core/ValueObjectConstResultImpl.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectConstResultImpl.cpp ---------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,7 +39,7 @@ ValueObjectConstResultImpl::ValueObjectConstResultImpl(
m_address_of_backend() {}
lldb::ValueObjectSP ValueObjectConstResultImpl::Dereference(Status &error) {
- if (m_impl_backend == NULL)
+ if (m_impl_backend == nullptr)
return lldb::ValueObjectSP();
return m_impl_backend->ValueObject::Dereference(error);
@@ -48,12 +47,12 @@ lldb::ValueObjectSP ValueObjectConstResultImpl::Dereference(Status &error) {
ValueObject *ValueObjectConstResultImpl::CreateChildAtIndex(
size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
- if (m_impl_backend == NULL)
- return NULL;
+ if (m_impl_backend == nullptr)
+ return nullptr;
m_impl_backend->UpdateValueIfNeeded(false);
- ValueObjectConstResultChild *valobj = NULL;
+ ValueObjectConstResultChild *valobj = nullptr;
bool omit_empty_base_classes = true;
bool ignore_array_bounds = synthetic_array_member;
@@ -107,7 +106,7 @@ ValueObject *ValueObjectConstResultImpl::CreateChildAtIndex(
lldb::ValueObjectSP ValueObjectConstResultImpl::GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str) {
- if (m_impl_backend == NULL)
+ if (m_impl_backend == nullptr)
return lldb::ValueObjectSP();
return m_impl_backend->ValueObject::GetSyntheticChildAtOffset(
@@ -115,10 +114,10 @@ lldb::ValueObjectSP ValueObjectConstResultImpl::GetSyntheticChildAtOffset(
}
lldb::ValueObjectSP ValueObjectConstResultImpl::AddressOf(Status &error) {
- if (m_address_of_backend.get() != NULL)
+ if (m_address_of_backend.get() != nullptr)
return m_address_of_backend;
- if (m_impl_backend == NULL)
+ if (m_impl_backend == nullptr)
return lldb::ValueObjectSP();
if (m_live_address != LLDB_INVALID_ADDRESS) {
CompilerType compiler_type(m_impl_backend->GetCompilerType());
@@ -144,7 +143,7 @@ lldb::ValueObjectSP ValueObjectConstResultImpl::AddressOf(Status &error) {
lldb::ValueObjectSP
ValueObjectConstResultImpl::Cast(const CompilerType &compiler_type) {
- if (m_impl_backend == NULL)
+ if (m_impl_backend == nullptr)
return lldb::ValueObjectSP();
ValueObjectConstResultCast *result_cast =
@@ -157,7 +156,7 @@ lldb::addr_t
ValueObjectConstResultImpl::GetAddressOf(bool scalar_is_load_address,
AddressType *address_type) {
- if (m_impl_backend == NULL)
+ if (m_impl_backend == nullptr)
return 0;
if (m_live_address == LLDB_INVALID_ADDRESS) {
@@ -174,7 +173,7 @@ ValueObjectConstResultImpl::GetAddressOf(bool scalar_is_load_address,
size_t ValueObjectConstResultImpl::GetPointeeData(DataExtractor &data,
uint32_t item_idx,
uint32_t item_count) {
- if (m_impl_backend == NULL)
+ if (m_impl_backend == nullptr)
return 0;
return m_impl_backend->ValueObject::GetPointeeData(data, item_idx,
item_count);
diff --git a/source/Core/ValueObjectDynamicValue.cpp b/source/Core/ValueObjectDynamicValue.cpp
index 161b6e49e0dda..90b46d1f170de 100644
--- a/source/Core/ValueObjectDynamicValue.cpp
+++ b/source/Core/ValueObjectDynamicValue.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectDynamicValue.cpp ------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Core/ValueObjectList.cpp b/source/Core/ValueObjectList.cpp
index 7a7e0d8417b7e..358a1b14517b9 100644
--- a/source/Core/ValueObjectList.cpp
+++ b/source/Core/ValueObjectList.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectList.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,13 +17,6 @@
using namespace lldb;
using namespace lldb_private;
-ValueObjectList::ValueObjectList() : m_value_objects() {}
-
-ValueObjectList::ValueObjectList(const ValueObjectList &rhs)
- : m_value_objects(rhs.m_value_objects) {}
-
-ValueObjectList::~ValueObjectList() {}
-
const ValueObjectList &ValueObjectList::operator=(const ValueObjectList &rhs) {
if (this != &rhs)
m_value_objects = rhs.m_value_objects;
diff --git a/source/Core/ValueObjectMemory.cpp b/source/Core/ValueObjectMemory.cpp
index 24103204ee47e..95d4330ee0c6b 100644
--- a/source/Core/ValueObjectMemory.cpp
+++ b/source/Core/ValueObjectMemory.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectMemory.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,7 +49,7 @@ ValueObjectMemory::ValueObjectMemory(ExecutionContextScope *exe_scope,
: ValueObject(exe_scope), m_address(address), m_type_sp(type_sp),
m_compiler_type() {
// Do not attempt to construct one of these objects with no variable!
- assert(m_type_sp.get() != NULL);
+ assert(m_type_sp.get() != nullptr);
SetName(ConstString(name));
m_value.SetContext(Value::eContextTypeLLDBType, m_type_sp.get());
TargetSP target_sp(GetTargetSP());
@@ -137,10 +136,8 @@ size_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {
uint64_t ValueObjectMemory::GetByteSize() {
if (m_type_sp)
- return m_type_sp->GetByteSize();
- if (llvm::Optional<uint64_t> size = m_compiler_type.GetByteSize(nullptr))
- return *size;
- return 0;
+ return m_type_sp->GetByteSize().getValueOr(0);
+ return m_compiler_type.GetByteSize(nullptr).getValueOr(0);
}
lldb::ValueType ValueObjectMemory::GetValueType() const {
diff --git a/source/Core/ValueObjectRegister.cpp b/source/Core/ValueObjectRegister.cpp
index 41d1c27f73619..75a254fbbc21d 100644
--- a/source/Core/ValueObjectRegister.cpp
+++ b/source/Core/ValueObjectRegister.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectRegister.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -77,7 +76,7 @@ bool ValueObjectRegisterContext::UpdateValue() {
else
m_reg_ctx_sp.reset();
- if (m_reg_ctx_sp.get() == NULL) {
+ if (m_reg_ctx_sp.get() == nullptr) {
SetValueIsValid(false);
m_error.SetErrorToGenericError();
} else
@@ -88,7 +87,7 @@ bool ValueObjectRegisterContext::UpdateValue() {
ValueObject *ValueObjectRegisterContext::CreateChildAtIndex(
size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
- ValueObject *new_valobj = NULL;
+ ValueObject *new_valobj = nullptr;
const size_t num_children = GetNumChildren();
if (idx < num_children) {
@@ -113,7 +112,7 @@ ValueObjectRegisterSet::Create(ExecutionContextScope *exe_scope,
ValueObjectRegisterSet::ValueObjectRegisterSet(ExecutionContextScope *exe_scope,
lldb::RegisterContextSP &reg_ctx,
uint32_t reg_set_idx)
- : ValueObject(exe_scope), m_reg_ctx_sp(reg_ctx), m_reg_set(NULL),
+ : ValueObject(exe_scope), m_reg_ctx_sp(reg_ctx), m_reg_set(nullptr),
m_reg_set_idx(reg_set_idx) {
assert(reg_ctx);
m_reg_set = reg_ctx->GetRegisterSet(m_reg_set_idx);
@@ -150,13 +149,13 @@ bool ValueObjectRegisterSet::UpdateValue() {
SetValueDidChange(false);
ExecutionContext exe_ctx(GetExecutionContextRef());
StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL)
+ if (frame == nullptr)
m_reg_ctx_sp.reset();
else {
m_reg_ctx_sp = frame->GetRegisterContext();
if (m_reg_ctx_sp) {
const RegisterSet *reg_set = m_reg_ctx_sp->GetRegisterSet(m_reg_set_idx);
- if (reg_set == NULL)
+ if (reg_set == nullptr)
m_reg_ctx_sp.reset();
else if (m_reg_set != reg_set) {
SetValueDidChange(true);
@@ -176,7 +175,7 @@ bool ValueObjectRegisterSet::UpdateValue() {
ValueObject *ValueObjectRegisterSet::CreateChildAtIndex(
size_t idx, bool synthetic_array_member, int32_t synthetic_index) {
- ValueObject *valobj = NULL;
+ ValueObject *valobj = nullptr;
if (m_reg_ctx_sp && m_reg_set) {
const size_t num_children = GetNumChildren();
if (idx < num_children)
@@ -187,13 +186,13 @@ ValueObject *ValueObjectRegisterSet::CreateChildAtIndex(
}
lldb::ValueObjectSP
-ValueObjectRegisterSet::GetChildMemberWithName(const ConstString &name,
+ValueObjectRegisterSet::GetChildMemberWithName(ConstString name,
bool can_create) {
- ValueObject *valobj = NULL;
+ ValueObject *valobj = nullptr;
if (m_reg_ctx_sp && m_reg_set) {
const RegisterInfo *reg_info =
m_reg_ctx_sp->GetRegisterInfoByName(name.AsCString());
- if (reg_info != NULL)
+ if (reg_info != nullptr)
valobj = new ValueObjectRegister(*this, m_reg_ctx_sp,
reg_info->kinds[eRegisterKindLLDB]);
}
@@ -204,11 +203,11 @@ ValueObjectRegisterSet::GetChildMemberWithName(const ConstString &name,
}
size_t
-ValueObjectRegisterSet::GetIndexOfChildWithName(const ConstString &name) {
+ValueObjectRegisterSet::GetIndexOfChildWithName(ConstString name) {
if (m_reg_ctx_sp && m_reg_set) {
const RegisterInfo *reg_info =
m_reg_ctx_sp->GetRegisterInfoByName(name.AsCString());
- if (reg_info != NULL)
+ if (reg_info != nullptr)
return reg_info->kinds[eRegisterKindLLDB];
}
return UINT32_MAX;
@@ -290,7 +289,7 @@ bool ValueObjectRegister::UpdateValue() {
m_error.Clear();
ExecutionContext exe_ctx(GetExecutionContextRef());
StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL) {
+ if (frame == nullptr) {
m_reg_ctx_sp.reset();
m_reg_value.Clear();
}
diff --git a/source/Core/ValueObjectSyntheticFilter.cpp b/source/Core/ValueObjectSyntheticFilter.cpp
index d22b1dc1c57d6..4004732357592 100644
--- a/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/source/Core/ValueObjectSyntheticFilter.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectSyntheticFilter.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,7 +36,7 @@ public:
return m_backend.GetChildAtIndex(idx, true);
}
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return m_backend.GetIndexOfChildWithName(name);
}
@@ -73,7 +72,7 @@ ConstString ValueObjectSynthetic::GetQualifiedTypeName() {
}
ConstString ValueObjectSynthetic::GetDisplayTypeName() {
- if (ConstString synth_name = m_synth_filter_ap->GetSyntheticTypeName())
+ if (ConstString synth_name = m_synth_filter_up->GetSyntheticTypeName())
return synth_name;
return m_parent->GetDisplayTypeName();
@@ -87,7 +86,7 @@ size_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) {
return m_synthetic_children_count <= max ? m_synthetic_children_count : max;
if (max < UINT32_MAX) {
- size_t num_children = m_synth_filter_ap->CalculateNumChildren(max);
+ size_t num_children = m_synth_filter_up->CalculateNumChildren(max);
if (log)
log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name "
"%s and type %s, the filter returned %zu child values",
@@ -96,7 +95,7 @@ size_t ValueObjectSynthetic::CalculateNumChildren(uint32_t max) {
return num_children;
} else {
size_t num_children = (m_synthetic_children_count =
- m_synth_filter_ap->CalculateNumChildren(max));
+ m_synth_filter_up->CalculateNumChildren(max));
if (log)
log->Printf("[ValueObjectSynthetic::CalculateNumChildren] for VO of name "
"%s and type %s, the filter returned %zu child values",
@@ -118,7 +117,7 @@ ValueObjectSynthetic::GetDynamicValue(lldb::DynamicValueType valueType) {
bool ValueObjectSynthetic::MightHaveChildren() {
if (m_might_have_children == eLazyBoolCalculate)
m_might_have_children =
- (m_synth_filter_ap->MightHaveChildren() ? eLazyBoolYes : eLazyBoolNo);
+ (m_synth_filter_up->MightHaveChildren() ? eLazyBoolYes : eLazyBoolNo);
return (m_might_have_children != eLazyBoolNo);
}
@@ -141,9 +140,9 @@ void ValueObjectSynthetic::CreateSynthFilter() {
valobj_for_frontend = deref_sp.get();
}
}
- m_synth_filter_ap = (m_synth_sp->GetFrontEnd(*valobj_for_frontend));
- if (!m_synth_filter_ap.get())
- m_synth_filter_ap = llvm::make_unique<DummySyntheticFrontEnd>(*m_parent);
+ m_synth_filter_up = (m_synth_sp->GetFrontEnd(*valobj_for_frontend));
+ if (!m_synth_filter_up)
+ m_synth_filter_up = llvm::make_unique<DummySyntheticFrontEnd>(*m_parent);
}
bool ValueObjectSynthetic::UpdateValue() {
@@ -174,7 +173,7 @@ bool ValueObjectSynthetic::UpdateValue() {
}
// let our backend do its update
- if (!m_synth_filter_ap->Update()) {
+ if (!m_synth_filter_up->Update()) {
if (log)
log->Printf("[ValueObjectSynthetic::UpdateValue] name=%s, synthetic "
"filter said caches are stale - clearing",
@@ -199,7 +198,7 @@ bool ValueObjectSynthetic::UpdateValue() {
m_provides_value = eLazyBoolCalculate;
- lldb::ValueObjectSP synth_val(m_synth_filter_ap->GetSyntheticValue());
+ lldb::ValueObjectSP synth_val(m_synth_filter_up->GetSyntheticValue());
if (synth_val && synth_val->CanProvideValue()) {
if (log)
@@ -236,13 +235,13 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
ValueObject *valobj;
if (!m_children_byindex.GetValueForKey(idx, valobj)) {
- if (can_create && m_synth_filter_ap.get() != nullptr) {
+ if (can_create && m_synth_filter_up != nullptr) {
if (log)
log->Printf("[ValueObjectSynthetic::GetChildAtIndex] name=%s, child at "
"index %zu not cached and will be created",
GetName().AsCString(), idx);
- lldb::ValueObjectSP synth_guy = m_synth_filter_ap->GetChildAtIndex(idx);
+ lldb::ValueObjectSP synth_guy = m_synth_filter_up->GetChildAtIndex(idx);
if (log)
log->Printf(
@@ -269,7 +268,7 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
"index %zu not cached and cannot "
"be created (can_create = %s, synth_filter = %p)",
GetName().AsCString(), idx, can_create ? "yes" : "no",
- static_cast<void *>(m_synth_filter_ap.get()));
+ static_cast<void *>(m_synth_filter_up.get()));
return lldb::ValueObjectSP();
}
@@ -284,7 +283,7 @@ lldb::ValueObjectSP ValueObjectSynthetic::GetChildAtIndex(size_t idx,
}
lldb::ValueObjectSP
-ValueObjectSynthetic::GetChildMemberWithName(const ConstString &name,
+ValueObjectSynthetic::GetChildMemberWithName(ConstString name,
bool can_create) {
UpdateValueIfNeeded();
@@ -296,19 +295,19 @@ ValueObjectSynthetic::GetChildMemberWithName(const ConstString &name,
return GetChildAtIndex(index, can_create);
}
-size_t ValueObjectSynthetic::GetIndexOfChildWithName(const ConstString &name) {
+size_t ValueObjectSynthetic::GetIndexOfChildWithName(ConstString name) {
UpdateValueIfNeeded();
uint32_t found_index = UINT32_MAX;
bool did_find = m_name_toindex.GetValueForKey(name.GetCString(), found_index);
- if (!did_find && m_synth_filter_ap.get() != nullptr) {
- uint32_t index = m_synth_filter_ap->GetIndexOfChildWithName(name);
+ if (!did_find && m_synth_filter_up != nullptr) {
+ uint32_t index = m_synth_filter_up->GetIndexOfChildWithName(name);
if (index == UINT32_MAX)
return index;
m_name_toindex.SetValueForKey(name.GetCString(), index);
return index;
- } else if (!did_find && m_synth_filter_ap.get() == nullptr)
+ } else if (!did_find && m_synth_filter_up == nullptr)
return UINT32_MAX;
else /*if (iter != m_name_toindex.end())*/
return found_index;
diff --git a/source/Core/ValueObjectVariable.cpp b/source/Core/ValueObjectVariable.cpp
index 4d401c56249cb..5aee82493b28f 100644
--- a/source/Core/ValueObjectVariable.cpp
+++ b/source/Core/ValueObjectVariable.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectVariable.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -58,7 +57,7 @@ ValueObjectVariable::ValueObjectVariable(ExecutionContextScope *exe_scope,
const lldb::VariableSP &var_sp)
: ValueObject(exe_scope), m_variable_sp(var_sp) {
// Do not attempt to construct one of these objects with no variable!
- assert(m_variable_sp.get() != NULL);
+ assert(m_variable_sp.get() != nullptr);
m_name = var_sp->GetName();
}
@@ -136,7 +135,7 @@ bool ValueObjectVariable::UpdateValue() {
else
m_error.SetErrorString("empty constant data");
// constant bytes can't be edited - sorry
- m_resolved_value.SetContext(Value::eContextTypeInvalid, NULL);
+ m_resolved_value.SetContext(Value::eContextTypeInvalid, nullptr);
} else {
lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS;
ExecutionContext exe_ctx(GetExecutionContextRef());
@@ -262,7 +261,7 @@ bool ValueObjectVariable::UpdateValue() {
SetValueIsValid(m_error.Success());
} else {
// could not find location, won't allow editing
- m_resolved_value.SetContext(Value::eContextTypeInvalid, NULL);
+ m_resolved_value.SetContext(Value::eContextTypeInvalid, nullptr);
}
}
return m_error.Success();
@@ -299,7 +298,7 @@ lldb::ModuleSP ValueObjectVariable::GetModule() {
SymbolContextScope *ValueObjectVariable::GetSymbolContextScope() {
if (m_variable_sp)
return m_variable_sp->GetSymbolContextScope();
- return NULL;
+ return nullptr;
}
bool ValueObjectVariable::GetDeclaration(Declaration &decl) {
diff --git a/source/DataFormatters/CXXFunctionPointer.cpp b/source/DataFormatters/CXXFunctionPointer.cpp
index 9059891e5e9b9..0ca000eb0529d 100644
--- a/source/DataFormatters/CXXFunctionPointer.cpp
+++ b/source/DataFormatters/CXXFunctionPointer.cpp
@@ -1,9 +1,8 @@
//===-- CXXFunctionPointer.cpp-----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/DataFormatters/DataVisualization.cpp b/source/DataFormatters/DataVisualization.cpp
index 23b8b6e128c8c..08b3b34447bba 100644
--- a/source/DataFormatters/DataVisualization.cpp
+++ b/source/DataFormatters/DataVisualization.cpp
@@ -1,10 +1,9 @@
//===-- DataVisualization.cpp ---------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,32 +50,21 @@ DataVisualization::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {
return GetFormatManager().GetSummaryForType(type_sp);
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
DataVisualization::GetSyntheticChildren(ValueObject &valobj,
lldb::DynamicValueType use_dynamic) {
return GetFormatManager().GetSyntheticChildren(valobj, use_dynamic);
}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP DataVisualization::GetSyntheticChildrenForType(
- lldb::TypeNameSpecifierImplSP type_sp) {
- return GetFormatManager().GetSyntheticChildrenForType(type_sp);
-}
-#endif
lldb::TypeFilterImplSP
DataVisualization::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
return GetFormatManager().GetFilterForType(type_sp);
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::ScriptedSyntheticChildrenSP
DataVisualization::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
return GetFormatManager().GetSyntheticForType(type_sp);
}
-#endif
lldb::TypeValidatorImplSP
DataVisualization::GetValidator(ValueObject &valobj,
@@ -97,11 +85,11 @@ bool DataVisualization::AnyMatches(
matching_category, matching_type);
}
-bool DataVisualization::Categories::GetCategory(const ConstString &category,
+bool DataVisualization::Categories::GetCategory(ConstString category,
lldb::TypeCategoryImplSP &entry,
bool allow_create) {
entry = GetFormatManager().GetCategory(category, allow_create);
- return (entry.get() != NULL);
+ return (entry.get() != nullptr);
}
bool DataVisualization::Categories::GetCategory(
@@ -112,11 +100,11 @@ bool DataVisualization::Categories::GetCategory(
return (entry.get() != nullptr);
}
-void DataVisualization::Categories::Add(const ConstString &category) {
+void DataVisualization::Categories::Add(ConstString category) {
GetFormatManager().GetCategory(category);
}
-bool DataVisualization::Categories::Delete(const ConstString &category) {
+bool DataVisualization::Categories::Delete(ConstString category) {
GetFormatManager().DisableCategory(category);
return GetFormatManager().DeleteCategory(category);
}
@@ -125,12 +113,12 @@ void DataVisualization::Categories::Clear() {
GetFormatManager().ClearCategories();
}
-void DataVisualization::Categories::Clear(const ConstString &category) {
+void DataVisualization::Categories::Clear(ConstString category) {
GetFormatManager().GetCategory(category)->Clear(
eFormatCategoryItemSummary | eFormatCategoryItemRegexSummary);
}
-void DataVisualization::Categories::Enable(const ConstString &category,
+void DataVisualization::Categories::Enable(ConstString category,
TypeCategoryMap::Position pos) {
if (GetFormatManager().GetCategory(category)->IsEnabled())
GetFormatManager().DisableCategory(category);
@@ -144,7 +132,7 @@ void DataVisualization::Categories::Enable(lldb::LanguageType lang_type) {
lang_category->Enable();
}
-void DataVisualization::Categories::Disable(const ConstString &category) {
+void DataVisualization::Categories::Disable(ConstString category) {
if (GetFormatManager().GetCategory(category)->IsEnabled())
GetFormatManager().DisableCategory(category);
}
@@ -193,17 +181,17 @@ DataVisualization::Categories::GetCategoryAtIndex(size_t index) {
}
bool DataVisualization::NamedSummaryFormats::GetSummaryFormat(
- const ConstString &type, lldb::TypeSummaryImplSP &entry) {
+ ConstString type, lldb::TypeSummaryImplSP &entry) {
return GetFormatManager().GetNamedSummaryContainer().Get(type, entry);
}
void DataVisualization::NamedSummaryFormats::Add(
- const ConstString &type, const lldb::TypeSummaryImplSP &entry) {
+ ConstString type, const lldb::TypeSummaryImplSP &entry) {
GetFormatManager().GetNamedSummaryContainer().Add(
FormatManager::GetValidTypeName(type), entry);
}
-bool DataVisualization::NamedSummaryFormats::Delete(const ConstString &type) {
+bool DataVisualization::NamedSummaryFormats::Delete(ConstString type) {
return GetFormatManager().GetNamedSummaryContainer().Delete(type);
}
diff --git a/source/DataFormatters/DumpValueObjectOptions.cpp b/source/DataFormatters/DumpValueObjectOptions.cpp
index 17f8d00ff4937..84f21696e0548 100644
--- a/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -1,10 +1,9 @@
//===-- DumpValueObjectOptions.cpp -----------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/DataFormatters/FormatCache.cpp b/source/DataFormatters/FormatCache.cpp
index bb5f379d3c736..7e328cb0dac85 100644
--- a/source/DataFormatters/FormatCache.cpp
+++ b/source/DataFormatters/FormatCache.cpp
@@ -1,10 +1,9 @@
//===-- FormatCache.cpp ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -110,7 +109,7 @@ FormatCache::FormatCache()
{
}
-FormatCache::Entry &FormatCache::GetEntry(const ConstString &type) {
+FormatCache::Entry &FormatCache::GetEntry(ConstString type) {
auto i = m_map.find(type), e = m_map.end();
if (i != e)
return i->second;
@@ -118,7 +117,7 @@ FormatCache::Entry &FormatCache::GetEntry(const ConstString &type) {
return m_map[type];
}
-bool FormatCache::GetFormat(const ConstString &type,
+bool FormatCache::GetFormat(ConstString type,
lldb::TypeFormatImplSP &format_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type);
@@ -136,7 +135,7 @@ bool FormatCache::GetFormat(const ConstString &type,
return false;
}
-bool FormatCache::GetSummary(const ConstString &type,
+bool FormatCache::GetSummary(ConstString type,
lldb::TypeSummaryImplSP &summary_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type);
@@ -154,7 +153,7 @@ bool FormatCache::GetSummary(const ConstString &type,
return false;
}
-bool FormatCache::GetSynthetic(const ConstString &type,
+bool FormatCache::GetSynthetic(ConstString type,
lldb::SyntheticChildrenSP &synthetic_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type);
@@ -172,7 +171,7 @@ bool FormatCache::GetSynthetic(const ConstString &type,
return false;
}
-bool FormatCache::GetValidator(const ConstString &type,
+bool FormatCache::GetValidator(ConstString type,
lldb::TypeValidatorImplSP &validator_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
auto entry = GetEntry(type);
@@ -190,25 +189,25 @@ bool FormatCache::GetValidator(const ConstString &type,
return false;
}
-void FormatCache::SetFormat(const ConstString &type,
+void FormatCache::SetFormat(ConstString type,
lldb::TypeFormatImplSP &format_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetFormat(format_sp);
}
-void FormatCache::SetSummary(const ConstString &type,
+void FormatCache::SetSummary(ConstString type,
lldb::TypeSummaryImplSP &summary_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetSummary(summary_sp);
}
-void FormatCache::SetSynthetic(const ConstString &type,
+void FormatCache::SetSynthetic(ConstString type,
lldb::SyntheticChildrenSP &synthetic_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetSynthetic(synthetic_sp);
}
-void FormatCache::SetValidator(const ConstString &type,
+void FormatCache::SetValidator(ConstString type,
lldb::TypeValidatorImplSP &validator_sp) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
GetEntry(type).SetValidator(validator_sp);
diff --git a/source/DataFormatters/FormatClasses.cpp b/source/DataFormatters/FormatClasses.cpp
index 1c595c3c04e5b..271963b5f8f43 100644
--- a/source/DataFormatters/FormatClasses.cpp
+++ b/source/DataFormatters/FormatClasses.cpp
@@ -1,10 +1,9 @@
//===-- FormatClasses.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/DataFormatters/FormatManager.cpp b/source/DataFormatters/FormatManager.cpp
index da03c64b0f8c9..dd2808a7cf7c9 100644
--- a/source/DataFormatters/FormatManager.cpp
+++ b/source/DataFormatters/FormatManager.cpp
@@ -1,9 +1,8 @@
//===-- FormatManager.cpp ----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -147,7 +146,7 @@ char FormatManager::GetFormatAsFormatChar(lldb::Format format) {
const char *FormatManager::GetFormatAsCString(Format format) {
if (format >= eFormatDefault && format < kNumFormats)
return g_format_infos[format].format_name;
- return NULL;
+ return nullptr;
}
void FormatManager::EnableAllCategories() {
@@ -298,7 +297,7 @@ FormatManager::GetFormatForType(lldb::TypeNameSpecifierImplSP type_sp) {
lldb::TypeFormatImplSP format_current_sp =
category_sp->GetFormatForType(type_sp);
if (format_current_sp &&
- (format_chosen_sp.get() == NULL ||
+ (format_chosen_sp.get() == nullptr ||
(prio_category > category_sp->GetEnabledPosition()))) {
prio_category = category_sp->GetEnabledPosition();
format_chosen_sp = format_current_sp;
@@ -322,7 +321,7 @@ FormatManager::GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp) {
lldb::TypeSummaryImplSP summary_current_sp =
category_sp->GetSummaryForType(type_sp);
if (summary_current_sp &&
- (summary_chosen_sp.get() == NULL ||
+ (summary_chosen_sp.get() == nullptr ||
(prio_category > category_sp->GetEnabledPosition()))) {
prio_category = category_sp->GetEnabledPosition();
summary_chosen_sp = summary_current_sp;
@@ -346,7 +345,7 @@ FormatManager::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
lldb::TypeFilterImplSP filter_current_sp(
(TypeFilterImpl *)category_sp->GetFilterForType(type_sp).get());
if (filter_current_sp &&
- (filter_chosen_sp.get() == NULL ||
+ (filter_chosen_sp.get() == nullptr ||
(prio_category > category_sp->GetEnabledPosition()))) {
prio_category = category_sp->GetEnabledPosition();
filter_chosen_sp = filter_current_sp;
@@ -355,7 +354,6 @@ FormatManager::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
return filter_chosen_sp;
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::ScriptedSyntheticChildrenSP
FormatManager::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
if (!type_sp)
@@ -372,7 +370,7 @@ FormatManager::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
(ScriptedSyntheticChildren *)category_sp->GetSyntheticForType(type_sp)
.get());
if (synth_current_sp &&
- (synth_chosen_sp.get() == NULL ||
+ (synth_chosen_sp.get() == nullptr ||
(prio_category > category_sp->GetEnabledPosition()))) {
prio_category = category_sp->GetEnabledPosition();
synth_chosen_sp = synth_current_sp;
@@ -380,21 +378,6 @@ FormatManager::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
}
return synth_chosen_sp;
}
-#endif
-
-#ifndef LLDB_DISABLE_PYTHON
-lldb::SyntheticChildrenSP FormatManager::GetSyntheticChildrenForType(
- lldb::TypeNameSpecifierImplSP type_sp) {
- if (!type_sp)
- return lldb::SyntheticChildrenSP();
- lldb::TypeFilterImplSP filter_sp = GetFilterForType(type_sp);
- lldb::ScriptedSyntheticChildrenSP synth_sp = GetSyntheticForType(type_sp);
- if (filter_sp->GetRevision() > synth_sp->GetRevision())
- return lldb::SyntheticChildrenSP(filter_sp.get());
- else
- return lldb::SyntheticChildrenSP(synth_sp.get());
-}
-#endif
lldb::TypeValidatorImplSP
FormatManager::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) {
@@ -411,7 +394,7 @@ FormatManager::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) {
lldb::TypeValidatorImplSP validator_current_sp(
category_sp->GetValidatorForType(type_sp).get());
if (validator_current_sp &&
- (validator_chosen_sp.get() == NULL ||
+ (validator_chosen_sp.get() == nullptr ||
(prio_category > category_sp->GetEnabledPosition()))) {
prio_category = category_sp->GetEnabledPosition();
validator_chosen_sp = validator_current_sp;
@@ -432,7 +415,7 @@ void FormatManager::ForEachCategory(TypeCategoryMap::ForEachCallback callback) {
}
lldb::TypeCategoryImplSP
-FormatManager::GetCategory(const ConstString &category_name, bool can_create) {
+FormatManager::GetCategory(ConstString category_name, bool can_create) {
if (!category_name)
return GetCategory(m_default_category_name);
lldb::TypeCategoryImplSP category;
@@ -574,7 +557,7 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject &valobj) {
return true;
}
-ConstString FormatManager::GetValidTypeName(const ConstString &type) {
+ConstString FormatManager::GetValidTypeName(ConstString type) {
return ::GetValidTypeName_Impl(type);
}
@@ -781,7 +764,6 @@ FormatManager::GetSummaryFormat(ValueObject &valobj,
return retval;
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
FormatManager::GetHardcodedSyntheticChildren(FormattersMatchData &match_data) {
SyntheticChildrenSP retval_sp;
@@ -860,7 +842,6 @@ FormatManager::GetSyntheticChildren(ValueObject &valobj,
m_format_cache.GetCacheHits(), m_format_cache.GetCacheMisses());
return retval;
}
-#endif
lldb::TypeValidatorImplSP
FormatManager::GetValidator(ValueObject &valobj,
@@ -1009,14 +990,12 @@ void FormatManager::LoadSystemFormatters() {
sys_category_sp->GetTypeSummariesContainer()->Add(ConstString("OSType"),
ostype_summary);
-#ifndef LLDB_DISABLE_PYTHON
TypeFormatImpl::Flags fourchar_flags;
fourchar_flags.SetCascades(true).SetSkipPointers(true).SetSkipReferences(
true);
AddFormat(sys_category_sp, lldb::eFormatOSType, ConstString("FourCharCode"),
fourchar_flags);
-#endif
}
void FormatManager::LoadVectorFormatters() {
diff --git a/source/DataFormatters/FormattersHelpers.cpp b/source/DataFormatters/FormattersHelpers.cpp
index 1a1321598966c..8f007df03faa4 100644
--- a/source/DataFormatters/FormattersHelpers.cpp
+++ b/source/DataFormatters/FormattersHelpers.cpp
@@ -1,10 +1,9 @@
//===-- FormattersHelpers.cpp -------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -74,7 +73,6 @@ void lldb_private::formatters::AddOneLineSummary(
category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
}
-#ifndef LLDB_DISABLE_PYTHON
void lldb_private::formatters::AddCXXSummary(
TypeCategoryImpl::SharedPointer category_sp,
CXXFunctionSummaryFormat::Callback funct, const char *description,
@@ -118,7 +116,6 @@ void lldb_private::formatters::AddFilter(
else
category_sp->GetTypeFiltersContainer()->Add(type_name, filter_sp);
}
-#endif
size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) {
if (!item_name || !*item_name)
@@ -126,7 +123,7 @@ size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) {
if (*item_name != '[')
return UINT32_MAX;
item_name++;
- char *endptr = NULL;
+ char *endptr = nullptr;
unsigned long int idx = ::strtoul(item_name, &endptr, 0);
if (idx == 0 && endptr == item_name)
return UINT32_MAX;
diff --git a/source/DataFormatters/LanguageCategory.cpp b/source/DataFormatters/LanguageCategory.cpp
index 4a4b7c544f093..969b02556548c 100644
--- a/source/DataFormatters/LanguageCategory.cpp
+++ b/source/DataFormatters/LanguageCategory.cpp
@@ -1,10 +1,9 @@
//===-- LanguageCategory.cpp ---------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/DataFormatters/StringPrinter.cpp b/source/DataFormatters/StringPrinter.cpp
index 6a000f0f64314..27d649bfc370e 100644
--- a/source/DataFormatters/StringPrinter.cpp
+++ b/source/DataFormatters/StringPrinter.cpp
@@ -1,10 +1,9 @@
//===-- StringPrinter.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,6 +20,7 @@
#include <ctype.h>
#include <locale>
+#include <memory>
using namespace lldb;
using namespace lldb_private;
@@ -271,7 +271,7 @@ static bool DumpUTFBufferToStream(
llvm::ConversionFlags),
const StringPrinter::ReadBufferAndDumpToStreamOptions &dump_options) {
Stream &stream(*dump_options.GetStream());
- if (dump_options.GetPrefixToken() != 0)
+ if (dump_options.GetPrefixToken() != nullptr)
stream.Printf("%s", dump_options.GetPrefixToken());
if (dump_options.GetQuote() != 0)
stream.Printf("%c", dump_options.GetQuote());
@@ -307,7 +307,8 @@ static bool DumpUTFBufferToStream(
llvm::UTF8 *utf8_data_end_ptr = nullptr;
if (ConvertFunction) {
- utf8_data_buffer_sp.reset(new DataBufferHeap(4 * bufferSPSize, 0));
+ utf8_data_buffer_sp =
+ std::make_shared<DataBufferHeap>(4 * bufferSPSize, 0);
utf8_data_ptr = (llvm::UTF8 *)utf8_data_buffer_sp->GetBytes();
utf8_data_end_ptr = utf8_data_ptr + utf8_data_buffer_sp->GetByteSize();
ConvertFunction(&data_ptr, data_end_ptr, &utf8_data_ptr,
@@ -372,7 +373,7 @@ static bool DumpUTFBufferToStream(
}
if (dump_options.GetQuote() != 0)
stream.Printf("%c", dump_options.GetQuote());
- if (dump_options.GetSuffixToken() != 0)
+ if (dump_options.GetSuffixToken() != nullptr)
stream.Printf("%s", dump_options.GetSuffixToken());
if (dump_options.GetIsTruncated())
stream.Printf("...");
@@ -448,7 +449,7 @@ bool StringPrinter::ReadStringAndDumpToStream<
const char *prefix_token = options.GetPrefixToken();
char quote = options.GetQuote();
- if (prefix_token != 0)
+ if (prefix_token != nullptr)
options.GetStream()->Printf("%s%c", prefix_token, quote);
else if (quote != 0)
options.GetStream()->Printf("%c", quote);
@@ -496,7 +497,7 @@ bool StringPrinter::ReadStringAndDumpToStream<
const char *suffix_token = options.GetSuffixToken();
- if (suffix_token != 0)
+ if (suffix_token != nullptr)
options.GetStream()->Printf("%c%s", quote, suffix_token);
else if (quote != 0)
options.GetStream()->Printf("%c", quote);
diff --git a/source/DataFormatters/TypeCategory.cpp b/source/DataFormatters/TypeCategory.cpp
index 5740a095f8bd5..fed2dfb3c7c5b 100644
--- a/source/DataFormatters/TypeCategory.cpp
+++ b/source/DataFormatters/TypeCategory.cpp
@@ -1,9 +1,8 @@
//===-- TypeCategory.cpp -----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@ TypeCategoryImpl::TypeCategoryImpl(
: m_format_cont("format", "regex-format", clist),
m_summary_cont("summary", "regex-summary", clist),
m_filter_cont("filter", "regex-filter", clist),
-#ifndef LLDB_DISABLE_PYTHON
m_synth_cont("synth", "regex-synth", clist),
-#endif
m_validator_cont("validator", "regex-validator", clist), m_enabled(false),
m_change_listener(clist), m_mutex(), m_name(name), m_languages() {
for (const lldb::LanguageType lang : langs)
@@ -139,7 +136,6 @@ bool TypeCategoryImpl::Get(ValueObject &valobj,
regex_filter = GetRegexTypeFiltersContainer()->Get(candidates, filter_sp,
&reason_filter);
-#ifndef LLDB_DISABLE_PYTHON
bool regex_synth = false;
uint32_t reason_synth = 0;
bool pick_synth = false;
@@ -170,14 +166,6 @@ bool TypeCategoryImpl::Get(ValueObject &valobj,
entry = filter_sp;
return true;
}
-
-#else
- if (filter_sp) {
- entry = filter_sp;
- return true;
- }
-#endif
-
return false;
}
@@ -213,12 +201,10 @@ void TypeCategoryImpl::Clear(FormatCategoryItems items) {
eFormatCategoryItemRegexFilter)
GetRegexTypeFiltersContainer()->Clear();
-#ifndef LLDB_DISABLE_PYTHON
if ((items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth)
GetTypeSyntheticsContainer()->Clear();
if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth)
GetRegexTypeSyntheticsContainer()->Clear();
-#endif
if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator)
GetTypeValidatorsContainer()->Clear();
@@ -247,12 +233,10 @@ bool TypeCategoryImpl::Delete(ConstString name, FormatCategoryItems items) {
eFormatCategoryItemRegexFilter)
success = GetRegexTypeFiltersContainer()->Delete(name) || success;
-#ifndef LLDB_DISABLE_PYTHON
if ((items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth)
success = GetTypeSyntheticsContainer()->Delete(name) || success;
if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth)
success = GetRegexTypeSyntheticsContainer()->Delete(name) || success;
-#endif
if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator)
success = GetTypeValidatorsContainer()->Delete(name) || success;
@@ -283,12 +267,10 @@ uint32_t TypeCategoryImpl::GetCount(FormatCategoryItems items) {
eFormatCategoryItemRegexFilter)
count += GetRegexTypeFiltersContainer()->GetCount();
-#ifndef LLDB_DISABLE_PYTHON
if ((items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth)
count += GetTypeSyntheticsContainer()->GetCount();
if ((items & eFormatCategoryItemRegexSynth) == eFormatCategoryItemRegexSynth)
count += GetRegexTypeSyntheticsContainer()->GetCount();
-#endif
if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator)
count += GetTypeValidatorsContainer()->GetCount();
@@ -309,9 +291,7 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
lldb::TypeFormatImplSP format_sp;
lldb::TypeSummaryImplSP summary_sp;
TypeFilterImpl::SharedPointer filter_sp;
-#ifndef LLDB_DISABLE_PYTHON
ScriptedSyntheticChildren::SharedPointer synth_sp;
-#endif
TypeValidatorImpl::SharedPointer validator_sp;
if ((items & eFormatCategoryItemValue) == eFormatCategoryItemValue) {
@@ -374,7 +354,6 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
}
}
-#ifndef LLDB_DISABLE_PYTHON
if ((items & eFormatCategoryItemSynth) == eFormatCategoryItemSynth) {
if (GetTypeSyntheticsContainer()->Get(type_name, synth_sp)) {
if (matching_category)
@@ -394,7 +373,6 @@ bool TypeCategoryImpl::AnyMatches(ConstString type_name,
return true;
}
}
-#endif
if ((items & eFormatCategoryItemValidator) == eFormatCategoryItemValidator) {
if (GetTypeValidatorsContainer()->Get(type_name, validator_sp)) {
@@ -467,7 +445,6 @@ TypeCategoryImpl::GetFilterForType(lldb::TypeNameSpecifierImplSP type_sp) {
return retval;
}
-#ifndef LLDB_DISABLE_PYTHON
TypeCategoryImpl::SynthContainer::MapValueType
TypeCategoryImpl::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
SynthContainer::MapValueType retval;
@@ -483,7 +460,6 @@ TypeCategoryImpl::GetSyntheticForType(lldb::TypeNameSpecifierImplSP type_sp) {
return retval;
}
-#endif
TypeCategoryImpl::ValidatorContainer::MapValueType
TypeCategoryImpl::GetValidatorForType(lldb::TypeNameSpecifierImplSP type_sp) {
@@ -555,7 +531,6 @@ TypeCategoryImpl::GetTypeNameSpecifierForFilterAtIndex(size_t index) {
index - GetTypeFiltersContainer()->GetCount());
}
-#ifndef LLDB_DISABLE_PYTHON
TypeCategoryImpl::SynthContainer::MapValueType
TypeCategoryImpl::GetSyntheticAtIndex(size_t index) {
if (index < GetTypeSyntheticsContainer()->GetCount())
@@ -573,7 +548,6 @@ TypeCategoryImpl::GetTypeNameSpecifierForSyntheticAtIndex(size_t index) {
return GetRegexTypeSyntheticsContainer()->GetTypeNameSpecifierAtIndex(
index - GetTypeSyntheticsContainer()->GetCount());
}
-#endif
TypeCategoryImpl::ValidatorContainer::MapValueType
TypeCategoryImpl::GetValidatorAtIndex(size_t index) {
diff --git a/source/DataFormatters/TypeCategoryMap.cpp b/source/DataFormatters/TypeCategoryMap.cpp
index 3193f2703efaf..69757c9844e19 100644
--- a/source/DataFormatters/TypeCategoryMap.cpp
+++ b/source/DataFormatters/TypeCategoryMap.cpp
@@ -1,10 +1,9 @@
//===-- TypeCategoryMap.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -112,7 +111,7 @@ void TypeCategoryMap::EnableAllCategories() {
decltype(sorted_categories)::iterator viter = sorted_categories.begin(),
vend = sorted_categories.end();
for (; viter != vend; viter++)
- if (viter->get())
+ if (*viter)
Enable(*viter, Last);
}
@@ -250,7 +249,6 @@ TypeCategoryMap::GetSummaryFormat(FormattersMatchData &match_data) {
return lldb::TypeSummaryImplSP();
}
-#ifndef LLDB_DISABLE_PYTHON
lldb::SyntheticChildrenSP
TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
@@ -292,7 +290,6 @@ TypeCategoryMap::GetSyntheticChildren(FormattersMatchData &match_data) {
"empty SP");
return lldb::SyntheticChildrenSP();
}
-#endif
lldb::TypeValidatorImplSP
TypeCategoryMap::GetValidator(FormattersMatchData &match_data) {
diff --git a/source/DataFormatters/TypeFormat.cpp b/source/DataFormatters/TypeFormat.cpp
index f00a679cecfdf..b526e9a744bc4 100644
--- a/source/DataFormatters/TypeFormat.cpp
+++ b/source/DataFormatters/TypeFormat.cpp
@@ -1,9 +1,8 @@
//===-- TypeFormat.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -70,7 +69,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj,
// default value logic
if (GetFormat() == eFormatCString) {
lldb_private::Flags type_flags(compiler_type.GetTypeInfo(
- NULL)); // disambiguate w.r.t. TypeFormatImpl::Flags
+ nullptr)); // disambiguate w.r.t. TypeFormatImpl::Flags
if (type_flags.Test(eTypeIsPointer) &&
!type_flags.Test(eTypeIsObjC)) {
// if we are dumping a pointer as a c-string, get the pointee data
diff --git a/source/DataFormatters/TypeSummary.cpp b/source/DataFormatters/TypeSummary.cpp
index 492d3efc7f4c6..7f6930fdf41f9 100644
--- a/source/DataFormatters/TypeSummary.cpp
+++ b/source/DataFormatters/TypeSummary.cpp
@@ -1,9 +1,8 @@
//===-- TypeSummary.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,16 +29,6 @@ using namespace lldb_private;
TypeSummaryOptions::TypeSummaryOptions()
: m_lang(eLanguageTypeUnknown), m_capping(eTypeSummaryCapped) {}
-TypeSummaryOptions::TypeSummaryOptions(const TypeSummaryOptions &rhs)
- : m_lang(rhs.m_lang), m_capping(rhs.m_capping) {}
-
-TypeSummaryOptions &TypeSummaryOptions::
-operator=(const TypeSummaryOptions &rhs) {
- m_lang = rhs.m_lang;
- m_capping = rhs.m_capping;
- return *this;
-}
-
lldb::LanguageType TypeSummaryOptions::GetLanguage() const { return m_lang; }
lldb::TypeSummaryCapping TypeSummaryOptions::GetCapping() const {
@@ -178,7 +167,7 @@ bool ScriptSummaryFormat::FormatObject(ValueObject *valobj, std::string &retval,
}
ScriptInterpreter *script_interpreter =
- target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ target_sp->GetDebugger().GetScriptInterpreter();
if (!script_interpreter) {
retval.assign("error: no ScriptInterpreter");
diff --git a/source/DataFormatters/TypeSynthetic.cpp b/source/DataFormatters/TypeSynthetic.cpp
index de46d505349b6..23c80fc58d021 100644
--- a/source/DataFormatters/TypeSynthetic.cpp
+++ b/source/DataFormatters/TypeSynthetic.cpp
@@ -1,10 +1,9 @@
//===-- TypeSynthetic.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,7 +51,7 @@ bool TypeFilterImpl::SetExpressionPathAtIndex(size_t i,
}
size_t
-TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(const ConstString &name) {
+TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(ConstString name) {
const char *name_cstr = name.GetCString();
if (name_cstr) {
for (size_t i = 0; i < filter->GetCount(); i++) {
@@ -126,12 +125,10 @@ lldb::ValueObjectSP SyntheticChildrenFrontEnd::CreateValueObjectFromData(
return valobj_sp;
}
-#ifndef LLDB_DISABLE_PYTHON
-
ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass,
ValueObject &backend)
: SyntheticChildrenFrontEnd(backend), m_python_class(pclass),
- m_wrapper_sp(), m_interpreter(NULL) {
+ m_wrapper_sp(), m_interpreter(nullptr) {
if (backend == LLDB_INVALID_UID)
return;
@@ -140,10 +137,9 @@ ScriptedSyntheticChildren::FrontEnd::FrontEnd(std::string pclass,
if (!target_sp)
return;
- m_interpreter =
- target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ m_interpreter = target_sp->GetDebugger().GetScriptInterpreter();
- if (m_interpreter != NULL)
+ if (m_interpreter != nullptr)
m_wrapper_sp = m_interpreter->CreateSyntheticScriptedProvider(
m_python_class.c_str(), backend.GetSP());
}
@@ -163,48 +159,48 @@ bool ScriptedSyntheticChildren::FrontEnd::IsValid() {
}
size_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren() {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return 0;
return m_interpreter->CalculateNumChildren(m_wrapper_sp, UINT32_MAX);
}
size_t ScriptedSyntheticChildren::FrontEnd::CalculateNumChildren(uint32_t max) {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return 0;
return m_interpreter->CalculateNumChildren(m_wrapper_sp, max);
}
bool ScriptedSyntheticChildren::FrontEnd::Update() {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return false;
return m_interpreter->UpdateSynthProviderInstance(m_wrapper_sp);
}
bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return false;
return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp);
}
size_t ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ ConstString name) {
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return UINT32_MAX;
return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp,
name.GetCString());
}
lldb::ValueObjectSP ScriptedSyntheticChildren::FrontEnd::GetSyntheticValue() {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return nullptr;
return m_interpreter->GetSyntheticValue(m_wrapper_sp);
}
ConstString ScriptedSyntheticChildren::FrontEnd::GetSyntheticTypeName() {
- if (!m_wrapper_sp || m_interpreter == NULL)
+ if (!m_wrapper_sp || m_interpreter == nullptr)
return ConstString();
return m_interpreter->GetSyntheticTypeName(m_wrapper_sp);
@@ -219,5 +215,3 @@ std::string ScriptedSyntheticChildren::GetDescription() {
return sstr.GetString();
}
-
-#endif // #ifndef LLDB_DISABLE_PYTHON
diff --git a/source/DataFormatters/TypeValidator.cpp b/source/DataFormatters/TypeValidator.cpp
index 6769a5a99856f..5ce24cacfb555 100644
--- a/source/DataFormatters/TypeValidator.cpp
+++ b/source/DataFormatters/TypeValidator.cpp
@@ -1,9 +1,8 @@
//===-- TypeValidator.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/DataFormatters/ValueObjectPrinter.cpp b/source/DataFormatters/ValueObjectPrinter.cpp
index 082158822dff3..409cffed9b0f9 100644
--- a/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/source/DataFormatters/ValueObjectPrinter.cpp
@@ -1,9 +1,8 @@
//===-- ValueObjectPrinter.cpp -----------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -332,7 +331,7 @@ TypeSummaryImpl *ValueObjectPrinter::GetSummaryFormatter(bool null_if_omitted) {
: m_valobj->GetSummaryFormat().get();
if (m_options.m_omit_summary_depth > 0)
- entry = NULL;
+ entry = nullptr;
m_summary_formatter.first = entry;
m_summary_formatter.second = true;
}
@@ -416,8 +415,9 @@ bool ValueObjectPrinter::PrintValueAndSummaryIfNeeded(bool &value_printed,
// explicitly)
TypeSummaryImpl *entry = GetSummaryFormatter();
if (!IsNil() && !IsUninitialized() && !m_value.empty() &&
- (entry == NULL || (entry->DoesPrintValue(m_valobj) ||
- m_options.m_format != eFormatDefault) ||
+ (entry == nullptr ||
+ (entry->DoesPrintValue(m_valobj) ||
+ m_options.m_format != eFormatDefault) ||
m_summary.empty()) &&
!m_options.m_hide_value) {
if (m_options.m_hide_pointer_value &&
diff --git a/source/DataFormatters/VectorType.cpp b/source/DataFormatters/VectorType.cpp
index b11fb1456afa8..18880f72ef2e9 100644
--- a/source/DataFormatters/VectorType.cpp
+++ b/source/DataFormatters/VectorType.cpp
@@ -1,9 +1,8 @@
//===-- VectorType.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -234,7 +233,7 @@ public:
bool MightHaveChildren() override { return true; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
diff --git a/source/Expression/DWARFExpression.cpp b/source/Expression/DWARFExpression.cpp
index a6249b3a28649..a9d365325d9e2 100644
--- a/source/Expression/DWARFExpression.cpp
+++ b/source/Expression/DWARFExpression.cpp
@@ -1,9 +1,8 @@
//===-- DWARFExpression.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,25 +46,20 @@ ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu,
uint32_t index_size = dwarf_cu->GetAddressByteSize();
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
lldb::offset_t offset = addr_base + index * index_size;
- return dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
- &offset, index_size);
+ return dwarf_cu->GetSymbolFileDWARF()
+ .GetDWARFContext()
+ .getOrLoadAddrData()
+ .GetMaxU64(&offset, index_size);
}
-//----------------------------------------------------------------------
// DWARFExpression constructor
-//----------------------------------------------------------------------
-DWARFExpression::DWARFExpression(DWARFUnit *dwarf_cu)
- : m_module_wp(), m_data(), m_dwarf_cu(dwarf_cu),
+DWARFExpression::DWARFExpression()
+ : m_module_wp(), m_data(), m_dwarf_cu(nullptr),
m_reg_kind(eRegisterKindDWARF), m_loclist_slide(LLDB_INVALID_ADDRESS) {}
-DWARFExpression::DWARFExpression(const DWARFExpression &rhs)
- : m_module_wp(rhs.m_module_wp), m_data(rhs.m_data),
- m_dwarf_cu(rhs.m_dwarf_cu), m_reg_kind(rhs.m_reg_kind),
- m_loclist_slide(rhs.m_loclist_slide) {}
-
DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp,
const DataExtractor &data,
- DWARFUnit *dwarf_cu,
+ const DWARFUnit *dwarf_cu,
lldb::offset_t data_offset,
lldb::offset_t data_length)
: m_module_wp(), m_data(data, data_offset, data_length),
@@ -75,58 +69,21 @@ DWARFExpression::DWARFExpression(lldb::ModuleSP module_sp,
m_module_wp = module_sp;
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
DWARFExpression::~DWARFExpression() {}
bool DWARFExpression::IsValid() const { return m_data.GetByteSize() > 0; }
-void DWARFExpression::SetOpcodeData(const DataExtractor &data) {
- m_data = data;
-}
-
-void DWARFExpression::CopyOpcodeData(lldb::ModuleSP module_sp,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- lldb::offset_t data_length) {
- const uint8_t *bytes = data.PeekData(data_offset, data_length);
- if (bytes) {
- m_module_wp = module_sp;
- m_data.SetData(DataBufferSP(new DataBufferHeap(bytes, data_length)));
- m_data.SetByteOrder(data.GetByteOrder());
- m_data.SetAddressByteSize(data.GetAddressByteSize());
- }
-}
-
-void DWARFExpression::CopyOpcodeData(const void *data,
- lldb::offset_t data_length,
- ByteOrder byte_order,
- uint8_t addr_byte_size) {
- if (data && data_length) {
- m_data.SetData(DataBufferSP(new DataBufferHeap(data, data_length)));
- m_data.SetByteOrder(byte_order);
- m_data.SetAddressByteSize(addr_byte_size);
- }
-}
-
-void DWARFExpression::CopyOpcodeData(uint64_t const_value,
- lldb::offset_t const_value_byte_size,
- uint8_t addr_byte_size) {
- if (const_value_byte_size) {
- m_data.SetData(
- DataBufferSP(new DataBufferHeap(&const_value, const_value_byte_size)));
- m_data.SetByteOrder(endian::InlHostByteOrder());
- m_data.SetAddressByteSize(addr_byte_size);
- }
-}
+void DWARFExpression::UpdateValue(uint64_t const_value,
+ lldb::offset_t const_value_byte_size,
+ uint8_t addr_byte_size) {
+ if (!const_value_byte_size)
+ return;
-void DWARFExpression::SetOpcodeData(lldb::ModuleSP module_sp,
- const DataExtractor &data,
- lldb::offset_t data_offset,
- lldb::offset_t data_length) {
- m_module_wp = module_sp;
- m_data.SetData(data, data_offset, data_length);
+ m_data.SetData(
+ DataBufferSP(new DataBufferHeap(&const_value, const_value_byte_size)));
+ m_data.SetByteOrder(endian::InlHostByteOrder());
+ m_data.SetAddressByteSize(addr_byte_size);
}
void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset,
@@ -491,23 +448,6 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset,
case DW_OP_call_ref: // 0x9a DWARF3 1 4- or 8-byte offset of DIE
s->Printf("DW_OP_call_ref(0x%8.8" PRIx64 ")", m_data.GetAddress(&offset));
break;
- // case DW_OP_call_frame_cfa: s << "call_frame_cfa"; break;
- // // 0x9c DWARF3
- // case DW_OP_bit_piece: // 0x9d DWARF3 2
- // s->Printf("DW_OP_bit_piece(0x%x, 0x%x)",
- // m_data.GetULEB128(&offset), m_data.GetULEB128(&offset));
- // break;
- // case DW_OP_lo_user: s->PutCString("DW_OP_lo_user"); break;
- // // 0xe0
- // case DW_OP_hi_user: s->PutCString("DW_OP_hi_user"); break;
- // // 0xff
- // case DW_OP_APPLE_extern:
- // s->Printf("DW_OP_APPLE_extern(%" PRIu64 ")",
- // m_data.GetULEB128(&offset));
- // break;
- // case DW_OP_APPLE_array_ref:
- // s->PutCString("DW_OP_APPLE_array_ref");
- // break;
case DW_OP_form_tls_address:
s->PutCString("DW_OP_form_tls_address"); // 0x9b
break;
@@ -515,6 +455,10 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset,
s->Printf("DW_OP_GNU_addr_index(0x%" PRIx64 ")",
m_data.GetULEB128(&offset));
break;
+ case DW_OP_addrx:
+ s->Printf("DW_OP_addrx(0x%" PRIx64 ")",
+ m_data.GetULEB128(&offset));
+ break;
case DW_OP_GNU_const_index: // 0xfc
s->Printf("DW_OP_GNU_const_index(0x%" PRIx64 ")",
m_data.GetULEB128(&offset));
@@ -525,62 +469,6 @@ void DWARFExpression::DumpLocation(Stream *s, lldb::offset_t offset,
case DW_OP_APPLE_uninit:
s->PutCString("DW_OP_APPLE_uninit"); // 0xF0
break;
- // case DW_OP_APPLE_assign: // 0xF1 - pops value off and
- // assigns it to second item on stack (2nd item must have
- // assignable context)
- // s->PutCString("DW_OP_APPLE_assign");
- // break;
- // case 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)
- // s->PutCString("DW_OP_APPLE_address_of");
- // break;
- // case 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)
- // s->PutCString("DW_OP_APPLE_value_of");
- // break;
- // case DW_OP_APPLE_deref_type: // 0xF4 - gets the address of
- // the top stack item (top item must be a variable, or a clang
- // type)
- // s->PutCString("DW_OP_APPLE_deref_type");
- // break;
- // case DW_OP_APPLE_expr_local: // 0xF5 - ULEB128 expression
- // local index
- // s->Printf("DW_OP_APPLE_expr_local(%" PRIu64 ")",
- // m_data.GetULEB128(&offset));
- // break;
- // case DW_OP_APPLE_constf: // 0xF6 - 1 byte float size,
- // followed by constant float data
- // {
- // uint8_t float_length = m_data.GetU8(&offset);
- // s->Printf("DW_OP_APPLE_constf(<%u> ", float_length);
- // m_data.Dump(s, offset, eFormatHex, float_length, 1,
- // UINT32_MAX, DW_INVALID_ADDRESS, 0, 0);
- // s->PutChar(')');
- // // Consume the float data
- // m_data.GetData(&offset, float_length);
- // }
- // break;
- // case DW_OP_APPLE_scalar_cast:
- // s->Printf("DW_OP_APPLE_scalar_cast(%s)",
- // Scalar::GetValueTypeAsCString
- // ((Scalar::Type)m_data.GetU8(&offset)));
- // break;
- // case DW_OP_APPLE_clang_cast:
- // {
- // clang::Type *clang_type = (clang::Type
- // *)m_data.GetMaxU64(&offset, sizeof(void*));
- // s->Printf("DW_OP_APPLE_clang_cast(%p)", clang_type);
- // }
- // break;
- // case DW_OP_APPLE_clear:
- // s->PutCString("DW_OP_APPLE_clear");
- // break;
- // case DW_OP_APPLE_error: // 0xFF - Stops expression
- // evaluation and returns an error (no args)
- // s->PutCString("DW_OP_APPLE_error");
- // break;
}
}
}
@@ -653,7 +541,7 @@ static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
lldb::RegisterKind reg_kind,
uint32_t reg_num, Status *error_ptr,
Value &value) {
- if (reg_ctx == NULL) {
+ if (reg_ctx == nullptr) {
if (error_ptr)
error_ptr->SetErrorStringWithFormat("No register context in frame.\n");
} else {
@@ -695,52 +583,6 @@ static bool ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
return false;
}
-// bool
-// DWARFExpression::LocationListContainsLoadAddress (Process* process, const
-// Address &addr) const
-//{
-// return LocationListContainsLoadAddress(process,
-// addr.GetLoadAddress(process));
-//}
-//
-// bool
-// DWARFExpression::LocationListContainsLoadAddress (Process* process, addr_t
-// load_addr) const
-//{
-// if (load_addr == LLDB_INVALID_ADDRESS)
-// return false;
-//
-// if (IsLocationList())
-// {
-// lldb::offset_t offset = 0;
-//
-// addr_t loc_list_base_addr = m_loclist_slide.GetLoadAddress(process);
-//
-// if (loc_list_base_addr == LLDB_INVALID_ADDRESS)
-// return false;
-//
-// while (m_data.ValidOffset(offset))
-// {
-// // We need to figure out what the value is for the location.
-// addr_t lo_pc = m_data.GetAddress(&offset);
-// addr_t hi_pc = m_data.GetAddress(&offset);
-// if (lo_pc == 0 && hi_pc == 0)
-// break;
-// else
-// {
-// lo_pc += loc_list_base_addr;
-// hi_pc += loc_list_base_addr;
-//
-// if (lo_pc <= load_addr && load_addr < hi_pc)
-// return true;
-//
-// offset += m_data.GetU16(&offset);
-// }
-// }
-// }
-// return false;
-//}
-
static offset_t GetOpcodeDataSize(const DataExtractor &data,
const lldb::offset_t data_offset,
const uint8_t op) {
@@ -878,6 +720,7 @@ static offset_t GetOpcodeDataSize(const DataExtractor &data,
return 8;
// All opcodes that have a single ULEB (signed or unsigned) argument
+ case DW_OP_addrx: // 0xa1 1 ULEB128 index
case DW_OP_constu: // 0x10 1 ULEB128 constant
case DW_OP_consts: // 0x11 1 SLEB128 constant
case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend
@@ -958,7 +801,7 @@ lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr(uint32_t op_addr_idx,
return op_file_addr;
else
++curr_op_addr_idx;
- } else if (op == DW_OP_GNU_addr_index) {
+ } else if (op == DW_OP_GNU_addr_index || op == DW_OP_addrx) {
uint64_t index = m_data.GetULEB128(&offset);
if (curr_op_addr_idx == op_addr_idx) {
if (!m_dwarf_cu) {
@@ -996,12 +839,12 @@ bool DWARFExpression::Update_DW_OP_addr(lldb::addr_t file_addr) {
// for this expression
// So first we copy the data into a heap buffer
- std::unique_ptr<DataBufferHeap> head_data_ap(
+ std::unique_ptr<DataBufferHeap> head_data_up(
new DataBufferHeap(m_data.GetDataStart(), m_data.GetByteSize()));
// Make en encoder so we can write the address into the buffer using the
// correct byte order (endianness)
- DataEncoder encoder(head_data_ap->GetBytes(), head_data_ap->GetByteSize(),
+ DataEncoder encoder(head_data_up->GetBytes(), head_data_up->GetByteSize(),
m_data.GetByteOrder(), addr_byte_size);
// Replace the address in the new buffer
@@ -1010,7 +853,7 @@ bool DWARFExpression::Update_DW_OP_addr(lldb::addr_t file_addr) {
// All went well, so now we can reset the data using a shared pointer to
// the heap data so "m_data" will now correctly manage the heap data.
- m_data.SetData(DataBufferSP(head_data_ap.release()));
+ m_data.SetData(DataBufferSP(head_data_up.release()));
return true;
} else {
const offset_t op_arg_size = GetOpcodeDataSize(m_data, offset, op);
@@ -1252,7 +1095,7 @@ bool DWARFExpression::Evaluate(ExecutionContext *exe_ctx,
if (IsLocationList()) {
lldb::offset_t offset = 0;
addr_t pc;
- StackFrame *frame = NULL;
+ StackFrame *frame = nullptr;
if (reg_ctx)
pc = reg_ctx->GetPC();
else {
@@ -1313,7 +1156,7 @@ bool DWARFExpression::Evaluate(ExecutionContext *exe_ctx,
bool DWARFExpression::Evaluate(
ExecutionContext *exe_ctx, RegisterContext *reg_ctx,
lldb::ModuleSP module_sp, const DataExtractor &opcodes,
- DWARFUnit *dwarf_cu, const lldb::offset_t opcodes_offset,
+ const DWARFUnit *dwarf_cu, const lldb::offset_t opcodes_offset,
const lldb::offset_t opcodes_length, const lldb::RegisterKind reg_kind,
const Value *initial_value_ptr, const Value *object_address_ptr,
Value &result, Status *error_ptr) {
@@ -1326,14 +1169,14 @@ bool DWARFExpression::Evaluate(
}
std::vector<Value> stack;
- Process *process = NULL;
- StackFrame *frame = NULL;
+ Process *process = nullptr;
+ StackFrame *frame = nullptr;
if (exe_ctx) {
process = exe_ctx->GetProcessPtr();
frame = exe_ctx->GetFramePtr();
}
- if (reg_ctx == NULL && frame)
+ if (reg_ctx == nullptr && frame)
reg_ctx = frame->GetRegisterContext().get();
if (initial_value_ptr)
@@ -1375,10 +1218,8 @@ bool DWARFExpression::Evaluate(
}
switch (op) {
- //----------------------------------------------------------------------
// The DW_OP_addr operation has a single operand that encodes a machine
// address and whose size is the size of an address on the target machine.
- //----------------------------------------------------------------------
case DW_OP_addr:
stack.push_back(Scalar(opcodes.GetAddress(&offset)));
stack.back().SetValueType(Value::eValueTypeFileAddress);
@@ -1389,7 +1230,6 @@ bool DWARFExpression::Evaluate(
frame->CalculateTarget().get());
break;
- //----------------------------------------------------------------------
// The DW_OP_addr_sect_offset4 is used for any location expressions in
// shared libraries that have a location like:
// DW_OP_addr(0x1000)
@@ -1398,7 +1238,6 @@ bool DWARFExpression::Evaluate(
// process where shared libraries have been slid. To account for this, this
// new address type where we can store the section pointer and a 4 byte
// offset.
- //----------------------------------------------------------------------
// case DW_OP_addr_sect_offset4:
// {
// result_type = eResultTypeFileAddress;
@@ -1428,14 +1267,12 @@ bool DWARFExpression::Evaluate(
// }
// break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_deref
// OPERANDS: none
// DESCRIPTION: Pops the top stack entry and treats it as an address.
// The value retrieved from that address is pushed. The size of the data
// retrieved from the dereferenced address is the size of an address on the
// target machine.
- //----------------------------------------------------------------------
case DW_OP_deref: {
if (stack.empty()) {
if (error_ptr)
@@ -1517,7 +1354,6 @@ bool DWARFExpression::Evaluate(
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_deref_size
// OPERANDS: 1
// 1 - uint8_t that specifies the size of the data to dereference.
@@ -1530,7 +1366,6 @@ bool DWARFExpression::Evaluate(
// address on the target machine. The data retrieved is zero extended to
// the size of an address on the target machine before being pushed on the
// expression stack.
- //----------------------------------------------------------------------
case DW_OP_deref_size: {
if (stack.empty()) {
if (error_ptr)
@@ -1639,7 +1474,6 @@ bool DWARFExpression::Evaluate(
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_xderef_size
// OPERANDS: 1
// 1 - uint8_t that specifies the size of the data to dereference.
@@ -1655,12 +1489,10 @@ bool DWARFExpression::Evaluate(
// the size of an address on the target machine. The data retrieved is zero
// extended to the size of an address on the target machine before being
// pushed on the expression stack.
- //----------------------------------------------------------------------
case DW_OP_xderef_size:
if (error_ptr)
error_ptr->SetErrorString("Unimplemented opcode: DW_OP_xderef_size.");
return false;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_xderef
// OPERANDS: none
// DESCRIPTION: Provides an extended dereference mechanism. The entry at
@@ -1671,17 +1503,14 @@ bool DWARFExpression::Evaluate(
// calculation and pushed as the new stack top. The size of the data
// retrieved from the dereferenced address is the size of an address on the
// target machine.
- //----------------------------------------------------------------------
case DW_OP_xderef:
if (error_ptr)
error_ptr->SetErrorString("Unimplemented opcode: DW_OP_xderef.");
return false;
- //----------------------------------------------------------------------
// All DW_OP_constXXX opcodes have a single operand as noted below:
//
// Opcode Operand 1
- // --------------- ----------------------------------------------------
// DW_OP_const1u 1-byte unsigned integer constant DW_OP_const1s
// 1-byte signed integer constant DW_OP_const2u 2-byte unsigned integer
// constant DW_OP_const2s 2-byte signed integer constant DW_OP_const4u
@@ -1689,7 +1518,6 @@ bool DWARFExpression::Evaluate(
// constant DW_OP_const8u 8-byte unsigned integer constant DW_OP_const8s
// 8-byte signed integer constant DW_OP_constu unsigned LEB128 integer
// constant DW_OP_consts signed LEB128 integer constant
- //----------------------------------------------------------------------
case DW_OP_const1u:
stack.push_back(Scalar((uint8_t)opcodes.GetU8(&offset)));
break;
@@ -1721,11 +1549,9 @@ bool DWARFExpression::Evaluate(
stack.push_back(Scalar(opcodes.GetSLEB128(&offset)));
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_dup
// OPERANDS: none
// DESCRIPTION: duplicates the value at the top of the stack
- //----------------------------------------------------------------------
case DW_OP_dup:
if (stack.empty()) {
if (error_ptr)
@@ -1735,11 +1561,9 @@ bool DWARFExpression::Evaluate(
stack.push_back(stack.back());
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_drop
// OPERANDS: none
// DESCRIPTION: pops the value at the top of the stack
- //----------------------------------------------------------------------
case DW_OP_drop:
if (stack.empty()) {
if (error_ptr)
@@ -1749,12 +1573,10 @@ bool DWARFExpression::Evaluate(
stack.pop_back();
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_over
// OPERANDS: none
// DESCRIPTION: Duplicates the entry currently second in the stack at
// the top of the stack.
- //----------------------------------------------------------------------
case DW_OP_over:
if (stack.size() < 2) {
if (error_ptr)
@@ -1765,16 +1587,14 @@ bool DWARFExpression::Evaluate(
stack.push_back(stack[stack.size() - 2]);
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_pick
// OPERANDS: uint8_t index into the current stack
// DESCRIPTION: The stack entry with the specified index (0 through 255,
// inclusive) is pushed on the stack
- //----------------------------------------------------------------------
case DW_OP_pick: {
uint8_t pick_idx = opcodes.GetU8(&offset);
if (pick_idx < stack.size())
- stack.push_back(stack[pick_idx]);
+ stack.push_back(stack[stack.size() - 1 - pick_idx]);
else {
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
@@ -1783,13 +1603,11 @@ bool DWARFExpression::Evaluate(
}
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_swap
// OPERANDS: none
// DESCRIPTION: swaps the top two stack entries. The entry at the top
// of the stack becomes the second stack entry, and the second entry
// becomes the top of the stack
- //----------------------------------------------------------------------
case DW_OP_swap:
if (stack.size() < 2) {
if (error_ptr)
@@ -1803,14 +1621,12 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_rot
// OPERANDS: none
// DESCRIPTION: Rotates the first three stack entries. The entry at
// the top of the stack becomes the third stack entry, the second entry
// becomes the top of the stack, and the third entry becomes the second
// entry.
- //----------------------------------------------------------------------
case DW_OP_rot:
if (stack.size() < 3) {
if (error_ptr)
@@ -1826,13 +1642,11 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_abs
// OPERANDS: none
// DESCRIPTION: pops the top stack entry, interprets it as a signed
// value and pushes its absolute value. If the absolute value can not be
// represented, the result is undefined.
- //----------------------------------------------------------------------
case DW_OP_abs:
if (stack.empty()) {
if (error_ptr)
@@ -1847,12 +1661,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_and
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, performs a bitwise and
// operation on the two, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_and:
if (stack.size() < 2) {
if (error_ptr)
@@ -1867,13 +1679,11 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_div
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, divides the former second
// entry by the former top of the stack using signed division, and pushes
// the result.
- //----------------------------------------------------------------------
case DW_OP_div:
if (stack.size() < 2) {
if (error_ptr)
@@ -1899,12 +1709,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_minus
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, subtracts the former top
// of the stack from the former second entry, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_minus:
if (stack.size() < 2) {
if (error_ptr)
@@ -1919,13 +1727,11 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_mod
// OPERANDS: none
// DESCRIPTION: pops the top two stack values and pushes the result of
// the calculation: former second stack entry modulo the former top of the
// stack.
- //----------------------------------------------------------------------
case DW_OP_mod:
if (stack.size() < 2) {
if (error_ptr)
@@ -1940,12 +1746,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_mul
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, multiplies them
// together, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_mul:
if (stack.size() < 2) {
if (error_ptr)
@@ -1960,11 +1764,9 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_neg
// OPERANDS: none
// DESCRIPTION: pops the top stack entry, and pushes its negation.
- //----------------------------------------------------------------------
case DW_OP_neg:
if (stack.empty()) {
if (error_ptr)
@@ -1980,12 +1782,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_not
// OPERANDS: none
// DESCRIPTION: pops the top stack entry, and pushes its bitwise
// complement
- //----------------------------------------------------------------------
case DW_OP_not:
if (stack.empty()) {
if (error_ptr)
@@ -2001,12 +1801,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_or
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, performs a bitwise or
// operation on the two, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_or:
if (stack.size() < 2) {
if (error_ptr)
@@ -2021,12 +1819,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_plus
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, adds them together, and
// pushes the result.
- //----------------------------------------------------------------------
case DW_OP_plus:
if (stack.size() < 2) {
if (error_ptr)
@@ -2040,12 +1836,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_plus_uconst
// OPERANDS: none
// DESCRIPTION: pops the top stack entry, adds it to the unsigned LEB128
// constant operand and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_plus_uconst:
if (stack.empty()) {
if (error_ptr)
@@ -2064,13 +1858,11 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_shl
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, shifts the former
// second entry left by the number of bits specified by the former top of
// the stack, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_shl:
if (stack.size() < 2) {
if (error_ptr)
@@ -2084,13 +1876,11 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_shr
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, shifts the former second
// entry right logically (filling with zero bits) by the number of bits
// specified by the former top of the stack, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_shr:
if (stack.size() < 2) {
if (error_ptr)
@@ -2109,14 +1899,12 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_shra
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, shifts the former second
// entry right arithmetically (divide the magnitude by 2, keep the same
// sign for the result) by the number of bits specified by the former top
// of the stack, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_shra:
if (stack.size() < 2) {
if (error_ptr)
@@ -2130,12 +1918,10 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_xor
// OPERANDS: none
// DESCRIPTION: pops the top two stack entries, performs the bitwise
// exclusive-or operation on the two, and pushes the result.
- //----------------------------------------------------------------------
case DW_OP_xor:
if (stack.size() < 2) {
if (error_ptr)
@@ -2150,14 +1936,12 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_skip
// OPERANDS: int16_t
// DESCRIPTION: An unconditional branch. Its single operand is a 2-byte
// signed integer constant. The 2-byte constant is the number of bytes of
// the DWARF expression to skip forward or backward from the current
// operation, beginning after the 2-byte constant.
- //----------------------------------------------------------------------
case DW_OP_skip: {
int16_t skip_offset = (int16_t)opcodes.GetU16(&offset);
lldb::offset_t new_offset = offset + skip_offset;
@@ -2170,7 +1954,6 @@ bool DWARFExpression::Evaluate(
}
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_bra
// OPERANDS: int16_t
// DESCRIPTION: A conditional branch. Its single operand is a 2-byte
@@ -2178,7 +1961,6 @@ bool DWARFExpression::Evaluate(
// value popped is not the constant 0, the 2-byte constant operand is the
// number of bytes of the DWARF expression to skip forward or backward from
// the current operation, beginning after the 2-byte constant.
- //----------------------------------------------------------------------
case DW_OP_bra:
if (stack.empty()) {
if (error_ptr)
@@ -2203,7 +1985,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_eq
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, compares using the
@@ -2211,7 +1992,6 @@ bool DWARFExpression::Evaluate(
// STACK RESULT: push the constant value 1 onto the stack if the result
// of the operation is true or the constant value 0 if the result of the
// operation is false.
- //----------------------------------------------------------------------
case DW_OP_eq:
if (stack.size() < 2) {
if (error_ptr)
@@ -2226,7 +2006,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_ge
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, compares using the
@@ -2234,7 +2013,6 @@ bool DWARFExpression::Evaluate(
// STACK RESULT: push the constant value 1 onto the stack if the result
// of the operation is true or the constant value 0 if the result of the
// operation is false.
- //----------------------------------------------------------------------
case DW_OP_ge:
if (stack.size() < 2) {
if (error_ptr)
@@ -2249,7 +2027,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_gt
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, compares using the
@@ -2257,7 +2034,6 @@ bool DWARFExpression::Evaluate(
// STACK RESULT: push the constant value 1 onto the stack if the result
// of the operation is true or the constant value 0 if the result of the
// operation is false.
- //----------------------------------------------------------------------
case DW_OP_gt:
if (stack.size() < 2) {
if (error_ptr)
@@ -2272,7 +2048,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_le
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, compares using the
@@ -2280,7 +2055,6 @@ bool DWARFExpression::Evaluate(
// STACK RESULT: push the constant value 1 onto the stack if the result
// of the operation is true or the constant value 0 if the result of the
// operation is false.
- //----------------------------------------------------------------------
case DW_OP_le:
if (stack.size() < 2) {
if (error_ptr)
@@ -2295,7 +2069,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_lt
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, compares using the
@@ -2303,7 +2076,6 @@ bool DWARFExpression::Evaluate(
// STACK RESULT: push the constant value 1 onto the stack if the result
// of the operation is true or the constant value 0 if the result of the
// operation is false.
- //----------------------------------------------------------------------
case DW_OP_lt:
if (stack.size() < 2) {
if (error_ptr)
@@ -2318,7 +2090,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_ne
// OPERANDS: none
// DESCRIPTION: pops the top two stack values, compares using the
@@ -2326,7 +2097,6 @@ bool DWARFExpression::Evaluate(
// STACK RESULT: push the constant value 1 onto the stack if the result
// of the operation is true or the constant value 0 if the result of the
// operation is false.
- //----------------------------------------------------------------------
case DW_OP_ne:
if (stack.size() < 2) {
if (error_ptr)
@@ -2341,13 +2111,11 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_litn
// OPERANDS: none
// DESCRIPTION: encode the unsigned literal values from 0 through 31.
// STACK RESULT: push the unsigned literal constant value onto the top
// of the stack.
- //----------------------------------------------------------------------
case DW_OP_lit0:
case DW_OP_lit1:
case DW_OP_lit2:
@@ -2383,11 +2151,9 @@ bool DWARFExpression::Evaluate(
stack.push_back(Scalar((uint64_t)(op - DW_OP_lit0)));
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_regN
// OPERANDS: none
// DESCRIPTION: Push the value in register n on the top of the stack.
- //----------------------------------------------------------------------
case DW_OP_reg0:
case DW_OP_reg1:
case DW_OP_reg2:
@@ -2427,12 +2193,10 @@ bool DWARFExpression::Evaluate(
else
return false;
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_regx
// OPERANDS:
// ULEB128 literal operand that encodes the register.
// DESCRIPTION: Push the value in register on the top of the stack.
- //----------------------------------------------------------------------
case DW_OP_regx: {
reg_num = opcodes.GetULEB128(&offset);
if (ReadRegisterValueAsScalar(reg_ctx, reg_kind, reg_num, error_ptr, tmp))
@@ -2441,13 +2205,11 @@ bool DWARFExpression::Evaluate(
return false;
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_bregN
// OPERANDS:
// SLEB128 offset from register N
// DESCRIPTION: Value is in memory at the address specified by register
// N plus an offset.
- //----------------------------------------------------------------------
case DW_OP_breg0:
case DW_OP_breg1:
case DW_OP_breg2:
@@ -2492,14 +2254,12 @@ bool DWARFExpression::Evaluate(
} else
return false;
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_bregx
// OPERANDS: 2
// ULEB128 literal operand that encodes the register.
// SLEB128 offset from register N
// DESCRIPTION: Value is in memory at the address specified by register
// N plus an offset.
- //----------------------------------------------------------------------
case DW_OP_bregx: {
reg_num = opcodes.GetULEB128(&offset);
@@ -2540,16 +2300,13 @@ bool DWARFExpression::Evaluate(
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_nop
// OPERANDS: none
// DESCRIPTION: A place holder. It has no effect on the location stack
// or any of its values.
- //----------------------------------------------------------------------
case DW_OP_nop:
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_piece
// OPERANDS: 1
// ULEB128: byte size of the piece
@@ -2563,7 +2320,6 @@ bool DWARFExpression::Evaluate(
// variable partially in memory and partially in registers. DW_OP_piece
// provides a way of describing how large a part of a variable a particular
// DWARF expression refers to.
- //----------------------------------------------------------------------
case DW_OP_piece: {
const uint64_t piece_byte_size = opcodes.GetULEB128(&offset);
@@ -2740,7 +2496,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_push_object_address
// OPERANDS: none
// DESCRIPTION: Pushes the address of the object currently being
@@ -2749,7 +2504,6 @@ bool DWARFExpression::Evaluate(
// DIE or it may be a component of an array, structure, or class whose
// address has been dynamically determined by an earlier step during user
// expression evaluation.
- //----------------------------------------------------------------------
case DW_OP_push_object_address:
if (object_address_ptr)
stack.push_back(*object_address_ptr);
@@ -2761,7 +2515,6 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_call2
// OPERANDS:
// uint16_t compile unit relative offset of a DIE
@@ -2780,12 +2533,10 @@ bool DWARFExpression::Evaluate(
// may be used as parameters by the called expression and values left on
// the stack by the called expression may be used as return values by prior
// agreement between the calling and called expressions.
- //----------------------------------------------------------------------
case DW_OP_call2:
if (error_ptr)
error_ptr->SetErrorString("Unimplemented opcode DW_OP_call2.");
return false;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_call4
// OPERANDS: 1
// uint32_t compile unit relative offset of a DIE
@@ -2805,30 +2556,25 @@ bool DWARFExpression::Evaluate(
// may be used as parameters by the called expression and values left on
// the stack by the called expression may be used as return values by prior
// agreement between the calling and called expressions.
- //----------------------------------------------------------------------
case DW_OP_call4:
if (error_ptr)
error_ptr->SetErrorString("Unimplemented opcode DW_OP_call4.");
return false;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_stack_value
// OPERANDS: None
// DESCRIPTION: Specifies that the object does not exist in memory but
// rather is a constant value. The value from the top of the stack is the
// value to be used. This is the actual object value and not the location.
- //----------------------------------------------------------------------
case DW_OP_stack_value:
stack.back().SetValueType(Value::eValueTypeScalar);
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_call_frame_cfa
// OPERANDS: None
// DESCRIPTION: Specifies a DWARF expression that pushes the value of
// the canonical frame address consistent with the call frame information
// located in .debug_frame (or in the FDEs of the eh_frame section).
- //----------------------------------------------------------------------
case DW_OP_call_frame_cfa:
if (frame) {
// Note that we don't have to parse FDEs because this DWARF expression
@@ -2850,14 +2596,12 @@ bool DWARFExpression::Evaluate(
}
break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_form_tls_address (or the old pre-DWARFv3 vendor extension
// opcode, DW_OP_GNU_push_tls_address)
// OPERANDS: none
// DESCRIPTION: Pops a TLS offset from the stack, converts it to
// an address in the current thread's thread-local storage block, and
// pushes it on the stack.
- //----------------------------------------------------------------------
case DW_OP_form_tls_address:
case DW_OP_GNU_push_tls_address: {
if (stack.size() < 1) {
@@ -2902,14 +2646,13 @@ bool DWARFExpression::Evaluate(
stack.back().SetValueType(Value::eValueTypeLoadAddress);
} break;
- //----------------------------------------------------------------------
- // OPCODE: DW_OP_GNU_addr_index
+ // OPCODE: DW_OP_addrx (DW_OP_GNU_addr_index is the legacy name.)
// OPERANDS: 1
// ULEB128: index to the .debug_addr section
// DESCRIPTION: Pushes an address to the stack from the .debug_addr
// section with the base address specified by the DW_AT_addr_base attribute
// and the 0 based index is the ULEB128 encoded index.
- //----------------------------------------------------------------------
+ case DW_OP_addrx:
case DW_OP_GNU_addr_index: {
if (!dwarf_cu) {
if (error_ptr)
@@ -2918,17 +2661,11 @@ bool DWARFExpression::Evaluate(
return false;
}
uint64_t index = opcodes.GetULEB128(&offset);
- uint32_t index_size = dwarf_cu->GetAddressByteSize();
- dw_offset_t addr_base = dwarf_cu->GetAddrBase();
- lldb::offset_t offset = addr_base + index * index_size;
- uint64_t value =
- dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(
- &offset, index_size);
+ lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
stack.push_back(Scalar(value));
stack.back().SetValueType(Value::eValueTypeFileAddress);
} break;
- //----------------------------------------------------------------------
// OPCODE: DW_OP_GNU_const_index
// OPERANDS: 1
// ULEB128: index to the .debug_addr section
@@ -2936,7 +2673,6 @@ bool DWARFExpression::Evaluate(
// the stack from the .debug_addr section with the base address specified
// by the DW_AT_addr_base attribute and the 0 based index is the ULEB128
// encoded index.
- //----------------------------------------------------------------------
case DW_OP_GNU_const_index: {
if (!dwarf_cu) {
if (error_ptr)
@@ -2945,22 +2681,8 @@ bool DWARFExpression::Evaluate(
return false;
}
uint64_t index = opcodes.GetULEB128(&offset);
- uint32_t index_size = dwarf_cu->GetAddressByteSize();
- dw_offset_t addr_base = dwarf_cu->GetAddrBase();
- lldb::offset_t offset = addr_base + index * index_size;
- const DWARFDataExtractor &debug_addr =
- dwarf_cu->GetSymbolFileDWARF()->get_debug_addr_data();
- switch (index_size) {
- case 4:
- stack.push_back(Scalar(debug_addr.GetU32(&offset)));
- break;
- case 8:
- stack.push_back(Scalar(debug_addr.GetU64(&offset)));
- break;
- default:
- assert(false && "Unhandled index size");
- return false;
- }
+ lldb::addr_t value = ReadAddressFromDebugAddrSection(dwarf_cu, index);
+ stack.push_back(Scalar(value));
} break;
default:
@@ -3028,7 +2750,7 @@ bool DWARFExpression::AddressRangeForLocationListEntry(
return false;
DWARFExpression::LocationListFormat format =
- dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
+ dwarf_cu->GetSymbolFileDWARF().GetLocationListFormat();
switch (format) {
case NonLocationList:
return false;
@@ -3195,6 +2917,7 @@ static bool print_dwarf_exp_op(Stream &s, const DataExtractor &data,
case DW_OP_call_ref:
size = dwarf_ref_size;
break;
+ case DW_OP_addrx:
case DW_OP_piece:
case DW_OP_plus_uconst:
case DW_OP_regx:
@@ -3204,7 +2927,7 @@ static bool print_dwarf_exp_op(Stream &s, const DataExtractor &data,
break;
default:
s.Printf("UNKNOWN ONE-OPERAND OPCODE, #%u", opcode);
- return true;
+ return false;
}
switch (size) {
@@ -3250,7 +2973,7 @@ static bool print_dwarf_exp_op(Stream &s, const DataExtractor &data,
break;
}
- return false;
+ return true;
}
bool DWARFExpression::PrintDWARFExpression(Stream &s, const DataExtractor &data,
@@ -3289,7 +3012,7 @@ void DWARFExpression::PrintDWARFLocationList(
s.Indent();
if (cu)
s.AddressRange(start_addr + base_addr, end_addr + base_addr,
- cu->GetAddressByteSize(), NULL, ": ");
+ cu->GetAddressByteSize(), nullptr, ": ");
uint32_t loc_length = debug_loc_data.GetU16(&offset);
DataExtractor locationData(debug_loc_data, offset, loc_length);
diff --git a/source/Expression/DiagnosticManager.cpp b/source/Expression/DiagnosticManager.cpp
index a98d30339b4aa..53d85f8a6d54d 100644
--- a/source/Expression/DiagnosticManager.cpp
+++ b/source/Expression/DiagnosticManager.cpp
@@ -1,9 +1,8 @@
//===-- DiagnosticManager.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Expression/Expression.cpp b/source/Expression/Expression.cpp
index 285079a85b433..8e1ef6958cc7b 100644
--- a/source/Expression/Expression.cpp
+++ b/source/Expression/Expression.cpp
@@ -1,9 +1,8 @@
//===-- Expression.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,16 +12,18 @@
using namespace lldb_private;
-Expression::Expression(Target &target)
- : m_target_wp(target.shared_from_this()),
+Expression::Expression(Target &target, ExpressionKind kind)
+ : m_kind(kind),
+ m_target_wp(target.shared_from_this()),
m_jit_start_addr(LLDB_INVALID_ADDRESS),
m_jit_end_addr(LLDB_INVALID_ADDRESS) {
// Can't make any kind of expression without a target.
assert(m_target_wp.lock());
}
-Expression::Expression(ExecutionContextScope &exe_scope)
- : m_target_wp(exe_scope.CalculateTarget()),
+Expression::Expression(ExecutionContextScope &exe_scope, ExpressionKind kind)
+ : m_kind(kind),
+ m_target_wp(exe_scope.CalculateTarget()),
m_jit_start_addr(LLDB_INVALID_ADDRESS),
m_jit_end_addr(LLDB_INVALID_ADDRESS) {
assert(m_target_wp.lock());
diff --git a/source/Expression/ExpressionVariable.cpp b/source/Expression/ExpressionVariable.cpp
index bce9a87bfb471..97305dcf5a026 100644
--- a/source/Expression/ExpressionVariable.cpp
+++ b/source/Expression/ExpressionVariable.cpp
@@ -1,9 +1,8 @@
//===-- ExpressionVariable.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,12 +25,12 @@ uint8_t *ExpressionVariable::GetValueBytes() {
return const_cast<uint8_t *>(
m_frozen_sp->GetDataExtractor().GetDataStart());
}
- return NULL;
+ return nullptr;
}
PersistentExpressionState::~PersistentExpressionState() {}
-lldb::addr_t PersistentExpressionState::LookupSymbol(const ConstString &name) {
+lldb::addr_t PersistentExpressionState::LookupSymbol(ConstString name) {
SymbolMap::iterator si = m_symbol_map.find(name.GetCString());
if (si != m_symbol_map.end())
diff --git a/source/Expression/FunctionCaller.cpp b/source/Expression/FunctionCaller.cpp
index 97f4f51e1ff65..618c1a13212c4 100644
--- a/source/Expression/FunctionCaller.cpp
+++ b/source/Expression/FunctionCaller.cpp
@@ -1,9 +1,8 @@
//===-- FunctionCaller.cpp ---------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,17 +29,15 @@
using namespace lldb_private;
-//----------------------------------------------------------------------
// FunctionCaller constructor
-//----------------------------------------------------------------------
FunctionCaller::FunctionCaller(ExecutionContextScope &exe_scope,
const CompilerType &return_type,
const Address &functionAddress,
const ValueList &arg_value_list,
const char *name)
- : Expression(exe_scope), m_execution_unit_sp(), m_parser(),
- m_jit_module_wp(), m_name(name ? name : "<unknown>"),
- m_function_ptr(NULL), m_function_addr(functionAddress),
+ : Expression(exe_scope, eKindFunctionCaller), m_execution_unit_sp(),
+ m_parser(), m_jit_module_wp(), m_name(name ? name : "<unknown>"),
+ m_function_ptr(nullptr), m_function_addr(functionAddress),
m_function_return_type(return_type),
m_wrapper_function_name("__lldb_caller_function"),
m_wrapper_struct_name("__lldb_caller_struct"), m_wrapper_args_addrs(),
@@ -51,9 +48,7 @@ FunctionCaller::FunctionCaller(ExecutionContextScope &exe_scope,
assert(m_jit_process_wp.lock());
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
FunctionCaller::~FunctionCaller() {
lldb::ProcessSP process_sp(m_jit_process_wp.lock());
if (process_sp) {
@@ -103,7 +98,8 @@ bool FunctionCaller::WriteFunctionWrapper(
jit_file.GetFilename() = const_func_name;
jit_module_sp->SetFileSpecAndObjectName(jit_file, ConstString());
m_jit_module_wp = jit_module_sp;
- process->GetTarget().GetImages().Append(jit_module_sp);
+ process->GetTarget().GetImages().Append(jit_module_sp,
+ true /* notify */);
}
}
if (process && m_jit_start_addr)
@@ -141,7 +137,7 @@ bool FunctionCaller::WriteFunctionArguments(
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return return_value;
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
@@ -242,11 +238,11 @@ lldb::ThreadPlanSP FunctionCaller::GetThreadPlanToCallFunction(
// FIXME: Use the errors Stream for better error reporting.
Thread *thread = exe_ctx.GetThreadPtr();
- if (thread == NULL) {
+ if (thread == nullptr) {
diagnostic_manager.PutString(
eDiagnosticSeverityError,
"Can't call a function without a valid thread.");
- return NULL;
+ return nullptr;
}
// Okay, now run the function:
@@ -282,7 +278,7 @@ bool FunctionCaller::FetchFunctionResults(ExecutionContext &exe_ctx,
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return false;
lldb::ProcessSP jit_process_sp(m_jit_process_wp.lock());
@@ -329,7 +325,7 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
lldb::addr_t args_addr;
- if (args_addr_ptr != NULL)
+ if (args_addr_ptr != nullptr)
args_addr = *args_addr_ptr;
else
args_addr = LLDB_INVALID_ADDRESS;
@@ -379,7 +375,7 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
if (exe_ctx.GetProcessPtr())
exe_ctx.GetProcessPtr()->SetRunningUserExpression(false);
- if (args_addr_ptr != NULL)
+ if (args_addr_ptr != nullptr)
*args_addr_ptr = args_addr;
if (return_value != lldb::eExpressionCompleted)
@@ -387,7 +383,7 @@ lldb::ExpressionResults FunctionCaller::ExecuteFunction(
FetchFunctionResults(exe_ctx, args_addr, results);
- if (args_addr_ptr == NULL)
+ if (args_addr_ptr == nullptr)
DeallocateFunctionResults(exe_ctx, args_addr);
return lldb::eExpressionCompleted;
diff --git a/source/Expression/IRExecutionUnit.cpp b/source/Expression/IRExecutionUnit.cpp
index ec6ceeac1813f..25404ad313e12 100644
--- a/source/Expression/IRExecutionUnit.cpp
+++ b/source/Expression/IRExecutionUnit.cpp
@@ -1,9 +1,8 @@
//===-- IRExecutionUnit.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,7 +24,7 @@
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
@@ -37,14 +36,14 @@
using namespace lldb_private;
-IRExecutionUnit::IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_ap,
- std::unique_ptr<llvm::Module> &module_ap,
+IRExecutionUnit::IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_up,
+ std::unique_ptr<llvm::Module> &module_up,
ConstString &name,
const lldb::TargetSP &target_sp,
const SymbolContext &sym_ctx,
std::vector<std::string> &cpu_features)
- : IRMemoryMap(target_sp), m_context_ap(context_ap.release()),
- m_module_ap(module_ap.release()), m_module(m_module_ap.get()),
+ : IRMemoryMap(target_sp), m_context_up(context_up.release()),
+ m_module_up(module_up.release()), m_module(m_module_up.get()),
m_cpu_features(cpu_features), m_name(name), m_sym_ctx(sym_ctx),
m_did_jit(false), m_function_load_addr(LLDB_INVALID_ADDRESS),
m_function_end_load_addr(LLDB_INVALID_ADDRESS),
@@ -166,8 +165,8 @@ Status IRExecutionUnit::DisassembleFunction(Stream &stream,
ArchSpec arch(target->GetArchitecture());
- const char *plugin_name = NULL;
- const char *flavor_string = NULL;
+ const char *plugin_name = nullptr;
+ const char *flavor_string = nullptr;
lldb::DisassemblerSP disassembler_sp =
Disassembler::FindPlugin(arch, flavor_string, plugin_name);
@@ -213,7 +212,7 @@ static void ReportInlineAsmError(const llvm::SMDiagnostic &diagnostic,
}
}
-void IRExecutionUnit::ReportSymbolLookupError(const ConstString &name) {
+void IRExecutionUnit::ReportSymbolLookupError(ConstString name) {
m_failed_lookups.push_back(name);
}
@@ -252,30 +251,24 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
std::string s;
llvm::raw_string_ostream oss(s);
- m_module->print(oss, NULL);
+ m_module->print(oss, nullptr);
oss.flush();
log->Printf("Module being sent to JIT: \n%s", s.c_str());
}
- llvm::Triple triple(m_module->getTargetTriple());
- llvm::Reloc::Model relocModel;
-
- if (triple.isOSBinFormatELF()) {
- relocModel = llvm::Reloc::Static;
- } else {
- relocModel = llvm::Reloc::PIC_;
- }
-
- m_module_ap->getContext().setInlineAsmDiagnosticHandler(ReportInlineAsmError,
+ m_module_up->getContext().setInlineAsmDiagnosticHandler(ReportInlineAsmError,
&error);
- llvm::EngineBuilder builder(std::move(m_module_ap));
+ llvm::EngineBuilder builder(std::move(m_module_up));
+ llvm::Triple triple(m_module->getTargetTriple());
builder.setEngineKind(llvm::EngineKind::JIT)
.setErrorStr(&error_string)
- .setRelocationModel(relocModel)
+ .setRelocationModel(triple.isOSBinFormatMachO()
+ ? llvm::Reloc::PIC_
+ : llvm::Reloc::Static)
.setMCJITMemoryManager(
std::unique_ptr<MemoryManager>(new MemoryManager(*this)))
.setOptLevel(llvm::CodeGenOpt::Less);
@@ -290,18 +283,18 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
llvm::TargetMachine *target_machine =
builder.selectTarget(triple, mArch, mCPU, mAttrs);
- m_execution_engine_ap.reset(builder.create(target_machine));
-
- m_strip_underscore =
- (m_execution_engine_ap->getDataLayout().getGlobalPrefix() == '_');
+ m_execution_engine_up.reset(builder.create(target_machine));
- if (!m_execution_engine_ap.get()) {
+ if (!m_execution_engine_up) {
error.SetErrorToGenericError();
error.SetErrorStringWithFormat("Couldn't JIT the function: %s",
error_string.c_str());
return;
}
+ m_strip_underscore =
+ (m_execution_engine_up->getDataLayout().getGlobalPrefix() == '_');
+
class ObjectDumper : public llvm::ObjectCache {
public:
void notifyObjectCompiled(const llvm::Module *module,
@@ -324,15 +317,15 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
};
if (process_sp->GetTarget().GetEnableSaveObjects()) {
- m_object_cache_ap = llvm::make_unique<ObjectDumper>();
- m_execution_engine_ap->setObjectCache(m_object_cache_ap.get());
+ m_object_cache_up = llvm::make_unique<ObjectDumper>();
+ m_execution_engine_up->setObjectCache(m_object_cache_up.get());
}
// Make sure we see all sections, including ones that don't have
// relocations...
- m_execution_engine_ap->setProcessAllSections(true);
+ m_execution_engine_up->setProcessAllSections(true);
- m_execution_engine_ap->DisableLazyCompilation();
+ m_execution_engine_up->DisableLazyCompilation();
for (llvm::Function &function : *m_module) {
if (function.isDeclaration() || function.hasPrivateLinkage())
@@ -341,7 +334,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
const bool external =
function.hasExternalLinkage() || function.hasLinkOnceODRLinkage();
- void *fun_ptr = m_execution_engine_ap->getPointerToFunction(&function);
+ void *fun_ptr = m_execution_engine_up->getPointerToFunction(&function);
if (!error.Success()) {
// We got an error through our callback!
@@ -360,7 +353,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
}
CommitAllocations(process_sp);
- ReportAllocations(*m_execution_engine_ap);
+ ReportAllocations(*m_execution_engine_up);
// We have to do this after calling ReportAllocations because for the MCJIT,
// getGlobalValueAddress will cause the JIT to perform all relocations. That
@@ -372,7 +365,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
llvm::GlobalValue &val) {
if (val.hasExternalLinkage() && !val.isDeclaration()) {
uint64_t var_ptr_addr =
- m_execution_engine_ap->getGlobalValueAddress(val.getName().str());
+ m_execution_engine_up->getGlobalValueAddress(val.getName().str());
lldb::addr_t remote_addr = GetRemoteAddressForLocal(var_ptr_addr);
@@ -407,7 +400,7 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
bool emitNewLine = false;
- for (const ConstString &failed_lookup : m_failed_lookups) {
+ for (ConstString failed_lookup : m_failed_lookups) {
if (emitNewLine)
ss.PutCString("\n");
emitNewLine = true;
@@ -489,13 +482,13 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
}
IRExecutionUnit::~IRExecutionUnit() {
- m_module_ap.reset();
- m_execution_engine_ap.reset();
- m_context_ap.reset();
+ m_module_up.reset();
+ m_execution_engine_up.reset();
+ m_context_up.reset();
}
IRExecutionUnit::MemoryManager::MemoryManager(IRExecutionUnit &parent)
- : m_default_mm_ap(new llvm::SectionMemoryManager()), m_parent(parent) {}
+ : m_default_mm_up(new llvm::SectionMemoryManager()), m_parent(parent) {}
IRExecutionUnit::MemoryManager::~MemoryManager() {}
@@ -597,7 +590,7 @@ uint8_t *IRExecutionUnit::MemoryManager::allocateCodeSection(
llvm::StringRef SectionName) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- uint8_t *return_value = m_default_mm_ap->allocateCodeSection(
+ uint8_t *return_value = m_default_mm_up->allocateCodeSection(
Size, Alignment, SectionID, SectionName);
m_parent.m_records.push_back(AllocationRecord(
@@ -628,7 +621,7 @@ uint8_t *IRExecutionUnit::MemoryManager::allocateDataSection(
llvm::StringRef SectionName, bool IsReadOnly) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- uint8_t *return_value = m_default_mm_ap->allocateDataSection(
+ uint8_t *return_value = m_default_mm_up->allocateDataSection(
Size, Alignment, SectionID, SectionName, IsReadOnly);
uint32_t permissions = lldb::ePermissionsReadable;
@@ -656,7 +649,7 @@ uint8_t *IRExecutionUnit::MemoryManager::allocateDataSection(
}
static ConstString
-FindBestAlternateMangledName(const ConstString &demangled,
+FindBestAlternateMangledName(ConstString demangled,
const lldb::LanguageType &lang_type,
const SymbolContext &sym_ctx) {
CPlusPlusLanguage::MethodName cpp_name(demangled);
@@ -718,7 +711,7 @@ struct IRExecutionUnit::SearchSpec {
void IRExecutionUnit::CollectCandidateCNames(
std::vector<IRExecutionUnit::SearchSpec> &C_specs,
- const ConstString &name) {
+ ConstString name) {
if (m_strip_underscore && name.AsCString()[0] == '_')
C_specs.insert(C_specs.begin(), ConstString(&name.AsCString()[1]));
C_specs.push_back(SearchSpec(name));
@@ -728,7 +721,7 @@ void IRExecutionUnit::CollectCandidateCPlusPlusNames(
std::vector<IRExecutionUnit::SearchSpec> &CPP_specs,
const std::vector<SearchSpec> &C_specs, const SymbolContext &sc) {
for (const SearchSpec &C_spec : C_specs) {
- const ConstString &name = C_spec.name;
+ ConstString name = C_spec.name;
if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
Mangled mangled(name, true);
@@ -760,7 +753,7 @@ void IRExecutionUnit::CollectFallbackNames(
// but the DWARF doesn't always encode "extern C" correctly.
for (const SearchSpec &C_spec : C_specs) {
- const ConstString &name = C_spec.name;
+ ConstString name = C_spec.name;
if (CPlusPlusLanguage::IsCPPMangledName(name.GetCString())) {
Mangled mangled_name(name);
@@ -781,7 +774,9 @@ void IRExecutionUnit::CollectFallbackNames(
lldb::addr_t IRExecutionUnit::FindInSymbols(
const std::vector<IRExecutionUnit::SearchSpec> &specs,
- const lldb_private::SymbolContext &sc) {
+ const lldb_private::SymbolContext &sc,
+ bool &symbol_was_missing_weak) {
+ symbol_was_missing_weak = false;
Target *target = sc.target_sp.get();
if (!target) {
@@ -796,16 +791,26 @@ lldb::addr_t IRExecutionUnit::FindInSymbols(
std::function<bool(lldb::addr_t &, SymbolContextList &,
const lldb_private::SymbolContext &)>
- get_external_load_address = [&best_internal_load_address, target](
+ get_external_load_address = [&best_internal_load_address, target,
+ &symbol_was_missing_weak](
lldb::addr_t &load_address, SymbolContextList &sc_list,
const lldb_private::SymbolContext &sc) -> lldb::addr_t {
load_address = LLDB_INVALID_ADDRESS;
- for (size_t si = 0, se = sc_list.GetSize(); si < se; ++si) {
- SymbolContext candidate_sc;
-
- sc_list.GetContextAtIndex(si, candidate_sc);
-
+ if (sc_list.GetSize() == 0)
+ return false;
+
+ // missing_weak_symbol will be true only if we found only weak undefined
+ // references to this symbol.
+ symbol_was_missing_weak = true;
+ for (auto candidate_sc : sc_list.SymbolContexts()) {
+ // Only symbols can be weak undefined:
+ if (!candidate_sc.symbol)
+ symbol_was_missing_weak = false;
+ else if (candidate_sc.symbol->GetType() != lldb::eSymbolTypeUndefined
+ || !candidate_sc.symbol->IsWeak())
+ symbol_was_missing_weak = false;
+
const bool is_external =
(candidate_sc.function) ||
(candidate_sc.symbol && candidate_sc.symbol->IsExternal());
@@ -842,11 +847,18 @@ lldb::addr_t IRExecutionUnit::FindInSymbols(
}
}
+ // You test the address of a weak symbol against NULL to see if it is
+ // present. So we should return 0 for a missing weak symbol.
+ if (symbol_was_missing_weak) {
+ load_address = 0;
+ return true;
+ }
+
return false;
};
if (sc.module_sp) {
- sc.module_sp->FindFunctions(spec.name, NULL, spec.mask,
+ sc.module_sp->FindFunctions(spec.name, nullptr, spec.mask,
true, // include_symbols
false, // include_inlines
true, // append
@@ -909,10 +921,8 @@ IRExecutionUnit::FindInRuntimes(const std::vector<SearchSpec> &specs,
return LLDB_INVALID_ADDRESS;
}
- ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime();
-
- if (runtime) {
- for (const SearchSpec &spec : specs) {
+ for (const SearchSpec &spec : specs) {
+ for (LanguageRuntime *runtime : process_sp->GetLanguageRuntimes()) {
lldb::addr_t symbol_load_addr = runtime->LookupRuntimeSymbol(spec.name);
if (symbol_load_addr != LLDB_INVALID_ADDRESS)
@@ -939,31 +949,37 @@ lldb::addr_t IRExecutionUnit::FindInUserDefinedSymbols(
}
lldb::addr_t
-IRExecutionUnit::FindSymbol(const lldb_private::ConstString &name) {
+IRExecutionUnit::FindSymbol(lldb_private::ConstString name, bool &missing_weak) {
std::vector<SearchSpec> candidate_C_names;
std::vector<SearchSpec> candidate_CPlusPlus_names;
CollectCandidateCNames(candidate_C_names, name);
+
+ lldb::addr_t ret = FindInSymbols(candidate_C_names, m_sym_ctx, missing_weak);
+ if (ret != LLDB_INVALID_ADDRESS)
+ return ret;
+
+ // If we find the symbol in runtimes or user defined symbols it can't be
+ // a missing weak symbol.
+ missing_weak = false;
+ ret = FindInRuntimes(candidate_C_names, m_sym_ctx);
+ if (ret != LLDB_INVALID_ADDRESS)
+ return ret;
- lldb::addr_t ret = FindInSymbols(candidate_C_names, m_sym_ctx);
- if (ret == LLDB_INVALID_ADDRESS)
- ret = FindInRuntimes(candidate_C_names, m_sym_ctx);
+ ret = FindInUserDefinedSymbols(candidate_C_names, m_sym_ctx);
+ if (ret != LLDB_INVALID_ADDRESS)
+ return ret;
- if (ret == LLDB_INVALID_ADDRESS)
- ret = FindInUserDefinedSymbols(candidate_C_names, m_sym_ctx);
+ CollectCandidateCPlusPlusNames(candidate_CPlusPlus_names, candidate_C_names,
+ m_sym_ctx);
+ ret = FindInSymbols(candidate_CPlusPlus_names, m_sym_ctx, missing_weak);
+ if (ret != LLDB_INVALID_ADDRESS)
+ return ret;
- if (ret == LLDB_INVALID_ADDRESS) {
- CollectCandidateCPlusPlusNames(candidate_CPlusPlus_names, candidate_C_names,
- m_sym_ctx);
- ret = FindInSymbols(candidate_CPlusPlus_names, m_sym_ctx);
- }
+ std::vector<SearchSpec> candidate_fallback_names;
- if (ret == LLDB_INVALID_ADDRESS) {
- std::vector<SearchSpec> candidate_fallback_names;
-
- CollectFallbackNames(candidate_fallback_names, candidate_C_names);
- ret = FindInSymbols(candidate_fallback_names, m_sym_ctx);
- }
+ CollectFallbackNames(candidate_fallback_names, candidate_C_names);
+ ret = FindInSymbols(candidate_fallback_names, m_sym_ctx, missing_weak);
return ret;
}
@@ -998,13 +1014,32 @@ void IRExecutionUnit::GetStaticInitializers(
}
}
+llvm::JITSymbol
+IRExecutionUnit::MemoryManager::findSymbol(const std::string &Name) {
+ bool missing_weak = false;
+ uint64_t addr = GetSymbolAddressAndPresence(Name, missing_weak);
+ // This is a weak symbol:
+ if (missing_weak)
+ return llvm::JITSymbol(addr,
+ llvm::JITSymbolFlags::Exported | llvm::JITSymbolFlags::Weak);
+ else
+ return llvm::JITSymbol(addr, llvm::JITSymbolFlags::Exported);
+}
+
uint64_t
IRExecutionUnit::MemoryManager::getSymbolAddress(const std::string &Name) {
+ bool missing_weak = false;
+ return GetSymbolAddressAndPresence(Name, missing_weak);
+}
+
+uint64_t
+IRExecutionUnit::MemoryManager::GetSymbolAddressAndPresence(
+ const std::string &Name, bool &missing_weak) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
ConstString name_cs(Name.c_str());
- lldb::addr_t ret = m_parent.FindSymbol(name_cs);
+ lldb::addr_t ret = m_parent.FindSymbol(name_cs, missing_weak);
if (ret == LLDB_INVALID_ADDRESS) {
if (log)
@@ -1024,8 +1059,6 @@ IRExecutionUnit::MemoryManager::getSymbolAddress(const std::string &Name) {
void *IRExecutionUnit::MemoryManager::getPointerToNamedFunction(
const std::string &Name, bool AbortOnFailure) {
- assert(sizeof(void *) == 8);
-
return (void *)getSymbolAddress(Name);
}
diff --git a/source/Expression/IRInterpreter.cpp b/source/Expression/IRInterpreter.cpp
index 457eaef46dd33..5a9814d15362d 100644
--- a/source/Expression/IRInterpreter.cpp
+++ b/source/Expression/IRInterpreter.cpp
@@ -1,9 +1,8 @@
//===-- IRInterpreter.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -234,8 +233,9 @@ public:
case Value::FunctionVal:
if (const Function *constant_func = dyn_cast<Function>(constant)) {
lldb_private::ConstString name(constant_func->getName());
- lldb::addr_t addr = m_execution_unit.FindSymbol(name);
- if (addr == LLDB_INVALID_ADDRESS)
+ bool missing_weak = false;
+ lldb::addr_t addr = m_execution_unit.FindSymbol(name, missing_weak);
+ if (addr == LLDB_INVALID_ADDRESS || missing_weak)
return false;
value = APInt(m_target_data.getPointerSizeInBits(), addr);
return true;
@@ -655,7 +655,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
std::string s;
raw_string_ostream oss(s);
- module.print(oss, NULL);
+ module.print(oss, nullptr);
oss.flush();
@@ -1601,16 +1601,16 @@ bool IRInterpreter::Interpret(llvm::Module &module, llvm::Function &function,
"unable to locate host data for transfer to device");
// Create the required buffer
rawArgs[i].size = dataSize;
- rawArgs[i].data_ap.reset(new uint8_t[dataSize + 1]);
+ rawArgs[i].data_up.reset(new uint8_t[dataSize + 1]);
// Read string from host memory
- execution_unit.ReadMemory(rawArgs[i].data_ap.get(), addr, dataSize,
+ execution_unit.ReadMemory(rawArgs[i].data_up.get(), addr, dataSize,
error);
assert(!error.Fail() &&
"we have failed to read the string from memory");
// Add null terminator
- rawArgs[i].data_ap[dataSize] = '\0';
+ rawArgs[i].data_up[dataSize] = '\0';
rawArgs[i].type = lldb_private::ABI::CallArgument::HostPointer;
} else /* if ( arg_ty->isPointerTy() ) */
{
diff --git a/source/Expression/IRMemoryMap.cpp b/source/Expression/IRMemoryMap.cpp
index e4c85d6ce7271..70e62ac12b0e8 100644
--- a/source/Expression/IRMemoryMap.cpp
+++ b/source/Expression/IRMemoryMap.cpp
@@ -1,9 +1,8 @@
//===-- IRMemoryMap.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -264,7 +263,7 @@ ExecutionContextScope *IRMemoryMap::GetBestExecutionContextScope() const {
if (target_sp)
return target_sp.get();
- return NULL;
+ return nullptr;
}
IRMemoryMap::Allocation::Allocation(lldb::addr_t process_alloc,
@@ -276,7 +275,7 @@ IRMemoryMap::Allocation::Allocation(lldb::addr_t process_alloc,
m_alignment(alignment) {
switch (policy) {
default:
- assert(0 && "We cannot reach this!");
+ llvm_unreachable("Invalid AllocationPolicy");
case eAllocationPolicyHostOnly:
case eAllocationPolicyMirror:
m_data.SetByteSize(size);
diff --git a/source/Expression/LLVMUserExpression.cpp b/source/Expression/LLVMUserExpression.cpp
index edf1e69c30d85..5a1b750318c9f 100644
--- a/source/Expression/LLVMUserExpression.cpp
+++ b/source/Expression/LLVMUserExpression.cpp
@@ -1,9 +1,8 @@
//===-- LLVMUserExpression.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,7 +12,6 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
#include "lldb/Expression/Materializer.h"
@@ -43,18 +41,17 @@ LLVMUserExpression::LLVMUserExpression(ExecutionContextScope &exe_scope,
llvm::StringRef prefix,
lldb::LanguageType language,
ResultType desired_type,
- const EvaluateExpressionOptions &options)
- : UserExpression(exe_scope, expr, prefix, language, desired_type, options),
+ const EvaluateExpressionOptions &options,
+ ExpressionKind kind)
+ : UserExpression(exe_scope, expr, prefix, language, desired_type, options,
+ kind),
m_stack_frame_bottom(LLDB_INVALID_ADDRESS),
- m_stack_frame_top(LLDB_INVALID_ADDRESS),
- m_allow_cxx(false),
- m_allow_objc(false),
- m_transformed_text(),
- m_execution_unit_sp(), m_materializer_ap(), m_jit_module_wp(),
- m_enforce_valid_object(true), m_in_cplusplus_method(false),
- m_in_objectivec_method(false), m_in_static_method(false),
- m_needs_object_ptr(false), m_target(NULL), m_can_interpret(false),
- m_materialized_address(LLDB_INVALID_ADDRESS) {}
+ m_stack_frame_top(LLDB_INVALID_ADDRESS), m_allow_cxx(false),
+ m_allow_objc(false), m_transformed_text(), m_execution_unit_sp(),
+ m_materializer_up(), m_jit_module_wp(), m_enforce_valid_object(true),
+ m_in_cplusplus_method(false), m_in_objectivec_method(false),
+ m_in_static_method(false), m_needs_object_ptr(false), m_target(nullptr),
+ m_can_interpret(false), m_materialized_address(LLDB_INVALID_ADDRESS) {}
LLVMUserExpression::~LLVMUserExpression() {
if (m_target) {
@@ -116,10 +113,9 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
function_stack_bottom = m_stack_frame_bottom;
function_stack_top = m_stack_frame_top;
- IRInterpreter::Interpret(*module, *function, args,
- *m_execution_unit_sp.get(), interpreter_error,
- function_stack_bottom, function_stack_top,
- exe_ctx);
+ IRInterpreter::Interpret(*module, *function, args, *m_execution_unit_sp,
+ interpreter_error, function_stack_bottom,
+ function_stack_top, exe_ctx);
if (!interpreter_error.Success()) {
diagnostic_manager.Printf(eDiagnosticSeverityError,
@@ -185,7 +181,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
if (execution_result == lldb::eExpressionInterrupted ||
execution_result == lldb::eExpressionHitBreakpoint) {
- const char *error_desc = NULL;
+ const char *error_desc = nullptr;
if (call_plan_sp) {
lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo();
@@ -314,8 +310,8 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression(
const bool zero_memory = false;
m_materialized_address = m_execution_unit_sp->Malloc(
- m_materializer_ap->GetStructByteSize(),
- m_materializer_ap->GetStructAlignment(),
+ m_materializer_up->GetStructByteSize(),
+ m_materializer_up->GetStructAlignment(),
lldb::ePermissionsReadable | lldb::ePermissionsWritable, policy,
zero_memory, alloc_error);
@@ -355,7 +351,7 @@ bool LLVMUserExpression::PrepareToExecuteJITExpression(
Status materialize_error;
- m_dematerializer_sp = m_materializer_ap->Materialize(
+ m_dematerializer_sp = m_materializer_up->Materialize(
frame, *m_execution_unit_sp, struct_address, materialize_error);
if (!materialize_error.Success()) {
diff --git a/source/Expression/Materializer.cpp b/source/Expression/Materializer.cpp
index 4d4e5e21092c7..0f871fcbefbc6 100644
--- a/source/Expression/Materializer.cpp
+++ b/source/Expression/Materializer.cpp
@@ -1,9 +1,8 @@
//===-- Materializer.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegisterValue.h"
+#include <memory>
+
using namespace lldb_private;
uint32_t Materializer::AddStructMember(Entity &entity) {
@@ -538,7 +539,8 @@ public:
"size of variable %s (%" PRIu64
") is larger than the ValueObject's size (%" PRIu64 ")",
m_variable_sp->GetName().AsCString(),
- m_variable_sp->GetType()->GetByteSize(), data.GetByteSize());
+ m_variable_sp->GetType()->GetByteSize().getValueOr(0),
+ data.GetByteSize());
}
return;
}
@@ -560,8 +562,8 @@ public:
m_temporary_allocation_size = data.GetByteSize();
- m_original_data.reset(
- new DataBufferHeap(data.GetDataStart(), data.GetByteSize()));
+ m_original_data = std::make_shared<DataBufferHeap>(data.GetDataStart(),
+ data.GetByteSize());
if (!alloc_error.Success()) {
err.SetErrorStringWithFormat(
@@ -1215,8 +1217,8 @@ public:
return;
}
- m_register_contents.reset(new DataBufferHeap(register_data.GetDataStart(),
- register_data.GetByteSize()));
+ m_register_contents = std::make_shared<DataBufferHeap>(
+ register_data.GetDataStart(), register_data.GetByteSize());
Status write_error;
diff --git a/source/Expression/REPL.cpp b/source/Expression/REPL.cpp
index 943385bb3aac7..f4ed887729d8d 100644
--- a/source/Expression/REPL.cpp
+++ b/source/Expression/REPL.cpp
@@ -1,9 +1,8 @@
//===-- REPL.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,10 +15,11 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/CommandReturnObject.h"
-#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/AnsiTerminal.h"
+#include <memory>
+
using namespace lldb_private;
REPL::REPL(LLVMCastKind kind, Target &target) : m_target(target), m_kind(kind) {
@@ -28,12 +28,6 @@ REPL::REPL(LLVMCastKind kind, Target &target) : m_target(target), m_kind(kind) {
auto exe_ctx = debugger.GetCommandInterpreter().GetExecutionContext();
m_format_options.OptionParsingStarting(&exe_ctx);
m_varobj_options.OptionParsingStarting(&exe_ctx);
- m_command_options.OptionParsingStarting(&exe_ctx);
-
- // Default certain settings for REPL regardless of the global settings.
- m_command_options.unwind_on_error = false;
- m_command_options.ignore_breakpoints = false;
- m_command_options.debug = false;
}
REPL::~REPL() = default;
@@ -72,15 +66,15 @@ std::string REPL::GetSourcePath() {
lldb::IOHandlerSP REPL::GetIOHandler() {
if (!m_io_handler_sp) {
Debugger &debugger = m_target.GetDebugger();
- m_io_handler_sp.reset(
- new IOHandlerEditline(debugger, IOHandler::Type::REPL,
- "lldb-repl", // Name of input reader for history
- llvm::StringRef("> "), // prompt
- llvm::StringRef(". "), // Continuation prompt
- true, // Multi-line
- true, // The REPL prompt is always colored
- 1, // Line number
- *this));
+ m_io_handler_sp = std::make_shared<IOHandlerEditline>(
+ debugger, IOHandler::Type::REPL,
+ "lldb-repl", // Name of input reader for history
+ llvm::StringRef("> "), // prompt
+ llvm::StringRef(". "), // Continuation prompt
+ true, // Multi-line
+ true, // The REPL prompt is always colored
+ 1, // Line number
+ *this, nullptr);
// Don't exit if CTRL+C is pressed
static_cast<IOHandlerEditline *>(m_io_handler_sp.get())
@@ -98,7 +92,7 @@ lldb::IOHandlerSP REPL::GetIOHandler() {
return m_io_handler_sp;
}
-void REPL::IOHandlerActivated(IOHandler &io_handler) {
+void REPL::IOHandlerActivated(IOHandler &io_handler, bool interactive) {
lldb::ProcessSP process_sp = m_target.GetProcessSP();
if (process_sp && process_sp->IsAlive())
return;
@@ -275,22 +269,15 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
const bool colorize_err = error_sp->GetFile().GetIsTerminalWithColors();
- EvaluateExpressionOptions expr_options;
+ EvaluateExpressionOptions expr_options = m_expr_options;
expr_options.SetCoerceToId(m_varobj_options.use_objc);
- expr_options.SetUnwindOnError(m_command_options.unwind_on_error);
- expr_options.SetIgnoreBreakpoints(m_command_options.ignore_breakpoints);
expr_options.SetKeepInMemory(true);
expr_options.SetUseDynamic(m_varobj_options.use_dynamic);
- expr_options.SetTryAllThreads(m_command_options.try_all_threads);
expr_options.SetGenerateDebugInfo(true);
expr_options.SetREPLEnabled(true);
expr_options.SetColorizeErrors(colorize_err);
expr_options.SetPoundLine(m_repl_source_path.c_str(),
m_code.GetSize() + 1);
- if (m_command_options.timeout > 0)
- expr_options.SetTimeout(std::chrono::microseconds(m_command_options.timeout));
- else
- expr_options.SetTimeout(llvm::None);
expr_options.SetLanguage(GetLanguage());
@@ -306,7 +293,6 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
lldb::ExpressionResults execution_results =
UserExpression::Evaluate(exe_ctx, expr_options, code.c_str(),
expr_prefix, result_valobj_sp, error,
- 0, // Line offset
nullptr, // Fixed Expression
&jit_module_sp);
diff --git a/source/Expression/UserExpression.cpp b/source/Expression/UserExpression.cpp
index 34945fdcbfa19..a72e2a07599e5 100644
--- a/source/Expression/UserExpression.cpp
+++ b/source/Expression/UserExpression.cpp
@@ -1,9 +1,8 @@
//===-- UserExpression.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,12 +15,11 @@
#include <map>
#include <string>
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
#include "lldb/Expression/Materializer.h"
@@ -50,8 +48,9 @@ UserExpression::UserExpression(ExecutionContextScope &exe_scope,
llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
ResultType desired_type,
- const EvaluateExpressionOptions &options)
- : Expression(exe_scope), m_expr_text(expr), m_expr_prefix(prefix),
+ const EvaluateExpressionOptions &options,
+ ExpressionKind kind)
+ : Expression(exe_scope, kind), m_expr_text(expr), m_expr_prefix(prefix),
m_language(language), m_desired_type(desired_type), m_options(options) {}
UserExpression::~UserExpression() {}
@@ -140,11 +139,23 @@ lldb::addr_t UserExpression::GetObjectPointer(lldb::StackFrameSP frame_sp,
lldb::ExpressionResults UserExpression::Evaluate(
ExecutionContext &exe_ctx, const EvaluateExpressionOptions &options,
llvm::StringRef expr, llvm::StringRef prefix,
- lldb::ValueObjectSP &result_valobj_sp, Status &error, uint32_t line_offset,
- std::string *fixed_expression, lldb::ModuleSP *jit_module_sp_ptr) {
+ lldb::ValueObjectSP &result_valobj_sp, Status &error,
+ std::string *fixed_expression, lldb::ModuleSP *jit_module_sp_ptr,
+ ValueObject *ctx_obj) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
LIBLLDB_LOG_STEP));
+ if (ctx_obj) {
+ static unsigned const ctx_type_mask =
+ lldb::TypeFlags::eTypeIsClass | lldb::TypeFlags::eTypeIsStructUnion;
+ if (!(ctx_obj->GetTypeInfo() & ctx_type_mask)) {
+ LLDB_LOG(log, "== [UserExpression::Evaluate] Passed a context object of "
+ "an invalid type, can't run expressions.");
+ error.SetErrorString("a context object of an invalid type passed");
+ return lldb::eExpressionSetupError;
+ }
+ }
+
lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
lldb::LanguageType language = options.GetLanguage();
const ResultType desired_type = options.DoesCoerceToId()
@@ -163,7 +174,7 @@ lldb::ExpressionResults UserExpression::Evaluate(
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL || process->GetState() != lldb::eStateStopped) {
+ if (process == nullptr || process->GetState() != lldb::eStateStopped) {
if (execution_policy == eExecutionPolicyAlways) {
if (log)
log->Printf("== [UserExpression::Evaluate] Expression may not run, but "
@@ -175,7 +186,7 @@ lldb::ExpressionResults UserExpression::Evaluate(
}
}
- if (process == NULL || !process->CanJIT())
+ if (process == nullptr || !process->CanJIT())
execution_policy = eExecutionPolicyNever;
// We need to set the expression execution thread here, turns out parse can
@@ -209,7 +220,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
lldb::UserExpressionSP user_expression_sp(
target->GetUserExpressionForLanguage(expr, full_prefix, language,
- desired_type, options, error));
+ desired_type, options, ctx_obj,
+ error));
if (error.Fail()) {
if (log)
log->Printf("== [UserExpression::Evaluate] Getting expression: %s ==",
@@ -254,7 +266,8 @@ lldb::ExpressionResults UserExpression::Evaluate(
lldb::UserExpressionSP fixed_expression_sp(
target->GetUserExpressionForLanguage(fixed_expression->c_str(),
full_prefix, language,
- desired_type, options, error));
+ desired_type, options, ctx_obj,
+ error));
DiagnosticManager fixed_diagnostic_manager;
parse_success = fixed_expression_sp->Parse(
fixed_diagnostic_manager, exe_ctx, execution_policy,
@@ -362,7 +375,7 @@ lldb::ExpressionResults UserExpression::Evaluate(
return lldb::eExpressionInterrupted;
}
- if (result_valobj_sp.get() == NULL) {
+ if (result_valobj_sp.get() == nullptr) {
result_valobj_sp = ValueObjectConstResult::Create(
exe_ctx.GetBestExecutionContextScope(), error);
}
diff --git a/source/Expression/UtilityFunction.cpp b/source/Expression/UtilityFunction.cpp
index a0a1e4edfb0be..eeaeca18da868 100644
--- a/source/Expression/UtilityFunction.cpp
+++ b/source/Expression/UtilityFunction.cpp
@@ -1,9 +1,8 @@
//===-- UtilityFunction.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/UtilityFunction.h"
@@ -31,23 +29,20 @@
using namespace lldb_private;
using namespace lldb;
-//------------------------------------------------------------------
/// Constructor
///
-/// @param[in] text
+/// \param[in] text
/// The text of the function. Must be a full translation unit.
///
-/// @param[in] name
+/// \param[in] name
/// The name of the function, as used in the text.
-//------------------------------------------------------------------
UtilityFunction::UtilityFunction(ExecutionContextScope &exe_scope,
- const char *text, const char *name)
- : Expression(exe_scope), m_execution_unit_sp(), m_jit_module_wp(),
- m_function_text(ExpressionSourceCode::g_expression_prefix),
- m_function_name(name) {
- if (text && text[0])
- m_function_text.append(text);
-}
+ const char *text, const char *name,
+ ExpressionKind kind)
+ : Expression(exe_scope, kind),
+ m_execution_unit_sp(), m_jit_module_wp(),
+ m_function_text(),
+ m_function_name(name) {}
UtilityFunction::~UtilityFunction() {
lldb::ProcessSP process_sp(m_jit_process_wp.lock());
diff --git a/source/Host/common/Editline.cpp b/source/Host/common/Editline.cpp
index f7ba4b5822ff9..d3a70aeaa3267 100644
--- a/source/Host/common/Editline.cpp
+++ b/source/Host/common/Editline.cpp
@@ -1,9 +1,8 @@
//===-- Editline.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -164,7 +163,7 @@ private:
// Use static GetHistory() function to get a EditlineHistorySP to one of
// these objects
EditlineHistory(const std::string &prefix, uint32_t size, bool unique_entries)
- : m_history(NULL), m_event(), m_prefix(prefix), m_path() {
+ : m_history(nullptr), m_event(), m_prefix(prefix), m_path() {
m_history = history_winit();
history_w(m_history, &m_event, H_SETSIZE, size);
if (unique_entries)
@@ -172,23 +171,28 @@ private:
}
const char *GetHistoryFilePath() {
+ // Compute the history path lazily.
if (m_path.empty() && m_history && !m_prefix.empty()) {
- FileSpec parent_path("~/.lldb");
- FileSystem::Instance().Resolve(parent_path);
- char history_path[PATH_MAX];
- if (!llvm::sys::fs::create_directory(parent_path.GetPath())) {
- snprintf(history_path, sizeof(history_path), "~/.lldb/%s-history",
- m_prefix.c_str());
- } else {
- snprintf(history_path, sizeof(history_path), "~/%s-widehistory",
- m_prefix.c_str());
+ llvm::SmallString<128> lldb_history_file;
+ llvm::sys::path::home_directory(lldb_history_file);
+ llvm::sys::path::append(lldb_history_file, ".lldb");
+
+ // LLDB stores its history in ~/.lldb/. If for some reason this directory
+ // isn't writable or cannot be created, history won't be available.
+ if (!llvm::sys::fs::create_directory(lldb_history_file)) {
+#if LLDB_EDITLINE_USE_WCHAR
+ std::string filename = m_prefix + "-widehistory";
+#else
+ std::string filename = m_prefix + "-history";
+#endif
+ llvm::sys::path::append(lldb_history_file, filename);
+ m_path = lldb_history_file.str();
}
- auto file_spec = FileSpec(history_path);
- FileSystem::Instance().Resolve(file_spec);
- m_path = file_spec.GetPath();
}
+
if (m_path.empty())
- return NULL;
+ return nullptr;
+
return m_path.c_str();
}
@@ -198,7 +202,7 @@ public:
if (m_history) {
history_wend(m_history);
- m_history = NULL;
+ m_history = nullptr;
}
}
@@ -220,7 +224,7 @@ public:
return history_sp;
}
- bool IsValid() const { return m_history != NULL; }
+ bool IsValid() const { return m_history != nullptr; }
HistoryW *GetHistoryPtr() { return m_history; }
@@ -261,9 +265,7 @@ protected:
}
}
-//------------------------------------------------------------------
// Editline private methods
-//------------------------------------------------------------------
void Editline::SetBaseLineNumber(int line_number) {
std::stringstream line_number_stream;
@@ -512,11 +514,13 @@ int Editline::GetCharacter(EditLineGetCharType *c) {
// Read returns, immediately lock the mutex again and check if we were
// interrupted.
m_output_mutex.unlock();
- int read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL);
+ int read_count =
+ m_input_connection.Read(&ch, 1, llvm::None, status, nullptr);
m_output_mutex.lock();
if (m_editor_status == EditorStatus::Interrupted) {
while (read_count > 0 && status == lldb::eConnectionStatusSuccess)
- read_count = m_input_connection.Read(&ch, 1, llvm::None, status, NULL);
+ read_count =
+ m_input_connection.Read(&ch, 1, llvm::None, status, nullptr);
lldbassert(status == lldb::eConnectionStatusInterrupted);
return 0;
}
@@ -857,10 +861,8 @@ unsigned char Editline::BufferEndCommand(int ch) {
return CC_NEWLINE;
}
-//------------------------------------------------------------------------------
/// Prints completions and their descriptions to the given file. Only the
/// completions in the interval [start, end) are printed.
-//------------------------------------------------------------------------------
static void PrintCompletion(FILE *output_file, size_t start, size_t end,
StringList &completions, StringList &descriptions) {
// This is an 'int' because of printf.
@@ -875,10 +877,11 @@ static void PrintCompletion(FILE *output_file, size_t start, size_t end,
const char *completion_str = completions.GetStringAtIndex(i);
const char *description_str = descriptions.GetStringAtIndex(i);
- fprintf(output_file, "\n\t%-*s", max_len, completion_str);
+ if (completion_str)
+ fprintf(output_file, "\n\t%-*s", max_len, completion_str);
// Print the description if we got one.
- if (strlen(description_str))
+ if (description_str && strlen(description_str))
fprintf(output_file, " -- %s", description_str);
}
}
@@ -977,7 +980,9 @@ void Editline::ConfigureEditor(bool multiline) {
TerminalSizeChanged();
if (m_history_sp && m_history_sp->IsValid()) {
- m_history_sp->Load();
+ if (!m_history_sp->Load()) {
+ fputs("Could not load history file\n.", m_output_file);
+ }
el_wset(m_editline, EL_HIST, history, m_history_sp->GetHistoryPtr());
}
el_set(m_editline, EL_CLIENTDATA, this);
@@ -1078,7 +1083,7 @@ void Editline::ConfigureEditor(bool multiline) {
// Allow user-specific customization prior to registering bindings we
// absolutely require
- el_source(m_editline, NULL);
+ el_source(m_editline, nullptr);
// Register an internal binding that external developers shouldn't use
el_wset(m_editline, EL_ADDFN, EditLineConstString("lldb-revert-line"),
@@ -1145,9 +1150,7 @@ void Editline::ConfigureEditor(bool multiline) {
}
}
-//------------------------------------------------------------------
// Editline public methods
-//------------------------------------------------------------------
Editline *Editline::InstanceFor(EditLine *editline) {
Editline *editor;
@@ -1222,9 +1225,13 @@ void Editline::TerminalSizeChanged() {
if (m_editline != nullptr) {
el_resize(m_editline);
int columns;
- // Despite the man page claiming non-zero indicates success, it's actually
- // zero
- if (el_get(m_editline, EL_GETTC, "co", &columns) == 0) {
+ // This function is documenting as taking (const char *, void *) for the
+ // vararg part, but in reality in was consuming arguments until the first
+ // null pointer. This was fixed in libedit in April 2019
+ // <http://mail-index.netbsd.org/source-changes/2019/04/26/msg105454.html>,
+ // but we're keeping the workaround until a version with that fix is more
+ // widely available.
+ if (el_get(m_editline, EL_GETTC, "co", &columns, nullptr) == 0) {
m_terminal_width = columns;
if (m_current_line_rows != -1) {
const LineInfoW *info = el_wline(m_editline);
diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp
index 810c15588402f..c8c8d7a0d496c 100644
--- a/source/Host/common/File.cpp
+++ b/source/Host/common/File.cpp
@@ -1,9 +1,8 @@
//===-- File.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -66,11 +65,11 @@ static const char *GetStreamOpenModeFromOptions(uint32_t options) {
} else if (options & File::eOpenOptionWrite) {
return "w";
}
- return NULL;
+ return nullptr;
}
int File::kInvalidDescriptor = -1;
-FILE *File::kInvalidStream = NULL;
+FILE *File::kInvalidStream = nullptr;
File::~File() { Close(); }
@@ -179,7 +178,7 @@ Status File::Close() {
void File::Clear() {
m_stream = nullptr;
- m_descriptor = -1;
+ m_descriptor = kInvalidDescriptor;
m_options = 0;
m_own_stream = false;
m_is_interactive = m_supports_colors = m_is_real_terminal =
@@ -504,6 +503,7 @@ Status File::Read(void *buf, size_t &num_bytes, off_t &offset) {
error.SetErrorString("invalid file handle");
}
#else
+ std::lock_guard<std::mutex> guard(offset_access_mutex);
long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
SeekFromStart(offset);
error = Read(buf, num_bytes);
@@ -528,18 +528,18 @@ Status File::Read(size_t &num_bytes, off_t &offset, bool null_terminate,
num_bytes = bytes_left;
size_t num_bytes_plus_nul_char = num_bytes + (null_terminate ? 1 : 0);
- std::unique_ptr<DataBufferHeap> data_heap_ap;
- data_heap_ap.reset(new DataBufferHeap());
- data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
+ std::unique_ptr<DataBufferHeap> data_heap_up;
+ data_heap_up.reset(new DataBufferHeap());
+ data_heap_up->SetByteSize(num_bytes_plus_nul_char);
- if (data_heap_ap.get()) {
- error = Read(data_heap_ap->GetBytes(), num_bytes, offset);
+ if (data_heap_up) {
+ error = Read(data_heap_up->GetBytes(), num_bytes, offset);
if (error.Success()) {
// Make sure we read exactly what we asked for and if we got
// less, adjust the array
- if (num_bytes_plus_nul_char < data_heap_ap->GetByteSize())
- data_heap_ap->SetByteSize(num_bytes_plus_nul_char);
- data_buffer_sp.reset(data_heap_ap.release());
+ if (num_bytes_plus_nul_char < data_heap_up->GetByteSize())
+ data_heap_up->SetByteSize(num_bytes_plus_nul_char);
+ data_buffer_sp.reset(data_heap_up.release());
return error;
}
}
@@ -603,7 +603,9 @@ Status File::Write(const void *buf, size_t &num_bytes, off_t &offset) {
num_bytes = bytes_written;
}
#else
+ std::lock_guard<std::mutex> guard(offset_access_mutex);
long cur = ::lseek(m_descriptor, 0, SEEK_CUR);
+ SeekFromStart(offset);
error = Write(buf, num_bytes);
long after = ::lseek(m_descriptor, 0, SEEK_CUR);
@@ -619,9 +621,7 @@ Status File::Write(const void *buf, size_t &num_bytes, off_t &offset) {
return error;
}
-//------------------------------------------------------------------
// Print some formatted output to the stream.
-//------------------------------------------------------------------
size_t File::Printf(const char *format, ...) {
va_list args;
va_start(args, format);
@@ -630,15 +630,13 @@ size_t File::Printf(const char *format, ...) {
return result;
}
-//------------------------------------------------------------------
// Print some formatted output to the stream.
-//------------------------------------------------------------------
size_t File::PrintfVarArg(const char *format, va_list args) {
size_t result = 0;
if (DescriptorIsValid()) {
- char *s = NULL;
+ char *s = nullptr;
result = vasprintf(&s, format, args);
- if (s != NULL) {
+ if (s != nullptr) {
if (result > 0) {
size_t s_len = result;
Write(s, s_len);
diff --git a/source/Target/FileAction.cpp b/source/Host/common/FileAction.cpp
index c9cc325b5a539..3268d952bcc97 100644
--- a/source/Target/FileAction.cpp
+++ b/source/Host/common/FileAction.cpp
@@ -1,23 +1,20 @@
//===-- FileAction.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <fcntl.h>
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/PosixApi.h"
-#include "lldb/Target/FileAction.h"
#include "lldb/Utility/Stream.h"
using namespace lldb_private;
-//----------------------------------------------------------------------------
// FileAction member functions
-//----------------------------------------------------------------------------
FileAction::FileAction()
: m_action(eFileActionNone), m_fd(-1), m_arg(-1), m_file_spec() {}
diff --git a/source/Host/common/FileCache.cpp b/source/Host/common/FileCache.cpp
index 17833ef2cbb35..4bd3efda7fb0e 100644
--- a/source/Host/common/FileCache.cpp
+++ b/source/Host/common/FileCache.cpp
@@ -1,9 +1,8 @@
//===-- FileCache.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/FileSystem.cpp b/source/Host/common/FileSystem.cpp
index 7191c9db9b2e6..d5ac05bd447c4 100644
--- a/source/Host/common/FileSystem.cpp
+++ b/source/Host/common/FileSystem.cpp
@@ -1,9 +1,8 @@
//===-- FileSystem.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,9 @@
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/TildeExpressionResolver.h"
+#include "llvm/Support/Errc.h"
#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
@@ -48,6 +49,27 @@ void FileSystem::Initialize() {
InstanceImpl().emplace();
}
+void FileSystem::Initialize(FileCollector &collector) {
+ lldbassert(!InstanceImpl() && "Already initialized.");
+ InstanceImpl().emplace(collector);
+}
+
+llvm::Error FileSystem::Initialize(const FileSpec &mapping) {
+ lldbassert(!InstanceImpl() && "Already initialized.");
+
+ llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer =
+ llvm::vfs::getRealFileSystem()->getBufferForFile(mapping.GetPath());
+
+ if (!buffer)
+ return llvm::errorCodeToError(buffer.getError());
+
+ InstanceImpl().emplace(llvm::vfs::getVFSFromYAML(std::move(buffer.get()),
+ nullptr, mapping.GetPath()),
+ true);
+
+ return llvm::Error::success();
+}
+
void FileSystem::Initialize(IntrusiveRefCntPtr<vfs::FileSystem> fs) {
lldbassert(!InstanceImpl() && "Already initialized.");
InstanceImpl().emplace(fs);
@@ -220,17 +242,21 @@ void FileSystem::Resolve(SmallVectorImpl<char> &path) {
if (path.empty())
return;
- // Resolve tilde.
- SmallString<128> original_path(path.begin(), path.end());
+ // Resolve tilde in path.
+ SmallString<128> resolved(path.begin(), path.end());
StandardTildeExpressionResolver Resolver;
- Resolver.ResolveFullPath(original_path, path);
+ Resolver.ResolveFullPath(llvm::StringRef(path.begin(), path.size()),
+ resolved);
// Try making the path absolute if it exists.
- SmallString<128> absolute_path(path.begin(), path.end());
- MakeAbsolute(path);
- if (!Exists(path)) {
- path.clear();
- path.append(original_path.begin(), original_path.end());
+ SmallString<128> absolute(resolved.begin(), resolved.end());
+ MakeAbsolute(absolute);
+
+ path.clear();
+ if (Exists(absolute)) {
+ path.append(absolute.begin(), absolute.end());
+ } else {
+ path.append(resolved.begin(), resolved.end());
}
}
@@ -243,25 +269,35 @@ void FileSystem::Resolve(FileSpec &file_spec) {
Resolve(path);
// Update the FileSpec with the resolved path.
- file_spec.SetPath(path);
+ if (file_spec.GetFilename().IsEmpty())
+ file_spec.GetDirectory().SetString(path);
+ else
+ file_spec.SetPath(path);
file_spec.SetIsResolved(true);
}
std::shared_ptr<DataBufferLLVM>
FileSystem::CreateDataBuffer(const llvm::Twine &path, uint64_t size,
uint64_t offset) {
+ if (m_collector)
+ m_collector->AddFile(path);
+
const bool is_volatile = !IsLocal(path);
+ const ErrorOr<std::string> external_path = GetExternalPath(path);
+
+ if (!external_path)
+ return nullptr;
std::unique_ptr<llvm::WritableMemoryBuffer> buffer;
if (size == 0) {
auto buffer_or_error =
- llvm::WritableMemoryBuffer::getFile(path, -1, is_volatile);
+ llvm::WritableMemoryBuffer::getFile(*external_path, -1, is_volatile);
if (!buffer_or_error)
return nullptr;
buffer = std::move(*buffer_or_error);
} else {
auto buffer_or_error = llvm::WritableMemoryBuffer::getFileSlice(
- path, size, offset, is_volatile);
+ *external_path, size, offset, is_volatile);
if (!buffer_or_error)
return nullptr;
buffer = std::move(*buffer_or_error);
@@ -277,12 +313,12 @@ FileSystem::CreateDataBuffer(const FileSpec &file_spec, uint64_t size,
bool FileSystem::ResolveExecutableLocation(FileSpec &file_spec) {
// If the directory is set there's nothing to do.
- const ConstString &directory = file_spec.GetDirectory();
+ ConstString directory = file_spec.GetDirectory();
if (directory)
return false;
// We cannot look for a file if there's no file name.
- const ConstString &filename = file_spec.GetFilename();
+ ConstString filename = file_spec.GetFilename();
if (!filename)
return false;
@@ -380,25 +416,56 @@ static mode_t GetOpenMode(uint32_t permissions) {
}
Status FileSystem::Open(File &File, const FileSpec &file_spec, uint32_t options,
- uint32_t permissions) {
+ uint32_t permissions, bool should_close_fd) {
+ if (m_collector)
+ m_collector->AddFile(file_spec);
+
if (File.IsValid())
File.Close();
const int open_flags = GetOpenFlags(options);
const mode_t open_mode =
(open_flags & O_CREAT) ? GetOpenMode(permissions) : 0;
- const std::string path = file_spec.GetPath();
+
+ auto path = GetExternalPath(file_spec);
+ if (!path)
+ return Status(path.getError());
int descriptor = llvm::sys::RetryAfterSignal(
- -1, OpenWithFS, *this, path.c_str(), open_flags, open_mode);
+ -1, OpenWithFS, *this, path->c_str(), open_flags, open_mode);
Status error;
if (!File::DescriptorIsValid(descriptor)) {
File.SetDescriptor(descriptor, false);
error.SetErrorToErrno();
} else {
- File.SetDescriptor(descriptor, true);
+ File.SetDescriptor(descriptor, should_close_fd);
File.SetOptions(options);
}
return error;
}
+
+ErrorOr<std::string> FileSystem::GetExternalPath(const llvm::Twine &path) {
+ if (!m_mapped)
+ return path.str();
+
+ // If VFS mapped we know the underlying FS is a RedirectingFileSystem.
+ ErrorOr<vfs::RedirectingFileSystem::Entry *> E =
+ static_cast<vfs::RedirectingFileSystem &>(*m_fs).lookupPath(path);
+ if (!E) {
+ if (E.getError() == llvm::errc::no_such_file_or_directory) {
+ return path.str();
+ }
+ return E.getError();
+ }
+
+ auto *F = dyn_cast<vfs::RedirectingFileSystem::RedirectingFileEntry>(*E);
+ if (!F)
+ return make_error_code(llvm::errc::not_supported);
+
+ return F->getExternalContentsPath().str();
+}
+
+ErrorOr<std::string> FileSystem::GetExternalPath(const FileSpec &file_spec) {
+ return GetExternalPath(file_spec.GetPath());
+}
diff --git a/source/Host/common/GetOptInc.cpp b/source/Host/common/GetOptInc.cpp
index 1d9b31743736a..95a68c5d3c760 100644
--- a/source/Host/common/GetOptInc.cpp
+++ b/source/Host/common/GetOptInc.cpp
@@ -1,9 +1,8 @@
//===-- GetOptInc.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -98,9 +97,9 @@ static void permute_args(int panonopt_start, int panonopt_end, int opt_end,
pos += nopts;
swap = nargv[pos];
/* LINTED const cast */
- ((char **)nargv)[pos] = nargv[cstart];
+ const_cast<char **>(nargv)[pos] = nargv[cstart];
/* LINTED const cast */
- ((char **)nargv)[cstart] = swap;
+ const_cast<char **>(nargv)[cstart] = swap;
}
}
}
diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp
index 62b936aadef1a..3ba9ab7f21f36 100644
--- a/source/Host/common/Host.cpp
+++ b/source/Host/common/Host.cpp
@@ -1,9 +1,8 @@
//===-- Host.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,17 +46,16 @@
#include <csignal>
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/MonitoringProcessLauncher.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Host/ProcessLauncher.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
-#include "lldb/Target/FileAction.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/DataBufferLLVM.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
@@ -101,7 +99,7 @@ struct MonitorInfo {
static thread_result_t MonitorChildProcessThreadFunction(void *arg);
-HostThread Host::StartMonitoringChildProcess(
+llvm::Expected<HostThread> Host::StartMonitoringChildProcess(
const Host::MonitorChildProcessCallback &callback, lldb::pid_t pid,
bool monitor_signals) {
MonitorInfo *info_ptr = new MonitorInfo();
@@ -114,14 +112,12 @@ HostThread Host::StartMonitoringChildProcess(
::snprintf(thread_name, sizeof(thread_name),
"<lldb.host.wait4(pid=%" PRIu64 ")>", pid);
return ThreadLauncher::LaunchThread(
- thread_name, MonitorChildProcessThreadFunction, info_ptr, NULL);
+ thread_name, MonitorChildProcessThreadFunction, info_ptr, 0);
}
#ifndef __linux__
-//------------------------------------------------------------------
// Scoped class that will disable thread canceling when it is constructed, and
// exception safely restore the previous value it when it goes out of scope.
-//------------------------------------------------------------------
class ScopedPThreadCancelDisabler {
public:
ScopedPThreadCancelDisabler() {
@@ -223,7 +219,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) {
bool exited = false;
int signal = 0;
int exit_status = 0;
- const char *status_cstr = NULL;
+ const char *status_cstr = nullptr;
if (WIFSTOPPED(status)) {
signal = WSTOPSIG(status);
status_cstr = "STOPPED";
@@ -286,7 +282,7 @@ static thread_result_t MonitorChildProcessThreadFunction(void *arg) {
if (log)
log->Printf("%s (arg = %p) thread exiting...", __FUNCTION__, arg);
- return NULL;
+ return nullptr;
}
#endif // #if !defined (__APPLE__) && !defined (_WIN32)
@@ -397,7 +393,7 @@ const char *Host::GetSignalAsCString(int signo) {
default:
break;
}
- return NULL;
+ return nullptr;
}
#endif
@@ -466,16 +462,19 @@ Status Host::RunShellCommand(const char *command, const FileSpec &working_dir,
int *status_ptr, int *signo_ptr,
std::string *command_output_ptr,
const Timeout<std::micro> &timeout,
- bool run_in_default_shell) {
+ bool run_in_default_shell,
+ bool hide_stderr) {
return RunShellCommand(Args(command), working_dir, status_ptr, signo_ptr,
- command_output_ptr, timeout, run_in_default_shell);
+ command_output_ptr, timeout, run_in_default_shell,
+ hide_stderr);
}
Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
int *status_ptr, int *signo_ptr,
std::string *command_output_ptr,
const Timeout<std::micro> &timeout,
- bool run_in_default_shell) {
+ bool run_in_default_shell,
+ bool hide_stderr) {
Status error;
ProcessLaunchInfo launch_info;
launch_info.SetArchitecture(HostInfo::GetArchitecture());
@@ -513,16 +512,18 @@ Status Host::RunShellCommand(const Args &args, const FileSpec &working_dir,
}
FileSpec output_file_spec(output_file_path.c_str());
-
+ // Set up file descriptors.
launch_info.AppendSuppressFileAction(STDIN_FILENO, true, false);
- if (output_file_spec) {
+ if (output_file_spec)
launch_info.AppendOpenFileAction(STDOUT_FILENO, output_file_spec, false,
true);
- launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
- } else {
+ else
launch_info.AppendSuppressFileAction(STDOUT_FILENO, false, true);
+
+ if (output_file_spec && !hide_stderr)
+ launch_info.AppendDuplicateFileAction(STDOUT_FILENO, STDERR_FILENO);
+ else
launch_info.AppendSuppressFileAction(STDERR_FILENO, false, true);
- }
std::shared_ptr<ShellInfo> shell_info_sp(new ShellInfo());
const bool monitor_signals = false;
@@ -614,12 +615,6 @@ bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
#endif
-const UnixSignalsSP &Host::GetUnixSignals() {
- static const auto s_unix_signals_sp =
- UnixSignals::Create(HostInfo::GetArchitecture());
- return s_unix_signals_sp;
-}
-
std::unique_ptr<Connection> Host::CreateDefaultConnection(llvm::StringRef url) {
#if defined(_WIN32)
if (url.startswith("file://"))
diff --git a/source/Host/common/HostInfoBase.cpp b/source/Host/common/HostInfoBase.cpp
index 34c362efc9e0b..130f0eb8ac8dd 100644
--- a/source/Host/common/HostInfoBase.cpp
+++ b/source/Host/common/HostInfoBase.cpp
@@ -1,9 +1,8 @@
//===-- HostInfoBase.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,13 +31,11 @@ using namespace lldb;
using namespace lldb_private;
namespace {
-//----------------------------------------------------------------------
// The HostInfoBaseFields is a work around for windows not supporting static
// variables correctly in a thread safe way. Really each of the variables in
// HostInfoBaseFields should live in the functions in which they are used and
// each one should be static, but the work around is in place to avoid this
// restriction. Ick.
-//----------------------------------------------------------------------
struct HostInfoBaseFields {
~HostInfoBaseFields() {
@@ -215,6 +212,38 @@ ArchSpec HostInfoBase::GetAugmentedArchSpec(llvm::StringRef triple) {
return ArchSpec(normalized_triple);
}
+bool HostInfoBase::ComputePathRelativeToLibrary(FileSpec &file_spec,
+ llvm::StringRef dir) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+
+ FileSpec lldb_file_spec = GetShlibDir();
+ if (!lldb_file_spec)
+ return false;
+
+ std::string raw_path = lldb_file_spec.GetPath();
+ if (log)
+ log->Printf("HostInfo::%s() attempting to "
+ "derive the path %s relative to liblldb install path: %s",
+ __FUNCTION__, dir.data(), raw_path.c_str());
+
+ // Drop bin (windows) or lib
+ llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);
+ if (parent_path.empty()) {
+ if (log)
+ log->Printf("HostInfo::%s() failed to find liblldb within the shared "
+ "lib path",
+ __FUNCTION__);
+ return false;
+ }
+
+ raw_path = (parent_path + dir).str();
+ if (log)
+ log->Printf("HostInfo::%s() derived the path as: %s", __FUNCTION__,
+ raw_path.c_str());
+ file_spec.GetDirectory().SetString(raw_path);
+ return (bool)file_spec.GetDirectory();
+}
+
bool HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec) {
// To get paths related to LLDB we get the path to the executable that
// contains this function. On MacOSX this will be "LLDB.framework/.../LLDB".
diff --git a/source/Host/common/HostNativeThreadBase.cpp b/source/Host/common/HostNativeThreadBase.cpp
index 25c8066bb1a35..a5f876a7232af 100644
--- a/source/Host/common/HostNativeThreadBase.cpp
+++ b/source/Host/common/HostNativeThreadBase.cpp
@@ -1,9 +1,8 @@
//===-- HostNativeThreadBase.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/HostProcess.cpp b/source/Host/common/HostProcess.cpp
index 1540333215143..e180687551f8f 100644
--- a/source/Host/common/HostProcess.cpp
+++ b/source/Host/common/HostProcess.cpp
@@ -1,9 +1,8 @@
//===-- HostProcess.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,7 +32,7 @@ lldb::pid_t HostProcess::GetProcessId() const {
bool HostProcess::IsRunning() const { return m_native_process->IsRunning(); }
-HostThread
+llvm::Expected<HostThread>
HostProcess::StartMonitoring(const Host::MonitorChildProcessCallback &callback,
bool monitor_signals) {
return m_native_process->StartMonitoring(callback, monitor_signals);
diff --git a/source/Host/common/HostThread.cpp b/source/Host/common/HostThread.cpp
index 2bf6f0a933d8a..89cadce5b2068 100644
--- a/source/Host/common/HostThread.cpp
+++ b/source/Host/common/HostThread.cpp
@@ -1,9 +1,8 @@
//===-- HostThread.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/LockFileBase.cpp b/source/Host/common/LockFileBase.cpp
index a8d7881ab8963..744b1eaabb4e2 100644
--- a/source/Host/common/LockFileBase.cpp
+++ b/source/Host/common/LockFileBase.cpp
@@ -1,9 +1,8 @@
//===-- LockFileBase.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/MainLoop.cpp b/source/Host/common/MainLoop.cpp
index 39c353e6717ec..1ce09a84671c5 100644
--- a/source/Host/common/MainLoop.cpp
+++ b/source/Host/common/MainLoop.cpp
@@ -1,9 +1,8 @@
//===-- MainLoop.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -62,10 +61,12 @@ using namespace lldb_private;
static sig_atomic_t g_signal_flags[NSIG];
+#ifndef SIGNAL_POLLING_UNSUPPORTED
static void SignalHandler(int signo, siginfo_t *info, void *) {
assert(signo < NSIG);
g_signal_flags[signo] = 1;
}
+#endif
class MainLoop::RunImpl {
public:
@@ -108,8 +109,14 @@ Status MainLoop::RunImpl::Poll() {
num_events = kevent(loop.m_kqueue, in_events.data(), in_events.size(),
out_events, llvm::array_lengthof(out_events), nullptr);
- if (num_events < 0)
- return Status("kevent() failed with error %d\n", num_events);
+ if (num_events < 0) {
+ if (errno == EINTR) {
+ // in case of EINTR, let the main loop run one iteration
+ // we need to zero num_events to avoid assertions failing
+ num_events = 0;
+ } else
+ return Status(errno, eErrorTypePOSIX);
+ }
return Status();
}
@@ -138,18 +145,20 @@ MainLoop::RunImpl::RunImpl(MainLoop &loop) : loop(loop) {
}
sigset_t MainLoop::RunImpl::get_sigmask() {
-#if SIGNAL_POLLING_UNSUPPORTED
- return 0;
-#else
sigset_t sigmask;
+#if defined(_WIN32)
+ sigmask = 0;
+#elif SIGNAL_POLLING_UNSUPPORTED
+ sigemptyset(&sigmask);
+#else
int ret = pthread_sigmask(SIG_SETMASK, nullptr, &sigmask);
assert(ret == 0);
(void) ret;
for (const auto &sig : loop.m_signals)
sigdelset(&sigmask, sig.first);
- return sigmask;
#endif
+ return sigmask;
}
#ifdef __ANDROID__
@@ -381,9 +390,6 @@ Status MainLoop::Run() {
return error;
impl.ProcessEvents();
-
- if (m_terminate_request)
- return Status();
}
return Status();
}
diff --git a/source/Host/common/MonitoringProcessLauncher.cpp b/source/Host/common/MonitoringProcessLauncher.cpp
index f6f772cb36794..55e9f69a089aa 100644
--- a/source/Host/common/MonitoringProcessLauncher.cpp
+++ b/source/Host/common/MonitoringProcessLauncher.cpp
@@ -1,16 +1,15 @@
//===-- MonitoringProcessLauncher.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/MonitoringProcessLauncher.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostProcess.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Utility/Log.h"
#include "llvm/Support/FileSystem.h"
@@ -54,8 +53,12 @@ MonitoringProcessLauncher::LaunchProcess(const ProcessLaunchInfo &launch_info,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
assert(launch_info.GetMonitorProcessCallback());
- process.StartMonitoring(launch_info.GetMonitorProcessCallback(),
- launch_info.GetMonitorSignals());
+ llvm::Expected<HostThread> maybe_thread =
+ process.StartMonitoring(launch_info.GetMonitorProcessCallback(),
+ launch_info.GetMonitorSignals());
+ if (!maybe_thread)
+ error.SetErrorStringWithFormatv("failed to launch host thread: {}",
+ llvm::toString(maybe_thread.takeError()));
if (log)
log->PutCString("started monitoring child process.");
} else {
diff --git a/source/Host/common/NativeProcessProtocol.cpp b/source/Host/common/NativeProcessProtocol.cpp
index e3c81f6c147b2..90272cb8d0bc6 100644
--- a/source/Host/common/NativeProcessProtocol.cpp
+++ b/source/Host/common/NativeProcessProtocol.cpp
@@ -1,9 +1,8 @@
//===-- NativeProcessProtocol.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,7 @@
using namespace lldb;
using namespace lldb_private;
-// -----------------------------------------------------------------------------
// NativeProcessProtocol Members
-// -----------------------------------------------------------------------------
NativeProcessProtocol::NativeProcessProtocol(lldb::pid_t pid, int terminal_fd,
NativeDelegate &delegate)
diff --git a/source/Host/common/NativeRegisterContext.cpp b/source/Host/common/NativeRegisterContext.cpp
index 6e6632aa710f0..2f30d52aea639 100644
--- a/source/Host/common/NativeRegisterContext.cpp
+++ b/source/Host/common/NativeRegisterContext.cpp
@@ -1,9 +1,8 @@
//===-- NativeRegisterContext.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ using namespace lldb_private;
NativeRegisterContext::NativeRegisterContext(NativeThreadProtocol &thread)
: m_thread(thread) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
NativeRegisterContext::~NativeRegisterContext() {}
// FIXME revisit invalidation, process stop ids, etc. Right now we don't
diff --git a/source/Host/common/NativeThreadProtocol.cpp b/source/Host/common/NativeThreadProtocol.cpp
index af43683295b0b..e62b1425c891b 100644
--- a/source/Host/common/NativeThreadProtocol.cpp
+++ b/source/Host/common/NativeThreadProtocol.cpp
@@ -1,9 +1,8 @@
//===-- NativeThreadProtocol.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/NativeWatchpointList.cpp b/source/Host/common/NativeWatchpointList.cpp
index e6ef7300eb22a..c3db95fb252ed 100644
--- a/source/Host/common/NativeWatchpointList.cpp
+++ b/source/Host/common/NativeWatchpointList.cpp
@@ -1,9 +1,8 @@
//===-- NativeWatchpointList.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/OptionParser.cpp b/source/Host/common/OptionParser.cpp
index d78bf335b4087..1e76f9b8f9f14 100644
--- a/source/Host/common/OptionParser.cpp
+++ b/source/Host/common/OptionParser.cpp
@@ -1,9 +1,8 @@
//===-- source/Host/common/OptionParser.cpp ---------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,8 +27,9 @@ void OptionParser::Prepare(std::unique_lock<std::mutex> &lock) {
void OptionParser::EnableError(bool error) { opterr = error ? 1 : 0; }
-int OptionParser::Parse(int argc, char *const argv[], llvm::StringRef optstring,
- const Option *longopts, int *longindex) {
+int OptionParser::Parse(llvm::MutableArrayRef<char *> argv,
+ llvm::StringRef optstring, const Option *longopts,
+ int *longindex) {
std::vector<option> opts;
while (longopts->definition != nullptr) {
option opt;
@@ -42,7 +42,8 @@ int OptionParser::Parse(int argc, char *const argv[], llvm::StringRef optstring,
}
opts.push_back(option());
std::string opt_cstr = optstring;
- return getopt_long_only(argc, argv, opt_cstr.c_str(), &opts[0], longindex);
+ return getopt_long_only(argv.size() - 1, argv.data(), opt_cstr.c_str(),
+ &opts[0], longindex);
}
char *OptionParser::GetOptionArgument() { return optarg; }
@@ -56,11 +57,11 @@ std::string OptionParser::GetShortOptionString(struct option *long_options) {
int i = 0;
bool done = false;
while (!done) {
- if (long_options[i].name == 0 && long_options[i].has_arg == 0 &&
- long_options[i].flag == 0 && long_options[i].val == 0) {
+ if (long_options[i].name == nullptr && long_options[i].has_arg == 0 &&
+ long_options[i].flag == nullptr && long_options[i].val == 0) {
done = true;
} else {
- if (long_options[i].flag == NULL && isalpha(long_options[i].val)) {
+ if (long_options[i].flag == nullptr && isalpha(long_options[i].val)) {
s.append(1, (char)long_options[i].val);
switch (long_options[i].has_arg) {
default:
diff --git a/source/Host/common/PipeBase.cpp b/source/Host/common/PipeBase.cpp
index 632bfcb3a2e0e..2cbadf0c85f69 100644
--- a/source/Host/common/PipeBase.cpp
+++ b/source/Host/common/PipeBase.cpp
@@ -1,9 +1,8 @@
//===-- source/Host/common/PipeBase.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/ProcessLaunchInfo.cpp b/source/Host/common/ProcessLaunchInfo.cpp
index ac1eba04f0cb8..266b467639961 100644
--- a/source/Target/ProcessLaunchInfo.cpp
+++ b/source/Host/common/ProcessLaunchInfo.cpp
@@ -1,19 +1,18 @@
//===-- ProcessLaunchInfo.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <climits>
#include "lldb/Host/Config.h"
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/FileAction.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
@@ -27,9 +26,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------------
// ProcessLaunchInfo member functions
-//----------------------------------------------------------------------------
ProcessLaunchInfo::ProcessLaunchInfo()
: ProcessInfo(), m_working_dir(), m_plugin_name(), m_flags(0),
@@ -191,8 +188,13 @@ bool ProcessLaunchInfo::NoOpMonitorCallback(lldb::pid_t pid, bool exited, int si
bool ProcessLaunchInfo::MonitorProcess() const {
if (m_monitor_callback && ProcessIDIsValid()) {
+ llvm::Expected<HostThread> maybe_thread =
Host::StartMonitoringChildProcess(m_monitor_callback, GetProcessID(),
m_monitor_signals);
+ if (!maybe_thread)
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(maybe_thread.takeError()));
return true;
}
return false;
diff --git a/source/Host/common/ProcessRunLock.cpp b/source/Host/common/ProcessRunLock.cpp
index e0ba2ecfd3e9b..a931da7187665 100644
--- a/source/Host/common/ProcessRunLock.cpp
+++ b/source/Host/common/ProcessRunLock.cpp
@@ -1,9 +1,8 @@
//===-- ProcessRunLock.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,19 +12,13 @@
namespace lldb_private {
ProcessRunLock::ProcessRunLock() : m_running(false) {
- int err = ::pthread_rwlock_init(&m_rwlock, NULL);
+ int err = ::pthread_rwlock_init(&m_rwlock, nullptr);
(void)err;
- //#if LLDB_CONFIGURATION_DEBUG
- // assert(err == 0);
- //#endif
}
ProcessRunLock::~ProcessRunLock() {
int err = ::pthread_rwlock_destroy(&m_rwlock);
(void)err;
- //#if LLDB_CONFIGURATION_DEBUG
- // assert(err == 0);
- //#endif
}
bool ProcessRunLock::ReadTryLock() {
diff --git a/source/Host/common/PseudoTerminal.cpp b/source/Host/common/PseudoTerminal.cpp
index 08d4fa218968f..85e54f4d3d6a8 100644
--- a/source/Host/common/PseudoTerminal.cpp
+++ b/source/Host/common/PseudoTerminal.cpp
@@ -1,9 +1,8 @@
//===-- PseudoTerminal.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,36 +26,28 @@ int posix_openpt(int flags);
using namespace lldb_private;
-//----------------------------------------------------------------------
// Write string describing error number
-//----------------------------------------------------------------------
static void ErrnoToStr(char *error_str, size_t error_len) {
std::string strerror = llvm::sys::StrError();
::snprintf(error_str, error_len, "%s", strerror.c_str());
}
-//----------------------------------------------------------------------
// PseudoTerminal constructor
-//----------------------------------------------------------------------
PseudoTerminal::PseudoTerminal()
: m_master_fd(invalid_fd), m_slave_fd(invalid_fd) {}
-//----------------------------------------------------------------------
// Destructor
//
// The destructor will close the master and slave file descriptors if they are
// valid and ownership has not been released using the
// ReleaseMasterFileDescriptor() or the ReleaseSaveFileDescriptor() member
// functions.
-//----------------------------------------------------------------------
PseudoTerminal::~PseudoTerminal() {
CloseMasterFileDescriptor();
CloseSlaveFileDescriptor();
}
-//----------------------------------------------------------------------
// Close the master file descriptor if it is valid.
-//----------------------------------------------------------------------
void PseudoTerminal::CloseMasterFileDescriptor() {
if (m_master_fd >= 0) {
::close(m_master_fd);
@@ -64,9 +55,7 @@ void PseudoTerminal::CloseMasterFileDescriptor() {
}
}
-//----------------------------------------------------------------------
// Close the slave file descriptor if it is valid.
-//----------------------------------------------------------------------
void PseudoTerminal::CloseSlaveFileDescriptor() {
if (m_slave_fd >= 0) {
::close(m_slave_fd);
@@ -74,7 +63,6 @@ void PseudoTerminal::CloseSlaveFileDescriptor() {
}
}
-//----------------------------------------------------------------------
// Open the first available pseudo terminal with OFLAG as the permissions. The
// file descriptor is stored in this object and can be accessed with the
// MasterFileDescriptor() accessor. The ownership of the master file descriptor
@@ -86,7 +74,6 @@ void PseudoTerminal::CloseSlaveFileDescriptor() {
//
// RETURNS:
// True when successful, false indicating an error occurred.
-//----------------------------------------------------------------------
bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
size_t error_len) {
if (error_str)
@@ -125,7 +112,6 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
#endif
}
-//----------------------------------------------------------------------
// Open the slave pseudo terminal for the current master pseudo terminal. A
// master pseudo terminal should already be valid prior to calling this
// function (see OpenFirstAvailableMaster()). The file descriptor is stored
@@ -135,7 +121,6 @@ bool PseudoTerminal::OpenFirstAvailableMaster(int oflag, char *error_str,
//
// RETURNS:
// True when successful, false indicating an error occurred.
-//----------------------------------------------------------------------
bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
if (error_str)
error_str[0] = '\0';
@@ -148,7 +133,7 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
if (slave_name == nullptr)
return false;
- m_slave_fd = ::open(slave_name, oflag);
+ m_slave_fd = llvm::sys::RetryAfterSignal(-1, ::open, slave_name, oflag);
if (m_slave_fd < 0) {
if (error_str)
@@ -159,7 +144,6 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
return true;
}
-//----------------------------------------------------------------------
// Get the name of the slave pseudo terminal. A master pseudo terminal should
// already be valid prior to calling this function (see
// OpenFirstAvailableMaster()).
@@ -169,7 +153,6 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
// The name of the slave pseudo terminal as a NULL terminated C string
// that comes from static memory, so a copy of the string should be
// made as subsequent calls can change this value.
-//----------------------------------------------------------------------
const char *PseudoTerminal::GetSlaveName(char *error_str,
size_t error_len) const {
if (error_str)
@@ -189,7 +172,6 @@ const char *PseudoTerminal::GetSlaveName(char *error_str,
return slave_name;
}
-//----------------------------------------------------------------------
// Fork a child process and have its stdio routed to a pseudo terminal.
//
// In the parent process when a valid pid is returned, the master file
@@ -207,7 +189,6 @@ const char *PseudoTerminal::GetSlaveName(char *error_str,
// RETURNS:
// in the parent process: the pid of the child, or -1 if fork fails
// in the child process: zero
-//----------------------------------------------------------------------
lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
if (error_str)
error_str[0] = '\0';
@@ -266,7 +247,6 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
return pid;
}
-//----------------------------------------------------------------------
// The master file descriptor accessor. This object retains ownership of the
// master file descriptor when this accessor is used. Use
// ReleaseMasterFileDescriptor() if you wish this object to release ownership
@@ -274,23 +254,18 @@ lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
//
// Returns the master file descriptor, or -1 if the master file descriptor is
// not currently valid.
-//----------------------------------------------------------------------
int PseudoTerminal::GetMasterFileDescriptor() const { return m_master_fd; }
-//----------------------------------------------------------------------
// The slave file descriptor accessor.
//
// Returns the slave file descriptor, or -1 if the slave file descriptor is not
// currently valid.
-//----------------------------------------------------------------------
int PseudoTerminal::GetSlaveFileDescriptor() const { return m_slave_fd; }
-//----------------------------------------------------------------------
// Release 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.
-//----------------------------------------------------------------------
int PseudoTerminal::ReleaseMasterFileDescriptor() {
// Release ownership of the master pseudo terminal file descriptor without
// closing it. (the destructor for this class will close it otherwise!)
@@ -299,12 +274,10 @@ int PseudoTerminal::ReleaseMasterFileDescriptor() {
return fd;
}
-//----------------------------------------------------------------------
// 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.
-//----------------------------------------------------------------------
int PseudoTerminal::ReleaseSlaveFileDescriptor() {
// Release ownership of the slave pseudo terminal file descriptor without
// closing it (the destructor for this class will close it otherwise!)
diff --git a/source/Host/common/Socket.cpp b/source/Host/common/Socket.cpp
index 875291bc115f8..a89f1178e96c1 100644
--- a/source/Host/common/Socket.cpp
+++ b/source/Host/common/Socket.cpp
@@ -1,9 +1,8 @@
//===-- Socket.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,6 +18,9 @@
#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/WindowsError.h"
#ifndef LLDB_DISABLE_POSIX
#include "lldb/Host/posix/DomainSocket.h"
@@ -78,6 +80,31 @@ Socket::Socket(SocketProtocol protocol, bool should_close,
Socket::~Socket() { Close(); }
+llvm::Error Socket::Initialize() {
+#if defined(_WIN32)
+ auto wVersion = WINSOCK_VERSION;
+ WSADATA wsaData;
+ int err = ::WSAStartup(wVersion, &wsaData);
+ if (err == 0) {
+ if (wsaData.wVersion < wVersion) {
+ WSACleanup();
+ return llvm::make_error<llvm::StringError>(
+ "WSASock version is not expected.", llvm::inconvertibleErrorCode());
+ }
+ } else {
+ return llvm::errorCodeToError(llvm::mapWindowsError(::WSAGetLastError()));
+ }
+#endif
+
+ return llvm::Error::success();
+}
+
+void Socket::Terminate() {
+#if defined(_WIN32)
+ ::WSACleanup();
+#endif
+}
+
std::unique_ptr<Socket> Socket::Create(const SocketProtocol protocol,
bool child_processes_inherit,
Status &error) {
@@ -124,7 +151,7 @@ Status Socket::TcpConnect(llvm::StringRef host_and_port,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_COMMUNICATION));
if (log)
log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.data());
+ host_and_port.str().c_str());
Status error;
std::unique_ptr<Socket> connect_socket(
@@ -144,7 +171,7 @@ Status Socket::TcpListen(llvm::StringRef host_and_port,
Predicate<uint16_t> *predicate, int backlog) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
- log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.data());
+ log->Printf("Socket::%s (%s)", __FUNCTION__, host_and_port.str().c_str());
Status error;
std::string host_str;
@@ -184,7 +211,7 @@ Status Socket::UdpConnect(llvm::StringRef host_and_port,
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
log->Printf("Socket::%s (host/port = %s)", __FUNCTION__,
- host_and_port.data());
+ host_and_port.str().c_str());
return UDPSocket::Connect(host_and_port, child_processes_inherit, socket);
}
@@ -260,8 +287,8 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
llvm::StringRef("([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)"));
RegularExpression::Match regex_match(2);
if (g_regex.Execute(host_and_port, &regex_match)) {
- if (regex_match.GetMatchAtIndex(host_and_port.data(), 1, host_str) &&
- regex_match.GetMatchAtIndex(host_and_port.data(), 2, port_str)) {
+ if (regex_match.GetMatchAtIndex(host_and_port, 1, host_str) &&
+ regex_match.GetMatchAtIndex(host_and_port, 2, port_str)) {
// IPv6 addresses are wrapped in [] when specified with ports
if (host_str.front() == '[' && host_str.back() == ']')
host_str = host_str.substr(1, host_str.size() - 2);
@@ -275,7 +302,8 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
// port is too large
if (error_ptr)
error_ptr->SetErrorStringWithFormat(
- "invalid host:port specification: '%s'", host_and_port.data());
+ "invalid host:port specification: '%s'",
+ host_and_port.str().c_str());
return false;
}
}
@@ -284,9 +312,7 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
// integer, representing a port with an empty host.
host_str.clear();
port_str.clear();
- bool ok = false;
- port = StringConvert::ToUInt32(host_and_port.data(), UINT32_MAX, 10, &ok);
- if (ok && port < UINT16_MAX) {
+ if (to_integer(host_and_port, port, 10) && port < UINT16_MAX) {
port_str = host_and_port;
if (error_ptr)
error_ptr->Clear();
@@ -295,7 +321,7 @@ bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
if (error_ptr)
error_ptr->SetErrorStringWithFormat("invalid host:port specification: '%s'",
- host_and_port.data());
+ host_and_port.str().c_str());
return false;
}
@@ -368,8 +394,8 @@ Status Socket::Close() {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
if (log)
- log->Printf("%p Socket::Close (fd = %i)", static_cast<void *>(this),
- m_socket);
+ log->Printf("%p Socket::Close (fd = %" PRIu64 ")",
+ static_cast<void *>(this), static_cast<uint64_t>(m_socket));
#if defined(_WIN32)
bool success = !!closesocket(m_socket);
@@ -453,9 +479,11 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
if (!child_processes_inherit) {
flags |= SOCK_CLOEXEC;
}
- NativeSocket fd = ::accept4(sockfd, addr, addrlen, flags);
+ NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
+ sockfd, addr, addrlen, flags);
#else
- NativeSocket fd = ::accept(sockfd, addr, addrlen);
+ NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
+ sockfd, addr, addrlen);
#endif
if (fd == kInvalidSocketValue)
SetLastError(error);
diff --git a/source/Host/common/SocketAddress.cpp b/source/Host/common/SocketAddress.cpp
index 172cb06a5819d..882fd24558f74 100644
--- a/source/Host/common/SocketAddress.cpp
+++ b/source/Host/common/SocketAddress.cpp
@@ -1,9 +1,8 @@
//===-- SocketAddress.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -72,9 +71,7 @@ const char *inet_ntop(int af, const void *src, char *dst, socklen_t size) {
using namespace lldb_private;
-//----------------------------------------------------------------------
// SocketAddress constructor
-//----------------------------------------------------------------------
SocketAddress::SocketAddress() { Clear(); }
SocketAddress::SocketAddress(const struct sockaddr &s) { m_socket_addr.sa = s; }
@@ -95,15 +92,7 @@ SocketAddress::SocketAddress(const struct addrinfo *addr_info) {
*this = addr_info;
}
-//----------------------------------------------------------------------
-// SocketAddress copy constructor
-//----------------------------------------------------------------------
-SocketAddress::SocketAddress(const SocketAddress &rhs)
- : m_socket_addr(rhs.m_socket_addr) {}
-
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SocketAddress::~SocketAddress() {}
void SocketAddress::Clear() {
@@ -184,9 +173,7 @@ bool SocketAddress::SetPort(uint16_t port) {
return false;
}
-//----------------------------------------------------------------------
// SocketAddress assignment operator
-//----------------------------------------------------------------------
const SocketAddress &SocketAddress::operator=(const SocketAddress &rhs) {
if (this != &rhs)
m_socket_addr = rhs.m_socket_addr;
@@ -249,11 +236,11 @@ SocketAddress::GetAddressInfo(const char *hostname, const char *servname,
hints.ai_protocol = ai_protocol;
hints.ai_flags = ai_flags;
- struct addrinfo *service_info_list = NULL;
+ struct addrinfo *service_info_list = nullptr;
int err = ::getaddrinfo(hostname, servname, &hints, &service_info_list);
if (err == 0 && service_info_list) {
- for (struct addrinfo *service_ptr = service_info_list; service_ptr != NULL;
- service_ptr = service_ptr->ai_next) {
+ for (struct addrinfo *service_ptr = service_info_list;
+ service_ptr != nullptr; service_ptr = service_ptr->ai_next) {
addr_list.emplace_back(SocketAddress(service_ptr));
}
}
diff --git a/source/Host/common/StringConvert.cpp b/source/Host/common/StringConvert.cpp
index 8f4e1956fc284..8bf04f0a9ca3a 100644
--- a/source/Host/common/StringConvert.cpp
+++ b/source/Host/common/StringConvert.cpp
@@ -1,9 +1,8 @@
//===-- StringConvert.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/common/TCPSocket.cpp b/source/Host/common/TCPSocket.cpp
index 1a10336f1dfc5..58f99f7832fe2 100644
--- a/source/Host/common/TCPSocket.cpp
+++ b/source/Host/common/TCPSocket.cpp
@@ -1,9 +1,8 @@
//===-- TCPSocket.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,7 @@
#include "lldb/Utility/Log.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/raw_ostream.h"
#ifndef LLDB_DISABLE_POSIX
@@ -118,6 +118,14 @@ std::string TCPSocket::GetRemoteIPAddress() const {
return "";
}
+std::string TCPSocket::GetRemoteConnectionURI() const {
+ if (m_socket != kInvalidSocketValue) {
+ return llvm::formatv("connect://[{0}]:{1}", GetRemoteIPAddress(),
+ GetRemotePortNumber());
+ }
+ return "";
+}
+
Status TCPSocket::CreateSocket(int domain) {
Status error;
if (IsValid())
@@ -143,7 +151,7 @@ Status TCPSocket::Connect(llvm::StringRef name) {
return error;
auto addresses = lldb_private::SocketAddress::GetAddressInfo(
- host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
+ host_str.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
for (auto address : addresses) {
error = CreateSocket(address.GetFamily());
if (error.Fail())
@@ -151,8 +159,8 @@ Status TCPSocket::Connect(llvm::StringRef name) {
address.SetPort(port);
- if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(),
- address.GetLength())) {
+ if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect,
+ GetNativeSocket(), &address.sockaddr(), address.GetLength())) {
CLOSE_SOCKET(GetNativeSocket());
continue;
}
@@ -182,7 +190,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) {
if (host_str == "*")
host_str = "0.0.0.0";
auto addresses = lldb_private::SocketAddress::GetAddressInfo(
- host_str.c_str(), NULL, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
+ host_str.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
for (auto address : addresses) {
int fd = Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP,
m_child_processes_inherit, error);
diff --git a/source/Host/common/TaskPool.cpp b/source/Host/common/TaskPool.cpp
index ba1362a46f333..73f761b5cf63a 100644
--- a/source/Host/common/TaskPool.cpp
+++ b/source/Host/common/TaskPool.cpp
@@ -1,14 +1,14 @@
//===--------------------- TaskPool.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/TaskPool.h"
#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Utility/Log.h"
#include <cstdint>
#include <queue>
@@ -66,15 +66,22 @@ void TaskPoolImpl::AddTask(std::function<void()> &&task_fn) {
// Note that this detach call needs to happen with the m_tasks_mutex held.
// This prevents the thread from exiting prematurely and triggering a linux
// libc bug (https://sourceware.org/bugzilla/show_bug.cgi?id=19951).
- lldb_private::ThreadLauncher::LaunchThread("task-pool.worker", WorkerPtr,
- this, nullptr, min_stack_size)
- .Release();
+ llvm::Expected<HostThread> host_thread =
+ lldb_private::ThreadLauncher::LaunchThread(
+ "task-pool.worker", WorkerPtr, this, min_stack_size);
+ if (host_thread) {
+ host_thread->Release();
+ } else {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(host_thread.takeError()));
+ }
}
}
lldb::thread_result_t TaskPoolImpl::WorkerPtr(void *pool) {
Worker((TaskPoolImpl *)pool);
- return 0;
+ return {};
}
void TaskPoolImpl::Worker(TaskPoolImpl *pool) {
diff --git a/source/Host/common/Terminal.cpp b/source/Host/common/Terminal.cpp
index be912fbe61554..4b536b03d852b 100644
--- a/source/Host/common/Terminal.cpp
+++ b/source/Host/common/Terminal.cpp
@@ -1,9 +1,8 @@
//===-- Terminal.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -82,36 +81,30 @@ bool Terminal::SetCanonical(bool enabled) {
return false;
}
-//----------------------------------------------------------------------
// Default constructor
-//----------------------------------------------------------------------
TerminalState::TerminalState()
: m_tty(), m_tflags(-1),
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
- m_termios_ap(),
+ m_termios_up(),
#endif
m_process_group(-1) {
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
TerminalState::~TerminalState() {}
void TerminalState::Clear() {
m_tty.Clear();
m_tflags = -1;
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
- m_termios_ap.reset();
+ m_termios_up.reset();
#endif
m_process_group = -1;
}
-//----------------------------------------------------------------------
// 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.
-//----------------------------------------------------------------------
bool TerminalState::Save(int fd, bool save_process_group) {
m_tty.SetFileDescriptor(fd);
if (m_tty.IsATerminal()) {
@@ -119,11 +112,11 @@ bool TerminalState::Save(int fd, bool save_process_group) {
m_tflags = ::fcntl(fd, F_GETFL, 0);
#endif
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
- if (m_termios_ap.get() == NULL)
- m_termios_ap.reset(new struct termios);
- int err = ::tcgetattr(fd, m_termios_ap.get());
+ if (m_termios_up == nullptr)
+ m_termios_up.reset(new struct termios);
+ int err = ::tcgetattr(fd, m_termios_up.get());
if (err != 0)
- m_termios_ap.reset();
+ m_termios_up.reset();
#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
#ifndef LLDB_DISABLE_POSIX
if (save_process_group)
@@ -135,17 +128,15 @@ bool TerminalState::Save(int fd, bool save_process_group) {
m_tty.Clear();
m_tflags = -1;
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
- m_termios_ap.reset();
+ m_termios_up.reset();
#endif
m_process_group = -1;
}
return IsValid();
}
-//----------------------------------------------------------------------
// Restore the state of the TTY using the cached values from a previous call to
// Save().
-//----------------------------------------------------------------------
bool TerminalState::Restore() const {
#ifndef LLDB_DISABLE_POSIX
if (IsValid()) {
@@ -155,12 +146,12 @@ bool TerminalState::Restore() const {
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
if (TTYStateIsValid())
- tcsetattr(fd, TCSANOW, m_termios_ap.get());
+ tcsetattr(fd, TCSANOW, m_termios_up.get());
#endif // #ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
if (ProcessGroupIsValid()) {
// Save the original signal handler.
- void (*saved_sigttou_callback)(int) = NULL;
+ void (*saved_sigttou_callback)(int) = nullptr;
saved_sigttou_callback = (void (*)(int))signal(SIGTTOU, SIG_IGN);
// Set the process group
tcsetpgrp(fd, m_process_group);
@@ -173,60 +164,44 @@ bool TerminalState::Restore() const {
return false;
}
-//----------------------------------------------------------------------
// Returns true if this object has valid saved TTY state settings that can be
// used to restore a previous state.
-//----------------------------------------------------------------------
bool TerminalState::IsValid() const {
return m_tty.FileDescriptorIsValid() &&
(TFlagsIsValid() || TTYStateIsValid());
}
-//----------------------------------------------------------------------
// Returns true if m_tflags is valid
-//----------------------------------------------------------------------
bool TerminalState::TFlagsIsValid() const { return m_tflags != -1; }
-//----------------------------------------------------------------------
// Returns true if m_ttystate is valid
-//----------------------------------------------------------------------
bool TerminalState::TTYStateIsValid() const {
#ifdef LLDB_CONFIG_TERMIOS_SUPPORTED
- return m_termios_ap.get() != 0;
+ return m_termios_up != nullptr;
#else
return false;
#endif
}
-//----------------------------------------------------------------------
// Returns true if m_process_group is valid
-//----------------------------------------------------------------------
bool TerminalState::ProcessGroupIsValid() const {
return static_cast<int32_t>(m_process_group) != -1;
}
-//------------------------------------------------------------------
// Constructor
-//------------------------------------------------------------------
TerminalStateSwitcher::TerminalStateSwitcher() : m_currentState(UINT32_MAX) {}
-//------------------------------------------------------------------
// Destructor
-//------------------------------------------------------------------
TerminalStateSwitcher::~TerminalStateSwitcher() {}
-//------------------------------------------------------------------
// Returns the number of states that this switcher contains
-//------------------------------------------------------------------
uint32_t TerminalStateSwitcher::GetNumberOfStates() const {
return llvm::array_lengthof(m_ttystates);
}
-//------------------------------------------------------------------
// Restore the state at index "idx".
//
// Returns true if the restore was successful, false otherwise.
-//------------------------------------------------------------------
bool TerminalStateSwitcher::Restore(uint32_t idx) const {
const uint32_t num_states = GetNumberOfStates();
if (idx >= num_states)
@@ -248,12 +223,10 @@ bool TerminalStateSwitcher::Restore(uint32_t idx) const {
return false;
}
-//------------------------------------------------------------------
// Save the state at index "idx" for file descriptor "fd" and save the process
// group if requested.
//
// Returns true if the restore was successful, false otherwise.
-//------------------------------------------------------------------
bool TerminalStateSwitcher::Save(uint32_t idx, int fd,
bool save_process_group) {
const uint32_t num_states = GetNumberOfStates();
diff --git a/source/Host/common/ThreadLauncher.cpp b/source/Host/common/ThreadLauncher.cpp
index f3401016393f3..6e3c8b6a13a46 100644
--- a/source/Host/common/ThreadLauncher.cpp
+++ b/source/Host/common/ThreadLauncher.cpp
@@ -1,10 +1,8 @@
-//===-- ThreadLauncher.cpp ---------------------------------------*- C++
-//-*-===//
+//===-- ThreadLauncher.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,18 +16,14 @@
#include "lldb/Host/windows/windows.h"
#endif
+#include "llvm/Support/WindowsError.h"
+
using namespace lldb;
using namespace lldb_private;
-HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
- lldb::thread_func_t thread_function,
- lldb::thread_arg_t thread_arg,
- Status *error_ptr,
- size_t min_stack_byte_size) {
- Status error;
- if (error_ptr)
- error_ptr->Clear();
-
+llvm::Expected<HostThread> ThreadLauncher::LaunchThread(
+ llvm::StringRef name, lldb::thread_func_t thread_function,
+ lldb::thread_arg_t thread_arg, size_t min_stack_byte_size) {
// Host::ThreadCreateTrampoline will delete this pointer for us.
HostThreadCreateInfo *info_ptr =
new HostThreadCreateInfo(name.data(), thread_function, thread_arg);
@@ -38,8 +32,8 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
thread = (lldb::thread_t)::_beginthreadex(
0, (unsigned)min_stack_byte_size,
HostNativeThread::ThreadCreateTrampoline, info_ptr, 0, NULL);
- if (thread == (lldb::thread_t)(-1L))
- error.SetError(::GetLastError(), eErrorTypeWin32);
+ if (thread == LLDB_INVALID_HOST_THREAD)
+ return llvm::errorCodeToError(llvm::mapWindowsError(GetLastError()));
#else
// ASAN instrumentation adds a lot of bookkeeping overhead on stack frames.
@@ -50,7 +44,7 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
}
#endif
- pthread_attr_t *thread_attr_ptr = NULL;
+ pthread_attr_t *thread_attr_ptr = nullptr;
pthread_attr_t thread_attr;
bool destroy_attr = false;
if (min_stack_byte_size > 0) {
@@ -74,12 +68,10 @@ HostThread ThreadLauncher::LaunchThread(llvm::StringRef name,
if (destroy_attr)
::pthread_attr_destroy(&thread_attr);
- error.SetError(err, eErrorTypePOSIX);
+ if (err)
+ return llvm::errorCodeToError(
+ std::error_code(err, std::generic_category()));
#endif
- if (error_ptr)
- *error_ptr = error;
- if (!error.Success())
- thread = LLDB_INVALID_HOST_THREAD;
return HostThread(thread);
}
diff --git a/source/Host/common/UDPSocket.cpp b/source/Host/common/UDPSocket.cpp
index 96bcc6a150a9e..8dbf57d6fe4ec 100644
--- a/source/Host/common/UDPSocket.cpp
+++ b/source/Host/common/UDPSocket.cpp
@@ -1,9 +1,8 @@
//===-- UDPSocket.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -135,3 +134,11 @@ Status UDPSocket::Connect(llvm::StringRef name, bool child_processes_inherit,
error.Clear();
return error;
}
+
+std::string UDPSocket::GetRemoteConnectionURI() const {
+ if (m_socket != kInvalidSocketValue) {
+ return llvm::formatv("udp://[{0}]:{1}", m_sockaddr.GetIPAddress(),
+ m_sockaddr.GetPort());
+ }
+ return "";
+}
diff --git a/source/Host/common/XML.cpp b/source/Host/common/XML.cpp
index 967a294cbf72f..cb23ac17ef53b 100644
--- a/source/Host/common/XML.cpp
+++ b/source/Host/common/XML.cpp
@@ -1,9 +1,8 @@
//===-- XML.cpp -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -135,7 +134,7 @@ XMLNode XMLNode::GetChild() const {
llvm::StringRef XMLNode::GetAttributeValue(const char *name,
const char *fail_value) const {
- const char *attr_value = NULL;
+ const char *attr_value = nullptr;
#if defined(LIBXML2_DEFINED)
if (IsValid())
diff --git a/source/Host/freebsd/Host.cpp b/source/Host/freebsd/Host.cpp
index 7bf959aee9825..99d728d63bc04 100644
--- a/source/Host/freebsd/Host.cpp
+++ b/source/Host/freebsd/Host.cpp
@@ -1,10 +1,9 @@
//===-- source/Host/freebsd/Host.cpp ------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,12 +23,12 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Process.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
@@ -39,6 +38,10 @@ extern "C" {
extern char **environ;
}
+namespace lldb_private {
+class ProcessLaunchInfo;
+}
+
using namespace lldb;
using namespace lldb_private;
diff --git a/source/Host/freebsd/HostInfoFreeBSD.cpp b/source/Host/freebsd/HostInfoFreeBSD.cpp
index d123936b3668a..e28cf4aa420fd 100644
--- a/source/Host/freebsd/HostInfoFreeBSD.cpp
+++ b/source/Host/freebsd/HostInfoFreeBSD.cpp
@@ -1,9 +1,8 @@
//===-- HostInfoFreeBSD.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/netbsd/Host.cpp b/source/Host/netbsd/Host.cpp
index 4d50363c72e08..08fec099bf492 100644
--- a/source/Host/netbsd/Host.cpp
+++ b/source/Host/netbsd/Host.cpp
@@ -1,9 +1,8 @@
//===-- source/Host/netbsd/Host.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,12 +22,12 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Process.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
@@ -41,6 +40,10 @@ extern char **environ;
using namespace lldb;
using namespace lldb_private;
+namespace lldb_private {
+class ProcessLaunchInfo;
+}
+
Environment Host::GetEnvironment() { return Environment(environ); }
static bool GetNetBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
diff --git a/source/Host/netbsd/HostInfoNetBSD.cpp b/source/Host/netbsd/HostInfoNetBSD.cpp
index a54483fcc55b6..99d4139223276 100644
--- a/source/Host/netbsd/HostInfoNetBSD.cpp
+++ b/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -1,9 +1,8 @@
//===-- HostInfoNetBSD.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Host/openbsd/Host.cpp b/source/Host/openbsd/Host.cpp
index cba1f4ee6b7cb..ba6cf057ca171 100644
--- a/source/Host/openbsd/Host.cpp
+++ b/source/Host/openbsd/Host.cpp
@@ -1,9 +1,8 @@
//===-- source/Host/openbsd/Host.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,12 +19,12 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/Process.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
@@ -38,6 +37,10 @@ extern char **environ;
using namespace lldb;
using namespace lldb_private;
+namespace lldb_private {
+class ProcessLaunchInfo;
+}
+
Environment Host::GetEnvironment() {
Environment env;
char *v;
@@ -68,8 +71,7 @@ GetOpenBSDProcessArgs(const ProcessInstanceInfoMatch *match_info_ptr,
cstr = data.GetCStr(&offset);
if (cstr) {
- process_info.GetExecutableFile().SetFile(cstr, false,
- FileSpec::Style::native);
+ process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native);
if (!(match_info_ptr == NULL ||
NameMatches(
diff --git a/source/Host/openbsd/HostInfoOpenBSD.cpp b/source/Host/openbsd/HostInfoOpenBSD.cpp
index 548958899322c..950f2ebb86b83 100644
--- a/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -1,9 +1,8 @@
//===-- HostInfoOpenBSD.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,16 +16,17 @@
using namespace lldb_private;
-bool HostInfoOpenBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
- uint32_t &update) {
+llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
struct utsname un;
::memset(&un, 0, sizeof(utsname));
if (uname(&un) < 0)
- return false;
+ return llvm::VersionTuple();
- int status = sscanf(un.release, "%u.%u", &major, &minor);
- return status == 2;
+ unsigned major, minor;
+ if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+ return llvm::VersionTuple(major, minor);
+ return llvm::VersionTuple();
}
bool HostInfoOpenBSD::GetOSBuildString(std::string &s) {
diff --git a/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index deac3844d4a27..067e85972ecac 100644
--- a/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -1,9 +1,8 @@
//===-- ConnectionFileDescriptorPosix.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,6 +31,7 @@
#include <unistd.h>
#endif
+#include <memory>
#include <sstream>
#include "llvm/Support/Errno.h"
@@ -87,8 +87,8 @@ ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
ConnectionFileDescriptor::ConnectionFileDescriptor(int fd, bool owns_fd)
: Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
m_waiting_for_accept(false), m_child_processes_inherit(false) {
- m_write_sp.reset(new File(fd, owns_fd));
- m_read_sp.reset(new File(fd, false));
+ m_write_sp = std::make_shared<File>(fd, owns_fd);
+ m_read_sp = std::make_shared<File>(fd, false);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION |
LIBLLDB_LOG_OBJECT));
@@ -111,7 +111,7 @@ ConnectionFileDescriptor::~ConnectionFileDescriptor() {
if (log)
log->Printf("%p ConnectionFileDescriptor::~ConnectionFileDescriptor ()",
static_cast<void *>(this));
- Disconnect(NULL);
+ Disconnect(nullptr);
CloseCommandPipe();
}
@@ -222,8 +222,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
m_read_sp = std::move(tcp_socket);
m_write_sp = m_read_sp;
} else {
- m_read_sp.reset(new File(fd, false));
- m_write_sp.reset(new File(fd, false));
+ m_read_sp = std::make_shared<File>(fd, false);
+ m_write_sp = std::make_shared<File>(fd, false);
}
m_uri = *addr;
return eConnectionStatusSuccess;
@@ -262,7 +262,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
options.c_cc[VMIN] = 1;
options.c_cc[VTIME] = 0;
- ::tcsetattr(fd, TCSANOW, &options);
+ llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
}
int flags = ::fcntl(fd, F_GETFL, 0);
@@ -272,8 +272,8 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
::fcntl(fd, F_SETFL, flags);
}
}
- m_read_sp.reset(new File(fd, true));
- m_write_sp.reset(new File(fd, false));
+ m_read_sp = std::make_shared<File>(fd, true);
+ m_write_sp = std::make_shared<File>(fd, false);
return eConnectionStatusSuccess;
}
#endif
@@ -758,13 +758,7 @@ void ConnectionFileDescriptor::SetChildProcessesInherit(
}
void ConnectionFileDescriptor::InitializeSocket(Socket *socket) {
- assert(socket->GetSocketProtocol() == Socket::ProtocolTcp);
- TCPSocket *tcp_socket = static_cast<TCPSocket *>(socket);
-
m_write_sp.reset(socket);
m_read_sp = m_write_sp;
- StreamString strm;
- strm.Printf("connect://%s:%u", tcp_socket->GetRemoteIPAddress().c_str(),
- tcp_socket->GetRemotePortNumber());
- m_uri = strm.GetString();
+ m_uri = socket->GetRemoteConnectionURI();
}
diff --git a/source/Host/posix/DomainSocket.cpp b/source/Host/posix/DomainSocket.cpp
index 3e3abadc2e5a3..27872f48129c0 100644
--- a/source/Host/posix/DomainSocket.cpp
+++ b/source/Host/posix/DomainSocket.cpp
@@ -1,14 +1,14 @@
//===-- DomainSocket.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/posix/DomainSocket.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include <stddef.h>
@@ -82,8 +82,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
m_socket = CreateSocket(kDomain, kType, 0, m_child_processes_inherit, error);
if (error.Fail())
return error;
- if (::connect(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) <
- 0)
+ if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+ (struct sockaddr *)&saddr_un, saddr_un_len) < 0)
SetLastError(error);
return error;
@@ -125,3 +125,31 @@ size_t DomainSocket::GetNameOffset() const { return 0; }
void DomainSocket::DeleteSocketFile(llvm::StringRef name) {
llvm::sys::fs::remove(name);
}
+
+std::string DomainSocket::GetSocketName() const {
+ if (m_socket != kInvalidSocketValue) {
+ struct sockaddr_un saddr_un;
+ saddr_un.sun_family = AF_UNIX;
+ socklen_t sock_addr_len = sizeof(struct sockaddr_un);
+ if (::getpeername(m_socket, (struct sockaddr *)&saddr_un, &sock_addr_len) ==
+ 0) {
+ std::string name(saddr_un.sun_path + GetNameOffset(),
+ sock_addr_len -
+ offsetof(struct sockaddr_un, sun_path) -
+ GetNameOffset());
+ if (name.back() == '\0') name.pop_back();
+ return name;
+ }
+ }
+ return "";
+}
+
+std::string DomainSocket::GetRemoteConnectionURI() const {
+ if (m_socket != kInvalidSocketValue) {
+ return llvm::formatv("{0}://{1}",
+ GetNameOffset() == 0 ? "unix-connect"
+ : "unix-abstract-connect",
+ GetSocketName());
+ }
+ return "";
+}
diff --git a/source/Host/posix/FileSystem.cpp b/source/Host/posix/FileSystem.cpp
index d7045ff999191..32fae68abb4d7 100644
--- a/source/Host/posix/FileSystem.cpp
+++ b/source/Host/posix/FileSystem.cpp
@@ -1,9 +1,8 @@
//===-- FileSystem.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,6 +25,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
using namespace lldb;
@@ -72,9 +72,9 @@ Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
}
FILE *FileSystem::Fopen(const char *path, const char *mode) {
- return ::fopen(path, mode);
+ return llvm::sys::RetryAfterSignal(nullptr, ::fopen, path, mode);
}
int FileSystem::Open(const char *path, int flags, int mode) {
- return ::open(path, flags, mode);
+ return llvm::sys::RetryAfterSignal(-1, ::open, path, flags, mode);
}
diff --git a/source/Host/posix/HostInfoPosix.cpp b/source/Host/posix/HostInfoPosix.cpp
index 4763ebc9b9d46..f300e22e9e5ca 100644
--- a/source/Host/posix/HostInfoPosix.cpp
+++ b/source/Host/posix/HostInfoPosix.cpp
@@ -1,13 +1,13 @@
//===-- HostInfoPosix.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/posix/HostInfoPosix.h"
+#include "lldb/Utility/UserIDResolver.h"
#include "lldb/Utility/Log.h"
#include "llvm/ADT/SmallString.h"
@@ -49,40 +49,38 @@ bool HostInfoPosix::GetHostname(std::string &s) {
#define USE_GETPWUID
#endif
-#ifdef USE_GETPWUID
-static std::mutex s_getpwuid_lock;
-#endif
+namespace {
+class PosixUserIDResolver : public UserIDResolver {
+protected:
+ llvm::Optional<std::string> DoGetUserName(id_t uid) override;
+ llvm::Optional<std::string> DoGetGroupName(id_t gid) override;
+};
+} // namespace
-const char *HostInfoPosix::LookupUserName(uint32_t uid,
- std::string &user_name) {
+llvm::Optional<std::string> PosixUserIDResolver::DoGetUserName(id_t uid) {
#ifdef USE_GETPWUID
// getpwuid_r is missing from android-9
- // make getpwuid thread safe with a mutex
- std::lock_guard<std::mutex> lock(s_getpwuid_lock);
+ // UserIDResolver provides some thread safety by making sure noone calls this
+ // function concurrently, but using getpwuid is ultimately not thread-safe as
+ // we don't know who else might be calling it.
struct passwd *user_info_ptr = ::getpwuid(uid);
- if (user_info_ptr) {
- user_name.assign(user_info_ptr->pw_name);
- return user_name.c_str();
- }
+ if (user_info_ptr)
+ return std::string(user_info_ptr->pw_name);
#else
struct passwd user_info;
struct passwd *user_info_ptr = &user_info;
char user_buffer[PATH_MAX];
size_t user_buffer_size = sizeof(user_buffer);
if (::getpwuid_r(uid, &user_info, user_buffer, user_buffer_size,
- &user_info_ptr) == 0) {
- if (user_info_ptr) {
- user_name.assign(user_info_ptr->pw_name);
- return user_name.c_str();
- }
+ &user_info_ptr) == 0 &&
+ user_info_ptr) {
+ return std::string(user_info_ptr->pw_name);
}
#endif
- user_name.clear();
- return nullptr;
+ return llvm::None;
}
-const char *HostInfoPosix::LookupGroupName(uint32_t gid,
- std::string &group_name) {
+llvm::Optional<std::string> PosixUserIDResolver::DoGetGroupName(id_t gid) {
#ifndef __ANDROID__
char group_buffer[PATH_MAX];
size_t group_buffer_size = sizeof(group_buffer);
@@ -91,24 +89,25 @@ const char *HostInfoPosix::LookupGroupName(uint32_t gid,
// Try the threadsafe version first
if (::getgrgid_r(gid, &group_info, group_buffer, group_buffer_size,
&group_info_ptr) == 0) {
- if (group_info_ptr) {
- group_name.assign(group_info_ptr->gr_name);
- return group_name.c_str();
- }
+ if (group_info_ptr)
+ return std::string(group_info_ptr->gr_name);
} else {
// The threadsafe version isn't currently working for me on darwin, but the
// non-threadsafe version is, so I am calling it below.
group_info_ptr = ::getgrgid(gid);
- if (group_info_ptr) {
- group_name.assign(group_info_ptr->gr_name);
- return group_name.c_str();
- }
+ if (group_info_ptr)
+ return std::string(group_info_ptr->gr_name);
}
- group_name.clear();
#else
assert(false && "getgrgid_r() not supported on Android");
#endif
- return NULL;
+ return llvm::None;
+}
+
+static llvm::ManagedStatic<PosixUserIDResolver> g_user_id_resolver;
+
+UserIDResolver &HostInfoPosix::GetUserIDResolver() {
+ return *g_user_id_resolver;
}
uint32_t HostInfoPosix::GetUserID() { return getuid(); }
@@ -121,43 +120,6 @@ uint32_t HostInfoPosix::GetEffectiveGroupID() { return getegid(); }
FileSpec HostInfoPosix::GetDefaultShell() { return FileSpec("/bin/sh"); }
-bool HostInfoPosix::ComputePathRelativeToLibrary(FileSpec &file_spec,
- llvm::StringRef dir) {
- Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
-
- FileSpec lldb_file_spec = GetShlibDir();
- if (!lldb_file_spec)
- return false;
-
- std::string raw_path = lldb_file_spec.GetPath();
- // drop library directory
- llvm::StringRef parent_path = llvm::sys::path::parent_path(raw_path);
-
- // Most Posix systems (e.g. Linux/*BSD) will attempt to replace a */lib with
- // */bin as the base directory for helper exe programs. This will fail if
- // the /lib and /bin directories are rooted in entirely different trees.
- if (log)
- log->Printf("HostInfoPosix::ComputePathRelativeToLibrary() attempting to "
- "derive the %s path from this path: %s",
- dir.data(), raw_path.c_str());
-
- if (!parent_path.empty()) {
- // Now write in bin in place of lib.
- raw_path = (parent_path + dir).str();
-
- if (log)
- log->Printf("Host::%s() derived the bin path as: %s", __FUNCTION__,
- raw_path.c_str());
- } else {
- if (log)
- log->Printf("Host::%s() failed to find /lib/liblldb within the shared "
- "lib path, bailing on bin path construction",
- __FUNCTION__);
- }
- file_spec.GetDirectory().SetString(raw_path);
- return (bool)file_spec.GetDirectory();
-}
-
bool HostInfoPosix::ComputeSupportExeDirectory(FileSpec &file_spec) {
return ComputePathRelativeToLibrary(file_spec, "/bin");
}
diff --git a/source/Host/posix/HostProcessPosix.cpp b/source/Host/posix/HostProcessPosix.cpp
index f431e0c72de16..cc187d4424686 100644
--- a/source/Host/posix/HostProcessPosix.cpp
+++ b/source/Host/posix/HostProcessPosix.cpp
@@ -1,9 +1,8 @@
//===-- HostProcessPosix.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -88,7 +87,7 @@ bool HostProcessPosix::IsRunning() const {
return error.Success();
}
-HostThread HostProcessPosix::StartMonitoring(
+llvm::Expected<HostThread> HostProcessPosix::StartMonitoring(
const Host::MonitorChildProcessCallback &callback, bool monitor_signals) {
return Host::StartMonitoringChildProcess(callback, m_process,
monitor_signals);
diff --git a/source/Host/posix/HostThreadPosix.cpp b/source/Host/posix/HostThreadPosix.cpp
index 13de42f763ec7..d78bba517f69c 100644
--- a/source/Host/posix/HostThreadPosix.cpp
+++ b/source/Host/posix/HostThreadPosix.cpp
@@ -1,9 +1,8 @@
//===-- HostThreadPosix.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,7 +29,7 @@ Status HostThreadPosix::Join(lldb::thread_result_t *result) {
error.SetError(err, lldb::eErrorTypePOSIX);
} else {
if (result)
- *result = NULL;
+ *result = nullptr;
error.SetError(EINVAL, eErrorTypePOSIX);
}
diff --git a/source/Host/posix/LockFilePosix.cpp b/source/Host/posix/LockFilePosix.cpp
index 05423062bd445..a6eae95c333b8 100644
--- a/source/Host/posix/LockFilePosix.cpp
+++ b/source/Host/posix/LockFilePosix.cpp
@@ -1,14 +1,15 @@
//===-- LockFilePosix.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Host/posix/LockFilePosix.h"
+#include "llvm/Support/Errno.h"
+
#include <fcntl.h>
#include <unistd.h>
@@ -28,7 +29,7 @@ Status fileLock(int fd, int cmd, int lock_type, const uint64_t start,
fl.l_pid = ::getpid();
Status error;
- if (::fcntl(fd, cmd, &fl) == -1)
+ if (llvm::sys::RetryAfterSignal(-1, ::fcntl, fd, cmd, &fl) == -1)
error.SetErrorToErrno();
return error;
diff --git a/source/Host/posix/PipePosix.cpp b/source/Host/posix/PipePosix.cpp
index 866a9897ee438..efdc151e37633 100644
--- a/source/Host/posix/PipePosix.cpp
+++ b/source/Host/posix/PipePosix.cpp
@@ -1,9 +1,8 @@
//===-- PipePosix.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,6 +10,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/SelectHelper.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
@@ -158,7 +158,7 @@ Status PipePosix::OpenAsReader(llvm::StringRef name,
flags |= O_CLOEXEC;
Status error;
- int fd = ::open(name.data(), flags);
+ int fd = llvm::sys::RetryAfterSignal(-1, ::open, name.data(), flags);
if (fd != -1)
m_fds[READ] = fd;
else
@@ -193,7 +193,7 @@ PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name,
if (fd == -1) {
const auto errno_copy = errno;
// We may get ENXIO if a reader side of the pipe hasn't opened yet.
- if (errno_copy != ENXIO)
+ if (errno_copy != ENXIO && errno_copy != EINTR)
return Status(errno_copy, eErrorTypePOSIX);
std::this_thread::sleep_for(
@@ -276,6 +276,8 @@ Status PipePosix::ReadWithTimeout(void *buf, size_t size,
bytes_read += result;
if (bytes_read == size || result == 0)
break;
+ } else if (errno == EINTR) {
+ continue;
} else {
error.SetErrorToErrno();
break;
@@ -306,6 +308,8 @@ Status PipePosix::Write(const void *buf, size_t size, size_t &bytes_written) {
bytes_written += result;
if (bytes_written == size)
break;
+ } else if (errno == EINTR) {
+ continue;
} else {
error.SetErrorToErrno();
}
diff --git a/source/Host/posix/ProcessLauncherPosixFork.cpp b/source/Host/posix/ProcessLauncherPosixFork.cpp
index 6bf78463d060f..185c7f0fe248d 100644
--- a/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -1,9 +1,8 @@
-//===-- ProcessLauncherLinux.cpp --------------------------------*- C++ -*-===//
+//===-- ProcessLauncherPosixFork.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,7 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/Pipe.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "llvm/Support/Errno.h"
@@ -73,7 +72,8 @@ static void DisableASLRIfRequested(int error_fd, const ProcessLaunchInfo &info)
static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
int flags) {
- int target_fd = ::open(file_spec.GetCString(), flags, 0666);
+ int target_fd = llvm::sys::RetryAfterSignal(-1, ::open,
+ file_spec.GetCString(), flags, 0666);
if (target_fd == -1)
ExitWithError(error_fd, "DupDescriptor-open");
@@ -212,7 +212,7 @@ ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info,
error.SetErrorString(buf);
- waitpid(pid, nullptr, 0);
+ llvm::sys::RetryAfterSignal(-1, waitpid, pid, nullptr, 0);
return HostProcess();
}
diff --git a/source/Initialization/SystemInitializer.cpp b/source/Initialization/SystemInitializer.cpp
index 4a8e10caef9f8..1e40c26944644 100644
--- a/source/Initialization/SystemInitializer.cpp
+++ b/source/Initialization/SystemInitializer.cpp
@@ -1,9 +1,8 @@
//===-- SystemInitializer.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Initialization/SystemInitializerCommon.cpp b/source/Initialization/SystemInitializerCommon.cpp
index d1d55fcfde74a..8558911c2f4cb 100644
--- a/source/Initialization/SystemInitializerCommon.cpp
+++ b/source/Initialization/SystemInitializerCommon.cpp
@@ -1,32 +1,28 @@
//===-- SystemInitializerCommon.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Initialization/SystemInitializerCommon.h"
-#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
-#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
-#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
-#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h"
-#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/Socket.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/Timer.h"
+#include "lldb/lldb-private.h"
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
#endif
-#if defined(_MSC_VER)
+#if defined(_WIN32)
#include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
#include "lldb/Host/windows/windows.h"
#endif
@@ -42,9 +38,8 @@ SystemInitializerCommon::SystemInitializerCommon() {}
SystemInitializerCommon::~SystemInitializerCommon() {}
-llvm::Error
-SystemInitializerCommon::Initialize(const InitializerOptions &options) {
-#if defined(_MSC_VER)
+llvm::Error SystemInitializerCommon::Initialize() {
+#if defined(_WIN32)
const char *disable_crash_dialog_var = getenv("LLDB_DISABLE_CRASH_DIALOG");
if (disable_crash_dialog_var &&
llvm::StringRef(disable_crash_dialog_var).equals_lower("true")) {
@@ -66,39 +61,47 @@ SystemInitializerCommon::Initialize(const InitializerOptions &options) {
}
#endif
- ReproducerMode mode = ReproducerMode::Off;
- if (options.reproducer_capture)
- mode = ReproducerMode::Capture;
- if (options.reproducer_replay)
- mode = ReproducerMode::Replay;
+ // If the reproducer wasn't initialized before, we can safely assume it's
+ // off.
+ if (!Reproducer::Initialized()) {
+ if (auto e = Reproducer::Initialize(ReproducerMode::Off, llvm::None))
+ return e;
+ }
- if (auto e = Reproducer::Initialize(mode, FileSpec(options.reproducer_path)))
- return e;
+ auto &r = repro::Reproducer::Instance();
+ if (repro::Loader *loader = r.GetLoader()) {
+ FileSpec vfs_mapping = loader->GetFile<FileProvider::Info>();
+ if (vfs_mapping) {
+ if (llvm::Error e = FileSystem::Initialize(vfs_mapping))
+ return e;
+ } else {
+ FileSystem::Initialize();
+ }
+ } else if (repro::Generator *g = r.GetGenerator()) {
+ repro::VersionProvider &vp = g->GetOrCreate<repro::VersionProvider>();
+ vp.SetVersion(lldb_private::GetVersion());
+ repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>();
+ FileSystem::Initialize(fp.GetFileCollector());
+ } else {
+ FileSystem::Initialize();
+ }
- FileSystem::Initialize();
Log::Initialize();
HostInfo::Initialize();
+
+ llvm::Error error = Socket::Initialize();
+ if (error)
+ return error;
+
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
process_gdb_remote::ProcessGDBRemoteLog::Initialize();
- // Initialize plug-ins
- ObjectContainerBSDArchive::Initialize();
-
- EmulateInstructionARM::Initialize();
- EmulateInstructionMIPS::Initialize();
- EmulateInstructionMIPS64::Initialize();
-
- //----------------------------------------------------------------------
- // Apple/Darwin hosted plugins
- //----------------------------------------------------------------------
- ObjectContainerUniversalMachO::Initialize();
-
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__)
ProcessPOSIXLog::Initialize();
#endif
-#if defined(_MSC_VER)
+#if defined(_WIN32)
ProcessWindowsLog::Initialize();
#endif
@@ -108,18 +111,12 @@ SystemInitializerCommon::Initialize(const InitializerOptions &options) {
void SystemInitializerCommon::Terminate() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
- ObjectContainerBSDArchive::Terminate();
-
- EmulateInstructionARM::Terminate();
- EmulateInstructionMIPS::Terminate();
- EmulateInstructionMIPS64::Terminate();
-
- ObjectContainerUniversalMachO::Terminate();
-#if defined(_MSC_VER)
+#if defined(_WIN32)
ProcessWindowsLog::Terminate();
#endif
+ Socket::Terminate();
HostInfo::Terminate();
Log::DisableAllLogChannels();
FileSystem::Terminate();
diff --git a/source/Initialization/SystemLifetimeManager.cpp b/source/Initialization/SystemLifetimeManager.cpp
index 65431bf6017d3..97f60489f04ba 100644
--- a/source/Initialization/SystemLifetimeManager.cpp
+++ b/source/Initialization/SystemLifetimeManager.cpp
@@ -1,9 +1,8 @@
//===-- SystemLifetimeManager.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,7 +25,7 @@ SystemLifetimeManager::~SystemLifetimeManager() {
llvm::Error SystemLifetimeManager::Initialize(
std::unique_ptr<SystemInitializer> initializer,
- const InitializerOptions &options, LoadPluginCallbackType plugin_callback) {
+ LoadPluginCallbackType plugin_callback) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (!m_initialized) {
assert(!m_initializer && "Attempting to call "
@@ -35,7 +34,7 @@ llvm::Error SystemLifetimeManager::Initialize(
m_initialized = true;
m_initializer = std::move(initializer);
- if (auto e = m_initializer->Initialize(options))
+ if (auto e = m_initializer->Initialize())
return e;
Debugger::Initialize(plugin_callback);
diff --git a/source/Interpreter/CommandAlias.cpp b/source/Interpreter/CommandAlias.cpp
index 078eb73a7a876..8c40574ee50ef 100644
--- a/source/Interpreter/CommandAlias.cpp
+++ b/source/Interpreter/CommandAlias.cpp
@@ -1,9 +1,8 @@
//===-- CommandAlias.cpp -----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,6 +30,8 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
Args args(options_args);
std::string options_string(options_args);
+ // TODO: Find a way to propagate errors in this CommandReturnObject up the
+ // stack.
CommandReturnObject result;
// Check to see if the command being aliased can take any command options.
Options *options = cmd_obj_sp->GetOptions();
diff --git a/source/Interpreter/CommandHistory.cpp b/source/Interpreter/CommandHistory.cpp
index ca5c90692b6a2..0be61f836e002 100644
--- a/source/Interpreter/CommandHistory.cpp
+++ b/source/Interpreter/CommandHistory.cpp
@@ -1,9 +1,8 @@
//===-- CommandHistory.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 6d75ec57c83b2..8948037a6307b 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1,12 +1,12 @@
//===-- CommandInterpreter.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+#include <memory>
#include <stdlib.h>
#include <string>
#include <vector>
@@ -81,6 +81,17 @@ static constexpr bool NoGlobalSetting = true;
static constexpr uintptr_t DefaultValueTrue = true;
static constexpr uintptr_t DefaultValueFalse = false;
static constexpr const char *NoCStrDefault = nullptr;
+static constexpr const char *InitFileWarning =
+ "There is a .lldbinit file in the current directory which is not being "
+ "read.\n"
+ "To silence this warning without sourcing in the local .lldbinit,\n"
+ "add the following to the lldbinit file in your home directory:\n"
+ " settings set target.load-cwd-lldbinit false\n"
+ "To allow lldb to source .lldbinit files in the current working "
+ "directory,\n"
+ "set the value of this variable to true. Only do so if you understand "
+ "and\n"
+ "accept the security risk.";
static constexpr PropertyDefinition g_properties[] = {
{"expand-regex-aliases", OptionValue::eTypeBoolean, NoGlobalSetting,
@@ -122,7 +133,6 @@ ConstString &CommandInterpreter::GetStaticBroadcasterClass() {
}
CommandInterpreter::CommandInterpreter(Debugger &debugger,
- ScriptLanguage script_language,
bool synchronous_execution)
: Broadcaster(debugger.GetBroadcasterManager(),
CommandInterpreter::GetStaticBroadcasterClass().AsCString()),
@@ -131,11 +141,10 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
m_debugger(debugger), m_synchronous_execution(synchronous_execution),
m_skip_lldbinit_files(false), m_skip_app_init_files(false),
- m_script_interpreter_sp(), m_command_io_handler_sp(), m_comment_char('#'),
+ m_command_io_handler_sp(), m_comment_char('#'),
m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
m_command_source_depth(0), m_num_errors(0), m_quit_requested(false),
m_stopped_for_crash(false) {
- debugger.SetScriptLanguage(script_language);
SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
SetEventName(eBroadcastBitQuitCommandReceived, "quit");
@@ -367,7 +376,7 @@ void CommandInterpreter::Initialize() {
if (cmd_obj_sp)
AddAlias("image", cmd_obj_sp);
- alias_arguments_vector_sp.reset(new OptionArgVector);
+ alias_arguments_vector_sp = std::make_shared<OptionArgVector>();
cmd_obj_sp = GetCommandSPExact("expression", false);
if (cmd_obj_sp) {
@@ -393,7 +402,7 @@ void CommandInterpreter::Initialize() {
cmd_obj_sp = GetCommandSPExact("process launch", false);
if (cmd_obj_sp) {
- alias_arguments_vector_sp.reset(new OptionArgVector);
+ alias_arguments_vector_sp = std::make_shared<OptionArgVector>();
#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
AddAlias("r", cmd_obj_sp, "--");
AddAlias("run", cmd_obj_sp, "--");
@@ -431,13 +440,15 @@ void CommandInterpreter::Initialize() {
AddAlias("var", cmd_obj_sp);
AddAlias("vo", cmd_obj_sp, "--object-description");
}
+
+ cmd_obj_sp = GetCommandSPExact("register", false);
+ if (cmd_obj_sp) {
+ AddAlias("re", cmd_obj_sp);
+ }
}
void CommandInterpreter::Clear() {
m_command_io_handler_sp.reset();
-
- if (m_script_interpreter_sp)
- m_script_interpreter_sp->Clear();
}
const char *CommandInterpreter::ProcessEmbeddedScriptCommands(const char *arg) {
@@ -522,7 +533,7 @@ void CommandInterpreter::LoadCommandDictionary() {
size_t num_regexes = llvm::array_lengthof(break_regexes);
- std::unique_ptr<CommandObjectRegexCommand> break_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> break_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-break",
"Set a breakpoint using one of several shorthand formats.",
@@ -550,28 +561,29 @@ void CommandInterpreter::LoadCommandDictionary() {
"current file\n"
" // containing text 'break "
"here'.\n",
- 2, CommandCompletions::eSymbolCompletion |
- CommandCompletions::eSourceFileCompletion,
+ 2,
+ CommandCompletions::eSymbolCompletion |
+ CommandCompletions::eSourceFileCompletion,
false));
- if (break_regex_cmd_ap.get()) {
+ if (break_regex_cmd_up) {
bool success = true;
for (size_t i = 0; i < num_regexes; i++) {
- success = break_regex_cmd_ap->AddRegexCommand(break_regexes[i][0],
+ success = break_regex_cmd_up->AddRegexCommand(break_regexes[i][0],
break_regexes[i][1]);
if (!success)
break;
}
success =
- break_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list --full");
+ break_regex_cmd_up->AddRegexCommand("^$", "breakpoint list --full");
if (success) {
- CommandObjectSP break_regex_cmd_sp(break_regex_cmd_ap.release());
+ CommandObjectSP break_regex_cmd_sp(break_regex_cmd_up.release());
m_command_dict[break_regex_cmd_sp->GetCommandName()] = break_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> tbreak_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> tbreak_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-tbreak",
"Set a one-shot breakpoint using one of several shorthand formats.",
@@ -599,11 +611,12 @@ void CommandInterpreter::LoadCommandDictionary() {
"current file\n"
" // containing text 'break "
"here'.\n",
- 2, CommandCompletions::eSymbolCompletion |
- CommandCompletions::eSourceFileCompletion,
+ 2,
+ CommandCompletions::eSymbolCompletion |
+ CommandCompletions::eSourceFileCompletion,
false));
- if (tbreak_regex_cmd_ap.get()) {
+ if (tbreak_regex_cmd_up) {
bool success = true;
for (size_t i = 0; i < num_regexes; i++) {
// If you add a resultant command string longer than 1024 characters be
@@ -614,155 +627,160 @@ void CommandInterpreter::LoadCommandDictionary() {
lldbassert(num_printed < 1024);
UNUSED_IF_ASSERT_DISABLED(num_printed);
success =
- tbreak_regex_cmd_ap->AddRegexCommand(break_regexes[i][0], buffer);
+ tbreak_regex_cmd_up->AddRegexCommand(break_regexes[i][0], buffer);
if (!success)
break;
}
success =
- tbreak_regex_cmd_ap->AddRegexCommand("^$", "breakpoint list --full");
+ tbreak_regex_cmd_up->AddRegexCommand("^$", "breakpoint list --full");
if (success) {
- CommandObjectSP tbreak_regex_cmd_sp(tbreak_regex_cmd_ap.release());
+ CommandObjectSP tbreak_regex_cmd_sp(tbreak_regex_cmd_up.release());
m_command_dict[tbreak_regex_cmd_sp->GetCommandName()] =
tbreak_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> attach_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> attach_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-attach", "Attach to process by ID or name.",
"_regexp-attach <pid> | <process-name>", 2, 0, false));
- if (attach_regex_cmd_ap.get()) {
- if (attach_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$",
+ if (attach_regex_cmd_up) {
+ if (attach_regex_cmd_up->AddRegexCommand("^([0-9]+)[[:space:]]*$",
"process attach --pid %1") &&
- attach_regex_cmd_ap->AddRegexCommand(
+ attach_regex_cmd_up->AddRegexCommand(
"^(-.*|.* -.*)$", "process attach %1") && // Any options that are
// specified get passed to
// 'process attach'
- attach_regex_cmd_ap->AddRegexCommand("^(.+)$",
+ attach_regex_cmd_up->AddRegexCommand("^(.+)$",
"process attach --name '%1'") &&
- attach_regex_cmd_ap->AddRegexCommand("^$", "process attach")) {
- CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_ap.release());
+ attach_regex_cmd_up->AddRegexCommand("^$", "process attach")) {
+ CommandObjectSP attach_regex_cmd_sp(attach_regex_cmd_up.release());
m_command_dict[attach_regex_cmd_sp->GetCommandName()] =
attach_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> down_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> down_regex_cmd_up(
new CommandObjectRegexCommand(*this, "_regexp-down",
"Select a newer stack frame. Defaults to "
"moving one frame, a numeric argument can "
"specify an arbitrary number.",
"_regexp-down [<count>]", 2, 0, false));
- if (down_regex_cmd_ap.get()) {
- if (down_regex_cmd_ap->AddRegexCommand("^$", "frame select -r -1") &&
- down_regex_cmd_ap->AddRegexCommand("^([0-9]+)$",
+ if (down_regex_cmd_up) {
+ if (down_regex_cmd_up->AddRegexCommand("^$", "frame select -r -1") &&
+ down_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"frame select -r -%1")) {
- CommandObjectSP down_regex_cmd_sp(down_regex_cmd_ap.release());
+ CommandObjectSP down_regex_cmd_sp(down_regex_cmd_up.release());
m_command_dict[down_regex_cmd_sp->GetCommandName()] = down_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> up_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> up_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-up",
"Select an older stack frame. Defaults to moving one "
"frame, a numeric argument can specify an arbitrary number.",
"_regexp-up [<count>]", 2, 0, false));
- if (up_regex_cmd_ap.get()) {
- if (up_regex_cmd_ap->AddRegexCommand("^$", "frame select -r 1") &&
- up_regex_cmd_ap->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) {
- CommandObjectSP up_regex_cmd_sp(up_regex_cmd_ap.release());
+ if (up_regex_cmd_up) {
+ if (up_regex_cmd_up->AddRegexCommand("^$", "frame select -r 1") &&
+ up_regex_cmd_up->AddRegexCommand("^([0-9]+)$", "frame select -r %1")) {
+ CommandObjectSP up_regex_cmd_sp(up_regex_cmd_up.release());
m_command_dict[up_regex_cmd_sp->GetCommandName()] = up_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> display_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> display_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-display",
"Evaluate an expression at every stop (see 'help target stop-hook'.)",
"_regexp-display expression", 2, 0, false));
- if (display_regex_cmd_ap.get()) {
- if (display_regex_cmd_ap->AddRegexCommand(
+ if (display_regex_cmd_up) {
+ if (display_regex_cmd_up->AddRegexCommand(
"^(.+)$", "target stop-hook add -o \"expr -- %1\"")) {
- CommandObjectSP display_regex_cmd_sp(display_regex_cmd_ap.release());
+ CommandObjectSP display_regex_cmd_sp(display_regex_cmd_up.release());
m_command_dict[display_regex_cmd_sp->GetCommandName()] =
display_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> undisplay_regex_cmd_ap(
- new CommandObjectRegexCommand(
- *this, "_regexp-undisplay", "Stop displaying expression at every "
- "stop (specified by stop-hook index.)",
- "_regexp-undisplay stop-hook-number", 2, 0, false));
- if (undisplay_regex_cmd_ap.get()) {
- if (undisplay_regex_cmd_ap->AddRegexCommand("^([0-9]+)$",
+ std::unique_ptr<CommandObjectRegexCommand> undisplay_regex_cmd_up(
+ new CommandObjectRegexCommand(*this, "_regexp-undisplay",
+ "Stop displaying expression at every "
+ "stop (specified by stop-hook index.)",
+ "_regexp-undisplay stop-hook-number", 2, 0,
+ false));
+ if (undisplay_regex_cmd_up) {
+ if (undisplay_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"target stop-hook delete %1")) {
- CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_ap.release());
+ CommandObjectSP undisplay_regex_cmd_sp(undisplay_regex_cmd_up.release());
m_command_dict[undisplay_regex_cmd_sp->GetCommandName()] =
undisplay_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> connect_gdb_remote_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> connect_gdb_remote_cmd_up(
new CommandObjectRegexCommand(
- *this, "gdb-remote", "Connect to a process via remote GDB server. "
- "If no host is specifed, localhost is assumed.",
+ *this, "gdb-remote",
+ "Connect to a process via remote GDB server. "
+ "If no host is specifed, localhost is assumed.",
"gdb-remote [<hostname>:]<portnum>", 2, 0, false));
- if (connect_gdb_remote_cmd_ap.get()) {
- if (connect_gdb_remote_cmd_ap->AddRegexCommand(
+ if (connect_gdb_remote_cmd_up) {
+ if (connect_gdb_remote_cmd_up->AddRegexCommand(
"^([^:]+|\\[[0-9a-fA-F:]+.*\\]):([0-9]+)$",
"process connect --plugin gdb-remote connect://%1:%2") &&
- connect_gdb_remote_cmd_ap->AddRegexCommand(
+ connect_gdb_remote_cmd_up->AddRegexCommand(
"^([[:digit:]]+)$",
"process connect --plugin gdb-remote connect://localhost:%1")) {
- CommandObjectSP command_sp(connect_gdb_remote_cmd_ap.release());
+ CommandObjectSP command_sp(connect_gdb_remote_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> connect_kdp_remote_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> connect_kdp_remote_cmd_up(
new CommandObjectRegexCommand(
- *this, "kdp-remote", "Connect to a process via remote KDP server. "
- "If no UDP port is specified, port 41139 is "
- "assumed.",
+ *this, "kdp-remote",
+ "Connect to a process via remote KDP server. "
+ "If no UDP port is specified, port 41139 is "
+ "assumed.",
"kdp-remote <hostname>[:<portnum>]", 2, 0, false));
- if (connect_kdp_remote_cmd_ap.get()) {
- if (connect_kdp_remote_cmd_ap->AddRegexCommand(
+ if (connect_kdp_remote_cmd_up) {
+ if (connect_kdp_remote_cmd_up->AddRegexCommand(
"^([^:]+:[[:digit:]]+)$",
"process connect --plugin kdp-remote udp://%1") &&
- connect_kdp_remote_cmd_ap->AddRegexCommand(
+ connect_kdp_remote_cmd_up->AddRegexCommand(
"^(.+)$", "process connect --plugin kdp-remote udp://%1:41139")) {
- CommandObjectSP command_sp(connect_kdp_remote_cmd_ap.release());
+ CommandObjectSP command_sp(connect_kdp_remote_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> bt_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> bt_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-bt",
"Show the current thread's call stack. Any numeric argument "
"displays at most that many "
- "frames. The argument 'all' displays all threads.",
+ "frames. The argument 'all' displays all threads. Use 'settings"
+ " set frame-format' to customize the printing of individual frames "
+ "and 'settings set thread-format' to customize the thread header.",
"bt [<digit> | all]", 2, 0, false));
- if (bt_regex_cmd_ap.get()) {
+ if (bt_regex_cmd_up) {
// accept but don't document "bt -c <number>" -- before bt was a regex
// command if you wanted to backtrace three frames you would do "bt -c 3"
// but the intention is to have this emulate the gdb "bt" command and so
// now "bt 3" is the preferred form, in line with gdb.
- if (bt_regex_cmd_ap->AddRegexCommand("^([[:digit:]]+)$",
+ if (bt_regex_cmd_up->AddRegexCommand("^([[:digit:]]+)[[:space:]]*$",
"thread backtrace -c %1") &&
- bt_regex_cmd_ap->AddRegexCommand("^-c ([[:digit:]]+)$",
+ bt_regex_cmd_up->AddRegexCommand("^-c ([[:digit:]]+)[[:space:]]*$",
"thread backtrace -c %1") &&
- bt_regex_cmd_ap->AddRegexCommand("^all$", "thread backtrace all") &&
- bt_regex_cmd_ap->AddRegexCommand("^$", "thread backtrace")) {
- CommandObjectSP command_sp(bt_regex_cmd_ap.release());
+ bt_regex_cmd_up->AddRegexCommand("^all[[:space:]]*$", "thread backtrace all") &&
+ bt_regex_cmd_up->AddRegexCommand("^[[:space:]]*$", "thread backtrace")) {
+ CommandObjectSP command_sp(bt_regex_cmd_up.release());
m_command_dict[command_sp->GetCommandName()] = command_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> list_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> list_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-list",
"List relevant source code using one of several shorthand formats.",
@@ -775,48 +793,48 @@ void CommandInterpreter::LoadCommandDictionary() {
"_regexp-list -[<count>] // List previous <count> lines\n"
"_regexp-list // List subsequent lines",
2, CommandCompletions::eSourceFileCompletion, false));
- if (list_regex_cmd_ap.get()) {
- if (list_regex_cmd_ap->AddRegexCommand("^([0-9]+)[[:space:]]*$",
+ if (list_regex_cmd_up) {
+ if (list_regex_cmd_up->AddRegexCommand("^([0-9]+)[[:space:]]*$",
"source list --line %1") &&
- list_regex_cmd_ap->AddRegexCommand(
+ list_regex_cmd_up->AddRegexCommand(
"^(.*[^[:space:]])[[:space:]]*:[[:space:]]*([[:digit:]]+)[[:space:]"
"]*$",
"source list --file '%1' --line %2") &&
- list_regex_cmd_ap->AddRegexCommand(
+ list_regex_cmd_up->AddRegexCommand(
"^\\*?(0x[[:xdigit:]]+)[[:space:]]*$",
"source list --address %1") &&
- list_regex_cmd_ap->AddRegexCommand("^-[[:space:]]*$",
+ list_regex_cmd_up->AddRegexCommand("^-[[:space:]]*$",
"source list --reverse") &&
- list_regex_cmd_ap->AddRegexCommand(
+ list_regex_cmd_up->AddRegexCommand(
"^-([[:digit:]]+)[[:space:]]*$",
"source list --reverse --count %1") &&
- list_regex_cmd_ap->AddRegexCommand("^(.+)$",
+ list_regex_cmd_up->AddRegexCommand("^(.+)$",
"source list --name \"%1\"") &&
- list_regex_cmd_ap->AddRegexCommand("^$", "source list")) {
- CommandObjectSP list_regex_cmd_sp(list_regex_cmd_ap.release());
+ list_regex_cmd_up->AddRegexCommand("^$", "source list")) {
+ CommandObjectSP list_regex_cmd_sp(list_regex_cmd_up.release());
m_command_dict[list_regex_cmd_sp->GetCommandName()] = list_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> env_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> env_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-env",
"Shorthand for viewing and setting environment variables.",
"\n"
- "_regexp-env // Show enrivonment\n"
+ "_regexp-env // Show environment\n"
"_regexp-env <name>=<value> // Set an environment variable",
2, 0, false));
- if (env_regex_cmd_ap.get()) {
- if (env_regex_cmd_ap->AddRegexCommand("^$",
+ if (env_regex_cmd_up) {
+ if (env_regex_cmd_up->AddRegexCommand("^$",
"settings show target.env-vars") &&
- env_regex_cmd_ap->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$",
+ env_regex_cmd_up->AddRegexCommand("^([A-Za-z_][A-Za-z_0-9]*=.*)$",
"settings set target.env-vars %1")) {
- CommandObjectSP env_regex_cmd_sp(env_regex_cmd_ap.release());
+ CommandObjectSP env_regex_cmd_sp(env_regex_cmd_up.release());
m_command_dict[env_regex_cmd_sp->GetCommandName()] = env_regex_cmd_sp;
}
}
- std::unique_ptr<CommandObjectRegexCommand> jump_regex_cmd_ap(
+ std::unique_ptr<CommandObjectRegexCommand> jump_regex_cmd_up(
new CommandObjectRegexCommand(
*this, "_regexp-jump", "Set the program counter to a new address.",
"\n"
@@ -825,16 +843,16 @@ void CommandInterpreter::LoadCommandDictionary() {
"_regexp-jump <file>:<line>\n"
"_regexp-jump *<addr>\n",
2, 0, false));
- if (jump_regex_cmd_ap.get()) {
- if (jump_regex_cmd_ap->AddRegexCommand("^\\*(.*)$",
+ if (jump_regex_cmd_up) {
+ if (jump_regex_cmd_up->AddRegexCommand("^\\*(.*)$",
"thread jump --addr %1") &&
- jump_regex_cmd_ap->AddRegexCommand("^([0-9]+)$",
+ jump_regex_cmd_up->AddRegexCommand("^([0-9]+)$",
"thread jump --line %1") &&
- jump_regex_cmd_ap->AddRegexCommand("^([^:]+):([0-9]+)$",
+ jump_regex_cmd_up->AddRegexCommand("^([^:]+):([0-9]+)$",
"thread jump --file %1 --line %2") &&
- jump_regex_cmd_ap->AddRegexCommand("^([+\\-][0-9]+)$",
+ jump_regex_cmd_up->AddRegexCommand("^([+\\-][0-9]+)$",
"thread jump --by %1")) {
- CommandObjectSP jump_regex_cmd_sp(jump_regex_cmd_ap.release());
+ CommandObjectSP jump_regex_cmd_sp(jump_regex_cmd_up.release());
m_command_dict[jump_regex_cmd_sp->GetCommandName()] = jump_regex_cmd_sp;
}
}
@@ -1721,7 +1739,7 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
log->Printf("HandleCommand, (revised) command_string: '%s'",
command_string.c_str());
const bool wants_raw_input =
- (cmd_obj != NULL) ? cmd_obj->WantsRawCommandString() : false;
+ (cmd_obj != nullptr) ? cmd_obj->WantsRawCommandString() : false;
log->Printf("HandleCommand, wants_raw_input:'%s'",
wants_raw_input ? "True" : "False");
}
@@ -2084,106 +2102,119 @@ int CommandInterpreter::GetOptionArgumentPosition(const char *in_string) {
return position;
}
-void CommandInterpreter::SourceInitFile(bool in_cwd,
- CommandReturnObject &result) {
- FileSpec init_file;
- if (in_cwd) {
- ExecutionContext exe_ctx(GetExecutionContext());
- Target *target = exe_ctx.GetTargetPtr();
- if (target) {
- // In the current working directory we don't load any program specific
- // .lldbinit files, we only look for a ".lldbinit" file.
- if (m_skip_lldbinit_files)
- return;
+static void GetHomeInitFile(llvm::SmallVectorImpl<char> &init_file,
+ llvm::StringRef suffix = {}) {
+ std::string init_file_name = ".lldbinit";
+ if (!suffix.empty()) {
+ init_file_name.append("-");
+ init_file_name.append(suffix.str());
+ }
- LoadCWDlldbinitFile should_load =
- target->TargetProperties::GetLoadCWDlldbinitFile();
- if (should_load == eLoadCWDlldbinitWarn) {
- FileSpec dot_lldb(".lldbinit");
- FileSystem::Instance().Resolve(dot_lldb);
- llvm::SmallString<64> home_dir_path;
- llvm::sys::path::home_directory(home_dir_path);
- FileSpec homedir_dot_lldb(home_dir_path.c_str());
- homedir_dot_lldb.AppendPathComponent(".lldbinit");
- FileSystem::Instance().Resolve(homedir_dot_lldb);
- if (FileSystem::Instance().Exists(dot_lldb) &&
- dot_lldb.GetDirectory() != homedir_dot_lldb.GetDirectory()) {
- result.AppendErrorWithFormat(
- "There is a .lldbinit file in the current directory which is not "
- "being read.\n"
- "To silence this warning without sourcing in the local "
- ".lldbinit,\n"
- "add the following to the lldbinit file in your home directory:\n"
- " settings set target.load-cwd-lldbinit false\n"
- "To allow lldb to source .lldbinit files in the current working "
- "directory,\n"
- "set the value of this variable to true. Only do so if you "
- "understand and\n"
- "accept the security risk.");
- result.SetStatus(eReturnStatusFailed);
- return;
- }
- } else if (should_load == eLoadCWDlldbinitTrue) {
- init_file.SetFile("./.lldbinit", FileSpec::Style::native);
- FileSystem::Instance().Resolve(init_file);
- }
- }
- } else {
- // If we aren't looking in the current working directory we are looking in
- // the home directory. We will first see if there is an application
- // specific ".lldbinit" file whose name is "~/.lldbinit" followed by a "-"
- // and the name of the program. If this file doesn't exist, we fall back to
- // just the "~/.lldbinit" file. We also obey any requests to not load the
- // init files.
- llvm::SmallString<64> home_dir_path;
- llvm::sys::path::home_directory(home_dir_path);
- FileSpec profilePath(home_dir_path.c_str());
- profilePath.AppendPathComponent(".lldbinit");
- std::string init_file_path = profilePath.GetPath();
-
- if (!m_skip_app_init_files) {
- FileSpec program_file_spec(HostInfo::GetProgramFileSpec());
- const char *program_name = program_file_spec.GetFilename().AsCString();
-
- if (program_name) {
- char program_init_file_name[PATH_MAX];
- ::snprintf(program_init_file_name, sizeof(program_init_file_name),
- "%s-%s", init_file_path.c_str(), program_name);
- init_file.SetFile(program_init_file_name, FileSpec::Style::native);
- FileSystem::Instance().Resolve(init_file);
- if (!FileSystem::Instance().Exists(init_file))
- init_file.Clear();
- }
- }
+ llvm::sys::path::home_directory(init_file);
+ llvm::sys::path::append(init_file, init_file_name);
+
+ FileSystem::Instance().Resolve(init_file);
+}
- if (!init_file && !m_skip_lldbinit_files)
- init_file.SetFile(init_file_path, FileSpec::Style::native);
+static void GetCwdInitFile(llvm::SmallVectorImpl<char> &init_file) {
+ llvm::StringRef s = ".lldbinit";
+ init_file.assign(s.begin(), s.end());
+ FileSystem::Instance().Resolve(init_file);
+}
+
+static LoadCWDlldbinitFile ShouldLoadCwdInitFile() {
+ lldb::TargetPropertiesSP properties = Target::GetGlobalProperties();
+ if (!properties)
+ return eLoadCWDlldbinitFalse;
+ return properties->GetLoadCWDlldbinitFile();
+}
+
+void CommandInterpreter::SourceInitFile(FileSpec file,
+ CommandReturnObject &result) {
+ assert(!m_skip_lldbinit_files);
+
+ if (!FileSystem::Instance().Exists(file)) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
}
- // If the file exists, tell HandleCommand to 'source' it; this will do the
- // actual broadcasting of the commands back to any appropriate listener (see
+ // Use HandleCommand to 'source' the given file; this will do the actual
+ // broadcasting of the commands back to any appropriate listener (see
// CommandObjectSource::Execute for more details).
+ const bool saved_batch = SetBatchCommandMode(true);
+ ExecutionContext *ctx = nullptr;
+ CommandInterpreterRunOptions options;
+ options.SetSilent(true);
+ options.SetPrintErrors(true);
+ options.SetStopOnError(false);
+ options.SetStopOnContinue(true);
+ HandleCommandsFromFile(file, ctx, options, result);
+ SetBatchCommandMode(saved_batch);
+}
+
+void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {
+ if (m_skip_lldbinit_files) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
+ }
- if (FileSystem::Instance().Exists(init_file)) {
- const bool saved_batch = SetBatchCommandMode(true);
- CommandInterpreterRunOptions options;
- options.SetSilent(true);
- options.SetStopOnError(false);
- options.SetStopOnContinue(true);
-
- HandleCommandsFromFile(init_file,
- nullptr, // Execution context
- options, result);
- SetBatchCommandMode(saved_batch);
- } else {
- // nothing to be done if the file doesn't exist
+ llvm::SmallString<128> init_file;
+ GetCwdInitFile(init_file);
+ if (!FileSystem::Instance().Exists(init_file)) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
+ }
+
+ LoadCWDlldbinitFile should_load = ShouldLoadCwdInitFile();
+
+ switch (should_load) {
+ case eLoadCWDlldbinitFalse:
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ break;
+ case eLoadCWDlldbinitTrue:
+ SourceInitFile(FileSpec(init_file.str()), result);
+ break;
+ case eLoadCWDlldbinitWarn: {
+ llvm::SmallString<128> home_init_file;
+ GetHomeInitFile(home_init_file);
+ if (llvm::sys::path::parent_path(init_file) ==
+ llvm::sys::path::parent_path(home_init_file)) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ } else {
+ result.AppendErrorWithFormat(InitFileWarning);
+ result.SetStatus(eReturnStatusFailed);
+ }
+ }
}
}
+/// We will first see if there is an application specific ".lldbinit" file
+/// whose name is "~/.lldbinit" followed by a "-" and the name of the program.
+/// If this file doesn't exist, we fall back to just the "~/.lldbinit" file.
+void CommandInterpreter::SourceInitFileHome(CommandReturnObject &result) {
+ if (m_skip_lldbinit_files) {
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ return;
+ }
+
+ llvm::SmallString<128> init_file;
+ GetHomeInitFile(init_file);
+
+ if (!m_skip_app_init_files) {
+ llvm::StringRef program_name =
+ HostInfo::GetProgramFileSpec().GetFilename().GetStringRef();
+ llvm::SmallString<128> program_init_file;
+ GetHomeInitFile(program_init_file, program_name);
+ if (FileSystem::Instance().Exists(program_init_file))
+ init_file = program_init_file;
+ }
+
+ SourceInitFile(FileSpec(init_file.str()), result);
+}
+
const char *CommandInterpreter::GetCommandPrefix() {
const char *prefix = GetDebugger().GetIOHandlerCommandPrefix();
- return prefix == NULL ? "" : prefix;
+ return prefix == nullptr ? "" : prefix;
}
PlatformSP CommandInterpreter::GetPlatform(bool prefer_target_platform) {
@@ -2359,156 +2390,152 @@ enum {
eHandleCommandFlagEchoCommand = (1u << 2),
eHandleCommandFlagEchoCommentCommand = (1u << 3),
eHandleCommandFlagPrintResult = (1u << 4),
- eHandleCommandFlagStopOnCrash = (1u << 5)
+ eHandleCommandFlagPrintErrors = (1u << 5),
+ eHandleCommandFlagStopOnCrash = (1u << 6)
};
void CommandInterpreter::HandleCommandsFromFile(
FileSpec &cmd_file, ExecutionContext *context,
CommandInterpreterRunOptions &options, CommandReturnObject &result) {
- if (FileSystem::Instance().Exists(cmd_file)) {
- StreamFileSP input_file_sp(new StreamFile());
-
- std::string cmd_file_path = cmd_file.GetPath();
- Status error = FileSystem::Instance().Open(input_file_sp->GetFile(),
- cmd_file, File::eOpenOptionRead);
- if (error.Success()) {
- Debugger &debugger = GetDebugger();
-
- uint32_t flags = 0;
-
- if (options.m_stop_on_continue == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Stop on continue by default
- flags |= eHandleCommandFlagStopOnContinue;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagStopOnContinue) {
- flags |= eHandleCommandFlagStopOnContinue;
- }
- } else if (options.m_stop_on_continue == eLazyBoolYes) {
- flags |= eHandleCommandFlagStopOnContinue;
- }
-
- if (options.m_stop_on_error == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- if (GetStopCmdSourceOnError())
- flags |= eHandleCommandFlagStopOnError;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagStopOnError) {
- flags |= eHandleCommandFlagStopOnError;
- }
- } else if (options.m_stop_on_error == eLazyBoolYes) {
- flags |= eHandleCommandFlagStopOnError;
- }
-
- // stop-on-crash can only be set, if it is present in all levels of
- // pushed flag sets.
- if (options.GetStopOnCrash()) {
- if (m_command_source_flags.empty()) {
- flags |= eHandleCommandFlagStopOnCrash;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagStopOnCrash) {
- flags |= eHandleCommandFlagStopOnCrash;
- }
- }
-
- if (options.m_echo_commands == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Echo command by default
- flags |= eHandleCommandFlagEchoCommand;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagEchoCommand) {
- flags |= eHandleCommandFlagEchoCommand;
- }
- } else if (options.m_echo_commands == eLazyBoolYes) {
- flags |= eHandleCommandFlagEchoCommand;
- }
-
- // We will only ever ask for this flag, if we echo commands in general.
- if (options.m_echo_comment_commands == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Echo comments by default
- flags |= eHandleCommandFlagEchoCommentCommand;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagEchoCommentCommand) {
- flags |= eHandleCommandFlagEchoCommentCommand;
- }
- } else if (options.m_echo_comment_commands == eLazyBoolYes) {
- flags |= eHandleCommandFlagEchoCommentCommand;
- }
-
- if (options.m_print_results == eLazyBoolCalculate) {
- if (m_command_source_flags.empty()) {
- // Print output by default
- flags |= eHandleCommandFlagPrintResult;
- } else if (m_command_source_flags.back() &
- eHandleCommandFlagPrintResult) {
- flags |= eHandleCommandFlagPrintResult;
- }
- } else if (options.m_print_results == eLazyBoolYes) {
- flags |= eHandleCommandFlagPrintResult;
- }
-
- if (flags & eHandleCommandFlagPrintResult) {
- debugger.GetOutputFile()->Printf("Executing commands in '%s'.\n",
- cmd_file_path.c_str());
- }
-
- // Used for inheriting the right settings when "command source" might
- // have nested "command source" commands
- lldb::StreamFileSP empty_stream_sp;
- m_command_source_flags.push_back(flags);
- IOHandlerSP io_handler_sp(new IOHandlerEditline(
- debugger, IOHandler::Type::CommandInterpreter, input_file_sp,
- empty_stream_sp, // Pass in an empty stream so we inherit the top
- // input reader output stream
- empty_stream_sp, // Pass in an empty stream so we inherit the top
- // input reader error stream
- flags,
- nullptr, // Pass in NULL for "editline_name" so no history is saved,
- // or written
- debugger.GetPrompt(), llvm::StringRef(),
- false, // Not multi-line
- debugger.GetUseColor(), 0, *this));
- const bool old_async_execution = debugger.GetAsyncExecution();
-
- // Set synchronous execution if we are not stopping on continue
- if ((flags & eHandleCommandFlagStopOnContinue) == 0)
- debugger.SetAsyncExecution(false);
-
- m_command_source_depth++;
-
- debugger.RunIOHandler(io_handler_sp);
- if (!m_command_source_flags.empty())
- m_command_source_flags.pop_back();
- m_command_source_depth--;
- result.SetStatus(eReturnStatusSuccessFinishNoResult);
- debugger.SetAsyncExecution(old_async_execution);
- } else {
- result.AppendErrorWithFormat(
- "error: an error occurred read file '%s': %s\n",
- cmd_file_path.c_str(), error.AsCString());
- result.SetStatus(eReturnStatusFailed);
- }
-
- } else {
+ if (!FileSystem::Instance().Exists(cmd_file)) {
result.AppendErrorWithFormat(
"Error reading commands from file %s - file not found.\n",
cmd_file.GetFilename().AsCString("<Unknown>"));
result.SetStatus(eReturnStatusFailed);
return;
}
-}
-ScriptInterpreter *CommandInterpreter::GetScriptInterpreter(bool can_create) {
- std::lock_guard<std::recursive_mutex> locker(m_script_interpreter_mutex);
- if (!m_script_interpreter_sp) {
- if (!can_create)
- return nullptr;
- lldb::ScriptLanguage script_lang = GetDebugger().GetScriptLanguage();
- m_script_interpreter_sp =
- PluginManager::GetScriptInterpreterForLanguage(script_lang, *this);
+ StreamFileSP input_file_sp(new StreamFile());
+ std::string cmd_file_path = cmd_file.GetPath();
+ Status error = FileSystem::Instance().Open(input_file_sp->GetFile(), cmd_file,
+ File::eOpenOptionRead);
+
+ if (error.Fail()) {
+ result.AppendErrorWithFormat(
+ "error: an error occurred read file '%s': %s\n", cmd_file_path.c_str(),
+ error.AsCString());
+ result.SetStatus(eReturnStatusFailed);
+ return;
}
- return m_script_interpreter_sp.get();
+
+ Debugger &debugger = GetDebugger();
+
+ uint32_t flags = 0;
+
+ if (options.m_stop_on_continue == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Stop on continue by default
+ flags |= eHandleCommandFlagStopOnContinue;
+ } else if (m_command_source_flags.back() &
+ eHandleCommandFlagStopOnContinue) {
+ flags |= eHandleCommandFlagStopOnContinue;
+ }
+ } else if (options.m_stop_on_continue == eLazyBoolYes) {
+ flags |= eHandleCommandFlagStopOnContinue;
+ }
+
+ if (options.m_stop_on_error == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ if (GetStopCmdSourceOnError())
+ flags |= eHandleCommandFlagStopOnError;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagStopOnError) {
+ flags |= eHandleCommandFlagStopOnError;
+ }
+ } else if (options.m_stop_on_error == eLazyBoolYes) {
+ flags |= eHandleCommandFlagStopOnError;
+ }
+
+ // stop-on-crash can only be set, if it is present in all levels of
+ // pushed flag sets.
+ if (options.GetStopOnCrash()) {
+ if (m_command_source_flags.empty()) {
+ flags |= eHandleCommandFlagStopOnCrash;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagStopOnCrash) {
+ flags |= eHandleCommandFlagStopOnCrash;
+ }
+ }
+
+ if (options.m_echo_commands == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Echo command by default
+ flags |= eHandleCommandFlagEchoCommand;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagEchoCommand) {
+ flags |= eHandleCommandFlagEchoCommand;
+ }
+ } else if (options.m_echo_commands == eLazyBoolYes) {
+ flags |= eHandleCommandFlagEchoCommand;
+ }
+
+ // We will only ever ask for this flag, if we echo commands in general.
+ if (options.m_echo_comment_commands == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Echo comments by default
+ flags |= eHandleCommandFlagEchoCommentCommand;
+ } else if (m_command_source_flags.back() &
+ eHandleCommandFlagEchoCommentCommand) {
+ flags |= eHandleCommandFlagEchoCommentCommand;
+ }
+ } else if (options.m_echo_comment_commands == eLazyBoolYes) {
+ flags |= eHandleCommandFlagEchoCommentCommand;
+ }
+
+ if (options.m_print_results == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Print output by default
+ flags |= eHandleCommandFlagPrintResult;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagPrintResult) {
+ flags |= eHandleCommandFlagPrintResult;
+ }
+ } else if (options.m_print_results == eLazyBoolYes) {
+ flags |= eHandleCommandFlagPrintResult;
+ }
+
+ if (options.m_print_errors == eLazyBoolCalculate) {
+ if (m_command_source_flags.empty()) {
+ // Print output by default
+ flags |= eHandleCommandFlagPrintErrors;
+ } else if (m_command_source_flags.back() & eHandleCommandFlagPrintErrors) {
+ flags |= eHandleCommandFlagPrintErrors;
+ }
+ } else if (options.m_print_errors == eLazyBoolYes) {
+ flags |= eHandleCommandFlagPrintErrors;
+ }
+
+ if (flags & eHandleCommandFlagPrintResult) {
+ debugger.GetOutputFile()->Printf("Executing commands in '%s'.\n",
+ cmd_file_path.c_str());
+ }
+
+ // Used for inheriting the right settings when "command source" might
+ // have nested "command source" commands
+ lldb::StreamFileSP empty_stream_sp;
+ m_command_source_flags.push_back(flags);
+ IOHandlerSP io_handler_sp(new IOHandlerEditline(
+ debugger, IOHandler::Type::CommandInterpreter, input_file_sp,
+ empty_stream_sp, // Pass in an empty stream so we inherit the top
+ // input reader output stream
+ empty_stream_sp, // Pass in an empty stream so we inherit the top
+ // input reader error stream
+ flags,
+ nullptr, // Pass in NULL for "editline_name" so no history is saved,
+ // or written
+ debugger.GetPrompt(), llvm::StringRef(),
+ false, // Not multi-line
+ debugger.GetUseColor(), 0, *this, nullptr));
+ const bool old_async_execution = debugger.GetAsyncExecution();
+
+ // Set synchronous execution if we are not stopping on continue
+ if ((flags & eHandleCommandFlagStopOnContinue) == 0)
+ debugger.SetAsyncExecution(false);
+
+ m_command_source_depth++;
+
+ debugger.RunIOHandler(io_handler_sp);
+ if (!m_command_source_flags.empty())
+ m_command_source_flags.pop_back();
+ m_command_source_depth--;
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
+ debugger.SetAsyncExecution(old_async_execution);
}
bool CommandInterpreter::GetSynchronous() { return m_synchronous_execution; }
@@ -2588,7 +2615,7 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text,
uint32_t chars_left = max_columns;
auto nextWordLength = [](llvm::StringRef S) {
- size_t pos = S.find_first_of(' ');
+ size_t pos = S.find(' ');
return pos == llvm::StringRef::npos ? S.size() : pos;
};
@@ -2801,7 +2828,9 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
HandleCommand(line.c_str(), eLazyBoolCalculate, result);
// Now emit the command output text from the command we just executed
- if (io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) {
+ if ((result.Succeeded() &&
+ io_handler.GetFlags().Test(eHandleCommandFlagPrintResult)) ||
+ io_handler.GetFlags().Test(eHandleCommandFlagPrintErrors)) {
// Display any STDOUT/STDERR _prior_ to emitting the command result text
GetProcessOutput();
@@ -2885,7 +2914,8 @@ bool CommandInterpreter::IOHandlerInterrupt(IOHandler &io_handler) {
}
}
- ScriptInterpreter *script_interpreter = GetScriptInterpreter(false);
+ ScriptInterpreter *script_interpreter =
+ m_debugger.GetScriptInterpreter(false);
if (script_interpreter) {
if (script_interpreter->Interrupt())
return true;
@@ -2904,8 +2934,9 @@ void CommandInterpreter::GetLLDBCommandsFromIOHandler(
llvm::StringRef(), // Continuation prompt
true, // Get multiple lines
debugger.GetUseColor(),
- 0, // Don't show line numbers
- delegate)); // IOHandlerDelegate
+ 0, // Don't show line numbers
+ delegate, // IOHandlerDelegate
+ nullptr)); // FileShadowCollector
if (io_handler_sp) {
io_handler_sp->SetUserData(baton);
@@ -2927,8 +2958,9 @@ void CommandInterpreter::GetPythonCommandsFromIOHandler(
llvm::StringRef(), // Continuation prompt
true, // Get multiple lines
debugger.GetUseColor(),
- 0, // Don't show line numbers
- delegate)); // IOHandlerDelegate
+ 0, // Don't show line numbers
+ delegate, // IOHandlerDelegate
+ nullptr)); // FileShadowCollector
if (io_handler_sp) {
io_handler_sp->SetUserData(baton);
@@ -2968,19 +3000,23 @@ CommandInterpreter::GetIOHandler(bool force_create,
flags |= eHandleCommandFlagEchoCommentCommand;
if (options->m_print_results != eLazyBoolNo)
flags |= eHandleCommandFlagPrintResult;
+ if (options->m_print_errors != eLazyBoolNo)
+ flags |= eHandleCommandFlagPrintErrors;
} else {
- flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult;
+ flags = eHandleCommandFlagEchoCommand | eHandleCommandFlagPrintResult |
+ eHandleCommandFlagPrintErrors;
}
- m_command_io_handler_sp.reset(new IOHandlerEditline(
+ m_command_io_handler_sp = std::make_shared<IOHandlerEditline>(
m_debugger, IOHandler::Type::CommandInterpreter,
m_debugger.GetInputFile(), m_debugger.GetOutputFile(),
m_debugger.GetErrorFile(), flags, "lldb", m_debugger.GetPrompt(),
llvm::StringRef(), // Continuation prompt
false, // Don't enable multiple line input, just single line commands
m_debugger.GetUseColor(),
- 0, // Don't show line numbers
- *this));
+ 0, // Don't show line numbers
+ *this, // IOHandlerDelegate
+ GetDebugger().GetInputRecorder());
}
return m_command_io_handler_sp;
}
@@ -3170,7 +3206,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
if (!scratch_command.empty())
revised_command_line.Printf(" %s", scratch_command.c_str());
- if (cmd_obj != NULL)
+ if (cmd_obj != nullptr)
command_line = revised_command_line.GetString();
return cmd_obj;
diff --git a/source/Interpreter/CommandObject.cpp b/source/Interpreter/CommandObject.cpp
index 05c540b37c62f..8e493c7a326f0 100644
--- a/source/Interpreter/CommandObject.cpp
+++ b/source/Interpreter/CommandObject.cpp
@@ -1,9 +1,8 @@
//===-- CommandObject.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,9 +35,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObject
-//-------------------------------------------------------------------------
CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef name,
llvm::StringRef help, llvm::StringRef syntax, uint32_t flags)
@@ -52,6 +49,8 @@ CommandObject::CommandObject(CommandInterpreter &interpreter, llvm::StringRef na
CommandObject::~CommandObject() {}
+Debugger &CommandObject::GetDebugger() { return m_interpreter.GetDebugger(); }
+
llvm::StringRef CommandObject::GetHelp() { return m_cmd_help_short; }
llvm::StringRef CommandObject::GetHelpLong() { return m_cmd_help_long; }
@@ -137,17 +136,15 @@ bool CommandObject::ParseOptions(Args &args, CommandReturnObject &result) {
}
bool CommandObject::CheckRequirements(CommandReturnObject &result) {
-#ifdef LLDB_CONFIGURATION_DEBUG
// Nothing should be stored in m_exe_ctx between running commands as
// m_exe_ctx has shared pointers to the target, process, thread and frame and
// we don't want any CommandObject instances to keep any of these objects
// around longer than for a single command. Every command should call
- // CommandObject::Cleanup() after it has completed
- assert(m_exe_ctx.GetTargetPtr() == NULL);
- assert(m_exe_ctx.GetProcessPtr() == NULL);
- assert(m_exe_ctx.GetThreadPtr() == NULL);
- assert(m_exe_ctx.GetFramePtr() == NULL);
-#endif
+ // CommandObject::Cleanup() after it has completed.
+ assert(!m_exe_ctx.GetTargetPtr());
+ assert(!m_exe_ctx.GetProcessPtr());
+ assert(!m_exe_ctx.GetThreadPtr());
+ assert(!m_exe_ctx.GetFramePtr());
// Lock down the interpreter's execution context prior to running the command
// so we guarantee the selected target, process, thread and frame can't go
@@ -1106,7 +1103,8 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
const CommandObject::ArgumentTableEntry *CommandObject::GetArgumentTable() {
// If this assertion fires, then the table above is out of date with the
// CommandArgumentType enumeration
- assert((sizeof(CommandObject::g_arguments_data) /
- sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg);
+ static_assert((sizeof(CommandObject::g_arguments_data) /
+ sizeof(CommandObject::ArgumentTableEntry)) == eArgTypeLastArg,
+ "");
return CommandObject::g_arguments_data;
}
diff --git a/source/Interpreter/CommandObjectRegexCommand.cpp b/source/Interpreter/CommandObjectRegexCommand.cpp
index 2944177b0dc3a..19335b95ca3af 100644
--- a/source/Interpreter/CommandObjectRegexCommand.cpp
+++ b/source/Interpreter/CommandObjectRegexCommand.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectRegexCommand.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// CommandObjectRegexCommand constructor
-//----------------------------------------------------------------------
CommandObjectRegexCommand::CommandObjectRegexCommand(
CommandInterpreter &interpreter, llvm::StringRef name, llvm::StringRef help,
llvm::StringRef syntax, uint32_t max_matches, uint32_t completion_type_mask,
@@ -26,9 +23,7 @@ CommandObjectRegexCommand::CommandObjectRegexCommand(
m_max_matches(max_matches), m_completion_type_mask(completion_type_mask),
m_entries(), m_is_removable(is_removable) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
CommandObjectRegexCommand::~CommandObjectRegexCommand() {}
bool CommandObjectRegexCommand::DoExecute(llvm::StringRef command,
diff --git a/source/Interpreter/CommandObjectScript.cpp b/source/Interpreter/CommandObjectScript.cpp
index ed434031ae4e4..edb1f67e7b376 100644
--- a/source/Interpreter/CommandObjectScript.cpp
+++ b/source/Interpreter/CommandObjectScript.cpp
@@ -1,9 +1,8 @@
//===-- CommandObjectScript.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// CommandObjectScript
-//-------------------------------------------------------------------------
CommandObjectScript::CommandObjectScript(CommandInterpreter &interpreter,
ScriptLanguage script_lang)
@@ -53,7 +50,7 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
return false;
}
- ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter();
+ ScriptInterpreter *script_interpreter = GetDebugger().GetScriptInterpreter();
if (script_interpreter == nullptr) {
result.AppendError("no script interpreter");
diff --git a/source/Interpreter/CommandObjectScript.h b/source/Interpreter/CommandObjectScript.h
index ca453a8754940..4f7a912979bf9 100644
--- a/source/Interpreter/CommandObjectScript.h
+++ b/source/Interpreter/CommandObjectScript.h
@@ -1,9 +1,8 @@
//===-- CommandObjectScript.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
-//-------------------------------------------------------------------------
// CommandObjectScript
-//-------------------------------------------------------------------------
class CommandObjectScript : public CommandObjectRaw {
public:
diff --git a/source/Interpreter/CommandOptionValidators.cpp b/source/Interpreter/CommandOptionValidators.cpp
index 1e614a958c767..c41c1566aab9e 100644
--- a/source/Interpreter/CommandOptionValidators.cpp
+++ b/source/Interpreter/CommandOptionValidators.cpp
@@ -1,9 +1,8 @@
//===-- CommandOptionValidators.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/CommandReturnObject.cpp b/source/Interpreter/CommandReturnObject.cpp
index cf397a47a3bf4..3a7a8755d9755 100644
--- a/source/Interpreter/CommandReturnObject.cpp
+++ b/source/Interpreter/CommandReturnObject.cpp
@@ -1,9 +1,8 @@
//===-- CommandReturnObject.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionArgParser.cpp b/source/Interpreter/OptionArgParser.cpp
index b0565b706c5b1..efaac0720fd0c 100644
--- a/source/Interpreter/OptionArgParser.cpp
+++ b/source/Interpreter/OptionArgParser.cpp
@@ -1,9 +1,8 @@
//===-- OptionArgParser.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupArchitecture.cpp b/source/Interpreter/OptionGroupArchitecture.cpp
index 42eafc9872dbe..2ee1a9c7cf846 100644
--- a/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/source/Interpreter/OptionGroupArchitecture.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupBoolean.cpp b/source/Interpreter/OptionGroupBoolean.cpp
index ca694ef5f4888..8a6482c8df25a 100644
--- a/source/Interpreter/OptionGroupBoolean.cpp
+++ b/source/Interpreter/OptionGroupBoolean.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupBoolean.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupFile.cpp b/source/Interpreter/OptionGroupFile.cpp
index 241bad022ba7a..cda75ec205ec4 100644
--- a/source/Interpreter/OptionGroupFile.cpp
+++ b/source/Interpreter/OptionGroupFile.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupFile.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupFormat.cpp b/source/Interpreter/OptionGroupFormat.cpp
index 6345a633635c3..d9acfd663dd1e 100644
--- a/source/Interpreter/OptionGroupFormat.cpp
+++ b/source/Interpreter/OptionGroupFormat.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupFormat.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupOutputFile.cpp b/source/Interpreter/OptionGroupOutputFile.cpp
index aebbf05131a00..ccb99a8fce4a6 100644
--- a/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/source/Interpreter/OptionGroupOutputFile.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupPlatform.cpp b/source/Interpreter/OptionGroupPlatform.cpp
index 5858fcc4aa482..6dc2996bb78a4 100644
--- a/source/Interpreter/OptionGroupPlatform.cpp
+++ b/source/Interpreter/OptionGroupPlatform.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupString.cpp b/source/Interpreter/OptionGroupString.cpp
index 1b1fbdf4f6ed6..c01b7065fbd09 100644
--- a/source/Interpreter/OptionGroupString.cpp
+++ b/source/Interpreter/OptionGroupString.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupString.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupUInt64.cpp b/source/Interpreter/OptionGroupUInt64.cpp
index bb2dcbbd23f91..53e5674d0296d 100644
--- a/source/Interpreter/OptionGroupUInt64.cpp
+++ b/source/Interpreter/OptionGroupUInt64.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupUInt64.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupUUID.cpp b/source/Interpreter/OptionGroupUUID.cpp
index 0859877774cc7..e32673bc52af6 100644
--- a/source/Interpreter/OptionGroupUUID.cpp
+++ b/source/Interpreter/OptionGroupUUID.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupUUID.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 40f219c8ab861..4e5463a4de00f 100644
--- a/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupValueObjectDisplay.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupVariable.cpp b/source/Interpreter/OptionGroupVariable.cpp
index f90212cfcb2f5..d703c3dedcd97 100644
--- a/source/Interpreter/OptionGroupVariable.cpp
+++ b/source/Interpreter/OptionGroupVariable.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupVariable.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionGroupWatchpoint.cpp b/source/Interpreter/OptionGroupWatchpoint.cpp
index 36b4cc5ac4f62..28e6b817fcc5a 100644
--- a/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -1,9 +1,8 @@
//===-- OptionGroupWatchpoint.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValue.cpp b/source/Interpreter/OptionValue.cpp
index 4e480dd5784ba..00c8642595b72 100644
--- a/source/Interpreter/OptionValue.cpp
+++ b/source/Interpreter/OptionValue.cpp
@@ -1,9 +1,8 @@
//===-- OptionValue.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,10 +14,8 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// 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 OptionValue::GetUInt64Value(uint64_t fail_value, bool *success_ptr) {
if (success_ptr)
*success_ptr = true;
@@ -168,13 +165,13 @@ const OptionValueFormat *OptionValue::GetAsFormat() const {
OptionValueLanguage *OptionValue::GetAsLanguage() {
if (GetType() == OptionValue::eTypeLanguage)
return static_cast<OptionValueLanguage *>(this);
- return NULL;
+ return nullptr;
}
const OptionValueLanguage *OptionValue::GetAsLanguage() const {
if (GetType() == OptionValue::eTypeLanguage)
return static_cast<const OptionValueLanguage *>(this);
- return NULL;
+ return nullptr;
}
OptionValueFormatEntity *OptionValue::GetAsFormatEntity() {
@@ -523,7 +520,7 @@ lldb::OptionValueSP OptionValue::CreateValueFromCStringForTypeMask(
value_sp.reset(new OptionValueFormat(eFormatInvalid));
break;
case 1u << eTypeFormatEntity:
- value_sp.reset(new OptionValueFormatEntity(NULL));
+ value_sp.reset(new OptionValueFormatEntity(nullptr));
break;
case 1u << eTypeLanguage:
value_sp.reset(new OptionValueLanguage(eLanguageTypeUnknown));
diff --git a/source/Interpreter/OptionValueArch.cpp b/source/Interpreter/OptionValueArch.cpp
index e4f0b9dd0df01..92dc45d092bee 100644
--- a/source/Interpreter/OptionValueArch.cpp
+++ b/source/Interpreter/OptionValueArch.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueArgs.cpp b/source/Interpreter/OptionValueArgs.cpp
index 4fa9e187668dd..d619dba5678aa 100644
--- a/source/Interpreter/OptionValueArgs.cpp
+++ b/source/Interpreter/OptionValueArgs.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueArgs.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueArray.cpp b/source/Interpreter/OptionValueArray.cpp
index d755fa2fddb92..30902c0f295a5 100644
--- a/source/Interpreter/OptionValueArray.cpp
+++ b/source/Interpreter/OptionValueArray.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueArray.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueBoolean.cpp b/source/Interpreter/OptionValueBoolean.cpp
index a7fe10e794317..8be8220fb3066 100644
--- a/source/Interpreter/OptionValueBoolean.cpp
+++ b/source/Interpreter/OptionValueBoolean.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueBoolean.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueChar.cpp b/source/Interpreter/OptionValueChar.cpp
index 1307b47a71349..23012e6e2ec3f 100644
--- a/source/Interpreter/OptionValueChar.cpp
+++ b/source/Interpreter/OptionValueChar.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueChar.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueDictionary.cpp b/source/Interpreter/OptionValueDictionary.cpp
index 5058064f1ca2e..eb66c485bfd17 100644
--- a/source/Interpreter/OptionValueDictionary.cpp
+++ b/source/Interpreter/OptionValueDictionary.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueDictionary.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -277,7 +276,7 @@ Status OptionValueDictionary::SetSubValue(const ExecutionContext *exe_ctx,
}
lldb::OptionValueSP
-OptionValueDictionary::GetValueForKey(const ConstString &key) const {
+OptionValueDictionary::GetValueForKey(ConstString key) const {
lldb::OptionValueSP value_sp;
collection::const_iterator pos = m_values.find(key);
if (pos != m_values.end())
@@ -285,7 +284,7 @@ OptionValueDictionary::GetValueForKey(const ConstString &key) const {
return value_sp;
}
-bool OptionValueDictionary::SetValueForKey(const ConstString &key,
+bool OptionValueDictionary::SetValueForKey(ConstString key,
const lldb::OptionValueSP &value_sp,
bool can_replace) {
// Make sure the value_sp object is allowed to contain values of the type
@@ -302,7 +301,7 @@ bool OptionValueDictionary::SetValueForKey(const ConstString &key,
return false;
}
-bool OptionValueDictionary::DeleteValueForKey(const ConstString &key) {
+bool OptionValueDictionary::DeleteValueForKey(ConstString key) {
collection::iterator pos = m_values.find(key);
if (pos != m_values.end()) {
m_values.erase(pos);
diff --git a/source/Interpreter/OptionValueEnumeration.cpp b/source/Interpreter/OptionValueEnumeration.cpp
index e65dd2b67831e..0b76bd0601aaf 100644
--- a/source/Interpreter/OptionValueEnumeration.cpp
+++ b/source/Interpreter/OptionValueEnumeration.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueEnumeration.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueFileSpec.cpp b/source/Interpreter/OptionValueFileSpec.cpp
index 735a7d86334d3..062d7ccdf2aa1 100644
--- a/source/Interpreter/OptionValueFileSpec.cpp
+++ b/source/Interpreter/OptionValueFileSpec.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFileSpec.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueFileSpecLIst.cpp b/source/Interpreter/OptionValueFileSpecLIst.cpp
index fd78bba94fef2..a95188870f0b2 100644
--- a/source/Interpreter/OptionValueFileSpecLIst.cpp
+++ b/source/Interpreter/OptionValueFileSpecLIst.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFileSpecLIst.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,7 @@ using namespace lldb_private;
void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
Stream &strm, uint32_t dump_mask) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
if (dump_mask & eDumpOptionType)
strm.Printf("(%s)", GetTypeAsCString());
if (dump_mask & eDumpOptionValue) {
@@ -44,6 +44,7 @@ void OptionValueFileSpecList::DumpValue(const ExecutionContext *exe_ctx,
Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
VarSetOperationType op) {
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
Status error;
Args args(value.str());
const size_t argc = args.GetArgumentCount();
@@ -164,5 +165,6 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
}
lldb::OptionValueSP OptionValueFileSpecList::DeepCopy() const {
- return OptionValueSP(new OptionValueFileSpecList(*this));
+ std::lock_guard<std::recursive_mutex> lock(m_mutex);
+ return OptionValueSP(new OptionValueFileSpecList(m_current_value));
}
diff --git a/source/Interpreter/OptionValueFormat.cpp b/source/Interpreter/OptionValueFormat.cpp
index 945d8bd336150..ba5a44c270da9 100644
--- a/source/Interpreter/OptionValueFormat.cpp
+++ b/source/Interpreter/OptionValueFormat.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFormat.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueFormatEntity.cpp b/source/Interpreter/OptionValueFormatEntity.cpp
index 18783625b86f7..1bb8c9f6955ab 100644
--- a/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/source/Interpreter/OptionValueFormatEntity.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueFormatEntity.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueLanguage.cpp b/source/Interpreter/OptionValueLanguage.cpp
index c6e168d66b4fa..d935d5e23496d 100644
--- a/source/Interpreter/OptionValueLanguage.cpp
+++ b/source/Interpreter/OptionValueLanguage.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueLanguage.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValuePathMappings.cpp b/source/Interpreter/OptionValuePathMappings.cpp
index 11ec739c5bb9a..75fcf02474758 100644
--- a/source/Interpreter/OptionValuePathMappings.cpp
+++ b/source/Interpreter/OptionValuePathMappings.cpp
@@ -1,9 +1,8 @@
//===-- OptionValuePathMappings.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueProperties.cpp b/source/Interpreter/OptionValueProperties.cpp
index 327d26b09ebb0..4dae930c3a6f4 100644
--- a/source/Interpreter/OptionValueProperties.cpp
+++ b/source/Interpreter/OptionValueProperties.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueProperties.cpp --------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@
using namespace lldb;
using namespace lldb_private;
-OptionValueProperties::OptionValueProperties(const ConstString &name)
+OptionValueProperties::OptionValueProperties(ConstString name)
: OptionValue(), m_name(name), m_properties(), m_name_to_index() {}
OptionValueProperties::OptionValueProperties(
@@ -67,8 +66,8 @@ void OptionValueProperties::SetValueChangedCallback(
property->SetValueChangedCallback(callback, baton);
}
-void OptionValueProperties::AppendProperty(const ConstString &name,
- const ConstString &desc,
+void OptionValueProperties::AppendProperty(ConstString name,
+ ConstString desc,
bool is_global,
const OptionValueSP &value_sp) {
Property property(name, desc, is_global, value_sp);
@@ -99,7 +98,7 @@ void OptionValueProperties::AppendProperty(const ConstString &name,
//
lldb::OptionValueSP
OptionValueProperties::GetValueForKey(const ExecutionContext *exe_ctx,
- const ConstString &key,
+ ConstString key,
bool will_modify) const {
lldb::OptionValueSP value_sp;
size_t idx = m_name_to_index.Find(key, SIZE_MAX);
@@ -160,7 +159,7 @@ OptionValueProperties::GetSubValue(const ExecutionContext *exe_ctx,
// args if executable basename is "test" and arch is "x86_64"
if (sub_name[1]) {
llvm::StringRef predicate_start = sub_name.drop_front();
- size_t pos = predicate_start.find_first_of('}');
+ size_t pos = predicate_start.find('}');
if (pos != llvm::StringRef::npos) {
auto predicate = predicate_start.take_front(pos);
auto rest = predicate_start.drop_front(pos);
@@ -205,7 +204,6 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
if (Properties::IsSettingExperimental(part))
name_contains_experimental = true;
-
lldb::OptionValueSP value_sp(GetSubValue(exe_ctx, name, will_modify, error));
if (value_sp)
error = value_sp->SetValueFromString(value, op);
@@ -220,14 +218,14 @@ Status OptionValueProperties::SetSubValue(const ExecutionContext *exe_ctx,
}
uint32_t
-OptionValueProperties::GetPropertyIndex(const ConstString &name) const {
+OptionValueProperties::GetPropertyIndex(ConstString name) const {
return m_name_to_index.Find(name, SIZE_MAX);
}
const Property *
OptionValueProperties::GetProperty(const ExecutionContext *exe_ctx,
bool will_modify,
- const ConstString &name) const {
+ ConstString name) const {
return GetPropertyAtIndex(
exe_ctx, will_modify,
m_name_to_index.Find(name, SIZE_MAX));
@@ -668,7 +666,7 @@ void OptionValueProperties::Apropos(
lldb::OptionValuePropertiesSP
OptionValueProperties::GetSubProperty(const ExecutionContext *exe_ctx,
- const ConstString &name) {
+ ConstString name) {
lldb::OptionValueSP option_value_sp(GetValueForKey(exe_ctx, name, false));
if (option_value_sp) {
OptionValueProperties *ov_properties = option_value_sp->GetAsProperties();
diff --git a/source/Interpreter/OptionValueRegex.cpp b/source/Interpreter/OptionValueRegex.cpp
index 3c06ff3957b01..bbe3fa7150199 100644
--- a/source/Interpreter/OptionValueRegex.cpp
+++ b/source/Interpreter/OptionValueRegex.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueRegex.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueSInt64.cpp b/source/Interpreter/OptionValueSInt64.cpp
index c087c3ee24be8..d26fc08a31320 100644
--- a/source/Interpreter/OptionValueSInt64.cpp
+++ b/source/Interpreter/OptionValueSInt64.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueSInt64.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueString.cpp b/source/Interpreter/OptionValueString.cpp
index c89a0c6bf4048..a519249ab4728 100644
--- a/source/Interpreter/OptionValueString.cpp
+++ b/source/Interpreter/OptionValueString.cpp
@@ -1,10 +1,9 @@
//===-- OptionValueString.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueUInt64.cpp b/source/Interpreter/OptionValueUInt64.cpp
index 053b5798880ea..3be0772daa8c6 100644
--- a/source/Interpreter/OptionValueUInt64.cpp
+++ b/source/Interpreter/OptionValueUInt64.cpp
@@ -1,10 +1,9 @@
//===-- OptionValueUInt64.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/OptionValueUUID.cpp b/source/Interpreter/OptionValueUUID.cpp
index 5518a0574112a..f39b66b77bb0f 100644
--- a/source/Interpreter/OptionValueUUID.cpp
+++ b/source/Interpreter/OptionValueUUID.cpp
@@ -1,9 +1,8 @@
//===-- OptionValueUUID.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Interpreter/Options.cpp b/source/Interpreter/Options.cpp
index c6357399a7e26..ba15c020f2daa 100644
--- a/source/Interpreter/Options.cpp
+++ b/source/Interpreter/Options.cpp
@@ -1,9 +1,8 @@
//===-- Options.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@
using namespace lldb;
using namespace lldb_private;
-//-------------------------------------------------------------------------
// Options
-//-------------------------------------------------------------------------
Options::Options() : m_getopt_table() { BuildValidOptionSets(); }
Options::~Options() {}
@@ -761,7 +758,7 @@ bool Options::HandleOptionArgumentCompletion(
CompletionRequest &request, OptionElementVector &opt_element_vector,
int opt_element_index, CommandInterpreter &interpreter) {
auto opt_defs = GetDefinitions();
- std::unique_ptr<SearchFilter> filter_ap;
+ std::unique_ptr<SearchFilter> filter_up;
int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
@@ -832,7 +829,7 @@ bool Options::HandleOptionArgumentCompletion(
interpreter.GetDebugger().GetSelectedTarget();
// Search filters require a target...
if (target_sp)
- filter_ap.reset(new SearchFilterByModule(target_sp, module_spec));
+ filter_up.reset(new SearchFilterByModule(target_sp, module_spec));
}
break;
}
@@ -840,7 +837,7 @@ bool Options::HandleOptionArgumentCompletion(
}
return CommandCompletions::InvokeCommonCompletionCallbacks(
- interpreter, completion_mask, request, filter_ap.get());
+ interpreter, completion_mask, request, filter_up.get());
}
void OptionGroupOptions::Append(OptionGroup *group) {
@@ -933,6 +930,7 @@ static std::vector<char *> GetArgvForParsing(const Args &args) {
result.push_back(const_cast<char *>("<FAKE-ARG0>"));
for (const Args::ArgEntry &entry : args)
result.push_back(const_cast<char *>(entry.c_str()));
+ result.push_back(nullptr);
return result;
}
@@ -975,19 +973,15 @@ static size_t FindArgumentIndexForOption(const Args &args,
return size_t(-1);
}
-llvm::Expected<Args> Options::ParseAlias(const Args &args,
- OptionArgVector *option_arg_vector,
- std::string &input_line) {
- StreamString sstr;
- int i;
- Option *long_options = GetLongOptions();
+static std::string BuildShortOptions(const Option *long_options) {
+ std::string storage;
+ llvm::raw_string_ostream sstr(storage);
- if (long_options == nullptr) {
- return llvm::make_error<llvm::StringError>("Invalid long options",
- llvm::inconvertibleErrorCode());
- }
+ // Leading : tells getopt to return a : for a missing option argument AND to
+ // suppress error messages.
+ sstr << ":";
- for (i = 0; long_options[i].definition != nullptr; ++i) {
+ for (size_t i = 0; long_options[i].definition != nullptr; ++i) {
if (long_options[i].flag == nullptr) {
sstr << (char)long_options[i].val;
switch (long_options[i].definition->option_has_arg) {
@@ -1003,6 +997,20 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
}
}
}
+ return std::move(sstr.str());
+}
+
+llvm::Expected<Args> Options::ParseAlias(const Args &args,
+ OptionArgVector *option_arg_vector,
+ std::string &input_line) {
+ Option *long_options = GetLongOptions();
+
+ if (long_options == nullptr) {
+ return llvm::make_error<llvm::StringError>("Invalid long options",
+ llvm::inconvertibleErrorCode());
+ }
+
+ std::string short_options = BuildShortOptions(long_options);
Args args_copy = args;
std::vector<char *> argv = GetArgvForParsing(args);
@@ -1010,10 +1018,15 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
int val;
- while (1) {
+ while (true) {
int long_options_index = -1;
- val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
- long_options, &long_options_index);
+ val = OptionParser::Parse(argv, short_options, long_options,
+ &long_options_index);
+
+ if (val == ':') {
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "last option requires an argument");
+ }
if (val == -1)
break;
@@ -1119,33 +1132,13 @@ llvm::Expected<Args> Options::ParseAlias(const Args &args,
OptionElementVector Options::ParseForCompletion(const Args &args,
uint32_t cursor_index) {
OptionElementVector option_element_vector;
- StreamString sstr;
Option *long_options = GetLongOptions();
option_element_vector.clear();
if (long_options == nullptr)
return option_element_vector;
- // Leading : tells getopt to return a : for a missing option argument AND to
- // suppress error messages.
-
- sstr << ":";
- for (int i = 0; long_options[i].definition != nullptr; ++i) {
- if (long_options[i].flag == nullptr) {
- sstr << (char)long_options[i].val;
- switch (long_options[i].definition->option_has_arg) {
- default:
- case OptionParser::eNoArgument:
- break;
- case OptionParser::eRequiredArgument:
- sstr << ":";
- break;
- case OptionParser::eOptionalArgument:
- sstr << "::";
- break;
- }
- }
- }
+ std::string short_options = BuildShortOptions(long_options);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
@@ -1156,19 +1149,15 @@ OptionElementVector Options::ParseForCompletion(const Args &args,
std::vector<char *> dummy_vec = GetArgvForParsing(args);
- // I stick an element on the end of the input, because if the last element
- // is option that requires an argument, getopt_long_only will freak out.
- dummy_vec.push_back(const_cast<char *>("<FAKE-VALUE>"));
-
bool failed_once = false;
uint32_t dash_dash_pos = -1;
- while (1) {
+ while (true) {
bool missing_argument = false;
int long_options_index = -1;
- val = OptionParser::Parse(dummy_vec.size(), &dummy_vec[0], sstr.GetString(),
- long_options, &long_options_index);
+ val = OptionParser::Parse(dummy_vec, short_options, long_options,
+ &long_options_index);
if (val == -1) {
// When we're completing a "--" which is the last option on line,
@@ -1331,7 +1320,6 @@ llvm::Expected<Args> Options::Parse(const Args &args,
ExecutionContext *execution_context,
lldb::PlatformSP platform_sp,
bool require_validation) {
- StreamString sstr;
Status error;
Option *long_options = GetLongOptions();
if (long_options == nullptr) {
@@ -1339,32 +1327,21 @@ llvm::Expected<Args> Options::Parse(const Args &args,
llvm::inconvertibleErrorCode());
}
- for (int i = 0; long_options[i].definition != nullptr; ++i) {
- if (long_options[i].flag == nullptr) {
- if (isprint8(long_options[i].val)) {
- sstr << (char)long_options[i].val;
- switch (long_options[i].definition->option_has_arg) {
- default:
- case OptionParser::eNoArgument:
- break;
- case OptionParser::eRequiredArgument:
- sstr << ':';
- break;
- case OptionParser::eOptionalArgument:
- sstr << "::";
- break;
- }
- }
- }
- }
+ std::string short_options = BuildShortOptions(long_options);
std::vector<char *> argv = GetArgvForParsing(args);
std::unique_lock<std::mutex> lock;
OptionParser::Prepare(lock);
int val;
- while (1) {
+ while (true) {
int long_options_index = -1;
- val = OptionParser::Parse(argv.size(), &*argv.begin(), sstr.GetString(),
- long_options, &long_options_index);
+ val = OptionParser::Parse(argv, short_options, long_options,
+ &long_options_index);
+
+ if (val == ':') {
+ error.SetErrorStringWithFormat("last option requires an argument");
+ break;
+ }
+
if (val == -1)
break;
@@ -1437,10 +1414,12 @@ llvm::Expected<Args> Options::Parse(const Args &args,
} else {
error.SetErrorStringWithFormat("invalid option with value '%i'", val);
}
- if (error.Fail())
- return error.ToError();
}
+ if (error.Fail())
+ return error.ToError();
+
+ argv.pop_back();
argv.erase(argv.begin(), argv.begin() + OptionParser::GetOptionIndex());
return ReconstituteArgsAfterParsing(argv, args);
}
diff --git a/source/Interpreter/Property.cpp b/source/Interpreter/Property.cpp
index 5f1022347cf49..78209311e2e51 100644
--- a/source/Interpreter/Property.cpp
+++ b/source/Interpreter/Property.cpp
@@ -1,9 +1,8 @@
//===-- Property.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,6 +15,8 @@
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Target/Language.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -30,18 +31,20 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_uint_value" is not used
// "definition.default_cstr_value" as a string value that represents the
// default string value for the architecture/triple
- m_value_sp.reset(new OptionValueArch(definition.default_cstr_value));
+ m_value_sp =
+ std::make_shared<OptionValueArch>(definition.default_cstr_value);
break;
case OptionValue::eTypeArgs:
// "definition.default_uint_value" is always a OptionValue::Type
- m_value_sp.reset(new OptionValueArgs());
+ m_value_sp = std::make_shared<OptionValueArgs>();
break;
case OptionValue::eTypeArray:
// "definition.default_uint_value" is always a OptionValue::Type
- m_value_sp.reset(new OptionValueArray(OptionValue::ConvertTypeToMask(
- (OptionValue::Type)definition.default_uint_value)));
+ m_value_sp =
+ std::make_shared<OptionValueArray>(OptionValue::ConvertTypeToMask(
+ (OptionValue::Type)definition.default_uint_value));
break;
case OptionValue::eTypeBoolean:
@@ -50,11 +53,12 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_cstr_value" as a string value that represents the
// default value.
if (definition.default_cstr_value)
- m_value_sp.reset(new OptionValueBoolean(OptionArgParser::ToBoolean(
- llvm::StringRef(definition.default_cstr_value), false, nullptr)));
+ m_value_sp =
+ std::make_shared<OptionValueBoolean>(OptionArgParser::ToBoolean(
+ llvm::StringRef(definition.default_cstr_value), false, nullptr));
else
- m_value_sp.reset(
- new OptionValueBoolean(definition.default_uint_value != 0));
+ m_value_sp = std::make_shared<OptionValueBoolean>(
+ definition.default_uint_value != 0);
break;
case OptionValue::eTypeChar: {
@@ -65,8 +69,9 @@ Property::Property(const PropertyDefinition &definition)
}
case OptionValue::eTypeDictionary:
// "definition.default_uint_value" is always a OptionValue::Type
- m_value_sp.reset(new OptionValueDictionary(OptionValue::ConvertTypeToMask(
- (OptionValue::Type)definition.default_uint_value)));
+ m_value_sp =
+ std::make_shared<OptionValueDictionary>(OptionValue::ConvertTypeToMask(
+ (OptionValue::Type)definition.default_uint_value));
break;
case OptionValue::eTypeEnum:
@@ -101,14 +106,14 @@ Property::Property(const PropertyDefinition &definition)
FileSpec file_spec = FileSpec(definition.default_cstr_value);
if (resolve)
FileSystem::Instance().Resolve(file_spec);
- m_value_sp.reset(new OptionValueFileSpec(file_spec, resolve));
+ m_value_sp = std::make_shared<OptionValueFileSpec>(file_spec, resolve);
break;
}
case OptionValue::eTypeFileSpecList:
// "definition.default_uint_value" is not used for a
// OptionValue::eTypeFileSpecList
- m_value_sp.reset(new OptionValueFileSpecList());
+ m_value_sp = std::make_shared<OptionValueFileSpecList>();
break;
case OptionValue::eTypeFormat:
@@ -123,7 +128,7 @@ Property::Property(const PropertyDefinition &definition)
nullptr);
else
new_format = (Format)definition.default_uint_value;
- m_value_sp.reset(new OptionValueFormat(new_format));
+ m_value_sp = std::make_shared<OptionValueFormat>(new_format);
}
break;
@@ -139,29 +144,30 @@ Property::Property(const PropertyDefinition &definition)
llvm::StringRef(definition.default_cstr_value));
else
new_lang = (LanguageType)definition.default_uint_value;
- m_value_sp.reset(new OptionValueLanguage(new_lang));
+ m_value_sp = std::make_shared<OptionValueLanguage>(new_lang);
}
break;
case OptionValue::eTypeFormatEntity:
// "definition.default_cstr_value" as a string value that represents the
// default
- m_value_sp.reset(
- new OptionValueFormatEntity(definition.default_cstr_value));
+ m_value_sp = std::make_shared<OptionValueFormatEntity>(
+ definition.default_cstr_value);
break;
case OptionValue::eTypePathMap:
// "definition.default_uint_value" tells us if notifications should occur
// for path mappings
- m_value_sp.reset(
- new OptionValuePathMappings(definition.default_uint_value != 0));
+ m_value_sp = std::make_shared<OptionValuePathMappings>(
+ definition.default_uint_value != 0);
break;
case OptionValue::eTypeRegex:
// "definition.default_uint_value" is used to the regular expression flags
// "definition.default_cstr_value" the default regular expression value
// value.
- m_value_sp.reset(new OptionValueRegex(definition.default_cstr_value));
+ m_value_sp =
+ std::make_shared<OptionValueRegex>(definition.default_cstr_value);
break;
case OptionValue::eTypeSInt64:
@@ -169,10 +175,10 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the
// default value.
- m_value_sp.reset(new OptionValueSInt64(
+ m_value_sp = std::make_shared<OptionValueSInt64>(
definition.default_cstr_value
? StringConvert::ToSInt64(definition.default_cstr_value)
- : definition.default_uint_value));
+ : definition.default_uint_value);
break;
case OptionValue::eTypeUInt64:
@@ -180,10 +186,10 @@ Property::Property(const PropertyDefinition &definition)
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the
// default value.
- m_value_sp.reset(new OptionValueUInt64(
+ m_value_sp = std::make_shared<OptionValueUInt64>(
definition.default_cstr_value
? StringConvert::ToUInt64(definition.default_cstr_value)
- : definition.default_uint_value));
+ : definition.default_uint_value);
break;
case OptionValue::eTypeUUID:
@@ -193,7 +199,7 @@ Property::Property(const PropertyDefinition &definition)
UUID uuid;
if (definition.default_cstr_value)
uuid.SetFromStringRef(definition.default_cstr_value);
- m_value_sp.reset(new OptionValueUUID(uuid));
+ m_value_sp = std::make_shared<OptionValueUUID>(uuid);
}
break;
@@ -212,7 +218,7 @@ Property::Property(const PropertyDefinition &definition)
}
}
-Property::Property(const ConstString &name, const ConstString &desc,
+Property::Property(ConstString name, ConstString desc,
bool is_global, const lldb::OptionValueSP &value_sp)
: m_name(name), m_description(desc), m_value_sp(value_sp),
m_is_global(is_global) {}
diff --git a/source/Interpreter/ScriptInterpreter.cpp b/source/Interpreter/ScriptInterpreter.cpp
index 497ad283f1a4a..d04baec76e606 100644
--- a/source/Interpreter/ScriptInterpreter.cpp
+++ b/source/Interpreter/ScriptInterpreter.cpp
@@ -1,9 +1,8 @@
//===-- ScriptInterpreter.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,16 +21,12 @@
using namespace lldb;
using namespace lldb_private;
-ScriptInterpreter::ScriptInterpreter(CommandInterpreter &interpreter,
+ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
lldb::ScriptLanguage script_lang)
- : m_interpreter(interpreter), m_script_lang(script_lang) {}
+ : m_debugger(debugger), m_script_lang(script_lang) {}
ScriptInterpreter::~ScriptInterpreter() {}
-CommandInterpreter &ScriptInterpreter::GetCommandInterpreter() {
- return m_interpreter;
-}
-
void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
std::vector<BreakpointOptions *> &bp_options_vec,
CommandReturnObject &result) {
diff --git a/source/Interpreter/embedded_interpreter.py b/source/Interpreter/embedded_interpreter.py
index c103b7e2e1d32..8a1195d83c6f8 100644
--- a/source/Interpreter/embedded_interpreter.py
+++ b/source/Interpreter/embedded_interpreter.py
@@ -72,6 +72,7 @@ def get_terminal_size(fd):
def readfunc_stdio(prompt):
sys.stdout.write(prompt)
+ sys.stdout.flush()
return sys.stdin.readline().rstrip()
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
index 9055660f2d6c1..362a80be4b0de 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
@@ -1,9 +1,8 @@
//===-- ABIMacOSX_arm.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1317,9 +1316,7 @@ ABIMacOSX_arm::GetRegisterInfoArray(uint32_t &count) {
size_t ABIMacOSX_arm::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABIMacOSX_arm::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
@@ -1605,7 +1602,7 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
r2_reg_info->byte_size +
r3_reg_info->byte_size &&
process_sp) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue r0_reg_value;
@@ -1618,18 +1615,18 @@ ValueObjectSP ABIMacOSX_arm::GetReturnValueObjectImpl(
reg_ctx->ReadRegister(r3_reg_info, r3_reg_value)) {
Status error;
if (r0_reg_value.GetAsMemoryData(r0_reg_info,
- heap_data_ap->GetBytes() + 0,
+ heap_data_up->GetBytes() + 0,
4, byte_order, error) &&
r1_reg_value.GetAsMemoryData(r1_reg_info,
- heap_data_ap->GetBytes() + 4,
+ heap_data_up->GetBytes() + 4,
4, byte_order, error) &&
r2_reg_value.GetAsMemoryData(r2_reg_info,
- heap_data_ap->GetBytes() + 8,
+ heap_data_up->GetBytes() + 8,
4, byte_order, error) &&
r3_reg_value.GetAsMemoryData(r3_reg_info,
- heap_data_ap->GetBytes() + 12,
+ heap_data_up->GetBytes() + 12,
4, byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
byte_order,
process_sp->GetAddressByteSize());
@@ -2046,9 +2043,7 @@ lldb_private::ConstString ABIMacOSX_arm::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABIMacOSX_arm::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
index 94f1e31a1235f..ac9ba00b9d918 100644
--- a/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
+++ b/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h
@@ -1,9 +1,8 @@
//===-- ABIMacOSX_arm.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -64,9 +63,7 @@ public:
bool IsArmv7kProcess() const;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -76,9 +73,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
index d8706c4a9cdd2..368e37213249e 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
@@ -1,9 +1,8 @@
//===-- ABIMacOSX_arm64.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1658,9 +1657,7 @@ ABIMacOSX_arm64::GetRegisterInfoArray(uint32_t &count) {
size_t ABIMacOSX_arm64::GetRedZoneSize() const { return 128; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABIMacOSX_arm64::CreateInstance(ProcessSP process_sp, const ArchSpec &arch) {
@@ -2115,7 +2112,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (!byte_size || *byte_size == 0)
return false;
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
Status error;
@@ -2149,10 +2146,10 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (!reg_ctx->ReadRegister(reg_info, reg_value))
return false;
- // Make sure we have enough room in "heap_data_ap"
- if ((data_offset + *base_byte_size) <= heap_data_ap->GetByteSize()) {
+ // Make sure we have enough room in "heap_data_up"
+ if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_ap->GetBytes() + data_offset, *base_byte_size,
+ reg_info, heap_data_up->GetBytes() + data_offset, *base_byte_size,
byte_order, error);
if (bytes_copied != *base_byte_size)
return false;
@@ -2163,7 +2160,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
}
data.SetByteOrder(byte_order);
data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_ap.release()));
+ data.SetData(DataBufferSP(heap_data_up.release()));
return true;
}
}
@@ -2192,7 +2189,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_ap->GetBytes() + data_offset, curr_byte_size,
+ reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
byte_order, error);
if (bytes_copied == 0)
return false;
@@ -2236,15 +2233,15 @@ static bool LoadValueFromConsecutiveGPRRegisters(
return false;
if (exe_ctx.GetProcessRef().ReadMemory(
- value_addr, heap_data_ap->GetBytes(), heap_data_ap->GetByteSize(),
- error) != heap_data_ap->GetByteSize()) {
+ value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
+ error) != heap_data_up->GetByteSize()) {
return false;
}
}
data.SetByteOrder(byte_order);
data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_ap.release()));
+ data.SetData(DataBufferSP(heap_data_up.release()));
return true;
}
@@ -2296,7 +2293,7 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
if (x1_reg_info) {
if (*byte_size <=
x0_reg_info->byte_size + x1_reg_info->byte_size) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order =
exe_ctx.GetProcessRef().GetByteOrder();
@@ -2306,13 +2303,13 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) {
Status error;
if (x0_reg_value.GetAsMemoryData(
- x0_reg_info, heap_data_ap->GetBytes() + 0, 8,
+ x0_reg_info, heap_data_up->GetBytes() + 0, 8,
byte_order, error) &&
x1_reg_value.GetAsMemoryData(
- x1_reg_info, heap_data_ap->GetBytes() + 8, 8,
+ x1_reg_info, heap_data_up->GetBytes() + 8, 8,
byte_order, error)) {
DataExtractor data(
- DataBufferSP(heap_data_ap.release()), byte_order,
+ DataBufferSP(heap_data_up.release()), byte_order,
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
@@ -2396,16 +2393,16 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
if (v0_info) {
if (*byte_size <= v0_info->byte_size) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(v0_info, reg_value)) {
Status error;
- if (reg_value.GetAsMemoryData(v0_info, heap_data_ap->GetBytes(),
- heap_data_ap->GetByteSize(),
+ if (reg_value.GetAsMemoryData(v0_info, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(),
byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
byte_order,
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
@@ -2440,9 +2437,7 @@ void ABIMacOSX_arm64::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString ABIMacOSX_arm64::GetPluginNameStatic() {
static ConstString g_plugin_name("ABIMacOSX_arm64");
diff --git a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
index 7a9444c775f49..bfacbcd54a944 100644
--- a/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
+++ b/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h
@@ -1,9 +1,8 @@
//===-- ABIMacOSX_arm64.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -66,9 +65,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -76,9 +73,7 @@ public:
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
static lldb_private::ConstString GetPluginNameStatic();
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
index a297bd1473b2b..67371b432ff80 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
@@ -1,9 +1,8 @@
//===-- ABIMacOSX_i386.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -704,9 +703,7 @@ ABIMacOSX_i386::GetRegisterInfoArray(uint32_t &count) {
size_t ABIMacOSX_i386::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABIMacOSX_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -1124,9 +1121,7 @@ lldb_private::ConstString ABIMacOSX_i386::GetPluginNameStatic() {
return g_short_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABIMacOSX_i386::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
index 536132d025869..57def683283fb 100644
--- a/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
+++ b/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h
@@ -1,9 +1,8 @@
//===-- ABIMacOSX_i386.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -69,9 +68,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -79,9 +76,7 @@ public:
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
static lldb_private::ConstString GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
index b93a8525010cc..dd47ac7cbe3cc 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_arm.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1318,9 +1317,7 @@ ABISysV_arm::GetRegisterInfoArray(uint32_t &count) {
size_t ABISysV_arm::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_arm::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -1742,8 +1739,8 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
uint32_t index = 0;
for (index = 0; index < num_children; index++) {
std::string name;
- base_type =
- compiler_type.GetFieldAtIndex(index, name, NULL, NULL, NULL);
+ base_type = compiler_type.GetFieldAtIndex(index, name, nullptr,
+ nullptr, nullptr);
if (base_type.IsFloatingPointType(float_count, is_complex)) {
llvm::Optional<uint64_t> base_byte_size =
@@ -1802,7 +1799,7 @@ ValueObjectSP ABISysV_arm::GetReturnValueObjectImpl(
const RegisterInfo *reg_info =
reg_ctx->GetRegisterInfo(eRegisterKindDWARF, regnum);
- if (reg_info == NULL)
+ if (reg_info == nullptr)
break;
RegisterValue reg_value;
@@ -2150,9 +2147,7 @@ lldb_private::ConstString ABISysV_arm::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_arm::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
index 7f2d658541abf..a0f00c8f227da 100644
--- a/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
+++ b/source/Plugins/ABI/SysV-arm/ABISysV_arm.h
@@ -1,9 +1,8 @@
//===-- ABISysV_arm.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -64,9 +63,7 @@ public:
bool IsArmHardFloat(lldb_private::Thread &thread) const;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -76,9 +73,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
index dd3f47303be50..1d547121e231e 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_arm64.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1661,9 +1660,7 @@ bool ABISysV_arm64::GetPointerReturnRegister(const char *&name) {
size_t ABISysV_arm64::GetRedZoneSize() const { return 128; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_arm64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -2091,7 +2088,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (byte_size || *byte_size == 0)
return false;
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
Status error;
@@ -2125,10 +2122,10 @@ static bool LoadValueFromConsecutiveGPRRegisters(
if (!reg_ctx->ReadRegister(reg_info, reg_value))
return false;
- // Make sure we have enough room in "heap_data_ap"
- if ((data_offset + *base_byte_size) <= heap_data_ap->GetByteSize()) {
+ // Make sure we have enough room in "heap_data_up"
+ if ((data_offset + *base_byte_size) <= heap_data_up->GetByteSize()) {
const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_ap->GetBytes() + data_offset, *base_byte_size,
+ reg_info, heap_data_up->GetBytes() + data_offset, *base_byte_size,
byte_order, error);
if (bytes_copied != *base_byte_size)
return false;
@@ -2139,7 +2136,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
}
data.SetByteOrder(byte_order);
data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_ap.release()));
+ data.SetData(DataBufferSP(heap_data_up.release()));
return true;
}
}
@@ -2164,7 +2161,7 @@ static bool LoadValueFromConsecutiveGPRRegisters(
const size_t curr_byte_size = std::min<size_t>(8, bytes_left);
const size_t bytes_copied = reg_value.GetAsMemoryData(
- reg_info, heap_data_ap->GetBytes() + data_offset, curr_byte_size,
+ reg_info, heap_data_up->GetBytes() + data_offset, curr_byte_size,
byte_order, error);
if (bytes_copied == 0)
return false;
@@ -2205,15 +2202,15 @@ static bool LoadValueFromConsecutiveGPRRegisters(
return false;
if (exe_ctx.GetProcessRef().ReadMemory(
- value_addr, heap_data_ap->GetBytes(), heap_data_ap->GetByteSize(),
- error) != heap_data_ap->GetByteSize()) {
+ value_addr, heap_data_up->GetBytes(), heap_data_up->GetByteSize(),
+ error) != heap_data_up->GetByteSize()) {
return false;
}
}
data.SetByteOrder(byte_order);
data.SetAddressByteSize(exe_ctx.GetProcessRef().GetAddressByteSize());
- data.SetData(DataBufferSP(heap_data_ap.release()));
+ data.SetData(DataBufferSP(heap_data_up.release()));
return true;
}
@@ -2267,7 +2264,7 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
if (x1_reg_info) {
if (*byte_size <=
x0_reg_info->byte_size + x1_reg_info->byte_size) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order =
exe_ctx.GetProcessRef().GetByteOrder();
@@ -2277,13 +2274,13 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
reg_ctx->ReadRegister(x1_reg_info, x1_reg_value)) {
Status error;
if (x0_reg_value.GetAsMemoryData(
- x0_reg_info, heap_data_ap->GetBytes() + 0, 8,
+ x0_reg_info, heap_data_up->GetBytes() + 0, 8,
byte_order, error) &&
x1_reg_value.GetAsMemoryData(
- x1_reg_info, heap_data_ap->GetBytes() + 8, 8,
+ x1_reg_info, heap_data_up->GetBytes() + 8, 8,
byte_order, error)) {
DataExtractor data(
- DataBufferSP(heap_data_ap.release()), byte_order,
+ DataBufferSP(heap_data_up.release()), byte_order,
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
@@ -2365,16 +2362,16 @@ ValueObjectSP ABISysV_arm64::GetReturnValueObjectImpl(
const RegisterInfo *v0_info = reg_ctx->GetRegisterInfoByName("v0", 0);
if (v0_info) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = exe_ctx.GetProcessRef().GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(v0_info, reg_value)) {
Status error;
- if (reg_value.GetAsMemoryData(v0_info, heap_data_ap->GetBytes(),
- heap_data_ap->GetByteSize(), byte_order,
+ if (reg_value.GetAsMemoryData(v0_info, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(), byte_order,
error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()), byte_order,
+ DataExtractor data(DataBufferSP(heap_data_up.release()), byte_order,
exe_ctx.GetProcessRef().GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
&thread, return_compiler_type, ConstString(""), data);
@@ -2413,9 +2410,7 @@ lldb_private::ConstString ABISysV_arm64::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString ABISysV_arm64::GetPluginName() { return GetPluginNameStatic(); }
diff --git a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
index b36b4547e6268..1fbdc793ed6ec 100644
--- a/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
+++ b/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.h
@@ -1,9 +1,8 @@
//===-- ABISysV_arm64.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -71,9 +70,7 @@ public:
bool GetPointerReturnRegister(const char *&name) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -83,9 +80,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
index ca40e9a04d7cd..93647564fe253 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_hexagon.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1010,9 +1009,7 @@ ABISysV_hexagon::GetRegisterInfoArray(uint32_t &count) {
*/
size_t ABISysV_hexagon::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_hexagon::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -1104,7 +1101,7 @@ bool ABISysV_hexagon::PrepareTrivialCall(
sp -= argSize;
// write this argument onto the stack of the host process
- proc->WriteMemory(sp, arg.data_ap.get(), arg.size, error);
+ proc->WriteMemory(sp, arg.data_up.get(), arg.size, error);
if (error.Fail())
return false;
@@ -1295,9 +1292,7 @@ lldb_private::ConstString ABISysV_hexagon::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_hexagon::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
index 6e39c0792e2a4..459b6315dba27 100644
--- a/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
+++ b/source/Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h
@@ -1,10 +1,9 @@
//===-- ABISysV_hexagon.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -72,9 +71,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -84,9 +81,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
index 3358eb8c27747..05f5dba90687f 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
@@ -1,9 +1,8 @@
//===----------------------- ABISysV_i386.cpp -------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//===----------------------------------------------------------------------===//
#include "ABISysV_i386.h"
@@ -193,9 +192,7 @@ ABISysV_i386::GetRegisterInfoArray(uint32_t &count) {
return g_register_infos;
}
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_i386::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -649,19 +646,20 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
if (*byte_size <= vec_reg->byte_size) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(vec_reg, reg_value)) {
Status error;
- if (reg_value.GetAsMemoryData(vec_reg, heap_data_ap->GetBytes(),
- heap_data_ap->GetByteSize(),
+ if (reg_value.GetAsMemoryData(vec_reg, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(),
byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
- byte_order, process_sp->GetTarget()
- .GetArchitecture()
- .GetAddressByteSize());
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
+ byte_order,
+ process_sp->GetTarget()
+ .GetArchitecture()
+ .GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
&thread, return_compiler_type, ConstString(""), data);
}
@@ -673,7 +671,7 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
if (vec_reg2) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
@@ -682,17 +680,18 @@ ValueObjectSP ABISysV_i386::GetReturnValueObjectSimple(
reg_ctx->ReadRegister(vec_reg2, reg_value2)) {
Status error;
- if (reg_value.GetAsMemoryData(vec_reg, heap_data_ap->GetBytes(),
+ if (reg_value.GetAsMemoryData(vec_reg, heap_data_up->GetBytes(),
vec_reg->byte_size, byte_order,
error) &&
reg_value2.GetAsMemoryData(
- vec_reg2, heap_data_ap->GetBytes() + vec_reg->byte_size,
- heap_data_ap->GetByteSize() - vec_reg->byte_size,
+ vec_reg2, heap_data_up->GetBytes() + vec_reg->byte_size,
+ heap_data_up->GetByteSize() - vec_reg->byte_size,
byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
- byte_order, process_sp->GetTarget()
- .GetArchitecture()
- .GetAddressByteSize());
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
+ byte_order,
+ process_sp->GetTarget()
+ .GetArchitecture()
+ .GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
&thread, return_compiler_type, ConstString(""), data);
}
@@ -838,9 +837,7 @@ void ABISysV_i386::Terminate() {
PluginManager::UnregisterPlugin(CreateInstance);
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_i386::GetPluginNameStatic() {
static ConstString g_name("sysv-i386");
diff --git a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
index 336a2754c6cab..982bdd676b74e 100644
--- a/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
+++ b/source/Plugins/ABI/SysV-i386/ABISysV_i386.h
@@ -1,9 +1,8 @@
//===------------------- ABISysV_i386.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -77,9 +76,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -87,9 +84,7 @@ public:
static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
static lldb_private::ConstString GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
index 6f3d2e3b36961..121c7300b9683 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_mips.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -550,9 +549,7 @@ ABISysV_mips::GetRegisterInfoArray(uint32_t &count) {
size_t ABISysV_mips::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_mips::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -1063,9 +1060,7 @@ lldb_private::ConstString ABISysV_mips::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_mips::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
index d23dbe9d97bd6..6cd9c19c22acc 100644
--- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
+++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.h
@@ -1,9 +1,8 @@
//===-- ABISysV_mips.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -62,9 +61,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -74,9 +71,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
index 1d6738d9fda95..18011cfb6b9ea 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_mips64.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -550,17 +549,12 @@ ABISysV_mips64::GetRegisterInfoArray(uint32_t &count) {
size_t ABISysV_mips64::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_mips64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
- if ((arch_type == llvm::Triple::mips64) ||
- (arch_type == llvm::Triple::mips64el)) {
+ if (arch.GetTriple().isMIPS64())
return ABISP(new ABISysV_mips64(process_sp));
- }
return ABISP();
}
@@ -923,15 +917,15 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
uint32_t integer_bytes = 0;
// True if return values are in FP return registers.
- bool use_fp_regs = 0;
+ bool use_fp_regs = false;
// True if we found any non floating point field in structure.
- bool found_non_fp_field = 0;
+ bool found_non_fp_field = false;
// True if return values are in r2 register.
- bool use_r2 = 0;
+ bool use_r2 = false;
// True if return values are in r3 register.
- bool use_r3 = 0;
+ bool use_r3 = false;
// True if the result is copied into our data buffer
- bool sucess = 0;
+ bool sucess = false;
std::string name;
bool is_complex;
uint32_t count;
@@ -949,9 +943,9 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
nullptr, nullptr);
if (field_compiler_type.IsFloatingPointType(count, is_complex))
- use_fp_regs = 1;
+ use_fp_regs = true;
else
- found_non_fp_field = 1;
+ found_non_fp_field = true;
}
if (use_fp_regs && !found_non_fp_field) {
@@ -1065,20 +1059,20 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
// structure
integer_bytes = integer_bytes + *field_byte_width +
padding; // Increase the consumed bytes.
- use_r2 = 1;
+ use_r2 = true;
} else {
// There isn't enough space left in r2 for this field, so this
// will be in r3.
integer_bytes = integer_bytes + *field_byte_width +
padding; // Increase the consumed bytes.
- use_r3 = 1;
+ use_r3 = true;
}
}
// We already have consumed at-least 8 bytes that means r2 is done,
// and this field will be in r3. Check if this field can fit in r3.
else if (integer_bytes + *field_byte_width + padding <= 16) {
integer_bytes = integer_bytes + *field_byte_width + padding;
- use_r3 = 1;
+ use_r3 = true;
} else {
// There isn't any space left for this field, this should not
// happen as we have already checked the overall size is not
@@ -1091,10 +1085,10 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
// Vector types up to 16 bytes are returned in GP return registers
if (type_flags & eTypeIsVector) {
if (*byte_size <= 8)
- use_r2 = 1;
+ use_r2 = true;
else {
- use_r2 = 1;
- use_r3 = 1;
+ use_r2 = true;
+ use_r3 = true;
}
}
@@ -1106,7 +1100,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
error);
if (bytes_copied != r2_info->byte_size)
return return_valobj_sp;
- sucess = 1;
+ sucess = true;
}
if (use_r3) {
reg_ctx->ReadRegister(r3_info, r3_value);
@@ -1116,7 +1110,7 @@ ValueObjectSP ABISysV_mips64::GetReturnValueObjectImpl(
if (bytes_copied != r3_info->byte_size)
return return_valobj_sp;
- sucess = 1;
+ sucess = true;
}
if (sucess) {
// The result is in our data buffer. Create a variable object out of
@@ -1214,9 +1208,7 @@ lldb_private::ConstString ABISysV_mips64::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_mips64::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
index c7670f4671148..7da71b36b4b72 100644
--- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
+++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.h
@@ -1,9 +1,8 @@
//===-- ABISysV_mips64.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -75,9 +74,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -87,9 +84,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
index 1fe7a6718a910..faa995033ac25 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_ppc.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -214,9 +213,7 @@ ABISysV_ppc::GetRegisterInfoArray(uint32_t &count) {
size_t ABISysV_ppc::GetRedZoneSize() const { return 224; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_ppc::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -619,16 +616,16 @@ ValueObjectSP ABISysV_ppc::GetReturnValueObjectSimple(
if (*byte_size <= altivec_reg->byte_size) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(altivec_reg, reg_value)) {
Status error;
if (reg_value.GetAsMemoryData(
- altivec_reg, heap_data_ap->GetBytes(),
- heap_data_ap->GetByteSize(), byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
+ altivec_reg, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(), byte_order, error)) {
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
byte_order,
process_sp->GetTarget()
.GetArchitecture()
@@ -976,9 +973,7 @@ lldb_private::ConstString ABISysV_ppc::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_ppc::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
index 3559cbb452000..3b199852c30d3 100644
--- a/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
+++ b/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.h
@@ -1,9 +1,8 @@
//===-- ABISysV_ppc.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -71,9 +70,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -83,9 +80,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
index fb46b7dc7fb67..aa7907550f294 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_ppc64.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -65,17 +64,13 @@ lldb::ByteOrder ABISysV_ppc64::GetByteOrder() const {
return GetProcessSP()->GetByteOrder();
}
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_ppc64::CreateInstance(lldb::ProcessSP process_sp,
const ArchSpec &arch) {
- if (arch.GetTriple().getArch() == llvm::Triple::ppc64 ||
- arch.GetTriple().getArch() == llvm::Triple::ppc64le) {
+ if (arch.GetTriple().isPPC64())
return ABISP(new ABISysV_ppc64(process_sp));
- }
return ABISP();
}
@@ -561,7 +556,7 @@ private:
Thread &m_thread;
CompilerType &m_type;
uint64_t m_byte_size;
- std::unique_ptr<DataBufferHeap> m_data_ap;
+ std::unique_ptr<DataBufferHeap> m_data_up;
int32_t m_src_offs = 0;
int32_t m_dst_offs = 0;
bool m_packed = false;
@@ -578,7 +573,7 @@ private:
RegisterContext *reg_ctx, ProcessSP process_sp)
: m_thread(thread), m_type(type),
m_byte_size(m_type.GetByteSize(nullptr).getValueOr(0)),
- m_data_ap(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
+ m_data_up(new DataBufferHeap(m_byte_size, 0)), m_reg_ctx(reg_ctx),
m_process_sp(process_sp), m_byte_order(process_sp->GetByteOrder()),
m_addr_size(
process_sp->GetTarget().GetArchitecture().GetAddressByteSize()) {}
@@ -687,7 +682,7 @@ private:
// build the ValueObject from our data buffer
ValueObjectSP BuildValueObject() {
- DataExtractor de(DataBufferSP(m_data_ap.release()), m_byte_order,
+ DataExtractor de(DataBufferSP(m_data_up.release()), m_byte_order,
m_addr_size);
return ValueObjectConstResult::Create(&m_thread, m_type, ConstString(""),
de);
@@ -752,7 +747,7 @@ private:
offs = vr_size - m_byte_size;
// copy extracted data to our buffer
- memcpy(m_data_ap->GetBytes(), vr_data->GetBytes() + offs, m_byte_size);
+ memcpy(m_data_up->GetBytes(), vr_data->GetBytes() + offs, m_byte_size);
return BuildValueObject();
}
@@ -766,7 +761,7 @@ private:
return {};
Status error;
- size_t rc = m_process_sp->ReadMemory(addr, m_data_ap->GetBytes(),
+ size_t rc = m_process_sp->ReadMemory(addr, m_data_up->GetBytes(),
m_byte_size, error);
if (rc != m_byte_size) {
LLDB_LOG(m_log, LOG_PREFIX "Failed to read memory pointed by r3");
@@ -804,7 +799,8 @@ private:
// copy to buffer
Status error;
size_t rc = val_sp->GetScalar().GetAsMemoryData(
- m_data_ap->GetBytes() + m_dst_offs, *elem_size, m_byte_order, error);
+ m_data_up->GetBytes() + m_dst_offs, *elem_size, m_byte_order,
+ error);
if (rc != *elem_size) {
LLDB_LOG(m_log, LOG_PREFIX "Failed to get float data");
return {};
@@ -888,7 +884,7 @@ private:
LOG_PREFIX "Extracting {0} alignment bytes at offset {1}", n,
m_src_offs);
// get alignment bytes
- if (!ExtractFromRegs(m_src_offs, n, m_data_ap->GetBytes() + m_dst_offs))
+ if (!ExtractFromRegs(m_src_offs, n, m_data_up->GetBytes() + m_dst_offs))
return false;
m_src_offs += n;
m_dst_offs += n;
@@ -898,7 +894,7 @@ private:
// get field
LLDB_LOG(m_log, LOG_PREFIX "Extracting {0} field bytes at offset {1}", size,
m_src_offs);
- if (!ExtractFromRegs(m_src_offs, size, m_data_ap->GetBytes() + m_dst_offs))
+ if (!ExtractFromRegs(m_src_offs, size, m_data_up->GetBytes() + m_dst_offs))
return false;
m_src_offs += size;
m_dst_offs += size;
@@ -1086,9 +1082,7 @@ lldb_private::ConstString ABISysV_ppc64::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_ppc64::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
index 54f461e1001ba..d5fb09eec0d02 100644
--- a/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
+++ b/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h
@@ -1,9 +1,8 @@
//===-- ABISysV_ppc64.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -71,9 +70,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -83,9 +80,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
index d8056ea7d3561..abe847b386a84 100644
--- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
+++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_s390x.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -196,9 +195,7 @@ ABISysV_s390x::GetRegisterInfoArray(uint32_t &count) {
size_t ABISysV_s390x::GetRedZoneSize() const { return 0; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_s390x::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
@@ -743,9 +740,7 @@ lldb_private::ConstString ABISysV_s390x::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_s390x::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
index 5433ebb4593e8..13df477e84bc0 100644
--- a/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
+++ b/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.h
@@ -1,9 +1,8 @@
//===-- ABISysV_s390x.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -63,9 +62,7 @@ public:
const lldb_private::RegisterInfo *
GetRegisterInfoArray(uint32_t &count) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -75,9 +72,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
index dc3e475e3b8ed..6c7b45f633996 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- ABISysV_x86_64.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,6 +30,8 @@
#include "lldb/Utility/RegisterValue.h"
#include "lldb/Utility/Status.h"
+#include <vector>
+
using namespace lldb;
using namespace lldb_private;
@@ -99,960 +100,90 @@ enum dwarf_regnums {
};
static RegisterInfo g_register_infos[] = {
- // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME
- // DWARF GENERIC PROCESS PLUGIN
- // LLDB NATIVE
- // ======== ======= == === ============= ===================
- // ======================= =====================
- // =========================== ===================== ======================
- {"rax",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rbx",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rcx",
- "arg4",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rdx",
- "arg3",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rsi",
- "arg2",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rsi, dwarf_rsi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rdi",
- "arg1",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rdi, dwarf_rdi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rbp",
- "fp",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rsp",
- "sp",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r8",
- "arg5",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r9",
- "arg6",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r10",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r11",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r12",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r13",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r14",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"r15",
- nullptr,
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rip",
- "pc",
- 8,
- 0,
- eEncodingUint,
- eFormatHex,
- {dwarf_rip, dwarf_rip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"rflags",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"cs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ss",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ds",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"es",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"gs",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm0",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm0, dwarf_stmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm1",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm1, dwarf_stmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm2",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm2, dwarf_stmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm3",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm3, dwarf_stmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm4",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm4, dwarf_stmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm5",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm5, dwarf_stmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm6",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm6, dwarf_stmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"stmm7",
- nullptr,
- 10,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_stmm7, dwarf_stmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fctrl",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fstat",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ftag",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fiseg",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fioff",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"foseg",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fooff",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"fop",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm0, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm1, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm2, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm3, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm4",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm4, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm5",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm5, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm6",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm6, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm7",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm7, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm8",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm8, dwarf_xmm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm9",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm9, dwarf_xmm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm10",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm10, dwarf_xmm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm11",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm11, dwarf_xmm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm12",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm12, dwarf_xmm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm13",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm13, dwarf_xmm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm14",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm14, dwarf_xmm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"xmm15",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_xmm15, dwarf_xmm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"mxcsr",
- nullptr,
- 4,
- 0,
- eEncodingUint,
- eFormatHex,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm0",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm0, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm1",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm1, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm2",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm2, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm3",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm3, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm4",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm4, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm5",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm5, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm6",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm6, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm7",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm7, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm8",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm8, dwarf_ymm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm9",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm9, dwarf_ymm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm10",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm10, dwarf_ymm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm11",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm11, dwarf_ymm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm12",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm12, dwarf_ymm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm13",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm13, dwarf_ymm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm14",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm14, dwarf_ymm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"ymm15",
- nullptr,
- 32,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {dwarf_ymm15, dwarf_ymm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd0",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd1",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd2",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bnd3",
- nullptr,
- 16,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt64,
- {dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bndcfgu",
- nullptr,
- 8,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0},
- {"bndstatus",
- nullptr,
- 8,
- 0,
- eEncodingVector,
- eFormatVectorOfUInt8,
- {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
- nullptr,
- nullptr,
- nullptr,
- 0}};
+ // clang-format off
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME DWARF GENERIC LLDB NATIVE
+ // ======== ======= == === ============= =================== ======================= ===================== =========================== ===================== ======================
+ {"rax", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rbx", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rcx", "arg4", 8, 0, eEncodingUint, eFormatHex, {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rdx", "arg3", 8, 0, eEncodingUint, eFormatHex, {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rsi", "arg2", 8, 0, eEncodingUint, eFormatHex, {dwarf_rsi, dwarf_rsi, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rdi", "arg1", 8, 0, eEncodingUint, eFormatHex, {dwarf_rdi, dwarf_rdi, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rbp", "fp", 8, 0, eEncodingUint, eFormatHex, {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rsp", "sp", 8, 0, eEncodingUint, eFormatHex, {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r8", "arg5", 8, 0, eEncodingUint, eFormatHex, {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r9", "arg6", 8, 0, eEncodingUint, eFormatHex, {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r10", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r11", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r12", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r13", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r14", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"r15", nullptr, 8, 0, eEncodingUint, eFormatHex, {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rip", "pc", 8, 0, eEncodingUint, eFormatHex, {dwarf_rip, dwarf_rip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"rflags", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"cs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ss", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ds", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"es", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"gs", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm0", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm0, dwarf_stmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm1", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm1, dwarf_stmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm2", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm2, dwarf_stmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm3", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm3, dwarf_stmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm4", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm4, dwarf_stmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm5", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm5, dwarf_stmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm6", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm6, dwarf_stmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"stmm7", nullptr, 10, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_stmm7, dwarf_stmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fctrl", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fstat", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ftag", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fiseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fioff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"foseg", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fooff", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"fop", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm0, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm1, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm2, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm3, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm4", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm4, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm5", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm5, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm6", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm6, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm7", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm7, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm8", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm8, dwarf_xmm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm9", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm9, dwarf_xmm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm10", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm10, dwarf_xmm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm11", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm11, dwarf_xmm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm12", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm12, dwarf_xmm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm13", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm13, dwarf_xmm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm14", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm14, dwarf_xmm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"xmm15", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_xmm15, dwarf_xmm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"mxcsr", nullptr, 4, 0, eEncodingUint, eFormatHex, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm0", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm0, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm1", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm1, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm2", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm2, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm3", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm3, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm4", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm4, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm5", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm5, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm6", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm6, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm7", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm7, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm8", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm8, dwarf_ymm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm9", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm9, dwarf_ymm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm10", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm10, dwarf_ymm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm11", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm11, dwarf_ymm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm12", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm12, dwarf_ymm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm13", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm13, dwarf_ymm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm14", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm14, dwarf_ymm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"ymm15", nullptr, 32, 0, eEncodingVector, eFormatVectorOfUInt8, {dwarf_ymm15, dwarf_ymm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"bnd0", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"bnd1", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"bnd2", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"bnd3", nullptr, 16, 0, eEncodingVector, eFormatVectorOfUInt64, {dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"bndcfgu", nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ {"bndstatus",nullptr, 8, 0, eEncodingVector, eFormatVectorOfUInt8, {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM}, nullptr, nullptr, nullptr, 0},
+ // clang-format on
+};
static const uint32_t k_num_register_infos =
llvm::array_lengthof(g_register_infos);
@@ -1085,14 +216,24 @@ bool ABISysV_x86_64::GetPointerReturnRegister(const char *&name) {
size_t ABISysV_x86_64::GetRedZoneSize() const { return 128; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ABISP
ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
- if (arch.GetTriple().getArch() == llvm::Triple::x86_64) {
- return ABISP(new ABISysV_x86_64(process_sp));
+ const llvm::Triple::ArchType arch_type = arch.GetTriple().getArch();
+ const llvm::Triple::OSType os_type = arch.GetTriple().getOS();
+ if (arch_type == llvm::Triple::x86_64) {
+ switch(os_type) {
+ case llvm::Triple::OSType::MacOSX:
+ case llvm::Triple::OSType::Linux:
+ case llvm::Triple::OSType::FreeBSD:
+ case llvm::Triple::OSType::NetBSD:
+ case llvm::Triple::OSType::Solaris:
+ case llvm::Triple::OSType::UnknownOS:
+ return ABISP(new ABISysV_x86_64(process_sp));
+ default:
+ return ABISP();
+ }
}
return ABISP();
}
@@ -1500,19 +641,20 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
if (*byte_size <= altivec_reg->byte_size) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
if (reg_ctx->ReadRegister(altivec_reg, reg_value)) {
Status error;
if (reg_value.GetAsMemoryData(
- altivec_reg, heap_data_ap->GetBytes(),
- heap_data_ap->GetByteSize(), byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
- byte_order, process_sp->GetTarget()
- .GetArchitecture()
- .GetAddressByteSize());
+ altivec_reg, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(), byte_order, error)) {
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
+ byte_order,
+ process_sp->GetTarget()
+ .GetArchitecture()
+ .GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
&thread, return_compiler_type, ConstString(""), data);
}
@@ -1524,7 +666,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
if (altivec_reg2) {
ProcessSP process_sp(thread.GetProcess());
if (process_sp) {
- std::unique_ptr<DataBufferHeap> heap_data_ap(
+ std::unique_ptr<DataBufferHeap> heap_data_up(
new DataBufferHeap(*byte_size, 0));
const ByteOrder byte_order = process_sp->GetByteOrder();
RegisterValue reg_value;
@@ -1534,17 +676,18 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
Status error;
if (reg_value.GetAsMemoryData(
- altivec_reg, heap_data_ap->GetBytes(),
+ altivec_reg, heap_data_up->GetBytes(),
altivec_reg->byte_size, byte_order, error) &&
reg_value2.GetAsMemoryData(
altivec_reg2,
- heap_data_ap->GetBytes() + altivec_reg->byte_size,
- heap_data_ap->GetByteSize() - altivec_reg->byte_size,
+ heap_data_up->GetBytes() + altivec_reg->byte_size,
+ heap_data_up->GetByteSize() - altivec_reg->byte_size,
byte_order, error)) {
- DataExtractor data(DataBufferSP(heap_data_ap.release()),
- byte_order, process_sp->GetTarget()
- .GetArchitecture()
- .GetAddressByteSize());
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
+ byte_order,
+ process_sp->GetTarget()
+ .GetArchitecture()
+ .GetAddressByteSize());
return_valobj_sp = ValueObjectConstResult::Create(
&thread, return_compiler_type, ConstString(""), data);
}
@@ -1559,6 +702,55 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectSimple(
return return_valobj_sp;
}
+// The compiler will flatten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+ Thread &thread, ExecutionContext &exe_ctx,
+ CompilerType &return_compiler_type,
+ uint32_t data_byte_offset,
+ std::vector<uint32_t> &aggregate_field_offsets,
+ std::vector<CompilerType> &aggregate_compiler_types) {
+
+ const uint32_t num_children = return_compiler_type.GetNumFields();
+ for (uint32_t idx = 0; idx < num_children; ++idx) {
+ std::string name;
+ bool is_signed;
+ uint32_t count;
+ bool is_complex;
+
+ uint64_t field_bit_offset = 0;
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
+ idx, name, &field_bit_offset, nullptr, nullptr);
+ llvm::Optional<uint64_t> field_bit_width =
+ field_compiler_type.GetBitSize(&thread);
+
+ // if we don't know the size of the field (e.g. invalid type), exit
+ if (!field_bit_width || *field_bit_width == 0) {
+ return false;
+ }
+
+ uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+ const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+ if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+ field_compiler_type.IsPointerType() ||
+ field_compiler_type.IsFloatingPointType(count, is_complex)) {
+ aggregate_field_offsets.push_back(field_byte_offset);
+ aggregate_compiler_types.push_back(field_compiler_type);
+ } else if (field_type_flags & eTypeHasChildren) {
+ if (!FlattenAggregateType(thread, exe_ctx, field_compiler_type,
+ field_byte_offset, aggregate_field_offsets,
+ aggregate_compiler_types)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
Thread &thread, CompilerType &return_compiler_type) const {
ValueObjectSP return_valobj_sp;
@@ -1581,10 +773,17 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
if (return_compiler_type.IsAggregateType()) {
Target *target = exe_ctx.GetTargetPtr();
bool is_memory = true;
- if (*bit_width <= 128) {
- ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder();
+ std::vector<uint32_t> aggregate_field_offsets;
+ std::vector<CompilerType> aggregate_compiler_types;
+ if (return_compiler_type.GetTypeSystem()->CanPassInRegisters(
+ return_compiler_type) &&
+ *bit_width <= 128 &&
+ FlattenAggregateType(thread, exe_ctx, return_compiler_type,
+ 0, aggregate_field_offsets,
+ aggregate_compiler_types)) {
+ ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
DataBufferSP data_sp(new DataBufferHeap(16, 0));
- DataExtractor return_ext(data_sp, target_byte_order,
+ DataExtractor return_ext(data_sp, byte_order,
target->GetArchitecture().GetAddressByteSize());
const RegisterInfo *rax_info =
@@ -1614,36 +813,27 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
uint32_t integer_bytes =
0; // Tracks how much of the rax/rds registers we've consumed so far
- const uint32_t num_children = return_compiler_type.GetNumFields();
+ // in case of the returned type is a subclass of non-abstract-base class
+ // it will have a padding to skip the base content
+ if (aggregate_field_offsets.size()) {
+ fp_bytes = aggregate_field_offsets[0];
+ integer_bytes = aggregate_field_offsets[0];
+ }
+
+ const uint32_t num_children = aggregate_compiler_types.size();
// Since we are in the small struct regime, assume we are not in memory.
is_memory = false;
-
for (uint32_t idx = 0; idx < num_children; idx++) {
- std::string name;
- uint64_t field_bit_offset = 0;
bool is_signed;
- bool is_complex;
uint32_t count;
+ bool is_complex;
- CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
- idx, name, &field_bit_offset, nullptr, nullptr);
- llvm::Optional<uint64_t> field_bit_width =
- field_compiler_type.GetBitSize(&thread);
-
- // if we don't know the size of the field (e.g. invalid type), just
- // bail out
- if (!field_bit_width || *field_bit_width == 0)
- break;
-
- // If there are any unaligned fields, this is stored in memory.
- if (field_bit_offset % *field_bit_width != 0) {
- is_memory = true;
- break;
- }
+ CompilerType field_compiler_type = aggregate_compiler_types[idx];
+ uint32_t field_byte_width = (uint32_t) (*field_compiler_type.GetByteSize(&thread));
+ uint32_t field_byte_offset = aggregate_field_offsets[idx];
- uint32_t field_byte_width = *field_bit_width / 8;
- uint32_t field_byte_offset = field_bit_offset / 8;
+ uint32_t field_bit_width = field_byte_width * 8;
DataExtractor *copy_from_extractor = nullptr;
uint32_t copy_from_offset = 0;
@@ -1675,10 +865,10 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
}
} else if (field_compiler_type.IsFloatingPointType(count, is_complex)) {
// Structs with long doubles are always passed in memory.
- if (*field_bit_width == 128) {
+ if (field_bit_width == 128) {
is_memory = true;
break;
- } else if (*field_bit_width == 64) {
+ } else if (field_bit_width == 64) {
// These have to be in a single xmm register.
if (fp_bytes == 0)
copy_from_extractor = &xmm0_data;
@@ -1687,7 +877,7 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
copy_from_offset = 0;
fp_bytes += field_byte_width;
- } else if (*field_bit_width == 32) {
+ } else if (field_bit_width == 32) {
// This one is kind of complicated. If we are in an "eightbyte"
// with another float, we'll be stuffed into an xmm register with
// it. If we are in an "eightbyte" with one or more ints, then we
@@ -1696,18 +886,15 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
if (field_byte_offset % 8 == 0) {
// We are at the beginning of one of the eightbytes, so check the
// next element (if any)
- if (idx == num_children - 1)
+ if (idx == num_children - 1) {
in_gpr = false;
- else {
- uint64_t next_field_bit_offset = 0;
+ } else {
CompilerType next_field_compiler_type =
- return_compiler_type.GetFieldAtIndex(idx + 1, name,
- &next_field_bit_offset,
- nullptr, nullptr);
+ aggregate_compiler_types[idx + 1];
if (next_field_compiler_type.IsIntegerOrEnumerationType(
- is_signed))
+ is_signed)) {
in_gpr = true;
- else {
+ } else {
copy_from_offset = 0;
in_gpr = false;
}
@@ -1716,18 +903,15 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
// We are inside of an eightbyte, so see if the field before us
// is floating point: This could happen if somebody put padding
// in the structure.
- if (idx == 0)
+ if (idx == 0) {
in_gpr = false;
- else {
- uint64_t prev_field_bit_offset = 0;
+ } else {
CompilerType prev_field_compiler_type =
- return_compiler_type.GetFieldAtIndex(idx - 1, name,
- &prev_field_bit_offset,
- nullptr, nullptr);
+ aggregate_compiler_types[idx - 1];
if (prev_field_compiler_type.IsIntegerOrEnumerationType(
- is_signed))
+ is_signed)) {
in_gpr = true;
- else {
+ } else {
copy_from_offset = 4;
in_gpr = false;
}
@@ -1760,7 +944,6 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
}
}
}
-
// These two tests are just sanity checks. If I somehow get the type
// calculation wrong above it is better to just return nothing than to
// assert or crash.
@@ -1769,13 +952,11 @@ ValueObjectSP ABISysV_x86_64::GetReturnValueObjectImpl(
if (copy_from_offset + field_byte_width >
copy_from_extractor->GetByteSize())
return return_valobj_sp;
-
copy_from_extractor->CopyByteOrderedData(
copy_from_offset, field_byte_width,
data_sp->GetBytes() + field_byte_offset, field_byte_width,
- target_byte_order);
+ byte_order);
}
-
if (!is_memory) {
// The result is in our data buffer. Let's make a variable object out
// of it:
@@ -1896,9 +1077,7 @@ lldb_private::ConstString ABISysV_x86_64::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ABISysV_x86_64::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
index 4afc8c4cad620..f6704aff348ce 100644
--- a/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
+++ b/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h
@@ -1,9 +1,8 @@
//===-- ABISysV_x86_64.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -73,9 +72,7 @@ public:
bool GetPointerReturnRegister(const char *&name) override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
@@ -85,9 +82,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
diff --git a/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp b/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
new file mode 100644
index 0000000000000..5dc7717d865df
--- /dev/null
+++ b/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.cpp
@@ -0,0 +1,1805 @@
+//===-- ABIWindows_x86_64.cpp --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ABIWindows_x86_64.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Triple.h"
+
+#include "lldb/Core/Module.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Value.h"
+#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Core/ValueObjectMemory.h"
+#include "lldb/Core/ValueObjectRegister.h"
+#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/StackFrame.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Target/Thread.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/Status.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+enum dwarf_regnums {
+ dwarf_rax = 0,
+ dwarf_rdx,
+ dwarf_rcx,
+ dwarf_rbx,
+ dwarf_rsi,
+ dwarf_rdi,
+ dwarf_rbp,
+ dwarf_rsp,
+ dwarf_r8,
+ dwarf_r9,
+ dwarf_r10,
+ dwarf_r11,
+ dwarf_r12,
+ dwarf_r13,
+ dwarf_r14,
+ dwarf_r15,
+ dwarf_rip,
+ dwarf_xmm0,
+ dwarf_xmm1,
+ dwarf_xmm2,
+ dwarf_xmm3,
+ dwarf_xmm4,
+ dwarf_xmm5,
+ dwarf_xmm6,
+ dwarf_xmm7,
+ dwarf_xmm8,
+ dwarf_xmm9,
+ dwarf_xmm10,
+ dwarf_xmm11,
+ dwarf_xmm12,
+ dwarf_xmm13,
+ dwarf_xmm14,
+ dwarf_xmm15,
+ dwarf_stmm0,
+ dwarf_stmm1,
+ dwarf_stmm2,
+ dwarf_stmm3,
+ dwarf_stmm4,
+ dwarf_stmm5,
+ dwarf_stmm6,
+ dwarf_stmm7,
+ dwarf_ymm0,
+ dwarf_ymm1,
+ dwarf_ymm2,
+ dwarf_ymm3,
+ dwarf_ymm4,
+ dwarf_ymm5,
+ dwarf_ymm6,
+ dwarf_ymm7,
+ dwarf_ymm8,
+ dwarf_ymm9,
+ dwarf_ymm10,
+ dwarf_ymm11,
+ dwarf_ymm12,
+ dwarf_ymm13,
+ dwarf_ymm14,
+ dwarf_ymm15,
+ dwarf_bnd0 = 126,
+ dwarf_bnd1,
+ dwarf_bnd2,
+ dwarf_bnd3
+};
+
+static RegisterInfo g_register_infos[] = {
+ // NAME ALT SZ OFF ENCODING FORMAT EH_FRAME
+ // DWARF GENERIC PROCESS PLUGIN
+ // LLDB NATIVE
+ // ======== ======= == === ============= ===================
+ // ======================= =====================
+ // =========================== ===================== ======================
+ {"rax",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rax, dwarf_rax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rbx",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rbx, dwarf_rbx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rcx",
+ "arg1",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rcx, dwarf_rcx, LLDB_REGNUM_GENERIC_ARG1, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rdx",
+ "arg2",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rdx, dwarf_rdx, LLDB_REGNUM_GENERIC_ARG2, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rsi",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rsi, dwarf_rsi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rdi",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rdi, dwarf_rdi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rbp",
+ "fp",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rbp, dwarf_rbp, LLDB_REGNUM_GENERIC_FP, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rsp",
+ "sp",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rsp, dwarf_rsp, LLDB_REGNUM_GENERIC_SP, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r8",
+ "arg3",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r8, dwarf_r8, LLDB_REGNUM_GENERIC_ARG3, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r9",
+ "arg4",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r9, dwarf_r9, LLDB_REGNUM_GENERIC_ARG4, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r10",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r10, dwarf_r10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r11",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r11, dwarf_r11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r12",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r12, dwarf_r12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r13",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r13, dwarf_r13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r14",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r14, dwarf_r14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"r15",
+ nullptr,
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_r15, dwarf_r15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rip",
+ "pc",
+ 8,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {dwarf_rip, dwarf_rip, LLDB_REGNUM_GENERIC_PC, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"rflags",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"cs",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ss",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ds",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"es",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fs",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"gs",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm0",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm0, dwarf_stmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm1",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm1, dwarf_stmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm2",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm2, dwarf_stmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm3",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm3, dwarf_stmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm4",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm4, dwarf_stmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm5",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm5, dwarf_stmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm6",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm6, dwarf_stmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"stmm7",
+ nullptr,
+ 10,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_stmm7, dwarf_stmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fctrl",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fstat",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ftag",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fiseg",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fioff",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"foseg",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fooff",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"fop",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm0",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm0, dwarf_xmm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm1",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm1, dwarf_xmm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm2",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm2, dwarf_xmm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm3",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm3, dwarf_xmm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm4",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm4, dwarf_xmm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm5",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm5, dwarf_xmm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm6",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm6, dwarf_xmm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm7",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm7, dwarf_xmm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm8",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm8, dwarf_xmm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm9",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm9, dwarf_xmm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm10",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm10, dwarf_xmm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm11",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm11, dwarf_xmm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm12",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm12, dwarf_xmm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm13",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm13, dwarf_xmm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm14",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm14, dwarf_xmm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"xmm15",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_xmm15, dwarf_xmm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"mxcsr",
+ nullptr,
+ 4,
+ 0,
+ eEncodingUint,
+ eFormatHex,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm0",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm0, dwarf_ymm0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm1",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm1, dwarf_ymm1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm2",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm2, dwarf_ymm2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm3",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm3, dwarf_ymm3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm4",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm4, dwarf_ymm4, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm5",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm5, dwarf_ymm5, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm6",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm6, dwarf_ymm6, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm7",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm7, dwarf_ymm7, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm8",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm8, dwarf_ymm8, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm9",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm9, dwarf_ymm9, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm10",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm10, dwarf_ymm10, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm11",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm11, dwarf_ymm11, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm12",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm12, dwarf_ymm12, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm13",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm13, dwarf_ymm13, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm14",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm14, dwarf_ymm14, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"ymm15",
+ nullptr,
+ 32,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {dwarf_ymm15, dwarf_ymm15, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"bnd0",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt64,
+ {dwarf_bnd0, dwarf_bnd0, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"bnd1",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt64,
+ {dwarf_bnd1, dwarf_bnd1, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"bnd2",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt64,
+ {dwarf_bnd2, dwarf_bnd2, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"bnd3",
+ nullptr,
+ 16,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt64,
+ {dwarf_bnd3, dwarf_bnd3, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"bndcfgu",
+ nullptr,
+ 8,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0},
+ {"bndstatus",
+ nullptr,
+ 8,
+ 0,
+ eEncodingVector,
+ eFormatVectorOfUInt8,
+ {LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
+ nullptr,
+ nullptr,
+ nullptr,
+ 0}};
+
+static const uint32_t k_num_register_infos =
+ llvm::array_lengthof(g_register_infos);
+static bool g_register_info_names_constified = false;
+
+const lldb_private::RegisterInfo *
+ABIWindows_x86_64::GetRegisterInfoArray(uint32_t &count) {
+ // Make the C-string names and alt_names for the register infos into const
+ // C-string values by having the ConstString unique the names in the global
+ // constant C-string pool.
+ if (!g_register_info_names_constified) {
+ g_register_info_names_constified = true;
+ for (uint32_t i = 0; i < k_num_register_infos; ++i) {
+ if (g_register_infos[i].name)
+ g_register_infos[i].name =
+ ConstString(g_register_infos[i].name).GetCString();
+ if (g_register_infos[i].alt_name)
+ g_register_infos[i].alt_name =
+ ConstString(g_register_infos[i].alt_name).GetCString();
+ }
+ }
+ count = k_num_register_infos;
+ return g_register_infos;
+}
+
+bool ABIWindows_x86_64::GetPointerReturnRegister(const char *&name) {
+ name = "rax";
+ return true;
+}
+
+size_t ABIWindows_x86_64::GetRedZoneSize() const { return 0; }
+
+//------------------------------------------------------------------
+// Static Functions
+//------------------------------------------------------------------
+
+ABISP
+ABIWindows_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch) {
+ if (arch.GetTriple().getArch() == llvm::Triple::x86_64 &&
+ arch.GetTriple().isOSWindows()) {
+ return ABISP(new ABIWindows_x86_64(process_sp));
+ }
+ return ABISP();
+}
+
+bool ABIWindows_x86_64::PrepareTrivialCall(Thread &thread, addr_t sp,
+ addr_t func_addr, addr_t return_addr,
+ llvm::ArrayRef<addr_t> args) const {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ if (log) {
+ StreamString s;
+ s.Printf("ABIWindows_x86_64::PrepareTrivialCall (tid = 0x%" PRIx64
+ ", sp = 0x%" PRIx64 ", func_addr = 0x%" PRIx64
+ ", return_addr = 0x%" PRIx64,
+ thread.GetID(), (uint64_t)sp, (uint64_t)func_addr,
+ (uint64_t)return_addr);
+
+ for (size_t i = 0; i < args.size(); ++i)
+ s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast<uint64_t>(i + 1),
+ args[i]);
+ s.PutCString(")");
+ log->PutString(s.GetString());
+ }
+
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+ if (!reg_ctx)
+ return false;
+
+ const RegisterInfo *reg_info = nullptr;
+
+ if (args.size() > 4) // Windows x64 only put first 4 arguments into registers
+ return false;
+
+ for (size_t i = 0; i < args.size(); ++i) {
+ reg_info = reg_ctx->GetRegisterInfo(eRegisterKindGeneric,
+ LLDB_REGNUM_GENERIC_ARG1 + i);
+ if (log)
+ log->Printf("About to write arg%" PRIu64 " (0x%" PRIx64 ") into %s",
+ static_cast<uint64_t>(i + 1), args[i], reg_info->name);
+ if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, args[i]))
+ return false;
+ }
+
+ // First, align the SP
+
+ if (log)
+ log->Printf("16-byte aligning SP: 0x%" PRIx64 " to 0x%" PRIx64,
+ (uint64_t)sp, (uint64_t)(sp & ~0xfull));
+
+ sp &= ~(0xfull); // 16-byte alignment
+
+ sp -= 8; // return address
+
+ Status error;
+ const RegisterInfo *pc_reg_info =
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ const RegisterInfo *sp_reg_info =
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP);
+ ProcessSP process_sp(thread.GetProcess());
+
+ RegisterValue reg_value;
+ if (log)
+ log->Printf("Pushing the return address onto the stack: 0x%" PRIx64
+ ": 0x%" PRIx64,
+ (uint64_t)sp, (uint64_t)return_addr);
+
+ // Save return address onto the stack
+ if (!process_sp->WritePointerToMemory(sp, return_addr, error))
+ return false;
+
+ // %rsp is set to the actual stack value.
+
+ if (log)
+ log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp);
+
+ if (!reg_ctx->WriteRegisterFromUnsigned(sp_reg_info, sp))
+ return false;
+
+ // %rip is set to the address of the called function.
+
+ if (log)
+ log->Printf("Writing IP: 0x%" PRIx64, (uint64_t)func_addr);
+
+ if (!reg_ctx->WriteRegisterFromUnsigned(pc_reg_info, func_addr))
+ return false;
+
+ return true;
+}
+
+static bool ReadIntegerArgument(Scalar &scalar, unsigned int bit_width,
+ bool is_signed, Thread &thread,
+ uint32_t *argument_register_ids,
+ unsigned int &current_argument_register,
+ addr_t &current_stack_argument) {
+ if (bit_width > 64)
+ return false; // Scalar can't hold large integer arguments
+
+ if (current_argument_register < 4) { // Windows pass first 4 arguments to register
+ scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
+ argument_register_ids[current_argument_register], 0);
+ current_argument_register++;
+ if (is_signed)
+ scalar.SignExtend(bit_width);
+ return true;
+ }
+ uint32_t byte_size = (bit_width + (CHAR_BIT - 1)) / CHAR_BIT;
+ Status error;
+ if (thread.GetProcess()->ReadScalarIntegerFromMemory(
+ current_stack_argument, byte_size, is_signed, scalar, error)) {
+ current_stack_argument += byte_size;
+ return true;
+ }
+ return false;
+}
+
+bool ABIWindows_x86_64::GetArgumentValues(Thread &thread,
+ ValueList &values) const {
+ unsigned int num_values = values.GetSize();
+ unsigned int value_index;
+
+ // Extract the register context so we can read arguments from registers
+
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+
+ if (!reg_ctx)
+ return false;
+
+ // Get the pointer to the first stack argument so we have a place to start
+ // when reading data
+
+ addr_t sp = reg_ctx->GetSP(0);
+
+ if (!sp)
+ return false;
+
+ addr_t current_stack_argument = sp + 8; // jump over return address
+
+ uint32_t argument_register_ids[4];
+
+ argument_register_ids[0] =
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1)
+ ->kinds[eRegisterKindLLDB];
+ argument_register_ids[1] =
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG2)
+ ->kinds[eRegisterKindLLDB];
+ argument_register_ids[2] =
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG3)
+ ->kinds[eRegisterKindLLDB];
+ argument_register_ids[3] =
+ reg_ctx->GetRegisterInfo(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG4)
+ ->kinds[eRegisterKindLLDB];
+
+ unsigned int current_argument_register = 0;
+
+ for (value_index = 0; value_index < num_values; ++value_index) {
+ Value *value = values.GetValueAtIndex(value_index);
+
+ if (!value)
+ return false;
+
+ CompilerType compiler_type = value->GetCompilerType();
+ llvm::Optional<uint64_t> bit_size = compiler_type.GetBitSize(&thread);
+ if (!bit_size)
+ return false;
+ bool is_signed;
+
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed)) {
+ ReadIntegerArgument(value->GetScalar(), *bit_size, is_signed, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
+ } else if (compiler_type.IsPointerType()) {
+ ReadIntegerArgument(value->GetScalar(), *bit_size, false, thread,
+ argument_register_ids, current_argument_register,
+ current_stack_argument);
+ }
+ }
+
+ return true;
+}
+
+Status ABIWindows_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+ lldb::ValueObjectSP &new_value_sp) {
+ Status error;
+ if (!new_value_sp) {
+ error.SetErrorString("Empty value object for return value.");
+ return error;
+ }
+
+ CompilerType compiler_type = new_value_sp->GetCompilerType();
+ if (!compiler_type) {
+ error.SetErrorString("Null clang type for return value.");
+ return error;
+ }
+
+ Thread *thread = frame_sp->GetThread().get();
+
+ bool is_signed;
+ uint32_t count;
+ bool is_complex;
+
+ RegisterContext *reg_ctx = thread->GetRegisterContext().get();
+
+ bool set_it_simple = false;
+ if (compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+ compiler_type.IsPointerType()) {
+ const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName("rax", 0);
+
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error.SetErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
+ return error;
+ }
+ lldb::offset_t offset = 0;
+ if (num_bytes <= 8) {
+ uint64_t raw_value = data.GetMaxU64(&offset, num_bytes);
+
+ if (reg_ctx->WriteRegisterFromUnsigned(reg_info, raw_value))
+ set_it_simple = true;
+ } else {
+ error.SetErrorString("We don't support returning longer than 64 bit "
+ "integer values at present.");
+ }
+ } else if (compiler_type.IsFloatingPointType(count, is_complex)) {
+ if (is_complex)
+ error.SetErrorString(
+ "We don't support returning complex values at present");
+ else {
+ llvm::Optional<uint64_t> bit_width =
+ compiler_type.GetBitSize(frame_sp.get());
+ if (!bit_width) {
+ error.SetErrorString("can't get type size");
+ return error;
+ }
+ if (*bit_width <= 64) {
+ const RegisterInfo *xmm0_info =
+ reg_ctx->GetRegisterInfoByName("xmm0", 0);
+ RegisterValue xmm0_value;
+ DataExtractor data;
+ Status data_error;
+ size_t num_bytes = new_value_sp->GetData(data, data_error);
+ if (data_error.Fail()) {
+ error.SetErrorStringWithFormat(
+ "Couldn't convert return value to raw data: %s",
+ data_error.AsCString());
+ return error;
+ }
+
+ unsigned char buffer[16];
+ ByteOrder byte_order = data.GetByteOrder();
+
+ data.CopyByteOrderedData(0, num_bytes, buffer, 16, byte_order);
+ xmm0_value.SetBytes(buffer, 16, byte_order);
+ reg_ctx->WriteRegister(xmm0_info, xmm0_value);
+ set_it_simple = true;
+ } else {
+ // Windows doesn't support 80 bit FP
+ error.SetErrorString(
+ "Windows-x86_64 doesn't allow FP larger than 64 bits.");
+ }
+ }
+ }
+
+ if (!set_it_simple) {
+ // Okay we've got a structure or something that doesn't fit in a simple
+ // register.
+ // TODO(wanyi): On Windows, if the return type is a struct:
+ // 1) smaller that 64 bits and return by value -> RAX
+ // 2) bigger than 64 bits, the caller will allocate memory for that struct
+ // and pass the struct pointer in RCX then return the pointer in RAX
+ error.SetErrorString("We only support setting simple integer and float "
+ "return types at present.");
+ }
+
+ return error;
+}
+
+ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectSimple(
+ Thread &thread, CompilerType &return_compiler_type) const {
+ ValueObjectSP return_valobj_sp;
+ Value value;
+
+ if (!return_compiler_type)
+ return return_valobj_sp;
+
+ value.SetCompilerType(return_compiler_type);
+
+ RegisterContext *reg_ctx = thread.GetRegisterContext().get();
+ if (!reg_ctx)
+ return return_valobj_sp;
+
+ const uint32_t type_flags = return_compiler_type.GetTypeInfo();
+ if (type_flags & eTypeIsScalar) {
+ value.SetValueType(Value::eValueTypeScalar);
+
+ bool success = false;
+ if (type_flags & eTypeIsInteger) {
+ // Extract the register context so we can read arguments from registers
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (!byte_size)
+ return return_valobj_sp;
+ uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(
+ reg_ctx->GetRegisterInfoByName("rax", 0), 0);
+ const bool is_signed = (type_flags & eTypeIsSigned) != 0;
+ switch (*byte_size) {
+ default:
+ break;
+
+ case sizeof(uint64_t):
+ if (is_signed)
+ value.GetScalar() = (int64_t)(raw_value);
+ else
+ value.GetScalar() = (uint64_t)(raw_value);
+ success = true;
+ break;
+
+ case sizeof(uint32_t):
+ if (is_signed)
+ value.GetScalar() = (int32_t)(raw_value & UINT32_MAX);
+ else
+ value.GetScalar() = (uint32_t)(raw_value & UINT32_MAX);
+ success = true;
+ break;
+
+ case sizeof(uint16_t):
+ if (is_signed)
+ value.GetScalar() = (int16_t)(raw_value & UINT16_MAX);
+ else
+ value.GetScalar() = (uint16_t)(raw_value & UINT16_MAX);
+ success = true;
+ break;
+
+ case sizeof(uint8_t):
+ if (is_signed)
+ value.GetScalar() = (int8_t)(raw_value & UINT8_MAX);
+ else
+ value.GetScalar() = (uint8_t)(raw_value & UINT8_MAX);
+ success = true;
+ break;
+ }
+ } else if (type_flags & eTypeIsFloat) {
+ if (type_flags & eTypeIsComplex) {
+ // Don't handle complex yet.
+ } else {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size <= sizeof(long double)) {
+ const RegisterInfo *xmm0_info =
+ reg_ctx->GetRegisterInfoByName("xmm0", 0);
+ RegisterValue xmm0_value;
+ if (reg_ctx->ReadRegister(xmm0_info, xmm0_value)) {
+ DataExtractor data;
+ if (xmm0_value.GetData(data)) {
+ lldb::offset_t offset = 0;
+ if (*byte_size == sizeof(float)) {
+ value.GetScalar() = (float)data.GetFloat(&offset);
+ success = true;
+ } else if (*byte_size == sizeof(double)) {
+ // double and long double are the same on windows
+ value.GetScalar() = (double)data.GetDouble(&offset);
+ success = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (success)
+ return_valobj_sp = ValueObjectConstResult::Create(
+ thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
+ } else if ((type_flags & eTypeIsPointer) ||
+ (type_flags & eTypeInstanceIsPointer)) {
+ unsigned rax_id =
+ reg_ctx->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB];
+ value.GetScalar() =
+ (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id,
+ 0);
+ value.SetValueType(Value::eValueTypeScalar);
+ return_valobj_sp = ValueObjectConstResult::Create(
+ thread.GetStackFrameAtIndex(0).get(), value, ConstString(""));
+ } else if (type_flags & eTypeIsVector) {
+ llvm::Optional<uint64_t> byte_size =
+ return_compiler_type.GetByteSize(nullptr);
+ if (byte_size && *byte_size > 0) {
+ const RegisterInfo *xmm_reg =
+ reg_ctx->GetRegisterInfoByName("xmm0", 0);
+ if (xmm_reg == nullptr)
+ xmm_reg = reg_ctx->GetRegisterInfoByName("mm0", 0);
+
+ if (xmm_reg) {
+ if (*byte_size <= xmm_reg->byte_size) {
+ ProcessSP process_sp(thread.GetProcess());
+ if (process_sp) {
+ std::unique_ptr<DataBufferHeap> heap_data_up(
+ new DataBufferHeap(*byte_size, 0));
+ const ByteOrder byte_order = process_sp->GetByteOrder();
+ RegisterValue reg_value;
+ if (reg_ctx->ReadRegister(xmm_reg, reg_value)) {
+ Status error;
+ if (reg_value.GetAsMemoryData(
+ xmm_reg, heap_data_up->GetBytes(),
+ heap_data_up->GetByteSize(), byte_order, error)) {
+ DataExtractor data(DataBufferSP(heap_data_up.release()),
+ byte_order,
+ process_sp->GetTarget()
+ .GetArchitecture()
+ .GetAddressByteSize());
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), data);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return return_valobj_sp;
+}
+
+// The compiler will flatten the nested aggregate type into single
+// layer and push the value to stack
+// This helper function will flatten an aggregate type
+// and return true if it can be returned in register(s) by value
+// return false if the aggregate is in memory
+static bool FlattenAggregateType(
+ Thread &thread, ExecutionContext &exe_ctx,
+ CompilerType &return_compiler_type,
+ uint32_t data_byte_offset,
+ std::vector<uint32_t> &aggregate_field_offsets,
+ std::vector<CompilerType> &aggregate_compiler_types) {
+
+ const uint32_t num_children = return_compiler_type.GetNumFields();
+ for (uint32_t idx = 0; idx < num_children; ++idx) {
+ std::string name;
+ bool is_signed;
+ uint32_t count;
+ bool is_complex;
+
+ uint64_t field_bit_offset = 0;
+ CompilerType field_compiler_type = return_compiler_type.GetFieldAtIndex(
+ idx, name, &field_bit_offset, nullptr, nullptr);
+ llvm::Optional<uint64_t> field_bit_width =
+ field_compiler_type.GetBitSize(&thread);
+
+ // if we don't know the size of the field (e.g. invalid type), exit
+ if (!field_bit_width || *field_bit_width == 0) {
+ return false;
+ }
+ // If there are any unaligned fields, this is stored in memory.
+ if (field_bit_offset % *field_bit_width != 0) {
+ return false;
+ }
+
+ // add overall offset
+ uint32_t field_byte_offset = field_bit_offset / 8 + data_byte_offset;
+
+ const uint32_t field_type_flags = field_compiler_type.GetTypeInfo();
+ if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+ field_compiler_type.IsPointerType() ||
+ field_compiler_type.IsFloatingPointType(count, is_complex)) {
+ aggregate_field_offsets.push_back(field_byte_offset);
+ aggregate_compiler_types.push_back(field_compiler_type);
+ } else if (field_type_flags & eTypeHasChildren) {
+ if (!FlattenAggregateType(thread, exe_ctx, field_compiler_type,
+ field_byte_offset, aggregate_field_offsets,
+ aggregate_compiler_types)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+ValueObjectSP ABIWindows_x86_64::GetReturnValueObjectImpl(
+ Thread &thread, CompilerType &return_compiler_type) const {
+ ValueObjectSP return_valobj_sp;
+
+ if (!return_compiler_type) {
+ return return_valobj_sp;
+ }
+
+ // try extract value as if it's a simple type
+ return_valobj_sp = GetReturnValueObjectSimple(thread, return_compiler_type);
+ if (return_valobj_sp) {
+ return return_valobj_sp;
+ }
+
+ RegisterContextSP reg_ctx_sp = thread.GetRegisterContext();
+ if (!reg_ctx_sp) {
+ return return_valobj_sp;
+ }
+
+ llvm::Optional<uint64_t> bit_width = return_compiler_type.GetBitSize(&thread);
+ if (!bit_width) {
+ return return_valobj_sp;
+ }
+
+ // if it's not simple or aggregate type, then we don't know how to handle it
+ if (!return_compiler_type.IsAggregateType()) {
+ return return_valobj_sp;
+ }
+
+ ExecutionContext exe_ctx(thread.shared_from_this());
+ Target *target = exe_ctx.GetTargetPtr();
+ uint32_t max_register_value_bit_width = 64;
+
+ // The scenario here is to have a struct/class which is POD
+ // if the return struct/class size is larger than 64 bits,
+ // the caller will allocate memory for it and pass the return addr in RCX
+ // then return the address in RAX
+
+ // if the struct is returned by value in register (RAX)
+ // its size has to be: 1, 2, 4, 8, 16, 32, or 64 bits (aligned)
+ // for floating point, the return value will be copied over to RAX
+ bool is_memory = *bit_width > max_register_value_bit_width ||
+ *bit_width & (*bit_width - 1);
+ std::vector<uint32_t> aggregate_field_offsets;
+ std::vector<CompilerType> aggregate_compiler_types;
+ if (!is_memory &&
+ FlattenAggregateType(thread, exe_ctx, return_compiler_type,
+ 0, aggregate_field_offsets,
+ aggregate_compiler_types)) {
+ ByteOrder byte_order = target->GetArchitecture().GetByteOrder();
+ DataBufferSP data_sp(
+ new DataBufferHeap(max_register_value_bit_width / 8, 0));
+ DataExtractor return_ext(data_sp, byte_order,
+ target->GetArchitecture().GetAddressByteSize());
+
+ // The only register used to return struct/class by value
+ const RegisterInfo *rax_info =
+ reg_ctx_sp->GetRegisterInfoByName("rax", 0);
+ RegisterValue rax_value;
+ reg_ctx_sp->ReadRegister(rax_info, rax_value);
+ DataExtractor rax_data;
+ rax_value.GetData(rax_data);
+
+ uint32_t used_bytes =
+ 0; // Tracks how much of the rax registers we've consumed so far
+
+ // in case of the returned type is a subclass of non-abstract-base class
+ // it will have a padding to skip the base content
+ if (aggregate_field_offsets.size())
+ used_bytes = aggregate_field_offsets[0];
+
+ const uint32_t num_children = aggregate_compiler_types.size();
+ for (uint32_t idx = 0; idx < num_children; idx++) {
+ bool is_signed;
+ bool is_complex;
+ uint32_t count;
+
+ CompilerType field_compiler_type = aggregate_compiler_types[idx];
+ uint32_t field_byte_width = (uint32_t) (*field_compiler_type.GetByteSize(&thread));
+ uint32_t field_byte_offset = aggregate_field_offsets[idx];
+
+ // this is unlikely w/o the overall size being greater than 8 bytes
+ // For now, return a nullptr return value object.
+ if (used_bytes >= 8 || used_bytes + field_byte_width > 8) {
+ return return_valobj_sp;
+ }
+
+ DataExtractor *copy_from_extractor = nullptr;
+ uint32_t copy_from_offset = 0;
+ if (field_compiler_type.IsIntegerOrEnumerationType(is_signed) ||
+ field_compiler_type.IsPointerType() ||
+ field_compiler_type.IsFloatingPointType(count, is_complex)) {
+ copy_from_extractor = &rax_data;
+ copy_from_offset = used_bytes;
+ used_bytes += field_byte_width;
+ }
+ // These two tests are just sanity checks. If I somehow get the type
+ // calculation wrong above it is better to just return nothing than to
+ // assert or crash.
+ if (!copy_from_extractor) {
+ return return_valobj_sp;
+ }
+ if (copy_from_offset + field_byte_width >
+ copy_from_extractor->GetByteSize()) {
+ return return_valobj_sp;
+ }
+ copy_from_extractor->CopyByteOrderedData(copy_from_offset,
+ field_byte_width, data_sp->GetBytes() + field_byte_offset,
+ field_byte_width, byte_order);
+ }
+ if (!is_memory) {
+ // The result is in our data buffer. Let's make a variable object out
+ // of it:
+ return_valobj_sp = ValueObjectConstResult::Create(
+ &thread, return_compiler_type, ConstString(""), return_ext);
+ }
+ }
+
+ // The Windows x86_64 ABI specifies that the return address for MEMORY
+ // objects be placed in rax on exit from the function.
+
+ // FIXME: This is just taking a guess, rax may very well no longer hold the
+ // return storage location.
+ // If we are going to do this right, when we make a new frame we should
+ // check to see if it uses a memory return, and if we are at the first
+ // instruction and if so stash away the return location. Then we would
+ // only return the memory return value if we know it is valid.
+ if (is_memory) {
+ unsigned rax_id =
+ reg_ctx_sp->GetRegisterInfoByName("rax", 0)->kinds[eRegisterKindLLDB];
+ lldb::addr_t storage_addr =
+ (uint64_t)thread.GetRegisterContext()->ReadRegisterAsUnsigned(rax_id,
+ 0);
+ return_valobj_sp = ValueObjectMemory::Create(
+ &thread, "", Address(storage_addr, nullptr), return_compiler_type);
+ }
+ return return_valobj_sp;
+}
+
+// This defines the CFA as rsp+8
+// the saved pc is at CFA-8 (i.e. rsp+0)
+// The saved rsp is CFA+0
+
+bool ABIWindows_x86_64::CreateFunctionEntryUnwindPlan(UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
+
+ uint32_t sp_reg_num = dwarf_rsp;
+ uint32_t pc_reg_num = dwarf_rip;
+
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+ row->GetCFAValue().SetIsRegisterPlusOffset(sp_reg_num, 8);
+ row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, -8, false);
+ row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true);
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetSourceName("x86_64 at-func-entry default");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ return true;
+}
+
+// Windows-x86_64 doesn't use %rbp
+// No available Unwind information for Windows-x86_64 (section .pdata)
+// Let's use SysV-x86_64 one for now
+bool ABIWindows_x86_64::CreateDefaultUnwindPlan(UnwindPlan &unwind_plan) {
+ unwind_plan.Clear();
+ unwind_plan.SetRegisterKind(eRegisterKindDWARF);
+
+ uint32_t fp_reg_num = dwarf_rbp;
+ uint32_t sp_reg_num = dwarf_rsp;
+ uint32_t pc_reg_num = dwarf_rip;
+
+ UnwindPlan::RowSP row(new UnwindPlan::Row);
+
+ const int32_t ptr_size = 8;
+ row->GetCFAValue().SetIsRegisterPlusOffset(dwarf_rbp, 2 * ptr_size);
+ row->SetOffset(0);
+
+ row->SetRegisterLocationToAtCFAPlusOffset(fp_reg_num, ptr_size * -2, true);
+ row->SetRegisterLocationToAtCFAPlusOffset(pc_reg_num, ptr_size * -1, true);
+ row->SetRegisterLocationToIsCFAPlusOffset(sp_reg_num, 0, true);
+
+ unwind_plan.AppendRow(row);
+ unwind_plan.SetSourceName("x86_64 default unwind plan");
+ unwind_plan.SetSourcedFromCompiler(eLazyBoolNo);
+ unwind_plan.SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+
+ return true;
+}
+
+bool ABIWindows_x86_64::RegisterIsVolatile(const RegisterInfo *reg_info) {
+ return !RegisterIsCalleeSaved(reg_info);
+}
+
+bool ABIWindows_x86_64::RegisterIsCalleeSaved(const RegisterInfo *reg_info) {
+ if (!reg_info)
+ return false;
+ assert(reg_info->name != nullptr && "unnamed register?");
+ std::string Name = std::string(reg_info->name);
+ bool IsCalleeSaved =
+ llvm::StringSwitch<bool>(Name)
+ .Cases("rbx", "ebx", "rbp", "ebp", "rdi", "edi", "rsi", "esi", true)
+ .Cases("rsp", "esp", "r12", "r13", "r14", "r15", "sp", "fp", true)
+ .Cases("xmm6", "xmm7", "xmm8", "xmm9", "xmm10", "xmm11", "xmm12",
+ "xmm13", "xmm14", "xmm15", true)
+ .Default(false);
+ return IsCalleeSaved;
+}
+
+void ABIWindows_x86_64::Initialize() {
+ PluginManager::RegisterPlugin(
+ GetPluginNameStatic(), "Windows ABI for x86_64 targets", CreateInstance);
+}
+
+void ABIWindows_x86_64::Terminate() {
+ PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+lldb_private::ConstString ABIWindows_x86_64::GetPluginNameStatic() {
+ static ConstString g_name("windows-x86_64");
+ return g_name;
+}
+
+//------------------------------------------------------------------
+// PluginInterface protocol
+//------------------------------------------------------------------
+
+lldb_private::ConstString ABIWindows_x86_64::GetPluginName() {
+ return GetPluginNameStatic();
+}
+
+uint32_t ABIWindows_x86_64::GetPluginVersion() { return 1; }
diff --git a/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h b/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
new file mode 100644
index 0000000000000..9f6b2ceef2997
--- /dev/null
+++ b/source/Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h
@@ -0,0 +1,99 @@
+//===-- ABIWindows_x86_64.h ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ABIWindows_x86_64_h_
+#define liblldb_ABIWindows_x86_64_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIWindows_x86_64 : public lldb_private::ABI {
+public:
+ ~ABIWindows_x86_64() override = default;
+
+ size_t GetRedZoneSize() const override;
+
+ 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 override;
+
+ bool GetArgumentValues(lldb_private::Thread &thread,
+ lldb_private::ValueList &values) const override;
+
+ lldb_private::Status
+ SetReturnValueObject(lldb::StackFrameSP &frame_sp,
+ lldb::ValueObjectSP &new_value) override;
+
+ lldb::ValueObjectSP
+ GetReturnValueObjectImpl(lldb_private::Thread &thread,
+ lldb_private::CompilerType &type) const override;
+
+ bool
+ CreateFunctionEntryUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+ bool CreateDefaultUnwindPlan(lldb_private::UnwindPlan &unwind_plan) override;
+
+ bool RegisterIsVolatile(const lldb_private::RegisterInfo *reg_info) override;
+
+ // In Windows_x86_64 ABI, stack will always be maintained 16-byte aligned
+ bool CallFrameAddressIsValid(lldb::addr_t cfa) override {
+ if (cfa & (16ull - 1ull))
+ return false; // Not 16 byte aligned
+ if (cfa == 0)
+ return false; // Zero is not a valid stack address
+ return true;
+ }
+
+ bool CodeAddressIsValid(lldb::addr_t pc) override {
+ // We have a 64 bit address space, so anything is valid as opcodes
+ // aren't fixed width...
+ return true;
+ }
+
+ const lldb_private::RegisterInfo *
+ GetRegisterInfoArray(uint32_t &count) override;
+
+ bool GetPointerReturnRegister(const char *&name) override;
+
+ //------------------------------------------------------------------
+ // Static Functions
+ //------------------------------------------------------------------
+
+ static void Initialize();
+
+ static void Terminate();
+
+ static lldb::ABISP CreateInstance(lldb::ProcessSP process_sp, const lldb_private::ArchSpec &arch);
+
+ static lldb_private::ConstString GetPluginNameStatic();
+
+ //------------------------------------------------------------------
+ // PluginInterface protocol
+ //------------------------------------------------------------------
+
+ lldb_private::ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
+
+protected:
+ void CreateRegisterMapIfNeeded();
+
+ lldb::ValueObjectSP
+ GetReturnValueObjectSimple(lldb_private::Thread &thread,
+ lldb_private::CompilerType &ast_type) const;
+
+ bool RegisterIsCalleeSaved(const lldb_private::RegisterInfo *reg_info);
+
+private:
+ ABIWindows_x86_64(lldb::ProcessSP process_sp) : lldb_private::ABI(process_sp) {
+ // Call CreateInstance instead.
+ }
+};
+
+#endif // liblldb_ABISysV_x86_64_h_
diff --git a/source/Plugins/Architecture/Arm/ArchitectureArm.cpp b/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
index 6993222ba5d41..5b86df6c52732 100644
--- a/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
+++ b/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
@@ -1,9 +1,8 @@
//===-- ArchitectureArm.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Architecture/Arm/ArchitectureArm.h b/source/Plugins/Architecture/Arm/ArchitectureArm.h
index 1a052c76b2c95..03e79ce524a72 100644
--- a/source/Plugins/Architecture/Arm/ArchitectureArm.h
+++ b/source/Plugins/Architecture/Arm/ArchitectureArm.h
@@ -1,9 +1,8 @@
//===-- ArchitectureArm.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Architecture/Mips/ArchitectureMips.cpp b/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
index 0cbbd99223213..60f1a2eb75724 100644
--- a/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
+++ b/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
@@ -1,9 +1,8 @@
//===-- ArchitectureMips.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Architecture/Mips/ArchitectureMips.h b/source/Plugins/Architecture/Mips/ArchitectureMips.h
index 2338daf2e4686..a15991ff9ebf5 100644
--- a/source/Plugins/Architecture/Mips/ArchitectureMips.h
+++ b/source/Plugins/Architecture/Mips/ArchitectureMips.h
@@ -1,9 +1,8 @@
//===-- ArchitectureMips.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
index 619de093aaccf..76eaa44546eb1 100644
--- a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
+++ b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
@@ -1,9 +1,8 @@
//===-- ArchitecturePPC64.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,11 +35,10 @@ void ArchitecturePPC64::Terminate() {
}
std::unique_ptr<Architecture> ArchitecturePPC64::Create(const ArchSpec &arch) {
- if ((arch.GetMachine() != llvm::Triple::ppc64 &&
- arch.GetMachine() != llvm::Triple::ppc64le) ||
- arch.GetTriple().getObjectFormat() != llvm::Triple::ObjectFormatType::ELF)
- return nullptr;
- return std::unique_ptr<Architecture>(new ArchitecturePPC64());
+ if (arch.GetTriple().isPPC64() &&
+ arch.GetTriple().getObjectFormat() == llvm::Triple::ObjectFormatType::ELF)
+ return std::unique_ptr<Architecture>(new ArchitecturePPC64());
+ return nullptr;
}
ConstString ArchitecturePPC64::GetPluginName() { return GetPluginNameStatic(); }
diff --git a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
index 95638853ad3dc..dc663b849c4ab 100644
--- a/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
+++ b/source/Plugins/Architecture/PPC64/ArchitecturePPC64.h
@@ -1,9 +1,8 @@
//===-- ArchitecturePPC64.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,10 +24,8 @@ public:
void OverrideStopInfo(Thread &thread) const override {}
- //------------------------------------------------------------------
/// This method compares current address with current function's
/// local entry point, returning the bytes to skip if they match.
- //------------------------------------------------------------------
size_t GetBytesToSkip(Symbol &func, const Address &curr_addr) const override;
void AdjustBreakpointAddress(const Symbol &func,
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
index 5df8422505915..44c75fc953c82 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
@@ -1,9 +1,8 @@
//===-- DisassemblerLLVMC.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -357,7 +356,7 @@ public:
return;
else {
const uint8_t *bytes = data.PeekData(offset, inst_size);
- if (bytes == NULL)
+ if (bytes == nullptr)
return;
m_opcode_name.assign(".byte");
m_opcode.SetOpcodeBytes(bytes, inst_size);
@@ -957,7 +956,7 @@ DisassemblerLLVMC::MCDisasmInstance::Create(const char *triple, const char *cpu,
return Instance();
std::unique_ptr<llvm::MCContext> context_up(
- new llvm::MCContext(asm_info_up.get(), reg_info_up.get(), 0));
+ new llvm::MCContext(asm_info_up.get(), reg_info_up.get(), nullptr));
if (!context_up)
return Instance();
@@ -1080,7 +1079,7 @@ bool DisassemblerLLVMC::MCDisasmInstance::IsCall(llvm::MCInst &mc_inst) const {
DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
const char *flavor_string)
- : Disassembler(arch, flavor_string), m_exe_ctx(NULL), m_inst(NULL),
+ : Disassembler(arch, flavor_string), m_exe_ctx(nullptr), m_inst(nullptr),
m_data_from_file(false) {
if (!FlavorValidForArchSpec(arch, m_flavor.c_str())) {
m_flavor.assign("default");
@@ -1179,10 +1178,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
break;
}
- if (triple.getArch() == llvm::Triple::mips ||
- triple.getArch() == llvm::Triple::mipsel ||
- triple.getArch() == llvm::Triple::mips64 ||
- triple.getArch() == llvm::Triple::mips64el) {
+ if (arch.IsMIPS()) {
uint32_t arch_flags = arch.GetFlags();
if (arch_flags & ArchSpec::eMIPSAse_msa)
features_str += "+msa,";
@@ -1192,12 +1188,17 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
features_str += "+dspr2,";
}
- // If any AArch64 variant, enable the ARMv8.2 ISA extensions so we can
- // disassemble newer instructions.
+ // If any AArch64 variant, enable the ARMv8.5 ISA with SVE extensions so we
+ // can disassemble newer instructions.
if (triple.getArch() == llvm::Triple::aarch64)
- features_str += "+v8.2a";
+ features_str += "+v8.5a,+sve2";
+
+ if (triple.getArch() == llvm::Triple::aarch64
+ && triple.getVendor() == llvm::Triple::Apple) {
+ cpu = "apple-latest";
+ }
- // We use m_disasm_ap.get() to tell whether we are valid or not, so if this
+ // We use m_disasm_up.get() to tell whether we are valid or not, so if this
// isn't good for some reason, we won't be valid and FindPlugin will fail and
// we won't get used.
m_disasm_up = MCDisasmInstance::Create(triple_str, cpu, features_str.c_str(),
@@ -1215,10 +1216,7 @@ DisassemblerLLVMC::DisassemblerLLVMC(const ArchSpec &arch,
if (!m_alternate_disasm_up)
m_disasm_up.reset();
- } else if (llvm_arch == llvm::Triple::mips ||
- llvm_arch == llvm::Triple::mipsel ||
- llvm_arch == llvm::Triple::mips64 ||
- llvm_arch == llvm::Triple::mips64el) {
+ } else if (arch.IsMIPS()) {
/* Create alternate disassembler for MIPS16 and microMIPS */
uint32_t arch_flags = arch.GetFlags();
if (arch_flags & ArchSpec::eMIPSAse_mips16)
@@ -1238,13 +1236,13 @@ DisassemblerLLVMC::~DisassemblerLLVMC() = default;
Disassembler *DisassemblerLLVMC::CreateInstance(const ArchSpec &arch,
const char *flavor) {
if (arch.GetTriple().getArch() != llvm::Triple::UnknownArch) {
- std::unique_ptr<DisassemblerLLVMC> disasm_ap(
+ std::unique_ptr<DisassemblerLLVMC> disasm_up(
new DisassemblerLLVMC(arch, flavor));
- if (disasm_ap.get() && disasm_ap->IsValid())
- return disasm_ap.release();
+ if (disasm_up.get() && disasm_up->IsValid())
+ return disasm_up.release();
}
- return NULL;
+ return nullptr;
}
size_t DisassemblerLLVMC::DecodeInstructions(const Address &base_addr,
@@ -1331,7 +1329,7 @@ const char *DisassemblerLLVMC::SymbolLookupCallback(void *disassembler,
bool DisassemblerLLVMC::FlavorValidForArchSpec(
const lldb_private::ArchSpec &arch, const char *flavor) {
llvm::Triple triple = arch.GetTriple();
- if (flavor == NULL || strcmp(flavor, "default") == 0)
+ if (flavor == nullptr || strcmp(flavor, "default") == 0)
return true;
if (triple.getArch() == llvm::Triple::x86 ||
@@ -1360,7 +1358,7 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
if (*type_ptr) {
if (m_exe_ctx && m_inst) {
// std::string remove_this_prior_to_checkin;
- Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : NULL;
+ Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : nullptr;
Address value_so_addr;
Address pc_so_addr;
if (m_inst->UsingFileAddress()) {
@@ -1425,13 +1423,11 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr,
}
*type_ptr = LLVMDisassembler_ReferenceType_InOut_None;
- *name = NULL;
- return NULL;
+ *name = nullptr;
+ return nullptr;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString DisassemblerLLVMC::GetPluginName() { return GetPluginNameStatic(); }
uint32_t DisassemblerLLVMC::GetPluginVersion() { return 1; }
diff --git a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
index 8b9f7c37d2b85..fd5775056d334 100644
--- a/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
+++ b/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
@@ -1,9 +1,8 @@
//===-- DisassemblerLLVMC.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,9 +26,7 @@ public:
~DisassemblerLLVMC() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -44,9 +41,7 @@ public:
lldb::offset_t data_offset, size_t num_instructions,
bool append, bool data_from_file) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
index 81eab8fdd970b..23c8416f49860 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
@@ -1,9 +1,8 @@
//===-- DynamicLoaderHexagonDYLD.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,6 +20,8 @@
#include "DynamicLoaderHexagonDYLD.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -58,7 +59,7 @@ static lldb::addr_t findSymbolAddress(Process *proc, ConstString findName) {
for (size_t i = 0; i < symtab->GetNumSymbols(); i++) {
const Symbol *sym = symtab->SymbolAtIndex(i);
assert(sym != nullptr);
- const ConstString &symName = sym->GetName();
+ ConstString symName = sym->GetName();
if (ConstString::Compare(findName, symName) == 0) {
Address addr = sym->GetAddress();
@@ -103,7 +104,7 @@ DynamicLoader *DynamicLoaderHexagonDYLD::CreateInstance(Process *process,
if (create)
return new DynamicLoaderHexagonDYLD(process);
- return NULL;
+ return nullptr;
}
DynamicLoaderHexagonDYLD::DynamicLoaderHexagonDYLD(Process *process)
@@ -198,7 +199,7 @@ ModuleSP DynamicLoaderHexagonDYLD::GetTargetExecutable() {
return executable;
// TODO: What case is this code used?
- executable = target.GetSharedModule(module_spec);
+ executable = target.GetOrCreateModule(module_spec, true /* notify */);
if (executable.get() != target.GetExecutableModulePointer()) {
// Don't load dependent images since we are in dyld where we will know and
// find out about all images that are loaded
@@ -242,9 +243,9 @@ void DynamicLoaderHexagonDYLD::UpdateLoadedSections(ModuleSP module,
}
}
-/// Removes the loaded sections from the target in @p module.
+/// Removes the loaded sections from the target in \p module.
///
-/// @param module The module to traverse.
+/// \param module The module to traverse.
void DynamicLoaderHexagonDYLD::UnloadSections(const ModuleSP module) {
Target &target = m_process->GetTarget();
const SectionList *sections = GetSectionListFromModule(module);
@@ -419,7 +420,7 @@ DynamicLoaderHexagonDYLD::GetStepThroughTrampolinePlan(Thread &thread,
const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol);
Symbol *sym = context.symbol;
- if (sym == NULL || !sym->IsTrampoline())
+ if (sym == nullptr || !sym->IsTrampoline())
return thread_plan_sp;
const ConstString sym_name = sym->GetMangled().GetName(
@@ -455,7 +456,8 @@ DynamicLoaderHexagonDYLD::GetStepThroughTrampolinePlan(Thread &thread,
llvm::sort(start, end);
addrs.erase(std::unique(start, end), end);
- thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop));
+ thread_plan_sp =
+ std::make_shared<ThreadPlanRunToAddress>(thread, addrs, stop);
}
return thread_plan_sp;
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
index d39f14e8b3fb8..c171513c54997 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.h
@@ -1,9 +1,8 @@
//===-- DynamicLoaderHexagonDYLD.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,7 @@ public:
static lldb_private::DynamicLoader *
CreateInstance(lldb_private::Process *process, bool force);
- //------------------------------------------------------------------
// DynamicLoader protocol
- //------------------------------------------------------------------
void DidAttach() override;
@@ -49,9 +46,7 @@ public:
const lldb::ThreadSP thread,
lldb::addr_t tls_file_addr) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -87,21 +82,21 @@ protected:
/// of loaded modules.
void RefreshModules();
- /// Updates the load address of every allocatable section in @p module.
+ /// Updates the load address of every allocatable section in \p module.
///
- /// @param module The module to traverse.
+ /// \param module The module to traverse.
///
- /// @param link_map_addr The virtual address of the link map for the @p
+ /// \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.
+ /// \param base_addr The virtual base address \p module is loaded at.
void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,
lldb::addr_t base_addr,
bool base_addr_is_offset) override;
- /// Removes the loaded sections from the target in @p module.
+ /// Removes the loaded sections from the target in \p module.
///
- /// @param module The module to traverse.
+ /// \param module The module to traverse.
void UnloadSections(const lldb::ModuleSP module) override;
/// Callback routine invoked when we hit the breakpoint on process entry.
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
index d5f60e07bd77d..844a06c2b37d4 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
@@ -1,9 +1,8 @@
//===-- HexagonDYLDRendezvous.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
index 758f358dc6185..70fc12b7fab72 100644
--- a/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
+++ b/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.h
@@ -1,9 +1,8 @@
//===-- HexagonDYLDRendezvous.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,7 @@ namespace lldb_private {
class Process;
}
-/// @class HexagonDYLDRendezvous
+/// \class HexagonDYLDRendezvous
/// Interface to the runtime linker.
///
/// A structure is present in a processes memory space which is updated by the
@@ -66,36 +65,36 @@ public:
/// This method should be called once one start up, then once each time the
/// runtime linker enters the function given by GetBreakAddress().
///
- /// @returns true on success and false on failure.
+ /// \returns true on success and false on failure.
///
- /// @see GetBreakAddress().
+ /// \see GetBreakAddress().
bool Resolve();
- /// @returns true if this rendezvous has been located in the inferiors
+ /// \returns true if this rendezvous has been located in the inferiors
/// address space and false otherwise.
bool IsValid();
- /// @returns the address of the rendezvous structure in the inferiors
+ /// \returns the address of the rendezvous structure in the inferiors
/// address space.
lldb::addr_t GetRendezvousAddress() const { return m_rendezvous_addr; }
/// Provide the dyld structure address
void SetRendezvousAddress(lldb::addr_t);
- /// @returns the version of the rendezvous protocol being used.
+ /// \returns the version of the rendezvous protocol being used.
uint64_t GetVersion() const { return m_current.version; }
- /// @returns address in the inferiors address space containing the linked
+ /// \returns address in the inferiors address space containing the linked
/// list of shared object descriptors.
lldb::addr_t GetLinkMapAddress() const { return m_current.map_addr; }
/// A breakpoint should be set at this address and Resolve called on each
/// hit.
///
- /// @returns the address of a function called by the runtime linker each
+ /// \returns the address of a function called by the runtime linker each
/// time a module is loaded/unloaded, or about to be loaded/unloaded.
///
- /// @see Resolve()
+ /// \see Resolve()
lldb::addr_t GetBreakAddress() const { return m_current.brk; }
/// In hexagon it is possible that we can know the dyld breakpoint without
@@ -106,18 +105,18 @@ public:
/// Returns the current state of the rendezvous structure.
uint64_t GetState() const { return m_current.state; }
- /// @returns the base address of the runtime linker in the inferiors address
+ /// \returns the base address of the runtime linker in the inferiors address
/// space.
lldb::addr_t GetLDBase() const { return m_current.ldbase; }
- /// @returns the thread layout metadata from the inferiors thread library.
+ /// \returns the thread layout metadata from the inferiors thread library.
const ThreadInfo &GetThreadInfo();
- /// @returns true if modules have been loaded into the inferior since the
+ /// \returns true if modules have been loaded into the inferior since the
/// last call to Resolve().
bool ModulesDidLoad() const { return !m_added_soentries.empty(); }
- /// @returns true if modules have been unloaded from the inferior since the
+ /// \returns true if modules have been unloaded from the inferior since the
/// last call to Resolve().
bool ModulesDidUnload() const { return !m_removed_soentries.empty(); }
@@ -125,7 +124,7 @@ public:
/// Constants describing the state of the rendezvous.
///
- /// @see GetState().
+ /// \see GetState().
enum RendezvousState {
eConsistent = 0,
eAdd,
@@ -208,15 +207,15 @@ protected:
/// Threading metadata read from the inferior.
ThreadInfo m_thread_info;
- /// Reads an unsigned integer of @p size bytes from the inferior's address
- /// space starting at @p addr.
+ /// Reads an unsigned integer of \p size bytes from the inferior's address
+ /// space starting at \p addr.
///
- /// @returns addr + size if the read was successful and false otherwise.
+ /// \returns addr + size if the read was successful and false otherwise.
lldb::addr_t ReadWord(lldb::addr_t addr, uint64_t *dst, size_t size);
- /// Reads an address from the inferior's address space starting at @p addr.
+ /// Reads an address from the inferior's address space starting at \p addr.
///
- /// @returns addr + target address size if the read was successful and
+ /// \returns addr + target address size if the read was successful and
/// 0 otherwise.
lldb::addr_t ReadPointer(lldb::addr_t addr, lldb::addr_t *dst);
@@ -224,7 +223,7 @@ protected:
/// addr.
std::string ReadStringFromMemory(lldb::addr_t addr);
- /// Reads an SOEntry starting at @p addr.
+ /// Reads an SOEntry starting at \p addr.
bool ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry);
/// Updates the current set of SOEntries, the set of added entries, and the
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
deleted file mode 100644
index 8068795df53a5..0000000000000
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-//===-- AuxVector.cpp -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "AuxVector.h"
-#include "lldb/Target/Process.h"
-#include "lldb/Utility/DataBufferHeap.h"
-#include "lldb/Utility/DataExtractor.h"
-#include "lldb/Utility/Log.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-static bool GetMaxU64(DataExtractor &data, lldb::offset_t *offset_ptr,
- uint64_t *value, unsigned int byte_size) {
- lldb::offset_t saved_offset = *offset_ptr;
- *value = data.GetMaxU64(offset_ptr, byte_size);
- return *offset_ptr != saved_offset;
-}
-
-static bool ParseAuxvEntry(DataExtractor &data, AuxVector::Entry &entry,
- lldb::offset_t *offset_ptr, unsigned int byte_size) {
- if (!GetMaxU64(data, offset_ptr, &entry.type, byte_size))
- return false;
-
- if (!GetMaxU64(data, offset_ptr, &entry.value, byte_size))
- return false;
-
- return true;
-}
-
-DataBufferSP AuxVector::GetAuxvData() {
- if (m_process)
- return m_process->GetAuxvData();
- else
- return DataBufferSP();
-}
-
-void AuxVector::ParseAuxv(DataExtractor &data) {
- const unsigned int byte_size = m_process->GetAddressByteSize();
- lldb::offset_t offset = 0;
-
- for (;;) {
- Entry entry;
-
- if (!ParseAuxvEntry(data, entry, &offset, byte_size))
- break;
-
- if (entry.type == AUXV_AT_NULL)
- break;
-
- if (entry.type == AUXV_AT_IGNORE)
- continue;
-
- m_auxv.push_back(entry);
- }
-}
-
-AuxVector::AuxVector(Process *process) : m_process(process) {
- DataExtractor data;
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
-
- data.SetData(GetAuxvData());
- data.SetByteOrder(m_process->GetByteOrder());
- data.SetAddressByteSize(m_process->GetAddressByteSize());
-
- ParseAuxv(data);
-
- if (log)
- DumpToLog(log);
-}
-
-AuxVector::iterator AuxVector::FindEntry(EntryType type) const {
- for (iterator I = begin(); I != end(); ++I) {
- if (I->type == static_cast<uint64_t>(type))
- return I;
- }
-
- return end();
-}
-
-void AuxVector::DumpToLog(Log *log) const {
- if (!log)
- return;
-
- log->PutCString("AuxVector: ");
- for (iterator I = begin(); I != end(); ++I) {
- log->Printf(" %s [%" PRIu64 "]: %" PRIx64, GetEntryName(*I), I->type,
- I->value);
- }
-}
-
-const char *AuxVector::GetEntryName(EntryType type) {
- const char *name = "AT_???";
-
-#define ENTRY_NAME(_type) \
- _type: \
- name = &#_type[5]
- switch (type) {
- case ENTRY_NAME(AUXV_AT_NULL); break;
- case ENTRY_NAME(AUXV_AT_IGNORE); break;
- case ENTRY_NAME(AUXV_AT_EXECFD); break;
- case ENTRY_NAME(AUXV_AT_PHDR); break;
- case ENTRY_NAME(AUXV_AT_PHENT); break;
- case ENTRY_NAME(AUXV_AT_PHNUM); break;
- case ENTRY_NAME(AUXV_AT_PAGESZ); break;
- case ENTRY_NAME(AUXV_AT_BASE); break;
- case ENTRY_NAME(AUXV_AT_FLAGS); break;
- case ENTRY_NAME(AUXV_AT_ENTRY); break;
- case ENTRY_NAME(AUXV_AT_NOTELF); break;
- case ENTRY_NAME(AUXV_AT_UID); break;
- case ENTRY_NAME(AUXV_AT_EUID); break;
- case ENTRY_NAME(AUXV_AT_GID); break;
- case ENTRY_NAME(AUXV_AT_EGID); break;
- case ENTRY_NAME(AUXV_AT_CLKTCK); break;
- case ENTRY_NAME(AUXV_AT_PLATFORM); break;
- case ENTRY_NAME(AUXV_AT_HWCAP); break;
- case ENTRY_NAME(AUXV_AT_FPUCW); break;
- case ENTRY_NAME(AUXV_AT_DCACHEBSIZE); break;
- case ENTRY_NAME(AUXV_AT_ICACHEBSIZE); break;
- case ENTRY_NAME(AUXV_AT_UCACHEBSIZE); break;
- case ENTRY_NAME(AUXV_AT_IGNOREPPC); break;
- case ENTRY_NAME(AUXV_AT_SECURE); break;
- case ENTRY_NAME(AUXV_AT_BASE_PLATFORM); break;
- case ENTRY_NAME(AUXV_AT_RANDOM); break;
- case ENTRY_NAME(AUXV_AT_EXECFN); break;
- case ENTRY_NAME(AUXV_AT_SYSINFO); break;
- case ENTRY_NAME(AUXV_AT_SYSINFO_EHDR); break;
- case ENTRY_NAME(AUXV_AT_L1I_CACHESHAPE); break;
- case ENTRY_NAME(AUXV_AT_L1D_CACHESHAPE); break;
- case ENTRY_NAME(AUXV_AT_L2_CACHESHAPE); break;
- case ENTRY_NAME(AUXV_AT_L3_CACHESHAPE); break;
- }
-#undef ENTRY_NAME
-
- return name;
-}
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h b/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
deleted file mode 100644
index 25446e33afd49..0000000000000
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/AuxVector.h
+++ /dev/null
@@ -1,109 +0,0 @@
-//===-- AuxVector.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_AuxVector_H_
-#define liblldb_AuxVector_H_
-
-#include <vector>
-
-#include "lldb/lldb-forward.h"
-
-namespace lldb_private {
-class DataExtractor;
-}
-
-/// @class AuxVector
-/// Represents a processes auxiliary vector.
-///
-/// When a process is loaded on Linux a vector of values is placed onto the
-/// stack communicating operating system specific information. On
-/// construction this class locates and parses this information and provides a
-/// simple read-only interface to the entries found.
-class AuxVector {
-
-public:
- AuxVector(lldb_private::Process *process);
-
- struct Entry {
- uint64_t type;
- uint64_t value;
-
- Entry() : type(0), value(0) {}
- };
-
- /// Constants describing the type of entry.
- /// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
- /// information. Added AUXV prefix to avoid potential conflicts with system-
- /// defined macros
- enum EntryType {
- AUXV_AT_NULL = 0, ///< End of auxv.
- AUXV_AT_IGNORE = 1, ///< Ignore entry.
- AUXV_AT_EXECFD = 2, ///< File descriptor of program.
- AUXV_AT_PHDR = 3, ///< Program headers.
- AUXV_AT_PHENT = 4, ///< Size of program header.
- AUXV_AT_PHNUM = 5, ///< Number of program headers.
- AUXV_AT_PAGESZ = 6, ///< Page size.
- AUXV_AT_BASE = 7, ///< Interpreter base address.
- AUXV_AT_FLAGS = 8, ///< Flags.
- AUXV_AT_ENTRY = 9, ///< Program entry point.
- AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.
- AUXV_AT_UID = 11, ///< UID.
- AUXV_AT_EUID = 12, ///< Effective UID.
- AUXV_AT_GID = 13, ///< GID.
- AUXV_AT_EGID = 14, ///< Effective GID.
- AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
- AUXV_AT_PLATFORM = 15, ///< String identifying platform.
- AUXV_AT_HWCAP = 16, ///< Machine dependent hints about processor capabilities.
- AUXV_AT_FPUCW = 18, ///< Used FPU control word.
- AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.
- AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.
- AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.
- AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.
- AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?
- AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.
- AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.
- AUXV_AT_EXECFN = 31, ///< Filename of executable.
- AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system
- ///calls and other nice things.
- AUXV_AT_SYSINFO_EHDR = 33,
- AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.
- AUXV_AT_L1D_CACHESHAPE = 35,
- AUXV_AT_L2_CACHESHAPE = 36,
- AUXV_AT_L3_CACHESHAPE = 37,
- };
-
-private:
- typedef std::vector<Entry> EntryVector;
-
-public:
- typedef EntryVector::const_iterator iterator;
-
- iterator begin() const { return m_auxv.begin(); }
- iterator end() const { return m_auxv.end(); }
-
- iterator FindEntry(EntryType type) const;
-
- static const char *GetEntryName(const Entry &entry) {
- return GetEntryName(static_cast<EntryType>(entry.type));
- }
-
- static const char *GetEntryName(EntryType type);
-
- void DumpToLog(lldb_private::Log *log) const;
-
-private:
- lldb_private::Process *m_process;
- EntryVector m_auxv;
-
- lldb::DataBufferSP GetAuxvData();
-
- void ParseAuxv(lldb_private::DataExtractor &data);
-};
-
-#endif
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index b30a1ab2cf1f7..0d736738ebb5b 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -1,9 +1,8 @@
//===-- DYLDRendezvous.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -489,10 +488,7 @@ bool DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry) {
const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
if ((arch.GetTriple().getOS() == llvm::Triple::FreeBSD ||
arch.GetTriple().getOS() == llvm::Triple::NetBSD) &&
- (arch.GetMachine() == llvm::Triple::mips ||
- arch.GetMachine() == llvm::Triple::mipsel ||
- arch.GetMachine() == llvm::Triple::mips64 ||
- arch.GetMachine() == llvm::Triple::mips64el)) {
+ arch.IsMIPS()) {
addr_t mips_l_offs;
if (!(addr = ReadPointer(addr, &mips_l_offs)))
return false;
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index f1a62c3bf9d80..993e62f5e9f9d 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -1,9 +1,8 @@
//===-- DYLDRendezvous.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,7 +24,7 @@ namespace lldb_private {
class Process;
}
-/// @class DYLDRendezvous
+/// \class DYLDRendezvous
/// Interface to the runtime linker.
///
/// A structure is present in a processes memory space which is updated by the
@@ -67,50 +66,50 @@ public:
/// This method should be called once one start up, then once each time the
/// runtime linker enters the function given by GetBreakAddress().
///
- /// @returns true on success and false on failure.
+ /// \returns true on success and false on failure.
///
- /// @see GetBreakAddress().
+ /// \see GetBreakAddress().
bool Resolve();
- /// @returns true if this rendezvous has been located in the inferiors
+ /// \returns true if this rendezvous has been located in the inferiors
/// address space and false otherwise.
bool IsValid();
- /// @returns the address of the rendezvous structure in the inferiors
+ /// \returns the address of the rendezvous structure in the inferiors
/// address space.
lldb::addr_t GetRendezvousAddress() const { return m_rendezvous_addr; }
- /// @returns the version of the rendezvous protocol being used.
+ /// \returns the version of the rendezvous protocol being used.
uint64_t GetVersion() const { return m_current.version; }
- /// @returns address in the inferiors address space containing the linked
+ /// \returns address in the inferiors address space containing the linked
/// list of shared object descriptors.
lldb::addr_t GetLinkMapAddress() const { return m_current.map_addr; }
/// A breakpoint should be set at this address and Resolve called on each
/// hit.
///
- /// @returns the address of a function called by the runtime linker each
+ /// \returns the address of a function called by the runtime linker each
/// time a module is loaded/unloaded, or about to be loaded/unloaded.
///
- /// @see Resolve()
+ /// \see Resolve()
lldb::addr_t GetBreakAddress() const { return m_current.brk; }
/// Returns the current state of the rendezvous structure.
uint64_t GetState() const { return m_current.state; }
- /// @returns the base address of the runtime linker in the inferiors address
+ /// \returns the base address of the runtime linker in the inferiors address
/// space.
lldb::addr_t GetLDBase() const { return m_current.ldbase; }
- /// @returns the thread layout metadata from the inferiors thread library.
+ /// \returns the thread layout metadata from the inferiors thread library.
const ThreadInfo &GetThreadInfo();
- /// @returns true if modules have been loaded into the inferior since the
+ /// \returns true if modules have been loaded into the inferior since the
/// last call to Resolve().
bool ModulesDidLoad() const { return !m_added_soentries.empty(); }
- /// @returns true if modules have been unloaded from the inferior since the
+ /// \returns true if modules have been unloaded from the inferior since the
/// last call to Resolve().
bool ModulesDidUnload() const { return !m_removed_soentries.empty(); }
@@ -118,7 +117,7 @@ public:
/// Constants describing the state of the rendezvous.
///
- /// @see GetState().
+ /// \see GetState().
enum RendezvousState { eConsistent, eAdd, eDelete };
/// Structure representing the shared objects currently loaded into the
@@ -202,15 +201,15 @@ protected:
/// Threading metadata read from the inferior.
ThreadInfo m_thread_info;
- /// Reads an unsigned integer of @p size bytes from the inferior's address
- /// space starting at @p addr.
+ /// Reads an unsigned integer of \p size bytes from the inferior's address
+ /// space starting at \p addr.
///
- /// @returns addr + size if the read was successful and false otherwise.
+ /// \returns addr + size if the read was successful and false otherwise.
lldb::addr_t ReadWord(lldb::addr_t addr, uint64_t *dst, size_t size);
- /// Reads an address from the inferior's address space starting at @p addr.
+ /// Reads an address from the inferior's address space starting at \p addr.
///
- /// @returns addr + target address size if the read was successful and
+ /// \returns addr + target address size if the read was successful and
/// 0 otherwise.
lldb::addr_t ReadPointer(lldb::addr_t addr, lldb::addr_t *dst);
@@ -218,7 +217,7 @@ protected:
/// addr.
std::string ReadStringFromMemory(lldb::addr_t addr);
- /// Reads an SOEntry starting at @p addr.
+ /// Reads an SOEntry starting at \p addr.
bool ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry);
/// Updates the current set of SOEntries, the set of added entries, and the
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index 6774b4fd12915..b55660899d0df 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -1,17 +1,14 @@
//===-- DynamicLoaderPOSIXDYLD.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// Main header include
#include "DynamicLoaderPOSIXDYLD.h"
-#include "AuxVector.h"
-
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -21,12 +18,13 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Platform.h"
-#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
+#include <memory>
using namespace lldb;
using namespace lldb_private;
@@ -68,7 +66,7 @@ DynamicLoader *DynamicLoaderPOSIXDYLD::CreateInstance(Process *process,
if (create)
return new DynamicLoaderPOSIXDYLD(process);
- return NULL;
+ return nullptr;
}
DynamicLoaderPOSIXDYLD::DynamicLoaderPOSIXDYLD(Process *process)
@@ -90,8 +88,8 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
if (log)
log->Printf("DynamicLoaderPOSIXDYLD::%s() pid %" PRIu64, __FUNCTION__,
m_process ? m_process->GetID() : LLDB_INVALID_PROCESS_ID);
+ m_auxv = llvm::make_unique<AuxVector>(m_process->GetAuxvData());
- m_auxv.reset(new AuxVector(m_process));
if (log)
log->Printf("DynamicLoaderPOSIXDYLD::%s pid %" PRIu64 " reloaded auxv data",
__FUNCTION__,
@@ -150,11 +148,6 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
true);
LoadAllCurrentModules();
- if (!SetRendezvousBreakpoint()) {
- // If we cannot establish rendezvous breakpoint right now we'll try again
- // at entry point.
- ProbeEntry();
- }
m_process->GetTarget().ModulesDidLoad(module_list);
if (log) {
@@ -169,6 +162,14 @@ void DynamicLoaderPOSIXDYLD::DidAttach() {
}
}
}
+
+ if (executable_sp.get()) {
+ if (!SetRendezvousBreakpoint()) {
+ // If we cannot establish rendezvous breakpoint right now we'll try again
+ // at entry point.
+ ProbeEntry();
+ }
+ }
}
void DynamicLoaderPOSIXDYLD::DidLaunch() {
@@ -179,7 +180,7 @@ void DynamicLoaderPOSIXDYLD::DidLaunch() {
ModuleSP executable;
addr_t load_offset;
- m_auxv.reset(new AuxVector(m_process));
+ m_auxv = llvm::make_unique<AuxVector>(m_process->GetAuxvData());
executable = GetTargetExecutable();
load_offset = ComputeLoadOffset();
@@ -463,7 +464,7 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread,
const SymbolContext &context = frame->GetSymbolContext(eSymbolContextSymbol);
Symbol *sym = context.symbol;
- if (sym == NULL || !sym->IsTrampoline())
+ if (sym == nullptr || !sym->IsTrampoline())
return thread_plan_sp;
ConstString sym_name = sym->GetName();
@@ -498,7 +499,8 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread,
llvm::sort(start, end);
addrs.erase(std::unique(start, end), end);
- thread_plan_sp.reset(new ThreadPlanRunToAddress(thread, addrs, stop));
+ thread_plan_sp =
+ std::make_shared<ThreadPlanRunToAddress>(thread, addrs, stop);
}
return thread_plan_sp;
@@ -542,7 +544,8 @@ ModuleSP DynamicLoaderPOSIXDYLD::LoadInterpreterModule() {
FileSpec file(info.GetName().GetCString());
ModuleSpec module_spec(file, target.GetArchitecture());
- if (ModuleSP module_sp = target.GetSharedModule(module_spec)) {
+ if (ModuleSP module_sp = target.GetOrCreateModule(module_spec,
+ true /* notify */)) {
UpdateLoadedSections(module_sp, LLDB_INVALID_ADDRESS, m_interpreter_base,
false);
return module_sp;
@@ -623,28 +626,28 @@ addr_t DynamicLoaderPOSIXDYLD::ComputeLoadOffset() {
}
void DynamicLoaderPOSIXDYLD::EvalSpecialModulesStatus() {
- auto I = m_auxv->FindEntry(AuxVector::AUXV_AT_SYSINFO_EHDR);
- if (I != m_auxv->end() && I->value != 0)
- m_vdso_base = I->value;
+ if (llvm::Optional<uint64_t> vdso_base =
+ m_auxv->GetAuxValue(AuxVector::AUXV_AT_SYSINFO_EHDR))
+ m_vdso_base = *vdso_base;
- I = m_auxv->FindEntry(AuxVector::AUXV_AT_BASE);
- if (I != m_auxv->end() && I->value != 0)
- m_interpreter_base = I->value;
+ if (llvm::Optional<uint64_t> interpreter_base =
+ m_auxv->GetAuxValue(AuxVector::AUXV_AT_BASE))
+ m_interpreter_base = *interpreter_base;
}
addr_t DynamicLoaderPOSIXDYLD::GetEntryPoint() {
if (m_entry_point != LLDB_INVALID_ADDRESS)
return m_entry_point;
- if (m_auxv.get() == NULL)
+ if (m_auxv == nullptr)
return LLDB_INVALID_ADDRESS;
- AuxVector::iterator I = m_auxv->FindEntry(AuxVector::AUXV_AT_ENTRY);
-
- if (I == m_auxv->end())
+ llvm::Optional<uint64_t> entry_point =
+ m_auxv->GetAuxValue(AuxVector::AUXV_AT_ENTRY);
+ if (!entry_point)
return LLDB_INVALID_ADDRESS;
- m_entry_point = static_cast<addr_t>(I->value);
+ m_entry_point = static_cast<addr_t>(*entry_point);
const ArchSpec &arch = m_process->GetTarget().GetArchitecture();
diff --git a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
index c5f2d3bcffbc6..0630d1eb11d14 100644
--- a/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
+++ b/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
@@ -1,9 +1,8 @@
//===-- DynamicLoaderPOSIXDYLD.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include <memory>
#include "DYLDRendezvous.h"
+#include "Plugins/Process/Utility/AuxVector.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Target/DynamicLoader.h"
@@ -37,9 +37,7 @@ public:
static lldb_private::DynamicLoader *
CreateInstance(lldb_private::Process *process, bool force);
- //------------------------------------------------------------------
// DynamicLoader protocol
- //------------------------------------------------------------------
void DidAttach() override;
@@ -54,9 +52,7 @@ public:
const lldb::ThreadSP thread,
lldb::addr_t tls_file_addr) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -103,21 +99,21 @@ protected:
/// of loaded modules.
void RefreshModules();
- /// Updates the load address of every allocatable section in @p module.
+ /// Updates the load address of every allocatable section in \p module.
///
- /// @param module The module to traverse.
+ /// \param module The module to traverse.
///
- /// @param link_map_addr The virtual address of the link map for the @p
+ /// \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.
+ /// \param base_addr The virtual base address \p module is loaded at.
void UpdateLoadedSections(lldb::ModuleSP module, lldb::addr_t link_map_addr,
lldb::addr_t base_addr,
bool base_addr_is_offset) override;
- /// Removes the loaded sections from the target in @p module.
+ /// Removes the loaded sections from the target in \p module.
///
- /// @param module The module to traverse.
+ /// \param module The module to traverse.
void UnloadSections(const lldb::ModuleSP module) override;
/// Resolves the entry point for the current inferior process and sets a
diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
index 2960e3939461e..6bc951c4d35b2 100644
--- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -1,9 +1,8 @@
//===-- DynamicLoaderStatic.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,11 +17,9 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Create an instance of this class. This function is filled into the plugin
// info class that gets handed out by the plugin factory and allows the lldb to
// instantiate an instance of this class.
-//----------------------------------------------------------------------
DynamicLoader *DynamicLoaderStatic::CreateInstance(Process *process,
bool force) {
bool create = force;
@@ -46,34 +43,26 @@ DynamicLoader *DynamicLoaderStatic::CreateInstance(Process *process,
if (create)
return new DynamicLoaderStatic(process);
- return NULL;
+ return nullptr;
}
-//----------------------------------------------------------------------
// Constructor
-//----------------------------------------------------------------------
DynamicLoaderStatic::DynamicLoaderStatic(Process *process)
: DynamicLoader(process) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
DynamicLoaderStatic::~DynamicLoaderStatic() {}
-//------------------------------------------------------------------
/// Called after attaching a process.
///
/// Allow DynamicLoader plug-ins to execute some code after
/// attaching to a process.
-//------------------------------------------------------------------
void DynamicLoaderStatic::DidAttach() { LoadAllImagesAtFileAddresses(); }
-//------------------------------------------------------------------
/// Called after attaching a process.
///
/// Allow DynamicLoader plug-ins to execute some code after
/// attaching to a process.
-//------------------------------------------------------------------
void DynamicLoaderStatic::DidLaunch() { LoadAllImagesAtFileAddresses(); }
void DynamicLoaderStatic::LoadAllImagesAtFileAddresses() {
@@ -157,9 +146,7 @@ const char *DynamicLoaderStatic::GetPluginDescriptionStatic() {
"addresses contained in each image.";
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString DynamicLoaderStatic::GetPluginName() {
return GetPluginNameStatic();
}
diff --git a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
index 7f8f82c76f72e..fa9aded7286c8 100644
--- a/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
+++ b/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h
@@ -1,9 +1,8 @@
//===-- DynamicLoaderStatic.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,9 +20,7 @@ public:
~DynamicLoaderStatic() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -35,12 +32,10 @@ public:
static lldb_private::DynamicLoader *
CreateInstance(lldb_private::Process *process, bool force);
- //------------------------------------------------------------------
/// Called after attaching a process.
///
/// Allow DynamicLoader plug-ins to execute some code after
/// attaching to a process.
- //------------------------------------------------------------------
void DidAttach() override;
void DidLaunch() override;
@@ -50,9 +45,7 @@ public:
lldb_private::Status CanLoadImage() override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
index 9405b1a5cfdce..fa3fbe0d9fa67 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
@@ -1,10 +1,9 @@
//===-- DynamicLoaderWindowsDYLD.cpp --------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,6 +12,7 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
@@ -62,6 +62,64 @@ DynamicLoader *DynamicLoaderWindowsDYLD::CreateInstance(Process *process,
return nullptr;
}
+void DynamicLoaderWindowsDYLD::OnLoadModule(lldb::ModuleSP module_sp,
+ const ModuleSpec module_spec,
+ lldb::addr_t module_addr) {
+
+ // Resolve the module unless we already have one.
+ if (!module_sp) {
+ Status error;
+ module_sp = m_process->GetTarget().GetOrCreateModule(module_spec,
+ true /* notify */, &error);
+ if (error.Fail())
+ return;
+ }
+
+ m_loaded_modules[module_sp] = module_addr;
+ UpdateLoadedSectionsCommon(module_sp, module_addr, false);
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ m_process->GetTarget().ModulesDidLoad(module_list);
+}
+
+void DynamicLoaderWindowsDYLD::OnUnloadModule(lldb::addr_t module_addr) {
+ Address resolved_addr;
+ if (!m_process->GetTarget().ResolveLoadAddress(module_addr, resolved_addr))
+ return;
+
+ ModuleSP module_sp = resolved_addr.GetModule();
+ if (module_sp) {
+ m_loaded_modules.erase(module_sp);
+ UnloadSectionsCommon(module_sp);
+ ModuleList module_list;
+ module_list.Append(module_sp);
+ m_process->GetTarget().ModulesDidUnload(module_list, false);
+ }
+}
+
+lldb::addr_t DynamicLoaderWindowsDYLD::GetLoadAddress(ModuleSP executable) {
+ // First, see if the load address is already cached.
+ auto it = m_loaded_modules.find(executable);
+ if (it != m_loaded_modules.end() && it->second != LLDB_INVALID_ADDRESS)
+ return it->second;
+
+ lldb::addr_t load_addr = LLDB_INVALID_ADDRESS;
+
+ // Second, try to get it through the process plugins. For a remote process,
+ // the remote platform will be responsible for providing it.
+ FileSpec file_spec(executable->GetPlatformFileSpec());
+ bool is_loaded = false;
+ Status status =
+ m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
+ // Servers other than lldb server could respond with a bogus address.
+ if (status.Success() && is_loaded && load_addr != LLDB_INVALID_ADDRESS) {
+ m_loaded_modules[executable] = load_addr;
+ return load_addr;
+ }
+
+ return LLDB_INVALID_ADDRESS;
+}
+
void DynamicLoaderWindowsDYLD::DidAttach() {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
if (log)
@@ -74,21 +132,17 @@ void DynamicLoaderWindowsDYLD::DidAttach() {
// Try to fetch the load address of the file from the process, since there
// could be randomization of the load address.
+ lldb::addr_t load_addr = GetLoadAddress(executable);
+ if (load_addr == LLDB_INVALID_ADDRESS)
+ return;
- // It might happen that the remote has a different dir for the file, so we
- // only send the basename of the executable in the query. I think this is safe
- // because I doubt that two executables with the same basenames are loaded in
- // memory...
- FileSpec file_spec(
- executable->GetPlatformFileSpec().GetFilename().GetCString());
- bool is_loaded;
- addr_t base_addr = 0;
- lldb::addr_t load_addr;
- Status error = m_process->GetFileLoadAddress(file_spec, is_loaded, load_addr);
- if (error.Success() && is_loaded) {
- base_addr = load_addr;
- UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, base_addr, false);
- }
+ // Request the process base address.
+ lldb::addr_t image_base = m_process->GetImageInfoAddress();
+ if (image_base == load_addr)
+ return;
+
+ // Rebase the process's modules if there is a mismatch.
+ UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_addr, false);
ModuleList module_list;
module_list.Append(executable);
@@ -96,7 +150,26 @@ void DynamicLoaderWindowsDYLD::DidAttach() {
m_process->LoadModules();
}
-void DynamicLoaderWindowsDYLD::DidLaunch() {}
+void DynamicLoaderWindowsDYLD::DidLaunch() {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DYNAMIC_LOADER));
+ if (log)
+ log->Printf("DynamicLoaderWindowsDYLD::%s()", __FUNCTION__);
+
+ ModuleSP executable = GetTargetExecutable();
+ if (!executable.get())
+ return;
+
+ lldb::addr_t load_addr = GetLoadAddress(executable);
+ if (load_addr != LLDB_INVALID_ADDRESS) {
+ // Update the loaded sections so that the breakpoints can be resolved.
+ UpdateLoadedSections(executable, LLDB_INVALID_ADDRESS, load_addr, false);
+
+ ModuleList module_list;
+ module_list.Append(executable);
+ m_process->GetTarget().ModulesDidLoad(module_list);
+ m_process->LoadModules();
+ }
+}
Status DynamicLoaderWindowsDYLD::CanLoadImage() { return Status(); }
diff --git a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
index 342b32b109278..100689a631282 100644
--- a/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
+++ b/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h
@@ -1,9 +1,8 @@
//===-- DynamicLoaderWindowsDYLD.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,6 +12,8 @@
#include "lldb/Target/DynamicLoader.h"
#include "lldb/lldb-forward.h"
+#include <map>
+
namespace lldb_private {
class DynamicLoaderWindowsDYLD : public DynamicLoader {
@@ -28,6 +29,10 @@ public:
static DynamicLoader *CreateInstance(Process *process, bool force);
+ void OnLoadModule(lldb::ModuleSP module_sp, const ModuleSpec module_spec,
+ lldb::addr_t module_addr);
+ void OnUnloadModule(lldb::addr_t module_addr);
+
void DidAttach() override;
void DidLaunch() override;
Status CanLoadImage() override;
@@ -36,6 +41,12 @@ public:
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
+
+protected:
+ lldb::addr_t GetLoadAddress(lldb::ModuleSP executable);
+
+private:
+ std::map<lldb::ModuleSP, lldb::addr_t> m_loaded_modules;
};
} // namespace lldb_private
diff --git a/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
index 0d619e4174e01..369f88327dd9d 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.cpp
@@ -1,9 +1,8 @@
//===-- ASTDumper.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -86,7 +85,7 @@ void ASTDumper::ToLog(Log *log, const char *prefix) {
memcpy(str, m_dump.c_str(), len);
- char *end = NULL;
+ char *end = nullptr;
end = strchr(str, '\n');
diff --git a/source/Plugins/ExpressionParser/Clang/ASTDumper.h b/source/Plugins/ExpressionParser/Clang/ASTDumper.h
index 58ba19739e5b3..ddf055d9c0c3d 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTDumper.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTDumper.h
@@ -1,9 +1,8 @@
//===-- ASTDumper.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index c2bc18a04e951..526ef90782ef3 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -1,9 +1,8 @@
//===-- ASTResultSynthesizer.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,8 +34,9 @@ using namespace lldb_private;
ASTResultSynthesizer::ASTResultSynthesizer(ASTConsumer *passthrough,
bool top_level, Target &target)
- : m_ast_context(NULL), m_passthrough(passthrough), m_passthrough_sema(NULL),
- m_target(target), m_sema(NULL), m_top_level(top_level) {
+ : m_ast_context(nullptr), m_passthrough(passthrough),
+ m_passthrough_sema(nullptr), m_target(target), m_sema(nullptr),
+ m_top_level(top_level) {
if (!m_passthrough)
return;
@@ -239,7 +239,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
break;
last_expr = implicit_cast->getSubExpr();
- } while (0);
+ } while (false);
// is_lvalue is used to record whether the expression returns an assignable
// Lvalue or an Rvalue. This is relevant because they are handled
@@ -312,7 +312,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
(is_lvalue ? "lvalue" : "rvalue"), s.c_str());
}
- clang::VarDecl *result_decl = NULL;
+ clang::VarDecl *result_decl = nullptr;
if (is_lvalue) {
IdentifierInfo *result_ptr_id;
@@ -330,14 +330,14 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
QualType ptr_qual_type;
- if (expr_qual_type->getAs<ObjCObjectType>() != NULL)
+ if (expr_qual_type->getAs<ObjCObjectType>() != nullptr)
ptr_qual_type = Ctx.getObjCObjectPointerType(expr_qual_type);
else
ptr_qual_type = Ctx.getPointerType(expr_qual_type);
result_decl =
VarDecl::Create(Ctx, DC, SourceLocation(), SourceLocation(),
- result_ptr_id, ptr_qual_type, NULL, SC_Static);
+ result_ptr_id, ptr_qual_type, nullptr, SC_Static);
if (!result_decl)
return false;
@@ -351,8 +351,9 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
} else {
IdentifierInfo &result_id = Ctx.Idents.get("$__lldb_expr_result");
- result_decl = VarDecl::Create(Ctx, DC, SourceLocation(), SourceLocation(),
- &result_id, expr_qual_type, NULL, SC_Static);
+ result_decl =
+ VarDecl::Create(Ctx, DC, SourceLocation(), SourceLocation(), &result_id,
+ expr_qual_type, nullptr, SC_Static);
if (!result_decl)
return false;
@@ -508,7 +509,7 @@ void ASTResultSynthesizer::InitializeSema(Sema &S) {
}
void ASTResultSynthesizer::ForgetSema() {
- m_sema = NULL;
+ m_sema = nullptr;
if (m_passthrough_sema)
m_passthrough_sema->ForgetSema();
diff --git a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
index 859a1dfa5f737..670ba6dce72e1 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.h
@@ -1,9 +1,8 @@
//===-- ASTResultSynthesizer.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,8 +15,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ASTResultSynthesizer ASTResultSynthesizer.h
+/// \class ASTResultSynthesizer ASTResultSynthesizer.h
/// "lldb/Expression/ASTResultSynthesizer.h" Adds a result variable
/// declaration to the ASTs for an expression.
///
@@ -29,165 +27,126 @@ namespace lldb_private {
/// ASTResultSynthesizer's job is to add the variable and its initialization
/// to the ASTs for the expression, and it does so by acting as a SemaConsumer
/// for Clang.
-//----------------------------------------------------------------------
class ASTResultSynthesizer : public clang::SemaConsumer {
public:
- //----------------------------------------------------------------------
/// Constructor
///
- /// @param[in] passthrough
+ /// \param[in] passthrough
/// Since the ASTs must typically go through to the Clang code generator
/// in order to produce LLVM IR, this SemaConsumer must allow them to
/// pass to the next step in the chain after processing. Passthrough is
/// the next ASTConsumer, or NULL if none is required.
///
- /// @param[in] top_level
+ /// \param[in] top_level
/// If true, register all top-level Decls and don't try to handle the
/// main function.
///
- /// @param[in] target
+ /// \param[in] target
/// The target, which contains the persistent variable store and the
/// AST importer.
- //----------------------------------------------------------------------
ASTResultSynthesizer(clang::ASTConsumer *passthrough, bool top_level,
Target &target);
- //----------------------------------------------------------------------
/// Destructor
- //----------------------------------------------------------------------
~ASTResultSynthesizer() override;
- //----------------------------------------------------------------------
/// Link this consumer with a particular AST context
///
- /// @param[in] Context
+ /// \param[in] Context
/// This AST context will be used for types and identifiers, and also
/// forwarded to the passthrough consumer, if one exists.
- //----------------------------------------------------------------------
void Initialize(clang::ASTContext &Context) override;
- //----------------------------------------------------------------------
/// Examine a list of Decls to find the function $__lldb_expr and transform
/// its code
///
- /// @param[in] D
+ /// \param[in] D
/// The list of Decls to search. These may contain LinkageSpecDecls,
/// which need to be searched recursively. That job falls to
/// TransformTopLevelDecl.
- //----------------------------------------------------------------------
bool HandleTopLevelDecl(clang::DeclGroupRef D) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void HandleTranslationUnit(clang::ASTContext &Ctx) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void HandleTagDeclDefinition(clang::TagDecl *D) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void CompleteTentativeDefinition(clang::VarDecl *D) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void HandleVTable(clang::CXXRecordDecl *RD) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void PrintStats() override;
- //----------------------------------------------------------------------
/// Set the Sema object to use when performing transforms, and pass it on
///
- /// @param[in] S
+ /// \param[in] S
/// The Sema to use. Because Sema isn't externally visible, this class
/// casts it to an Action for actual use.
- //----------------------------------------------------------------------
void InitializeSema(clang::Sema &S) override;
- //----------------------------------------------------------------------
/// Reset the Sema to NULL now that transformations are done
- //----------------------------------------------------------------------
void ForgetSema() override;
- //----------------------------------------------------------------------
/// The parse has succeeded, so record its persistent decls
- //----------------------------------------------------------------------
void CommitPersistentDecls();
private:
- //----------------------------------------------------------------------
/// Hunt the given Decl for FunctionDecls named $__lldb_expr, recursing as
/// necessary through LinkageSpecDecls, and calling SynthesizeResult on
/// anything that was found
///
- /// @param[in] D
+ /// \param[in] D
/// The Decl to hunt.
- //----------------------------------------------------------------------
void TransformTopLevelDecl(clang::Decl *D);
- //----------------------------------------------------------------------
/// Process an Objective-C method and produce the result variable and
/// initialization
///
- /// @param[in] MethodDecl
+ /// \param[in] MethodDecl
/// The method to process.
- //----------------------------------------------------------------------
bool SynthesizeObjCMethodResult(clang::ObjCMethodDecl *MethodDecl);
- //----------------------------------------------------------------------
/// Process a function and produce the result variable and initialization
///
- /// @param[in] FunDecl
+ /// \param[in] FunDecl
/// The function to process.
- //----------------------------------------------------------------------
bool SynthesizeFunctionResult(clang::FunctionDecl *FunDecl);
- //----------------------------------------------------------------------
/// Process a function body and produce the result variable and
/// initialization
///
- /// @param[in] Body
+ /// \param[in] Body
/// The body of the function.
///
- /// @param[in] DC
+ /// \param[in] DC
/// The DeclContext of the function, into which the result variable
/// is inserted.
- //----------------------------------------------------------------------
bool SynthesizeBodyResult(clang::CompoundStmt *Body, clang::DeclContext *DC);
- //----------------------------------------------------------------------
/// Given a DeclContext for a function or method, find all types declared in
/// the context and record any persistent types found.
///
- /// @param[in] FunDeclCtx
+ /// \param[in] FunDeclCtx
/// The context for the function to process.
- //----------------------------------------------------------------------
void RecordPersistentTypes(clang::DeclContext *FunDeclCtx);
- //----------------------------------------------------------------------
/// Given a TypeDecl, if it declares a type whose name starts with a dollar
/// sign, register it as a pointer type in the target's scratch
/// AST context.
///
- /// @param[in] Body
+ /// \param[in] Body
/// The body of the function.
- //----------------------------------------------------------------------
void MaybeRecordPersistentType(clang::TypeDecl *D);
- //----------------------------------------------------------------------
/// Given a NamedDecl, register it as a pointer type in the target's scratch
/// AST context.
///
- /// @param[in] Body
+ /// \param[in] Body
/// The body of the function.
- //----------------------------------------------------------------------
void RecordPersistentDecl(clang::NamedDecl *D);
clang::ASTContext
diff --git a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
index 2faeecdf724eb..190eacaa2b62b 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.cpp
@@ -1,9 +1,8 @@
//===-- ASTStructExtractor.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,9 +29,9 @@ using namespace lldb_private;
ASTStructExtractor::ASTStructExtractor(ASTConsumer *passthrough,
const char *struct_name,
ClangFunctionCaller &function)
- : m_ast_context(NULL), m_passthrough(passthrough), m_passthrough_sema(NULL),
- m_sema(NULL), m_action(NULL), m_function(function),
- m_struct_name(struct_name) {
+ : m_ast_context(nullptr), m_passthrough(passthrough),
+ m_passthrough_sema(nullptr), m_sema(nullptr), m_action(nullptr),
+ m_function(function), m_struct_name(struct_name) {
if (!m_passthrough)
return;
@@ -58,7 +57,7 @@ void ASTStructExtractor::ExtractFromFunctionDecl(FunctionDecl *F) {
if (!body_compound_stmt)
return; // do we have to handle this?
- RecordDecl *struct_decl = NULL;
+ RecordDecl *struct_decl = nullptr;
StringRef desired_name(m_struct_name);
@@ -178,8 +177,8 @@ void ASTStructExtractor::InitializeSema(Sema &S) {
}
void ASTStructExtractor::ForgetSema() {
- m_sema = NULL;
- m_action = NULL;
+ m_sema = nullptr;
+ m_action = nullptr;
if (m_passthrough_sema)
m_passthrough_sema->ForgetSema();
diff --git a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
index 65f4b00a86512..7aef2e254e1f6 100644
--- a/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
+++ b/source/Plugins/ExpressionParser/Clang/ASTStructExtractor.h
@@ -1,9 +1,8 @@
//===-- ASTStructExtractor.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,8 +17,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ASTStructExtractor ASTStructExtractor.h
+/// \class ASTStructExtractor ASTStructExtractor.h
/// "lldb/Expression/ASTStructExtractor.h" Extracts and describes the argument
/// structure for a wrapped function.
///
@@ -33,112 +31,85 @@ namespace lldb_private {
/// The definition of this struct is itself in the body of the wrapper
/// function, so Clang does the structure layout itself. ASTStructExtractor
/// reads through the AST for the wrapper function and finds the struct.
-//----------------------------------------------------------------------
class ASTStructExtractor : public clang::SemaConsumer {
public:
- //----------------------------------------------------------------------
/// Constructor
///
- /// @param[in] passthrough
+ /// \param[in] passthrough
/// Since the ASTs must typically go through to the Clang code generator
/// in order to produce LLVM IR, this SemaConsumer must allow them to
/// pass to the next step in the chain after processing. Passthrough is
/// the next ASTConsumer, or NULL if none is required.
///
- /// @param[in] struct_name
+ /// \param[in] struct_name
/// The name of the structure to extract from the wrapper function.
///
- /// @param[in] function
+ /// \param[in] function
/// The caller object whose members should be populated with information
/// about the argument struct. ClangFunctionCaller friends
/// ASTStructExtractor
/// for this purpose.
- //----------------------------------------------------------------------
ASTStructExtractor(clang::ASTConsumer *passthrough, const char *struct_name,
ClangFunctionCaller &function);
- //----------------------------------------------------------------------
/// Destructor
- //----------------------------------------------------------------------
~ASTStructExtractor() override;
- //----------------------------------------------------------------------
/// Link this consumer with a particular AST context
///
- /// @param[in] Context
+ /// \param[in] Context
/// This AST context will be used for types and identifiers, and also
/// forwarded to the passthrough consumer, if one exists.
- //----------------------------------------------------------------------
void Initialize(clang::ASTContext &Context) override;
- //----------------------------------------------------------------------
/// Examine a list of Decls to find the function $__lldb_expr and transform
/// its code
///
- /// @param[in] D
+ /// \param[in] D
/// The list of Decls to search. These may contain LinkageSpecDecls,
/// which need to be searched recursively. That job falls to
/// TransformTopLevelDecl.
- //----------------------------------------------------------------------
bool HandleTopLevelDecl(clang::DeclGroupRef D) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void HandleTranslationUnit(clang::ASTContext &Ctx) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void HandleTagDeclDefinition(clang::TagDecl *D) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void CompleteTentativeDefinition(clang::VarDecl *D) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void HandleVTable(clang::CXXRecordDecl *RD) override;
- //----------------------------------------------------------------------
/// Passthrough stub
- //----------------------------------------------------------------------
void PrintStats() override;
- //----------------------------------------------------------------------
/// Set the Sema object to use when performing transforms, and pass it on
///
- /// @param[in] S
+ /// \param[in] S
/// The Sema to use. Because Sema isn't externally visible, this class
/// casts it to an Action for actual use.
- //----------------------------------------------------------------------
void InitializeSema(clang::Sema &S) override;
- //----------------------------------------------------------------------
/// Reset the Sema to NULL now that transformations are done
- //----------------------------------------------------------------------
void ForgetSema() override;
private:
- //----------------------------------------------------------------------
/// Hunt the given FunctionDecl for the argument struct and place
/// information about it into m_function
///
- /// @param[in] F
+ /// \param[in] F
/// The FunctionDecl to hunt.
- //----------------------------------------------------------------------
void ExtractFromFunctionDecl(clang::FunctionDecl *F);
- //----------------------------------------------------------------------
/// Hunt the given Decl for FunctionDecls named the same as the wrapper
/// function name, recursing as necessary through LinkageSpecDecls, and
/// calling ExtractFromFunctionDecl on anything that was found
///
- /// @param[in] D
+ /// \param[in] D
/// The Decl to hunt.
- //----------------------------------------------------------------------
void ExtractFromTopLevelDecl(clang::Decl *D);
clang::ASTContext
diff --git a/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp b/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
new file mode 100644
index 0000000000000..bbdf4e31c5a45
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
@@ -0,0 +1,26 @@
+//===-- ASTUtils.cpp --------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "ASTUtils.h"
+
+lldb_private::ExternalASTSourceWrapper::~ExternalASTSourceWrapper() {}
+
+void lldb_private::ExternalASTSourceWrapper::PrintStats() {
+ m_Source->PrintStats();
+}
+
+lldb_private::ASTConsumerForwarder::~ASTConsumerForwarder() {}
+
+void lldb_private::ASTConsumerForwarder::PrintStats() { m_c->PrintStats(); }
+
+lldb_private::SemaSourceWithPriorities::~SemaSourceWithPriorities() {}
+
+void lldb_private::SemaSourceWithPriorities::PrintStats() {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->PrintStats();
+}
diff --git a/source/Plugins/ExpressionParser/Clang/ASTUtils.h b/source/Plugins/ExpressionParser/Clang/ASTUtils.h
new file mode 100644
index 0000000000000..d429e8c3855fc
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -0,0 +1,579 @@
+//===-- ASTUtils.h ----------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ASTUtils_h_
+#define liblldb_ASTUtils_h_
+
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/MultiplexExternalSemaSource.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaConsumer.h"
+
+namespace lldb_private {
+
+/// Wraps an ExternalASTSource into an ExternalSemaSource. Doesn't take
+/// ownership of the provided source.
+class ExternalASTSourceWrapper : public clang::ExternalSemaSource {
+ ExternalASTSource *m_Source;
+
+public:
+ ExternalASTSourceWrapper(ExternalASTSource *Source) : m_Source(Source) {
+ assert(m_Source && "Can't wrap nullptr ExternalASTSource");
+ }
+
+ ~ExternalASTSourceWrapper() override;
+
+ clang::Decl *GetExternalDecl(uint32_t ID) override {
+ return m_Source->GetExternalDecl(ID);
+ }
+
+ clang::Selector GetExternalSelector(uint32_t ID) override {
+ return m_Source->GetExternalSelector(ID);
+ }
+
+ uint32_t GetNumExternalSelectors() override {
+ return m_Source->GetNumExternalSelectors();
+ }
+
+ clang::Stmt *GetExternalDeclStmt(uint64_t Offset) override {
+ return m_Source->GetExternalDeclStmt(Offset);
+ }
+
+ clang::CXXCtorInitializer **
+ GetExternalCXXCtorInitializers(uint64_t Offset) override {
+ return m_Source->GetExternalCXXCtorInitializers(Offset);
+ }
+
+ clang::CXXBaseSpecifier *
+ GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
+ return m_Source->GetExternalCXXBaseSpecifiers(Offset);
+ }
+
+ void updateOutOfDateIdentifier(clang::IdentifierInfo &II) override {
+ m_Source->updateOutOfDateIdentifier(II);
+ }
+
+ bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC,
+ clang::DeclarationName Name) override {
+ return m_Source->FindExternalVisibleDeclsByName(DC, Name);
+ }
+
+ void completeVisibleDeclsMap(const clang::DeclContext *DC) override {
+ m_Source->completeVisibleDeclsMap(DC);
+ }
+
+ clang::Module *getModule(unsigned ID) override {
+ return m_Source->getModule(ID);
+ }
+
+ llvm::Optional<ASTSourceDescriptor>
+ getSourceDescriptor(unsigned ID) override {
+ return m_Source->getSourceDescriptor(ID);
+ }
+
+ ExtKind hasExternalDefinitions(const clang::Decl *D) override {
+ return m_Source->hasExternalDefinitions(D);
+ }
+
+ void FindExternalLexicalDecls(
+ const clang::DeclContext *DC,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &Result) override {
+ m_Source->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
+ }
+
+ void
+ FindFileRegionDecls(clang::FileID File, unsigned Offset, unsigned Length,
+ llvm::SmallVectorImpl<clang::Decl *> &Decls) override {
+ m_Source->FindFileRegionDecls(File, Offset, Length, Decls);
+ }
+
+ void CompleteRedeclChain(const clang::Decl *D) override {
+ m_Source->CompleteRedeclChain(D);
+ }
+
+ void CompleteType(clang::TagDecl *Tag) override {
+ m_Source->CompleteType(Tag);
+ }
+
+ void CompleteType(clang::ObjCInterfaceDecl *Class) override {
+ m_Source->CompleteType(Class);
+ }
+
+ void ReadComments() override { m_Source->ReadComments(); }
+
+ void StartedDeserializing() override { m_Source->StartedDeserializing(); }
+
+ void FinishedDeserializing() override { m_Source->FinishedDeserializing(); }
+
+ void StartTranslationUnit(clang::ASTConsumer *Consumer) override {
+ m_Source->StartTranslationUnit(Consumer);
+ }
+
+ void PrintStats() 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 {
+ return m_Source->layoutRecordType(Record, Size, Alignment, FieldOffsets,
+ BaseOffsets, VirtualBaseOffsets);
+ }
+};
+
+/// Wraps an ASTConsumer into an SemaConsumer. Doesn't take ownership of the
+/// provided consumer. If the provided ASTConsumer is also a SemaConsumer,
+/// the wrapper will also forward SemaConsumer functions.
+class ASTConsumerForwarder : public clang::SemaConsumer {
+ clang::ASTConsumer *m_c;
+ clang::SemaConsumer *m_sc;
+
+public:
+ ASTConsumerForwarder(clang::ASTConsumer *c) : m_c(c) {
+ m_sc = llvm::dyn_cast<clang::SemaConsumer>(m_c);
+ }
+
+ ~ASTConsumerForwarder() override;
+
+ void Initialize(clang::ASTContext &Context) override {
+ m_c->Initialize(Context);
+ }
+
+ bool HandleTopLevelDecl(clang::DeclGroupRef D) override {
+ return m_c->HandleTopLevelDecl(D);
+ }
+
+ void HandleInlineFunctionDefinition(clang::FunctionDecl *D) override {
+ m_c->HandleInlineFunctionDefinition(D);
+ }
+
+ void HandleInterestingDecl(clang::DeclGroupRef D) override {
+ m_c->HandleInterestingDecl(D);
+ }
+
+ void HandleTranslationUnit(clang::ASTContext &Ctx) override {
+ m_c->HandleTranslationUnit(Ctx);
+ }
+
+ void HandleTagDeclDefinition(clang::TagDecl *D) override {
+ m_c->HandleTagDeclDefinition(D);
+ }
+
+ void HandleTagDeclRequiredDefinition(const clang::TagDecl *D) override {
+ m_c->HandleTagDeclRequiredDefinition(D);
+ }
+
+ void HandleCXXImplicitFunctionInstantiation(clang::FunctionDecl *D) override {
+ m_c->HandleCXXImplicitFunctionInstantiation(D);
+ }
+
+ void HandleTopLevelDeclInObjCContainer(clang::DeclGroupRef D) override {
+ m_c->HandleTopLevelDeclInObjCContainer(D);
+ }
+
+ void HandleImplicitImportDecl(clang::ImportDecl *D) override {
+ m_c->HandleImplicitImportDecl(D);
+ }
+
+ void CompleteTentativeDefinition(clang::VarDecl *D) override {
+ m_c->CompleteTentativeDefinition(D);
+ }
+
+ void AssignInheritanceModel(clang::CXXRecordDecl *RD) override {
+ m_c->AssignInheritanceModel(RD);
+ }
+
+ void HandleCXXStaticMemberVarInstantiation(clang::VarDecl *D) override {
+ m_c->HandleCXXStaticMemberVarInstantiation(D);
+ }
+
+ void HandleVTable(clang::CXXRecordDecl *RD) override {
+ m_c->HandleVTable(RD);
+ }
+
+ clang::ASTMutationListener *GetASTMutationListener() override {
+ return m_c->GetASTMutationListener();
+ }
+
+ clang::ASTDeserializationListener *GetASTDeserializationListener() override {
+ return m_c->GetASTDeserializationListener();
+ }
+
+ void PrintStats() override;
+
+ void InitializeSema(clang::Sema &S) override {
+ if (m_sc)
+ m_sc->InitializeSema(S);
+ }
+
+ /// Inform the semantic consumer that Sema is no longer available.
+ void ForgetSema() override {
+ if (m_sc)
+ m_sc->ForgetSema();
+ }
+
+ bool shouldSkipFunctionBody(clang::Decl *D) override {
+ return m_c->shouldSkipFunctionBody(D);
+ }
+};
+
+/// A ExternalSemaSource multiplexer that prioritizes its sources.
+///
+/// This ExternalSemaSource will forward all requests to its attached sources.
+/// However, unlike a normal multiplexer it will not forward a request to all
+/// sources, but instead give priority to certain sources. If a source with a
+/// higher priority can fulfill a request, all sources with a lower priority
+/// will not receive the request.
+///
+/// This class is mostly use to multiplex between sources of different
+/// 'quality', e.g. a C++ modules and debug information. The C++ module will
+/// provide more accurate replies to the requests, but might not be able to
+/// answer all requests. The debug information will be used as a fallback then
+/// to provide information that is not in the C++ module.
+class SemaSourceWithPriorities : public clang::ExternalSemaSource {
+
+private:
+ /// The sources ordered in decreasing priority.
+ llvm::SmallVector<clang::ExternalSemaSource *, 2> Sources;
+
+public:
+ /// Construct a SemaSourceWithPriorities with a 'high quality' source that
+ /// has the higher priority and a 'low quality' source that will be used
+ /// as a fallback.
+ SemaSourceWithPriorities(clang::ExternalSemaSource &high_quality_source,
+ clang::ExternalSemaSource &low_quality_source) {
+ Sources.push_back(&high_quality_source);
+ Sources.push_back(&low_quality_source);
+ }
+
+ ~SemaSourceWithPriorities() override;
+
+ void addSource(clang::ExternalSemaSource &source) {
+ Sources.push_back(&source);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // ExternalASTSource.
+ //===--------------------------------------------------------------------===//
+
+ clang::Decl *GetExternalDecl(uint32_t ID) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (clang::Decl *Result = Sources[i]->GetExternalDecl(ID))
+ return Result;
+ return nullptr;
+ }
+
+ void CompleteRedeclChain(const clang::Decl *D) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->CompleteRedeclChain(D);
+ }
+
+ clang::Selector GetExternalSelector(uint32_t ID) override {
+ clang::Selector Sel;
+ for (size_t i = 0; i < Sources.size(); ++i) {
+ Sel = Sources[i]->GetExternalSelector(ID);
+ if (!Sel.isNull())
+ return Sel;
+ }
+ return Sel;
+ }
+
+ uint32_t GetNumExternalSelectors() override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (uint32_t total = Sources[i]->GetNumExternalSelectors())
+ return total;
+ return 0;
+ }
+
+ clang::Stmt *GetExternalDeclStmt(uint64_t Offset) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (clang::Stmt *Result = Sources[i]->GetExternalDeclStmt(Offset))
+ return Result;
+ return nullptr;
+ }
+
+ clang::CXXBaseSpecifier *
+ GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (clang::CXXBaseSpecifier *R =
+ Sources[i]->GetExternalCXXBaseSpecifiers(Offset))
+ return R;
+ return nullptr;
+ }
+
+ clang::CXXCtorInitializer **
+ GetExternalCXXCtorInitializers(uint64_t Offset) override {
+ for (auto *S : Sources)
+ if (auto *R = S->GetExternalCXXCtorInitializers(Offset))
+ return R;
+ return nullptr;
+ }
+
+ ExtKind hasExternalDefinitions(const clang::Decl *D) override {
+ for (const auto &S : Sources)
+ if (auto EK = S->hasExternalDefinitions(D))
+ if (EK != EK_ReplyHazy)
+ return EK;
+ return EK_ReplyHazy;
+ }
+
+ bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC,
+ clang::DeclarationName Name) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (Sources[i]->FindExternalVisibleDeclsByName(DC, Name))
+ return true;
+ return false;
+ }
+
+ void completeVisibleDeclsMap(const clang::DeclContext *DC) override {
+ // FIXME: Only one source should be able to complete the decls map.
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->completeVisibleDeclsMap(DC);
+ }
+
+ void FindExternalLexicalDecls(
+ const clang::DeclContext *DC,
+ llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
+ llvm::SmallVectorImpl<clang::Decl *> &Result) override {
+ for (size_t i = 0; i < Sources.size(); ++i) {
+ Sources[i]->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
+ if (!Result.empty())
+ return;
+ }
+ }
+
+ void
+ FindFileRegionDecls(clang::FileID File, unsigned Offset, unsigned Length,
+ llvm::SmallVectorImpl<clang::Decl *> &Decls) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->FindFileRegionDecls(File, Offset, Length, Decls);
+ }
+
+ void CompleteType(clang::TagDecl *Tag) override {
+ while (!Tag->isCompleteDefinition())
+ for (size_t i = 0; i < Sources.size(); ++i) {
+ // FIXME: We are technically supposed to loop here too until
+ // Tag->isCompleteDefinition() is true, but if our low quality source
+ // is failing to complete the tag this code will deadlock.
+ Sources[i]->CompleteType(Tag);
+ if (Tag->isCompleteDefinition())
+ break;
+ }
+ }
+
+ void CompleteType(clang::ObjCInterfaceDecl *Class) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->CompleteType(Class);
+ }
+
+ void ReadComments() override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->ReadComments();
+ }
+
+ void StartedDeserializing() override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->StartedDeserializing();
+ }
+
+ void FinishedDeserializing() override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->FinishedDeserializing();
+ }
+
+ void StartTranslationUnit(clang::ASTConsumer *Consumer) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ Sources[i]->StartTranslationUnit(Consumer);
+ }
+
+ void PrintStats() override;
+
+ clang::Module *getModule(unsigned ID) override {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (auto M = Sources[i]->getModule(ID))
+ return M;
+ return nullptr;
+ }
+
+ bool DeclIsFromPCHWithObjectFile(const clang::Decl *D) override {
+ for (auto *S : Sources)
+ if (S->DeclIsFromPCHWithObjectFile(D))
+ return true;
+ return false;
+ }
+
+ 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 {
+ for (size_t i = 0; i < Sources.size(); ++i)
+ if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets,
+ BaseOffsets, VirtualBaseOffsets))
+ return true;
+ return false;
+ }
+
+ void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override {
+ for (auto &Source : Sources)
+ Source->getMemoryBufferSizes(sizes);
+ }
+
+ //===--------------------------------------------------------------------===//
+ // ExternalSemaSource.
+ //===--------------------------------------------------------------------===//
+
+ void InitializeSema(clang::Sema &S) override {
+ for (auto &Source : Sources)
+ Source->InitializeSema(S);
+ }
+
+ void ForgetSema() override {
+ for (auto &Source : Sources)
+ Source->ForgetSema();
+ }
+
+ void ReadMethodPool(clang::Selector Sel) override {
+ for (auto &Source : Sources)
+ Source->ReadMethodPool(Sel);
+ }
+
+ void updateOutOfDateSelector(clang::Selector Sel) override {
+ for (auto &Source : Sources)
+ Source->updateOutOfDateSelector(Sel);
+ }
+
+ void ReadKnownNamespaces(
+ llvm::SmallVectorImpl<clang::NamespaceDecl *> &Namespaces) override {
+ for (auto &Source : Sources)
+ Source->ReadKnownNamespaces(Namespaces);
+ }
+
+ void ReadUndefinedButUsed(
+ llvm::MapVector<clang::NamedDecl *, clang::SourceLocation> &Undefined)
+ override {
+ for (auto &Source : Sources)
+ Source->ReadUndefinedButUsed(Undefined);
+ }
+
+ void ReadMismatchingDeleteExpressions(
+ llvm::MapVector<clang::FieldDecl *,
+ llvm::SmallVector<std::pair<clang::SourceLocation, bool>,
+ 4>> &Exprs) override {
+ for (auto &Source : Sources)
+ Source->ReadMismatchingDeleteExpressions(Exprs);
+ }
+
+ bool LookupUnqualified(clang::LookupResult &R, clang::Scope *S) override {
+ for (auto &Source : Sources) {
+ Source->LookupUnqualified(R, S);
+ if (!R.empty())
+ break;
+ }
+
+ return !R.empty();
+ }
+
+ void ReadTentativeDefinitions(
+ llvm::SmallVectorImpl<clang::VarDecl *> &Defs) override {
+ for (auto &Source : Sources)
+ Source->ReadTentativeDefinitions(Defs);
+ }
+
+ void ReadUnusedFileScopedDecls(
+ llvm::SmallVectorImpl<const clang::DeclaratorDecl *> &Decls) override {
+ for (auto &Source : Sources)
+ Source->ReadUnusedFileScopedDecls(Decls);
+ }
+
+ void ReadDelegatingConstructors(
+ llvm::SmallVectorImpl<clang::CXXConstructorDecl *> &Decls) override {
+ for (auto &Source : Sources)
+ Source->ReadDelegatingConstructors(Decls);
+ }
+
+ void ReadExtVectorDecls(
+ llvm::SmallVectorImpl<clang::TypedefNameDecl *> &Decls) override {
+ for (auto &Source : Sources)
+ Source->ReadExtVectorDecls(Decls);
+ }
+
+ void ReadUnusedLocalTypedefNameCandidates(
+ llvm::SmallSetVector<const clang::TypedefNameDecl *, 4> &Decls) override {
+ for (auto &Source : Sources)
+ Source->ReadUnusedLocalTypedefNameCandidates(Decls);
+ }
+
+ void ReadReferencedSelectors(
+ llvm::SmallVectorImpl<std::pair<clang::Selector, clang::SourceLocation>>
+ &Sels) override {
+ for (auto &Source : Sources)
+ Source->ReadReferencedSelectors(Sels);
+ }
+
+ void ReadWeakUndeclaredIdentifiers(
+ llvm::SmallVectorImpl<std::pair<clang::IdentifierInfo *, clang::WeakInfo>>
+ &WI) override {
+ for (auto &Source : Sources)
+ Source->ReadWeakUndeclaredIdentifiers(WI);
+ }
+
+ void ReadUsedVTables(
+ llvm::SmallVectorImpl<clang::ExternalVTableUse> &VTables) override {
+ for (auto &Source : Sources)
+ Source->ReadUsedVTables(VTables);
+ }
+
+ void ReadPendingInstantiations(
+ llvm::SmallVectorImpl<
+ std::pair<clang::ValueDecl *, clang::SourceLocation>> &Pending)
+ override {
+ for (auto &Source : Sources)
+ Source->ReadPendingInstantiations(Pending);
+ }
+
+ void ReadLateParsedTemplates(
+ llvm::MapVector<const clang::FunctionDecl *,
+ std::unique_ptr<clang::LateParsedTemplate>> &LPTMap)
+ override {
+ for (auto &Source : Sources)
+ Source->ReadLateParsedTemplates(LPTMap);
+ }
+
+ clang::TypoCorrection
+ CorrectTypo(const clang::DeclarationNameInfo &Typo, int LookupKind,
+ clang::Scope *S, clang::CXXScopeSpec *SS,
+ clang::CorrectionCandidateCallback &CCC,
+ clang::DeclContext *MemberContext, bool EnteringContext,
+ const clang::ObjCObjectPointerType *OPT) override {
+ for (auto &Source : Sources) {
+ if (clang::TypoCorrection C =
+ Source->CorrectTypo(Typo, LookupKind, S, SS, CCC,
+ MemberContext, EnteringContext, OPT))
+ return C;
+ }
+ return clang::TypoCorrection();
+ }
+
+ bool MaybeDiagnoseMissingCompleteType(clang::SourceLocation Loc,
+ clang::QualType T) override {
+ for (auto &Source : Sources) {
+ if (Source->MaybeDiagnoseMissingCompleteType(Loc, T))
+ return true;
+ }
+ return false;
+ }
+};
+
+} // namespace lldb_private
+#endif // liblldb_ASTUtils_h_
diff --git a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 84771e59531d1..c5778f86bb62d 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1,9 +1,8 @@
//===-- ClangASTSource.cpp ---------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,21 +20,21 @@
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/TaggedASTType.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/RecordLayout.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
+#include <memory>
#include <vector>
using namespace clang;
using namespace lldb_private;
-//------------------------------------------------------------------
// Scoped class that will remove an active lexical decl from the set when it
// goes out of scope.
-//------------------------------------------------------------------
namespace {
class ScopedLexicalDeclEraser {
public:
@@ -53,7 +52,7 @@ private:
ClangASTSource::ClangASTSource(const lldb::TargetSP &target)
: m_import_in_progress(false), m_lookups_enabled(false), m_target(target),
- m_ast_context(NULL), m_active_lexical_decls(), m_active_lookups() {
+ m_ast_context(nullptr), m_active_lexical_decls(), m_active_lookups() {
if (!target->GetUseModernTypeLookup()) {
m_ast_importer_sp = m_target->GetClangASTImporter();
}
@@ -92,7 +91,7 @@ void ClangASTSource::InstallASTContext(clang::ASTContext &ast_context,
if (!process)
break;
- ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+ ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process));
if (!language_runtime)
break;
@@ -103,7 +102,7 @@ void ClangASTSource::InstallASTContext(clang::ASTContext &ast_context,
break;
sources.push_back(runtime_decl_vendor->GetImporterSource());
- } while (0);
+ } while (false);
do {
DeclVendor *modules_decl_vendor =
@@ -113,7 +112,7 @@ void ClangASTSource::InstallASTContext(clang::ASTContext &ast_context,
break;
sources.push_back(modules_decl_vendor->GetImporterSource());
- } while (0);
+ } while (false);
if (!is_shared_context) {
// Update the scratch AST context's merger to reflect any new sources we
@@ -127,7 +126,9 @@ void ClangASTSource::InstallASTContext(clang::ASTContext &ast_context,
sources.push_back({*scratch_ast_context->getASTContext(),
*scratch_ast_context->getFileManager(),
scratch_ast_context->GetOriginMap()});
- } while (0);
+ }
+ while (false)
+ ;
m_merger_up =
llvm::make_unique<clang::ExternalASTMerger>(target, sources);
@@ -443,8 +444,8 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
return;
}
- Decl *original_decl = NULL;
- ASTContext *original_ctx = NULL;
+ Decl *original_decl = nullptr;
+ ASTContext *original_ctx = nullptr;
if (m_ast_importer_sp->ResolveDeclOrigin(interface_decl, &original_decl,
&original_ctx)) {
@@ -477,12 +478,12 @@ clang::ObjCInterfaceDecl *ClangASTSource::GetCompleteObjCInterface(
lldb::ProcessSP process(m_target->GetProcessSP());
if (!process)
- return NULL;
+ return nullptr;
- ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+ ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process));
if (!language_runtime)
- return NULL;
+ return nullptr;
ConstString class_name(interface_decl->getNameAsString().c_str());
@@ -490,7 +491,7 @@ clang::ObjCInterfaceDecl *ClangASTSource::GetCompleteObjCInterface(
language_runtime->LookupInCompleteClassCache(class_name));
if (!complete_type_sp)
- return NULL;
+ return nullptr;
TypeFromUser complete_type =
TypeFromUser(complete_type_sp->GetFullCompilerType());
@@ -498,7 +499,7 @@ clang::ObjCInterfaceDecl *ClangASTSource::GetCompleteObjCInterface(
complete_type.GetOpaqueQualType();
if (!complete_opaque_type)
- return NULL;
+ return nullptr;
const clang::Type *complete_clang_type =
QualType::getFromOpaquePtr(complete_opaque_type).getTypePtr();
@@ -506,7 +507,7 @@ clang::ObjCInterfaceDecl *ClangASTSource::GetCompleteObjCInterface(
dyn_cast<ObjCInterfaceType>(complete_clang_type);
if (!complete_interface_type)
- return NULL;
+ return nullptr;
ObjCInterfaceDecl *complete_iface_decl(complete_interface_type->getDecl());
@@ -571,8 +572,8 @@ void ClangASTSource::FindExternalLexicalDecls(
current_id, static_cast<const void *>(m_ast_context));
}
- Decl *original_decl = NULL;
- ASTContext *original_ctx = NULL;
+ Decl *original_decl = nullptr;
+ ASTContext *original_ctx = nullptr;
if (!m_ast_importer_sp->ResolveDeclOrigin(context_decl, &original_decl,
&original_ctx))
@@ -611,10 +612,15 @@ void ClangASTSource::FindExternalLexicalDecls(
if (!original_decl_context)
return;
+ // Indicates whether we skipped any Decls of the original DeclContext.
+ bool SkippedDecls = false;
for (TagDecl::decl_iterator iter = original_decl_context->decls_begin();
iter != original_decl_context->decls_end(); ++iter) {
Decl *decl = *iter;
+ // The predicate function returns true if the passed declaration kind is
+ // the one we are looking for.
+ // See clang::ExternalASTSource::FindExternalLexicalDecls()
if (predicate(decl->getKind())) {
if (log) {
ASTDumper ast_dumper(decl);
@@ -639,21 +645,22 @@ void ClangASTSource::FindExternalLexicalDecls(
m_ast_importer_sp->RequireCompleteType(copied_field_type);
}
-
- DeclContext *decl_context_non_const =
- const_cast<DeclContext *>(decl_context);
-
- if (copied_decl->getDeclContext() != decl_context) {
- if (copied_decl->getDeclContext()->containsDecl(copied_decl))
- copied_decl->getDeclContext()->removeDecl(copied_decl);
- copied_decl->setDeclContext(decl_context_non_const);
- }
-
- if (!decl_context_non_const->containsDecl(copied_decl))
- decl_context_non_const->addDeclInternal(copied_decl);
+ } else {
+ SkippedDecls = true;
}
}
+ // CopyDecl may build a lookup table which may set up ExternalLexicalStorage
+ // to false. However, since we skipped some of the external Decls we must
+ // set it back!
+ if (SkippedDecls) {
+ decl_context->setHasExternalLexicalStorage(true);
+ // This sets HasLazyExternalLexicalLookups to true. By setting this bit we
+ // ensure that the lookup table is rebuilt, which means the external source
+ // is consulted again when a clang::DeclContext::lookup is called.
+ const_cast<DeclContext *>(decl_context)->setMustBuildLookupTable();
+ }
+
return;
}
@@ -708,7 +715,7 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
return; // otherwise we may need to fall back
}
- context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap);
+ context.m_namespace_map = std::make_shared<ClangASTImporter::NamespaceMap>();
if (const NamespaceDecl *namespace_context =
dyn_cast<NamespaceDecl>(context.m_decl_context)) {
@@ -763,6 +770,10 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
}
}
+clang::Sema *ClangASTSource::getSema() {
+ return ClangASTContext::GetASTContext(m_ast_context)->getSema();
+}
+
bool ClangASTSource::IgnoreName(const ConstString name,
bool ignore_all_dollar_names) {
static const ConstString id_name("id");
@@ -932,7 +943,7 @@ void ClangASTSource::FindExternalVisibleDecls(
context.m_found.type = true;
}
}
- } while (0);
+ } while (false);
}
if (!context.m_found.type) {
@@ -946,7 +957,7 @@ void ClangASTSource::FindExternalVisibleDecls(
break;
ObjCLanguageRuntime *language_runtime(
- process->GetObjCLanguageRuntime());
+ ObjCLanguageRuntime::Get(*process));
if (!language_runtime)
break;
@@ -983,17 +994,17 @@ void ClangASTSource::FindExternalVisibleDecls(
}
context.AddNamedDecl(copied_named_decl);
- } while (0);
+ } while (false);
}
- } while (0);
+ } while (false);
}
template <class D> class TaggedASTDecl {
public:
- TaggedASTDecl() : decl(NULL) {}
+ TaggedASTDecl() : decl(nullptr) {}
TaggedASTDecl(D *_decl) : decl(_decl) {}
- bool IsValid() const { return (decl != NULL); }
+ bool IsValid() const { return (decl != nullptr); }
bool IsInvalid() const { return !IsValid(); }
D *operator->() const { return decl; }
D *decl;
@@ -1026,7 +1037,7 @@ public:
template <class D>
DeclFromUser<D> DeclFromParser<D>::GetOrigin(ClangASTSource &source) {
DeclFromUser<> origin_decl;
- source.ResolveDeclOrigin(this->decl, &origin_decl.decl, NULL);
+ source.ResolveDeclOrigin(this->decl, &origin_decl.decl, nullptr);
if (origin_decl.IsInvalid())
return DeclFromUser<D>();
return DeclFromUser<D>(dyn_cast<D>(origin_decl.decl));
@@ -1156,8 +1167,8 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
return;
do {
- Decl *original_decl = NULL;
- ASTContext *original_ctx = NULL;
+ Decl *original_decl = nullptr;
+ ASTContext *original_ctx = nullptr;
m_ast_importer_sp->ResolveDeclOrigin(interface_decl, &original_decl,
&original_ctx);
@@ -1171,7 +1182,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (FindObjCMethodDeclsWithOrigin(current_id, context,
original_interface_decl, "at origin"))
return; // found it, no need to look any further
- } while (0);
+ } while (false);
StreamString ss;
@@ -1276,7 +1287,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (*cursor == ' ' || *cursor == '(')
sc_list.Append(candidate_sc);
}
- } while (0);
+ } while (false);
if (sc_list.GetSize()) {
// We found a good function symbol. Use that.
@@ -1359,7 +1370,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
"in debug info");
return;
- } while (0);
+ } while (false);
do {
// Check the modules only if the debug information didn't have a complete
@@ -1386,7 +1397,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
current_id, context, interface_decl_from_modules, "in modules"))
return;
}
- } while (0);
+ } while (false);
do {
// Check the runtime only if the debug information didn't have a complete
@@ -1397,7 +1408,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
if (!process)
break;
- ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+ ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process));
if (!language_runtime)
break;
@@ -1423,7 +1434,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
FindObjCMethodDeclsWithOrigin(current_id, context, runtime_interface_decl,
"in runtime");
- } while (0);
+ } while (false);
}
static bool FindObjCPropertyAndIvarDeclsWithOrigin(
@@ -1542,7 +1553,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
complete_iface_decl);
return;
- } while (0);
+ } while (false);
do {
// Check the modules only if the debug information didn't have a complete
@@ -1578,7 +1589,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
if (FindObjCPropertyAndIvarDeclsWithOrigin(current_id, context, *this,
interface_decl_from_modules))
return;
- } while (0);
+ } while (false);
do {
// Check the runtime only if the debug information didn't have a complete
@@ -1589,7 +1600,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
if (!process)
return;
- ObjCLanguageRuntime *language_runtime(process->GetObjCLanguageRuntime());
+ ObjCLanguageRuntime *language_runtime(ObjCLanguageRuntime::Get(*process));
if (!language_runtime)
return;
@@ -1623,7 +1634,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
if (FindObjCPropertyAndIvarDeclsWithOrigin(
current_id, context, *this, interface_decl_from_runtime))
return;
- } while (0);
+ } while (false);
}
typedef llvm::DenseMap<const FieldDecl *, uint64_t> FieldOffsetMap;
@@ -1836,7 +1847,7 @@ bool ClangASTSource::layoutRecordType(const RecordDecl *record, uint64_t &size,
}
void ClangASTSource::CompleteNamespaceMap(
- ClangASTImporter::NamespaceMapSP &namespace_map, const ConstString &name,
+ ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name,
ClangASTImporter::NamespaceMapSP &parent_map) const {
static unsigned int invocation_id = 0;
unsigned int current_id = invocation_id++;
@@ -1966,7 +1977,14 @@ clang::QualType ClangASTSource::CopyTypeWithMerger(
return QualType();
}
- return merger.ImporterForOrigin(from_context).Import(type);
+ if (llvm::Expected<QualType> type_or_error =
+ merger.ImporterForOrigin(from_context).Import(type)) {
+ return *type_or_error;
+ } else {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG_ERROR(log, type_or_error.takeError(), "Couldn't import type: {0}");
+ return QualType();
+ }
}
clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
@@ -1979,7 +1997,16 @@ clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
return nullptr;
}
- return m_merger_up->ImporterForOrigin(from_context).Import(src_decl);
+ if (llvm::Expected<Decl *> decl_or_error =
+ m_merger_up->ImporterForOrigin(from_context).Import(src_decl)) {
+ return *decl_or_error;
+ } else {
+ Log *log =
+ lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG_ERROR(log, decl_or_error.takeError(),
+ "Couldn't import decl: {0}");
+ return nullptr;
+ }
} else {
lldbassert(0 && "No mechanism for copying a decl!");
return nullptr;
@@ -2045,12 +2072,12 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
assert(type && "Type for variable must be valid!");
if (!type.IsValid())
- return NULL;
+ return nullptr;
ClangASTContext *lldb_ast =
llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!lldb_ast)
- return NULL;
+ return nullptr;
IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo();
@@ -2058,7 +2085,7 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) {
clang::NamedDecl *Decl = VarDecl::Create(
*ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(),
- SourceLocation(), ii, ClangUtil::GetQualType(type), 0, SC_Static);
+ SourceLocation(), ii, ClangUtil::GetQualType(type), nullptr, SC_Static);
m_decls.push_back(Decl);
return Decl;
@@ -2069,15 +2096,15 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
assert(type && "Type for variable must be valid!");
if (!type.IsValid())
- return NULL;
+ return nullptr;
if (m_function_types.count(type))
- return NULL;
+ return nullptr;
ClangASTContext *lldb_ast =
llvm::dyn_cast<ClangASTContext>(type.GetTypeSystem());
if (!lldb_ast)
- return NULL;
+ return nullptr;
m_function_types.insert(type);
@@ -2106,8 +2133,8 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
clang::FunctionDecl *func_decl = FunctionDecl::Create(
*ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type,
- NULL, SC_Extern, isInlineSpecified, hasWrittenPrototype,
- isConstexprSpecified);
+ nullptr, SC_Extern, isInlineSpecified, hasWrittenPrototype,
+ isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
// We have to do more than just synthesize the FunctionDecl. We have to
// synthesize ParmVarDecls for all of the FunctionDecl's arguments. To do
@@ -2125,9 +2152,10 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) {
QualType arg_qual_type(func_proto_type->getParamType(ArgIndex));
- parm_var_decls.push_back(ParmVarDecl::Create(
- *ast, const_cast<DeclContext *>(context), SourceLocation(),
- SourceLocation(), NULL, arg_qual_type, NULL, SC_Static, NULL));
+ parm_var_decls.push_back(
+ ParmVarDecl::Create(*ast, const_cast<DeclContext *>(context),
+ SourceLocation(), SourceLocation(), nullptr,
+ arg_qual_type, nullptr, SC_Static, nullptr));
}
func_decl->setParams(ArrayRef<ParmVarDecl *>(parm_var_decls));
@@ -2148,7 +2176,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type,
ClangASTContext::IsOperator(decl_name.getAsString().c_str(), op_kind)) {
if (!ClangASTContext::CheckOverloadedOperatorKindParameterCount(
false, op_kind, func_proto_type->getNumParams()))
- return NULL;
+ return nullptr;
}
m_decls.push_back(func_decl);
@@ -2196,7 +2224,7 @@ NameSearchContext::AddTypeDecl(const CompilerType &clang_type) {
return (NamedDecl *)interface_decl;
}
}
- return NULL;
+ return nullptr;
}
void NameSearchContext::AddLookupResult(clang::DeclContextLookupResult result) {
diff --git a/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
index a42422b0f97f0..7a8bacf48a8fd 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
@@ -1,9 +1,8 @@
//===-- ClangASTSource.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,8 +22,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ClangASTSource ClangASTSource.h "lldb/Expression/ClangASTSource.h"
+/// \class ClangASTSource ClangASTSource.h "lldb/Expression/ClangASTSource.h"
/// Provider for named objects defined in the debug info for Clang
///
/// As Clang parses an expression, it may encounter names that are not defined
@@ -32,37 +30,30 @@ namespace lldb_private {
/// knows the name it is looking for, but nothing else. The ExternalSemaSource
/// class provides Decls (VarDecl, FunDecl, TypeDecl) to Clang for these
/// names, consulting the ClangExpressionDeclMap to do the actual lookups.
-//----------------------------------------------------------------------
class ClangASTSource : public ClangExternalASTSourceCommon,
public ClangASTImporter::MapCompleter {
public:
- //------------------------------------------------------------------
/// Constructor
///
/// Initializes class variables.
///
- /// @param[in] target
+ /// \param[in] target
/// A reference to the target containing debug information to use.
- //------------------------------------------------------------------
ClangASTSource(const lldb::TargetSP &target);
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
~ClangASTSource() override;
- //------------------------------------------------------------------
/// Interface stubs.
- //------------------------------------------------------------------
- clang::Decl *GetExternalDecl(uint32_t) override { return NULL; }
- clang::Stmt *GetExternalDeclStmt(uint64_t) override { return NULL; }
+ clang::Decl *GetExternalDecl(uint32_t) override { return nullptr; }
+ clang::Stmt *GetExternalDeclStmt(uint64_t) override { return nullptr; }
clang::Selector GetExternalSelector(uint32_t) override {
return clang::Selector();
}
uint32_t GetNumExternalSelectors() override { return 0; }
clang::CXXBaseSpecifier *
GetExternalCXXBaseSpecifiers(uint64_t Offset) override {
- return NULL;
+ return nullptr;
}
void MaterializeVisibleDecls(const clang::DeclContext *DC) { return; }
@@ -74,7 +65,6 @@ public:
// APIs for ExternalASTSource
//
- //------------------------------------------------------------------
/// Look up all Decls that match a particular name. Only handles
/// Identifiers and DeclContexts that are either NamespaceDecls or
/// TranslationUnitDecls. Calls SetExternalVisibleDeclsForName with the
@@ -83,69 +73,64 @@ public:
/// The work for this function is done by
/// void FindExternalVisibleDecls (NameSearchContext &);
///
- /// @param[in] DC
+ /// \param[in] DC
/// The DeclContext to register the found Decls in.
///
- /// @param[in] Name
+ /// \param[in] Name
/// The name to find entries for.
///
- /// @return
+ /// \return
/// Whatever SetExternalVisibleDeclsForName returns.
- //------------------------------------------------------------------
bool FindExternalVisibleDeclsByName(const clang::DeclContext *DC,
clang::DeclarationName Name) override;
- //------------------------------------------------------------------
/// Enumerate all Decls in a given lexical context.
///
- /// @param[in] DC
+ /// \param[in] DC
/// The DeclContext being searched.
///
- /// @param[in] isKindWeWant
+ /// \param[in] isKindWeWant
/// A callback function that returns true given the
/// DeclKinds of desired Decls, and false otherwise.
///
- /// @param[in] Decls
+ /// \param[in] Decls
/// A vector that is filled in with matching Decls.
- //------------------------------------------------------------------
void FindExternalLexicalDecls(
const clang::DeclContext *DC,
llvm::function_ref<bool(clang::Decl::Kind)> IsKindWeWant,
llvm::SmallVectorImpl<clang::Decl *> &Decls) override;
- //------------------------------------------------------------------
/// Specify the layout of the contents of a RecordDecl.
///
- /// @param[in] Record
+ /// \param[in] Record
/// The record (in the parser's AST context) that needs to be
/// laid out.
///
- /// @param[out] Size
+ /// \param[out] Size
/// The total size of the record in bits.
///
- /// @param[out] Alignment
+ /// \param[out] Alignment
/// The alignment of the record in bits.
///
- /// @param[in] FieldOffsets
+ /// \param[in] FieldOffsets
/// A map that must be populated with pairs of the record's
/// fields (in the parser's AST context) and their offsets
/// (measured in bits).
///
- /// @param[in] BaseOffsets
+ /// \param[in] BaseOffsets
/// A map that must be populated with pairs of the record's
/// C++ concrete base classes (in the parser's AST context,
/// and only if the record is a CXXRecordDecl and has base
/// classes) and their offsets (measured in bytes).
///
- /// @param[in] VirtualBaseOffsets
+ /// \param[in] VirtualBaseOffsets
/// A map that must be populated with pairs of the record's
/// C++ virtual base classes (in the parser's AST context,
/// and only if the record is a CXXRecordDecl and has base
/// classes) and their offsets (measured in bytes).
///
- /// @return
+ /// \return
/// True <=> the layout is valid.
- //-----------------------------------------------------------------
bool layoutRecordType(
const clang::RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
llvm::DenseMap<const clang::FieldDecl *, uint64_t> &FieldOffsets,
@@ -154,52 +139,44 @@ public:
llvm::DenseMap<const clang::CXXRecordDecl *, clang::CharUnits>
&VirtualBaseOffsets) override;
- //------------------------------------------------------------------
/// Complete a TagDecl.
///
- /// @param[in] Tag
+ /// \param[in] Tag
/// The Decl to be completed in place.
- //------------------------------------------------------------------
void CompleteType(clang::TagDecl *Tag) override;
- //------------------------------------------------------------------
/// Complete an ObjCInterfaceDecl.
///
- /// @param[in] Class
+ /// \param[in] Class
/// The Decl to be completed in place.
- //------------------------------------------------------------------
void CompleteType(clang::ObjCInterfaceDecl *Class) override;
- //------------------------------------------------------------------
/// Called on entering a translation unit. Tells Clang by calling
/// setHasExternalVisibleStorage() and setHasExternalLexicalStorage() that
/// this object has something to say about undefined names.
///
- /// @param[in] ASTConsumer
+ /// \param[in] ASTConsumer
/// Unused.
- //------------------------------------------------------------------
void StartTranslationUnit(clang::ASTConsumer *Consumer) override;
//
// APIs for NamespaceMapCompleter
//
- //------------------------------------------------------------------
/// Look up the modules containing a given namespace and put the appropriate
/// entries in the namespace map.
///
- /// @param[in] namespace_map
+ /// \param[in] namespace_map
/// The map to be completed.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the namespace to be found.
///
- /// @param[in] parent_map
+ /// \param[in] parent_map
/// The map for the namespace's parent namespace, if there is
/// one.
- //------------------------------------------------------------------
void CompleteNamespaceMap(
- ClangASTImporter::NamespaceMapSP &namespace_map, const ConstString &name,
+ ClangASTImporter::NamespaceMapSP &namespace_map, ConstString name,
ClangASTImporter::NamespaceMapSP &parent_map) const override;
//
@@ -210,14 +187,14 @@ public:
AddNamespace(NameSearchContext &context,
ClangASTImporter::NamespaceMapSP &namespace_decls);
- //------------------------------------------------------------------
/// The worker function for FindExternalVisibleDeclsByName.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when filing results.
- //------------------------------------------------------------------
virtual void FindExternalVisibleDecls(NameSearchContext &context);
+ clang::Sema *getSema();
+
void SetImportInProgress(bool import_in_progress) {
m_import_in_progress = import_in_progress;
}
@@ -228,13 +205,11 @@ public:
}
bool GetLookupsEnabled() { return m_lookups_enabled; }
- //----------------------------------------------------------------------
- /// @class ClangASTSourceProxy ClangASTSource.h
+ /// \class ClangASTSourceProxy ClangASTSource.h
/// "lldb/Expression/ClangASTSource.h" Proxy for ClangASTSource
///
/// Clang AST contexts like to own their AST sources, so this is a state-
/// free proxy object.
- //----------------------------------------------------------------------
class ClangASTSourceProxy : public ClangExternalASTSourceCommon {
public:
ClangASTSourceProxy(ClangASTSource &original) : m_original(original) {}
@@ -295,157 +270,135 @@ public:
}
protected:
- //------------------------------------------------------------------
/// Look for the complete version of an Objective-C interface, and return it
/// if found.
///
- /// @param[in] interface_decl
+ /// \param[in] interface_decl
/// An ObjCInterfaceDecl that may not be the complete one.
///
- /// @return
+ /// \return
/// NULL if the complete interface couldn't be found;
/// the complete interface otherwise.
- //------------------------------------------------------------------
clang::ObjCInterfaceDecl *
GetCompleteObjCInterface(const clang::ObjCInterfaceDecl *interface_decl);
- //------------------------------------------------------------------
/// Find all entities matching a given name in a given module, using a
/// NameSearchContext to make Decls for them.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
///
- /// @param[in] module
+ /// \param[in] module
/// If non-NULL, the module to query.
///
- /// @param[in] namespace_decl
+ /// \param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
///
- /// @param[in] current_id
+ /// \param[in] current_id
/// The ID for the current FindExternalVisibleDecls invocation,
/// for logging purposes.
- //------------------------------------------------------------------
void FindExternalVisibleDecls(NameSearchContext &context,
lldb::ModuleSP module,
CompilerDeclContext &namespace_decl,
unsigned int current_id);
- //------------------------------------------------------------------
/// Find all Objective-C methods matching a given selector.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
/// Its m_decl_name contains the selector and its m_decl_context
/// is the containing object.
- //------------------------------------------------------------------
void FindObjCMethodDecls(NameSearchContext &context);
- //------------------------------------------------------------------
/// Find all Objective-C properties and ivars with a given name.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
/// Its m_decl_name contains the name and its m_decl_context
/// is the containing object.
- //------------------------------------------------------------------
void FindObjCPropertyAndIvarDecls(NameSearchContext &context);
- //------------------------------------------------------------------
/// A wrapper for ClangASTContext::CopyType that sets a flag that
/// indicates that we should not respond to queries during import.
///
- /// @param[in] dest_context
+ /// \param[in] dest_context
/// The target AST context, typically the parser's AST context.
///
- /// @param[in] source_context
+ /// \param[in] source_context
/// The source AST context, typically the AST context of whatever
/// symbol file the type was found in.
///
- /// @param[in] src_type
+ /// \param[in] src_type
/// The source type.
///
- /// @return
+ /// \return
/// The imported type.
- //------------------------------------------------------------------
CompilerType GuardedCopyType(const CompilerType &src_type);
public:
- //------------------------------------------------------------------
/// Returns true if a name should be ignored by name lookup.
///
- /// @param[in] name
+ /// \param[in] name
/// The name to be considered.
///
- /// @param[in] ignore_all_dollar_nmmes
+ /// \param[in] ignore_all_dollar_nmmes
/// True if $-names of all sorts should be ignored.
///
- /// @return
+ /// \return
/// True if the name is one of a class of names that are ignored by
/// global lookup for performance reasons.
- //------------------------------------------------------------------
bool IgnoreName(const ConstString name, bool ignore_all_dollar_names);
public:
- //------------------------------------------------------------------
/// Copies a single Decl into the parser's AST context.
///
- /// @param[in] src_decl
+ /// \param[in] src_decl
/// The Decl to copy.
///
- /// @return
+ /// \return
/// A copy of the Decl in m_ast_context, or NULL if the copy failed.
- //------------------------------------------------------------------
clang::Decl *CopyDecl(clang::Decl *src_decl);
- //------------------------------------------------------------------
/// Copies a single Type to the target of the given ExternalASTMerger.
///
- /// @param[in] src_context
+ /// \param[in] src_context
/// The ASTContext containing the type.
///
- /// @param[in] merger
+ /// \param[in] merger
/// The merger to use. This isn't just *m_merger_up because it might be
/// the persistent AST context's merger.
///
- /// @param[in] type
+ /// \param[in] type
/// The type to copy.
///
- /// @return
+ /// \return
/// A copy of the Type in the merger's target context.
- //------------------------------------------------------------------
clang::QualType CopyTypeWithMerger(clang::ASTContext &src_context,
clang::ExternalASTMerger &merger,
clang::QualType type);
- //------------------------------------------------------------------
/// Determined the origin of a single Decl, if it can be found.
///
- /// @param[in] decl
+ /// \param[in] decl
/// The Decl whose origin is to be found.
///
- /// @param[out] original_decl
+ /// \param[out] original_decl
/// A pointer whose target is filled in with the original Decl.
///
- /// @param[in] original_ctx
+ /// \param[in] original_ctx
/// A pointer whose target is filled in with the original's ASTContext.
///
- /// @return
+ /// \return
/// True if lookup succeeded; false otherwise.
- //------------------------------------------------------------------
bool ResolveDeclOrigin(const clang::Decl *decl, clang::Decl **original_decl,
clang::ASTContext **original_ctx);
- //------------------------------------------------------------------
/// Returns m_merger_up. Only call this if the target is configured to use
/// modern lookup,
- //------------------------------------------------------------------
clang::ExternalASTMerger &GetMergerUnchecked();
- //------------------------------------------------------------------
/// Returns true if there is a merger. This only occurs if the target is
/// using modern lookup.
- //------------------------------------------------------------------
bool HasMerger() { return (bool)m_merger_up; }
protected:
@@ -471,15 +424,13 @@ protected:
std::set<const char *> m_active_lookups;
};
-//----------------------------------------------------------------------
-/// @class NameSearchContext ClangASTSource.h
+/// \class NameSearchContext ClangASTSource.h
/// "lldb/Expression/ClangASTSource.h" Container for all objects relevant to a
/// single name lookup
///
/// LLDB needs to create Decls for entities it finds. This class communicates
/// what name is being searched for and provides helper functions to construct
/// Decls given appropriate type information.
-//----------------------------------------------------------------------
struct NameSearchContext {
ClangASTSource &m_ast_source; ///< The AST source making the request
llvm::SmallVectorImpl<clang::NamedDecl *>
@@ -504,24 +455,22 @@ struct NameSearchContext {
bool type : 1;
} m_found;
- //------------------------------------------------------------------
/// Constructor
///
/// Initializes class variables.
///
- /// @param[in] astSource
+ /// \param[in] astSource
/// A reference to the AST source making a request.
///
- /// @param[in] decls
+ /// \param[in] decls
/// A reference to a list into which new Decls will be placed. This
/// list is typically empty when the function is called.
///
- /// @param[in] name
+ /// \param[in] name
/// The name being searched for (always an Identifier).
///
- /// @param[in] dc
+ /// \param[in] dc
/// The DeclContext to register Decls in.
- //------------------------------------------------------------------
NameSearchContext(ClangASTSource &astSource,
llvm::SmallVectorImpl<clang::NamedDecl *> &decls,
clang::DeclarationName &name, const clang::DeclContext *dc)
@@ -530,59 +479,47 @@ struct NameSearchContext {
memset(&m_found, 0, sizeof(m_found));
}
- //------------------------------------------------------------------
/// Create a VarDecl with the name being searched for and the provided type
/// and register it in the right places.
///
- /// @param[in] type
+ /// \param[in] type
/// The opaque QualType for the VarDecl being registered.
- //------------------------------------------------------------------
clang::NamedDecl *AddVarDecl(const CompilerType &type);
- //------------------------------------------------------------------
/// Create a FunDecl with the name being searched for and the provided type
/// and register it in the right places.
///
- /// @param[in] type
+ /// \param[in] type
/// The opaque QualType for the FunDecl being registered.
///
- /// @param[in] extern_c
+ /// \param[in] extern_c
/// If true, build an extern "C" linkage specification for this.
- //------------------------------------------------------------------
clang::NamedDecl *AddFunDecl(const CompilerType &type, bool extern_c = false);
- //------------------------------------------------------------------
/// Create a FunDecl with the name being searched for and generic type (i.e.
/// intptr_t NAME_GOES_HERE(...)) and register it in the right places.
- //------------------------------------------------------------------
clang::NamedDecl *AddGenericFunDecl();
- //------------------------------------------------------------------
/// Create a TypeDecl with the name being searched for and the provided type
/// and register it in the right places.
///
- /// @param[in] compiler_type
+ /// \param[in] compiler_type
/// The opaque QualType for the TypeDecl being registered.
- //------------------------------------------------------------------
clang::NamedDecl *AddTypeDecl(const CompilerType &compiler_type);
- //------------------------------------------------------------------
/// Add Decls from the provided DeclContextLookupResult to the list of
/// results.
///
- /// @param[in] result
+ /// \param[in] result
/// The DeclContextLookupResult, usually returned as the result
/// of querying a DeclContext.
- //------------------------------------------------------------------
void AddLookupResult(clang::DeclContextLookupResult result);
- //------------------------------------------------------------------
/// Add a NamedDecl to the list of results.
///
- /// @param[in] decl
+ /// \param[in] decl
/// The NamedDecl, usually returned as the result
/// of querying a DeclContext.
- //------------------------------------------------------------------
void AddNamedDecl(clang::NamedDecl *decl);
};
diff --git a/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h b/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
index 9ea4e3aa7dabf..db50c2aa3e908 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangDiagnostic.h
@@ -1,9 +1,8 @@
//===-- ClangDiagnostic.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,7 +33,7 @@ public:
uint32_t compiler_id)
: Diagnostic(message, severity, eDiagnosticOriginClang, compiler_id) {}
- virtual ~ClangDiagnostic() = default;
+ ~ClangDiagnostic() override = default;
bool HasFixIts() const override { return !m_fixit_vec.empty(); }
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 9c2f8c4b6c928..a49a7029e0d28 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1,9 +1,8 @@
//===-- ClangExpressionDeclMap.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,9 +32,7 @@
#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrame.h"
@@ -54,6 +51,8 @@
#include "clang/AST/RecursiveASTVisitor.h"
#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
using namespace lldb;
using namespace lldb_private;
@@ -66,10 +65,11 @@ const char *g_lldb_local_vars_namespace_cstr = "$__lldb_local_vars";
ClangExpressionDeclMap::ClangExpressionDeclMap(
bool keep_result_in_memory,
Materializer::PersistentVariableDelegate *result_delegate,
- ExecutionContext &exe_ctx)
+ ExecutionContext &exe_ctx, ValueObject *ctx_obj)
: ClangASTSource(exe_ctx.GetTargetSP()), m_found_entities(),
m_struct_members(), m_keep_result_in_memory(keep_result_in_memory),
- m_result_delegate(result_delegate), m_parser_vars(), m_struct_vars() {
+ m_result_delegate(result_delegate), m_ctx_obj(ctx_obj), m_parser_vars(),
+ m_struct_vars() {
EnableStructVars();
}
@@ -132,7 +132,7 @@ void ClangExpressionDeclMap::DidParse() {
if (log)
ClangASTMetrics::DumpCounters(log);
- if (m_parser_vars.get()) {
+ if (m_parser_vars) {
for (size_t entity_index = 0, num_entities = m_found_entities.GetSize();
entity_index < num_entities; ++entity_index) {
ExpressionVariableSP var_sp(
@@ -272,9 +272,15 @@ static clang::QualType ExportAllDeclaredTypes(
merger.AddSources(importer_source);
clang::ASTImporter &exporter = merger.ImporterForOrigin(source);
CompleteAllDeclContexts(exporter, file, root);
- clang::QualType ret = exporter.Import(root);
+ llvm::Expected<clang::QualType> ret_or_error = exporter.Import(root);
merger.RemoveSources(importer_source);
- return ret;
+ if (ret_or_error) {
+ return *ret_or_error;
+ } else {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG_ERROR(log, ret_or_error.takeError(), "Couldn't import type: {0}");
+ return clang::QualType();
+ }
}
TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
@@ -309,7 +315,7 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target,
}
bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
- const ConstString &name,
+ ConstString name,
TypeFromParser parser_type,
bool is_result,
bool is_lvalue) {
@@ -361,7 +367,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
ExecutionContext &exe_ctx = m_parser_vars->m_exe_ctx;
Target *target = exe_ctx.GetTargetPtr();
- if (target == NULL)
+ if (target == nullptr)
return false;
ClangASTContext *context(target->GetScratchClangASTContext());
@@ -424,7 +430,7 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl,
}
bool ClangExpressionDeclMap::AddValueToStruct(const NamedDecl *decl,
- const ConstString &name,
+ ConstString name,
llvm::Value *value, size_t size,
lldb::offset_t alignment) {
assert(m_struct_vars.get());
@@ -604,7 +610,7 @@ bool ClangExpressionDeclMap::GetFunctionInfo(const NamedDecl *decl,
addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target,
Process *process,
- const ConstString &name,
+ ConstString name,
lldb::SymbolType symbol_type,
lldb_private::Module *module) {
SymbolContextList sc_list;
@@ -692,7 +698,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target,
}
if (symbol_load_addr == LLDB_INVALID_ADDRESS && process) {
- ObjCLanguageRuntime *runtime = process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process);
if (runtime) {
symbol_load_addr = runtime->LookupRuntimeSymbol(name);
@@ -702,7 +708,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(Target &target,
return symbol_load_addr;
}
-addr_t ClangExpressionDeclMap::GetSymbolAddress(const ConstString &name,
+addr_t ClangExpressionDeclMap::GetSymbolAddress(ConstString name,
lldb::SymbolType symbol_type) {
assert(m_parser_vars.get());
@@ -715,7 +721,7 @@ addr_t ClangExpressionDeclMap::GetSymbolAddress(const ConstString &name,
}
lldb::VariableSP ClangExpressionDeclMap::FindGlobalVariable(
- Target &target, ModuleSP &module, const ConstString &name,
+ Target &target, ModuleSP &module, ConstString name,
CompilerDeclContext *namespace_decl, TypeFromUser *type) {
VariableList vars;
@@ -921,16 +927,31 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
name.GetCString());
context.AddNamedDecl(parser_named_decl);
- } while (0);
+ } while (false);
}
if (name.GetCString()[0] == '$' && !namespace_decl) {
static ConstString g_lldb_class_name("$__lldb_class");
if (name == g_lldb_class_name) {
+ if (m_ctx_obj) {
+ Status status;
+ lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
+ if (!ctx_obj_ptr || status.Fail())
+ return;
+
+ AddThisType(context, TypeFromUser(m_ctx_obj->GetCompilerType()),
+ current_id);
+
+ m_struct_vars->m_object_pointer_type =
+ TypeFromUser(ctx_obj_ptr->GetCompilerType());
+
+ return;
+ }
+
// Clang is looking for the type of "this"
- if (frame == NULL)
+ if (frame == nullptr)
return;
// Find the block that defines the function represented by "sym_ctx"
@@ -1020,6 +1041,21 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
static ConstString g_lldb_objc_class_name("$__lldb_objc_class");
if (name == g_lldb_objc_class_name) {
+ if (m_ctx_obj) {
+ Status status;
+ lldb::ValueObjectSP ctx_obj_ptr = m_ctx_obj->AddressOf(status);
+ if (!ctx_obj_ptr || status.Fail())
+ return;
+
+ AddOneType(context, TypeFromUser(m_ctx_obj->GetCompilerType()),
+ current_id);
+
+ m_struct_vars->m_object_pointer_type =
+ TypeFromUser(ctx_obj_ptr->GetCompilerType());
+
+ return;
+ }
+
// Clang is looking for the type of "*self"
if (!frame)
@@ -1241,7 +1277,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
}
}
if (target) {
- var = FindGlobalVariable(*target, module_sp, name, &namespace_decl, NULL);
+ var = FindGlobalVariable(*target, module_sp, name, &namespace_decl,
+ nullptr);
if (var) {
valobj = ValueObjectVariable::Create(target, var);
@@ -1398,8 +1435,8 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
}
if (sc_list.GetSize()) {
- Symbol *extern_symbol = NULL;
- Symbol *non_extern_symbol = NULL;
+ Symbol *extern_symbol = nullptr;
+ Symbol *non_extern_symbol = nullptr;
for (uint32_t index = 0, num_indices = sc_list.GetSize();
index < num_indices; ++index) {
@@ -1416,13 +1453,13 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
if (decl_ctx.IsClassMethod(nullptr, nullptr, nullptr))
continue;
- AddOneFunction(context, sym_ctx.function, NULL, current_id);
+ AddOneFunction(context, sym_ctx.function, nullptr, current_id);
context.m_found.function_with_type_info = true;
context.m_found.function = true;
} else if (sym_ctx.symbol) {
if (sym_ctx.symbol->GetType() == eSymbolTypeReExported && target) {
sym_ctx.symbol = sym_ctx.symbol->ResolveReExportedSymbol(*target);
- if (sym_ctx.symbol == NULL)
+ if (sym_ctx.symbol == nullptr)
continue;
}
@@ -1448,10 +1485,10 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
if (!context.m_found.function_with_type_info) {
if (extern_symbol) {
- AddOneFunction(context, NULL, extern_symbol, current_id);
+ AddOneFunction(context, nullptr, extern_symbol, current_id);
context.m_found.function = true;
} else if (non_extern_symbol) {
- AddOneFunction(context, NULL, non_extern_symbol, current_id);
+ AddOneFunction(context, nullptr, non_extern_symbol, current_id);
context.m_found.function = true;
}
}
@@ -1525,7 +1562,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
context.m_found.variable = true;
}
}
- } while (0);
+ } while (false);
}
if (target && !context.m_found.variable && !namespace_decl) {
@@ -1687,7 +1724,7 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
bool is_reference = pt.IsReferenceType();
- NamedDecl *var_decl = NULL;
+ NamedDecl *var_decl = nullptr;
if (is_reference)
var_decl = context.AddVarDecl(pt);
else
@@ -1704,7 +1741,7 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
entity->GetParserVars(GetParserID());
parser_vars->m_parser_type = pt;
parser_vars->m_named_decl = var_decl;
- parser_vars->m_llvm_value = NULL;
+ parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value = var_location;
parser_vars->m_lldb_var = var;
@@ -1747,7 +1784,7 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context,
->GetParserVars(GetParserID());
parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
- parser_vars->m_llvm_value = NULL;
+ parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value.Clear();
if (log) {
@@ -1766,7 +1803,7 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
- if (target == NULL)
+ if (target == nullptr)
return;
ASTContext *scratch_ast_context =
@@ -1805,7 +1842,7 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context,
parser_vars->m_parser_type = parser_type;
parser_vars->m_named_decl = var_decl;
- parser_vars->m_llvm_value = NULL;
+ parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_sym = &symbol;
if (log) {
@@ -1853,7 +1890,7 @@ bool ClangExpressionDeclMap::ResolveUnknownTypes() {
var_type.getAsOpaquePtr(),
ClangASTContext::GetASTContext(&var_decl->getASTContext()));
- lldb::opaque_compiler_type_t copied_type = 0;
+ lldb::opaque_compiler_type_t copied_type = nullptr;
if (m_ast_importer_sp) {
copied_type = m_ast_importer_sp->CopyType(
scratch_ast_context->getASTContext(), &var_decl->getASTContext(),
@@ -1926,7 +1963,7 @@ void ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context,
entity->GetParserVars(GetParserID());
parser_vars->m_parser_type = parser_clang_type;
parser_vars->m_named_decl = var_decl;
- parser_vars->m_llvm_value = NULL;
+ parser_vars->m_llvm_value = nullptr;
parser_vars->m_lldb_value.Clear();
entity->m_flags |= ClangExpressionVariable::EVBareRegister;
@@ -1945,7 +1982,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- NamedDecl *function_decl = NULL;
+ NamedDecl *function_decl = nullptr;
Address fun_address;
CompilerType function_clang_type;
@@ -2105,7 +2142,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
}
parser_vars->m_named_decl = function_decl;
- parser_vars->m_llvm_value = NULL;
+ parser_vars->m_llvm_value = nullptr;
if (log) {
std::string function_str =
@@ -2125,7 +2162,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
}
void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
- TypeFromUser &ut,
+ const TypeFromUser &ut,
unsigned int current_id) {
CompilerType copied_clang_type = GuardedCopyType(ut);
@@ -2158,7 +2195,7 @@ void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
CXXMethodDecl *method_decl =
ClangASTContext::GetASTContext(m_ast_context)
->AddMethodToCXXRecordType(
- copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", NULL,
+ copied_clang_type.GetOpaqueQualType(), "$__lldb_expr", nullptr,
method_type, lldb::eAccessPublic, is_virtual, is_static,
is_inline, is_explicit, is_attr_used, is_artificial);
@@ -2199,7 +2236,7 @@ void ClangExpressionDeclMap::AddThisType(NameSearchContext &context,
}
void ClangExpressionDeclMap::AddOneType(NameSearchContext &context,
- TypeFromUser &ut,
+ const TypeFromUser &ut,
unsigned int current_id) {
CompilerType copied_clang_type = GuardedCopyType(ut);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 93fa57876bce4..03b73e6be391f 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -1,9 +1,8 @@
//===-- ClangExpressionDeclMap.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,8 +29,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ClangExpressionDeclMap ClangExpressionDeclMap.h
+/// \class ClangExpressionDeclMap ClangExpressionDeclMap.h
/// "lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are
/// defined in LLDB's debug information.
///
@@ -54,236 +52,213 @@ namespace lldb_private {
///
/// Fourth and finally, it "dematerializes" the struct after the JITted code
/// has has executed, placing the new values back where it found the old ones.
-//----------------------------------------------------------------------
class ClangExpressionDeclMap : public ClangASTSource {
public:
- //------------------------------------------------------------------
/// Constructor
///
/// Initializes class variables.
///
- /// @param[in] keep_result_in_memory
+ /// \param[in] keep_result_in_memory
/// If true, inhibits the normal deallocation of the memory for
/// the result persistent variable, and instead marks the variable
/// as persisting.
///
- /// @param[in] delegate
+ /// \param[in] delegate
/// If non-NULL, use this delegate to report result values. This
/// allows the client ClangUserExpression to report a result.
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to use when parsing.
- //------------------------------------------------------------------
+ ///
+ /// \param[in] ctx_obj
+ /// If not empty, then expression is evaluated in context of this object.
+ /// See the comment to `UserExpression::Evaluate` for details.
ClangExpressionDeclMap(
bool keep_result_in_memory,
Materializer::PersistentVariableDelegate *result_delegate,
- ExecutionContext &exe_ctx);
+ ExecutionContext &exe_ctx,
+ ValueObject *ctx_obj);
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
~ClangExpressionDeclMap() override;
- //------------------------------------------------------------------
/// Enable the state needed for parsing and IR transformation.
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to use when finding types for variables.
/// Also used to find a "scratch" AST context to store result types.
///
- /// @param[in] materializer
+ /// \param[in] materializer
/// If non-NULL, the materializer to populate with information about
/// the variables to use
///
- /// @return
+ /// \return
/// True if parsing is possible; false if it is unsafe to continue.
- //------------------------------------------------------------------
bool WillParse(ExecutionContext &exe_ctx, Materializer *materializer);
void InstallCodeGenerator(clang::ASTConsumer *code_gen);
- //------------------------------------------------------------------
/// [Used by ClangExpressionParser] For each variable that had an unknown
/// type at the beginning of parsing, determine its final type now.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
bool ResolveUnknownTypes();
- //------------------------------------------------------------------
/// Disable the state needed for parsing and IR transformation.
- //------------------------------------------------------------------
void DidParse();
- //------------------------------------------------------------------
/// [Used by IRForTarget] Add a variable to the list of persistent
/// variables for the process.
///
- /// @param[in] decl
+ /// \param[in] decl
/// The Clang declaration for the persistent variable, used for
/// lookup during parsing.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the persistent variable, usually $something.
///
- /// @param[in] type
+ /// \param[in] type
/// The type of the variable, in the Clang parser's context.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
bool AddPersistentVariable(const clang::NamedDecl *decl,
- const ConstString &name, TypeFromParser type,
+ ConstString name, TypeFromParser type,
bool is_result, bool is_lvalue);
- //------------------------------------------------------------------
/// [Used by IRForTarget] Add a variable to the struct that needs to
/// be materialized each time the expression runs.
///
- /// @param[in] decl
+ /// \param[in] decl
/// The Clang declaration for the variable.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the variable.
///
- /// @param[in] value
+ /// \param[in] value
/// The LLVM IR value for this variable.
///
- /// @param[in] size
+ /// \param[in] size
/// The size of the variable in bytes.
///
- /// @param[in] alignment
+ /// \param[in] alignment
/// The required alignment of the variable in bytes.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
- bool AddValueToStruct(const clang::NamedDecl *decl, const ConstString &name,
+ bool AddValueToStruct(const clang::NamedDecl *decl, ConstString name,
llvm::Value *value, size_t size,
lldb::offset_t alignment);
- //------------------------------------------------------------------
/// [Used by IRForTarget] Finalize the struct, laying out the position of
/// each object in it.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
bool DoStructLayout();
- //------------------------------------------------------------------
/// [Used by IRForTarget] Get general information about the laid-out struct
/// after DoStructLayout() has been called.
///
- /// @param[out] num_elements
+ /// \param[out] num_elements
/// The number of elements in the struct.
///
- /// @param[out] size
+ /// \param[out] size
/// The size of the struct, in bytes.
///
- /// @param[out] alignment
+ /// \param[out] alignment
/// The alignment of the struct, in bytes.
///
- /// @return
+ /// \return
/// True if the information could be retrieved; false otherwise.
- //------------------------------------------------------------------
bool GetStructInfo(uint32_t &num_elements, size_t &size,
lldb::offset_t &alignment);
- //------------------------------------------------------------------
/// [Used by IRForTarget] Get specific information about one field of the
/// laid-out struct after DoStructLayout() has been called.
///
- /// @param[out] decl
+ /// \param[out] decl
/// The parsed Decl for the field, as generated by ClangASTSource
/// on ClangExpressionDeclMap's behalf. In the case of the result
/// value, this will have the name $__lldb_result even if the
/// result value ends up having the name $1. This is an
/// implementation detail of IRForTarget.
///
- /// @param[out] value
+ /// \param[out] value
/// The IR value for the field (usually a GlobalVariable). In
/// the case of the result value, this will have the correct
/// name ($1, for instance). This is an implementation detail
/// of IRForTarget.
///
- /// @param[out] offset
+ /// \param[out] offset
/// The offset of the field from the beginning of the struct.
/// As long as the struct is aligned according to its required
/// alignment, this offset will align the field correctly.
///
- /// @param[out] name
+ /// \param[out] name
/// The name of the field as used in materialization.
///
- /// @param[in] index
+ /// \param[in] index
/// The index of the field about which information is requested.
///
- /// @return
+ /// \return
/// True if the information could be retrieved; false otherwise.
- //------------------------------------------------------------------
bool GetStructElement(const clang::NamedDecl *&decl, llvm::Value *&value,
lldb::offset_t &offset, ConstString &name,
uint32_t index);
- //------------------------------------------------------------------
/// [Used by IRForTarget] Get information about a function given its Decl.
///
- /// @param[in] decl
+ /// \param[in] decl
/// The parsed Decl for the Function, as generated by ClangASTSource
/// on ClangExpressionDeclMap's behalf.
///
- /// @param[out] ptr
+ /// \param[out] ptr
/// The absolute address of the function in the target.
///
- /// @return
+ /// \return
/// True if the information could be retrieved; false otherwise.
- //------------------------------------------------------------------
bool GetFunctionInfo(const clang::NamedDecl *decl, uint64_t &ptr);
- //------------------------------------------------------------------
/// [Used by IRForTarget] Get the address of a symbol given nothing but its
/// name.
///
- /// @param[in] target
+ /// \param[in] target
/// The target to find the symbol in. If not provided,
/// then the current parsing context's Target.
///
- /// @param[in] process
+ /// \param[in] process
/// The process to use. For Objective-C symbols, the process's
/// Objective-C language runtime may be queried if the process
/// is non-NULL.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the symbol.
///
- /// @param[in] module
+ /// \param[in] module
/// The module to limit the search to. This can be NULL
///
- /// @return
+ /// \return
/// Valid load address for the symbol
- //------------------------------------------------------------------
lldb::addr_t GetSymbolAddress(Target &target, Process *process,
- const ConstString &name,
- lldb::SymbolType symbol_type,
- Module *module = NULL);
+ ConstString name, lldb::SymbolType symbol_type,
+ Module *module = nullptr);
- lldb::addr_t GetSymbolAddress(const ConstString &name,
+ lldb::addr_t GetSymbolAddress(ConstString name,
lldb::SymbolType symbol_type);
- //------------------------------------------------------------------
/// [Used by IRInterpreter] Get basic target information.
///
- /// @param[out] byte_order
+ /// \param[out] byte_order
/// The byte order of the target.
///
- /// @param[out] address_byte_size
+ /// \param[out] address_byte_size
/// The size of a pointer in bytes.
///
- /// @return
+ /// \return
/// True if the information could be determined; false
/// otherwise.
- //------------------------------------------------------------------
struct TargetInfo {
lldb::ByteOrder byte_order;
size_t address_byte_size;
@@ -296,38 +271,34 @@ public:
};
TargetInfo GetTargetInfo();
- //------------------------------------------------------------------
/// [Used by ClangASTSource] Find all entities matching a given name, using
/// a NameSearchContext to make Decls for them.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
void FindExternalVisibleDecls(NameSearchContext &context) override;
- //------------------------------------------------------------------
/// Find all entities matching a given name in a given module/namespace,
/// using a NameSearchContext to make Decls for them.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext that can construct Decls for this name.
///
- /// @param[in] module
+ /// \param[in] module
/// If non-NULL, the module to query.
///
- /// @param[in] namespace_decl
+ /// \param[in] namespace_decl
/// If valid and module is non-NULL, the parent namespace.
///
- /// @param[in] current_id
+ /// \param[in] current_id
/// The ID for the current FindExternalVisibleDecls invocation,
/// for logging purposes.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
void FindExternalVisibleDecls(NameSearchContext &context,
lldb::ModuleSP module,
CompilerDeclContext &namespace_decl,
@@ -344,10 +315,12 @@ private:
Materializer::PersistentVariableDelegate
*m_result_delegate; ///< If non-NULL, used to report expression results to
///ClangUserExpression.
+ ValueObject *m_ctx_obj; ///< If not empty, then expression is
+ ///evaluated in context of this object.
+ ///For details see the comment to
+ ///`UserExpression::Evaluate`.
- //----------------------------------------------------------------------
/// The following values should not live beyond parsing
- //----------------------------------------------------------------------
class ParserVars {
public:
ParserVars() {}
@@ -357,7 +330,7 @@ private:
return m_exe_ctx.GetTargetPtr();
else if (m_sym_ctx.target_sp)
m_sym_ctx.target_sp.get();
- return NULL;
+ return nullptr;
}
ExecutionContext m_exe_ctx; ///< The execution context to use when parsing.
@@ -380,27 +353,21 @@ private:
std::unique_ptr<ParserVars> m_parser_vars;
- //----------------------------------------------------------------------
/// Activate parser-specific variables
- //----------------------------------------------------------------------
void EnableParserVars() {
if (!m_parser_vars.get())
m_parser_vars = llvm::make_unique<ParserVars>();
}
- //----------------------------------------------------------------------
/// Deallocate parser-specific variables
- //----------------------------------------------------------------------
void DisableParserVars() { m_parser_vars.reset(); }
- //----------------------------------------------------------------------
/// The following values contain layout information for the materialized
/// struct, but are not specific to a single materialization
- //----------------------------------------------------------------------
struct StructVars {
StructVars()
: m_struct_alignment(0), m_struct_size(0), m_struct_laid_out(false),
- m_result_name(), m_object_pointer_type(NULL, NULL) {}
+ m_result_name(), m_object_pointer_type(nullptr, nullptr) {}
lldb::offset_t
m_struct_alignment; ///< The alignment of the struct in bytes.
@@ -416,202 +383,176 @@ private:
std::unique_ptr<StructVars> m_struct_vars;
- //----------------------------------------------------------------------
/// Activate struct variables
- //----------------------------------------------------------------------
void EnableStructVars() {
if (!m_struct_vars.get())
m_struct_vars.reset(new struct StructVars);
}
- //----------------------------------------------------------------------
/// Deallocate struct variables
- //----------------------------------------------------------------------
void DisableStructVars() { m_struct_vars.reset(); }
- //----------------------------------------------------------------------
/// Get this parser's ID for use in extracting parser- and JIT-specific data
/// from persistent variables.
- //----------------------------------------------------------------------
uint64_t GetParserID() { return (uint64_t) this; }
- //------------------------------------------------------------------
/// Given a target, find a variable that matches the given name and type.
///
- /// @param[in] target
+ /// \param[in] target
/// The target to use as a basis for finding the variable.
///
- /// @param[in] module
+ /// \param[in] module
/// If non-NULL, the module to search.
///
- /// @param[in] name
+ /// \param[in] name
/// The name as a plain C string.
///
- /// @param[in] namespace_decl
+ /// \param[in] namespace_decl
/// If non-NULL and module is non-NULL, the parent namespace.
///
- /// @param[in] type
+ /// \param[in] type
/// The required type for the variable. This function may be called
/// during parsing, in which case we don't know its type; hence the
/// default.
///
- /// @return
+ /// \return
/// The LLDB Variable found, or NULL if none was found.
- //------------------------------------------------------------------
lldb::VariableSP FindGlobalVariable(Target &target, lldb::ModuleSP &module,
- const ConstString &name,
+ ConstString name,
CompilerDeclContext *namespace_decl,
- TypeFromUser *type = NULL);
+ TypeFromUser *type = nullptr);
- //------------------------------------------------------------------
/// Get the value of a variable in a given execution context and return the
/// associated Types if needed.
///
- /// @param[in] var
+ /// \param[in] var
/// The variable to evaluate.
///
- /// @param[out] var_location
+ /// \param[out] var_location
/// The variable location value to fill in
///
- /// @param[out] found_type
+ /// \param[out] found_type
/// The type of the found value, as it was found in the user process.
/// This is only useful when the variable is being inspected on behalf
/// of the parser, hence the default.
///
- /// @param[out] parser_type
+ /// \param[out] parser_type
/// The type of the found value, as it was copied into the parser's
/// AST context. This is only useful when the variable is being
/// inspected on behalf of the parser, hence the default.
///
- /// @param[in] decl
+ /// \param[in] decl
/// The Decl to be looked up.
///
- /// @return
+ /// \return
/// Return true if the value was successfully filled in.
- //------------------------------------------------------------------
bool GetVariableValue(lldb::VariableSP &var,
lldb_private::Value &var_location,
- TypeFromUser *found_type = NULL,
- TypeFromParser *parser_type = NULL);
+ TypeFromUser *found_type = nullptr,
+ TypeFromParser *parser_type = nullptr);
- //------------------------------------------------------------------
/// Use the NameSearchContext to generate a Decl for the given LLDB
/// Variable, and put it in the Tuple list.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] var
+ /// \param[in] var
/// The LLDB Variable that needs a Decl.
///
- /// @param[in] valobj
+ /// \param[in] valobj
/// The LLDB ValueObject for that variable.
- //------------------------------------------------------------------
void AddOneVariable(NameSearchContext &context, lldb::VariableSP var,
lldb::ValueObjectSP valobj, unsigned int current_id);
- //------------------------------------------------------------------
/// Use the NameSearchContext to generate a Decl for the given persistent
/// variable, and put it in the list of found entities.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] pvar
+ /// \param[in] pvar
/// The persistent variable that needs a Decl.
///
- /// @param[in] current_id
+ /// \param[in] current_id
/// The ID of the current invocation of FindExternalVisibleDecls
/// for logging purposes.
- //------------------------------------------------------------------
void AddOneVariable(NameSearchContext &context,
lldb::ExpressionVariableSP &pvar_sp,
unsigned int current_id);
- //------------------------------------------------------------------
/// Use the NameSearchContext to generate a Decl for the given LLDB symbol
/// (treated as a variable), and put it in the list of found entities.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] var
+ /// \param[in] var
/// The LLDB Variable that needs a Decl.
- //------------------------------------------------------------------
void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol,
unsigned int current_id);
- //------------------------------------------------------------------
/// Use the NameSearchContext to generate a Decl for the given function.
/// (Functions are not placed in the Tuple list.) Can handle both fully
/// typed functions and generic functions.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] fun
+ /// \param[in] fun
/// The Function that needs to be created. If non-NULL, this is
/// a fully-typed function.
///
- /// @param[in] sym
+ /// \param[in] sym
/// The Symbol that corresponds to a function that needs to be
/// created with generic type (unitptr_t foo(...)).
- //------------------------------------------------------------------
void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym,
unsigned int current_id);
- //------------------------------------------------------------------
/// Use the NameSearchContext to generate a Decl for the given register.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] reg_info
+ /// \param[in] reg_info
/// The information corresponding to that register.
- //------------------------------------------------------------------
void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info,
unsigned int current_id);
- //------------------------------------------------------------------
/// Use the NameSearchContext to generate a Decl for the given type. (Types
/// are not placed in the Tuple list.)
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] type
+ /// \param[in] type
/// The type that needs to be created.
- //------------------------------------------------------------------
- void AddOneType(NameSearchContext &context, TypeFromUser &type,
+ void AddOneType(NameSearchContext &context, const TypeFromUser &type,
unsigned int current_id);
- //------------------------------------------------------------------
/// Generate a Decl for "*this" and add a member function declaration to it
/// for the expression, then report it.
///
- /// @param[in] context
+ /// \param[in] context
/// The NameSearchContext to use when constructing the Decl.
///
- /// @param[in] type
+ /// \param[in] type
/// The type for *this.
- //------------------------------------------------------------------
- void AddThisType(NameSearchContext &context, TypeFromUser &type,
+ void AddThisType(NameSearchContext &context, const TypeFromUser &type,
unsigned int current_id);
- //------------------------------------------------------------------
/// Move a type out of the current ASTContext into another, but make sure to
/// export all components of the type also.
///
- /// @param[in] target
+ /// \param[in] target
/// The ClangASTContext to move to.
- /// @param[in] source
+ /// \param[in] source
/// The ClangASTContext to move from. This is assumed to be going away.
- /// @param[in] parser_type
+ /// \param[in] parser_type
/// The type as it appears in the source context.
///
- /// @return
+ /// \return
/// Returns the moved type, or an empty type if there was a problem.
- //------------------------------------------------------------------
TypeFromUser DeportType(ClangASTContext &target, ClangASTContext &source,
TypeFromParser parser_type);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
index b5b640c9185f2..48da5abb91261 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionHelper.h
@@ -1,9 +1,8 @@
//===-- ClangExpressionHelper.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@ namespace lldb_private {
class RecordingMemoryManager;
-//----------------------------------------------------------------------
// ClangExpressionHelper
-//----------------------------------------------------------------------
class ClangExpressionHelper : public ExpressionTypeSystemHelper {
public:
static bool classof(const ExpressionTypeSystemHelper *ts) {
@@ -37,25 +34,19 @@ public:
: ExpressionTypeSystemHelper(
ExpressionTypeSystemHelper::LLVMCastKind::eKindClangHelper) {}
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
virtual ~ClangExpressionHelper() {}
- //------------------------------------------------------------------
/// Return the object that the parser should use when resolving external
/// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
virtual ClangExpressionDeclMap *DeclMap() = 0;
- //------------------------------------------------------------------
/// Return the object that the parser should allow to access ASTs.
/// May be NULL if the ASTs do not need to be transformed.
///
- /// @param[in] passthrough
+ /// \param[in] passthrough
/// The ASTConsumer that the returned transformer should send
/// the ASTs to after transformation.
- //------------------------------------------------------------------
virtual clang::ASTConsumer *
ASTTransformer(clang::ASTConsumer *passthrough) = 0;
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index 6650c0db967f3..7d13891ded8d2 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1,19 +1,16 @@
//===-- ClangExpressionParser.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <cctype>
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ExternalASTSource.h"
#include "clang/AST/PrettyPrinter.h"
#include "clang/Basic/DiagnosticIDs.h"
-#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
@@ -39,15 +36,11 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
+#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/TargetSelect.h"
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wglobal-constructors"
-#include "llvm/ExecutionEngine/MCJIT.h"
-#pragma clang diagnostic pop
-
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/DynamicLibrary.h"
@@ -58,19 +51,25 @@
#include "ClangDiagnostic.h"
#include "ClangExpressionParser.h"
+#include "ClangUserExpression.h"
+#include "ASTUtils.h"
#include "ClangASTSource.h"
+#include "ClangDiagnostic.h"
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionHelper.h"
+#include "ClangExpressionParser.h"
+#include "ClangHost.h"
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
+#include "IRDynamicChecks.h"
#include "IRForTarget.h"
+#include "ModuleDependencyCollector.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Expression/IRDynamicChecks.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Expression/IRInterpreter.h"
#include "lldb/Host/File.h"
@@ -79,17 +78,22 @@
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/ThreadPlanCallFunction.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StringList.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
+#include <cctype>
+#include <memory>
+
using namespace clang;
using namespace llvm;
using namespace lldb_private;
@@ -111,24 +115,19 @@ public:
void moduleImport(SourceLocation import_location, clang::ModuleIdPath path,
const clang::Module * /*null*/) override {
- std::vector<ConstString> string_path;
+ SourceModule module;
- for (const std::pair<IdentifierInfo *, SourceLocation> &component : path) {
- string_path.push_back(ConstString(component.first->getName()));
- }
+ for (const std::pair<IdentifierInfo *, SourceLocation> &component : path)
+ module.path.push_back(ConstString(component.first->getName()));
StreamString error_stream;
ClangModulesDeclVendor::ModuleVector exported_modules;
-
- if (!m_decl_vendor.AddModule(string_path, &exported_modules,
- m_error_stream)) {
+ if (!m_decl_vendor.AddModule(module, &exported_modules, m_error_stream))
m_has_errors = true;
- }
- for (ClangModulesDeclVendor::ModuleID module : exported_modules) {
+ for (ClangModulesDeclVendor::ModuleID module : exported_modules)
m_persistent_vars.AddHandLoadedClangModule(module);
- }
}
bool hasErrors() { return m_has_errors; }
@@ -150,7 +149,7 @@ public:
}
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const clang::Diagnostic &Info) {
+ const clang::Diagnostic &Info) override {
if (m_manager) {
llvm::SmallVector<char, 32> diag_str;
Info.FormatDiagnostic(diag_str);
@@ -214,15 +213,58 @@ private:
std::shared_ptr<clang::TextDiagnosticBuffer> m_passthrough;
};
+static void
+SetupModuleHeaderPaths(CompilerInstance *compiler,
+ std::vector<ConstString> include_directories,
+ lldb::TargetSP target_sp) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts();
+
+ for (ConstString dir : include_directories) {
+ search_opts.AddPath(dir.AsCString(), frontend::System, false, true);
+ LLDB_LOG(log, "Added user include dir: {0}", dir);
+ }
+
+ llvm::SmallString<128> module_cache;
+ auto props = ModuleList::GetGlobalModuleListProperties();
+ props.GetClangModulesCachePath().GetPath(module_cache);
+ search_opts.ModuleCachePath = module_cache.str();
+ LLDB_LOG(log, "Using module cache path: {0}", module_cache.c_str());
+
+ FileSpec clang_resource_dir = GetClangResourceDir();
+ std::string resource_dir = clang_resource_dir.GetPath();
+ if (FileSystem::Instance().IsDirectory(resource_dir)) {
+ search_opts.ResourceDir = resource_dir;
+ std::string resource_include = resource_dir + "/include";
+ search_opts.AddPath(resource_include, frontend::System, false, true);
+
+ LLDB_LOG(log, "Added resource include dir: {0}", resource_include);
+ }
+
+ search_opts.ImplicitModuleMaps = true;
+
+ std::vector<std::string> system_include_directories =
+ target_sp->GetPlatform()->GetSystemIncludeDirectories(
+ lldb::eLanguageTypeC_plus_plus);
+
+ for (const std::string &include_dir : system_include_directories) {
+ search_opts.AddPath(include_dir, frontend::System, false, true);
+
+ LLDB_LOG(log, "Added system include dir: {0}", include_dir);
+ }
+}
+
//===----------------------------------------------------------------------===//
// Implementation of ClangExpressionParser
//===----------------------------------------------------------------------===//
-ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
- Expression &expr,
- bool generate_debug_info)
+ClangExpressionParser::ClangExpressionParser(
+ ExecutionContextScope *exe_scope, Expression &expr,
+ bool generate_debug_info, std::vector<ConstString> include_directories)
: ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(),
- m_pp_callbacks(nullptr) {
+ m_pp_callbacks(nullptr),
+ m_include_directories(std::move(include_directories)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
// We can't compile expressions without a target. So if the exe_scope is
@@ -249,6 +291,22 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
// 1. Create a new compiler instance.
m_compiler.reset(new CompilerInstance());
+
+ // When capturing a reproducer, hook up the file collector with clang to
+ // collector modules and headers.
+ if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+ repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>();
+ m_compiler->setModuleDepCollector(
+ std::make_shared<ModuleDependencyCollectorAdaptor>(
+ fp.GetFileCollector()));
+ DependencyOutputOptions &opts = m_compiler->getDependencyOutputOpts();
+ opts.IncludeSystemHeaders = true;
+ opts.IncludeModuleFiles = true;
+ }
+
+ // Make sure clang uses the same VFS as LLDB.
+ m_compiler->createFileManager(FileSystem::Instance().GetVirtualFileSystem());
+
lldb::LanguageType frame_lang =
expr.Language(); // defaults to lldb::eLanguageTypeUnknown
bool overridden_target_opts = false;
@@ -363,6 +421,7 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
// 5. Set language options.
lldb::LanguageType language = expr.Language();
+ LangOptions &lang_opts = m_compiler->getLangOpts();
switch (language) {
case lldb::eLanguageTypeC:
@@ -374,13 +433,13 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
// For now, the expression parser must use C++ anytime the language is a C
// family language, because the expression parser uses features of C++ to
// capture values.
- m_compiler->getLangOpts().CPlusPlus = true;
+ lang_opts.CPlusPlus = true;
break;
case lldb::eLanguageTypeObjC:
- m_compiler->getLangOpts().ObjC = true;
+ lang_opts.ObjC = true;
// FIXME: the following language option is a temporary workaround,
// to "ask for ObjC, get ObjC++" (see comment above).
- m_compiler->getLangOpts().CPlusPlus = true;
+ lang_opts.CPlusPlus = true;
// Clang now sets as default C++14 as the default standard (with
// GNU extensions), so we do the same here to avoid mismatches that
@@ -388,71 +447,92 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
// as it's a C++11 feature). Currently lldb evaluates C++14 as C++11 (see
// two lines below) so we decide to be consistent with that, but this could
// be re-evaluated in the future.
- m_compiler->getLangOpts().CPlusPlus11 = true;
+ lang_opts.CPlusPlus11 = true;
break;
case lldb::eLanguageTypeC_plus_plus:
case lldb::eLanguageTypeC_plus_plus_11:
case lldb::eLanguageTypeC_plus_plus_14:
- m_compiler->getLangOpts().CPlusPlus11 = true;
+ lang_opts.CPlusPlus11 = true;
m_compiler->getHeaderSearchOpts().UseLibcxx = true;
LLVM_FALLTHROUGH;
case lldb::eLanguageTypeC_plus_plus_03:
- m_compiler->getLangOpts().CPlusPlus = true;
+ lang_opts.CPlusPlus = true;
if (process_sp)
- m_compiler->getLangOpts().ObjC =
+ lang_opts.ObjC =
process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC) != nullptr;
break;
case lldb::eLanguageTypeObjC_plus_plus:
case lldb::eLanguageTypeUnknown:
default:
- m_compiler->getLangOpts().ObjC = true;
- m_compiler->getLangOpts().CPlusPlus = true;
- m_compiler->getLangOpts().CPlusPlus11 = true;
+ lang_opts.ObjC = true;
+ lang_opts.CPlusPlus = true;
+ lang_opts.CPlusPlus11 = true;
m_compiler->getHeaderSearchOpts().UseLibcxx = true;
break;
}
- m_compiler->getLangOpts().Bool = true;
- m_compiler->getLangOpts().WChar = true;
- m_compiler->getLangOpts().Blocks = true;
- m_compiler->getLangOpts().DebuggerSupport =
+ lang_opts.Bool = true;
+ lang_opts.WChar = true;
+ lang_opts.Blocks = true;
+ lang_opts.DebuggerSupport =
true; // Features specifically for debugger clients
if (expr.DesiredResultType() == Expression::eResultTypeId)
- m_compiler->getLangOpts().DebuggerCastResultToId = true;
+ lang_opts.DebuggerCastResultToId = true;
- m_compiler->getLangOpts().CharIsSigned =
- ArchSpec(m_compiler->getTargetOpts().Triple.c_str())
- .CharIsSignedByDefault();
+ lang_opts.CharIsSigned = ArchSpec(m_compiler->getTargetOpts().Triple.c_str())
+ .CharIsSignedByDefault();
// Spell checking is a nice feature, but it ends up completing a lot of types
// that we didn't strictly speaking need to complete. As a result, we spend a
// long time parsing and importing debug information.
- m_compiler->getLangOpts().SpellChecking = false;
+ lang_opts.SpellChecking = false;
+
+ auto *clang_expr = dyn_cast<ClangUserExpression>(&m_expr);
+ if (clang_expr && clang_expr->DidImportCxxModules()) {
+ LLDB_LOG(log, "Adding lang options for importing C++ modules");
+
+ lang_opts.Modules = true;
+ // We want to implicitly build modules.
+ lang_opts.ImplicitModules = true;
+ // To automatically import all submodules when we import 'std'.
+ lang_opts.ModulesLocalVisibility = false;
+
+ // We use the @import statements, so we need this:
+ // FIXME: We could use the modules-ts, but that currently doesn't work.
+ lang_opts.ObjC = true;
+
+ // Options we need to parse libc++ code successfully.
+ // FIXME: We should ask the driver for the appropriate default flags.
+ lang_opts.GNUMode = true;
+ lang_opts.GNUKeywords = true;
+ lang_opts.DoubleSquareBracketAttributes = true;
+ lang_opts.CPlusPlus11 = true;
+
+ SetupModuleHeaderPaths(m_compiler.get(), m_include_directories,
+ target_sp);
+ }
- if (process_sp && m_compiler->getLangOpts().ObjC) {
- if (process_sp->GetObjCLanguageRuntime()) {
- if (process_sp->GetObjCLanguageRuntime()->GetRuntimeVersion() ==
+ if (process_sp && lang_opts.ObjC) {
+ if (auto *runtime = ObjCLanguageRuntime::Get(*process_sp)) {
+ if (runtime->GetRuntimeVersion() ==
ObjCLanguageRuntime::ObjCRuntimeVersions::eAppleObjC_V2)
- m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::MacOSX,
- VersionTuple(10, 7));
+ lang_opts.ObjCRuntime.set(ObjCRuntime::MacOSX, VersionTuple(10, 7));
else
- m_compiler->getLangOpts().ObjCRuntime.set(ObjCRuntime::FragileMacOSX,
- VersionTuple(10, 7));
+ lang_opts.ObjCRuntime.set(ObjCRuntime::FragileMacOSX,
+ VersionTuple(10, 7));
- if (process_sp->GetObjCLanguageRuntime()->HasNewLiteralsAndIndexing())
- m_compiler->getLangOpts().DebuggerObjCLiteral = true;
+ if (runtime->HasNewLiteralsAndIndexing())
+ lang_opts.DebuggerObjCLiteral = true;
}
}
- m_compiler->getLangOpts().ThreadsafeStatics = false;
- m_compiler->getLangOpts().AccessControl =
- false; // Debuggers get universal access
- m_compiler->getLangOpts().DollarIdents =
- true; // $ indicates a persistent variable name
+ lang_opts.ThreadsafeStatics = false;
+ lang_opts.AccessControl = false; // Debuggers get universal access
+ lang_opts.DollarIdents = true; // $ indicates a persistent variable name
// We enable all builtin functions beside the builtins from libc/libm (e.g.
// 'fopen'). Those libc functions are already correctly handled by LLDB, and
// additionally enabling them as expandable builtins is breaking Clang.
- m_compiler->getLangOpts().NoBuiltin = true;
+ lang_opts.NoBuiltin = true;
// Set CodeGen options
m_compiler->getCodeGenOpts().EmitDeclMetadata = true;
@@ -483,14 +563,9 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
m_compiler->getDiagnostics().setClient(new ClangDiagnosticManagerAdapter);
// 7. Set up the source management objects inside the compiler
-
- clang::FileSystemOptions file_system_options;
- m_file_manager.reset(new clang::FileManager(file_system_options));
-
- if (!m_compiler->hasSourceManager())
- m_compiler->createSourceManager(*m_file_manager.get());
-
m_compiler->createFileManager();
+ if (!m_compiler->hasSourceManager())
+ m_compiler->createSourceManager(m_compiler->getFileManager());
m_compiler->createPreprocessor(TU_Complete);
if (ClangModulesDeclVendor *decl_vendor =
@@ -517,17 +592,6 @@ ClangExpressionParser::ClangExpressionParser(ExecutionContextScope *exe_scope,
m_compiler->createASTContext();
clang::ASTContext &ast_context = m_compiler->getASTContext();
- ClangExpressionHelper *type_system_helper =
- dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
- ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
-
- if (decl_map) {
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source(
- decl_map->CreateProxy());
- decl_map->InstallASTContext(ast_context, m_compiler->getFileManager());
- ast_context.setExternalSource(ast_source);
- }
-
m_ast_context.reset(
new ClangASTContext(m_compiler->getTargetOpts().Triple.c_str()));
m_ast_context->setASTContext(&ast_context);
@@ -545,13 +609,11 @@ ClangExpressionParser::~ClangExpressionParser() {}
namespace {
-//----------------------------------------------------------------------
-/// @class CodeComplete
+/// \class CodeComplete
///
/// A code completion consumer for the clang Sema that is responsible for
/// creating the completion suggestions when a user requests completion
/// of an incomplete `expr` invocation.
-//----------------------------------------------------------------------
class CodeComplete : public CodeCompleteConsumer {
CodeCompletionTUInfo m_info;
@@ -624,20 +686,20 @@ class CodeComplete : public CodeCompleteConsumer {
public:
/// Constructs a CodeComplete consumer that can be attached to a Sema.
- /// @param[out] matches
+ /// \param[out] matches
/// The list of matches that the lldb completion API expects as a result.
/// This may already contain matches, so it's only allowed to append
/// to this variable.
- /// @param[out] expr
+ /// \param[out] expr
/// The whole expression string that we are currently parsing. This
/// string needs to be equal to the input the user typed, and NOT the
/// final code that Clang is parsing.
- /// @param[out] position
+ /// \param[out] position
/// The character position of the user cursor in the `expr` parameter.
///
CodeComplete(CompletionRequest &request, clang::LangOptions ops,
std::string expr, unsigned position)
- : CodeCompleteConsumer(CodeCompleteOptions(), false),
+ : CodeCompleteConsumer(CodeCompleteOptions()),
m_info(std::make_shared<GlobalCodeCompletionAllocator>()), m_expr(expr),
m_position(position), m_request(request), m_desc_policy(ops) {
@@ -653,7 +715,7 @@ public:
}
/// Deregisters and destroys this code-completion consumer.
- virtual ~CodeComplete() {}
+ ~CodeComplete() override {}
/// \name Code-completion filtering
/// Check if the result should be filtered out.
@@ -788,8 +850,8 @@ bool ClangExpressionParser::Complete(CompletionRequest &request, unsigned line,
// To actually get the raw user input here, we have to cast our expression to
// the LLVMUserExpression which exposes the right API. This should never fail
// as we always have a ClangUserExpression whenever we call this.
- LLVMUserExpression &llvm_expr = *static_cast<LLVMUserExpression *>(&m_expr);
- CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr.GetUserText(),
+ ClangUserExpression *llvm_expr = cast<ClangUserExpression>(&m_expr);
+ CodeComplete CC(request, m_compiler->getLangOpts(), llvm_expr->GetUserText(),
typed_pos);
// We don't need a code generator for parsing.
m_code_generator.reset();
@@ -848,9 +910,9 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
if (file.Write(expr_text, bytes_written).Success()) {
if (bytes_written == expr_text_len) {
file.Close();
- source_mgr.setMainFileID(
- source_mgr.createFileID(m_file_manager->getFile(result_path),
- SourceLocation(), SrcMgr::C_User));
+ source_mgr.setMainFileID(source_mgr.createFileID(
+ m_compiler->getFileManager().getFile(result_path),
+ SourceLocation(), SrcMgr::C_User));
created_main_file = true;
}
}
@@ -859,7 +921,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
if (!created_main_file) {
std::unique_ptr<MemoryBuffer> memory_buffer =
- MemoryBuffer::getMemBufferCopy(expr_text, __FUNCTION__);
+ MemoryBuffer::getMemBufferCopy(expr_text, "<lldb-expr>");
source_mgr.setMainFileID(source_mgr.createFileID(std::move(memory_buffer)));
}
@@ -869,12 +931,6 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
ClangExpressionHelper *type_system_helper =
dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
- ASTConsumer *ast_transformer =
- type_system_helper->ASTTransformer(m_code_generator.get());
-
- if (ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap())
- decl_map->InstallCodeGenerator(m_code_generator.get());
-
// If we want to parse for code completion, we need to attach our code
// completion consumer to the Sema and specify a completion position.
// While parsing the Sema will call this consumer with the provided
@@ -889,18 +945,72 @@ ClangExpressionParser::ParseInternal(DiagnosticManager &diagnostic_manager,
PP.SetCodeCompletionPoint(main_file, completion_line, completion_column);
}
+ ASTConsumer *ast_transformer =
+ type_system_helper->ASTTransformer(m_code_generator.get());
+
+ std::unique_ptr<clang::ASTConsumer> Consumer;
if (ast_transformer) {
- ast_transformer->Initialize(m_compiler->getASTContext());
- ParseAST(m_compiler->getPreprocessor(), ast_transformer,
- m_compiler->getASTContext(), false, TU_Complete,
- completion_consumer);
+ Consumer.reset(new ASTConsumerForwarder(ast_transformer));
+ } else if (m_code_generator) {
+ Consumer.reset(new ASTConsumerForwarder(m_code_generator.get()));
} else {
- m_code_generator->Initialize(m_compiler->getASTContext());
- ParseAST(m_compiler->getPreprocessor(), m_code_generator.get(),
- m_compiler->getASTContext(), false, TU_Complete,
- completion_consumer);
+ Consumer.reset(new ASTConsumer());
+ }
+
+ clang::ASTContext &ast_context = m_compiler->getASTContext();
+
+ m_compiler->setSema(new Sema(m_compiler->getPreprocessor(), ast_context,
+ *Consumer, TU_Complete, completion_consumer));
+ m_compiler->setASTConsumer(std::move(Consumer));
+
+ if (ast_context.getLangOpts().Modules) {
+ m_compiler->createModuleManager();
+ m_ast_context->setSema(&m_compiler->getSema());
}
+ ClangExpressionDeclMap *decl_map = type_system_helper->DeclMap();
+ if (decl_map) {
+ decl_map->InstallCodeGenerator(&m_compiler->getASTConsumer());
+
+ clang::ExternalASTSource *ast_source = decl_map->CreateProxy();
+
+ if (ast_context.getExternalSource()) {
+ auto module_wrapper =
+ new ExternalASTSourceWrapper(ast_context.getExternalSource());
+
+ auto ast_source_wrapper = new ExternalASTSourceWrapper(ast_source);
+
+ auto multiplexer =
+ new SemaSourceWithPriorities(*module_wrapper, *ast_source_wrapper);
+ IntrusiveRefCntPtr<ExternalASTSource> Source(multiplexer);
+ ast_context.setExternalSource(Source);
+ } else {
+ ast_context.setExternalSource(ast_source);
+ }
+ decl_map->InstallASTContext(ast_context, m_compiler->getFileManager());
+ }
+
+ // Check that the ASTReader is properly attached to ASTContext and Sema.
+ if (ast_context.getLangOpts().Modules) {
+ assert(m_compiler->getASTContext().getExternalSource() &&
+ "ASTContext doesn't know about the ASTReader?");
+ assert(m_compiler->getSema().getExternalSource() &&
+ "Sema doesn't know about the ASTReader?");
+ }
+
+ {
+ llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(
+ &m_compiler->getSema());
+ ParseAST(m_compiler->getSema(), false, false);
+ }
+
+ // Make sure we have no pointer to the Sema we are about to destroy.
+ if (ast_context.getLangOpts().Modules)
+ m_ast_context->setSema(nullptr);
+ // Destroy the Sema. This is necessary because we want to emulate the
+ // original behavior of ParseAST (which also destroys the Sema after parsing).
+ m_compiler->setSema(nullptr);
+
diag_buf->EndSourceFile();
unsigned num_errors = diag_buf->getNumErrors();
@@ -1050,10 +1160,10 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
lldb_private::Status err;
- std::unique_ptr<llvm::Module> llvm_module_ap(
+ std::unique_ptr<llvm::Module> llvm_module_up(
m_code_generator->ReleaseModule());
- if (!llvm_module_ap.get()) {
+ if (!llvm_module_up) {
err.SetErrorToGenericError();
err.SetErrorString("IR doesn't contain a module");
return err;
@@ -1064,7 +1174,7 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
if (execution_policy != eExecutionPolicyTopLevel) {
// Find the actual name of the function (it's often mangled somehow)
- if (!FindFunctionInModule(function_name, llvm_module_ap.get(),
+ if (!FindFunctionInModule(function_name, llvm_module_up.get(),
m_expr.FunctionName())) {
err.SetErrorToGenericError();
err.SetErrorStringWithFormat("Couldn't find %s() in the module",
@@ -1105,14 +1215,14 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
"expression module '%s'",
__FUNCTION__, m_expr.FunctionName());
- custom_passes.EarlyPasses->run(*llvm_module_ap);
+ custom_passes.EarlyPasses->run(*llvm_module_up);
}
- execution_unit_sp.reset(
- new IRExecutionUnit(m_llvm_context, // handed off here
- llvm_module_ap, // handed off here
- function_name, exe_ctx.GetTargetSP(), sc,
- m_compiler->getTargetOpts().Features));
+ execution_unit_sp = std::make_shared<IRExecutionUnit>(
+ m_llvm_context, // handed off here
+ llvm_module_up, // handed off here
+ function_name, exe_ctx.GetTargetSP(), sc,
+ m_compiler->getTargetOpts().Features);
ClangExpressionHelper *type_system_helper =
dyn_cast<ClangExpressionHelper>(m_expr.GetTypeSystemHelper());
@@ -1120,7 +1230,7 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
type_system_helper->DeclMap(); // result can be NULL
if (decl_map) {
- Stream *error_stream = NULL;
+ Stream *error_stream = nullptr;
Target *target = exe_ctx.GetTargetPtr();
error_stream = target->GetDebugger().GetErrorFile().get();
@@ -1172,8 +1282,8 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
(execution_policy != eExecutionPolicyTopLevel && !can_interpret)) {
if (m_expr.NeedsValidation() && process) {
if (!process->GetDynamicCheckers()) {
- DynamicCheckerFunctions *dynamic_checkers =
- new DynamicCheckerFunctions();
+ ClangDynamicCheckerFunctions *dynamic_checkers =
+ new ClangDynamicCheckerFunctions();
DiagnosticManager install_diagnostics;
@@ -1189,27 +1299,30 @@ lldb_private::Status ClangExpressionParser::PrepareForExecution(
process->SetDynamicCheckers(dynamic_checkers);
if (log)
- log->Printf("== [ClangUserExpression::Evaluate] Finished "
- "installing dynamic checkers ==");
+ log->Printf("== [ClangExpressionParser::PrepareForExecution] "
+ "Finished installing dynamic checkers ==");
}
- IRDynamicChecks ir_dynamic_checks(*process->GetDynamicCheckers(),
- function_name.AsCString());
+ if (auto *checker_funcs = llvm::dyn_cast<ClangDynamicCheckerFunctions>(
+ process->GetDynamicCheckers())) {
+ IRDynamicChecks ir_dynamic_checks(*checker_funcs,
+ function_name.AsCString());
- llvm::Module *module = execution_unit_sp->GetModule();
- if (!module || !ir_dynamic_checks.runOnModule(*module)) {
- err.SetErrorToGenericError();
- err.SetErrorString("Couldn't add dynamic checks to the expression");
- return err;
- }
+ llvm::Module *module = execution_unit_sp->GetModule();
+ if (!module || !ir_dynamic_checks.runOnModule(*module)) {
+ err.SetErrorToGenericError();
+ err.SetErrorString("Couldn't add dynamic checks to the expression");
+ return err;
+ }
- if (custom_passes.LatePasses) {
- if (log)
- log->Printf("%s - Running Late IR Passes from LanguageRuntime on "
- "expression module '%s'",
- __FUNCTION__, m_expr.FunctionName());
+ if (custom_passes.LatePasses) {
+ if (log)
+ log->Printf("%s - Running Late IR Passes from LanguageRuntime on "
+ "expression module '%s'",
+ __FUNCTION__, m_expr.FunctionName());
- custom_passes.LatePasses->run(*module);
+ custom_passes.LatePasses->run(*module);
+ }
}
}
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
index 03ff55f614d5c..a42c2190ffb8b 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
@@ -1,9 +1,8 @@
//===-- ClangExpressionParser.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,8 +27,7 @@ namespace lldb_private {
class IRExecutionUnit;
-//----------------------------------------------------------------------
-/// @class ClangExpressionParser ClangExpressionParser.h
+/// \class ClangExpressionParser ClangExpressionParser.h
/// "lldb/Expression/ClangExpressionParser.h" Encapsulates an instance of
/// Clang that can parse expressions.
///
@@ -38,140 +36,130 @@ class IRExecutionUnit;
/// as a glorified parameter list, performing the required parsing and
/// conversion to formats (DWARF bytecode, or JIT compiled machine code) that
/// can be executed.
-//----------------------------------------------------------------------
class ClangExpressionParser : public ExpressionParser {
public:
- //------------------------------------------------------------------
/// Constructor
///
/// Initializes class variables.
///
- /// @param[in] exe_scope,
+ /// \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
+ /// \param[in] expr
/// The expression to be parsed.
- //------------------------------------------------------------------
+ ///
+ /// @param[in] include_directories
+ /// List of include directories that should be used when parsing the
+ /// expression.
ClangExpressionParser(ExecutionContextScope *exe_scope, Expression &expr,
- bool generate_debug_info);
+ bool generate_debug_info,
+ std::vector<ConstString> include_directories = {});
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
~ClangExpressionParser() override;
bool Complete(CompletionRequest &request, unsigned line, unsigned pos,
unsigned typed_pos) override;
- //------------------------------------------------------------------
/// Parse a single expression and convert it to IR using Clang. Don't wrap
/// the expression in anything at all.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report errors to.
///
- /// @return
+ /// \return
/// The number of errors encountered during parsing. 0 means
/// success.
- //------------------------------------------------------------------
unsigned Parse(DiagnosticManager &diagnostic_manager) override;
bool RewriteExpression(DiagnosticManager &diagnostic_manager) override;
- //------------------------------------------------------------------
/// Ready an already-parsed expression for execution, possibly evaluating it
/// statically.
///
- /// @param[out] func_addr
+ /// \param[out] func_addr
/// The address to which the function has been written.
///
- /// @param[out] func_end
+ /// \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
+ /// \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
+ /// \param[in] exe_ctx
/// The execution context to write the function into.
///
- /// @param[out] evaluated_statically
+ /// \param[out] evaluated_statically
/// Set to true if the expression could be interpreted statically;
/// untouched otherwise.
///
- /// @param[out] const_result
+ /// \param[out] const_result
/// If the result of the expression is constant, and the
/// expression has no side effects, this is set to the result of the
/// expression.
///
- /// @param[in] execution_policy
+ /// \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
+ /// \return
/// An error code indicating the success or failure of the operation.
/// Test with Success().
- //------------------------------------------------------------------
Status
PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end,
lldb::IRExecutionUnitSP &execution_unit_sp,
ExecutionContext &exe_ctx, bool &can_interpret,
lldb_private::ExecutionPolicy execution_policy) override;
- //------------------------------------------------------------------
/// Run all static initializers for an execution unit.
///
- /// @param[in] execution_unit_sp
+ /// \param[in] execution_unit_sp
/// The execution unit.
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to use when running them. Thread can't be null.
///
- /// @return
+ /// \return
/// The error code indicating the
- //------------------------------------------------------------------
Status RunStaticInitializers(lldb::IRExecutionUnitSP &execution_unit_sp,
ExecutionContext &exe_ctx);
- //------------------------------------------------------------------
/// Returns a string representing current ABI.
///
- /// @param[in] target_arch
+ /// \param[in] target_arch
/// The target architecture.
///
- /// @return
+ /// \return
/// A string representing target ABI for the current architecture.
- //-------------------------------------------------------------------
std::string GetClangTargetABI(const ArchSpec &target_arch);
private:
- //------------------------------------------------------------------
/// Parses the expression.
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// The diagnostic manager that should receive the diagnostics
/// from the parsing process.
///
- /// @param[in] completion
+ /// \param[in] completion
/// The completion consumer that should be used during parsing
/// (or a nullptr if no consumer should be attached).
///
- /// @param[in] completion_line
+ /// \param[in] completion_line
/// The line in which the completion marker should be placed.
/// The first line is represented by the value 0.
///
- /// @param[in] completion_column
+ /// \param[in] completion_column
/// The column in which the completion marker should be placed.
/// The first column is represented by the value 0.
///
- /// @return
+ /// \return
/// The number of parsing errors.
- //-------------------------------------------------------------------
unsigned ParseInternal(DiagnosticManager &diagnostic_manager,
clang::CodeCompleteConsumer *completion = nullptr,
unsigned completion_line = 0,
@@ -179,8 +167,6 @@ private:
std::unique_ptr<llvm::LLVMContext>
m_llvm_context; ///< The LLVM context to generate IR into
- std::unique_ptr<clang::FileManager>
- m_file_manager; ///< The Clang file manager object used by the compiler
std::unique_ptr<clang::CompilerInstance>
m_compiler; ///< The Clang compiler used to parse expressions into IR
std::unique_ptr<clang::CodeGenerator>
@@ -190,6 +176,8 @@ private:
LLDBPreprocessorCallbacks *m_pp_callbacks; ///< Called when the preprocessor
///encounters module imports
std::unique_ptr<ClangASTContext> m_ast_context;
+
+ std::vector<ConstString> m_include_directories;
};
}
diff --git a/source/Expression/ExpressionSourceCode.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
index 03b2d26a256d3..f513b1eea360a 100644
--- a/source/Expression/ExpressionSourceCode.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
@@ -1,13 +1,17 @@
-//===-- ExpressionSourceCode.cpp --------------------------------*- C++ -*-===//
+//===-- ClangExpressionSourceCode.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "lldb/Expression/ExpressionSourceCode.h"
+#include "ClangExpressionSourceCode.h"
+
+#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/StringRef.h"
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
@@ -25,7 +29,7 @@
using namespace lldb_private;
-const char *ExpressionSourceCode::g_expression_prefix = R"(
+const char *ClangExpressionSourceCode::g_expression_prefix = R"(
#ifndef NULL
#define NULL (__null)
#endif
@@ -162,24 +166,121 @@ static void AddMacros(const DebugMacros *dm, CompileUnit *comp_unit,
}
}
+namespace {
+/// Allows checking if a token is contained in a given expression.
+class TokenVerifier {
+ /// The tokens we found in the expression.
+ llvm::StringSet<> m_tokens;
+
+public:
+ TokenVerifier(std::string body);
+ /// Returns true iff the given expression body contained a token with the
+ /// given content.
+ bool hasToken(llvm::StringRef token) const {
+ return m_tokens.find(token) != m_tokens.end();
+ }
+};
+} // namespace
+
+TokenVerifier::TokenVerifier(std::string body) {
+ using namespace clang;
+
+ // We only care about tokens and not their original source locations. If we
+ // move the whole expression to only be in one line we can simplify the
+ // following code that extracts the token contents.
+ std::replace(body.begin(), body.end(), '\n', ' ');
+ std::replace(body.begin(), body.end(), '\r', ' ');
+
+ FileSystemOptions file_opts;
+ FileManager file_mgr(file_opts,
+ FileSystem::Instance().GetVirtualFileSystem());
+
+ // Let's build the actual source code Clang needs and setup some utility
+ // objects.
+ llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_ids(new DiagnosticIDs());
+ llvm::IntrusiveRefCntPtr<DiagnosticOptions> diags_opts(
+ new DiagnosticOptions());
+ DiagnosticsEngine diags(diag_ids, diags_opts);
+ clang::SourceManager SM(diags, file_mgr);
+ auto buf = llvm::MemoryBuffer::getMemBuffer(body);
+
+ FileID FID = SM.createFileID(clang::SourceManager::Unowned, buf.get());
+
+ // Let's just enable the latest ObjC and C++ which should get most tokens
+ // right.
+ LangOptions Opts;
+ Opts.ObjC = true;
+ Opts.DollarIdents = true;
+ Opts.CPlusPlus17 = true;
+ Opts.LineComment = true;
+
+ Lexer lex(FID, buf.get(), SM, Opts);
+
+ Token token;
+ bool exit = false;
+ while (!exit) {
+ // Returns true if this is the last token we get from the lexer.
+ exit = lex.LexFromRawLexer(token);
+
+ // Extract the column number which we need to extract the token content.
+ // Our expression is just one line, so we don't need to handle any line
+ // numbers here.
+ bool invalid = false;
+ unsigned start = SM.getSpellingColumnNumber(token.getLocation(), &invalid);
+ if (invalid)
+ continue;
+ // Column numbers start at 1, but indexes in our string start at 0.
+ --start;
+
+ // Annotations don't have a length, so let's skip them.
+ if (token.isAnnotation())
+ continue;
+
+ // Extract the token string from our source code and store it.
+ std::string token_str = body.substr(start, token.getLength());
+ if (token_str.empty())
+ continue;
+ m_tokens.insert(token_str);
+ }
+}
+
static void AddLocalVariableDecls(const lldb::VariableListSP &var_list_sp,
- StreamString &stream) {
+ StreamString &stream,
+ const std::string &expr,
+ lldb::LanguageType wrapping_language) {
+ TokenVerifier tokens(expr);
+
for (size_t i = 0; i < var_list_sp->GetSize(); i++) {
lldb::VariableSP var_sp = var_list_sp->GetVariableAtIndex(i);
ConstString var_name = var_sp->GetName();
- if (!var_name || var_name == ConstString("this") ||
- var_name == ConstString(".block_descriptor"))
+
+
+ // We can check for .block_descriptor w/o checking for langauge since this
+ // is not a valid identifier in either C or C++.
+ if (!var_name || var_name == ".block_descriptor")
+ continue;
+
+ if (!expr.empty() && !tokens.hasToken(var_name.GetStringRef()))
+ continue;
+
+ if ((var_name == "self" || var_name == "_cmd") &&
+ (wrapping_language == lldb::eLanguageTypeObjC ||
+ wrapping_language == lldb::eLanguageTypeObjC_plus_plus))
+ continue;
+
+ if (var_name == "this" &&
+ wrapping_language == lldb::eLanguageTypeC_plus_plus)
continue;
stream.Printf("using $__lldb_local_vars::%s;\n", var_name.AsCString());
}
}
-bool ExpressionSourceCode::GetText(std::string &text,
- lldb::LanguageType wrapping_language,
- bool static_method,
- ExecutionContext &exe_ctx) const {
+bool ClangExpressionSourceCode::GetText(
+ std::string &text, lldb::LanguageType wrapping_language, bool static_method,
+ ExecutionContext &exe_ctx, bool add_locals, bool force_add_all_locals,
+ llvm::ArrayRef<std::string> modules) const {
const char *target_specific_defines = "typedef signed char BOOL;\n";
std::string module_macros;
@@ -252,14 +353,14 @@ bool ExpressionSourceCode::GetText(std::string &text,
}
}
- ConstString object_name;
- if (Language::LanguageIsCPlusPlus(frame->GetLanguage())) {
+ if (add_locals)
if (target->GetInjectLocalVariables(&exe_ctx)) {
lldb::VariableListSP var_list_sp =
frame->GetInScopeVariableList(false, true);
- AddLocalVariableDecls(var_list_sp, lldb_local_var_decls);
+ AddLocalVariableDecls(var_list_sp, lldb_local_var_decls,
+ force_add_all_locals ? "" : m_body,
+ wrapping_language);
}
- }
}
if (m_wrap) {
@@ -272,6 +373,15 @@ bool ExpressionSourceCode::GetText(std::string &text,
break;
}
+ // Generate a list of @import statements that will import the specified
+ // module into our expression.
+ std::string module_imports;
+ for (const std::string &module : modules) {
+ module_imports.append("@import ");
+ module_imports.append(module);
+ module_imports.append(";\n");
+ }
+
StreamString wrap_stream;
wrap_stream.Printf("%s\n%s\n%s\n%s\n%s\n", module_macros.c_str(),
@@ -297,50 +407,58 @@ bool ExpressionSourceCode::GetText(std::string &text,
default:
break;
case lldb::eLanguageTypeC:
- wrap_stream.Printf("void \n"
+ wrap_stream.Printf("%s"
+ "void \n"
"%s(void *$__lldb_arg) \n"
"{ \n"
" %s; \n"
"%s"
"} \n",
- m_name.c_str(), lldb_local_var_decls.GetData(),
- tagged_body.c_str());
+ module_imports.c_str(), m_name.c_str(),
+ lldb_local_var_decls.GetData(), tagged_body.c_str());
break;
case lldb::eLanguageTypeC_plus_plus:
- wrap_stream.Printf("void \n"
+ wrap_stream.Printf("%s"
+ "void \n"
"$__lldb_class::%s(void *$__lldb_arg) \n"
"{ \n"
" %s; \n"
"%s"
"} \n",
- m_name.c_str(), lldb_local_var_decls.GetData(),
- tagged_body.c_str());
+ module_imports.c_str(), m_name.c_str(),
+ lldb_local_var_decls.GetData(), tagged_body.c_str());
break;
case lldb::eLanguageTypeObjC:
if (static_method) {
wrap_stream.Printf(
+ "%s"
"@interface $__lldb_objc_class ($__lldb_category) \n"
"+(void)%s:(void *)$__lldb_arg; \n"
"@end \n"
"@implementation $__lldb_objc_class ($__lldb_category) \n"
"+(void)%s:(void *)$__lldb_arg \n"
"{ \n"
+ " %s; \n"
"%s"
"} \n"
"@end \n",
- m_name.c_str(), m_name.c_str(), tagged_body.c_str());
+ module_imports.c_str(), m_name.c_str(), m_name.c_str(),
+ lldb_local_var_decls.GetData(), tagged_body.c_str());
} else {
wrap_stream.Printf(
+ "%s"
"@interface $__lldb_objc_class ($__lldb_category) \n"
"-(void)%s:(void *)$__lldb_arg; \n"
"@end \n"
"@implementation $__lldb_objc_class ($__lldb_category) \n"
"-(void)%s:(void *)$__lldb_arg \n"
"{ \n"
+ " %s; \n"
"%s"
"} \n"
"@end \n",
- m_name.c_str(), m_name.c_str(), tagged_body.c_str());
+ module_imports.c_str(), m_name.c_str(), m_name.c_str(),
+ lldb_local_var_decls.GetData(), tagged_body.c_str());
}
break;
}
@@ -353,7 +471,7 @@ bool ExpressionSourceCode::GetText(std::string &text,
return true;
}
-bool ExpressionSourceCode::GetOriginalBodyBounds(
+bool ClangExpressionSourceCode::GetOriginalBodyBounds(
std::string transformed_text, lldb::LanguageType wrapping_language,
size_t &start_loc, size_t &end_loc) {
const char *start_marker;
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
new file mode 100644
index 0000000000000..8942902958372
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.h
@@ -0,0 +1,71 @@
+//===-- ClangExpressionSourceCode.h -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ClangExpressionSourceCode_h
+#define liblldb_ClangExpressionSourceCode_h
+
+#include "lldb/Expression/Expression.h"
+#include "lldb/Expression/ExpressionSourceCode.h"
+#include "lldb/lldb-enumerations.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+
+#include <string>
+
+namespace lldb_private {
+
+class ExecutionContext;
+
+class ClangExpressionSourceCode : public ExpressionSourceCode {
+public:
+ static const char *g_expression_prefix;
+
+ static ClangExpressionSourceCode *CreateWrapped(const char *prefix,
+ const char *body) {
+ return new ClangExpressionSourceCode("$__lldb_expr", prefix, body, true);
+ }
+
+ uint32_t GetNumBodyLines();
+
+ /// Generates the source code that will evaluate the expression.
+ ///
+ /// \param text output parameter containing the source code string.
+ /// \param wrapping_language If the expression is supossed to be wrapped,
+ /// then this is the language that should be used for that.
+ /// \param static_method True iff the expression is valuated inside a static
+ /// Objective-C method.
+ /// \param exe_ctx The execution context in which the expression will be
+ /// evaluated.
+ /// \param add_locals True iff local variables should be injected into the
+ /// expression source code.
+ /// \param force_add_all_locals True iff all local variables should be
+ /// injected even if they are not used in the expression.
+ /// \param modules A list of (C++) modules that the expression should import.
+ ///
+ /// \return true iff the source code was successfully generated.
+ bool GetText(std::string &text, lldb::LanguageType wrapping_language,
+ bool static_method, ExecutionContext &exe_ctx, bool add_locals,
+ bool force_add_all_locals,
+ llvm::ArrayRef<std::string> modules) 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);
+
+protected:
+ ClangExpressionSourceCode(const char *name, const char *prefix, const char *body,
+ bool wrap) :
+ ExpressionSourceCode(name, prefix, body, wrap) {}
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
index 624cbf2a1a4fb..b5a2c80b53494 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.cpp
@@ -1,9 +1,8 @@
//===-- ClangExpressionVariable.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,7 +31,7 @@ ClangExpressionVariable::ClangExpressionVariable(
}
ClangExpressionVariable::ClangExpressionVariable(
- ExecutionContextScope *exe_scope, Value &value, const ConstString &name,
+ ExecutionContextScope *exe_scope, Value &value, ConstString name,
uint16_t flags)
: ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
m_jit_vars() {
@@ -49,7 +48,7 @@ ClangExpressionVariable::ClangExpressionVariable(
}
ClangExpressionVariable::ClangExpressionVariable(
- ExecutionContextScope *exe_scope, const ConstString &name,
+ ExecutionContextScope *exe_scope, ConstString name,
const TypeFromUser &user_type, lldb::ByteOrder byte_order,
uint32_t addr_byte_size)
: ExpressionVariable(LLVMCastKind::eKindClang), m_parser_vars(),
diff --git a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
index 6886f0940adb5..eb7f74f20a20d 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangExpressionVariable.h
@@ -1,9 +1,8 @@
//===-- ClangExpressionVariable.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,8 +34,7 @@ namespace lldb_private {
class ValueObjectConstResult;
-//----------------------------------------------------------------------
-/// @class ClangExpressionVariable ClangExpressionVariable.h
+/// \class ClangExpressionVariable ClangExpressionVariable.h
/// "lldb/Expression/ClangExpressionVariable.h" Encapsulates one variable for
/// the expression parser.
///
@@ -56,36 +54,31 @@ class ValueObjectConstResult;
///
/// This class supports all of these use cases using simple type polymorphism,
/// and provides necessary support methods. Its interface is RTTI-neutral.
-//----------------------------------------------------------------------
class ClangExpressionVariable : public ExpressionVariable {
public:
ClangExpressionVariable(ExecutionContextScope *exe_scope,
lldb::ByteOrder byte_order, uint32_t addr_byte_size);
ClangExpressionVariable(ExecutionContextScope *exe_scope, Value &value,
- const ConstString &name, uint16_t flags = EVNone);
+ ConstString name, uint16_t flags = EVNone);
ClangExpressionVariable(const lldb::ValueObjectSP &valobj_sp);
ClangExpressionVariable(ExecutionContextScope *exe_scope,
- const ConstString &name,
+ ConstString name,
const TypeFromUser &user_type,
lldb::ByteOrder byte_order, uint32_t addr_byte_size);
- //----------------------------------------------------------------------
/// Utility functions for dealing with ExpressionVariableLists in Clang-
/// specific ways
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
/// Finds a variable by NamedDecl in the list.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the requested variable.
///
- /// @return
+ /// \return
/// The variable requested, or NULL if that variable is not in the list.
- //----------------------------------------------------------------------
static ClangExpressionVariable *
FindVariableInList(ExpressionVariableList &list, const clang::NamedDecl *decl,
uint64_t parser_id) {
@@ -105,31 +98,27 @@ public:
return nullptr;
}
- //----------------------------------------------------------------------
/// If the variable contains its own data, make a Value point at it. If \a
/// exe_ctx in not NULL, the value will be resolved in with that execution
/// context.
///
- /// @param[in] value
+ /// \param[in] value
/// The value to point at the data.
///
- /// @param[in] exe_ctx
+ /// \param[in] exe_ctx
/// The execution context to use to resolve \a value.
///
- /// @return
+ /// \return
/// True on success; false otherwise (in particular, if this variable
/// does not contain its own data).
- //----------------------------------------------------------------------
bool PointValueAtData(Value &value, ExecutionContext *exe_ctx);
- //----------------------------------------------------------------------
/// The following values should not live beyond parsing
- //----------------------------------------------------------------------
class ParserVars {
public:
ParserVars()
- : m_parser_type(), m_named_decl(NULL), m_llvm_value(NULL),
- m_lldb_value(), m_lldb_var(), m_lldb_sym(NULL) {}
+ : m_parser_type(), m_named_decl(nullptr), m_llvm_value(nullptr),
+ m_lldb_value(), m_lldb_var(), m_lldb_sym(nullptr) {}
TypeFromParser
m_parser_type; ///< The type of the variable according to the parser
@@ -149,34 +138,26 @@ private:
ParserVarMap m_parser_vars;
public:
- //----------------------------------------------------------------------
/// Make this variable usable by the parser by allocating space for parser-
/// specific variables
- //----------------------------------------------------------------------
void EnableParserVars(uint64_t parser_id) {
m_parser_vars.insert(std::make_pair(parser_id, ParserVars()));
}
- //----------------------------------------------------------------------
/// Deallocate parser-specific variables
- //----------------------------------------------------------------------
void DisableParserVars(uint64_t parser_id) { m_parser_vars.erase(parser_id); }
- //----------------------------------------------------------------------
/// Access parser-specific variables
- //----------------------------------------------------------------------
ParserVars *GetParserVars(uint64_t parser_id) {
ParserVarMap::iterator i = m_parser_vars.find(parser_id);
if (i == m_parser_vars.end())
- return NULL;
+ return nullptr;
else
return &i->second;
}
- //----------------------------------------------------------------------
/// The following values are valid if the variable is used by JIT code
- //----------------------------------------------------------------------
struct JITVars {
JITVars() : m_alignment(0), m_size(0), m_offset(0) {}
@@ -192,40 +173,32 @@ private:
JITVarMap m_jit_vars;
public:
- //----------------------------------------------------------------------
/// Make this variable usable for materializing for the JIT by allocating
/// space for JIT-specific variables
- //----------------------------------------------------------------------
void EnableJITVars(uint64_t parser_id) {
m_jit_vars.insert(std::make_pair(parser_id, JITVars()));
}
- //----------------------------------------------------------------------
/// Deallocate JIT-specific variables
- //----------------------------------------------------------------------
void DisableJITVars(uint64_t parser_id) { m_jit_vars.erase(parser_id); }
JITVars *GetJITVars(uint64_t parser_id) {
JITVarMap::iterator i = m_jit_vars.find(parser_id);
if (i == m_jit_vars.end())
- return NULL;
+ return nullptr;
else
return &i->second;
}
TypeFromUser GetTypeFromUser();
- //------------------------------------------------------------------
// llvm casting support
- //------------------------------------------------------------------
static bool classof(const ExpressionVariable *ev) {
return ev->getKind() == ExpressionVariable::eKindClang;
}
- //----------------------------------------------------------------------
/// Members
- //----------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(ClangExpressionVariable);
};
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
index 8ec9ff2235f5e..eabc96aa8e51c 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.cpp
@@ -1,9 +1,8 @@
//===-- ClangFunctionCaller.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,9 +42,7 @@
using namespace lldb_private;
-//----------------------------------------------------------------------
// ClangFunctionCaller constructor
-//----------------------------------------------------------------------
ClangFunctionCaller::ClangFunctionCaller(ExecutionContextScope &exe_scope,
const CompilerType &return_type,
const Address &functionAddress,
@@ -59,9 +56,7 @@ ClangFunctionCaller::ClangFunctionCaller(ExecutionContextScope &exe_scope,
assert(m_jit_process_wp.lock());
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ClangFunctionCaller::~ClangFunctionCaller() {}
unsigned
diff --git a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
index 9d933bfa60958..24f6f2eb91b3b 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangFunctionCaller.h
@@ -1,9 +1,8 @@
//===-- ClangFunctionCaller.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,8 +24,7 @@ namespace lldb_private {
class ASTStructExtractor;
class ClangExpressionParser;
-//----------------------------------------------------------------------
-/// @class ClangFunctionCaller ClangFunctionCaller.h
+/// \class ClangFunctionCaller ClangFunctionCaller.h
/// "lldb/Expression/ClangFunctionCaller.h" Encapsulates a function that can
/// be called.
///
@@ -58,30 +56,30 @@ class ClangExpressionParser;
///
/// Any of the methods that take arg_addr_ptr can be passed NULL, and the
/// argument space will be managed for you.
-//----------------------------------------------------------------------
class ClangFunctionCaller : public FunctionCaller {
friend class ASTStructExtractor;
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindClangFunctionCaller;
+ }
+
class ClangFunctionCallerHelper : public ClangExpressionHelper {
public:
ClangFunctionCallerHelper(ClangFunctionCaller &owner) : m_owner(owner) {}
~ClangFunctionCallerHelper() override = default;
- //------------------------------------------------------------------
/// Return the object that the parser should use when resolving external
/// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
- ClangExpressionDeclMap *DeclMap() override { return NULL; }
+ ClangExpressionDeclMap *DeclMap() override { return nullptr; }
- //------------------------------------------------------------------
/// Return the object that the parser should allow to access ASTs. May be
/// NULL if the ASTs do not need to be transformed.
///
- /// @param[in] passthrough
+ /// \param[in] passthrough
/// The ASTConsumer that the returned transformer should send
/// the ASTs to after transformation.
- //------------------------------------------------------------------
clang::ASTConsumer *
ASTTransformer(clang::ASTConsumer *passthrough) override;
@@ -94,27 +92,25 @@ class ClangFunctionCaller : public FunctionCaller {
};
public:
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] exe_scope
+ /// \param[in] exe_scope
/// An execution context scope that gets us at least a target and
/// process.
///
- /// @param[in] ast_context
+ /// \param[in] ast_context
/// The AST context to evaluate argument types in.
///
- /// @param[in] return_qualtype
+ /// \param[in] return_qualtype
/// An opaque Clang QualType for the function result. Should be
/// defined in ast_context.
///
- /// @param[in] function_address
+ /// \param[in] function_address
/// The address of the function to call.
///
- /// @param[in] arg_value_list
+ /// \param[in] arg_value_list
/// The default values to use when calling this function. Can
/// be overridden using WriteFunctionArguments().
- //------------------------------------------------------------------
ClangFunctionCaller(ExecutionContextScope &exe_scope,
const CompilerType &return_type,
const Address &function_address,
@@ -122,20 +118,18 @@ public:
~ClangFunctionCaller() override;
- //------------------------------------------------------------------
/// Compile the wrapper function
///
- /// @param[in] thread_to_use_sp
+ /// \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
+ /// \param[in] diagnostic_manager
/// The diagnostic manager to report parser errors to.
///
- /// @return
+ /// \return
/// The number of errors.
- //------------------------------------------------------------------
unsigned CompileFunction(lldb::ThreadSP thread_to_use_sp,
DiagnosticManager &diagnostic_manager) override;
@@ -147,9 +141,7 @@ protected:
const char *GetWrapperStructName() { return m_wrapper_struct_name.c_str(); }
private:
- //------------------------------------------------------------------
// For ClangFunctionCaller only
- //------------------------------------------------------------------
// Note: the parser needs to be destructed before the execution unit, so
// declare the execution unit first.
diff --git a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
index 44a13353818a6..65c5473918314 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -1,9 +1,8 @@
//===-- ClangHost.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,11 +16,9 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Threading.h"
+#include "lldb/Host/Config.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
-#if !defined(_WIN32)
-#include "lldb/Host/posix/HostInfoPosix.h"
-#endif
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
@@ -29,18 +26,6 @@
using namespace lldb_private;
-#if defined(_WIN32)
-static bool ComputeClangDirectory(FileSpec &file_spec) { return false; }
-#else
-static bool DefaultComputeClangDirectory(FileSpec &file_spec) {
- return HostInfoPosix::ComputePathRelativeToLibrary(
- file_spec, (llvm::Twine("/lib") + CLANG_LIBDIR_SUFFIX + "/clang/" +
- CLANG_VERSION_STRING)
- .str());
-}
-
-#if defined(__APPLE__)
-
static bool VerifyClangPath(const llvm::Twine &clang_path) {
if (FileSystem::Instance().IsDirectory(clang_path))
return true;
@@ -52,8 +37,55 @@ static bool VerifyClangPath(const llvm::Twine &clang_path) {
return false;
}
-bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
+///
+/// This will compute the clang resource directory assuming that clang was
+/// installed with the same prefix as lldb.
+///
+/// If verify is true, the first candidate resource directory will be returned.
+/// This mode is only used for testing.
+///
+static bool DefaultComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
+ FileSpec &file_spec,
+ bool verify) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ std::string raw_path = lldb_shlib_spec.GetPath();
+ llvm::StringRef parent_dir = llvm::sys::path::parent_path(raw_path);
+
+ static const llvm::StringRef kResourceDirSuffixes[] = {
+ // LLVM.org's build of LLDB uses the clang resource directory placed
+ // in $install_dir/lib{,64}/clang/$clang_version.
+ "lib" CLANG_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING,
+ // swift-lldb uses the clang resource directory copied from swift, which
+ // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
+ // it there, so we use LLDB_LIBDIR_SUFFIX.
+ "lib" LLDB_LIBDIR_SUFFIX "/lldb/clang",
+ };
+
+ for (const auto &Suffix : kResourceDirSuffixes) {
+ llvm::SmallString<256> clang_dir(parent_dir);
+ llvm::SmallString<32> relative_path(Suffix);
+ llvm::sys::path::native(relative_path);
+ llvm::sys::path::append(clang_dir, relative_path);
+ if (!verify || VerifyClangPath(clang_dir)) {
+ if (log)
+ log->Printf("DefaultComputeClangResourceDir: Setting ClangResourceDir "
+ "to \"%s\", verify = %s",
+ clang_dir.str().str().c_str(), verify ? "true" : "false");
+ file_spec.GetDirectory().SetString(clang_dir);
+ FileSystem::Instance().Resolve(file_spec);
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool lldb_private::ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
FileSpec &file_spec, bool verify) {
+#if !defined(__APPLE__)
+ return DefaultComputeClangResourceDirectory(lldb_shlib_spec, file_spec,
+ verify);
+#else
std::string raw_path = lldb_shlib_spec.GetPath();
auto rev_it = llvm::sys::path::rbegin(raw_path);
@@ -66,8 +98,10 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
++rev_it;
}
+ // We found a non-framework build of LLDB
if (rev_it == r_end)
- return DefaultComputeClangDirectory(file_spec);
+ return DefaultComputeClangResourceDirectory(lldb_shlib_spec, file_spec,
+ verify);
// Inside Xcode and in Xcode toolchains LLDB is always in lockstep
// with the Swift compiler, so it can reuse its Clang resource
@@ -84,7 +118,7 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
"Developer/Toolchains/XcodeDefault.xctoolchain",
swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native);
+ file_spec.GetDirectory().SetString(clang_path.c_str());
FileSystem::Instance().Resolve(file_spec);
return true;
}
@@ -99,7 +133,7 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
raw_path.resize(parent - r_end);
llvm::sys::path::append(clang_path, raw_path, swift_clang_resource_dir);
if (!verify || VerifyClangPath(clang_path)) {
- file_spec.SetFile(clang_path.c_str(), FileSpec::Style::native);
+ file_spec.GetDirectory().SetString(clang_path.c_str());
FileSystem::Instance().Resolve(file_spec);
return true;
}
@@ -112,30 +146,19 @@ bool lldb_private::ComputeClangDirectory(FileSpec &lldb_shlib_spec,
// Fall back to the Clang resource directory inside the framework.
raw_path.append("LLDB.framework/Resources/Clang");
- file_spec.SetFile(raw_path.c_str(), FileSpec::Style::native);
+ file_spec.GetDirectory().SetString(raw_path.c_str());
FileSystem::Instance().Resolve(file_spec);
return true;
-}
-
-static bool ComputeClangDirectory(FileSpec &file_spec) {
- if (FileSpec lldb_file_spec = HostInfo::GetShlibDir())
- return ComputeClangDirectory(lldb_file_spec, file_spec, true);
- return false;
-}
-#else // __APPLE__
-
-// All non-Apple posix systems.
-static bool ComputeClangDirectory(FileSpec &file_spec) {
- return DefaultComputeClangDirectory(file_spec);
-}
#endif // __APPLE__
-#endif // _WIN32
+}
FileSpec lldb_private::GetClangResourceDir() {
static FileSpec g_cached_resource_dir;
static llvm::once_flag g_once_flag;
llvm::call_once(g_once_flag, []() {
- ::ComputeClangDirectory(g_cached_resource_dir);
+ if (FileSpec lldb_file_spec = HostInfo::GetShlibDir())
+ ComputeClangResourceDirectory(lldb_file_spec, g_cached_resource_dir,
+ true);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
if (log)
log->Printf("GetClangResourceDir() => '%s'",
diff --git a/source/Plugins/ExpressionParser/Clang/ClangHost.h b/source/Plugins/ExpressionParser/Clang/ClangHost.h
index 4fe423adb1a54..9d49188178cdb 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangHost.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangHost.h
@@ -1,9 +1,8 @@
//===-- ClangHost.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,10 +13,8 @@ namespace lldb_private {
class FileSpec;
-#if defined(__APPLE__)
-bool ComputeClangDirectory(FileSpec &lldb_shlib_spec, FileSpec &file_spec,
- bool verify);
-#endif
+bool ComputeClangResourceDirectory(FileSpec &lldb_shlib_spec,
+ FileSpec &file_spec, bool verify);
FileSpec GetClangResourceDir();
diff --git a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
index ced21dfe0dda2..4a220790e50dc 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
@@ -1,9 +1,8 @@
//===-- ClangModulesDeclVendor.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,15 +22,18 @@
#include "ClangHost.h"
#include "ClangModulesDeclVendor.h"
+#include "ModuleDependencyCollector.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/SourceModule.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/Reproducer.h"
#include "lldb/Utility/StreamString.h"
using namespace lldb_private;
@@ -70,13 +72,13 @@ public:
~ClangModulesDeclVendorImpl() override = default;
- bool AddModule(ModulePath &path, ModuleVector *exported_modules,
+ bool AddModule(const SourceModule &module, ModuleVector *exported_modules,
Stream &error_stream) override;
bool AddModulesForCompileUnit(CompileUnit &cu, ModuleVector &exported_modules,
Stream &error_stream) override;
- uint32_t FindDecls(const ConstString &name, bool append, uint32_t max_matches,
+ uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
std::vector<clang::NamedDecl *> &decls) override;
void ForEachMacro(const ModuleVector &modules,
@@ -183,7 +185,7 @@ void ClangModulesDeclVendorImpl::ReportModuleExports(
}
}
-bool ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
+bool ClangModulesDeclVendorImpl::AddModule(const SourceModule &module,
ModuleVector *exported_modules,
Stream &error_stream) {
// Fail early.
@@ -198,7 +200,7 @@ bool ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
std::vector<ConstString> imported_module;
- for (ConstString path_component : path) {
+ for (ConstString path_component : module.path) {
imported_module.push_back(path_component);
}
@@ -213,11 +215,42 @@ bool ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
}
}
- if (!m_compiler_instance->getPreprocessor()
- .getHeaderSearchInfo()
- .lookupModule(path[0].GetStringRef())) {
+ clang::HeaderSearch &HS =
+ m_compiler_instance->getPreprocessor().getHeaderSearchInfo();
+
+ if (module.search_path) {
+ auto path_begin = llvm::sys::path::begin(module.search_path.GetStringRef());
+ auto path_end = llvm::sys::path::end(module.search_path.GetStringRef());
+ auto sysroot_begin = llvm::sys::path::begin(module.sysroot.GetStringRef());
+ auto sysroot_end = llvm::sys::path::end(module.sysroot.GetStringRef());
+ // FIXME: Use C++14 std::equal(it, it, it, it) variant once it's available.
+ bool is_system_module = (std::distance(path_begin, path_end) >=
+ std::distance(sysroot_begin, sysroot_end)) &&
+ std::equal(sysroot_begin, sysroot_end, path_begin);
+ // No need to inject search paths to modules in the sysroot.
+ if (!is_system_module) {
+ auto error = [&]() {
+ error_stream.Printf("error: No module map file in %s\n",
+ module.search_path.AsCString());
+ return false;
+ };
+
+ bool is_system = true;
+ bool is_framework = false;
+ auto *dir =
+ HS.getFileMgr().getDirectory(module.search_path.GetStringRef());
+ if (!dir)
+ return error();
+ auto *file = HS.lookupModuleMapFile(dir, is_framework);
+ if (!file)
+ return error();
+ if (!HS.loadModuleMapFile(file, is_system))
+ return error();
+ }
+ }
+ if (!HS.lookupModule(module.path.front().GetStringRef())) {
error_stream.Printf("error: Header search couldn't locate module %s\n",
- path[0].AsCString());
+ module.path.front().AsCString());
return false;
}
@@ -229,7 +262,7 @@ bool ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
clang::SourceManager &source_manager =
m_compiler_instance->getASTContext().getSourceManager();
- for (ConstString path_component : path) {
+ for (ConstString path_component : module.path) {
clang_path.push_back(std::make_pair(
&m_compiler_instance->getASTContext().Idents.get(
path_component.GetStringRef()),
@@ -249,19 +282,18 @@ bool ClangModulesDeclVendorImpl::AddModule(ModulePath &path,
if (!top_level_module) {
diagnostic_consumer->DumpDiagnostics(error_stream);
error_stream.Printf("error: Couldn't load top-level module %s\n",
- path[0].AsCString());
+ module.path.front().AsCString());
return false;
}
clang::Module *submodule = top_level_module;
- for (size_t ci = 1; ci < path.size(); ++ci) {
- llvm::StringRef component = path[ci].GetStringRef();
- submodule = submodule->findSubmodule(component.str());
+ for (auto &component : llvm::ArrayRef<ConstString>(module.path).drop_front()) {
+ submodule = submodule->findSubmodule(component.GetStringRef());
if (!submodule) {
diagnostic_consumer->DumpDiagnostics(error_stream);
error_stream.Printf("error: Couldn't load submodule %s\n",
- component.str().c_str());
+ component.GetCString());
return false;
}
}
@@ -288,12 +320,16 @@ bool ClangModulesDeclVendor::LanguageSupportsClangModules(
switch (language) {
default:
return false;
- // C++ and friends to be added
case lldb::LanguageType::eLanguageTypeC:
case lldb::LanguageType::eLanguageTypeC11:
case lldb::LanguageType::eLanguageTypeC89:
case lldb::LanguageType::eLanguageTypeC99:
+ case lldb::LanguageType::eLanguageTypeC_plus_plus:
+ case lldb::LanguageType::eLanguageTypeC_plus_plus_03:
+ case lldb::LanguageType::eLanguageTypeC_plus_plus_11:
+ case lldb::LanguageType::eLanguageTypeC_plus_plus_14:
case lldb::LanguageType::eLanguageTypeObjC:
+ case lldb::LanguageType::eLanguageTypeObjC_plus_plus:
return true;
}
}
@@ -302,28 +338,17 @@ bool ClangModulesDeclVendorImpl::AddModulesForCompileUnit(
CompileUnit &cu, ClangModulesDeclVendor::ModuleVector &exported_modules,
Stream &error_stream) {
if (LanguageSupportsClangModules(cu.GetLanguage())) {
- std::vector<ConstString> imported_modules = cu.GetImportedModules();
-
- for (ConstString imported_module : imported_modules) {
- std::vector<ConstString> path;
-
- path.push_back(imported_module);
-
- if (!AddModule(path, &exported_modules, error_stream)) {
+ for (auto &imported_module : cu.GetImportedModules())
+ if (!AddModule(imported_module, &exported_modules, error_stream))
return false;
- }
- }
-
- return true;
}
-
return true;
}
// ClangImporter::lookupValue
uint32_t
-ClangModulesDeclVendorImpl::FindDecls(const ConstString &name, bool append,
+ClangModulesDeclVendorImpl::FindDecls(ConstString name, bool append,
uint32_t max_matches,
std::vector<clang::NamedDecl *> &decls) {
if (!m_enabled) {
@@ -583,7 +608,7 @@ ClangModulesDeclVendor::Create(Target &target) {
compiler_invocation_arguments.push_back(module_cache_argument);
}
- FileSpecList &module_search_paths = target.GetClangModuleSearchPaths();
+ FileSpecList module_search_paths = target.GetClangModuleSearchPaths();
for (size_t spi = 0, spe = module_search_paths.GetSize(); spi < spe; ++spi) {
const FileSpec &search_path = module_search_paths.GetFileSpecAtIndex(spi);
@@ -610,9 +635,13 @@ ClangModulesDeclVendor::Create(Target &target) {
std::vector<const char *> compiler_invocation_argument_cstrs;
compiler_invocation_argument_cstrs.reserve(
compiler_invocation_arguments.size());
- for (const std::string &arg : compiler_invocation_arguments) {
+ for (const std::string &arg : compiler_invocation_arguments)
compiler_invocation_argument_cstrs.push_back(arg.c_str());
- }
+
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ LLDB_LOG(log, "ClangModulesDeclVendor's compiler flags {0:$[ ]}",
+ llvm::make_range(compiler_invocation_arguments.begin(),
+ compiler_invocation_arguments.end()));
std::shared_ptr<clang::CompilerInvocation> invocation =
clang::createInvocationFromCommandLine(compiler_invocation_argument_cstrs,
@@ -632,6 +661,20 @@ ClangModulesDeclVendor::Create(Target &target) {
std::unique_ptr<clang::CompilerInstance> instance(
new clang::CompilerInstance);
+ // When capturing a reproducer, hook up the file collector with clang to
+ // collector modules and headers.
+ if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) {
+ repro::FileProvider &fp = g->GetOrCreate<repro::FileProvider>();
+ instance->setModuleDepCollector(
+ std::make_shared<ModuleDependencyCollectorAdaptor>(
+ fp.GetFileCollector()));
+ clang::DependencyOutputOptions &opts = instance->getDependencyOutputOpts();
+ opts.IncludeSystemHeaders = true;
+ opts.IncludeModuleFiles = true;
+ }
+
+ // Make sure clang uses the same VFS as LLDB.
+ instance->createFileManager(FileSystem::Instance().GetVirtualFileSystem());
instance->setDiagnostics(diagnostics_engine.get());
instance->setInvocation(invocation);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
index 23769ccfb0c04..d5c8757bdcd00 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h
@@ -1,9 +1,8 @@
//===-- ClangModulesDeclVendor.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#include "lldb/Core/ClangForward.h"
#include "lldb/Symbol/DeclVendor.h"
+#include "lldb/Symbol/SourceModule.h"
#include "lldb/Target/Platform.h"
#include <set>
@@ -21,9 +21,7 @@ namespace lldb_private {
class ClangModulesDeclVendor : public DeclVendor {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
ClangModulesDeclVendor();
~ClangModulesDeclVendor() override;
@@ -34,84 +32,77 @@ public:
typedef uintptr_t ModuleID;
typedef std::vector<ModuleID> ModuleVector;
- //------------------------------------------------------------------
/// Add a module to the list of modules to search.
///
- /// @param[in] path
+ /// \param[in] module
/// The path to the exact module to be loaded. E.g., if the desired
/// module is std.io, then this should be { "std", "io" }.
///
- /// @param[in] exported_modules
+ /// \param[in] exported_modules
/// If non-NULL, a pointer to a vector to populate with the ID of every
/// module that is re-exported by the specified module.
///
- /// @param[in] error_stream
+ /// \param[in] error_stream
/// A stream to populate with the output of the Clang parser when
/// it tries to load the module.
///
- /// @return
+ /// \return
/// True if the module could be loaded; false if not. If the
/// compiler encountered a fatal error during a previous module
/// load, then this will always return false for this ModuleImporter.
- //------------------------------------------------------------------
- virtual bool AddModule(ModulePath &path, ModuleVector *exported_modules,
+ virtual bool AddModule(const SourceModule &module,
+ ModuleVector *exported_modules,
Stream &error_stream) = 0;
- //------------------------------------------------------------------
/// Add all modules referred to in a given compilation unit to the list
/// of modules to search.
///
- /// @param[in] cu
+ /// \param[in] cu
/// The compilation unit to scan for imported modules.
///
- /// @param[in] exported_modules
+ /// \param[in] exported_modules
/// A vector to populate with the ID of each module loaded (directly
/// and via re-exports) in this way.
///
- /// @param[in] error_stream
+ /// \param[in] error_stream
/// A stream to populate with the output of the Clang parser when
/// it tries to load the modules.
///
- /// @return
+ /// \return
/// True if all modules referred to by the compilation unit could be
/// loaded; false if one could not be loaded. If the compiler
/// encountered a fatal error during a previous module
/// load, then this will always return false for this ModuleImporter.
- //------------------------------------------------------------------
virtual bool AddModulesForCompileUnit(CompileUnit &cu,
ModuleVector &exported_modules,
Stream &error_stream) = 0;
- //------------------------------------------------------------------
/// Enumerate all the macros that are defined by a given set of modules
/// that are already imported.
///
- /// @param[in] modules
+ /// \param[in] modules
/// The unique IDs for all modules to query. Later modules have higher
/// priority, just as if you @imported them in that order. This matters
/// if module A #defines a macro and module B #undefs it.
///
- /// @param[in] handler
+ /// \param[in] handler
/// A function to call with the text of each #define (including the
/// #define directive). #undef directives are not included; we simply
/// elide any corresponding #define. If this function returns true,
/// we stop the iteration immediately.
- //------------------------------------------------------------------
virtual void
ForEachMacro(const ModuleVector &modules,
std::function<bool(const std::string &)> handler) = 0;
- //------------------------------------------------------------------
/// Query whether Clang supports modules for a particular language.
/// LLDB uses this to decide whether to try to find the modules loaded
- /// by a gaiven compile unit.
+ /// by a given compile unit.
///
- /// @param[in] language
+ /// \param[in] language
/// The language to query for.
///
- /// @return
+ /// \return
/// True if Clang has modules for the given language.
- //------------------------------------------------------------------
static bool LanguageSupportsClangModules(lldb::LanguageType language);
};
diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
index bb73d55a9a414..742a14992dc9e 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
@@ -1,15 +1,15 @@
//===-- ClangPersistentVariables.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ClangPersistentVariables.h"
#include "lldb/Core/Value.h"
+#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
@@ -32,7 +32,7 @@ ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable(
}
ExpressionVariableSP ClangPersistentVariables::CreatePersistentVariable(
- ExecutionContextScope *exe_scope, const ConstString &name,
+ ExecutionContextScope *exe_scope, ConstString name,
const CompilerType &compiler_type, lldb::ByteOrder byte_order,
uint32_t addr_byte_size) {
return AddNewlyConstructedVariable(new ClangExpressionVariable(
@@ -49,11 +49,26 @@ void ClangPersistentVariables::RemovePersistentVariable(
return;
name++;
- if (strtoul(name, NULL, 0) == m_next_persistent_variable_id - 1)
+ if (strtoul(name, nullptr, 0) == m_next_persistent_variable_id - 1)
m_next_persistent_variable_id--;
}
-void ClangPersistentVariables::RegisterPersistentDecl(const ConstString &name,
+llvm::Optional<CompilerType>
+ClangPersistentVariables::GetCompilerTypeFromPersistentDecl(
+ ConstString type_name) {
+ CompilerType compiler_type;
+ if (clang::TypeDecl *tdecl = llvm::dyn_cast_or_null<clang::TypeDecl>(
+ GetPersistentDecl(type_name))) {
+ compiler_type.SetCompilerType(
+ ClangASTContext::GetASTContext(&tdecl->getASTContext()),
+ reinterpret_cast<lldb::opaque_compiler_type_t>(
+ const_cast<clang::Type *>(tdecl->getTypeForDecl())));
+ return compiler_type;
+ }
+ return llvm::None;
+}
+
+void ClangPersistentVariables::RegisterPersistentDecl(ConstString name,
clang::NamedDecl *decl) {
m_persistent_decls.insert(
std::pair<const char *, clang::NamedDecl *>(name.GetCString(), decl));
@@ -68,12 +83,12 @@ void ClangPersistentVariables::RegisterPersistentDecl(const ConstString &name,
}
clang::NamedDecl *
-ClangPersistentVariables::GetPersistentDecl(const ConstString &name) {
+ClangPersistentVariables::GetPersistentDecl(ConstString name) {
PersistentDeclMap::const_iterator i =
m_persistent_decls.find(name.GetCString());
if (i == m_persistent_decls.end())
- return NULL;
+ return nullptr;
else
return i->second;
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
index c4438c7e22039..b39f89ad7eef8 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
@@ -1,9 +1,8 @@
//===-- ClangPersistentVariables.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,24 +18,20 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ClangPersistentVariables ClangPersistentVariables.h
+/// \class ClangPersistentVariables ClangPersistentVariables.h
/// "lldb/Expression/ClangPersistentVariables.h" Manages persistent values
/// that need to be preserved between expression invocations.
///
/// A list of variables that can be accessed and updated by any expression. See
/// ClangPersistentVariable for more discussion. Also provides an increasing,
/// 0-based counter for naming result variables.
-//----------------------------------------------------------------------
class ClangPersistentVariables : public PersistentExpressionState {
public:
ClangPersistentVariables();
~ClangPersistentVariables() override = default;
- //------------------------------------------------------------------
// llvm casting support
- //------------------------------------------------------------------
static bool classof(const PersistentExpressionState *pv) {
return pv->getKind() == PersistentExpressionState::eKindClang;
}
@@ -45,7 +40,7 @@ public:
CreatePersistentVariable(const lldb::ValueObjectSP &valobj_sp) override;
lldb::ExpressionVariableSP CreatePersistentVariable(
- ExecutionContextScope *exe_scope, const ConstString &name,
+ ExecutionContextScope *exe_scope, ConstString name,
const CompilerType &compiler_type, lldb::ByteOrder byte_order,
uint32_t addr_byte_size) override;
@@ -55,9 +50,12 @@ public:
return "$";
}
- void RegisterPersistentDecl(const ConstString &name, clang::NamedDecl *decl);
+ llvm::Optional<CompilerType>
+ GetCompilerTypeFromPersistentDecl(ConstString type_name) override;
+
+ void RegisterPersistentDecl(ConstString name, clang::NamedDecl *decl);
- clang::NamedDecl *GetPersistentDecl(const ConstString &name);
+ clang::NamedDecl *GetPersistentDecl(ConstString name);
void AddHandLoadedClangModule(ClangModulesDeclVendor::ModuleID module) {
m_hand_loaded_clang_modules.push_back(module);
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index f42955df07aa3..2dae5b7022f30 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -1,9 +1,8 @@
//===-- ClangUserExpression.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,6 +21,7 @@
#include "ClangDiagnostic.h"
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionParser.h"
+#include "ClangExpressionSourceCode.h"
#include "ClangModulesDeclVendor.h"
#include "ClangPersistentVariables.h"
@@ -37,6 +37,7 @@
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
+#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
@@ -55,18 +56,20 @@
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
+#include "llvm/ADT/ScopeExit.h"
+
using namespace lldb_private;
ClangUserExpression::ClangUserExpression(
ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
- ResultType desired_type, const EvaluateExpressionOptions &options)
+ ResultType desired_type, const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj)
: LLVMUserExpression(exe_scope, expr, prefix, language, desired_type,
- options),
- m_type_system_helper(*m_target_wp.lock().get(),
- options.GetExecutionPolicy() ==
- eExecutionPolicyTopLevel),
- m_result_delegate(exe_scope.CalculateTarget()) {
+ options, eKindClangUserExpression),
+ m_type_system_helper(*m_target_wp.lock(), options.GetExecutionPolicy() ==
+ eExecutionPolicyTopLevel),
+ m_result_delegate(exe_scope.CalculateTarget()), m_ctx_obj(ctx_obj) {
switch (m_language) {
case lldb::eLanguageTypeC_plus_plus:
m_allow_cxx = true;
@@ -99,7 +102,7 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
}
StackFrame *frame = exe_ctx.GetFramePtr();
- if (frame == NULL) {
+ if (frame == nullptr) {
if (log)
log->Printf(" [CUE::SC] Null stack frame");
return;
@@ -131,7 +134,27 @@ void ClangUserExpression::ScanContext(ExecutionContext &exe_ctx, Status &err) {
return;
}
- if (clang::CXXMethodDecl *method_decl =
+ if (m_ctx_obj) {
+ switch (m_ctx_obj->GetObjectRuntimeLanguage()) {
+ case lldb::eLanguageTypeC:
+ case lldb::eLanguageTypeC89:
+ case lldb::eLanguageTypeC99:
+ case lldb::eLanguageTypeC11:
+ case lldb::eLanguageTypeC_plus_plus:
+ case lldb::eLanguageTypeC_plus_plus_03:
+ case lldb::eLanguageTypeC_plus_plus_11:
+ case lldb::eLanguageTypeC_plus_plus_14:
+ m_in_cplusplus_method = true;
+ break;
+ case lldb::eLanguageTypeObjC:
+ case lldb::eLanguageTypeObjC_plus_plus:
+ m_in_objectivec_method = true;
+ break;
+ default:
+ break;
+ }
+ m_needs_object_ptr = true;
+ } else if (clang::CXXMethodDecl *method_decl =
ClangASTContext::DeclContextGetAsCXXMethodDecl(decl_context)) {
if (m_allow_cxx && method_decl->isInstance()) {
if (m_enforce_valid_object) {
@@ -307,21 +330,6 @@ static void ApplyObjcCastHack(std::string &expr) {
#undef OBJC_CAST_HACK_FROM
}
-namespace {
-// Utility guard that calls a callback when going out of scope.
-class OnExit {
-public:
- typedef std::function<void(void)> Callback;
-
- OnExit(Callback const &callback) : m_callback(callback) {}
-
- ~OnExit() { m_callback(); }
-
-private:
- Callback m_callback;
-};
-} // namespace
-
bool ClangUserExpression::SetupPersistentState(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx) {
if (Target *target = exe_ctx.GetTargetPtr()) {
@@ -377,7 +385,8 @@ static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target) {
}
void ClangUserExpression::UpdateLanguageForExpr(
- DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) {
+ DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
+ std::vector<std::string> modules_to_import, bool for_completion) {
m_expr_lang = lldb::LanguageType::eLanguageTypeUnknown;
std::string prefix = m_expr_prefix;
@@ -385,8 +394,8 @@ void ClangUserExpression::UpdateLanguageForExpr(
if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) {
m_transformed_text = m_expr_text;
} else {
- std::unique_ptr<ExpressionSourceCode> source_code(
- ExpressionSourceCode::CreateWrapped(prefix.c_str(),
+ std::unique_ptr<ClangExpressionSourceCode> source_code(
+ ClangExpressionSourceCode::CreateWrapped(prefix.c_str(),
m_expr_text.c_str()));
if (m_in_cplusplus_method)
@@ -397,7 +406,8 @@ void ClangUserExpression::UpdateLanguageForExpr(
m_expr_lang = lldb::eLanguageTypeC;
if (!source_code->GetText(m_transformed_text, m_expr_lang,
- m_in_static_method, exe_ctx)) {
+ m_in_static_method, exe_ctx, !m_ctx_obj,
+ for_completion, modules_to_import)) {
diagnostic_manager.PutString(eDiagnosticSeverityError,
"couldn't construct expression body");
return;
@@ -409,14 +419,73 @@ void ClangUserExpression::UpdateLanguageForExpr(
std::size_t original_end;
bool found_bounds = source_code->GetOriginalBodyBounds(
m_transformed_text, m_expr_lang, original_start, original_end);
- if (found_bounds) {
+ if (found_bounds)
m_user_expression_start_pos = original_start;
+ }
+}
+
+static bool SupportsCxxModuleImport(lldb::LanguageType language) {
+ switch (language) {
+ case lldb::eLanguageTypeC_plus_plus:
+ case lldb::eLanguageTypeC_plus_plus_03:
+ case lldb::eLanguageTypeC_plus_plus_11:
+ case lldb::eLanguageTypeC_plus_plus_14:
+ case lldb::eLanguageTypeObjC_plus_plus:
+ return true;
+ default:
+ return false;
+ }
+}
+
+std::vector<std::string>
+ClangUserExpression::GetModulesToImport(ExecutionContext &exe_ctx) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
+ if (!SupportsCxxModuleImport(Language()))
+ return {};
+
+ Target *target = exe_ctx.GetTargetPtr();
+ if (!target || !target->GetEnableImportStdModule())
+ return {};
+
+ StackFrame *frame = exe_ctx.GetFramePtr();
+ if (!frame)
+ return {};
+
+ Block *block = frame->GetFrameBlock();
+ if (!block)
+ return {};
+
+ SymbolContext sc;
+ block->CalculateSymbolContext(&sc);
+ if (!sc.comp_unit)
+ return {};
+
+ if (log) {
+ for (const SourceModule &m : sc.comp_unit->GetImportedModules()) {
+ LLDB_LOG(log, "Found module in compile unit: {0:$[.]} - include dir: {1}",
+ llvm::make_range(m.path.begin(), m.path.end()), m.search_path);
}
}
+
+ for (const SourceModule &m : sc.comp_unit->GetImportedModules())
+ m_include_directories.push_back(m.search_path);
+
+ // Check if we imported 'std' or any of its submodules.
+ // We currently don't support importing any other modules in the expression
+ // parser.
+ for (const SourceModule &m : sc.comp_unit->GetImportedModules())
+ if (!m.path.empty() && m.path.front() == "std")
+ return {"std"};
+
+ return {};
}
bool ClangUserExpression::PrepareForParsing(
- DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) {
+ DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
+ bool for_completion) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+
InstallContext(exe_ctx);
if (!SetupPersistentState(diagnostic_manager, exe_ctx))
@@ -437,7 +506,14 @@ bool ClangUserExpression::PrepareForParsing(
SetupDeclVendor(exe_ctx, m_target);
- UpdateLanguageForExpr(diagnostic_manager, exe_ctx);
+ std::vector<std::string> used_modules = GetModulesToImport(exe_ctx);
+ m_imported_cpp_modules = !used_modules.empty();
+
+ LLDB_LOG(log, "List of imported modules in expression: {0}",
+ llvm::make_range(used_modules.begin(), used_modules.end()));
+
+ UpdateLanguageForExpr(diagnostic_manager, exe_ctx, used_modules,
+ for_completion);
return true;
}
@@ -448,7 +524,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
bool generate_debug_info) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
- if (!PrepareForParsing(diagnostic_manager, exe_ctx))
+ if (!PrepareForParsing(diagnostic_manager, exe_ctx, /*for_completion*/ false))
return false;
if (log)
@@ -469,13 +545,13 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
// Parse the expression
//
- m_materializer_ap.reset(new Materializer());
+ m_materializer_up.reset(new Materializer());
ResetDeclMap(exe_ctx, m_result_delegate, keep_result_in_memory);
- OnExit on_exit([this]() { ResetDeclMap(); });
+ auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
- if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
+ if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
diagnostic_manager.PutString(
eDiagnosticSeverityError,
"current process state is unsuitable for expression parsing");
@@ -496,7 +572,8 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
// succeeds or the rewrite parser we might make if it fails. But the
// parser_sp will never be empty.
- ClangExpressionParser parser(exe_scope, *this, generate_debug_info);
+ ClangExpressionParser parser(exe_scope, *this, generate_debug_info,
+ m_include_directories);
unsigned num_errors = parser.Parse(diagnostic_manager);
@@ -509,7 +586,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
size_t fixed_end;
const std::string &fixed_expression =
diagnostic_manager.GetFixedExpression();
- if (ExpressionSourceCode::GetOriginalBodyBounds(
+ if (ClangExpressionSourceCode::GetOriginalBodyBounds(
fixed_expression, m_expr_lang, fixed_start, fixed_end))
m_fixed_text =
fixed_expression.substr(fixed_start, fixed_end - fixed_start);
@@ -518,7 +595,7 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
return false;
}
- //////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////
// Prepare the output of the parser for execution, evaluating it statically
// if possible
//
@@ -597,25 +674,23 @@ bool ClangUserExpression::Parse(DiagnosticManager &diagnostic_manager,
return true;
}
-//------------------------------------------------------------------
/// Converts an absolute position inside a given code string into
/// a column/line pair.
///
-/// @param[in] abs_pos
+/// \param[in] abs_pos
/// A absolute position in the code string that we want to convert
/// to a column/line pair.
///
-/// @param[in] code
+/// \param[in] code
/// A multi-line string usually representing source code.
///
-/// @param[out] line
+/// \param[out] line
/// The line in the code that contains the given absolute position.
/// The first line in the string is indexed as 1.
///
-/// @param[out] column
+/// \param[out] column
/// The column in the line that contains the absolute position.
/// The first character in a line is indexed as 0.
-//------------------------------------------------------------------
static void AbsPosToLineColumnPos(size_t abs_pos, llvm::StringRef code,
unsigned &line, unsigned &column) {
// Reset to code position to beginning of the file.
@@ -648,7 +723,7 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
// correct.
DiagnosticManager diagnostic_manager;
- if (!PrepareForParsing(diagnostic_manager, exe_ctx))
+ if (!PrepareForParsing(diagnostic_manager, exe_ctx, /*for_completion*/ true))
return false;
if (log)
@@ -658,13 +733,13 @@ bool ClangUserExpression::Complete(ExecutionContext &exe_ctx,
// Parse the expression
//
- m_materializer_ap.reset(new Materializer());
+ m_materializer_up.reset(new Materializer());
ResetDeclMap(exe_ctx, m_result_delegate, /*keep result in memory*/ true);
- OnExit on_exit([this]() { ResetDeclMap(); });
+ auto on_exit = llvm::make_scope_exit([this]() { ResetDeclMap(); });
- if (!DeclMap()->WillParse(exe_ctx, m_materializer_ap.get())) {
+ if (!DeclMap()->WillParse(exe_ctx, m_materializer_up.get())) {
diagnostic_manager.PutString(
eDiagnosticSeverityError,
"current process state is unsuitable for expression parsing");
@@ -734,7 +809,15 @@ bool ClangUserExpression::AddArguments(ExecutionContext &exe_ctx,
Status object_ptr_error;
- object_ptr = GetObjectPointer(frame_sp, object_name, object_ptr_error);
+ if (m_ctx_obj) {
+ AddressType address_type;
+ object_ptr = m_ctx_obj->GetAddressOf(false, &address_type);
+ if (object_ptr == LLDB_INVALID_ADDRESS ||
+ address_type != eAddressTypeLoad)
+ object_ptr_error.SetErrorString("Can't get context object's "
+ "debuggee address");
+ } else
+ object_ptr = GetObjectPointer(frame_sp, object_name, object_ptr_error);
if (!object_ptr_error.Success()) {
exe_ctx.GetTargetRef().GetDebugger().GetAsyncOutputStream()->Printf(
@@ -777,9 +860,11 @@ lldb::ExpressionVariableSP ClangUserExpression::GetResultAfterDematerialization(
void ClangUserExpression::ClangUserExpressionHelper::ResetDeclMap(
ExecutionContext &exe_ctx,
Materializer::PersistentVariableDelegate &delegate,
- bool keep_result_in_memory) {
+ bool keep_result_in_memory,
+ ValueObject *ctx_obj) {
m_expr_decl_map_up.reset(
- new ClangExpressionDeclMap(keep_result_in_memory, &delegate, exe_ctx));
+ new ClangExpressionDeclMap(keep_result_in_memory, &delegate, exe_ctx,
+ ctx_obj));
}
clang::ASTConsumer *
@@ -792,7 +877,7 @@ ClangUserExpression::ClangUserExpressionHelper::ASTTransformer(
}
void ClangUserExpression::ClangUserExpressionHelper::CommitPersistentDecls() {
- if (m_result_synthesizer_up.get()) {
+ if (m_result_synthesizer_up) {
m_result_synthesizer_up->CommitPersistentDecls();
}
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
index 7e4cba6618507..24c152bdb45d3 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
@@ -1,9 +1,8 @@
//===-- ClangUserExpression.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,8 +28,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ClangUserExpression ClangUserExpression.h
+/// \class ClangUserExpression ClangUserExpression.h
/// "lldb/Expression/ClangUserExpression.h" Encapsulates a single expression
/// for use with Clang
///
@@ -38,9 +36,13 @@ namespace lldb_private {
/// and as a backend for the expr command. ClangUserExpression encapsulates
/// the objects needed to parse and interpret or JIT an expression. It uses
/// the Clang parser to produce LLVM IR from the expression.
-//----------------------------------------------------------------------
class ClangUserExpression : public LLVMUserExpression {
public:
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindClangUserExpression;
+ }
+
enum { kDefaultTimeout = 500000u };
class ClangUserExpressionHelper : public ClangExpressionHelper {
@@ -50,10 +52,8 @@ public:
~ClangUserExpressionHelper() override = default;
- //------------------------------------------------------------------
/// Return the object that the parser should use when resolving external
/// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
ClangExpressionDeclMap *DeclMap() override {
return m_expr_decl_map_up.get();
}
@@ -62,16 +62,15 @@ public:
void ResetDeclMap(ExecutionContext &exe_ctx,
Materializer::PersistentVariableDelegate &result_delegate,
- bool keep_result_in_memory);
+ bool keep_result_in_memory,
+ ValueObject *ctx_obj);
- //------------------------------------------------------------------
/// Return the object that the parser should allow to access ASTs. May be
/// NULL if the ASTs do not need to be transformed.
///
- /// @param[in] passthrough
+ /// \param[in] passthrough
/// The ASTConsumer that the returned transformer should send
/// the ASTs to after transformation.
- //------------------------------------------------------------------
clang::ASTConsumer *
ASTTransformer(clang::ASTConsumer *passthrough) override;
@@ -88,53 +87,55 @@ public:
bool m_top_level;
};
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] expr
+ /// \param[in] expr
/// The expression to parse.
///
- /// @param[in] expr_prefix
+ /// \param[in] expr_prefix
/// If non-NULL, a C string containing translation-unit level
/// definitions to be included when the expression is parsed.
///
- /// @param[in] language
+ /// \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
+ /// \param[in] desired_type
/// If not eResultTypeAny, the type to use for the expression
/// result.
- //------------------------------------------------------------------
+ ///
+ /// \param[in] ctx_obj
+ /// The object (if any) in which context the expression
+ /// must be evaluated. For details see the comment to
+ /// `UserExpression::Evaluate`.
ClangUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
llvm::StringRef prefix, lldb::LanguageType language,
ResultType desired_type,
- const EvaluateExpressionOptions &options);
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj);
~ClangUserExpression() override;
- //------------------------------------------------------------------
/// Parse the expression
///
- /// @param[in] diagnostic_manager
+ /// \param[in] diagnostic_manager
/// A diagnostic manager to report parse errors and warnings to.
///
- /// @param[in] exe_ctx
+ /// \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
+ /// \param[in] execution_policy
/// Determines whether interpretation is possible or mandatory.
///
- /// @param[in] keep_result_in_memory
+ /// \param[in] keep_result_in_memory
/// True if the resulting persistent variable should reside in
/// target memory, if applicable.
///
- /// @return
+ /// \return
/// True on success (no errors); false otherwise.
- //------------------------------------------------------------------
bool Parse(DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
lldb_private::ExecutionPolicy execution_policy,
bool keep_result_in_memory, bool generate_debug_info) override;
@@ -154,17 +155,18 @@ public:
Materializer::PersistentVariableDelegate &result_delegate,
bool keep_result_in_memory) {
m_type_system_helper.ResetDeclMap(exe_ctx, result_delegate,
- keep_result_in_memory);
+ keep_result_in_memory,
+ m_ctx_obj);
}
lldb::ExpressionVariableSP
GetResultAfterDematerialization(ExecutionContextScope *exe_scope) override;
+ bool DidImportCxxModules() const { return m_imported_cpp_modules; }
+
private:
- //------------------------------------------------------------------
/// Populate m_in_cplusplus_method and m_in_objectivec_method based on the
/// environment.
- //------------------------------------------------------------------
void ScanContext(ExecutionContext &exe_ctx,
lldb_private::Status &err) override;
@@ -173,12 +175,15 @@ private:
lldb::addr_t struct_address,
DiagnosticManager &diagnostic_manager) override;
+ std::vector<std::string> GetModulesToImport(ExecutionContext &exe_ctx);
void UpdateLanguageForExpr(DiagnosticManager &diagnostic_manager,
- ExecutionContext &exe_ctx);
+ ExecutionContext &exe_ctx,
+ std::vector<std::string> modules_to_import,
+ bool for_completion);
bool SetupPersistentState(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx);
bool PrepareForParsing(DiagnosticManager &diagnostic_manager,
- ExecutionContext &exe_ctx);
+ ExecutionContext &exe_ctx, bool for_completion);
ClangUserExpressionHelper m_type_system_helper;
@@ -199,12 +204,21 @@ private:
/// The language type of the current expression.
lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown;
+ /// The include directories that should be used when parsing the expression.
+ std::vector<ConstString> m_include_directories;
/// The absolute character position in the transformed source code where the
/// user code (as typed by the user) starts. If the variable is empty, then we
/// were not able to calculate this position.
llvm::Optional<size_t> m_user_expression_start_pos;
ResultDelegate m_result_delegate;
+
+ /// The object (if any) in which context the expression is evaluated.
+ /// See the comment to `UserExpression::Evaluate` for details.
+ ValueObject *m_ctx_obj;
+
+ /// True iff this expression explicitly imported C++ modules.
+ bool m_imported_cpp_modules = false;
};
} // namespace lldb_private
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
index fe6ca450a79df..5eec224477fcb 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -1,15 +1,15 @@
//===-- ClangUtilityFunction.cpp ---------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ClangUtilityFunction.h"
#include "ClangExpressionDeclMap.h"
#include "ClangExpressionParser.h"
+#include "ClangExpressionSourceCode.h"
#include <stdio.h>
#if HAVE_SYS_TYPES_H
@@ -19,7 +19,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Expression/ExpressionSourceCode.h"
#include "lldb/Expression/IRExecutionUnit.h"
#include "lldb/Host/Host.h"
#include "lldb/Target/ExecutionContext.h"
@@ -30,33 +29,33 @@
using namespace lldb_private;
-//------------------------------------------------------------------
/// Constructor
///
-/// @param[in] text
+/// \param[in] text
/// The text of the function. Must be a full translation unit.
///
-/// @param[in] name
+/// \param[in] name
/// The name of the function, as used in the text.
-//------------------------------------------------------------------
ClangUtilityFunction::ClangUtilityFunction(ExecutionContextScope &exe_scope,
const char *text, const char *name)
- : UtilityFunction(exe_scope, text, name) {}
+ : UtilityFunction(exe_scope, text, name, eKindClangUtilityFunction) {
+ m_function_text.assign(ClangExpressionSourceCode::g_expression_prefix);
+ if (text && text[0])
+ m_function_text.append(text);
+}
ClangUtilityFunction::~ClangUtilityFunction() {}
-//------------------------------------------------------------------
/// Install the utility function into a process
///
-/// @param[in] diagnostic_manager
+/// \param[in] diagnostic_manager
/// A diagnostic manager to report errors and warnings to.
///
-/// @param[in] exe_ctx
+/// \param[in] exe_ctx
/// The execution context to install the utility function to.
///
-/// @return
+/// \return
/// True on success (no errors); false otherwise.
-//------------------------------------------------------------------
bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx) {
if (m_jit_start_addr != LLDB_INVALID_ADDRESS) {
@@ -91,7 +90,7 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
ResetDeclMap(exe_ctx, keep_result_in_memory);
- if (!DeclMap()->WillParse(exe_ctx, NULL)) {
+ if (!DeclMap()->WillParse(exe_ctx, nullptr)) {
diagnostic_manager.PutString(
eDiagnosticSeverityError,
"current process state is unsuitable for expression parsing");
@@ -157,5 +156,6 @@ bool ClangUtilityFunction::Install(DiagnosticManager &diagnostic_manager,
void ClangUtilityFunction::ClangUtilityFunctionHelper::ResetDeclMap(
ExecutionContext &exe_ctx, bool keep_result_in_memory) {
m_expr_decl_map_up.reset(
- new ClangExpressionDeclMap(keep_result_in_memory, nullptr, exe_ctx));
+ new ClangExpressionDeclMap(keep_result_in_memory, nullptr, exe_ctx,
+ nullptr));
}
diff --git a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
index b0650f0eda025..70ebb2f3ad8aa 100644
--- a/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
+++ b/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.h
@@ -1,9 +1,8 @@
//===-- ClangUtilityFunction.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,8 +22,7 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class ClangUtilityFunction ClangUtilityFunction.h
+/// \class ClangUtilityFunction ClangUtilityFunction.h
/// "lldb/Expression/ClangUtilityFunction.h" Encapsulates a single expression
/// for use with Clang
///
@@ -34,19 +32,21 @@ namespace lldb_private {
/// functions can perform error-checking for ClangUserExpressions, or can
/// simply provide a way to push a function into the target for the debugger
/// to call later on.
-//----------------------------------------------------------------------
class ClangUtilityFunction : public UtilityFunction {
public:
+ /// LLVM-style RTTI support.
+ static bool classof(const Expression *E) {
+ return E->getKind() == eKindClangUtilityFunction;
+ }
+
class ClangUtilityFunctionHelper : public ClangExpressionHelper {
public:
ClangUtilityFunctionHelper() {}
~ClangUtilityFunctionHelper() override {}
- //------------------------------------------------------------------
/// Return the object that the parser should use when resolving external
/// values. May be NULL if everything should be self-contained.
- //------------------------------------------------------------------
ClangExpressionDeclMap *DeclMap() override {
return m_expr_decl_map_up.get();
}
@@ -55,14 +55,12 @@ public:
void ResetDeclMap(ExecutionContext &exe_ctx, bool keep_result_in_memory);
- //------------------------------------------------------------------
/// Return the object that the parser should allow to access ASTs. May be
/// NULL if the ASTs do not need to be transformed.
///
- /// @param[in] passthrough
+ /// \param[in] passthrough
/// The ASTConsumer that the returned transformer should send
/// the ASTs to after transformation.
- //------------------------------------------------------------------
clang::ASTConsumer *
ASTTransformer(clang::ASTConsumer *passthrough) override {
return nullptr;
@@ -71,15 +69,13 @@ public:
private:
std::unique_ptr<ClangExpressionDeclMap> m_expr_decl_map_up;
};
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] text
+ /// \param[in] text
/// The text of the function. Must be a full translation unit.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the function, as used in the text.
- //------------------------------------------------------------------
ClangUtilityFunction(ExecutionContextScope &exe_scope, const char *text,
const char *name);
diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
index 20431d5f93c57..f8e004fe7d4ad 100644
--- a/source/Expression/IRDynamicChecks.cpp
+++ b/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
@@ -1,9 +1,8 @@
//===-- IRDynamicChecks.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,17 +14,18 @@
#include "llvm/IR/Value.h"
#include "llvm/Support/raw_ostream.h"
-#include "lldb/Expression/IRDynamicChecks.h"
+#include "IRDynamicChecks.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Log.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
using namespace llvm;
using namespace lldb_private;
@@ -41,12 +41,13 @@ static const char g_valid_pointer_check_text[] =
" unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n"
"}";
-DynamicCheckerFunctions::DynamicCheckerFunctions() = default;
+ClangDynamicCheckerFunctions::ClangDynamicCheckerFunctions()
+ : DynamicCheckerFunctions(DCF_Clang) {}
-DynamicCheckerFunctions::~DynamicCheckerFunctions() = default;
+ClangDynamicCheckerFunctions::~ClangDynamicCheckerFunctions() = default;
-bool DynamicCheckerFunctions::Install(DiagnosticManager &diagnostic_manager,
- ExecutionContext &exe_ctx) {
+bool ClangDynamicCheckerFunctions::Install(
+ DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx) {
Status error;
m_valid_pointer_check.reset(
exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage(
@@ -62,7 +63,7 @@ bool DynamicCheckerFunctions::Install(DiagnosticManager &diagnostic_manager,
if (process) {
ObjCLanguageRuntime *objc_language_runtime =
- process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime::Get(*process);
if (objc_language_runtime) {
m_objc_object_check.reset(objc_language_runtime->CreateObjectChecker(
@@ -76,8 +77,8 @@ bool DynamicCheckerFunctions::Install(DiagnosticManager &diagnostic_manager,
return true;
}
-bool DynamicCheckerFunctions::DoCheckersExplainStop(lldb::addr_t addr,
- Stream &message) {
+bool ClangDynamicCheckerFunctions::DoCheckersExplainStop(lldb::addr_t addr,
+ Stream &message) {
// FIXME: We have to get the checkers to know why they scotched the call in
// more detail,
// so we can print a better message here.
@@ -103,8 +104,7 @@ static std::string PrintValue(llvm::Value *V, bool truncate = false) {
return s;
}
-//----------------------------------------------------------------------
-/// @class Instrumenter IRDynamicChecks.cpp
+/// \class Instrumenter IRDynamicChecks.cpp
/// Finds and instruments individual LLVM IR instructions
///
/// When instrumenting LLVM IR, it is frequently desirable to first search for
@@ -130,38 +130,32 @@ static std::string PrintValue(llvm::Value *V, bool truncate = false) {
///
/// - InspectFunction [default: iterates through the basic blocks in a
/// function calling InspectBasicBlock]
-//----------------------------------------------------------------------
class Instrumenter {
public:
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] module
+ /// \param[in] module
/// The module being instrumented.
- //------------------------------------------------------------------
- Instrumenter(llvm::Module &module, DynamicCheckerFunctions &checker_functions)
- : m_module(module), m_checker_functions(checker_functions),
+ Instrumenter(llvm::Module &module,
+ std::shared_ptr<UtilityFunction> checker_function)
+ : m_module(module), m_checker_function(checker_function),
m_i8ptr_ty(nullptr), m_intptr_ty(nullptr) {}
virtual ~Instrumenter() = default;
- //------------------------------------------------------------------
/// Inspect a function to find instructions to instrument
///
- /// @param[in] function
+ /// \param[in] function
/// The function to inspect.
///
- /// @return
+ /// \return
/// True on success; false on error.
- //------------------------------------------------------------------
bool Inspect(llvm::Function &function) { return InspectFunction(function); }
- //------------------------------------------------------------------
/// Instrument all the instructions found by Inspect()
///
- /// @return
+ /// \return
/// True on success; false on error.
- //------------------------------------------------------------------
bool Instrument() {
for (InstIterator ii = m_to_instrument.begin(),
last_ii = m_to_instrument.end();
@@ -174,48 +168,40 @@ public:
}
protected:
- //------------------------------------------------------------------
/// Add instrumentation to a single instruction
///
- /// @param[in] inst
+ /// \param[in] inst
/// The instruction to be instrumented.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
virtual bool InstrumentInstruction(llvm::Instruction *inst) = 0;
- //------------------------------------------------------------------
/// Register a single instruction to be instrumented
///
- /// @param[in] inst
+ /// \param[in] inst
/// The instruction to be instrumented.
- //------------------------------------------------------------------
void RegisterInstruction(llvm::Instruction &i) {
m_to_instrument.push_back(&i);
}
- //------------------------------------------------------------------
/// Determine whether a single instruction is interesting to instrument,
/// and, if so, call RegisterInstruction
///
- /// @param[in] i
+ /// \param[in] i
/// The instruction to be inspected.
///
- /// @return
+ /// \return
/// False if there was an error scanning; true otherwise.
- //------------------------------------------------------------------
virtual bool InspectInstruction(llvm::Instruction &i) { return true; }
- //------------------------------------------------------------------
/// Scan a basic block to see if any instructions are interesting
///
- /// @param[in] bb
+ /// \param[in] bb
/// The basic block to be inspected.
///
- /// @return
+ /// \return
/// False if there was an error scanning; true otherwise.
- //------------------------------------------------------------------
virtual bool InspectBasicBlock(llvm::BasicBlock &bb) {
for (llvm::BasicBlock::iterator ii = bb.begin(), last_ii = bb.end();
ii != last_ii; ++ii) {
@@ -226,15 +212,13 @@ protected:
return true;
}
- //------------------------------------------------------------------
/// Scan a function to see if any instructions are interesting
///
- /// @param[in] f
+ /// \param[in] f
/// The function to be inspected.
///
- /// @return
+ /// \return
/// False if there was an error scanning; true otherwise.
- //------------------------------------------------------------------
virtual bool InspectFunction(llvm::Function &f) {
for (llvm::Function::iterator bbi = f.begin(), last_bbi = f.end();
bbi != last_bbi; ++bbi) {
@@ -245,17 +229,15 @@ protected:
return true;
}
- //------------------------------------------------------------------
/// Build a function pointer for a function with signature void
/// (*)(uint8_t*) with a given address
///
- /// @param[in] start_address
+ /// \param[in] start_address
/// The address of the function.
///
- /// @return
+ /// \return
/// The function pointer, for use in a CallInst.
- //------------------------------------------------------------------
- llvm::Value *BuildPointerValidatorFunc(lldb::addr_t start_address) {
+ llvm::FunctionCallee BuildPointerValidatorFunc(lldb::addr_t start_address) {
llvm::Type *param_array[1];
param_array[0] = const_cast<llvm::PointerType *>(GetI8PtrTy());
@@ -267,20 +249,18 @@ protected:
PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
Constant *fun_addr_int =
ConstantInt::get(GetIntptrTy(), start_address, false);
- return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
+ return {fun_ty, ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty)};
}
- //------------------------------------------------------------------
/// Build a function pointer for a function with signature void
/// (*)(uint8_t*, uint8_t*) with a given address
///
- /// @param[in] start_address
+ /// \param[in] start_address
/// The address of the function.
///
- /// @return
+ /// \return
/// The function pointer, for use in a CallInst.
- //------------------------------------------------------------------
- llvm::Value *BuildObjectCheckerFunc(lldb::addr_t start_address) {
+ llvm::FunctionCallee BuildObjectCheckerFunc(lldb::addr_t start_address) {
llvm::Type *param_array[2];
param_array[0] = const_cast<llvm::PointerType *>(GetI8PtrTy());
@@ -293,7 +273,7 @@ protected:
PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty);
Constant *fun_addr_int =
ConstantInt::get(GetIntptrTy(), start_address, false);
- return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty);
+ return {fun_ty, ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty)};
}
PointerType *GetI8PtrTy() {
@@ -319,8 +299,8 @@ protected:
InstVector m_to_instrument; ///< List of instructions the inspector found
llvm::Module &m_module; ///< The module which is being instrumented
- DynamicCheckerFunctions
- &m_checker_functions; ///< The dynamic checker functions for the process
+ std::shared_ptr<UtilityFunction>
+ m_checker_function; ///< The dynamic checker function for the process
private:
PointerType *m_i8ptr_ty;
@@ -330,8 +310,8 @@ private:
class ValidPointerChecker : public Instrumenter {
public:
ValidPointerChecker(llvm::Module &module,
- DynamicCheckerFunctions &checker_functions)
- : Instrumenter(module, checker_functions),
+ std::shared_ptr<UtilityFunction> checker_function)
+ : Instrumenter(module, checker_function),
m_valid_pointer_check_func(nullptr) {}
~ValidPointerChecker() override = default;
@@ -345,8 +325,8 @@ protected:
PrintValue(inst).c_str());
if (!m_valid_pointer_check_func)
- m_valid_pointer_check_func = BuildPointerValidatorFunc(
- m_checker_functions.m_valid_pointer_check->StartAddress());
+ m_valid_pointer_check_func =
+ BuildPointerValidatorFunc(m_checker_function->StartAddress());
llvm::Value *dereferenced_ptr = nullptr;
@@ -383,14 +363,14 @@ protected:
}
private:
- llvm::Value *m_valid_pointer_check_func;
+ llvm::FunctionCallee m_valid_pointer_check_func;
};
class ObjcObjectChecker : public Instrumenter {
public:
ObjcObjectChecker(llvm::Module &module,
- DynamicCheckerFunctions &checker_functions)
- : Instrumenter(module, checker_functions),
+ std::shared_ptr<UtilityFunction> checker_function)
+ : Instrumenter(module, checker_function),
m_objc_object_check_func(nullptr) {}
~ObjcObjectChecker() override = default;
@@ -414,8 +394,8 @@ protected:
// InspectInstruction wouldn't have registered it
if (!m_objc_object_check_func)
- m_objc_object_check_func = BuildObjectCheckerFunc(
- m_checker_functions.m_objc_object_check->StartAddress());
+ m_objc_object_check_func =
+ BuildObjectCheckerFunc(m_checker_function->StartAddress());
// id objc_msgSend(id theReceiver, SEL theSelector, ...)
@@ -425,8 +405,15 @@ protected:
switch (msgSend_types[inst]) {
case eMsgSend:
case eMsgSend_fpret:
- target_object = call_inst->getArgOperand(0);
- selector = call_inst->getArgOperand(1);
+ // On arm64, clang uses objc_msgSend for scalar and struct return
+ // calls. The call instruction will record which was used.
+ if (call_inst->hasStructRetAttr()) {
+ target_object = call_inst->getArgOperand(1);
+ selector = call_inst->getArgOperand(2);
+ } else {
+ target_object = call_inst->getArgOperand(0);
+ selector = call_inst->getArgOperand(1);
+ }
break;
case eMsgSend_stret:
target_object = call_inst->getArgOperand(1);
@@ -545,11 +532,11 @@ protected:
}
private:
- llvm::Value *m_objc_object_check_func;
+ llvm::FunctionCallee m_objc_object_check_func;
};
-IRDynamicChecks::IRDynamicChecks(DynamicCheckerFunctions &checker_functions,
- const char *func_name)
+IRDynamicChecks::IRDynamicChecks(
+ ClangDynamicCheckerFunctions &checker_functions, const char *func_name)
: ModulePass(ID), m_func_name(func_name),
m_checker_functions(checker_functions) {}
@@ -568,7 +555,7 @@ bool IRDynamicChecks::runOnModule(llvm::Module &M) {
}
if (m_checker_functions.m_valid_pointer_check) {
- ValidPointerChecker vpc(M, m_checker_functions);
+ ValidPointerChecker vpc(M, m_checker_functions.m_valid_pointer_check);
if (!vpc.Inspect(*function))
return false;
@@ -578,7 +565,7 @@ bool IRDynamicChecks::runOnModule(llvm::Module &M) {
}
if (m_checker_functions.m_objc_object_check) {
- ObjcObjectChecker ooc(M, m_checker_functions);
+ ObjcObjectChecker ooc(M, m_checker_functions.m_objc_object_check);
if (!ooc.Inspect(*function))
return false;
diff --git a/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h b/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
new file mode 100644
index 0000000000000..60c0691b21c18
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.h
@@ -0,0 +1,131 @@
+//===-- IRDynamicChecks.h ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_IRDynamicChecks_h_
+#define liblldb_IRDynamicChecks_h_
+
+#include "lldb/Expression/DynamicCheckerFunctions.h"
+#include "lldb/lldb-types.h"
+#include "llvm/Pass.h"
+
+namespace llvm {
+class BasicBlock;
+class Module;
+}
+
+namespace lldb_private {
+
+class ExecutionContext;
+class Stream;
+
+class ClangDynamicCheckerFunctions
+ : public lldb_private::DynamicCheckerFunctions {
+public:
+ /// Constructor
+ ClangDynamicCheckerFunctions();
+
+ /// Destructor
+ virtual ~ClangDynamicCheckerFunctions();
+
+ static bool classof(const DynamicCheckerFunctions *checker_funcs) {
+ return checker_funcs->GetKind() == DCF_Clang;
+ }
+
+ /// 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) override;
+
+ bool DoCheckersExplainStop(lldb::addr_t addr, Stream &message) override;
+
+ std::shared_ptr<UtilityFunction> m_valid_pointer_check;
+ std::shared_ptr<UtilityFunction> m_objc_object_check;
+};
+
+/// \class IRDynamicChecks IRDynamicChecks.h
+/// "lldb/Expression/IRDynamicChecks.h" 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 methods on objects that do not respond to them, and so forth.
+///
+/// IRDynamicChecks adds calls to the functions in DynamicCheckerFunctions to
+/// appropriate locations in an expression's IR.
+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(ClangDynamicCheckerFunctions &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
+ ClangDynamicCheckerFunctions
+ &m_checker_functions; ///< The checker functions for the process
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_IRDynamicChecks_h_
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 3a7cd58b70ab1..07acb2e1030f3 100644
--- a/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1,9 +1,8 @@
//===-- IRForTarget.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -61,7 +60,7 @@ IRForTarget::FunctionValueCache::GetValue(llvm::Function *function) {
static llvm::Value *FindEntryInstruction(llvm::Function *function) {
if (function->empty())
- return NULL;
+ return nullptr;
return function->getEntryBlock().getFirstNonPHIOrDbg();
}
@@ -72,11 +71,12 @@ IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map,
lldb_private::Stream &error_stream,
const char *func_name)
: ModulePass(ID), m_resolve_vars(resolve_vars), m_func_name(func_name),
- m_module(NULL), m_decl_map(decl_map), m_CFStringCreateWithBytes(NULL),
- m_sel_registerName(NULL), m_objc_getClass(NULL), m_intptr_ty(NULL),
- m_error_stream(error_stream),
- m_execution_unit(execution_unit), m_result_store(NULL),
- m_result_is_pointer(false), m_reloc_placeholder(NULL),
+ m_module(nullptr), m_decl_map(decl_map),
+ m_CFStringCreateWithBytes(nullptr), m_sel_registerName(nullptr),
+ m_objc_getClass(nullptr), m_intptr_ty(nullptr),
+ m_error_stream(error_stream), m_execution_unit(execution_unit),
+ m_result_store(nullptr), m_result_is_pointer(false),
+ m_reloc_placeholder(nullptr),
m_entry_instruction_finder(FindEntryInstruction) {}
/* Handy utility functions used at several places in the code */
@@ -117,7 +117,7 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(const GlobalValue *global_val,
module->getNamedMetadata("clang.global.decl.ptrs");
if (!named_metadata)
- return NULL;
+ return nullptr;
unsigned num_nodes = named_metadata->getNumOperands();
unsigned node_index;
@@ -126,7 +126,7 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(const GlobalValue *global_val,
llvm::MDNode *metadata_node =
dyn_cast<llvm::MDNode>(named_metadata->getOperand(node_index));
if (!metadata_node)
- return NULL;
+ return nullptr;
if (metadata_node->getNumOperands() != 2)
continue;
@@ -139,14 +139,14 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(const GlobalValue *global_val,
mdconst::dyn_extract<ConstantInt>(metadata_node->getOperand(1));
if (!constant_int)
- return NULL;
+ return nullptr;
uintptr_t ptr = constant_int->getZExtValue();
return reinterpret_cast<clang::NamedDecl *>(ptr);
}
- return NULL;
+ return nullptr;
}
clang::NamedDecl *IRForTarget::DeclForGlobal(GlobalValue *global_val) {
@@ -165,7 +165,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
ValueSymbolTable &value_symbol_table = m_module->getValueSymbolTable();
std::string result_name_str;
- const char *result_name = NULL;
+ const char *result_name = nullptr;
for (ValueSymbolTable::iterator vi = value_symbol_table.begin(),
ve = value_symbol_table.end();
@@ -343,8 +343,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
GlobalVariable *new_result_global = new GlobalVariable(
(*m_module), result_global->getType()->getElementType(),
- false, /* not constant */
- GlobalValue::ExternalLinkage, NULL, /* no initializer */
+ false, /* not constant */
+ GlobalValue::ExternalLinkage, nullptr, /* no initializer */
m_result_name.GetCString());
// It's too late in compilation to create a new VarDecl for this, but we
@@ -433,9 +433,11 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
static lldb_private::ConstString g_CFStringCreateWithBytes_str(
"CFStringCreateWithBytes");
+ bool missing_weak = false;
CFStringCreateWithBytes_addr =
- m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str);
- if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS) {
+ m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str,
+ missing_weak);
+ if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS || missing_weak) {
if (log)
log->PutCString("Couldn't find CFStringCreateWithBytes in the target");
@@ -478,18 +480,18 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
ArrayRef<Type *> CFSCWB_arg_types(arg_type_array, 5);
- llvm::Type *CFSCWB_ty =
+ llvm::FunctionType *CFSCWB_ty =
FunctionType::get(ns_str_ty, CFSCWB_arg_types, false);
// Build the constant containing the pointer to the function
PointerType *CFSCWB_ptr_ty = PointerType::getUnqual(CFSCWB_ty);
Constant *CFSCWB_addr_int =
ConstantInt::get(m_intptr_ty, CFStringCreateWithBytes_addr, false);
- m_CFStringCreateWithBytes =
- ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty);
+ m_CFStringCreateWithBytes = {
+ CFSCWB_ty, ConstantExpr::getIntToPtr(CFSCWB_addr_int, CFSCWB_ptr_ty)};
}
- ConstantDataSequential *string_array = NULL;
+ ConstantDataSequential *string_array = nullptr;
if (cstr)
string_array = dyn_cast<ConstantDataSequential>(cstr->getInitializer());
@@ -734,7 +736,7 @@ bool IRForTarget::RewriteObjCConstStrings() {
}
if (!cstr_array)
- cstr_global = NULL;
+ cstr_global = nullptr;
if (!RewriteObjCConstString(nsstring_global, cstr_global)) {
if (log)
@@ -857,9 +859,11 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
if (!m_sel_registerName) {
lldb::addr_t sel_registerName_addr;
+ bool missing_weak = false;
static lldb_private::ConstString g_sel_registerName_str("sel_registerName");
- sel_registerName_addr = m_execution_unit.FindSymbol(g_sel_registerName_str);
- if (sel_registerName_addr == LLDB_INVALID_ADDRESS)
+ sel_registerName_addr = m_execution_unit.FindSymbol(g_sel_registerName_str,
+ missing_weak);
+ if (sel_registerName_addr == LLDB_INVALID_ADDRESS || missing_weak)
return false;
if (log)
@@ -881,14 +885,15 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
ArrayRef<Type *> srN_arg_types(type_array, 1);
- llvm::Type *srN_type =
+ llvm::FunctionType *srN_type =
FunctionType::get(sel_ptr_type, srN_arg_types, false);
// Build the constant containing the pointer to the function
PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type);
Constant *srN_addr_int =
ConstantInt::get(m_intptr_ty, sel_registerName_addr, false);
- m_sel_registerName = ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty);
+ m_sel_registerName = {srN_type,
+ ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty)};
}
Value *argument_array[1];
@@ -1026,9 +1031,11 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
if (!m_objc_getClass) {
lldb::addr_t objc_getClass_addr;
+ bool missing_weak = false;
static lldb_private::ConstString g_objc_getClass_str("objc_getClass");
- objc_getClass_addr = m_execution_unit.FindSymbol(g_objc_getClass_str);
- if (objc_getClass_addr == LLDB_INVALID_ADDRESS)
+ objc_getClass_addr = m_execution_unit.FindSymbol(g_objc_getClass_str,
+ missing_weak);
+ if (objc_getClass_addr == LLDB_INVALID_ADDRESS || missing_weak)
return false;
if (log)
@@ -1043,14 +1050,15 @@ bool IRForTarget::RewriteObjCClassReference(Instruction *class_load) {
ArrayRef<Type *> ogC_arg_types(type_array, 1);
- llvm::Type *ogC_type =
+ llvm::FunctionType *ogC_type =
FunctionType::get(class_type, ogC_arg_types, false);
// Build the constant containing the pointer to the function
PointerType *ogC_ptr_ty = PointerType::getUnqual(ogC_type);
Constant *ogC_addr_int =
ConstantInt::get(m_intptr_ty, objc_getClass_addr, false);
- m_objc_getClass = ConstantExpr::getIntToPtr(ogC_addr_int, ogC_ptr_ty);
+ m_objc_getClass = {ogC_type,
+ ConstantExpr::getIntToPtr(ogC_addr_int, ogC_ptr_ty)};
}
Value *argument_array[1];
@@ -1148,8 +1156,8 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
return false;
GlobalVariable *persistent_global = new GlobalVariable(
- (*m_module), alloc->getType(), false, /* not constant */
- GlobalValue::ExternalLinkage, NULL, /* no initializer */
+ (*m_module), alloc->getType(), false, /* not constant */
+ GlobalValue::ExternalLinkage, nullptr, /* no initializer */
alloc->getName().str());
// What we're going to do here is make believe this was a regular old
@@ -1345,13 +1353,13 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) {
std::string name(named_decl->getName().str());
clang::ValueDecl *value_decl = dyn_cast<clang::ValueDecl>(named_decl);
- if (value_decl == NULL)
+ if (value_decl == nullptr)
return false;
lldb_private::CompilerType compiler_type(&value_decl->getASTContext(),
value_decl->getType());
- const Type *value_type = NULL;
+ const Type *value_type = nullptr;
if (name[0] == '$') {
// The $__lldb_expr_result name indicates the return value has allocated
@@ -1629,12 +1637,12 @@ bool IRForTarget::ResolveExternals(Function &llvm_function) {
}
static bool isGuardVariableRef(Value *V) {
- Constant *Old = NULL;
+ Constant *Old = nullptr;
if (!(Old = dyn_cast<Constant>(V)))
return false;
- ConstantExpr *CE = NULL;
+ ConstantExpr *CE = nullptr;
if ((CE = dyn_cast<ConstantExpr>(V))) {
if (CE->getOpcode() != Instruction::BitCast)
@@ -1929,8 +1937,8 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
}
for (element_index = 0; element_index < num_elements; ++element_index) {
- const clang::NamedDecl *decl = NULL;
- Value *value = NULL;
+ const clang::NamedDecl *decl = nullptr;
+ Value *value = nullptr;
lldb::offset_t offset;
lldb_private::ConstString name;
@@ -2050,7 +2058,7 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
std::string s;
raw_string_ostream oss(s);
- m_module->print(oss, NULL);
+ m_module->print(oss, nullptr);
oss.flush();
@@ -2087,7 +2095,7 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
m_reloc_placeholder = new llvm::GlobalVariable(
(*m_module), int8_ty, false /* IsConstant */,
GlobalVariable::InternalLinkage, Constant::getNullValue(int8_ty),
- "reloc_placeholder", NULL /* InsertBefore */,
+ "reloc_placeholder", nullptr /* InsertBefore */,
GlobalVariable::NotThreadLocal /* ThreadLocal */, 0 /* AddressSpace */);
////////////////////////////////////////////////////////////
@@ -2109,7 +2117,7 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
std::string s;
raw_string_ostream oss(s);
- m_module->print(oss, NULL);
+ m_module->print(oss, nullptr);
oss.flush();
@@ -2244,7 +2252,7 @@ bool IRForTarget::runOnModule(Module &llvm_module) {
std::string s;
raw_string_ostream oss(s);
- m_module->print(oss, NULL);
+ m_module->print(oss, nullptr);
oss.flush();
diff --git a/source/Plugins/ExpressionParser/Clang/IRForTarget.h b/source/Plugins/ExpressionParser/Clang/IRForTarget.h
index c6c44b46023ce..f87fd8ac32cb3 100644
--- a/source/Plugins/ExpressionParser/Clang/IRForTarget.h
+++ b/source/Plugins/ExpressionParser/Clang/IRForTarget.h
@@ -1,10 +1,9 @@
//===-- IRForTarget.h ---------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,6 +16,7 @@
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-public.h"
+#include "llvm/IR/DerivedTypes.h"
#include "llvm/Pass.h"
#include <functional>
@@ -31,11 +31,9 @@ class Function;
class GlobalValue;
class GlobalVariable;
class Instruction;
-class IntegerType;
class Module;
class StoreInst;
class DataLayout;
-class Type;
class Value;
}
@@ -45,8 +43,7 @@ class IRExecutionUnit;
class IRMemoryMap;
}
-//----------------------------------------------------------------------
-/// @class IRForTarget IRForTarget.h "lldb/Expression/IRForTarget.h"
+/// \class IRForTarget IRForTarget.h "lldb/Expression/IRForTarget.h"
/// Transforms the IR for a function to run in the target
///
/// Once an expression has been parsed and converted to IR, it can run in two
@@ -57,168 +54,143 @@ class IRMemoryMap;
/// transformations to the IR which make it relocatable. These
/// transformations are discussed in more detail next to their relevant
/// functions.
-//----------------------------------------------------------------------
class IRForTarget : public llvm::ModulePass {
public:
enum class LookupResult { Success, Fail, Ignore };
- //------------------------------------------------------------------
/// Constructor
///
- /// @param[in] decl_map
+ /// \param[in] decl_map
/// The list of externally-referenced variables for the expression,
/// for use in looking up globals and allocating the argument
/// struct. See the documentation for ClangExpressionDeclMap.
///
- /// @param[in] resolve_vars
+ /// \param[in] resolve_vars
/// True if the external variable references (including persistent
/// variables) should be resolved. If not, only external functions
/// are resolved.
///
- /// @param[in] execution_policy
+ /// \param[in] execution_policy
/// Determines whether an IR interpreter can be used to statically
/// evaluate the expression.
///
- /// @param[in] const_result
+ /// \param[in] const_result
/// This variable is populated with the statically-computed result
/// of the function, if it has no side-effects and the result can
/// be computed statically.
///
- /// @param[in] execution_unit
+ /// \param[in] execution_unit
/// The holder for raw data associated with the expression.
///
- /// @param[in] error_stream
+ /// \param[in] error_stream
/// If non-NULL, a stream on which errors can be printed.
///
- /// @param[in] func_name
+ /// \param[in] func_name
/// The name of the function to prepare for execution in the target.
- //------------------------------------------------------------------
IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, bool resolve_vars,
lldb_private::IRExecutionUnit &execution_unit,
lldb_private::Stream &error_stream,
const char *func_name = "$__lldb_expr");
- //------------------------------------------------------------------
/// Destructor
- //------------------------------------------------------------------
~IRForTarget() override;
- //------------------------------------------------------------------
/// Run this IR transformer on a single module
///
/// Implementation of the llvm::ModulePass::runOnModule() function.
///
- /// @param[in] llvm_module
+ /// \param[in] llvm_module
/// 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.
///
- /// @param[in] interpreter_error
+ /// \param[in] interpreter_error
/// An error. If the expression fails to be interpreted, this error
/// is set to a reason why.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool runOnModule(llvm::Module &llvm_module) override;
- //------------------------------------------------------------------
/// Interface stub
///
/// Implementation of the llvm::ModulePass::assignPassManager() function.
- //------------------------------------------------------------------
void assignPassManager(llvm::PMStack &pass_mgr_stack,
llvm::PassManagerType pass_mgr_type =
llvm::PMT_ModulePassManager) override;
- //------------------------------------------------------------------
/// Returns PMT_ModulePassManager
///
/// Implementation of the llvm::ModulePass::getPotentialPassManagerType()
/// function.
- //------------------------------------------------------------------
llvm::PassManagerType getPotentialPassManagerType() const override;
private:
- //------------------------------------------------------------------
/// Ensures that the current function's linkage is set to external.
/// Otherwise the JIT may not return an address for it.
///
- /// @param[in] llvm_function
+ /// \param[in] llvm_function
/// The function whose linkage is to be fixed.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
bool FixFunctionLinkage(llvm::Function &llvm_function);
- //------------------------------------------------------------------
/// A module-level pass to replace all function pointers with their
/// integer equivalents.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] llvm_module
+ /// \param[in] llvm_module
/// The module currently being processed.
///
- /// @param[in] llvm_function
+ /// \param[in] llvm_function
/// The function currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise.
- //------------------------------------------------------------------
bool HasSideEffects(llvm::Function &llvm_function);
- //------------------------------------------------------------------
/// A function-level pass to check whether the function has side
/// effects.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Get the address of a function, and a location to put the complete Value
/// of the function if one is available.
///
- /// @param[in] function
+ /// \param[in] function
/// The function to find the location of.
///
- /// @param[out] ptr
+ /// \param[out] ptr
/// The location of the function in the target.
///
- /// @param[out] name
+ /// \param[out] name
/// The resolved name of the function (matters for intrinsics).
///
- /// @param[out] value_ptr
+ /// \param[out] value_ptr
/// A variable to put the function's completed Value* in, or NULL
/// if the Value* shouldn't be stored anywhere.
///
- /// @return
+ /// \return
/// The pointer.
- //------------------------------------------------------------------
LookupResult GetFunctionAddress(llvm::Function *function, uint64_t &ptr,
lldb_private::ConstString &name,
llvm::Constant **&value_ptr);
- //------------------------------------------------------------------
/// A function-level pass to take the generated global value
/// $__lldb_expr_result and make it into a persistent variable. Also see
/// ASTResultSynthesizer.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Find the NamedDecl corresponding to a Value. This interface is exposed
/// for the IR interpreter.
///
- /// @param[in] module
+ /// \param[in] module
/// The module containing metadata to search
///
- /// @param[in] global
+ /// \param[in] global
/// The global entity to search for
///
- /// @return
+ /// \return
/// The corresponding variable declaration
- //------------------------------------------------------------------
public:
static clang::NamedDecl *DeclForGlobal(const llvm::GlobalValue *global_val,
llvm::Module *module);
@@ -226,75 +198,62 @@ public:
private:
clang::NamedDecl *DeclForGlobal(llvm::GlobalValue *global);
- //------------------------------------------------------------------
/// Set the constant result variable m_const_result to the provided
/// constant, assuming it can be evaluated. The result variable will be
/// reset to NULL later if the expression has side effects.
///
- /// @param[in] initializer
+ /// \param[in] initializer
/// The constant initializer for the variable.
///
- /// @param[in] name
+ /// \param[in] name
/// The name of the result variable.
///
- /// @param[in] type
+ /// \param[in] type
/// The Clang type of the result variable.
- //------------------------------------------------------------------
void MaybeSetConstantResult(llvm::Constant *initializer,
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
lldb_private::TypeFromParser type);
- //------------------------------------------------------------------
/// If the IR represents a cast of a variable, set m_const_result to the
/// result of the cast. The result variable will be reset to
/// NULL latger if the expression has side effects.
///
- /// @param[in] type
+ /// \param[in] type
/// The Clang type of the result variable.
- //------------------------------------------------------------------
void MaybeSetCastResult(lldb_private::TypeFromParser type);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] llvm_function
+ /// \param[in] llvm_function
/// The function currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool CreateResultVariable(llvm::Function &llvm_function);
- //------------------------------------------------------------------
/// A module-level pass to find Objective-C constant strings and
/// transform them to calls to CFStringCreateWithBytes.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Rewrite a single Objective-C constant string.
///
- /// @param[in] NSStr
+ /// \param[in] NSStr
/// The constant NSString to be transformed
///
- /// @param[in] CStr
+ /// \param[in] CStr
/// The constant C string inside the NSString. This will be
/// passed as the bytes argument to CFStringCreateWithBytes.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewriteObjCConstString(llvm::GlobalVariable *NSStr,
llvm::GlobalVariable *CStr);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewriteObjCConstStrings();
- //------------------------------------------------------------------
/// A basic block-level pass to find all Objective-C method calls and
/// rewrite them to use sel_registerName instead of statically allocated
/// selectors. The reason is that the selectors are created on the
@@ -302,59 +261,47 @@ private:
/// section and prepare them. This doesn't happen when code is copied into
/// the target, though, and there's no easy way to induce the runtime to
/// scan them. So instead we get our selectors from sel_registerName.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Replace a single selector reference
///
- /// @param[in] selector_load
+ /// \param[in] selector_load
/// The load of the statically-allocated selector.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewriteObjCSelector(llvm::Instruction *selector_load);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] basic_block
+ /// \param[in] basic_block
/// The basic block currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewriteObjCSelectors(llvm::BasicBlock &basic_block);
- //------------------------------------------------------------------
/// A basic block-level pass to find all Objective-C class references that
/// use the old-style Objective-C runtime and rewrite them to use
/// class_getClass instead of statically allocated class references.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Replace a single old-style class reference
///
- /// @param[in] selector_load
+ /// \param[in] selector_load
/// The load of the statically-allocated selector.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewriteObjCClassReference(llvm::Instruction *class_load);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] basic_block
+ /// \param[in] basic_block
/// The basic block currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewriteObjCClassReferences(llvm::BasicBlock &basic_block);
- //------------------------------------------------------------------
/// A basic block-level pass to find all newly-declared persistent
/// variables and register them with the ClangExprDeclMap. This allows them
/// to be materialized and dematerialized like normal external variables.
@@ -362,182 +309,147 @@ private:
/// locals, so they have an allocation. This pass excises these allocations
/// and makes references look like external references where they will be
/// resolved -- like all other external references -- by ResolveExternals().
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Handle a single allocation of a persistent variable
///
- /// @param[in] persistent_alloc
+ /// \param[in] persistent_alloc
/// The allocation of the persistent variable.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RewritePersistentAlloc(llvm::Instruction *persistent_alloc);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] basic_block
+ /// \param[in] basic_block
/// The basic block currently being processed.
- //------------------------------------------------------------------
bool RewritePersistentAllocs(llvm::BasicBlock &basic_block);
- //------------------------------------------------------------------
/// A function-level pass to find all external variables and functions
/// used in the IR. Each found external variable is added to the struct,
/// and each external function is resolved in place, its call replaced with
/// a call to a function pointer whose value is the address of the function
/// in the target process.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Write an initializer to a memory array of assumed sufficient size.
///
- /// @param[in] data
+ /// \param[in] data
/// A pointer to the data to write to.
///
- /// @param[in] initializer
+ /// \param[in] initializer
/// The initializer itself.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool MaterializeInitializer(uint8_t *data, llvm::Constant *initializer);
- //------------------------------------------------------------------
/// Move an internal variable into the static allocation section.
///
- /// @param[in] global_variable
+ /// \param[in] global_variable
/// The variable.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool MaterializeInternalVariable(llvm::GlobalVariable *global_variable);
- //------------------------------------------------------------------
/// Handle a single externally-defined variable
///
- /// @param[in] value
+ /// \param[in] value
/// The variable.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool MaybeHandleVariable(llvm::Value *value);
- //------------------------------------------------------------------
/// Handle a single externally-defined symbol
///
- /// @param[in] symbol
+ /// \param[in] symbol
/// The symbol.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool HandleSymbol(llvm::Value *symbol);
- //------------------------------------------------------------------
/// Handle a single externally-defined Objective-C class
///
- /// @param[in] classlist_reference
+ /// \param[in] classlist_reference
/// The reference, usually "01L_OBJC_CLASSLIST_REFERENCES_$_n"
/// where n (if present) is an index.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool HandleObjCClass(llvm::Value *classlist_reference);
- //------------------------------------------------------------------
/// Handle all the arguments to a function call
///
- /// @param[in] C
+ /// \param[in] C
/// The call instruction.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool MaybeHandleCallArguments(llvm::CallInst *call_inst);
- //------------------------------------------------------------------
/// Resolve variable references in calls to external functions
///
- /// @param[in] basic_block
+ /// \param[in] basic_block
/// The basic block currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool ResolveCalls(llvm::BasicBlock &basic_block);
- //------------------------------------------------------------------
/// Remove calls to __cxa_atexit, which should never be generated by
/// expressions.
///
- /// @param[in] call_inst
+ /// \param[in] call_inst
/// The call instruction.
///
- /// @return
+ /// \return
/// True if the scan was successful; false if some operation
/// failed
- //------------------------------------------------------------------
bool RemoveCXAAtExit(llvm::BasicBlock &basic_block);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] basic_block
+ /// \param[in] basic_block
/// The function currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool ResolveExternals(llvm::Function &llvm_function);
- //------------------------------------------------------------------
/// A basic block-level pass to excise guard variables from the code.
/// The result for the function is passed through Clang as a static
/// variable. Static variables normally have guard variables to ensure that
/// they are only initialized once.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// Rewrite a load to a guard variable to return constant 0.
///
- /// @param[in] guard_load
+ /// \param[in] guard_load
/// The load instruction to zero out.
- //------------------------------------------------------------------
void TurnGuardLoadIntoZero(llvm::Instruction *guard_load);
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] basic_block
+ /// \param[in] basic_block
/// The basic block currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool RemoveGuards(llvm::BasicBlock &basic_block);
- //------------------------------------------------------------------
/// A function-level pass to make all external variable references
/// point at the correct offsets from the void* passed into the function.
/// ClangExpressionDeclMap::DoStructLayout() must be called beforehand, so
/// that the offsets are valid.
- //------------------------------------------------------------------
- //------------------------------------------------------------------
/// The top-level pass implementation
///
- /// @param[in] llvm_function
+ /// \param[in] llvm_function
/// The function currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool ReplaceVariables(llvm::Function &llvm_function);
/// Flags
@@ -557,18 +469,16 @@ private:
///module.
lldb_private::ClangExpressionDeclMap
*m_decl_map; ///< The DeclMap containing the Decls
- llvm::Constant *m_CFStringCreateWithBytes; ///< The address of the function
- ///CFStringCreateWithBytes, cast to
- ///the
- /// appropriate function pointer type
- llvm::Constant *m_sel_registerName; ///< The address of the function
- ///sel_registerName, cast to the
- ///appropriate
- /// function pointer type
- llvm::Constant *m_objc_getClass; ///< The address of the function
- ///objc_getClass, cast to the
- ///appropriate
- /// function pointer type
+ llvm::FunctionCallee
+ m_CFStringCreateWithBytes; ///< The address of the function
+ /// CFStringCreateWithBytes, cast to the
+ /// appropriate function pointer type
+ llvm::FunctionCallee m_sel_registerName; ///< The address of the function
+ /// sel_registerName, cast to the
+ /// appropriate function pointer type
+ llvm::FunctionCallee m_objc_getClass; ///< The address of the function
+ /// objc_getClass, cast to the
+ /// appropriate function pointer type
llvm::IntegerType
*m_intptr_ty; ///< The type of an integer large enough to hold a pointer.
lldb_private::Stream
@@ -589,7 +499,6 @@ private:
///final
/// location of the static allocation.
- //------------------------------------------------------------------
/// UnfoldConstant operates on a constant [Old] which has just been replaced
/// with a value [New]. We assume that new_value has been properly placed
/// early in the function, in front of the first instruction in the entry
@@ -602,12 +511,11 @@ private:
/// instructions replace the constant uses, so UnfoldConstant calls itself
/// recursively for those.
///
- /// @param[in] llvm_function
+ /// \param[in] llvm_function
/// The function currently being processed.
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
class FunctionValueCache {
public:
@@ -631,32 +539,28 @@ private:
FunctionValueCache &entry_instruction_finder,
lldb_private::Stream &error_stream);
- //------------------------------------------------------------------
/// Construct a reference to m_reloc_placeholder with a given type and
/// offset. This typically happens after inserting data into
/// m_data_allocator.
///
- /// @param[in] type
+ /// \param[in] type
/// The type of the value being loaded.
///
- /// @param[in] offset
+ /// \param[in] offset
/// The offset of the value from the base of m_data_allocator.
///
- /// @return
+ /// \return
/// The Constant for the reference, usually a ConstantExpr.
- //------------------------------------------------------------------
llvm::Constant *BuildRelocation(llvm::Type *type, uint64_t offset);
- //------------------------------------------------------------------
/// Commit the allocation in m_data_allocator and use its final location to
/// replace m_reloc_placeholder.
///
- /// @param[in] module
+ /// \param[in] module
/// The module that m_data_allocator resides in
///
- /// @return
+ /// \return
/// True on success; false otherwise
- //------------------------------------------------------------------
bool CompleteDataAllocation();
};
diff --git a/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h b/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h
new file mode 100644
index 0000000000000..0e959f86fd2ad
--- /dev/null
+++ b/source/Plugins/ExpressionParser/Clang/ModuleDependencyCollector.h
@@ -0,0 +1,38 @@
+//===-- ModuleDependencyCollector.h -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_ModuleDependencyCollector_h_
+#define liblldb_ModuleDependencyCollector_h_
+
+#include "lldb/Utility/FileCollector.h"
+#include "clang/Frontend/Utils.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+class ModuleDependencyCollectorAdaptor
+ : public clang::ModuleDependencyCollector {
+public:
+ ModuleDependencyCollectorAdaptor(FileCollector &file_collector)
+ : clang::ModuleDependencyCollector(""), m_file_collector(file_collector) {
+ }
+
+ void addFile(llvm::StringRef Filename,
+ llvm::StringRef FileDst = {}) override {
+ m_file_collector.AddFile(Filename);
+ }
+
+ bool insertSeen(llvm::StringRef Filename) override { return false; }
+ void addFileMapping(llvm::StringRef VPath, llvm::StringRef RPath) override {}
+ void writeFileMap() override {}
+
+private:
+ FileCollector &m_file_collector;
+};
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
index 85bc4a61c9d4e..6323889c2e093 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
@@ -1,9 +1,8 @@
//===-- EmulateInstructionARM.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,11 +36,9 @@ using namespace lldb_private;
#define AlignPC(pc_val) (pc_val & 0xFFFFFFFC)
-//----------------------------------------------------------------------
//
// ITSession implementation
//
-//----------------------------------------------------------------------
static bool GetARMDWARFRegisterInfo(unsigned reg_num, RegisterInfo &reg_info) {
::memset(&reg_info, 0, sizeof(RegisterInfo));
@@ -710,11 +707,9 @@ uint32_t ITSession::GetCond() {
#define VFPv2_ABOVE (VFPv2 | VFPv3 | AdvancedSIMD)
#define VFPv2v3 (VFPv2 | VFPv3)
-//----------------------------------------------------------------------
//
// EmulateInstructionARM implementation
//
-//----------------------------------------------------------------------
void EmulateInstructionARM::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
@@ -740,21 +735,21 @@ EmulateInstructionARM::CreateInstance(const ArchSpec &arch,
if (EmulateInstructionARM::SupportsEmulatingInstructionsOfTypeStatic(
inst_type)) {
if (arch.GetTriple().getArch() == llvm::Triple::arm) {
- std::unique_ptr<EmulateInstructionARM> emulate_insn_ap(
+ std::unique_ptr<EmulateInstructionARM> emulate_insn_up(
new EmulateInstructionARM(arch));
- if (emulate_insn_ap.get())
- return emulate_insn_ap.release();
+ if (emulate_insn_up)
+ return emulate_insn_up.release();
} else if (arch.GetTriple().getArch() == llvm::Triple::thumb) {
- std::unique_ptr<EmulateInstructionARM> emulate_insn_ap(
+ std::unique_ptr<EmulateInstructionARM> emulate_insn_up(
new EmulateInstructionARM(arch));
- if (emulate_insn_ap.get())
- return emulate_insn_ap.release();
+ if (emulate_insn_up)
+ return emulate_insn_up.release();
}
}
- return NULL;
+ return nullptr;
}
bool EmulateInstructionARM::SetTargetTriple(const ArchSpec &arch) {
@@ -10155,7 +10150,7 @@ bool EmulateInstructionARM::EmulateADDRegShift(const uint32_t opcode,
shift_t = DecodeRegShift(Bits32(opcode, 6, 5));
// if d == 15 || n == 15 || m == 15 || s == 15 then UNPREDICTABLE;
- if ((d == 15) || (m == 15) || (m == 15) || (s == 15))
+ if ((d == 15) || (n == 15) || (m == 15) || (s == 15))
return false;
break;
@@ -12853,9 +12848,7 @@ EmulateInstructionARM::ARMOpcode *
EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
uint32_t arm_isa) {
static ARMOpcode g_arm_opcodes[] = {
- //----------------------------------------------------------------------
// Prologue instructions
- //----------------------------------------------------------------------
// push register(s)
{0x0fff0000, 0x092d0000, ARMvAll, eEncodingA1, No_VFP, eSize32,
@@ -12894,9 +12887,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
{0x0fbf0f00, 0x0d2d0a00, ARMV6T2_ABOVE, eEncodingA2, No_VFP, eSize32,
&EmulateInstructionARM::EmulateVPUSH, "vpush.32 <list>"},
- //----------------------------------------------------------------------
// Epilogue instructions
- //----------------------------------------------------------------------
{0x0fff0000, 0x08bd0000, ARMvAll, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulatePOP, "pop <registers>"},
@@ -12907,15 +12898,11 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
{0x0fbf0f00, 0x0cbd0a00, ARMV6T2_ABOVE, eEncodingA2, No_VFP, eSize32,
&EmulateInstructionARM::EmulateVPOP, "vpop.32 <list>"},
- //----------------------------------------------------------------------
// Supervisor Call (previously Software Interrupt)
- //----------------------------------------------------------------------
{0x0f000000, 0x0f000000, ARMvAll, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateSVC, "svc #imm24"},
- //----------------------------------------------------------------------
// Branch instructions
- //----------------------------------------------------------------------
// To resolve ambiguity, "blx <label>" should come before "b #imm24" and
// "bl <label>".
{0xfe000000, 0xfa000000, ARMV5_ABOVE, eEncodingA2, No_VFP, eSize32,
@@ -12933,9 +12920,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
{0x0ffffff0, 0x012fff20, ARMvAll, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateBXJRm, "bxj <Rm>"},
- //----------------------------------------------------------------------
// Data-processing instructions
- //----------------------------------------------------------------------
// adc (immediate)
{0x0fe00000, 0x02a00000, ARMvAll, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateADCImm, "adc{s}<c> <Rd>, <Rn>, #const"},
@@ -13099,9 +13084,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
&EmulateInstructionARM::EmulateSUBSPcLrEtc,
"<opc>S<c> PC,<Rn>,<Rm{,<shift>}"},
- //----------------------------------------------------------------------
// Load instructions
- //----------------------------------------------------------------------
{0x0fd00000, 0x08900000, ARMvAll, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateLDM, "ldm<c> <Rn>{!} <registers>"},
{0x0fd00000, 0x08100000, ARMvAll, eEncodingA1, No_VFP, eSize32,
@@ -13166,9 +13149,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
&EmulateInstructionARM::EmulateVLD1SingleAll,
"vld1<c>.<size> <list>, [<Rn>{@<align>}], <Rm>"},
- //----------------------------------------------------------------------
// Store instructions
- //----------------------------------------------------------------------
{0x0fd00000, 0x08800000, ARMvAll, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateSTM, "stm<c> <Rn>{!} <registers>"},
{0x0fd00000, 0x08000000, ARMvAll, eEncodingA1, No_VFP, eSize32,
@@ -13212,9 +13193,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
&EmulateInstructionARM::EmulateVST1Single,
"vst1<c>.<size> <list>, [<Rn>{@<align>}], <Rm>"},
- //----------------------------------------------------------------------
// Other instructions
- //----------------------------------------------------------------------
{0x0fff00f0, 0x06af00f0, ARMV6_ABOVE, eEncodingA1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateSXTB, "sxtb<c> <Rd>,<Rm>{,<rotation>}"},
{0x0fff00f0, 0x06bf0070, ARMV6_ABOVE, eEncodingA1, No_VFP, eSize32,
@@ -13234,7 +13213,7 @@ EmulateInstructionARM::GetARMOpcodeForInstruction(const uint32_t opcode,
(g_arm_opcodes[i].variants & arm_isa) != 0)
return &g_arm_opcodes[i];
}
- return NULL;
+ return nullptr;
}
EmulateInstructionARM::ARMOpcode *
@@ -13242,9 +13221,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
uint32_t arm_isa) {
static ARMOpcode g_thumb_opcodes[] = {
- //----------------------------------------------------------------------
// Prologue instructions
- //----------------------------------------------------------------------
// push register(s)
{0xfffffe00, 0x0000b400, ARMvAll, eEncodingT1, No_VFP, eSize16,
@@ -13288,9 +13265,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
{0xffbf0f00, 0xed2d0a00, ARMV6T2_ABOVE, eEncodingT2, No_VFP, eSize32,
&EmulateInstructionARM::EmulateVPUSH, "vpush.32 <list>"},
- //----------------------------------------------------------------------
// Epilogue instructions
- //----------------------------------------------------------------------
{0xfffff800, 0x0000a800, ARMV4T_ABOVE, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateADDSPImm, "add<c> <Rd>, sp, #imm"},
@@ -13307,15 +13282,11 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
{0xffbf0f00, 0xecbd0a00, ARMV6T2_ABOVE, eEncodingT2, No_VFP, eSize32,
&EmulateInstructionARM::EmulateVPOP, "vpop.32 <list>"},
- //----------------------------------------------------------------------
// Supervisor Call (previously Software Interrupt)
- //----------------------------------------------------------------------
{0xffffff00, 0x0000df00, ARMvAll, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateSVC, "svc #imm8"},
- //----------------------------------------------------------------------
// If Then makes up to four following instructions conditional.
- //----------------------------------------------------------------------
// The next 5 opcode _must_ come before the if then instruction
{0xffffffff, 0x0000bf00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateNop, "nop"},
@@ -13330,9 +13301,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
{0xffffff00, 0x0000bf00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateIT, "it{<x>{<y>{<z>}}} <firstcond>"},
- //----------------------------------------------------------------------
// Branch instructions
- //----------------------------------------------------------------------
// To resolve ambiguity, "b<c> #imm8" should come after "svc #imm8".
{0xfffff000, 0x0000d000, ARMvAll, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateB, "b<c> #imm8 (outside IT)"},
@@ -13367,9 +13336,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
{0xfff0fff0, 0xe8d0f010, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateTB, "tbh<c> <Rn>, <Rm>, lsl #1"},
- //----------------------------------------------------------------------
// Data-processing instructions
- //----------------------------------------------------------------------
// adc (immediate)
{0xfbe08000, 0xf1400000, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateADCImm, "adc{s}<c> <Rd>, <Rn>, #<const>"},
@@ -13597,20 +13564,16 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
{0xffffff00, 0xf3de8f00, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateSUBSPcLrEtc, "SUBS<c> PC, LR, #<imm8>"},
- //----------------------------------------------------------------------
// RFE instructions *** IMPORTANT *** THESE MUST BE LISTED **BEFORE** THE
// LDM.. Instructions in this table;
// otherwise the wrong instructions will be selected.
- //----------------------------------------------------------------------
{0xffd0ffff, 0xe810c000, ARMV6T2_ABOVE, eEncodingT1, No_VFP, eSize32,
&EmulateInstructionARM::EmulateRFE, "rfedb<c> <Rn>{!}"},
{0xffd0ffff, 0xe990c000, ARMV6T2_ABOVE, eEncodingT2, No_VFP, eSize32,
&EmulateInstructionARM::EmulateRFE, "rfe{ia}<c> <Rn>{!}"},
- //----------------------------------------------------------------------
// Load instructions
- //----------------------------------------------------------------------
{0xfffff800, 0x0000c800, ARMV4T_ABOVE, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateLDM, "ldm<c> <Rn>{!} <registers>"},
{0xffd02000, 0xe8900000, ARMV6T2_ABOVE, eEncodingT2, No_VFP, eSize32,
@@ -13718,9 +13681,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
&EmulateInstructionARM::EmulateVLD1SingleAll,
"vld1<c>.<size> <list>, [<Rn>{@<align>}], <Rm>"},
- //----------------------------------------------------------------------
// Store instructions
- //----------------------------------------------------------------------
{0xfffff800, 0x0000c000, ARMV4T_ABOVE, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateSTM, "stm<c> <Rn>{!} <registers>"},
{0xffd00000, 0xe8800000, ARMV6T2_ABOVE, eEncodingT2, No_VFP, eSize32,
@@ -13777,9 +13738,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
&EmulateInstructionARM::EmulateVST1Single,
"vst1<c>.<size> <list>, [<Rn>{@<align>}], <Rm>"},
- //----------------------------------------------------------------------
// Other instructions
- //----------------------------------------------------------------------
{0xffffffc0, 0x0000b240, ARMV6_ABOVE, eEncodingT1, No_VFP, eSize16,
&EmulateInstructionARM::EmulateSXTB, "sxtb<c> <Rd>,<Rm>"},
{0xfffff080, 0xfa4ff080, ARMV6_ABOVE, eEncodingT2, No_VFP, eSize32,
@@ -13804,7 +13763,7 @@ EmulateInstructionARM::GetThumbOpcodeForInstruction(const uint32_t opcode,
(g_thumb_opcodes[i].variants & arm_isa) != 0)
return &g_thumb_opcodes[i];
}
- return NULL;
+ return nullptr;
}
bool EmulateInstructionARM::SetArchitecture(const ArchSpec &arch) {
@@ -14352,7 +14311,7 @@ bool EmulateInstructionARM::WriteFlags(Context &context, const uint32_t result,
}
bool EmulateInstructionARM::EvaluateInstruction(uint32_t evaluate_options) {
- ARMOpcode *opcode_data = NULL;
+ ARMOpcode *opcode_data = nullptr;
if (m_opcode_mode == eModeThumb)
opcode_data =
@@ -14441,7 +14400,7 @@ bool EmulateInstructionARM::TestEmulation(Stream *out_stream, ArchSpec &arch,
OptionValueSP value_sp = test_data->GetValueForKey(opcode_key);
uint32_t test_opcode;
- if ((value_sp.get() == NULL) ||
+ if ((value_sp.get() == nullptr) ||
(value_sp->GetType() != OptionValue::eTypeUInt64)) {
out_stream->Printf("TestEmulation: Error reading opcode from test file.\n");
return false;
@@ -14467,7 +14426,7 @@ bool EmulateInstructionARM::TestEmulation(Stream *out_stream, ArchSpec &arch,
EmulationStateARM after_state;
value_sp = test_data->GetValueForKey(before_key);
- if ((value_sp.get() == NULL) ||
+ if ((value_sp.get() == nullptr) ||
(value_sp->GetType() != OptionValue::eTypeDictionary)) {
out_stream->Printf("TestEmulation: Failed to find 'before' state.\n");
return false;
@@ -14480,7 +14439,7 @@ bool EmulateInstructionARM::TestEmulation(Stream *out_stream, ArchSpec &arch,
}
value_sp = test_data->GetValueForKey(after_key);
- if ((value_sp.get() == NULL) ||
+ if ((value_sp.get() == nullptr) ||
(value_sp->GetType() != OptionValue::eTypeDictionary)) {
out_stream->Printf("TestEmulation: Failed to find 'after' state.\n");
return false;
diff --git a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
index fb1867c6362a6..13d7fc061bea1 100644
--- a/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
+++ b/source/Plugins/Instruction/ARM/EmulateInstructionARM.h
@@ -1,9 +1,8 @@
-//===-- lldb_EmulateInstructionARM.h ----------------------------*- C++ -*-===//
+//===-- EmulateInstructionARM.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -46,7 +45,7 @@ private:
class EmulateInstructionARM : public EmulateInstruction {
public:
- typedef enum {
+ enum ARMEncoding {
eEncodingA1,
eEncodingA2,
eEncodingA3,
@@ -57,7 +56,7 @@ public:
eEncodingT3,
eEncodingT4,
eEncodingT5
- } ARMEncoding;
+ };
static void Initialize();
@@ -292,7 +291,7 @@ public:
protected:
// Typedef for the callback function used during the emulation.
// Pass along (ARMEncoding)encoding as the callback data.
- typedef enum { eSize16, eSize32 } ARMInstrSize;
+ enum ARMInstrSize { eSize16, eSize32 };
typedef struct {
uint32_t mask;
diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index d770b3bdc52e8..11c7677c201a3 100644
--- a/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -1,9 +1,8 @@
//===-- EmulationStateARM.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -285,14 +284,14 @@ bool EmulationStateARM::LoadStateFromDictionary(
// Load memory, if present.
- if (value_sp.get() != NULL) {
+ if (value_sp.get() != nullptr) {
static ConstString address_key("address");
static ConstString data_key("data");
uint64_t start_address = 0;
OptionValueDictionary *mem_dict = value_sp->GetAsDictionary();
value_sp = mem_dict->GetValueForKey(address_key);
- if (value_sp.get() == NULL)
+ if (value_sp.get() == nullptr)
return false;
else
start_address = value_sp->GetUInt64Value();
@@ -307,7 +306,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
for (uint32_t i = 0; i < num_elts; ++i) {
value_sp = mem_array->GetValueAtIndex(i);
- if (value_sp.get() == NULL)
+ if (value_sp.get() == nullptr)
return false;
uint64_t value = value_sp->GetUInt64Value();
StoreToPseudoAddress(address, value);
@@ -316,7 +315,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
}
value_sp = test_data->GetValueForKey(registers_key);
- if (value_sp.get() == NULL)
+ if (value_sp.get() == nullptr)
return false;
// Load General Registers
@@ -329,7 +328,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
sstr.Printf("r%d", i);
ConstString reg_name(sstr.GetString());
value_sp = reg_dict->GetValueForKey(reg_name);
- if (value_sp.get() == NULL)
+ if (value_sp.get() == nullptr)
return false;
uint64_t reg_value = value_sp->GetUInt64Value();
StorePseudoRegisterValue(dwarf_r0 + i, reg_value);
@@ -337,7 +336,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
static ConstString cpsr_name("cpsr");
value_sp = reg_dict->GetValueForKey(cpsr_name);
- if (value_sp.get() == NULL)
+ if (value_sp.get() == nullptr)
return false;
StorePseudoRegisterValue(dwarf_cpsr, value_sp->GetUInt64Value());
@@ -347,7 +346,7 @@ bool EmulationStateARM::LoadStateFromDictionary(
sstr.Printf("s%d", i);
ConstString reg_name(sstr.GetString());
value_sp = reg_dict->GetValueForKey(reg_name);
- if (value_sp.get() == NULL)
+ if (value_sp.get() == nullptr)
return false;
uint64_t reg_value = value_sp->GetUInt64Value();
StorePseudoRegisterValue(dwarf_s0 + i, reg_value);
diff --git a/source/Plugins/Instruction/ARM/EmulationStateARM.h b/source/Plugins/Instruction/ARM/EmulationStateARM.h
index f27f4755a1776..e5af37a215040 100644
--- a/source/Plugins/Instruction/ARM/EmulationStateARM.h
+++ b/source/Plugins/Instruction/ARM/EmulationStateARM.h
@@ -1,9 +1,8 @@
-//===-- lldb_EmulationStateARM.h --------------------------------*- C++ -*-===//
+//===-- EmulationStateARM.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
index 661a651c56c27..d7e8e04913426 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
@@ -1,9 +1,8 @@
//===-- EmulateInstructionARM64.cpp ------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -118,11 +117,9 @@ ConstrainUnpredictable(EmulateInstructionARM64::Unpredictable which) {
return result;
}
-//----------------------------------------------------------------------
//
// EmulateInstructionARM implementation
//
-//----------------------------------------------------------------------
void EmulateInstructionARM64::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
@@ -157,7 +154,7 @@ EmulateInstructionARM64::CreateInstance(const ArchSpec &arch,
}
}
- return NULL;
+ return nullptr;
}
bool EmulateInstructionARM64::SetTargetTriple(const ArchSpec &arch) {
@@ -208,9 +205,7 @@ bool EmulateInstructionARM64::GetRegisterInfo(RegisterKind reg_kind,
EmulateInstructionARM64::Opcode *
EmulateInstructionARM64::GetOpcodeForInstruction(const uint32_t opcode) {
static EmulateInstructionARM64::Opcode g_opcodes[] = {
- //----------------------------------------------------------------------
// Prologue instructions
- //----------------------------------------------------------------------
// push register(s)
{0xff000000, 0xd1000000, No_VFP,
@@ -416,7 +411,7 @@ bool EmulateInstructionARM64::ReadInstruction() {
bool EmulateInstructionARM64::EvaluateInstruction(uint32_t evaluate_options) {
const uint32_t opcode = m_opcode.GetOpcode32();
Opcode *opcode_data = GetOpcodeForInstruction(opcode);
- if (opcode_data == NULL)
+ if (opcode_data == nullptr)
return false;
// printf ("opcode template for 0x%8.8x: %s\n", opcode, opcode_data->name);
@@ -662,10 +657,10 @@ bool EmulateInstructionARM64::EmulateADDSUBImm(const uint32_t opcode) {
if (sub_op) {
operand2 = NOT(operand2);
- carry_in = 1;
+ carry_in = true;
imm = -imm; // For the Register plug offset context below
} else {
- carry_in = 0;
+ carry_in = false;
}
ProcState proc_state;
diff --git a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
index 1d1bd74d3f612..03a57a2cf92bf 100644
--- a/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
+++ b/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.h
@@ -1,9 +1,8 @@
//===-- EmulateInstructionARM64.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -74,25 +73,25 @@ public:
bool
CreateFunctionEntryUnwind(lldb_private::UnwindPlan &unwind_plan) override;
- typedef enum { AddrMode_OFF, AddrMode_PRE, AddrMode_POST } AddrMode;
+ enum AddrMode { AddrMode_OFF, AddrMode_PRE, AddrMode_POST };
- typedef enum {
+ enum BranchType {
BranchType_CALL,
BranchType_ERET,
BranchType_DRET,
BranchType_RET,
BranchType_JMP
- } BranchType;
+ };
- typedef enum { CountOp_CLZ, CountOp_CLS, CountOp_CNT } CountOp;
+ enum CountOp { CountOp_CLZ, CountOp_CLS, CountOp_CNT };
- typedef enum { RevOp_RBIT, RevOp_REV16, RevOp_REV32, RevOp_REV64 } RevOp;
+ enum RevOp { RevOp_RBIT, RevOp_REV16, RevOp_REV32, RevOp_REV64 };
- typedef enum { BitwiseOp_NOT, BitwiseOp_RBIT } BitwiseOp;
+ enum BitwiseOp { BitwiseOp_NOT, BitwiseOp_RBIT };
- typedef enum { EL0 = 0, EL1 = 1, EL2 = 2, EL3 = 3 } ExceptionLevel;
+ enum ExceptionLevel { EL0 = 0, EL1 = 1, EL2 = 2, EL3 = 3 };
- typedef enum {
+ enum ExtendType {
ExtendType_SXTB,
ExtendType_SXTH,
ExtendType_SXTW,
@@ -101,44 +100,36 @@ public:
ExtendType_UXTH,
ExtendType_UXTW,
ExtendType_UXTX
- } ExtendType;
+ };
- typedef enum { ExtractType_LEFT, ExtractType_RIGHT } ExtractType;
+ enum ExtractType { ExtractType_LEFT, ExtractType_RIGHT };
- typedef enum { LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR } LogicalOp;
+ enum LogicalOp { LogicalOp_AND, LogicalOp_EOR, LogicalOp_ORR };
- typedef enum { MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH, MemOp_NOP } MemOp;
+ enum MemOp { MemOp_LOAD, MemOp_STORE, MemOp_PREFETCH, MemOp_NOP };
- typedef enum { MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K } MoveWideOp;
+ enum MoveWideOp { MoveWideOp_N, MoveWideOp_Z, MoveWideOp_K };
- typedef enum {
- ShiftType_LSL,
- ShiftType_LSR,
- ShiftType_ASR,
- ShiftType_ROR
- } ShiftType;
+ enum ShiftType { ShiftType_LSL, ShiftType_LSR, ShiftType_ASR, ShiftType_ROR };
- typedef enum { SP0 = 0, SPx = 1 } StackPointerSelection;
+ enum StackPointerSelection { SP0 = 0, SPx = 1 };
- typedef enum {
- Unpredictable_WBOVERLAP,
- Unpredictable_LDPOVERLAP
- } Unpredictable;
+ enum Unpredictable { Unpredictable_WBOVERLAP, Unpredictable_LDPOVERLAP };
- typedef enum {
+ enum ConstraintType {
Constraint_NONE,
Constraint_UNKNOWN,
Constraint_SUPPRESSWB,
Constraint_NOP
- } ConstraintType;
+ };
- typedef enum {
+ enum AccType {
AccType_NORMAL,
AccType_UNPRIV,
AccType_STREAM,
AccType_ALIGNED,
AccType_ORDERED
- } AccType;
+ };
typedef struct {
uint32_t N : 1, V : 1, C : 1,
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
index 7fccb23110268..cbf3dda7896e4 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
@@ -1,9 +1,8 @@
//===-- EmulateInstructionMIPS.cpp -------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,11 +42,9 @@ using namespace lldb_private;
#define UInt(x) ((uint64_t)x)
#define integer int64_t
-//----------------------------------------------------------------------
//
// EmulateInstructionMIPS implementation
//
-//----------------------------------------------------------------------
#ifdef __mips__
extern "C" {
@@ -216,7 +213,7 @@ EmulateInstructionMIPS::CreateInstance(const ArchSpec &arch,
}
}
- return NULL;
+ return nullptr;
}
bool EmulateInstructionMIPS::SetTargetTriple(const ArchSpec &arch) {
@@ -678,9 +675,7 @@ bool EmulateInstructionMIPS::GetRegisterInfo(RegisterKind reg_kind,
EmulateInstructionMIPS::MipsOpcode *
EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
static EmulateInstructionMIPS::MipsOpcode g_opcodes[] = {
- //----------------------------------------------------------------------
// Prologue/Epilogue instructions
- //----------------------------------------------------------------------
{"ADDiu", &EmulateInstructionMIPS::Emulate_ADDiu,
"ADDIU rt, rs, immediate"},
{"SW", &EmulateInstructionMIPS::Emulate_SW, "SW rt, offset(rs)"},
@@ -689,9 +684,7 @@ EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
{"ADDU", &EmulateInstructionMIPS::Emulate_SUBU_ADDU, "ADDU rd, rs, rt"},
{"LUI", &EmulateInstructionMIPS::Emulate_LUI, "LUI rt, immediate"},
- //----------------------------------------------------------------------
// MicroMIPS Prologue/Epilogue instructions
- //----------------------------------------------------------------------
{"ADDIUSP_MM", &EmulateInstructionMIPS::Emulate_ADDIUSP,
"ADDIU immediate"},
{"ADDIUS5_MM", &EmulateInstructionMIPS::Emulate_ADDIUS5,
@@ -712,10 +705,8 @@ EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
"LWP rd,offset(base)"},
{"JRADDIUSP", &EmulateInstructionMIPS::Emulate_JRADDIUSP,
"JRADDIUSP immediate"},
- //----------------------------------------------------------------------
// Load/Store instructions
- //----------------------------------------------------------------------
/* Following list of emulated instructions are required by implementation
of hardware watchpoint
for MIPS in lldb. As we just need the address accessed by instructions,
@@ -835,9 +826,7 @@ EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
{"SCDX", &EmulateInstructionMIPS::Emulate_LDST_Imm,
"SCDX rt, offset(base)"},
- //----------------------------------------------------------------------
// MicroMIPS Load/Store instructions
- //----------------------------------------------------------------------
{"LBU16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
"LBU16 rt, decoded_offset(base)"},
{"LHU16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
@@ -855,9 +844,7 @@ EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
{"SB16_MM", &EmulateInstructionMIPS::Emulate_LDST_Imm,
"SB16 rt, offset(base)"},
- //----------------------------------------------------------------------
// Branch instructions
- //----------------------------------------------------------------------
{"BEQ", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQ rs,rt,offset"},
{"BNE", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BNE rs,rt,offset"},
{"BEQL", &EmulateInstructionMIPS::Emulate_BXX_3ops, "BEQL rs,rt,offset"},
@@ -949,9 +936,7 @@ EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
{"BNZ_V", &EmulateInstructionMIPS::Emulate_BNZV, "BNZ.V wt,s16"},
{"BZ_V", &EmulateInstructionMIPS::Emulate_BZV, "BZ.V wt,s16"},
- //----------------------------------------------------------------------
// MicroMIPS Branch instructions
- //----------------------------------------------------------------------
{"B16_MM", &EmulateInstructionMIPS::Emulate_B16_MM, "B16 offset"},
{"BEQZ16_MM", &EmulateInstructionMIPS::Emulate_Branch_MM,
"BEQZ16 rs, offset"},
@@ -981,7 +966,7 @@ EmulateInstructionMIPS::GetOpcodeForInstruction(const char *op_name) {
return &g_opcodes[i];
}
- return NULL;
+ return nullptr;
}
uint32_t
@@ -1098,7 +1083,7 @@ bool EmulateInstructionMIPS::EvaluateInstruction(uint32_t evaluate_options) {
*/
const char *op_name = m_insn_info->getName(mc_insn.getOpcode()).data();
- if (op_name == NULL)
+ if (op_name == nullptr)
return false;
/*
@@ -1107,7 +1092,7 @@ bool EmulateInstructionMIPS::EvaluateInstruction(uint32_t evaluate_options) {
*/
MipsOpcode *opcode_data = GetOpcodeForInstruction(op_name);
- if (opcode_data == NULL)
+ if (opcode_data == nullptr)
return false;
uint64_t old_pc = 0, new_pc = 0;
@@ -2890,7 +2875,7 @@ bool EmulateInstructionMIPS::Emulate_MSA_Branch_DF(llvm::MCInst &insn,
bool success = false, branch_hit = true;
int32_t target = 0;
RegisterValue reg_value;
- const uint8_t *ptr = NULL;
+ const uint8_t *ptr = nullptr;
uint32_t wt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
int32_t offset = insn.getOperand(1).getImm();
diff --git a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
index 8d6e0be3cd784..cd447ae4975e9 100644
--- a/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
+++ b/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h
@@ -1,10 +1,9 @@
//===-- EmulateInstructionMIPS.h ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,8 +20,11 @@ class MCInstrInfo;
class MCInst;
}
+namespace lldb_private {
+ class OptionValueDictionary;
+}
+
#include "lldb/Core/EmulateInstruction.h"
-#include "lldb/Interpreter/OptionValue.h"
#include "lldb/Utility/Status.h"
class EmulateInstructionMIPS : public lldb_private::EmulateInstruction {
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
index 9d178dd97ddf4..69f0278d14377 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
@@ -1,9 +1,8 @@
//===-- EmulateInstructionMIPS64.cpp -----------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,11 +42,9 @@ using namespace lldb_private;
#define UInt(x) ((uint64_t)x)
#define integer int64_t
-//----------------------------------------------------------------------
//
// EmulateInstructionMIPS64 implementation
//
-//----------------------------------------------------------------------
#ifdef __mips__
extern "C" {
@@ -203,7 +200,7 @@ EmulateInstructionMIPS64::CreateInstance(const ArchSpec &arch,
}
}
- return NULL;
+ return nullptr;
}
bool EmulateInstructionMIPS64::SetTargetTriple(const ArchSpec &arch) {
@@ -665,9 +662,7 @@ bool EmulateInstructionMIPS64::GetRegisterInfo(RegisterKind reg_kind,
EmulateInstructionMIPS64::MipsOpcode *
EmulateInstructionMIPS64::GetOpcodeForInstruction(const char *op_name) {
static EmulateInstructionMIPS64::MipsOpcode g_opcodes[] = {
- //----------------------------------------------------------------------
// Prologue/Epilogue instructions
- //----------------------------------------------------------------------
{"DADDiu", &EmulateInstructionMIPS64::Emulate_DADDiu,
"DADDIU rt, rs, immediate"},
{"ADDiu", &EmulateInstructionMIPS64::Emulate_DADDiu,
@@ -684,9 +679,7 @@ EmulateInstructionMIPS64::GetOpcodeForInstruction(const char *op_name) {
"ADDU rd, rs, rt"},
{"LUI", &EmulateInstructionMIPS64::Emulate_LUI, "LUI rt, immediate"},
- //----------------------------------------------------------------------
// Load/Store instructions
- //----------------------------------------------------------------------
/* Following list of emulated instructions are required by implementation
of hardware watchpoint
for MIPS in lldb. As we just need the address accessed by instructions,
@@ -792,9 +785,7 @@ EmulateInstructionMIPS64::GetOpcodeForInstruction(const char *op_name) {
{"SWXC1", &EmulateInstructionMIPS64::Emulate_LDST_Reg,
"SWXC1 fs, index (base)"},
- //----------------------------------------------------------------------
// Branch instructions
- //----------------------------------------------------------------------
{"BEQ", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BEQ rs,rt,offset"},
{"BEQ64", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BEQ rs,rt,offset"},
{"BNE", &EmulateInstructionMIPS64::Emulate_BXX_3ops, "BNE rs,rt,offset"},
@@ -940,7 +931,7 @@ EmulateInstructionMIPS64::GetOpcodeForInstruction(const char *op_name) {
return &g_opcodes[i];
}
- return NULL;
+ return nullptr;
}
bool EmulateInstructionMIPS64::ReadInstruction() {
@@ -983,7 +974,7 @@ bool EmulateInstructionMIPS64::EvaluateInstruction(uint32_t evaluate_options) {
*/
const char *op_name = m_insn_info->getName(mc_insn.getOpcode()).data();
- if (op_name == NULL)
+ if (op_name == nullptr)
return false;
/*
@@ -992,7 +983,7 @@ bool EmulateInstructionMIPS64::EvaluateInstruction(uint32_t evaluate_options) {
*/
MipsOpcode *opcode_data = GetOpcodeForInstruction(op_name);
- if (opcode_data == NULL)
+ if (opcode_data == nullptr)
return false;
uint64_t old_pc = 0, new_pc = 0;
@@ -2195,7 +2186,7 @@ bool EmulateInstructionMIPS64::Emulate_MSA_Branch_DF(llvm::MCInst &insn,
bool success = false, branch_hit = true;
int64_t target = 0;
RegisterValue reg_value;
- const uint8_t *ptr = NULL;
+ const uint8_t *ptr = nullptr;
uint32_t wt = m_reg_info->getEncodingValue(insn.getOperand(0).getReg());
int64_t offset = insn.getOperand(1).getImm();
diff --git a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
index e9783633ac7de..953a0935bd066 100644
--- a/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
+++ b/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h
@@ -1,9 +1,8 @@
//===-- EmulateInstructionMIPS64.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
index f3a9ca570a4ac..c77fa04fc7d77 100644
--- a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
+++ b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
@@ -1,9 +1,8 @@
//===-- EmulateInstructionPPC64.cpp ------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -56,23 +55,15 @@ EmulateInstruction *
EmulateInstructionPPC64::CreateInstance(const ArchSpec &arch,
InstructionType inst_type) {
if (EmulateInstructionPPC64::SupportsEmulatingInstructionsOfTypeStatic(
- inst_type)) {
- if (arch.GetTriple().getArch() == llvm::Triple::ppc64 ||
- arch.GetTriple().getArch() == llvm::Triple::ppc64le) {
+ inst_type))
+ if (arch.GetTriple().isPPC64())
return new EmulateInstructionPPC64(arch);
- }
- }
return nullptr;
}
bool EmulateInstructionPPC64::SetTargetTriple(const ArchSpec &arch) {
- if (arch.GetTriple().getArch() == llvm::Triple::ppc64)
- return true;
- else if (arch.GetTriple().getArch() == llvm::Triple::ppc64le)
- return true;
-
- return false;
+ return arch.GetTriple().isPPC64();
}
static bool LLDBTableGetRegisterInfo(uint32_t reg_num, RegisterInfo &reg_info) {
diff --git a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
index e9a1da6dd3941..bf239770b933e 100644
--- a/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
+++ b/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.h
@@ -1,9 +1,8 @@
//===-- EmulateInstructionPPC64.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
index 9a6e39be0bfd2..c8ac04641e685 100644
--- a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.cpp
@@ -1,9 +1,8 @@
//===-- ASanRuntime.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -72,7 +71,6 @@ bool AddressSanitizerRuntime::CheckIfRuntimeIsValid(
return symbol != nullptr;
}
-static constexpr std::chrono::seconds g_retrieve_report_data_function_timeout(2);
const char *address_sanitizer_retrieve_report_data_prefix = R"(
extern "C"
{
@@ -127,7 +125,7 @@ StructuredData::ObjectSP AddressSanitizerRuntime::RetrieveReportData() {
options.SetTryAllThreads(true);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_retrieve_report_data_function_timeout);
+ options.SetTimeout(process_sp->GetUtilityExpressionTimeout());
options.SetPrefix(address_sanitizer_retrieve_report_data_prefix);
options.SetAutoApplyFixIts(false);
options.SetLanguage(eLanguageTypeObjC_plus_plus);
@@ -289,7 +287,7 @@ void AddressSanitizerRuntime::Activate() {
const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType(
symbol_name, eSymbolTypeCode);
- if (symbol == NULL)
+ if (symbol == nullptr)
return;
if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
diff --git a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
index 1439f86e586f0..0771e624ff6b8 100644
--- a/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/ASan/ASanRuntime.h
@@ -1,9 +1,8 @@
-//===-- AddressSanitizerRuntime.h -------------------------------*- C++ -*-===//
+//===-- ASanRuntime.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
index 32da327ee465c..dfe61316b0425 100644
--- a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
@@ -1,9 +1,8 @@
//===-- MainThreadCheckerRuntime.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,6 +24,8 @@
#include "lldb/Utility/RegularExpression.h"
#include "Plugins/Process/Utility/HistoryThread.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -239,7 +240,7 @@ lldb::ThreadCollectionSP
MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
- threads.reset(new ThreadCollection());
+ threads = std::make_shared<ThreadCollection>();
ProcessSP process_sp = GetProcessSP();
@@ -260,11 +261,8 @@ MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP thread_id_obj =
info->GetObjectForDotSeparatedPath("tid");
tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
-
- uint32_t stop_id = 0;
- bool stop_id_is_valid = false;
- HistoryThread *history_thread =
- new HistoryThread(*process_sp, tid, PCs, stop_id, stop_id_is_valid);
+
+ HistoryThread *history_thread = new HistoryThread(*process_sp, tid, PCs);
ThreadSP new_thread_sp(history_thread);
// Save this in the Process' ExtendedThreadList so a strong pointer retains
diff --git a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
index 516d9fef5e8e2..1dcbc0f6bc89a 100644
--- a/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
@@ -1,9 +1,8 @@
//===-- MainThreadCheckerRuntime.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
index 6ce50f5c68399..89f2139db71b1 100644
--- a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
@@ -1,9 +1,8 @@
//===-- TSanRuntime.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,6 +30,8 @@
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -59,8 +60,6 @@ lldb::InstrumentationRuntimeType ThreadSanitizerRuntime::GetTypeStatic() {
ThreadSanitizerRuntime::~ThreadSanitizerRuntime() { Deactivate(); }
-static constexpr std::chrono::seconds g_retrieve_data_function_timeout(2);
-
const char *thread_sanitizer_retrieve_report_data_prefix = R"(
extern "C"
{
@@ -317,7 +316,7 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
options.SetTryAllThreads(true);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_retrieve_data_function_timeout);
+ options.SetTimeout(process_sp->GetUtilityExpressionTimeout());
options.SetPrefix(thread_sanitizer_retrieve_report_data_prefix);
options.SetAutoApplyFixIts(false);
options.SetLanguage(eLanguageTypeObjC_plus_plus);
@@ -901,7 +900,7 @@ void ThreadSanitizerRuntime::Activate() {
const Symbol *symbol = GetRuntimeModuleSP()->FindFirstSymbolWithNameAndType(
symbol_name, eSymbolTypeCode);
- if (symbol == NULL)
+ if (symbol == nullptr)
return;
if (!symbol->ValueIsAddress() || !symbol->GetAddressRef().IsValid())
@@ -1031,10 +1030,8 @@ static void AddThreadsForPath(const std::string &path,
o->GetObjectForDotSeparatedPath("thread_os_id");
tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
- uint32_t stop_id = 0;
- bool stop_id_is_valid = false;
HistoryThread *history_thread =
- new HistoryThread(*process_sp, tid, pcs, stop_id, stop_id_is_valid);
+ new HistoryThread(*process_sp, tid, pcs);
ThreadSP new_thread_sp(history_thread);
new_thread_sp->SetName(GenerateThreadName(path, o, info).c_str());
@@ -1051,7 +1048,7 @@ lldb::ThreadCollectionSP
ThreadSanitizerRuntime::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
- threads.reset(new ThreadCollection());
+ threads = std::make_shared<ThreadCollection>();
if (info->GetObjectForDotSeparatedPath("instrumentation_class")
->GetStringValue() != "ThreadSanitizer")
diff --git a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
index e6482d394efa1..db8bb1db79960 100644
--- a/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.h
@@ -1,9 +1,8 @@
-//===-- ThreadSanitizerRuntime.h --------------------------------*- C++ -*-===//
+//===-- TSanRuntime.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
index 1e9280c8c0643..367098bb448e8 100644
--- a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
+++ b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.cpp
@@ -1,9 +1,8 @@
//===-- UBSanRuntime.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,6 +31,8 @@
#include "lldb/Utility/Stream.h"
#include <ctype.h>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -130,7 +131,7 @@ StructuredData::ObjectSP UndefinedBehaviorSanitizerRuntime::RetrieveReportData(
options.SetTryAllThreads(true);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(std::chrono::seconds(2));
+ options.SetTimeout(process_sp->GetUtilityExpressionTimeout());
options.SetPrefix(ub_sanitizer_retrieve_report_data_prefix);
options.SetAutoApplyFixIts(false);
options.SetLanguage(eLanguageTypeObjC_plus_plus);
@@ -304,7 +305,7 @@ lldb::ThreadCollectionSP
UndefinedBehaviorSanitizerRuntime::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
- threads.reset(new ThreadCollection());
+ threads = std::make_shared<ThreadCollection>();
ProcessSP process_sp = GetProcessSP();
@@ -326,10 +327,7 @@ UndefinedBehaviorSanitizerRuntime::GetBacktracesFromExtendedStopInfo(
info->GetObjectForDotSeparatedPath("tid");
tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
- uint32_t stop_id = 0;
- bool stop_id_is_valid = false;
- HistoryThread *history_thread =
- new HistoryThread(*process_sp, tid, PCs, stop_id, stop_id_is_valid);
+ HistoryThread *history_thread = new HistoryThread(*process_sp, tid, PCs);
ThreadSP new_thread_sp(history_thread);
std::string stop_reason_description = GetStopReasonDescription(info);
new_thread_sp->SetName(stop_reason_description.c_str());
diff --git a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h
index 8f138fc12073e..1d854b7bf06f6 100644
--- a/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h
+++ b/source/Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h
@@ -1,9 +1,8 @@
-//===-- UndefinedBehaviorSanitizerRuntime.h ---------------------*- C++ -*-===//
+//===-- UBSanRuntime.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
index 3040b8b390523..140d09ed43cfa 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
@@ -1,9 +1,8 @@
//===-- JITLoaderGDB.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,17 +29,13 @@
#include "JITLoaderGDB.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//------------------------------------------------------------------
// Debug Interface Structures
-//------------------------------------------------------------------
-typedef enum {
- JIT_NOACTION = 0,
- JIT_REGISTER_FN,
- JIT_UNREGISTER_FN
-} jit_actions_t;
+enum jit_actions_t { JIT_NOACTION = 0, JIT_REGISTER_FN, JIT_UNREGISTER_FN };
template <typename ptr_t> struct jit_code_entry {
ptr_t next_entry; // pointer
@@ -58,11 +53,27 @@ template <typename ptr_t> struct jit_descriptor {
namespace {
+enum EnableJITLoaderGDB {
+ eEnableJITLoaderGDBDefault,
+ eEnableJITLoaderGDBOn,
+ eEnableJITLoaderGDBOff,
+};
+
+static constexpr OptionEnumValueElement g_enable_jit_loader_gdb_enumerators[] = {
+ {eEnableJITLoaderGDBDefault, "default", "Enable JIT compilation interface "
+ "for all platforms except macOS"},
+ {eEnableJITLoaderGDBOn, "on", "Enable JIT compilation interface"},
+ {eEnableJITLoaderGDBOff, "off", "Disable JIT compilation interface"}
+ };
+
static constexpr PropertyDefinition g_properties[] = {
- {"enable-jit-breakpoint", OptionValue::eTypeBoolean, true, true, nullptr,
- {}, "Enable breakpoint on __jit_debug_register_code."}};
+ {"enable", OptionValue::eTypeEnum, true,
+ eEnableJITLoaderGDBDefault, nullptr,
+ OptionEnumValues(g_enable_jit_loader_gdb_enumerators),
+ "Enable GDB's JIT compilation interface (default: enabled on "
+ "all platforms except macOS)"}};
-enum { ePropertyEnableJITBreakpoint };
+enum { ePropertyEnable, ePropertyEnableJITBreakpoint };
class PluginProperties : public Properties {
public:
@@ -71,14 +82,14 @@ public:
}
PluginProperties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
m_collection_sp->Initialize(g_properties);
}
- bool GetEnableJITBreakpoint() const {
- return m_collection_sp->GetPropertyAtIndexAsBoolean(
- nullptr, ePropertyEnableJITBreakpoint,
- g_properties[ePropertyEnableJITBreakpoint].default_uint_value != 0);
+ EnableJITLoaderGDB GetEnable() const {
+ return (EnableJITLoaderGDB)m_collection_sp->GetPropertyAtIndexAsEnumeration(
+ nullptr, ePropertyEnable,
+ g_properties[ePropertyEnable].default_uint_value);
}
};
@@ -160,13 +171,8 @@ void JITLoaderGDB::ModulesDidLoad(ModuleList &module_list) {
SetJITBreakpoint(module_list);
}
-//------------------------------------------------------------------
// Setup the JIT Breakpoint
-//------------------------------------------------------------------
void JITLoaderGDB::SetJITBreakpoint(lldb_private::ModuleList &module_list) {
- if (!GetGlobalPluginProperties()->GetEnableJITBreakpoint())
- return;
-
if (DidSetJITBreakpoint())
return;
@@ -317,6 +323,10 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) {
FileSpec(jit_name), symbolfile_addr, symbolfile_size);
if (module_sp && module_sp->GetObjectFile()) {
+ // Object formats (like ELF) have no representation for a JIT type.
+ // We will get it wrong, if we deduce it from the header.
+ module_sp->GetObjectFile()->SetType(ObjectFile::eTypeJIT);
+
// load the symbol table right away
module_sp->GetObjectFile()->GetSymtab();
@@ -391,9 +401,7 @@ bool JITLoaderGDB::ReadJITDescriptorImpl(bool all_entries) {
return false; // Continue Running.
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString JITLoaderGDB::GetPluginNameStatic() {
static ConstString g_name("gdb");
return g_name;
@@ -401,9 +409,21 @@ lldb_private::ConstString JITLoaderGDB::GetPluginNameStatic() {
JITLoaderSP JITLoaderGDB::CreateInstance(Process *process, bool force) {
JITLoaderSP jit_loader_sp;
- ArchSpec arch(process->GetTarget().GetArchitecture());
- if (arch.GetTriple().getVendor() != llvm::Triple::Apple)
- jit_loader_sp.reset(new JITLoaderGDB(process));
+ bool enable;
+ switch (GetGlobalPluginProperties()->GetEnable()) {
+ case EnableJITLoaderGDB::eEnableJITLoaderGDBOn:
+ enable = true;
+ break;
+ case EnableJITLoaderGDB::eEnableJITLoaderGDBOff:
+ enable = false;
+ break;
+ case EnableJITLoaderGDB::eEnableJITLoaderGDBDefault:
+ ArchSpec arch(process->GetTarget().GetArchitecture());
+ enable = arch.GetTriple().getVendor() != llvm::Triple::Apple;
+ break;
+ }
+ if (enable)
+ jit_loader_sp = std::make_shared<JITLoaderGDB>(process);
return jit_loader_sp;
}
@@ -433,7 +453,7 @@ bool JITLoaderGDB::DidSetJITBreakpoint() const {
}
addr_t JITLoaderGDB::GetSymbolAddress(ModuleList &module_list,
- const ConstString &name,
+ ConstString name,
SymbolType symbol_type) const {
SymbolContextList target_symbols;
Target &target = m_process->GetTarget();
diff --git a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
index a220166012931..2a2537c3edd41 100644
--- a/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
+++ b/source/Plugins/JITLoader/GDB/JITLoaderGDB.h
@@ -1,9 +1,8 @@
//===-- JITLoaderGDB.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,9 +20,7 @@ public:
~JITLoaderGDB() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -37,16 +34,12 @@ public:
static void DebuggerInitialize(lldb_private::Debugger &debugger);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
// JITLoader interface
- //------------------------------------------------------------------
void DidAttach() override;
void DidLaunch() override;
@@ -55,7 +48,7 @@ public:
private:
lldb::addr_t GetSymbolAddress(lldb_private::ModuleList &module_list,
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
lldb::SymbolType symbol_type) const;
void SetJITBreakpoint(lldb_private::ModuleList &module_list);
diff --git a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 40200503a8a7e..87b5b5947f358 100644
--- a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -1,9 +1,8 @@
//===-- BlockPointer.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -150,7 +149,7 @@ public:
// maybe return false if the block pointer is, say, null
bool MightHaveChildren() override { return true; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
if (!m_block_struct_type.IsValid())
return UINT32_MAX;
diff --git a/source/Plugins/Language/CPlusPlus/BlockPointer.h b/source/Plugins/Language/CPlusPlus/BlockPointer.h
index e5008a8f36765..624c17a6a6af8 100644
--- a/source/Plugins/Language/CPlusPlus/BlockPointer.h
+++ b/source/Plugins/Language/CPlusPlus/BlockPointer.h
@@ -1,9 +1,8 @@
//===-- BlockPointer.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 982b286d0f05d..44b9e5e24ccd9 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1,9 +1,8 @@
//===-- CPlusPlusLanguage.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -57,9 +56,7 @@ lldb_private::ConstString CPlusPlusLanguage::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString CPlusPlusLanguage::GetPluginName() {
return GetPluginNameStatic();
@@ -67,9 +64,7 @@ lldb_private::ConstString CPlusPlusLanguage::GetPluginName() {
uint32_t CPlusPlusLanguage::GetPluginVersion() { return 1; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
Language *CPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
if (Language::LanguageIsCPlusPlus(language))
@@ -419,61 +414,49 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
.SetShowMembersOneLiner(false)
.SetHideItemNames(false);
-#ifndef LLDB_DISABLE_PYTHON
- lldb::TypeSummaryImplSP std_string_summary_sp(new CXXFunctionSummaryFormat(
- stl_summary_flags,
- lldb_private::formatters::LibcxxStringSummaryProviderASCII,
- "std::string summary provider"));
- lldb::TypeSummaryImplSP std_stringu16_summary_sp(new CXXFunctionSummaryFormat(
- stl_summary_flags,
- lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
- "std::u16string summary provider"));
- lldb::TypeSummaryImplSP std_stringu32_summary_sp(new CXXFunctionSummaryFormat(
- stl_summary_flags,
- lldb_private::formatters::LibcxxStringSummaryProviderUTF32,
- "std::u32string summary provider"));
- lldb::TypeSummaryImplSP std_wstring_summary_sp(new CXXFunctionSummaryFormat(
- stl_summary_flags, lldb_private::formatters::LibcxxWStringSummaryProvider,
- "std::wstring summary provider"));
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxStringSummaryProviderASCII,
+ "std::string summary provider",
+ ConstString("^std::__[[:alnum:]]+::string$"), stl_summary_flags,
+ true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxStringSummaryProviderASCII,
+ "std::string summary provider",
+ ConstString("^std::__[[:alnum:]]+::basic_string<char, "
+ "std::__[[:alnum:]]+::char_traits<char>, "
+ "std::__[[:alnum:]]+::allocator<char> >$"),
+ stl_summary_flags, true);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__1::string"), std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__ndk1::string"), std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__1::basic_string<char, std::__1::char_traits<char>, "
- "std::__1::allocator<char> >"),
- std_string_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString(
- "std::__1::basic_string<char16_t, std::__1::char_traits<char16_t>, "
- "std::__1::allocator<char16_t> >"),
- std_stringu16_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString(
- "std::__1::basic_string<char32_t, std::__1::char_traits<char32_t>, "
- "std::__1::allocator<char32_t> >"),
- std_stringu32_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__ndk1::basic_string<char, "
- "std::__ndk1::char_traits<char>, "
- "std::__ndk1::allocator<char> >"),
- std_string_summary_sp);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxStringSummaryProviderUTF16,
+ "std::u16string summary provider",
+ ConstString(
+ "^std::__[[:alnum:]]+::basic_string<char16_t, "
+ "std::__[[:alnum:]]+::char_traits<char16_t>, "
+ "std::__[[:alnum:]]+::allocator<char16_t> >$"),
+ stl_summary_flags, true);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__1::wstring"), std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__ndk1::wstring"), std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__1::basic_string<wchar_t, "
- "std::__1::char_traits<wchar_t>, "
- "std::__1::allocator<wchar_t> >"),
- std_wstring_summary_sp);
- cpp_category_sp->GetTypeSummariesContainer()->Add(
- ConstString("std::__ndk1::basic_string<wchar_t, "
- "std::__ndk1::char_traits<wchar_t>, "
- "std::__ndk1::allocator<wchar_t> >"),
- std_wstring_summary_sp);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxStringSummaryProviderUTF32,
+ "std::u32string summary provider",
+ ConstString(
+ "^std::__[[:alnum:]]+::basic_string<char32_t, "
+ "std::__[[:alnum:]]+::char_traits<char32_t>, "
+ "std::__[[:alnum:]]+::allocator<char32_t> >$"),
+ stl_summary_flags, true);
+
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxWStringSummaryProvider,
+ "std::wstring summary provider",
+ ConstString("^std::__[[:alnum:]]+::wstring$"),
+ stl_summary_flags, true);
+ AddCXXSummary(cpp_category_sp,
+ lldb_private::formatters::LibcxxWStringSummaryProvider,
+ "std::wstring summary provider",
+ ConstString("^std::__[[:alnum:]]+::basic_string<wchar_t, "
+ "std::__[[:alnum:]]+::char_traits<wchar_t>, "
+ "std::__[[:alnum:]]+::allocator<wchar_t> >$"),
+ stl_summary_flags, true);
SyntheticChildren::Flags stl_synth_flags;
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
@@ -485,54 +468,55 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
cpp_category_sp,
lldb_private::formatters::LibcxxBitsetSyntheticFrontEndCreator,
"libc++ std::bitset synthetic children",
- ConstString("^std::__(ndk)?1::bitset<.+>(( )?&)?$"), stl_deref_flags,
+ ConstString("^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$"), stl_deref_flags,
true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator,
"libc++ std::vector synthetic children",
- ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"), stl_deref_flags,
+ ConstString("^std::__[[:alnum:]]+::vector<.+>(( )?&)?$"), stl_deref_flags,
true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdForwardListSyntheticFrontEndCreator,
"libc++ std::forward_list synthetic children",
- ConstString("^std::__(ndk)?1::forward_list<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$"),
stl_synth_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdListSyntheticFrontEndCreator,
"libc++ std::list synthetic children",
- ConstString("^std::__(ndk)?1::list<.+>(( )?&)?$"), stl_synth_flags, true);
+ ConstString("^std::__[[:alnum:]]+::list<.+>(( )?&)?$"), stl_deref_flags,
+ true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
"libc++ std::map synthetic children",
- ConstString("^std::__(ndk)?1::map<.+> >(( )?&)?$"), stl_synth_flags,
+ ConstString("^std::__[[:alnum:]]+::map<.+> >(( )?&)?$"), stl_synth_flags,
true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
"libc++ std::set synthetic children",
- ConstString("^std::__(ndk)?1::set<.+> >(( )?&)?$"), stl_deref_flags,
+ ConstString("^std::__[[:alnum:]]+::set<.+> >(( )?&)?$"), stl_deref_flags,
true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
"libc++ std::multiset synthetic children",
- ConstString("^std::__(ndk)?1::multiset<.+> >(( )?&)?$"), stl_deref_flags,
- true);
+ ConstString("^std::__[[:alnum:]]+::multiset<.+> >(( )?&)?$"),
+ stl_deref_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdMapSyntheticFrontEndCreator,
"libc++ std::multimap synthetic children",
- ConstString("^std::__(ndk)?1::multimap<.+> >(( )?&)?$"), stl_synth_flags,
- true);
+ ConstString("^std::__[[:alnum:]]+::multimap<.+> >(( )?&)?$"),
+ stl_synth_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEndCreator,
"libc++ std::unordered containers synthetic children",
- ConstString("^(std::__(ndk)?1::)unordered_(multi)?(map|set)<.+> >$"),
+ ConstString("^(std::__[[:alnum:]]+::)unordered_(multi)?(map|set)<.+> >$"),
stl_synth_flags, true);
AddCXXSynthetic(
cpp_category_sp,
@@ -542,29 +526,29 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
true);
AddCXXSynthetic(cpp_category_sp, LibcxxQueueFrontEndCreator,
"libc++ std::queue synthetic children",
- ConstString("^std::__(ndk)?1::queue<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::queue<.+>(( )?&)?$"),
stl_synth_flags, true);
AddCXXSynthetic(cpp_category_sp, LibcxxTupleFrontEndCreator,
"libc++ std::tuple synthetic children",
- ConstString("^std::__(ndk)?1::tuple<.*>(( )?&)?$"), stl_synth_flags,
- true);
+ ConstString("^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$"),
+ stl_synth_flags, true);
AddCXXSynthetic(cpp_category_sp, LibcxxOptionalFrontEndCreator,
"libc++ std::optional synthetic children",
- ConstString("^std::__(ndk)?1::optional<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::optional<.+>(( )?&)?$"),
stl_synth_flags, true);
AddCXXSynthetic(cpp_category_sp, LibcxxVariantFrontEndCreator,
"libc++ std::variant synthetic children",
- ConstString("^std::__(ndk)?1::variant<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::variant<.+>(( )?&)?$"),
stl_synth_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxAtomicSyntheticFrontEndCreator,
"libc++ std::atomic synthetic children",
- ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_synth_flags, true);
+ ConstString("^std::__[[:alnum:]]+::atomic<.+>$"), stl_synth_flags, true);
cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
RegularExpressionSP(new RegularExpression(
- llvm::StringRef("^(std::__(ndk)?1::)deque<.+>(( )?&)?$"))),
+ llvm::StringRef("^(std::__[[:alnum:]]+::)deque<.+>(( )?&)?$"))),
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
@@ -573,94 +557,96 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
cpp_category_sp,
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
"shared_ptr synthetic children",
- ConstString("^(std::__(ndk)?1::)shared_ptr<.+>(( )?&)?$"),
+ ConstString("^(std::__[[:alnum:]]+::)shared_ptr<.+>(( )?&)?$"),
stl_synth_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator,
"weak_ptr synthetic children",
- ConstString("^(std::__(ndk)?1::)weak_ptr<.+>(( )?&)?$"), stl_synth_flags,
- true);
+ ConstString("^(std::__[[:alnum:]]+::)weak_ptr<.+>(( )?&)?$"),
+ stl_synth_flags, true);
AddCXXSummary(
cpp_category_sp, lldb_private::formatters::LibcxxFunctionSummaryProvider,
"libc++ std::function summary provider",
- ConstString("^std::__(ndk)?1::function<.+>$"), stl_summary_flags, true);
+ ConstString("^std::__[[:alnum:]]+::function<.+>$"), stl_summary_flags,
+ true);
stl_summary_flags.SetDontShowChildren(false);
stl_summary_flags.SetSkipPointers(false);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::bitset summary provider",
- ConstString("^std::__(ndk)?1::bitset<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::bitset<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::vector summary provider",
- ConstString("^std::__(ndk)?1::vector<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::vector<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::list summary provider",
- ConstString("^std::__(ndk)?1::forward_list<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::forward_list<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::list summary provider",
- ConstString("^std::__(ndk)?1::list<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::list<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::map summary provider",
- ConstString("^std::__(ndk)?1::map<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::map<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::deque summary provider",
- ConstString("^std::__(ndk)?1::deque<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::deque<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::queue summary provider",
- ConstString("^std::__(ndk)?1::queue<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::queue<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::set summary provider",
- ConstString("^std::__(ndk)?1::set<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::set<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::multiset summary provider",
- ConstString("^std::__(ndk)?1::multiset<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::multiset<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::multimap summary provider",
- ConstString("^std::__(ndk)?1::multimap<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::multimap<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(
cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider,
"libc++ std::unordered containers summary provider",
- ConstString("^(std::__(ndk)?1::)unordered_(multi)?(map|set)<.+> >$"),
+ ConstString("^(std::__[[:alnum:]]+::)unordered_(multi)?(map|set)<.+> >$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp, LibcxxContainerSummaryProvider,
"libc++ std::tuple summary provider",
- ConstString("^std::__(ndk)?1::tuple<.*>(( )?&)?$"), stl_summary_flags,
- true);
+ ConstString("^std::__[[:alnum:]]+::tuple<.*>(( )?&)?$"),
+ stl_summary_flags, true);
AddCXXSummary(
cpp_category_sp, lldb_private::formatters::LibCxxAtomicSummaryProvider,
"libc++ std::atomic summary provider",
- ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_summary_flags, true);
+ ConstString("^std::__[[:alnum:]]+::atomic<.+>$"), stl_summary_flags,
+ true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxOptionalSummaryProvider,
"libc++ std::optional summary provider",
- ConstString("^std::__(ndk)?1::optional<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::optional<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxVariantSummaryProvider,
"libc++ std::variant summary provider",
- ConstString("^std::__(ndk)?1::variant<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::variant<.+>(( )?&)?$"),
stl_summary_flags, true);
stl_summary_flags.SetSkipPointers(true);
@@ -668,27 +654,27 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxSmartPointerSummaryProvider,
"libc++ std::shared_ptr summary provider",
- ConstString("^std::__(ndk)?1::shared_ptr<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::shared_ptr<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSummary(cpp_category_sp,
lldb_private::formatters::LibcxxSmartPointerSummaryProvider,
"libc++ std::weak_ptr summary provider",
- ConstString("^std::__(ndk)?1::weak_ptr<.+>(( )?&)?$"),
+ ConstString("^std::__[[:alnum:]]+::weak_ptr<.+>(( )?&)?$"),
stl_summary_flags, true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator,
"std::vector iterator synthetic children",
- ConstString("^std::__(ndk)?1::__wrap_iter<.+>$"), stl_synth_flags, true);
+ ConstString("^std::__[[:alnum:]]+::__wrap_iter<.+>$"), stl_synth_flags,
+ true);
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator,
"std::map iterator synthetic children",
- ConstString("^std::__(ndk)?1::__map_iterator<.+>$"), stl_synth_flags,
+ ConstString("^std::__[[:alnum:]]+::__map_iterator<.+>$"), stl_synth_flags,
true);
-#endif
}
static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
@@ -759,8 +745,6 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"std::char_traits<wchar_t>, std::allocator<wchar_t> >"),
cxx11_wstring_summary_sp);
-#ifndef LLDB_DISABLE_PYTHON
-
SyntheticChildren::Flags stl_synth_flags;
stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
false);
@@ -849,7 +833,6 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
"libstdc++ std::weak_ptr summary provider",
ConstString("^std::weak_ptr<.+>(( )?&)?$"), stl_summary_flags,
true);
-#endif
}
static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
@@ -874,7 +857,6 @@ static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
.SetShowMembersOneLiner(false)
.SetHideItemNames(false);
-#ifndef LLDB_DISABLE_PYTHON
// FIXME because of a bug in the FormattersContainer we need to add a summary
// for both X* and const X* (<rdar://problem/12717717>)
AddCXXSummary(
@@ -927,13 +909,12 @@ static void LoadSystemFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
AddCXXSummary(
cpp_category_sp, lldb_private::formatters::Char16SummaryProvider,
"unichar summary provider", ConstString("unichar"), widechar_flags);
-#endif
}
std::unique_ptr<Language::TypeScavenger> CPlusPlusLanguage::GetTypeScavenger() {
class CPlusPlusTypeScavenger : public Language::ImageListTypeScavenger {
public:
- virtual CompilerType AdjustForInclusion(CompilerType &candidate) override {
+ CompilerType AdjustForInclusion(CompilerType &candidate) override {
LanguageType lang_type(candidate.GetMinimumLanguage());
if (!Language::LanguageIsC(lang_type) &&
!Language::LanguageIsCPlusPlus(lang_type))
@@ -954,8 +935,8 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
llvm::call_once(g_initialize, [this]() -> void {
DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
if (g_category) {
- LoadLibCxxFormatters(g_category);
LoadLibStdcppFormatters(g_category);
+ LoadLibCxxFormatters(g_category);
LoadSystemFormatters(g_category);
}
});
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
index 3c8ca96e81f65..d30e560807323 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
@@ -1,9 +1,8 @@
//===-- CPlusPlusLanguage.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,7 +31,7 @@ public:
: m_full(), m_basename(), m_context(), m_arguments(), m_qualifiers(),
m_parsed(false), m_parse_error(false) {}
- MethodName(const ConstString &s)
+ MethodName(ConstString s)
: m_full(s), m_basename(), m_context(), m_arguments(), m_qualifiers(),
m_parsed(false), m_parse_error(false) {}
@@ -46,7 +45,7 @@ public:
return (bool)m_full;
}
- const ConstString &GetFullName() const { return m_full; }
+ ConstString GetFullName() const { return m_full; }
std::string GetScopeQualifiedName();
@@ -93,9 +92,7 @@ public:
const Highlighter *GetHighlighter() const override { return &m_highlighter; }
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -128,9 +125,7 @@ public:
FindAlternateFunctionManglings(const ConstString mangled,
std::set<ConstString> &candidates);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
index b32fe9588965e..932db17b964a5 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp
@@ -1,9 +1,8 @@
//===-- CPlusPlusNameParser.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -641,6 +640,8 @@ static const llvm::StringMap<tok::TokenKind> &GetKeywordsMap() {
}
void CPlusPlusNameParser::ExtractTokens() {
+ if (m_text.empty())
+ return;
clang::Lexer lexer(clang::SourceLocation(), GetLangOptions(), m_text.data(),
m_text.data(), m_text.data() + m_text.size());
const auto &kw_map = GetKeywordsMap();
diff --git a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
index d46a53a7a7044..414c3a0091577 100644
--- a/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
+++ b/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.h
@@ -1,9 +1,8 @@
//===-- CPlusPlusNameParser.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
index 24185b3144668..959079070accc 100644
--- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -1,9 +1,8 @@
//===-- CxxStringTypes.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
index 8e2ec44dc71c2..92bef2382eac1 100644
--- a/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
+++ b/source/Plugins/Language/CPlusPlus/CxxStringTypes.h
@@ -1,10 +1,9 @@
//===-- CxxStringTypes.h ----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 7e8c06bd4c754..abe89035c5323 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -1,9 +1,8 @@
//===-- LibCxx.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,7 +18,6 @@
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/VectorIterator.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
@@ -28,6 +26,8 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
@@ -68,7 +68,7 @@ bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
if (process == nullptr)
return false;
- CPPLanguageRuntime *cpp_runtime = process->GetCPPLanguageRuntime();
+ CPPLanguageRuntime *cpp_runtime = CPPLanguageRuntime::Get(*process);
if (!cpp_runtime)
return false;
@@ -300,10 +300,10 @@ bool lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
}
size_t lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
- if (name == ConstString("first"))
+ GetIndexOfChildWithName(ConstString name) {
+ if (name == "first")
return 0;
- if (name == ConstString("second"))
+ if (name == "second")
return 1;
return UINT32_MAX;
}
@@ -430,12 +430,12 @@ bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
}
size_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
- if (name == ConstString("__ptr_"))
+ GetIndexOfChildWithName(ConstString name) {
+ if (name == "__ptr_")
return 0;
- if (name == ConstString("count"))
+ if (name == "count")
return 1;
- if (name == ConstString("weak_count"))
+ if (name == "weak_count")
return 2;
return UINT32_MAX;
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxx.h b/source/Plugins/Language/CPlusPlus/LibCxx.h
index 224a540eda041..214f5512e4a50 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -1,10 +1,9 @@
//===-- LibCxx.h ---------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -67,7 +66,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
~LibCxxMapIteratorSyntheticFrontEnd() override;
@@ -96,7 +95,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
~LibcxxSharedPtrSyntheticFrontEnd() override;
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index dea52e2f30b6b..b4e7a1703e46a 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -1,10 +1,9 @@
//===-- LibCxxAtomic.cpp ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,13 +13,68 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
+//
+// We are supporting two versions of libc++ std::atomic
+//
+// Given std::atomic<int> i;
+//
+// The previous version of std::atomic was laid out like this
+//
+// (lldb) frame var -L -R i
+// 0x00007ffeefbff9a0: (std::__1::atomic<int>) i = {
+// 0x00007ffeefbff9a0: std::__1::__atomic_base<int, true> = {
+// 0x00007ffeefbff9a0: std::__1::__atomic_base<int, false> = {
+// 0x00007ffeefbff9a0: __a_ = 5
+// }
+// }
+// }
+//
+// In this case we need to obtain __a_ and the current version is laid out as so
+//
+// (lldb) frame var -L -R i
+// 0x00007ffeefbff9b0: (std::__1::atomic<int>) i = {
+// 0x00007ffeefbff9b0: std::__1::__atomic_base<int, true> = {
+// 0x00007ffeefbff9b0: std::__1::__atomic_base<int, false> = {
+// 0x00007ffeefbff9b0: __a_ = {
+// 0x00007ffeefbff9b0: std::__1::__cxx_atomic_base_impl<int> = {
+// 0x00007ffeefbff9b0: __a_value = 5
+// }
+// }
+// }
+// }
+//}
+//
+// In this case we need to obtain __a_value
+//
+// The below method covers both cases and returns the relevant member as a
+// ValueObjectSP
+//
+ValueObjectSP
+lldb_private::formatters::GetLibCxxAtomicValue(ValueObject &valobj) {
+ ValueObjectSP non_sythetic = valobj.GetNonSyntheticValue();
+ if (!non_sythetic)
+ return {};
+
+ ValueObjectSP member__a_ =
+ non_sythetic->GetChildMemberWithName(ConstString("__a_"), true);
+ if (!member__a_)
+ return {};
+
+ ValueObjectSP member__a_value =
+ member__a_->GetChildMemberWithName(ConstString("__a_value"), true);
+ if (!member__a_value)
+ return member__a_;
+
+ return member__a_value;
+}
+
bool lldb_private::formatters::LibCxxAtomicSummaryProvider(
ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
- static ConstString g___a_("__a_");
- if (ValueObjectSP child = valobj.GetChildMemberWithName(g___a_, true)) {
+ if (ValueObjectSP atomic_value = GetLibCxxAtomicValue(valobj)) {
std::string summary;
- if (child->GetSummaryAsCString(summary, options) && summary.size() > 0) {
+ if (atomic_value->GetSummaryAsCString(summary, options) &&
+ summary.size() > 0) {
stream.Printf("%s", summary.c_str());
return true;
}
@@ -45,7 +99,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
lldb::ValueObjectSP GetSyntheticValue() override;
@@ -60,9 +114,9 @@ lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
: SyntheticChildrenFrontEnd(*valobj_sp), m_real_child(nullptr) {}
bool lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::Update() {
- static ConstString g___a_("__a_");
-
- m_real_child = m_backend.GetChildMemberWithName(g___a_, true).get();
+ ValueObjectSP atomic_value = GetLibCxxAtomicValue(m_backend);
+ if (atomic_value)
+ m_real_child = GetLibCxxAtomicValue(m_backend).get();
return false;
}
@@ -84,7 +138,7 @@ lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
}
size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
: UINT32_MAX;
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
index a9d948bf189c4..8be833dd82f6e 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
+++ b/source/Plugins/Language/CPlusPlus/LibCxxAtomic.h
@@ -1,10 +1,9 @@
//===-- LibCxxAtomic.h -------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,9 @@
namespace lldb_private {
namespace formatters {
+
+lldb::ValueObjectSP GetLibCxxAtomicValue(ValueObject &valobj);
+
bool LibCxxAtomicSummaryProvider(ValueObject &valobj, Stream &stream,
const TypeSummaryOptions &options);
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp b/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
index 489ac4d960721..815dafb6c7242 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxBitset.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@ class BitsetFrontEnd : public SyntheticChildrenFrontEnd {
public:
BitsetFrontEnd(ValueObject &valobj);
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return formatters::ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
index 390483d02668b..79c7434f617f8 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxInitializerList.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,7 +33,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
ValueObject *m_start;
@@ -109,7 +108,7 @@ bool lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
}
size_t lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
if (!m_start)
return UINT32_MAX;
return ExtractIndexFromString(name.GetCString());
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
index 81606b573ceab..f5281f2ce532b 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -112,7 +111,7 @@ private:
class AbstractListFrontEnd : public SyntheticChildrenFrontEnd {
public:
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return ExtractIndexFromString(name.GetCString());
}
bool MightHaveChildren() override { return true; }
@@ -385,7 +384,7 @@ lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(size_t idx) {
if (current_sp->GetName() == g_next) {
ProcessSP process_sp(current_sp->GetProcessSP());
if (!process_sp)
- return nullptr;
+ return lldb::ValueObjectSP();
// if we grabbed the __next_ pointer, then the child is one pointer deep-er
lldb::addr_t addr = current_sp->GetParent()->GetPointerValue();
@@ -393,6 +392,8 @@ lldb::ValueObjectSP ListFrontEnd::GetChildAtIndex(size_t idx) {
ExecutionContext exe_ctx(process_sp);
current_sp =
CreateValueObjectFromAddress("__value_", addr, exe_ctx, m_element_type);
+ if (!current_sp)
+ return lldb::ValueObjectSP();
}
// we need to copy current_sp into a new object otherwise we will end up with
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
index 429569d579287..619c718a1c1b9 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxMap.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -185,7 +184,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
bool GetDataType();
@@ -453,7 +452,7 @@ bool lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
}
size_t lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
return ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp b/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
index 762b824f262a8..116021588848c 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxOptional.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxOptional.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@ public:
Update();
}
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return formatters::ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp b/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
index c4e0b66d4272e..4b72089c6ba2e 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxQueue.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@ public:
Update();
}
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return m_container_sp ? m_container_sp->GetIndexOfChildWithName(name)
: UINT32_MAX;
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp b/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
index 9b412a12f532f..8da7460f2275f 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxTuple.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@ public:
Update();
}
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return formatters::ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
index 51ae8cb3184c7..b2c38c915c815 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxUnorderedMap.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,7 +39,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
CompilerType m_element_type;
@@ -210,7 +209,7 @@ bool lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
}
size_t lldb_private::formatters::LibcxxStdUnorderedMapSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
return ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
index e874616c32517..491cf048e4592 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxVariant.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -174,7 +173,7 @@ public:
Update();
}
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return formatters::ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVariant.h b/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
index 04834581963f4..65db5aeaa99de 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
+++ b/source/Plugins/Language/CPlusPlus/LibCxxVariant.h
@@ -1,10 +1,9 @@
//===-- LibCxxVariant.h -------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
index ed405c8751744..bcd7442bc6693 100644
--- a/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp
@@ -1,9 +1,8 @@
//===-- LibCxxVector.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,7 +32,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
ValueObject *m_start;
@@ -54,7 +53,7 @@ public:
bool MightHaveChildren() override { return true; }
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
CompilerType m_bool_type;
@@ -165,7 +164,7 @@ bool lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
}
size_t lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
if (!m_start || !m_finish)
return UINT32_MAX;
return ExtractIndexFromString(name.GetCString());
@@ -272,7 +271,7 @@ bool lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::Update() {
}
size_t lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
if (!m_count || !m_base_data_address)
return UINT32_MAX;
const char *item_name = name.GetCString();
@@ -291,7 +290,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEndCreator(
if (!type.IsValid() || type.GetNumTemplateArguments() == 0)
return nullptr;
CompilerType arg_type = type.GetTypeTemplateArgument(0);
- if (arg_type.GetTypeName() == ConstString("bool"))
+ if (arg_type.GetTypeName() == "bool")
return new LibcxxVectorBoolSyntheticFrontEnd(valobj_sp);
return new LibcxxStdVectorSyntheticFrontEnd(valobj_sp);
}
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
index 695371fc39921..0e0f6663c924b 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp
@@ -1,9 +1,8 @@
//===-- LibStdcpp.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,7 +49,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
ExecutionContextRef m_exe_ctx_ref;
@@ -71,7 +70,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
};
} // end of anonymous namespace
@@ -142,10 +141,10 @@ LibstdcppMapIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
bool LibstdcppMapIteratorSyntheticFrontEnd::MightHaveChildren() { return true; }
size_t LibstdcppMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
- if (name == ConstString("first"))
+ ConstString name) {
+ if (name == "first")
return 0;
- if (name == ConstString("second"))
+ if (name == "second")
return 1;
return UINT32_MAX;
}
@@ -224,8 +223,8 @@ VectorIteratorSyntheticFrontEnd::GetChildAtIndex(size_t idx) {
bool VectorIteratorSyntheticFrontEnd::MightHaveChildren() { return true; }
size_t VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
- if (name == ConstString("item"))
+ ConstString name) {
+ if (name == "item")
return 0;
return UINT32_MAX;
}
@@ -374,8 +373,8 @@ bool LibStdcppSharedPtrSyntheticFrontEnd::Update() { return false; }
bool LibStdcppSharedPtrSyntheticFrontEnd::MightHaveChildren() { return true; }
size_t LibStdcppSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
- if (name == ConstString("_M_ptr"))
+ ConstString name) {
+ if (name == "_M_ptr")
return 0;
return UINT32_MAX;
}
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcpp.h b/source/Plugins/Language/CPlusPlus/LibStdcpp.h
index 1400477dcd0d0..e7f88d667c141 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcpp.h
+++ b/source/Plugins/Language/CPlusPlus/LibStdcpp.h
@@ -1,9 +1,8 @@
//===-- LibStdcpp.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
index 943af6ee81e41..66624e5beb6dc 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp
@@ -1,9 +1,8 @@
//===-- LibStdcppTuple.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
std::vector<ValueObjectSP> m_members;
@@ -96,7 +95,7 @@ size_t LibStdcppTupleSyntheticFrontEnd::CalculateNumChildren() {
}
size_t LibStdcppTupleSyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
+ ConstString name) {
return ExtractIndexFromString(name.GetCString());
}
diff --git a/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
index 9d46e3e3ee58c..3860f960cb3de 100644
--- a/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
+++ b/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
@@ -1,9 +1,8 @@
//===-- LibStdcppUniquePointer.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
bool GetSummary(Stream &stream, const TypeSummaryOptions &options);
@@ -130,13 +129,12 @@ size_t LibStdcppUniquePtrSyntheticFrontEnd::CalculateNumChildren() {
}
size_t LibStdcppUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
- if (name == ConstString("ptr") || name == ConstString("pointer"))
+ ConstString name) {
+ if (name == "ptr" || name == "pointer")
return 0;
- if (name == ConstString("del") || name == ConstString("deleter"))
+ if (name == "del" || name == "deleter")
return 1;
- if (name == ConstString("obj") || name == ConstString("object") ||
- name == ConstString("$$dereference$$"))
+ if (name == "obj" || name == "object" || name == "$$dereference$$")
return 2;
return UINT32_MAX;
}
diff --git a/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
index 84f03e0e30169..248c51acea420 100644
--- a/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
+++ b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
@@ -1,9 +1,8 @@
//===-- MSVCUndecoratedNameParser.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
index 0c49100d8d494..6e20877cae1b5 100644
--- a/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
+++ b/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h
@@ -1,9 +1,8 @@
//===-- MSVCUndecoratedNameParser.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp b/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
index 1fe8482263eb4..a9a1b44731f29 100644
--- a/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
+++ b/source/Plugins/Language/ClangCommon/ClangHighlighter.cpp
@@ -1,14 +1,14 @@
//===-- ClangHighlighter.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ClangHighlighter.h"
+#include "lldb/Host/FileSystem.h"
#include "lldb/Target/Language.h"
#include "lldb/Utility/AnsiTerminal.h"
#include "lldb/Utility/StreamString.h"
@@ -136,7 +136,8 @@ void ClangHighlighter::Highlight(const HighlightStyle &options,
using namespace clang;
FileSystemOptions file_opts;
- FileManager file_mgr(file_opts);
+ FileManager file_mgr(file_opts,
+ FileSystem::Instance().GetVirtualFileSystem());
unsigned line_number = previous_lines.count('\n') + 1U;
diff --git a/source/Plugins/Language/ClangCommon/ClangHighlighter.h b/source/Plugins/Language/ClangCommon/ClangHighlighter.h
index 579c4315228fa..f459f94246973 100644
--- a/source/Plugins/Language/ClangCommon/ClangHighlighter.h
+++ b/source/Plugins/Language/ClangCommon/ClangHighlighter.h
@@ -1,9 +1,8 @@
//===-- ClangHighlighter.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/ObjC/CF.cpp b/source/Plugins/Language/ObjC/CF.cpp
index e3dab5a1442d7..5bca260616ea8 100644
--- a/source/Plugins/Language/ObjC/CF.cpp
+++ b/source/Plugins/Language/ObjC/CF.cpp
@@ -1,10 +1,9 @@
//===-- CF.cpp ----------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -23,6 +21,8 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
@@ -51,9 +51,7 @@ bool lldb_private::formatters::CFBagSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -115,9 +113,7 @@ bool lldb_private::formatters::CFBitVectorSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -140,10 +136,8 @@ bool lldb_private::formatters::CFBitVectorSummaryProvider(
bool is_type_ok = false; // check to see if this is a CFBag we know about
if (descriptor->IsCFType()) {
ConstString type_name(valobj.GetTypeName());
- if (type_name == ConstString("__CFMutableBitVector") ||
- type_name == ConstString("__CFBitVector") ||
- type_name == ConstString("CFMutableBitVectorRef") ||
- type_name == ConstString("CFBitVectorRef")) {
+ if (type_name == "__CFMutableBitVector" || type_name == "__CFBitVector" ||
+ type_name == "CFMutableBitVectorRef" || type_name == "CFBitVectorRef") {
if (valobj.IsPointerType())
is_type_ok = true;
}
@@ -239,9 +233,7 @@ bool lldb_private::formatters::CFBinaryHeapSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
diff --git a/source/Plugins/Language/ObjC/CF.h b/source/Plugins/Language/ObjC/CF.h
index 6945f9e8c9b1c..2abb56d407eb8 100644
--- a/source/Plugins/Language/ObjC/CF.h
+++ b/source/Plugins/Language/ObjC/CF.h
@@ -1,9 +1,8 @@
//===-- CF.h ---------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/ObjC/Cocoa.cpp b/source/Plugins/Language/ObjC/Cocoa.cpp
index 48085378939e6..ddf3953bb512a 100644
--- a/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -1,9 +1,8 @@
//===-- Cocoa.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "lldb/Host/Time.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
@@ -28,6 +26,7 @@
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/bit.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
@@ -43,9 +42,7 @@ bool lldb_private::formatters::NSBundleSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -93,9 +90,7 @@ bool lldb_private::formatters::NSTimeZoneSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -140,9 +135,7 @@ bool lldb_private::formatters::NSNotificationSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -187,9 +180,7 @@ bool lldb_private::formatters::NSMachPortSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -235,9 +226,7 @@ bool lldb_private::formatters::NSIndexSetSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -426,9 +415,7 @@ bool lldb_private::formatters::NSNumberSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -484,10 +471,9 @@ bool lldb_private::formatters::NSNumberSummaryProvider(
return true;
} else {
Status error;
-
- AppleObjCRuntime *runtime =
- llvm::dyn_cast_or_null<AppleObjCRuntime>(
- process_sp->GetObjCLanguageRuntime());
+
+ AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
+ ObjCLanguageRuntime::Get(*process_sp));
const bool new_format =
(runtime && runtime->GetFoundationVersion() >= 1400);
@@ -679,9 +665,7 @@ bool lldb_private::formatters::NSURLSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -750,24 +734,18 @@ bool lldb_private::formatters::NSURLSummaryProvider(
/// distantFuture, except within about 1e-25 second of the reference date.
const int TAGGED_DATE_EXPONENT_BIAS = 0x3ef;
-typedef union {
- struct {
- uint64_t fraction:52; // unsigned
- uint64_t exponent:11; // signed
- uint64_t sign:1;
- };
- uint64_t i;
- double d;
-} DoubleBits;
-typedef union {
- struct {
- uint64_t fraction:52; // unsigned
- uint64_t exponent:7; // signed
- uint64_t sign:1;
- uint64_t unused:4; // placeholder for pointer tag bits
- };
- uint64_t i;
-} TaggedDoubleBits;
+struct DoubleBits {
+ uint64_t fraction : 52; // unsigned
+ uint64_t exponent : 11; // signed
+ uint64_t sign : 1;
+};
+
+struct TaggedDoubleBits {
+ uint64_t fraction : 52; // unsigned
+ uint64_t exponent : 7; // signed
+ uint64_t sign : 1;
+ uint64_t unused : 4; // placeholder for pointer tag bits
+};
static uint64_t decodeExponent(uint64_t exp) {
// Tagged exponent field is 7-bit signed. Sign-extend the value to 64 bits
@@ -775,24 +753,24 @@ static uint64_t decodeExponent(uint64_t exp) {
return llvm::SignExtend64<7>(exp) + TAGGED_DATE_EXPONENT_BIAS;
}
-static uint64_t decodeTaggedTimeInterval(uint64_t encodedTimeInterval) {
+static double decodeTaggedTimeInterval(uint64_t encodedTimeInterval) {
if (encodedTimeInterval == 0)
return 0.0;
if (encodedTimeInterval == std::numeric_limits<uint64_t>::max())
return (uint64_t)-0.0;
- TaggedDoubleBits encodedBits = {};
- encodedBits.i = encodedTimeInterval;
- DoubleBits decodedBits;
+ TaggedDoubleBits encodedBits =
+ llvm::bit_cast<TaggedDoubleBits>(encodedTimeInterval);
+ assert(encodedBits.unused == 0);
// Sign and fraction are represented exactly.
// Exponent is encoded.
- assert(encodedBits.unused == 0);
+ DoubleBits decodedBits;
decodedBits.sign = encodedBits.sign;
decodedBits.fraction = encodedBits.fraction;
decodedBits.exponent = decodeExponent(encodedBits.exponent);
- return decodedBits.d;
+ return llvm::bit_cast<double>(decodedBits);
}
bool lldb_private::formatters::NSDateSummaryProvider(
@@ -801,9 +779,7 @@ bool lldb_private::formatters::NSDateSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -869,7 +845,8 @@ bool lldb_private::formatters::NSDateSummaryProvider(
// Accomodate for the __NSTaggedDate format introduced in Foundation 1600.
if (class_name == g___NSTaggedDate) {
- auto *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(process_sp->GetObjCLanguageRuntime());
+ auto *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
+ ObjCLanguageRuntime::Get(*process_sp));
if (runtime && runtime->GetFoundationVersion() >= 1600)
date_value = decodeTaggedTimeInterval(value_bits << 4);
}
@@ -897,9 +874,7 @@ bool lldb_private::formatters::ObjCClassSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -940,7 +915,7 @@ public:
bool MightHaveChildren() override { return false; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
return UINT32_MAX;
}
};
@@ -958,9 +933,7 @@ bool lldb_private::formatters::NSDataSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -1059,8 +1032,8 @@ bool lldb_private::formatters::ObjCBooleanSummaryProvider(
if (!process_sp)
return false;
- if (AppleObjCRuntime *objc_runtime =
- (AppleObjCRuntime *)process_sp->GetObjCLanguageRuntime()) {
+ if (AppleObjCRuntime *objc_runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
+ ObjCLanguageRuntime::Get(*process_sp))) {
lldb::addr_t cf_true = LLDB_INVALID_ADDRESS,
cf_false = LLDB_INVALID_ADDRESS;
objc_runtime->GetValuesForGlobalCFBooleans(cf_true, cf_false);
diff --git a/source/Plugins/Language/ObjC/Cocoa.h b/source/Plugins/Language/ObjC/Cocoa.h
index 0f2ca54963028..388e6f03aa0f9 100644
--- a/source/Plugins/Language/ObjC/Cocoa.h
+++ b/source/Plugins/Language/ObjC/Cocoa.h
@@ -1,10 +1,9 @@
//===-- Cocoa.h ---------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,10 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Utility/Stream.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_private {
namespace formatters {
bool NSIndexSetSummaryProvider(ValueObject &valobj, Stream &stream,
diff --git a/source/Plugins/Language/ObjC/CoreMedia.cpp b/source/Plugins/Language/ObjC/CoreMedia.cpp
index cbc38c907953a..d19290ec56fb9 100644
--- a/source/Plugins/Language/ObjC/CoreMedia.cpp
+++ b/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -1,10 +1,9 @@
//===-- CoreMedia.cpp --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/ObjC/CoreMedia.h b/source/Plugins/Language/ObjC/CoreMedia.h
index 98561efbf7edd..79abb67b9d7e3 100644
--- a/source/Plugins/Language/ObjC/CoreMedia.h
+++ b/source/Plugins/Language/ObjC/CoreMedia.h
@@ -1,10 +1,9 @@
//===-- CoreMedia.h -----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/ObjC/NSArray.cpp b/source/Plugins/Language/ObjC/NSArray.cpp
index 6c110da9ecc24..404dabf2870c0 100644
--- a/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/source/Plugins/Language/ObjC/NSArray.cpp
@@ -1,9 +1,8 @@
//===-- NSArray.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,13 +11,13 @@
#include "Cocoa.h"
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
+
#include "lldb/Core/ValueObject.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -58,7 +57,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
protected:
virtual lldb::addr_t GetDataAddress() = 0;
@@ -172,13 +171,8 @@ namespace Foundation1437 {
PtrType _data;
uint32_t _offset;
uint32_t _size;
- union {
- PtrType _mutations;
- struct {
- uint32_t _muts;
- uint32_t _used;
- };
- };
+ uint32_t _muts;
+ uint32_t _used;
};
using NSArrayMSyntheticFrontEnd =
@@ -248,7 +242,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
ExecutionContextRef m_exe_ctx_ref;
@@ -320,7 +314,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
};
class NSArray1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
@@ -337,7 +331,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
};
} // namespace formatters
} // namespace lldb_private
@@ -350,9 +344,7 @@ bool lldb_private::formatters::NSArraySummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -550,7 +542,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::MightHaveChildren() {
size_t
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName(
- const ConstString &name) {
+ ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -639,7 +631,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
template <typename D32, typename D64, bool Inline>
size_t
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -729,7 +721,7 @@ lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd(
size_t
lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
+ ConstString name) {
return UINT32_MAX;
}
@@ -758,7 +750,7 @@ lldb_private::formatters::NSArray1SyntheticFrontEnd::NSArray1SyntheticFrontEnd(
size_t
lldb_private::formatters::NSArray1SyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
+ ConstString name) {
static const ConstString g_zero("[0]");
if (name == g_zero)
@@ -805,7 +797,7 @@ lldb_private::formatters::NSArraySyntheticFrontEndCreator(
if (!process_sp)
return nullptr;
AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
- process_sp->GetObjCLanguageRuntime());
+ ObjCLanguageRuntime::Get(*process_sp));
if (!runtime)
return nullptr;
diff --git a/source/Plugins/Language/ObjC/NSDictionary.cpp b/source/Plugins/Language/ObjC/NSDictionary.cpp
index 9a7fc2bd97cb5..10f66c4a37f80 100644
--- a/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -1,9 +1,8 @@
//===-- NSDictionary.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,7 +19,6 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/StackFrame.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -112,7 +110,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
struct DataDescriptor_32 {
@@ -155,7 +153,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
ValueObjectSP m_pair;
@@ -176,7 +174,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
struct DictionaryItemDescriptor {
@@ -209,7 +207,7 @@ namespace Foundation1100 {
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
struct DataDescriptor_32 {
@@ -282,18 +280,11 @@ namespace Foundation1437 {
struct DataDescriptor_32 {
uint32_t _buffer;
- union {
- struct {
- uint32_t _mutations;
- };
- struct {
- uint32_t _muts;
- uint32_t _used:25;
- uint32_t _kvo:1;
- uint32_t _szidx:6;
- };
- };
-
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
+
uint64_t GetSize() {
return (_szidx) >= NSDictionaryNumSizeBuckets ?
0 : NSDictionaryCapacities[_szidx];
@@ -302,18 +293,11 @@ namespace Foundation1437 {
struct DataDescriptor_64 {
uint64_t _buffer;
- union {
- struct {
- uint64_t _mutations;
- };
- struct {
- uint32_t _muts;
- uint32_t _used:25;
- uint32_t _kvo:1;
- uint32_t _szidx:6;
- };
- };
-
+ uint32_t _muts;
+ uint32_t _used : 25;
+ uint32_t _kvo : 1;
+ uint32_t _szidx : 6;
+
uint64_t GetSize() {
return (_szidx) >= NSDictionaryNumSizeBuckets ?
0 : NSDictionaryCapacities[_szidx];
@@ -362,9 +346,7 @@ bool lldb_private::formatters::NSDictionarySummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -454,8 +436,8 @@ lldb_private::formatters::NSDictionarySyntheticFrontEndCreator(
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
return nullptr;
- AppleObjCRuntime *runtime =
- llvm::dyn_cast_or_null<AppleObjCRuntime>(process_sp->GetObjCLanguageRuntime());
+ AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
+ ObjCLanguageRuntime::Get(*process_sp));
if (!runtime)
return nullptr;
@@ -527,7 +509,7 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::
}
size_t lldb_private::formatters::NSDictionaryISyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -663,7 +645,7 @@ lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
: SyntheticChildrenFrontEnd(*valobj_sp.get()), m_pair(nullptr) {}
size_t lldb_private::formatters::NSDictionary1SyntheticFrontEnd::
- GetIndexOfChildWithName(const ConstString &name) {
+ GetIndexOfChildWithName(ConstString name) {
static const ConstString g_zero("[0]");
return name == g_zero ? 0 : UINT32_MAX;
}
@@ -751,7 +733,7 @@ lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>::
template <typename D32, typename D64>
size_t
-lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: GetIndexOfChildWithName(const ConstString &name) {
+lldb_private::formatters::GenericNSDictionaryMSyntheticFrontEnd<D32,D64>:: GetIndexOfChildWithName(ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -920,7 +902,7 @@ lldb_private::formatters::Foundation1100::
size_t
lldb_private::formatters::Foundation1100::
- NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(const ConstString &name) {
+ NSDictionaryMSyntheticFrontEnd::GetIndexOfChildWithName(ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
diff --git a/source/Plugins/Language/ObjC/NSDictionary.h b/source/Plugins/Language/ObjC/NSDictionary.h
index 6ec9a8eebe137..ecb3fccdf8775 100644
--- a/source/Plugins/Language/ObjC/NSDictionary.h
+++ b/source/Plugins/Language/ObjC/NSDictionary.h
@@ -1,10 +1,9 @@
//===-- NSDictionary.h ---------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,8 +51,8 @@ public:
class Prefix : public Matcher {
public:
Prefix(ConstString p);
- virtual ~Prefix() = default;
- virtual bool Match(ConstString class_name) override;
+ ~Prefix() override = default;
+ bool Match(ConstString class_name) override;
private:
ConstString m_prefix;
@@ -61,8 +60,8 @@ public:
class Full : public Matcher {
public:
Full(ConstString n);
- virtual ~Full() = default;
- virtual bool Match(ConstString class_name) override;
+ ~Full() override = default;
+ bool Match(ConstString class_name) override;
private:
ConstString m_name;
diff --git a/source/Plugins/Language/ObjC/NSError.cpp b/source/Plugins/Language/ObjC/NSError.cpp
index 975bda5179f20..97df3be72c843 100644
--- a/source/Plugins/Language/ObjC/NSError.cpp
+++ b/source/Plugins/Language/ObjC/NSError.cpp
@@ -1,9 +1,8 @@
//===-- NSError.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -24,6 +22,7 @@
#include "lldb/Utility/Stream.h"
#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
using namespace lldb;
using namespace lldb_private;
@@ -164,7 +163,7 @@ public:
bool MightHaveChildren() override { return true; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
static ConstString g___userInfo("_userInfo");
if (name == g___userInfo)
return 0;
@@ -188,9 +187,7 @@ lldb_private::formatters::NSErrorSyntheticFrontEndCreator(
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
return nullptr;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return nullptr;
diff --git a/source/Plugins/Language/ObjC/NSException.cpp b/source/Plugins/Language/ObjC/NSException.cpp
index 2404ef9d10034..931794a12ab17 100644
--- a/source/Plugins/Language/ObjC/NSException.cpp
+++ b/source/Plugins/Language/ObjC/NSException.cpp
@@ -1,9 +1,8 @@
//===-- NSException.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/ProcessStructReader.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -24,6 +22,7 @@
#include "lldb/Utility/Stream.h"
#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
using namespace lldb;
using namespace lldb_private;
@@ -150,7 +149,7 @@ public:
bool MightHaveChildren() override { return true; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
// NSException has 4 members:
// NSString *name;
// NSString *reason;
@@ -180,9 +179,7 @@ lldb_private::formatters::NSExceptionSyntheticFrontEndCreator(
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
return nullptr;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return nullptr;
diff --git a/source/Plugins/Language/ObjC/NSIndexPath.cpp b/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 41df9abb3eb2d..9ee6021ae56bd 100644
--- a/source/Plugins/Language/ObjC/NSIndexPath.cpp
+++ b/source/Plugins/Language/ObjC/NSIndexPath.cpp
@@ -1,9 +1,8 @@
//===-- NSIndexPath.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,10 +13,10 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/DataFormatters/TypeSynthetic.h"
#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::formatters;
@@ -69,9 +68,7 @@ public:
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -128,7 +125,7 @@ public:
bool MightHaveChildren() override { return m_impl.m_mode != Mode::Invalid; }
- size_t GetIndexOfChildWithName(const ConstString &name) override {
+ size_t GetIndexOfChildWithName(ConstString name) override {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
diff --git a/source/Plugins/Language/ObjC/NSSet.cpp b/source/Plugins/Language/ObjC/NSSet.cpp
index 7e03d7574af0e..ebaa990fb74b2 100644
--- a/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/source/Plugins/Language/ObjC/NSSet.cpp
@@ -1,9 +1,8 @@
//===-- NSSet.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Endian.h"
@@ -55,7 +53,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
struct DataDescriptor_32 {
@@ -96,7 +94,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
private:
@@ -155,28 +153,18 @@ namespace Foundation1437 {
uint32_t _cow;
// __table storage
uint32_t _objs_addr;
- union {
- uint32_t _mutations;
- struct {
- uint32_t _muts;
- uint32_t _used : 26;
- uint32_t _szidx : 6;
- };
- };
+ uint32_t _muts;
+ uint32_t _used : 26;
+ uint32_t _szidx : 6;
};
struct DataDescriptor_64 {
uint64_t _cow;
// __Table storage
uint64_t _objs_addr;
- union {
- uint64_t _mutations;
- struct {
- uint32_t _muts;
- uint32_t _used : 26;
- uint32_t _szidx : 6;
- };
- };
+ uint32_t _muts;
+ uint32_t _used : 26;
+ uint32_t _szidx : 6;
};
using NSSetMSyntheticFrontEnd =
@@ -222,7 +210,7 @@ public:
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(const ConstString &name) override;
+ size_t GetIndexOfChildWithName(ConstString name) override;
};
} // namespace formatters
} // namespace lldb_private
@@ -236,9 +224,7 @@ bool lldb_private::formatters::NSSetSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
@@ -315,9 +301,7 @@ lldb_private::formatters::NSSetSyntheticFrontEndCreator(
lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
if (!process_sp)
return nullptr;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return nullptr;
@@ -385,7 +369,7 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::~NSSetISyntheticFrontEnd() {
size_t
lldb_private::formatters::NSSetISyntheticFrontEnd::GetIndexOfChildWithName(
- const ConstString &name) {
+ ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
@@ -540,7 +524,7 @@ template <typename D32, typename D64>
size_t
lldb_private::formatters::
GenericNSSetMSyntheticFrontEnd<D32, D64>::GetIndexOfChildWithName(
- const ConstString &name) {
+ ConstString name) {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildren())
diff --git a/source/Plugins/Language/ObjC/NSSet.h b/source/Plugins/Language/ObjC/NSSet.h
index 00451be6c7f35..f11b6d406dec3 100644
--- a/source/Plugins/Language/ObjC/NSSet.h
+++ b/source/Plugins/Language/ObjC/NSSet.h
@@ -1,10 +1,9 @@
//===-- NSSet.h ---------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Language/ObjC/NSString.cpp b/source/Plugins/Language/ObjC/NSString.cpp
index f882b2adc260f..4800c955e5f51 100644
--- a/source/Plugins/Language/ObjC/NSString.cpp
+++ b/source/Plugins/Language/ObjC/NSString.cpp
@@ -1,10 +1,9 @@
//===-- NSString.cpp ----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -60,9 +59,7 @@ bool lldb_private::formatters::NSStringSummaryProvider(
if (!process_sp)
return false;
- ObjCLanguageRuntime *runtime =
- (ObjCLanguageRuntime *)process_sp->GetLanguageRuntime(
- lldb::eLanguageTypeObjC);
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (!runtime)
return false;
diff --git a/source/Plugins/Language/ObjC/NSString.h b/source/Plugins/Language/ObjC/NSString.h
index 3a923c2be6ac5..699d8eb36f882 100644
--- a/source/Plugins/Language/ObjC/NSString.h
+++ b/source/Plugins/Language/ObjC/NSString.h
@@ -1,10 +1,9 @@
//===-- NSString.h ---------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,10 @@
#include "lldb/Core/ValueObject.h"
#include "lldb/DataFormatters/TypeSummary.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Utility/Stream.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_private {
namespace formatters {
bool NSStringSummaryProvider(ValueObject &valobj, Stream &stream,
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
index 0598d69f6ebbb..f9ab18688de72 100644
--- a/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -1,9 +1,8 @@
//===-- ObjCLanguage.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,13 +16,14 @@
#include "lldb/DataFormatters/FormattersHelpers.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompilerType.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/StreamString.h"
#include "llvm/Support/Threading.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
#include "CF.h"
#include "Cocoa.h"
#include "CoreMedia.h"
@@ -49,9 +49,7 @@ lldb_private::ConstString ObjCLanguage::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ObjCLanguage::GetPluginName() {
return GetPluginNameStatic();
@@ -59,9 +57,7 @@ lldb_private::ConstString ObjCLanguage::GetPluginName() {
uint32_t ObjCLanguage::GetPluginVersion() { return 1; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
Language *ObjCLanguage::CreateInstance(lldb::LanguageType language) {
switch (language) {
@@ -120,7 +116,7 @@ bool ObjCLanguage::MethodName::SetName(const char *name, bool strict) {
return SetName(llvm::StringRef(name), strict);
}
-const ConstString &ObjCLanguage::MethodName::GetClassName() {
+ConstString ObjCLanguage::MethodName::GetClassName() {
if (!m_class) {
if (IsValid(false)) {
const char *full = m_full.GetCString();
@@ -146,7 +142,7 @@ const ConstString &ObjCLanguage::MethodName::GetClassName() {
return m_class;
}
-const ConstString &ObjCLanguage::MethodName::GetClassNameWithCategory() {
+ConstString ObjCLanguage::MethodName::GetClassNameWithCategory() {
if (!m_class_category) {
if (IsValid(false)) {
const char *full = m_full.GetCString();
@@ -169,7 +165,7 @@ const ConstString &ObjCLanguage::MethodName::GetClassNameWithCategory() {
return m_class_category;
}
-const ConstString &ObjCLanguage::MethodName::GetSelector() {
+ConstString ObjCLanguage::MethodName::GetSelector() {
if (!m_selector) {
if (IsValid(false)) {
const char *full = m_full.GetCString();
@@ -184,7 +180,7 @@ const ConstString &ObjCLanguage::MethodName::GetSelector() {
return m_selector;
}
-const ConstString &ObjCLanguage::MethodName::GetCategory() {
+ConstString ObjCLanguage::MethodName::GetCategory() {
if (!m_category_is_valid && !m_category) {
if (IsValid(false)) {
m_category_is_valid = true;
@@ -225,43 +221,46 @@ ConstString ObjCLanguage::MethodName::GetFullNameWithoutCategory(
return ConstString();
}
-size_t ObjCLanguage::MethodName::GetFullNames(std::vector<ConstString> &names,
- bool append) {
- if (!append)
- names.clear();
- if (IsValid(false)) {
+std::vector<ConstString>
+ObjCLanguage::GetMethodNameVariants(ConstString method_name) const {
+ std::vector<ConstString> variant_names;
+ ObjCLanguage::MethodName objc_method(method_name.GetCString(), false);
+ if (!objc_method.IsValid(false)) {
+ return variant_names;
+ }
+
+ const bool is_class_method =
+ objc_method.GetType() == MethodName::eTypeClassMethod;
+ const bool is_instance_method =
+ objc_method.GetType() == MethodName::eTypeInstanceMethod;
+ ConstString name_sans_category =
+ objc_method.GetFullNameWithoutCategory(/*empty_if_no_category*/ true);
+
+ if (is_class_method || is_instance_method) {
+ if (name_sans_category)
+ variant_names.emplace_back(name_sans_category);
+ } else {
StreamString strm;
- const bool is_class_method = m_type == eTypeClassMethod;
- const bool is_instance_method = m_type == eTypeInstanceMethod;
- const ConstString &category = GetCategory();
- if (is_class_method || is_instance_method) {
- names.push_back(m_full);
- if (category) {
- strm.Printf("%c[%s %s]", is_class_method ? '+' : '-',
- GetClassName().GetCString(), GetSelector().GetCString());
- names.emplace_back(strm.GetString());
- }
- } else {
- const ConstString &class_name = GetClassName();
- const ConstString &selector = GetSelector();
- strm.Printf("+[%s %s]", class_name.GetCString(), selector.GetCString());
- names.emplace_back(strm.GetString());
- strm.Clear();
- strm.Printf("-[%s %s]", class_name.GetCString(), selector.GetCString());
- names.emplace_back(strm.GetString());
+
+ strm.Printf("+%s", objc_method.GetFullName().GetCString());
+ variant_names.emplace_back(strm.GetString());
+ strm.Clear();
+
+ strm.Printf("-%s", objc_method.GetFullName().GetCString());
+ variant_names.emplace_back(strm.GetString());
+ strm.Clear();
+
+ if (name_sans_category) {
+ strm.Printf("+%s", name_sans_category.GetCString());
+ variant_names.emplace_back(strm.GetString());
strm.Clear();
- if (category) {
- strm.Printf("+[%s(%s) %s]", class_name.GetCString(),
- category.GetCString(), selector.GetCString());
- names.emplace_back(strm.GetString());
- strm.Clear();
- strm.Printf("-[%s(%s) %s]", class_name.GetCString(),
- category.GetCString(), selector.GetCString());
- names.emplace_back(strm.GetString());
- }
+
+ strm.Printf("-%s", name_sans_category.GetCString());
+ variant_names.emplace_back(strm.GetString());
}
}
- return names.size();
+
+ return variant_names;
}
static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
@@ -286,7 +285,6 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL *"),
ObjC_BOOL_summary);
-#ifndef LLDB_DISABLE_PYTHON
// we need to skip pointers here since we are special casing a SEL* when
// retrieving its value
objc_flags.SetSkipPointers(true);
@@ -318,7 +316,6 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb_private::formatters::ObjCClassSyntheticFrontEndCreator,
"Class synthetic children", ConstString("Class"),
class_synth_flags);
-#endif // LLDB_DISABLE_PYTHON
objc_flags.SetSkipPointers(false);
objc_flags.SetCascades(true);
@@ -384,7 +381,6 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
appkit_flags.SetDontShowChildren(false);
-#ifndef LLDB_DISABLE_PYTHON
AddCXXSummary(
objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
"NSArray summary provider", ConstString("NSArray"), appkit_flags);
@@ -841,7 +837,6 @@ static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
lldb_private::formatters::CFBitVectorSummaryProvider,
"CFBitVector summary provider",
ConstString("__CFMutableBitVector"), appkit_flags);
-#endif // LLDB_DISABLE_PYTHON
}
static void LoadCoreMediaFormatters(TypeCategoryImplSP objc_category_sp) {
@@ -857,11 +852,9 @@ static void LoadCoreMediaFormatters(TypeCategoryImplSP objc_category_sp) {
.SetSkipPointers(false)
.SetSkipReferences(false);
-#ifndef LLDB_DISABLE_PYTHON
AddCXXSummary(objc_category_sp,
lldb_private::formatters::CMTimeSummaryProvider,
"CMTime summary provider", ConstString("CMTime"), cm_flags);
-#endif // LLDB_DISABLE_PYTHON
}
lldb::TypeCategoryImplSP ObjCLanguage::GetFormatters() {
@@ -898,7 +891,7 @@ ObjCLanguage::GetPossibleFormattersMatches(ValueObject &valobj,
lldb::ProcessSP process_sp = valobj.GetProcessSP();
if (!process_sp)
break;
- ObjCLanguageRuntime *runtime = process_sp->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
if (runtime == nullptr)
break;
ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp(
@@ -940,26 +933,16 @@ std::unique_ptr<Language::TypeScavenger> ObjCLanguage::GetTypeScavenger() {
ResultSet &results) override {
bool result = false;
- Process *process = exe_scope->CalculateProcess().get();
- if (process) {
- const bool create_on_demand = false;
- auto objc_runtime = process->GetObjCLanguageRuntime(create_on_demand);
- if (objc_runtime) {
- auto decl_vendor = objc_runtime->GetDeclVendor();
- if (decl_vendor) {
- std::vector<clang::NamedDecl *> decls;
+ if (auto *process = exe_scope->CalculateProcess().get()) {
+ if (auto *objc_runtime = ObjCLanguageRuntime::Get(*process)) {
+ if (auto *decl_vendor = objc_runtime->GetDeclVendor()) {
ConstString name(key);
- decl_vendor->FindDecls(name, true, UINT32_MAX, decls);
- for (auto decl : decls) {
- if (decl) {
- if (CompilerType candidate =
- ClangASTContext::GetTypeForDecl(decl)) {
- result = true;
- std::unique_ptr<Language::TypeScavenger::Result> result(
- new ObjCScavengerResult(candidate));
- results.insert(std::move(result));
- }
- }
+ for (const CompilerType &type :
+ decl_vendor->FindTypes(name, /*max_matches*/ UINT32_MAX)) {
+ result = true;
+ std::unique_ptr<Language::TypeScavenger::Result> result(
+ new ObjCScavengerResult(type));
+ results.insert(std::move(result));
}
}
}
@@ -977,21 +960,16 @@ std::unique_ptr<Language::TypeScavenger> ObjCLanguage::GetTypeScavenger() {
ResultSet &results) override {
bool result = false;
- Target *target = exe_scope->CalculateTarget().get();
- if (target) {
- if (auto clang_modules_decl_vendor =
+ if (auto *target = exe_scope->CalculateTarget().get()) {
+ if (auto *clang_modules_decl_vendor =
target->GetClangModulesDeclVendor()) {
- std::vector<clang::NamedDecl *> decls;
ConstString key_cs(key);
-
- if (clang_modules_decl_vendor->FindDecls(key_cs, false, UINT32_MAX,
- decls) > 0 &&
- !decls.empty()) {
- CompilerType module_type =
- ClangASTContext::GetTypeForDecl(decls.front());
+ auto types = clang_modules_decl_vendor->FindTypes(
+ key_cs, /*max_matches*/ UINT32_MAX);
+ if (!types.empty()) {
result = true;
std::unique_ptr<Language::TypeScavenger::Result> result(
- new ObjCScavengerResult(module_type));
+ new ObjCScavengerResult(types.front()));
results.insert(std::move(result));
}
}
@@ -1005,7 +983,7 @@ std::unique_ptr<Language::TypeScavenger> ObjCLanguage::GetTypeScavenger() {
class ObjCDebugInfoScavenger : public Language::ImageListTypeScavenger {
public:
- virtual CompilerType AdjustForInclusion(CompilerType &candidate) override {
+ CompilerType AdjustForInclusion(CompilerType &candidate) override {
LanguageType lang_type(candidate.GetMinimumLanguage());
if (!Language::LanguageIsObjC(lang_type))
return CompilerType();
diff --git a/source/Plugins/Language/ObjC/ObjCLanguage.h b/source/Plugins/Language/ObjC/ObjCLanguage.h
index 114f9323de024..3e2cc09729934 100644
--- a/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ b/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -1,9 +1,8 @@
//===-- ObjCLanguage.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -59,32 +58,20 @@ public:
Type GetType() const { return m_type; }
- const ConstString &GetFullName() const { return m_full; }
+ ConstString GetFullName() const { return m_full; }
ConstString GetFullNameWithoutCategory(bool empty_if_no_category);
bool SetName(const char *name, bool strict);
bool SetName(llvm::StringRef name, bool strict);
- const ConstString &GetClassName();
-
- const ConstString &GetClassNameWithCategory();
+ ConstString GetClassName();
- const ConstString &GetCategory();
+ ConstString GetClassNameWithCategory();
- const ConstString &GetSelector();
+ ConstString GetCategory();
- // Get all possible names for a method. Examples:
- // If name is "+[NSString(my_additions) myStringWithCString:]"
- // names[0] => "+[NSString(my_additions) myStringWithCString:]"
- // names[1] => "+[NSString myStringWithCString:]"
- // If name is specified without the leading '+' or '-' like
- // "[NSString(my_additions) myStringWithCString:]"
- // names[0] => "+[NSString(my_additions) myStringWithCString:]"
- // names[1] => "-[NSString(my_additions) myStringWithCString:]"
- // names[2] => "+[NSString myStringWithCString:]"
- // names[3] => "-[NSString myStringWithCString:]"
- size_t GetFullNames(std::vector<ConstString> &names, bool append);
+ ConstString GetSelector();
protected:
ConstString
@@ -106,6 +93,18 @@ public:
return lldb::eLanguageTypeObjC;
}
+ // Get all possible names for a method. Examples:
+ // If method_name is "+[NSString(my_additions) myStringWithCString:]"
+ // variant_names[0] => "+[NSString myStringWithCString:]"
+ // If name is specified without the leading '+' or '-' like
+ // "[NSString(my_additions) myStringWithCString:]"
+ // variant_names[0] => "+[NSString(my_additions) myStringWithCString:]"
+ // variant_names[1] => "-[NSString(my_additions) myStringWithCString:]"
+ // variant_names[2] => "+[NSString myStringWithCString:]"
+ // variant_names[3] => "-[NSString myStringWithCString:]"
+ std::vector<ConstString>
+ GetMethodNameVariants(ConstString method_name) const override;
+
lldb::TypeCategoryImplSP GetFormatters() override;
std::vector<ConstString>
@@ -124,9 +123,7 @@ public:
const Highlighter *GetHighlighter() const override { return &m_highlighter; }
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -155,9 +152,7 @@ public:
return false;
}
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
index 5e6d86e05318b..81b3c5807c411 100644
--- a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
+++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
@@ -1,10 +1,9 @@
//===-- ObjCPlusPlusLanguage.cpp --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,18 +38,14 @@ lldb_private::ConstString ObjCPlusPlusLanguage::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ObjCPlusPlusLanguage::GetPluginName() {
return GetPluginNameStatic();
}
uint32_t ObjCPlusPlusLanguage::GetPluginVersion() { return 1; }
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
Language *ObjCPlusPlusLanguage::CreateInstance(lldb::LanguageType language) {
switch (language) {
case lldb::eLanguageTypeObjC_plus_plus:
diff --git a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
index b64f0f81e0011..6224a3f47b3b4 100644
--- a/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
+++ b/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h
@@ -1,9 +1,8 @@
//===-- ObjCPlusPlusLanguage.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,7 @@ public:
const Highlighter *GetHighlighter() const override { return &m_highlighter; }
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -43,9 +40,7 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Target/CPPLanguageRuntime.cpp b/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index f0bd1758461cb..b392282c3eb1a 100644
--- a/source/Target/CPPLanguageRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -1,20 +1,21 @@
//===-- CPPLanguageRuntime.cpp
-//-------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "lldb/Target/CPPLanguageRuntime.h"
-
#include <string.h>
+#include <memory>
+
+#include "CPPLanguageRuntime.h"
+
#include "llvm/ADT/StringRef.h"
#include "lldb/Symbol/Block.h"
+#include "lldb/Symbol/Variable.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Core/PluginManager.h"
@@ -31,14 +32,20 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
+static ConstString g_this = ConstString("this");
+
+char CPPLanguageRuntime::ID = 0;
+
// Destructor
-//----------------------------------------------------------------------
CPPLanguageRuntime::~CPPLanguageRuntime() {}
CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
: LanguageRuntime(process) {}
+bool CPPLanguageRuntime::IsWhitelistedRuntimeValue(ConstString name) {
+ return name == g_this;
+}
+
bool CPPLanguageRuntime::GetObjectDescription(Stream &str,
ValueObject &object) {
// C++ has no generic way to do this.
@@ -169,7 +176,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
//
// This covers the case of the lambda known at compile time.
size_t first_open_angle_bracket = vtable_name.find('<') + 1;
- size_t first_comma = vtable_name.find_first_of(',');
+ size_t first_comma = vtable_name.find(',');
llvm::StringRef first_template_parameter =
vtable_name.slice(first_open_angle_bracket, first_comma);
@@ -196,7 +203,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
return llvm::Regex::escape(first_template_parameter.str()) +
R"(::operator\(\)\(.*\))";
- if (symbol != NULL &&
+ if (symbol != nullptr &&
symbol->GetName().GetStringRef().contains("__invoke")) {
llvm::StringRef symbol_name = symbol->GetName().GetStringRef();
@@ -223,8 +230,8 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
SymbolContextList scl;
- target.GetImages().FindFunctions(RegularExpression{func_to_match}, true, true,
- true, scl);
+ target.GetImages().FindSymbolsMatchingRegExAndType(
+ RegularExpression{R"(^)" + func_to_match}, eSymbolTypeAny, scl, true);
// Case 1,2 or 3
if (scl.GetSize() >= 1) {
@@ -260,7 +267,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo(
}
// Case 4 or 5
- if (!symbol->GetName().GetStringRef().startswith("vtable for")) {
+ if (symbol && !symbol->GetName().GetStringRef().startswith("vtable for")) {
optional_info.callable_case =
LibCppStdFunctionCallableCase::FreeOrMemberFunction;
optional_info.callable_address = function_address_resolved;
@@ -319,7 +326,7 @@ CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
StackFrameSP frame = thread.GetStackFrameAtIndex(0);
if (frame) {
- ValueObjectSP value_sp = frame->FindVariable(ConstString("this"));
+ ValueObjectSP value_sp = frame->FindVariable(g_this);
CPPLanguageRuntime::LibCppStdFunctionCallableInfo callable_info =
FindLibCppStdFunctionCallableInfo(value_sp);
@@ -328,16 +335,16 @@ CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread,
value_sp->GetValueIsValid()) {
// We found the std::function wrapped callable and we have its address.
// We now create a ThreadPlan to run to the callable.
- ret_plan_sp.reset(new ThreadPlanRunToAddress(
- thread, callable_info.callable_address, stop_others));
+ ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(
+ thread, callable_info.callable_address, stop_others);
return ret_plan_sp;
} else {
// We are in std::function but we could not obtain the callable.
// We create a ThreadPlan to keep stepping through using the address range
// of the current function.
- ret_plan_sp.reset(new ThreadPlanStepInRange(thread, range_of_curr_func,
- sc, eOnlyThisThread,
- eLazyBoolYes, eLazyBoolYes));
+ ret_plan_sp = std::make_shared<ThreadPlanStepInRange>(
+ thread, range_of_curr_func, sc, eOnlyThisThread, eLazyBoolYes,
+ eLazyBoolYes);
return ret_plan_sp;
}
}
diff --git a/include/lldb/Target/CPPLanguageRuntime.h b/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
index e96ee168389b9..28526361efc4a 100644
--- a/include/lldb/Target/CPPLanguageRuntime.h
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h
@@ -1,10 +1,8 @@
//===-- CPPLanguageRuntime.h
-//---------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -41,11 +39,24 @@ public:
~CPPLanguageRuntime() override;
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || LanguageRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
+ }
+
lldb::LanguageType GetLanguageType() const override {
return lldb::eLanguageTypeC_plus_plus;
}
- virtual bool IsVTableName(const char *name) = 0;
+ static CPPLanguageRuntime *Get(Process &process) {
+ return llvm::cast_or_null<CPPLanguageRuntime>(
+ process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus));
+ }
bool GetObjectDescription(Stream &str, ValueObject &object) override;
@@ -54,21 +65,20 @@ public:
/// Obtain a ThreadPlan to get us into C++ constructs such as std::function.
///
- /// @param[in] thread
+ /// \param[in] thread
/// Curent thrad of execution.
///
- /// @param[in] stop_others
+ /// \param[in] stop_others
/// True if other threads should pause during execution.
///
- /// @return
+ /// \return
/// A ThreadPlan Shared pointer
lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
- bool stop_others);
+ bool stop_others) override;
+ bool IsWhitelistedRuntimeValue(ConstString name) override;
protected:
- //------------------------------------------------------------------
// Classes that inherit from CPPLanguageRuntime can see and modify these
- //------------------------------------------------------------------
CPPLanguageRuntime(Process *process);
private:
diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
index 49a3d40d7b371..41f38a4e3dcd0 100644
--- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
@@ -1,10 +1,9 @@
//===-- ItaniumABILanguageRuntime.cpp --------------------------------------*-
//C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -44,10 +43,12 @@ using namespace lldb_private;
static const char *vtable_demangled_prefix = "vtable for ";
+char ItaniumABILanguageRuntime::ID = 0;
+
bool ItaniumABILanguageRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
const bool check_cxx = true;
const bool check_objc = false;
- return in_value.GetCompilerType().IsPossibleDynamicType(NULL, check_cxx,
+ return in_value.GetCompilerType().IsPossibleDynamicType(nullptr, check_cxx,
check_objc);
}
@@ -70,7 +71,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress(
target.GetImages().ResolveSymbolContextForAddress(
vtable_addr, eSymbolContextSymbol, sc);
Symbol *symbol = sc.symbol;
- if (symbol != NULL) {
+ if (symbol != nullptr) {
const char *name =
symbol->GetMangled()
.GetDemangledName(lldb::eLanguageTypeC_plus_plus)
@@ -236,16 +237,15 @@ bool ItaniumABILanguageRuntime::GetDynamicTypeAndAddress(
if (!class_type_or_name)
return false;
- TypeSP type_sp = class_type_or_name.GetTypeSP();
+ CompilerType type = class_type_or_name.GetCompilerType();
// There can only be one type with a given name, so we've just found
// duplicate definitions, and this one will do as well as any other. We
// don't consider something to have a dynamic type if it is the same as
// the static type. So compare against the value we were handed.
- if (!type_sp)
+ if (!type)
return true;
- if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(),
- type_sp->GetForwardCompilerType())) {
+ if (ClangASTContext::AreTypesSame(in_value.GetCompilerType(), type)) {
// The dynamic type we found was the same type, so we don't have a
// dynamic type here...
return false;
@@ -307,17 +307,7 @@ TypeAndOrName ItaniumABILanguageRuntime::FixUpDynamicType(
return ret;
}
-bool ItaniumABILanguageRuntime::IsVTableName(const char *name) {
- if (name == NULL)
- return false;
-
- // Can we maybe ask Clang about this?
- return strstr(name, "_vptr$") == name;
-}
-
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
LanguageRuntime *
ItaniumABILanguageRuntime::CreateInstance(Process *process,
lldb::LanguageType language) {
@@ -330,7 +320,7 @@ ItaniumABILanguageRuntime::CreateInstance(Process *process,
language == eLanguageTypeC_plus_plus_14)
return new ItaniumABILanguageRuntime(process);
else
- return NULL;
+ return nullptr;
}
class CommandObjectMultiwordItaniumABI_Demangle : public CommandObjectParsed {
@@ -429,9 +419,7 @@ lldb_private::ConstString ItaniumABILanguageRuntime::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ItaniumABILanguageRuntime::GetPluginName() {
return GetPluginNameStatic();
}
@@ -479,16 +467,14 @@ BreakpointResolverSP ItaniumABILanguageRuntime::CreateExceptionResolver(
lldb::SearchFilterSP ItaniumABILanguageRuntime::CreateExceptionSearchFilter() {
Target &target = m_process->GetTarget();
+ FileSpecList filter_modules;
if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) {
// Limit the number of modules that are searched for these breakpoints for
// Apple binaries.
- FileSpecList filter_modules;
filter_modules.Append(FileSpec("libc++abi.dylib"));
filter_modules.Append(FileSpec("libSystem.B.dylib"));
- return target.GetSearchFilterForModuleList(&filter_modules);
- } else {
- return LanguageRuntime::CreateExceptionSearchFilter();
}
+ return target.GetSearchFilterForModuleList(&filter_modules);
}
lldb::BreakpointSP ItaniumABILanguageRuntime::CreateExceptionBreakpoint(
@@ -496,7 +482,7 @@ lldb::BreakpointSP ItaniumABILanguageRuntime::CreateExceptionBreakpoint(
Target &target = m_process->GetTarget();
FileSpecList filter_modules;
BreakpointResolverSP exception_resolver_sp =
- CreateExceptionResolver(NULL, catch_bp, throw_bp, for_expressions);
+ CreateExceptionResolver(nullptr, catch_bp, throw_bp, for_expressions);
SearchFilterSP filter_sp(CreateExceptionSearchFilter());
const bool hardware = false;
const bool resolve_indirect_functions = false;
@@ -569,7 +555,7 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
options.SetUnwindOnError(true);
options.SetIgnoreBreakpoints(true);
options.SetStopOthers(true);
- options.SetTimeout(std::chrono::milliseconds(500));
+ options.SetTimeout(m_process->GetUtilityExpressionTimeout());
options.SetTryAllThreads(false);
thread_sp->CalculateExecutionContext(exe_ctx);
@@ -600,6 +586,10 @@ ValueObjectSP ItaniumABILanguageRuntime::GetExceptionObjectForThread(
addr_t exception_addr =
m_process->ReadPointerFromMemory(result_ptr - ptr_size, error);
+ if (!error.Success()) {
+ return ValueObjectSP();
+ }
+
lldb_private::formatters::InferiorSizedWord exception_isw(exception_addr,
*m_process);
ValueObjectSP exception = ValueObject::CreateValueObjectFromData(
diff --git a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
index abed3706c6b8b..97cc81b8681fc 100644
--- a/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
+++ b/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
@@ -1,9 +1,8 @@
//===-- ItaniumABILanguageRuntime.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,19 +16,18 @@
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Core/Value.h"
#include "lldb/Symbol/Type.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+
namespace lldb_private {
class ItaniumABILanguageRuntime : public lldb_private::CPPLanguageRuntime {
public:
~ItaniumABILanguageRuntime() override = default;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -39,7 +37,15 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- bool IsVTableName(const char *name) override;
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || CPPLanguageRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
+ }
bool GetDynamicTypeAndAddress(ValueObject &in_value,
lldb::DynamicValueType use_dynamic,
@@ -69,9 +75,7 @@ public:
lldb::ValueObjectSP GetExceptionObjectForThread(
lldb::ThreadSP thread_sp) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -91,9 +95,8 @@ private:
ItaniumABILanguageRuntime(Process *process)
: // Call CreateInstance instead.
- lldb_private::CPPLanguageRuntime(process),
- m_cxx_exception_bp_sp(), m_dynamic_type_map(),
- m_dynamic_type_map_mutex() {}
+ lldb_private::CPPLanguageRuntime(process), m_cxx_exception_bp_sp(),
+ m_dynamic_type_map(), m_dynamic_type_map_mutex() {}
lldb::BreakpointSP m_cxx_exception_bp_sp;
DynamicTypeCache m_dynamic_type_map;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 679c3c850e5b5..93aa07f89165e 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -1,10 +1,9 @@
//===-- AppleObjCClassDescriptorV2.cpp -----------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -335,9 +334,9 @@ bool ClassDescriptorV2::Describe(
std::unique_ptr<class_rw_t> class_rw;
if (!Read_objc_class(process, objc_class))
- return 0;
+ return false;
if (!Read_class_row(process, *objc_class, class_ro, class_rw))
- return 0;
+ return false;
static ConstString NSObject_name("NSObject");
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index 308ff1426fb26..b8ba9dbb65f45 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -1,9 +1,8 @@
//===-- AppleObjCClassDescriptorV2.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,10 @@
#include <mutex>
#include "AppleObjCRuntimeV2.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_private {
class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor {
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
index 4fc340b23c2c7..18f2a1829a419 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp
@@ -1,19 +1,18 @@
//===-- AppleObjCDeclVendor.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "AppleObjCDeclVendor.h"
#include "Plugins/ExpressionParser/Clang/ASTDumper.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "lldb/Core/Module.h"
#include "lldb/Symbol/ClangExternalASTSourceCommon.h"
#include "lldb/Symbol/ClangUtil.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"
@@ -21,6 +20,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
+
using namespace lldb_private;
class lldb_private::AppleObjCExternalASTSource
@@ -63,7 +63,7 @@ public:
non_const_interface_decl->lookup(name);
return (result.size() != 0);
- } while (0);
+ } while (false);
SetNoExternalVisibleDeclsForName(decl_ctx, name);
return false;
@@ -174,9 +174,9 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) {
m_runtime.GetClassDescriptorFromISA(isa);
if (!descriptor)
- return NULL;
+ return nullptr;
- const ConstString &name(descriptor->GetClassName());
+ ConstString name(descriptor->GetClassName());
clang::IdentifierInfo &identifier_info =
ast_ctx->Idents.get(name.GetStringRef());
@@ -204,12 +204,12 @@ public:
ObjCRuntimeMethodType(const char *types) : m_is_valid(false) {
const char *cursor = types;
enum ParserState { Start = 0, InType, InPos } state = Start;
- const char *type = NULL;
+ const char *type = nullptr;
int brace_depth = 0;
uint32_t stepsLeft = 256;
- while (1) {
+ while (true) {
if (--stepsLeft == 0) {
m_is_valid = false;
return;
@@ -262,7 +262,7 @@ public:
m_is_valid = false;
return;
}
- type = NULL;
+ type = nullptr;
} else {
++cursor;
}
@@ -320,7 +320,7 @@ public:
bool instance,
ObjCLanguageRuntime::EncodingToTypeSP type_realizer_sp) {
if (!m_is_valid || m_type_vector.size() < 3)
- return NULL;
+ return nullptr;
clang::ASTContext &ast_ctx(interface_decl->getASTContext());
@@ -355,7 +355,7 @@ public:
clang::IdentifierInfo **identifier_infos = selector_components.data();
if (!identifier_infos) {
- return NULL;
+ return nullptr;
}
clang::Selector sel = ast_ctx.Selectors.getSelector(
@@ -368,12 +368,13 @@ public:
for_expression));
if (ret_type.isNull())
- return NULL;
+ return nullptr;
clang::ObjCMethodDecl *ret = clang::ObjCMethodDecl::Create(
ast_ctx, clang::SourceLocation(), clang::SourceLocation(), sel,
- ret_type, NULL, interface_decl, isInstance, isVariadic, isSynthesized,
- isImplicitlyDeclared, isDefined, impControl, HasRelatedResultType);
+ ret_type, nullptr, interface_decl, isInstance, isVariadic,
+ isSynthesized, isImplicitlyDeclared, isDefined, impControl,
+ HasRelatedResultType);
std::vector<clang::ParmVarDecl *> parm_vars;
@@ -384,12 +385,12 @@ public:
ast_ctx, m_type_vector[ai].c_str(), for_expression));
if (arg_type.isNull())
- return NULL; // well, we just wasted a bunch of time. Wish we could
- // delete the stuff we'd just made!
+ return nullptr; // well, we just wasted a bunch of time. Wish we could
+ // delete the stuff we'd just made!
parm_vars.push_back(clang::ParmVarDecl::Create(
- ast_ctx, ret, clang::SourceLocation(), clang::SourceLocation(), NULL,
- arg_type, NULL, clang::SC_None, NULL));
+ ast_ctx, ret, clang::SourceLocation(), clang::SourceLocation(),
+ nullptr, arg_type, nullptr, clang::SC_None, nullptr));
}
ret->setMethodParams(ast_ctx,
@@ -513,7 +514,7 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) {
clang::SourceLocation(), &m_ast_ctx.getASTContext()->Idents.get(name),
ClangUtil::GetQualType(ivar_type),
type_source_info, // TypeSourceInfo *
- clang::ObjCIvarDecl::Public, 0, is_synthesized);
+ clang::ObjCIvarDecl::Public, nullptr, is_synthesized);
if (ivar_decl) {
interface_decl->addDecl(ivar_decl);
@@ -548,7 +549,7 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) {
}
uint32_t
-AppleObjCDeclVendor::FindDecls(const ConstString &name, bool append,
+AppleObjCDeclVendor::FindDecls(ConstString name, bool append,
uint32_t max_matches,
std::vector<clang::NamedDecl *> &decls) {
static unsigned int invocation_id = 0;
@@ -647,7 +648,7 @@ AppleObjCDeclVendor::FindDecls(const ConstString &name, bool append,
decls.push_back(iface_decl);
ret++;
break;
- } while (0);
+ } while (false);
return ret;
}
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
index 7f5c0bf3eb632..77b30b7fde791 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.h
@@ -1,9 +1,8 @@
//===-- AppleObjCDeclVendor.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,9 +11,10 @@
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/DeclVendor.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_private {
class AppleObjCExternalASTSource;
@@ -23,7 +23,7 @@ class AppleObjCDeclVendor : public DeclVendor {
public:
AppleObjCDeclVendor(ObjCLanguageRuntime &runtime);
- uint32_t FindDecls(const ConstString &name, bool append, uint32_t max_matches,
+ uint32_t FindDecls(ConstString name, bool append, uint32_t max_matches,
std::vector<clang::NamedDecl *> &decls) override;
clang::ExternalASTMerger::ImporterSource GetImporterSource() override;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
index ed47b481a810a..52ed3628520f9 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
@@ -1,10 +1,9 @@
//===-- AppleObjCRuntime.cpp -------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,7 +24,6 @@
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
@@ -40,19 +38,20 @@
#include "Plugins/Process/Utility/HistoryThread.h"
#include "Plugins/Language/ObjC/NSString.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
#include <vector>
using namespace lldb;
using namespace lldb_private;
-static constexpr std::chrono::seconds g_po_function_timeout(15);
+char AppleObjCRuntime::ID = 0;
AppleObjCRuntime::~AppleObjCRuntime() {}
AppleObjCRuntime::AppleObjCRuntime(Process *process)
: ObjCLanguageRuntime(process), m_read_objc_library(false),
- m_objc_trampoline_handler_ap(), m_Foundation_major() {
+ m_objc_trampoline_handler_up(), m_Foundation_major() {
ReadObjCLibraryIfNeeded(process->GetTarget().GetImages());
}
@@ -131,9 +130,9 @@ bool AppleObjCRuntime::GetObjectDescription(Stream &strm, Value &value,
// ret.SetContext(Value::eContextTypeClangType, return_compiler_type);
ret.SetCompilerType(return_compiler_type);
- if (exe_ctx.GetFramePtr() == NULL) {
+ if (exe_ctx.GetFramePtr() == nullptr) {
Thread *thread = exe_ctx.GetThreadPtr();
- if (thread == NULL) {
+ if (thread == nullptr) {
exe_ctx.SetThreadSP(process->GetThreadList().GetSelectedThread());
thread = exe_ctx.GetThreadPtr();
}
@@ -172,7 +171,7 @@ bool AppleObjCRuntime::GetObjectDescription(Stream &strm, Value &value,
options.SetTryAllThreads(true);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_po_function_timeout);
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetIsForUtilityExpr(true);
ExpressionResults results = m_print_object_caller_up->ExecuteFunction(
@@ -218,7 +217,7 @@ lldb::ModuleSP AppleObjCRuntime::GetObjCModule() {
}
Address *AppleObjCRuntime::GetPrintForDebuggerAddr() {
- if (!m_PrintForDebugger_addr.get()) {
+ if (!m_PrintForDebugger_addr) {
const ModuleList &modules = m_process->GetTarget().GetImages();
SymbolContextList contexts;
@@ -228,7 +227,7 @@ Address *AppleObjCRuntime::GetPrintForDebuggerAddr() {
eSymbolTypeCode, contexts)) &&
(!modules.FindSymbolsWithNameAndType(ConstString("_CFPrintForDebugger"),
eSymbolTypeCode, contexts)))
- return NULL;
+ return nullptr;
contexts.GetContextAtIndex(0, context);
@@ -240,7 +239,7 @@ Address *AppleObjCRuntime::GetPrintForDebuggerAddr() {
bool AppleObjCRuntime::CouldHaveDynamicValue(ValueObject &in_value) {
return in_value.GetCompilerType().IsPossibleDynamicType(
- NULL,
+ nullptr,
false, // do not check C++
true); // check ObjC
}
@@ -328,9 +327,9 @@ bool AppleObjCRuntime::ReadObjCLibrary(const ModuleSP &module_sp) {
// Maybe check here and if we have a handler already, and the UUID of this
// module is the same as the one in the current module, then we don't have to
// reread it?
- m_objc_trampoline_handler_ap.reset(
+ m_objc_trampoline_handler_up.reset(
new AppleObjCTrampolineHandler(m_process->shared_from_this(), module_sp));
- if (m_objc_trampoline_handler_ap.get() != NULL) {
+ if (m_objc_trampoline_handler_up != nullptr) {
m_read_objc_library = true;
return true;
} else
@@ -340,15 +339,13 @@ bool AppleObjCRuntime::ReadObjCLibrary(const ModuleSP &module_sp) {
ThreadPlanSP AppleObjCRuntime::GetStepThroughTrampolinePlan(Thread &thread,
bool stop_others) {
ThreadPlanSP thread_plan_sp;
- if (m_objc_trampoline_handler_ap.get())
- thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan(
+ if (m_objc_trampoline_handler_up)
+ thread_plan_sp = m_objc_trampoline_handler_up->GetStepThroughDispatchPlan(
thread, stop_others);
return thread_plan_sp;
}
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
ObjCLanguageRuntime::ObjCRuntimeVersions
AppleObjCRuntime::GetObjCVersion(Process *process, ModuleSP &objc_module_sp) {
if (!process)
@@ -456,28 +453,27 @@ bool AppleObjCRuntime::CalculateHasNewLiteralsAndIndexing() {
lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() {
Target &target = m_process->GetTarget();
+ FileSpecList filter_modules;
if (target.GetArchitecture().GetTriple().getVendor() == llvm::Triple::Apple) {
- FileSpecList filter_modules;
filter_modules.Append(std::get<0>(GetExceptionThrowLocation()));
- return target.GetSearchFilterForModuleList(&filter_modules);
- } else {
- return LanguageRuntime::CreateExceptionSearchFilter();
}
+ return target.GetSearchFilterForModuleList(&filter_modules);
}
ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
ThreadSP thread_sp) {
- auto cpp_runtime = m_process->GetCPPLanguageRuntime();
+ auto *cpp_runtime = m_process->GetLanguageRuntime(eLanguageTypeC_plus_plus);
if (!cpp_runtime) return ValueObjectSP();
auto cpp_exception = cpp_runtime->GetExceptionObjectForThread(thread_sp);
if (!cpp_exception) return ValueObjectSP();
-
- auto descriptor = GetClassDescriptor(*cpp_exception.get());
+
+ auto descriptor = GetClassDescriptor(*cpp_exception);
if (!descriptor || !descriptor->IsValid()) return ValueObjectSP();
while (descriptor) {
ConstString class_name(descriptor->GetClassName());
- if (class_name == ConstString("NSException")) return cpp_exception;
+ if (class_name == "NSException")
+ return cpp_exception;
descriptor = descriptor->GetSuperclass();
}
@@ -556,7 +552,7 @@ ThreadSP AppleObjCRuntime::GetBacktraceThreadFromException(
if (pcs.empty()) return ThreadSP();
- ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs, 0, false));
+ ThreadSP new_thread_sp(new HistoryThread(*m_process, 0, pcs));
m_process->GetExtendedThreadList().AddThread(new_thread_sp);
return new_thread_sp;
}
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
index 8660646001497..79ac53e1e440a 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h
@@ -1,9 +1,8 @@
//===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,30 +14,29 @@
#include "AppleObjCTrampolineHandler.h"
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_private {
class AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime {
public:
~AppleObjCRuntime() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
// Note there is no CreateInstance, Initialize & Terminate functions here,
// because
// you can't make an instance of this generic runtime.
- static bool classof(const ObjCLanguageRuntime *runtime) {
- switch (runtime->GetRuntimeVersion()) {
- case ObjCRuntimeVersions::eAppleObjC_V1:
- case ObjCRuntimeVersions::eAppleObjC_V2:
- return true;
- default:
- return false;
- }
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || ObjCLanguageRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
}
// These are generic runtime functions:
@@ -120,7 +118,7 @@ protected:
std::unique_ptr<Address> m_PrintForDebugger_addr;
bool m_read_objc_library;
std::unique_ptr<lldb_private::AppleObjCTrampolineHandler>
- m_objc_trampoline_handler_ap;
+ m_objc_trampoline_handler_up;
lldb::BreakpointSP m_objc_exception_bp_sp;
lldb::ModuleWP m_objc_module_wp;
std::unique_ptr<FunctionCaller> m_print_object_caller_up;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index 1cfc7a1a022b5..c8884fd5c9b9c 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -1,10 +1,9 @@
//===-- AppleObjCRuntimeV1.cpp --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,11 +31,14 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
+#include <memory>
#include <vector>
using namespace lldb;
using namespace lldb_private;
+char AppleObjCRuntimeV1::ID = 0;
+
AppleObjCRuntimeV1::AppleObjCRuntimeV1(Process *process)
: AppleObjCRuntime(process), m_hash_signature(),
m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS) {}
@@ -61,9 +63,7 @@ bool AppleObjCRuntimeV1::GetDynamicTypeAndAddress(
return !class_type_or_name.IsEmpty();
}
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
lldb_private::LanguageRuntime *
AppleObjCRuntimeV1::CreateInstance(Process *process,
lldb::LanguageType language) {
@@ -77,15 +77,16 @@ AppleObjCRuntimeV1::CreateInstance(Process *process,
ObjCRuntimeVersions::eAppleObjC_V1)
return new AppleObjCRuntimeV1(process);
else
- return NULL;
+ return nullptr;
} else
- return NULL;
+ return nullptr;
}
void AppleObjCRuntimeV1::Initialize() {
PluginManager::RegisterPlugin(
GetPluginNameStatic(), "Apple Objective-C Language Runtime - Version 1",
- CreateInstance);
+ CreateInstance,
+ /*command_callback = */ nullptr, GetBreakpointExceptionPrecondition);
}
void AppleObjCRuntimeV1::Terminate() {
@@ -97,9 +98,7 @@ lldb_private::ConstString AppleObjCRuntimeV1::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString AppleObjCRuntimeV1::GetPluginName() {
return GetPluginNameStatic();
}
@@ -112,10 +111,10 @@ AppleObjCRuntimeV1::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp,
BreakpointResolverSP resolver_sp;
if (throw_bp)
- resolver_sp.reset(new BreakpointResolverName(
+ resolver_sp = std::make_shared<BreakpointResolverName>(
bkpt, std::get<1>(GetExceptionThrowLocation()).AsCString(),
eFunctionNameTypeBase, eLanguageTypeUnknown, Breakpoint::Exact, 0,
- eLazyBoolNo));
+ eLazyBoolNo);
// FIXME: don't do catch yet.
return resolver_sp;
}
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
index 442a3a1fb5e1e..6fdae63d4126e 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
@@ -1,9 +1,8 @@
//===-- AppleObjCRuntimeV1.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,18 +10,17 @@
#define liblldb_AppleObjCRuntimeV1_h_
#include "AppleObjCRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_private {
class AppleObjCRuntimeV1 : public AppleObjCRuntime {
public:
~AppleObjCRuntimeV1() override = default;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -32,13 +30,14 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- static bool classof(const ObjCLanguageRuntime *runtime) {
- switch (runtime->GetRuntimeVersion()) {
- case ObjCRuntimeVersions::eAppleObjC_V1:
- return true;
- default:
- return false;
- }
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || AppleObjCRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
}
lldb::addr_t GetTaggedPointerObfuscator();
@@ -100,9 +99,7 @@ public:
UtilityFunction *CreateObjectChecker(const char *) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -148,7 +145,7 @@ protected:
HashTableSignature m_hash_signature;
lldb::addr_t m_isa_hash_table_ptr;
- std::unique_ptr<DeclVendor> m_decl_vendor_ap;
+ std::unique_ptr<DeclVendor> m_decl_vendor_up;
private:
AppleObjCRuntimeV1(Process *process);
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index b6ed2fe376d35..635eaff637bcb 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1,14 +1,14 @@
//===-- AppleObjCRuntimeV2.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <stdint.h>
+#include <memory>
#include <string>
#include <vector>
@@ -65,13 +65,14 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclObjC.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
#include <vector>
using namespace lldb;
using namespace lldb_private;
-// 2 second timeout when running utility functions
-static constexpr std::chrono::seconds g_utility_function_timeout(2);
+char AppleObjCRuntimeV2::ID = 0;
static const char *g_get_dynamic_class_info_name =
"__lldb_apple_objc_v2_get_dynamic_class_info";
@@ -157,6 +158,16 @@ __lldb_apple_objc_v2_get_dynamic_class_info (void *gdb_objc_realized_classes_ptr
)";
+// We'll substitute in class_getName or class_getNameRaw depending
+// on which is present.
+static const char *g_shared_cache_class_name_funcptr = R"(
+extern "C"
+{
+ const char *%s(void *objc_class);
+ const char *(*class_name_lookup_func)(void *) = %s;
+}
+)";
+
static const char *g_get_shared_cache_class_info_name =
"__lldb_apple_objc_v2_get_shared_cache_class_info";
// Testing using the new C++11 raw string literals. If this breaks GCC then we
@@ -165,7 +176,6 @@ static const char *g_get_shared_cache_class_info_body = R"(
extern "C"
{
- const char *class_getName(void *objc_class);
size_t strlen(const char *);
char *strncpy (char * s1, const char * s2, size_t n);
int printf(const char * format, ...);
@@ -286,13 +296,24 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
if (class_infos && idx < max_class_infos)
{
class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
- const char *name = class_getName (class_infos[idx].isa);
+ const char *name = class_name_lookup_func (class_infos[idx].isa);
DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
// Hash the class name so we don't have to read it
const char *s = name;
uint32_t h = 5381;
for (unsigned char c = *s; c; c = *++s)
+ {
+ // class_getName demangles swift names and the hash must
+ // be calculated on the mangled name. hash==0 means lldb
+ // will fetch the mangled name and compute the hash in
+ // ParseClassInfoArray.
+ if (c == '.')
+ {
+ h = 0;
+ break;
+ }
h = ((h << 5) + h) + c;
+ }
class_infos[idx].hash = h;
}
else
@@ -318,13 +339,24 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
if (class_infos && idx < max_class_infos)
{
class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
- const char *name = class_getName (class_infos[idx].isa);
+ const char *name = class_name_lookup_func (class_infos[idx].isa);
DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, name);
// Hash the class name so we don't have to read it
const char *s = name;
uint32_t h = 5381;
for (unsigned char c = *s; c; c = *++s)
+ {
+ // class_getName demangles swift names and the hash must
+ // be calculated on the mangled name. hash==0 means lldb
+ // will fetch the mangled name and compute the hash in
+ // ParseClassInfoArray.
+ if (c == '.')
+ {
+ h = 0;
+ break;
+ }
h = ((h << 5) + h) + c;
+ }
class_infos[idx].hash = h;
}
++idx;
@@ -384,20 +416,20 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
m_get_class_info_args(LLDB_INVALID_ADDRESS),
m_get_class_info_args_mutex(), m_get_shared_cache_class_info_code(),
m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS),
- m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_ap(),
+ m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_up(),
m_tagged_pointer_obfuscator(LLDB_INVALID_ADDRESS),
- m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS),
- m_hash_signature(),
+ m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), m_hash_signature(),
m_has_object_getClass(false), m_loaded_objc_opt(false),
- m_non_pointer_isa_cache_ap(
+ m_non_pointer_isa_cache_up(
NonPointerISACache::CreateInstance(*this, objc_module_sp)),
- m_tagged_pointer_vendor_ap(
+ m_tagged_pointer_vendor_up(
TaggedPointerVendorV2::CreateInstance(*this, objc_module_sp)),
m_encoding_to_type_sp(), m_noclasses_warning_emitted(false),
m_CFBoolean_values() {
static const ConstString g_gdb_object_getClass("gdb_object_getClass");
- m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(
- g_gdb_object_getClass, eSymbolTypeCode) != NULL);
+ m_has_object_getClass =
+ (objc_module_sp->FindFirstSymbolWithNameAndType(
+ g_gdb_object_getClass, eSymbolTypeCode) != nullptr);
RegisterObjCExceptionRecognizer();
}
@@ -406,7 +438,7 @@ bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
TypeAndOrName &class_type_or_name, Address &address,
Value::ValueType &value_type) {
// We should never get here with a null process...
- assert(m_process != NULL);
+ assert(m_process != nullptr);
// The Runtime is attached to a particular process, you shouldn't pass in a
// value from another process. Note, however, the process might be NULL (e.g.
@@ -443,12 +475,10 @@ bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
class_type_or_name.SetTypeSP(type_sp);
} else {
// try to go for a CompilerType at least
- DeclVendor *vendor = GetDeclVendor();
- if (vendor) {
- std::vector<clang::NamedDecl *> decls;
- if (vendor->FindDecls(class_name, false, 1, decls) && decls.size())
- class_type_or_name.SetCompilerType(
- ClangASTContext::GetTypeForDecl(decls[0]));
+ if (auto *vendor = GetDeclVendor()) {
+ auto types = vendor->FindTypes(class_name, /*max_matches*/ 1);
+ if (!types.empty())
+ class_type_or_name.SetCompilerType(types.front());
}
}
}
@@ -457,9 +487,7 @@ bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress(
return !class_type_or_name.IsEmpty();
}
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process,
LanguageType language) {
// FIXME: This should be a MacOS or iOS process, and we need to look for the
@@ -472,9 +500,9 @@ LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process,
ObjCRuntimeVersions::eAppleObjC_V2)
return new AppleObjCRuntimeV2(process, objc_module_sp);
else
- return NULL;
+ return nullptr;
} else
- return NULL;
+ return nullptr;
}
static constexpr OptionDefinition g_objc_classtable_dump_options[] = {
@@ -572,7 +600,7 @@ protected:
}
Process *process = m_exe_ctx.GetProcessPtr();
- ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process);
if (objc_runtime) {
auto iterators_pair = objc_runtime->GetDescriptorIteratorPair();
auto iterator = iterators_pair.first;
@@ -674,7 +702,7 @@ protected:
Process *process = m_exe_ctx.GetProcessPtr();
ExecutionContext exe_ctx(process);
- ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process);
if (objc_runtime) {
ObjCLanguageRuntime::TaggedPointerVendor *tagged_ptr_vendor =
objc_runtime->GetTaggedPointerVendor();
@@ -777,7 +805,8 @@ void AppleObjCRuntimeV2::Initialize() {
CreateInstance,
[](CommandInterpreter &interpreter) -> lldb::CommandObjectSP {
return CommandObjectSP(new CommandObjectMultiwordObjC(interpreter));
- });
+ },
+ GetBreakpointExceptionPrecondition);
}
void AppleObjCRuntimeV2::Terminate() {
@@ -789,9 +818,7 @@ lldb_private::ConstString AppleObjCRuntimeV2::GetPluginNameStatic() {
return g_name;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString AppleObjCRuntimeV2::GetPluginName() {
return GetPluginNameStatic();
}
@@ -804,10 +831,10 @@ AppleObjCRuntimeV2::CreateExceptionResolver(Breakpoint *bkpt, bool catch_bp,
BreakpointResolverSP resolver_sp;
if (throw_bp)
- resolver_sp.reset(new BreakpointResolverName(
+ resolver_sp = std::make_shared<BreakpointResolverName>(
bkpt, std::get<1>(GetExceptionThrowLocation()).AsCString(),
eFunctionNameTypeBase, eLanguageTypeUnknown, Breakpoint::Exact, 0,
- eLazyBoolNo));
+ eLazyBoolNo);
// FIXME: We don't do catch breakpoints for ObjC yet.
// Should there be some way for the runtime to specify what it can do in this
// regard?
@@ -872,20 +899,16 @@ size_t AppleObjCRuntimeV2::GetByteOffsetForIvar(CompilerType &parent_ast_type,
const char *class_name = parent_ast_type.GetConstTypeName().AsCString();
if (class_name && class_name[0] && ivar_name && ivar_name[0]) {
- //----------------------------------------------------------------------
// Make the objective C V2 mangled name for the ivar offset from the class
// name and ivar name
- //----------------------------------------------------------------------
std::string buffer("OBJC_IVAR_$_");
buffer.append(class_name);
buffer.push_back('.');
buffer.append(ivar_name);
ConstString ivar_const_str(buffer.c_str());
- //----------------------------------------------------------------------
// Try to get the ivar offset address from the symbol table first using the
// name we created above
- //----------------------------------------------------------------------
SymbolContextList sc_list;
Target &target = m_process->GetTarget();
target.GetImages().FindSymbolsWithNameAndType(ivar_const_str,
@@ -902,10 +925,8 @@ size_t AppleObjCRuntimeV2::GetByteOffsetForIvar(CompilerType &parent_ast_type,
ivar_offset_symbol.symbol->GetLoadAddress(&target);
}
- //----------------------------------------------------------------------
// If we didn't get the ivar offset address from the symbol table, fall
// back to getting it from the runtime
- //----------------------------------------------------------------------
if (ivar_offset_address == LLDB_INVALID_ADDRESS)
ivar_offset_address = LookupRuntimeSymbol(ivar_const_str);
@@ -921,16 +942,16 @@ size_t AppleObjCRuntimeV2::GetByteOffsetForIvar(CompilerType &parent_ast_type,
// computational effort as possible whether something could possibly be a
// tagged pointer - false positives are possible but false negatives shouldn't
bool AppleObjCRuntimeV2::IsTaggedPointer(addr_t ptr) {
- if (!m_tagged_pointer_vendor_ap)
+ if (!m_tagged_pointer_vendor_up)
return false;
- return m_tagged_pointer_vendor_ap->IsPossibleTaggedPointer(ptr);
+ return m_tagged_pointer_vendor_up->IsPossibleTaggedPointer(ptr);
}
class RemoteNXMapTable {
public:
RemoteNXMapTable()
: m_count(0), m_num_buckets_minus_one(0),
- m_buckets_ptr(LLDB_INVALID_ADDRESS), m_process(NULL),
+ m_buckets_ptr(LLDB_INVALID_ADDRESS), m_process(nullptr),
m_end_iterator(*this, -1), m_load_addr(LLDB_INVALID_ADDRESS),
m_map_pair_size(0), m_invalid_key(0) {}
@@ -1148,8 +1169,8 @@ bool AppleObjCRuntimeV2::HashTableSignature::NeedsUpdate(
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA isa) {
ObjCLanguageRuntime::ClassDescriptorSP class_descriptor_sp;
- if (m_non_pointer_isa_cache_ap.get())
- class_descriptor_sp = m_non_pointer_isa_cache_ap->GetClassDescriptor(isa);
+ if (m_non_pointer_isa_cache_up)
+ class_descriptor_sp = m_non_pointer_isa_cache_up->GetClassDescriptor(isa);
if (!class_descriptor_sp)
class_descriptor_sp = ObjCLanguageRuntime::GetClassDescriptorFromISA(isa);
return class_descriptor_sp;
@@ -1176,7 +1197,7 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
// tagged pointer
if (IsTaggedPointer(isa_pointer)) {
- return m_tagged_pointer_vendor_ap->GetClassDescriptor(isa_pointer);
+ return m_tagged_pointer_vendor_up->GetClassDescriptor(isa_pointer);
} else {
ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
@@ -1265,7 +1286,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
RemoteNXMapTable &hash_table) {
Process *process = GetProcess();
- if (process == NULL)
+ if (process == nullptr)
return DescriptorMapUpdateResult::Fail();
uint32_t num_class_infos = 0;
@@ -1310,7 +1331,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
ValueList arguments;
FunctionCaller *get_class_info_function = nullptr;
- if (!m_get_class_info_code.get()) {
+ if (!m_get_class_info_code) {
Status error;
m_get_class_info_code.reset(GetTargetRef().GetUtilityFunctionForLanguage(
g_get_dynamic_class_info_body, eLanguageTypeObjC,
@@ -1332,7 +1353,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
m_get_class_info_code.reset();
}
}
- if (!m_get_class_info_code.get())
+ if (!m_get_class_info_code)
return DescriptorMapUpdateResult::Fail();
// Next make the runner function for our implementation utility function.
@@ -1411,7 +1432,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
options.SetTryAllThreads(false);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_utility_function_timeout);
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetIsForUtilityExpr(true);
Value return_value;
@@ -1501,8 +1522,18 @@ uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data,
} else {
// Read the 32 bit hash for the class name
const uint32_t name_hash = data.GetU32(&offset);
- ClassDescriptorSP descriptor_sp(new ClassDescriptorV2(*this, isa, NULL));
- AddClass(isa, descriptor_sp, name_hash);
+ ClassDescriptorSP descriptor_sp(
+ new ClassDescriptorV2(*this, isa, nullptr));
+
+ // The code in g_get_shared_cache_class_info_body sets the value of the hash
+ // to 0 to signal a demangled symbol. We use class_getName() in that code to
+ // find the class name, but this returns a demangled name for Swift symbols.
+ // For those symbols, recompute the hash here by reading their name from the
+ // runtime.
+ if (name_hash)
+ AddClass(isa, descriptor_sp, name_hash);
+ else
+ AddClass(isa, descriptor_sp, descriptor_sp->GetClassName().AsCString(nullptr));
num_parsed++;
if (should_log)
log->Printf("AppleObjCRuntimeV2 added isa=0x%" PRIx64
@@ -1521,7 +1552,7 @@ AppleObjCRuntimeV2::DescriptorMapUpdateResult
AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
Process *process = GetProcess();
- if (process == NULL)
+ if (process == nullptr)
return DescriptorMapUpdateResult::Fail();
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_TYPES));
@@ -1565,11 +1596,54 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
ValueList arguments;
FunctionCaller *get_shared_cache_class_info_function = nullptr;
- if (!m_get_shared_cache_class_info_code.get()) {
+ if (!m_get_shared_cache_class_info_code) {
Status error;
+
+ // If the inferior objc.dylib has the class_getNameRaw function,
+ // use that in our jitted expression. Else fall back to the old
+ // class_getName.
+ static ConstString g_class_getName_symbol_name("class_getName");
+ static ConstString g_class_getNameRaw_symbol_name("class_getNameRaw");
+ ConstString class_name_getter_function_name = g_class_getName_symbol_name;
+
+ ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process);
+ if (objc_runtime) {
+ const ModuleList &images = process->GetTarget().GetImages();
+ std::lock_guard<std::recursive_mutex> guard(images.GetMutex());
+ for (size_t i = 0; i < images.GetSize(); ++i) {
+ lldb::ModuleSP mod_sp = images.GetModuleAtIndexUnlocked(i);
+ if (objc_runtime->IsModuleObjCLibrary(mod_sp)) {
+ const Symbol *symbol =
+ mod_sp->FindFirstSymbolWithNameAndType(g_class_getNameRaw_symbol_name,
+ lldb::eSymbolTypeCode);
+ if (symbol &&
+ (symbol->ValueIsAddress() || symbol->GetAddressRef().IsValid())) {
+ class_name_getter_function_name = g_class_getNameRaw_symbol_name;
+ }
+ }
+ }
+ }
+
+ // Substitute in the correct class_getName / class_getNameRaw function name,
+ // concatenate the two parts of our expression text. The format string
+ // has two %s's, so provide the name twice.
+ int prefix_string_size = snprintf (nullptr, 0,
+ g_shared_cache_class_name_funcptr,
+ class_name_getter_function_name.AsCString(),
+ class_name_getter_function_name.AsCString());
+
+ char *class_name_func_ptr_expr = (char*) malloc (prefix_string_size + 1);
+ snprintf (class_name_func_ptr_expr, prefix_string_size + 1,
+ g_shared_cache_class_name_funcptr,
+ class_name_getter_function_name.AsCString(),
+ class_name_getter_function_name.AsCString());
+ std::string shared_class_expression = class_name_func_ptr_expr;
+ shared_class_expression += g_get_shared_cache_class_info_body;
+ free (class_name_func_ptr_expr);
+
m_get_shared_cache_class_info_code.reset(
GetTargetRef().GetUtilityFunctionForLanguage(
- g_get_shared_cache_class_info_body, eLanguageTypeObjC,
+ shared_class_expression.c_str(), eLanguageTypeObjC,
g_get_shared_cache_class_info_name, error));
if (error.Fail()) {
if (log)
@@ -1589,7 +1663,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
}
}
- if (!m_get_shared_cache_class_info_code.get())
+ if (!m_get_shared_cache_class_info_code)
return DescriptorMapUpdateResult::Fail();
// Next make the function caller for our implementation utility function.
@@ -1662,7 +1736,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
options.SetTryAllThreads(false);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_utility_function_timeout);
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetIsForUtilityExpr(true);
Value return_value;
@@ -1686,9 +1760,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
if (log)
log->Printf("Discovered %u ObjC classes in shared cache\n",
num_class_infos);
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(num_class_infos <= num_classes);
-#endif
if (num_class_infos > 0) {
if (num_class_infos > num_classes) {
num_class_infos = num_classes;
@@ -1737,7 +1809,7 @@ bool AppleObjCRuntimeV2::UpdateISAToDescriptorMapFromMemory(
Process *process = GetProcess();
- if (process == NULL)
+ if (process == nullptr)
return false;
uint32_t num_map_table_isas = 0;
@@ -1946,13 +2018,13 @@ AppleObjCRuntimeV2::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) {
}
DeclVendor *AppleObjCRuntimeV2::GetDeclVendor() {
- if (!m_decl_vendor_ap.get())
- m_decl_vendor_ap.reset(new AppleObjCDeclVendor(*this));
+ if (!m_decl_vendor_up)
+ m_decl_vendor_up.reset(new AppleObjCDeclVendor(*this));
- return m_decl_vendor_ap.get();
+ return m_decl_vendor_up.get();
}
-lldb::addr_t AppleObjCRuntimeV2::LookupRuntimeSymbol(const ConstString &name) {
+lldb::addr_t AppleObjCRuntimeV2::LookupRuntimeSymbol(ConstString name) {
lldb::addr_t ret = LLDB_INVALID_ADDRESS;
const char *name_cstr = name.AsCString();
@@ -2022,18 +2094,18 @@ AppleObjCRuntimeV2::NonPointerISACache::CreateInstance(
auto objc_debug_isa_magic_mask = ExtractRuntimeGlobalSymbol(
process, ConstString("objc_debug_isa_magic_mask"), objc_module_sp, error);
if (error.Fail())
- return NULL;
+ return nullptr;
auto objc_debug_isa_magic_value = ExtractRuntimeGlobalSymbol(
process, ConstString("objc_debug_isa_magic_value"), objc_module_sp,
error);
if (error.Fail())
- return NULL;
+ return nullptr;
auto objc_debug_isa_class_mask = ExtractRuntimeGlobalSymbol(
process, ConstString("objc_debug_isa_class_mask"), objc_module_sp, error);
if (error.Fail())
- return NULL;
+ return nullptr;
if (log)
log->PutCString("AOCRT::NPI: Found all the non-indexed ISA masks");
@@ -2550,7 +2622,8 @@ bool AppleObjCRuntimeV2::NonPointerISACache::EvaluateNonPointerISA(
ObjCLanguageRuntime::EncodingToTypeSP AppleObjCRuntimeV2::GetEncodingToType() {
if (!m_encoding_to_type_sp)
- m_encoding_to_type_sp.reset(new AppleObjCTypeEncodingParser(*this));
+ m_encoding_to_type_sp =
+ std::make_shared<AppleObjCTypeEncodingParser>(*this);
return m_encoding_to_type_sp;
}
@@ -2558,8 +2631,8 @@ lldb_private::AppleObjCRuntime::ObjCISA
AppleObjCRuntimeV2::GetPointerISA(ObjCISA isa) {
ObjCISA ret = isa;
- if (m_non_pointer_isa_cache_ap)
- m_non_pointer_isa_cache_ap->EvaluateNonPointerISA(isa, ret);
+ if (m_non_pointer_isa_cache_up)
+ m_non_pointer_isa_cache_up->EvaluateNonPointerISA(isa, ret);
return ret;
}
@@ -2629,6 +2702,8 @@ class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
value.SetCompilerType(voidstar);
exception = ValueObjectConstResult::Create(frame_sp.get(), value,
ConstString("exception"));
+ exception = ValueObjectRecognizerSynthesizedValue::Create(
+ *exception, eValueTypeVariableArgument);
exception = exception->GetDynamicValue(eDynamicDontRunTarget);
m_arguments = ValueObjectListSP(new ValueObjectList());
@@ -2641,7 +2716,8 @@ class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
};
class ObjCExceptionThrowFrameRecognizer : public StackFrameRecognizer {
- lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame) {
+ lldb::RecognizedStackFrameSP
+ RecognizeFrame(lldb::StackFrameSP frame) override {
return lldb::RecognizedStackFrameSP(
new ObjCExceptionRecognizedStackFrame(frame));
};
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
index aa91f857219b2..a0fd39dc03b20 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -1,9 +1,8 @@
//===-- AppleObjCRuntimeV2.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,10 @@
#include <mutex>
#include "AppleObjCRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
class RemoteNXMapTable;
namespace lldb_private {
@@ -26,9 +26,7 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
public:
~AppleObjCRuntimeV2() override = default;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -38,13 +36,14 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
- static bool classof(const ObjCLanguageRuntime *runtime) {
- switch (runtime->GetRuntimeVersion()) {
- case ObjCRuntimeVersions::eAppleObjC_V2:
- return true;
- default:
- return false;
- }
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || AppleObjCRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
}
// These are generic runtime functions:
@@ -56,9 +55,7 @@ public:
UtilityFunction *CreateObjectChecker(const char *) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -80,14 +77,14 @@ public:
DeclVendor *GetDeclVendor() override;
- lldb::addr_t LookupRuntimeSymbol(const ConstString &name) override;
+ lldb::addr_t LookupRuntimeSymbol(ConstString name) override;
EncodingToTypeSP GetEncodingToType() override;
bool IsTaggedPointer(lldb::addr_t ptr) override;
TaggedPointerVendor *GetTaggedPointerVendor() override {
- return m_tagged_pointer_vendor_ap.get();
+ return m_tagged_pointer_vendor_up.get();
}
lldb::addr_t GetTaggedPointerObfuscator();
@@ -327,14 +324,14 @@ private:
lldb::addr_t m_get_shared_cache_class_info_args;
std::mutex m_get_shared_cache_class_info_args_mutex;
- std::unique_ptr<DeclVendor> m_decl_vendor_ap;
+ std::unique_ptr<DeclVendor> m_decl_vendor_up;
lldb::addr_t m_tagged_pointer_obfuscator;
lldb::addr_t m_isa_hash_table_ptr;
HashTableSignature m_hash_signature;
bool m_has_object_getClass;
bool m_loaded_objc_opt;
- std::unique_ptr<NonPointerISACache> m_non_pointer_isa_cache_ap;
- std::unique_ptr<TaggedPointerVendor> m_tagged_pointer_vendor_ap;
+ std::unique_ptr<NonPointerISACache> m_non_pointer_isa_cache_up;
+ std::unique_ptr<TaggedPointerVendor> m_tagged_pointer_vendor_up;
EncodingToTypeSP m_encoding_to_type_sp;
bool m_noclasses_warning_emitted;
llvm::Optional<std::pair<lldb::addr_t, lldb::addr_t>> m_CFBoolean_values;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
index e9182c5909773..b3eb09caa86dc 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
@@ -1,15 +1,13 @@
//===-- AppleObjCTrampolineHandler.cpp ----------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "AppleObjCTrampolineHandler.h"
-
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -25,7 +23,6 @@
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
@@ -37,6 +34,10 @@
#include "llvm/ADT/STLExtras.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -457,8 +458,9 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols() {
size_t num_modules = target_modules.GetSize();
if (!m_objc_module_sp) {
for (size_t i = 0; i < num_modules; i++) {
- if (process_sp->GetObjCLanguageRuntime()->IsModuleObjCLibrary(
- target_modules.GetModuleAtIndexUnlocked(i))) {
+ if (ObjCLanguageRuntime::Get(*process_sp)
+ ->IsModuleObjCLibrary(
+ target_modules.GetModuleAtIndexUnlocked(i))) {
m_objc_module_sp = target_modules.GetModuleAtIndexUnlocked(i);
break;
}
@@ -470,7 +472,7 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols() {
const Symbol *trampoline_symbol =
m_objc_module_sp->FindFirstSymbolWithNameAndType(trampoline_name,
eSymbolTypeData);
- if (trampoline_symbol != NULL) {
+ if (trampoline_symbol != nullptr) {
m_trampoline_header = trampoline_symbol->GetLoadAddress(&target);
if (m_trampoline_header == LLDB_INVALID_ADDRESS)
return false;
@@ -480,7 +482,7 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols() {
const Symbol *changed_symbol =
m_objc_module_sp->FindFirstSymbolWithNameAndType(changed_name,
eSymbolTypeCode);
- if (changed_symbol != NULL) {
+ if (changed_symbol != nullptr) {
const Address changed_symbol_addr = changed_symbol->GetAddress();
if (!changed_symbol_addr.IsValid())
return false;
@@ -541,7 +543,7 @@ bool AppleObjCTrampolineHandler::AppleObjCVTables::RefreshTrampolines(
Status error;
DataExtractor data;
error = argument_values.GetValueAtIndex(0)->GetValueAsData(&exe_ctx, data,
- 0, NULL);
+ 0, nullptr);
lldb::offset_t offset = 0;
lldb::addr_t region_addr = data.GetPointer(&offset);
@@ -668,7 +670,7 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(
ConstString msg_forward_name("_objc_msgForward");
ConstString msg_forward_stret_name("_objc_msgForward_stret");
- Target *target = process_sp ? &process_sp->GetTarget() : NULL;
+ Target *target = process_sp ? &process_sp->GetTarget() : nullptr;
const Symbol *class_getMethodImplementation =
m_objc_module_sp->FindFirstSymbolWithNameAndType(get_impl_name,
eSymbolTypeCode);
@@ -748,9 +750,9 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler(
}
// Build our vtable dispatch handler here:
- m_vtables_ap.reset(new AppleObjCVTables(process_sp, m_objc_module_sp));
- if (m_vtables_ap.get())
- m_vtables_ap->ReadRegions();
+ m_vtables_up.reset(new AppleObjCVTables(process_sp, m_objc_module_sp));
+ if (m_vtables_up)
+ m_vtables_up->ReadRegions();
}
lldb::addr_t
@@ -770,8 +772,8 @@ AppleObjCTrampolineHandler::SetupDispatchFunction(Thread &thread,
// First stage is to make the ClangUtility to hold our injected function:
- if (!m_impl_code.get()) {
- if (m_lookup_implementation_function_code != NULL) {
+ if (!m_impl_code) {
+ if (m_lookup_implementation_function_code != nullptr) {
Status error;
m_impl_code.reset(exe_ctx.GetTargetRef().GetUtilityFunctionForLanguage(
m_lookup_implementation_function_code, eLanguageTypeObjC,
@@ -864,8 +866,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
if (!found_it) {
uint32_t flags;
- if (m_vtables_ap.get()) {
- found_it = m_vtables_ap->IsAddressInVTables(curr_pc, flags);
+ if (m_vtables_up) {
+ found_it = m_vtables_up->IsAddressInVTables(curr_pc, flags);
if (found_it) {
this_dispatch.name = "vtable";
this_dispatch.stret_return =
@@ -886,11 +888,11 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
lldb::StackFrameSP thread_cur_frame = thread.GetStackFrameAtIndex(0);
- const ABI *abi = NULL;
+ const ABI *abi = nullptr;
ProcessSP process_sp(thread.CalculateProcess());
if (process_sp)
abi = process_sp->GetABI().get();
- if (abi == NULL)
+ if (abi == nullptr)
return ret_plan_sp;
TargetSP target_sp(thread.CalculateTarget());
@@ -1036,8 +1038,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
isa_addr, sel_addr);
}
ObjCLanguageRuntime *objc_runtime =
- thread.GetProcess()->GetObjCLanguageRuntime();
- assert(objc_runtime != NULL);
+ ObjCLanguageRuntime::Get(*thread.GetProcess());
+ assert(objc_runtime != nullptr);
impl_addr = objc_runtime->LookupInMethodCache(isa_addr, sel_addr);
}
@@ -1049,8 +1051,8 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
log->Printf("Found implementation address in cache: 0x%" PRIx64,
impl_addr);
- ret_plan_sp.reset(
- new ThreadPlanRunToAddress(thread, impl_addr, stop_others));
+ ret_plan_sp = std::make_shared<ThreadPlanRunToAddress>(thread, impl_addr,
+ stop_others);
} else {
// We haven't seen this class/selector pair yet. Look it up.
StreamString errors;
@@ -1129,9 +1131,9 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan(Thread &thread,
// is not safe to run only one thread. So we override the
// stop_others value passed in to us here:
const bool trampoline_stop_others = false;
- ret_plan_sp.reset(new AppleThreadPlanStepThroughObjCTrampoline(
+ ret_plan_sp = std::make_shared<AppleThreadPlanStepThroughObjCTrampoline>(
thread, this, dispatch_values, isa_addr, sel_addr,
- trampoline_stop_others));
+ trampoline_stop_others);
if (log) {
StreamString s;
ret_plan_sp->GetDescription(&s, eDescriptionLevelFull);
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
index fe3390757d080..d120d671eeb3e 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h
@@ -1,9 +1,8 @@
//===-- AppleObjCTrampolineHandler.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,7 +36,7 @@ public:
struct DispatchFunction {
public:
- typedef enum { eFixUpNone, eFixUpFixed, eFixUpToFix } FixUpState;
+ enum FixUpState { eFixUpNone, eFixUpFixed, eFixUpToFix };
const char *name;
bool stret_return;
@@ -75,8 +74,9 @@ private:
class VTableRegion {
public:
VTableRegion()
- : m_valid(false), m_owner(NULL), m_header_addr(LLDB_INVALID_ADDRESS),
- m_code_start_addr(0), m_code_end_addr(0), m_next_region(0) {}
+ : m_valid(false), m_owner(nullptr),
+ m_header_addr(LLDB_INVALID_ADDRESS), m_code_start_addr(0),
+ m_code_end_addr(0), m_next_region(0) {}
VTableRegion(AppleObjCVTables *owner, lldb::addr_t header_addr);
@@ -150,7 +150,7 @@ private:
lldb::addr_t m_impl_stret_fn_addr;
lldb::addr_t m_msg_forward_addr;
lldb::addr_t m_msg_forward_stret_addr;
- std::unique_ptr<AppleObjCVTables> m_vtables_ap;
+ std::unique_ptr<AppleObjCVTables> m_vtables_up;
};
} // namespace lldb_private
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
index 9bb1a4e0ee42b..26654e9212b9b 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp
@@ -1,9 +1,8 @@
//===-- AppleObjCTypeEncodingParser.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,8 +23,8 @@ using namespace lldb_utility;
AppleObjCTypeEncodingParser::AppleObjCTypeEncodingParser(
ObjCLanguageRuntime &runtime)
: ObjCLanguageRuntime::EncodingToType(), m_runtime(runtime) {
- if (!m_scratch_ast_ctx_ap)
- m_scratch_ast_ctx_ap.reset(new ClangASTContext(runtime.GetProcess()
+ if (!m_scratch_ast_ctx_up)
+ m_scratch_ast_ctx_up.reset(new ClangASTContext(runtime.GetProcess()
->GetTarget()
.GetArchitecture()
.GetTriple()
@@ -246,25 +245,19 @@ clang::QualType AppleObjCTypeEncodingParser::BuildObjCObjectPointerType(
if (!decl_vendor)
return clang::QualType();
- const bool append = false;
- const uint32_t max_matches = 1;
- std::vector<clang::NamedDecl *> decls;
-
- uint32_t num_types =
- decl_vendor->FindDecls(ConstString(name), append, max_matches, decls);
+ auto types = decl_vendor->FindTypes(ConstString(name), /*max_matches*/ 1);
// The user can forward-declare something that has no definition. The runtime
// doesn't prohibit this at all. This is a rare and very weird case. We keep
// this assert in debug builds so we catch other weird cases.
#ifdef LLDB_CONFIGURATION_DEBUG
- assert(num_types);
+ assert(!types.empty());
#else
- if (!num_types)
+ if (types.empty())
return ast_ctx.getObjCIdType();
#endif
- return ClangUtil::GetQualType(
- ClangASTContext::GetTypeForDecl(decls[0]).GetPointerType());
+ return ClangUtil::GetQualType(types.front().GetPointerType());
} else {
// We're going to resolve this dynamically anyway, so just smile and wave.
return ast_ctx.getObjCIdType();
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
index fac564e331653..e576e8f283f20 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.h
@@ -1,9 +1,8 @@
//===-- AppleObjCTypeEncodingParser.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,9 +11,10 @@
#include "clang/AST/ASTContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
namespace lldb_utility {
class StringLexer;
}
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
index 2b54d0a542d95..d18435c9c6dbc 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
@@ -1,32 +1,32 @@
//===-- AppleThreadPlanStepThroughObjCTrampoline.cpp
-//--------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "AppleThreadPlanStepThroughObjCTrampoline.h"
+
#include "AppleObjCTrampolineHandler.h"
#include "lldb/Expression/DiagnosticManager.h"
#include "lldb/Expression/FunctionCaller.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/ThreadPlanRunToAddress.h"
#include "lldb/Target/ThreadPlanStepOut.h"
#include "lldb/Utility/Log.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
+
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepThroughObjCTrampoline constructor
-//----------------------------------------------------------------------
AppleThreadPlanStepThroughObjCTrampoline::
AppleThreadPlanStepThroughObjCTrampoline(
Thread &thread, AppleObjCTrampolineHandler *trampoline_handler,
@@ -37,12 +37,10 @@ AppleThreadPlanStepThroughObjCTrampoline::
eVoteNoOpinion),
m_trampoline_handler(trampoline_handler),
m_args_addr(LLDB_INVALID_ADDRESS), m_input_values(input_values),
- m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(NULL),
+ m_isa_addr(isa_addr), m_sel_addr(sel_addr), m_impl_function(nullptr),
m_stop_others(stop_others) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
AppleThreadPlanStepThroughObjCTrampoline::
~AppleThreadPlanStepThroughObjCTrampoline() {}
@@ -174,8 +172,8 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
target_addr);
ObjCLanguageRuntime *objc_runtime =
- GetThread().GetProcess()->GetObjCLanguageRuntime();
- assert(objc_runtime != NULL);
+ ObjCLanguageRuntime::Get(*GetThread().GetProcess());
+ assert(objc_runtime != nullptr);
objc_runtime->AddToMethodCache(m_isa_addr, m_sel_addr, target_addr);
if (log)
log->Printf("Adding {isa-addr=0x%" PRIx64 ", sel-addr=0x%" PRIx64
@@ -184,8 +182,8 @@ bool AppleThreadPlanStepThroughObjCTrampoline::ShouldStop(Event *event_ptr) {
// Extract the target address from the value:
- m_run_to_sp.reset(
- new ThreadPlanRunToAddress(m_thread, target_so_addr, m_stop_others));
+ m_run_to_sp = std::make_shared<ThreadPlanRunToAddress>(
+ m_thread, target_so_addr, m_stop_others);
m_thread.QueueThreadPlan(m_run_to_sp, false);
m_run_to_sp->SetPrivate(true);
return false;
diff --git a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
index 5758e19f83ca8..96f37851a35fc 100644
--- a/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
+++ b/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h
@@ -1,9 +1,8 @@
//===-- AppleThreadPlanStepThroughObjCTrampoline.h --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/ObjCLanguageRuntime.cpp b/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
index 8627da938ea34..631c15c46ce85 100644
--- a/source/Target/ObjCLanguageRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp
@@ -1,13 +1,14 @@
//===-- ObjCLanguageRuntime.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "clang/AST/Type.h"
+#include "ObjCLanguageRuntime.h"
+
#include "lldb/Core/MappedHash.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
@@ -17,7 +18,7 @@
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/Type.h"
#include "lldb/Symbol/TypeList.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Timer.h"
@@ -28,9 +29,9 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
+char ObjCLanguageRuntime::ID = 0;
+
// Destructor
-//----------------------------------------------------------------------
ObjCLanguageRuntime::~ObjCLanguageRuntime() {}
ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
@@ -40,6 +41,12 @@ ObjCLanguageRuntime::ObjCLanguageRuntime(Process *process)
m_isa_to_descriptor_stop_id(UINT32_MAX), m_complete_class_cache(),
m_negative_complete_class_cache() {}
+bool ObjCLanguageRuntime::IsWhitelistedRuntimeValue(ConstString name) {
+ static ConstString g_self = ConstString("self");
+ static ConstString g_cmd = ConstString("_cmd");
+ return name == g_self || name == g_cmd;
+}
+
bool ObjCLanguageRuntime::AddClass(ObjCISA isa,
const ClassDescriptorSP &descriptor_sp,
const char *class_name) {
@@ -154,7 +161,7 @@ bool ObjCLanguageRuntime::ClassDescriptor::IsPointerValid(
}
ObjCLanguageRuntime::ObjCISA
-ObjCLanguageRuntime::GetISA(const ConstString &name) {
+ObjCLanguageRuntime::GetISA(ConstString name) {
ISAToDescriptorIterator pos = GetDescriptorIterator(name);
if (pos != m_isa_to_descriptor.end())
return pos->first;
@@ -162,7 +169,7 @@ ObjCLanguageRuntime::GetISA(const ConstString &name) {
}
ObjCLanguageRuntime::ISAToDescriptorIterator
-ObjCLanguageRuntime::GetDescriptorIterator(const ConstString &name) {
+ObjCLanguageRuntime::GetDescriptorIterator(ConstString name) {
ISAToDescriptorIterator end = m_isa_to_descriptor.end();
if (name) {
@@ -227,7 +234,7 @@ ObjCLanguageRuntime::GetActualTypeName(ObjCLanguageRuntime::ObjCISA isa) {
ObjCLanguageRuntime::ClassDescriptorSP
ObjCLanguageRuntime::GetClassDescriptorFromClassName(
- const ConstString &class_name) {
+ ConstString class_name) {
ISAToDescriptorIterator pos = GetDescriptorIterator(class_name);
if (pos != m_isa_to_descriptor.end())
return pos->second;
@@ -303,8 +310,8 @@ ObjCLanguageRuntime::GetNonKVOClassDescriptor(ObjCISA isa) {
CompilerType
ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name,
bool for_expression) {
- if (m_scratch_ast_ctx_ap)
- return RealizeType(*m_scratch_ast_ctx_ap, name, for_expression);
+ if (m_scratch_ast_ctx_up)
+ return RealizeType(*m_scratch_ast_ctx_up, name, for_expression);
return CompilerType();
}
@@ -356,9 +363,19 @@ bool ObjCLanguageRuntime::GetTypeBitSize(const CompilerType &compiler_type,
return found;
}
-//------------------------------------------------------------------
+lldb::BreakpointPreconditionSP
+ObjCLanguageRuntime::GetBreakpointExceptionPrecondition(LanguageType language,
+ bool throw_bp) {
+ if (language != eLanguageTypeObjC)
+ return lldb::BreakpointPreconditionSP();
+ if (!throw_bp)
+ return lldb::BreakpointPreconditionSP();
+ BreakpointPreconditionSP precondition_sp(
+ new ObjCLanguageRuntime::ObjCExceptionPrecondition());
+ return precondition_sp;
+}
+
// Exception breakpoint Precondition class for ObjC:
-//------------------------------------------------------------------
void ObjCLanguageRuntime::ObjCExceptionPrecondition::AddClassName(
const char *class_name) {
m_class_names.insert(class_name);
@@ -382,3 +399,38 @@ Status ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(
"The ObjC Exception breakpoint doesn't support extra options.");
return error;
}
+
+llvm::Optional<CompilerType>
+ObjCLanguageRuntime::GetRuntimeType(CompilerType base_type) {
+ CompilerType class_type;
+ bool is_pointer_type = false;
+
+ if (ClangASTContext::IsObjCObjectPointerType(base_type, &class_type))
+ is_pointer_type = true;
+ else if (ClangASTContext::IsObjCObjectOrInterfaceType(base_type))
+ class_type = base_type;
+ else
+ return llvm::None;
+
+ if (!class_type)
+ return llvm::None;
+
+ ConstString class_name(class_type.GetConstTypeName());
+ if (!class_name)
+ return llvm::None;
+
+ TypeSP complete_objc_class_type_sp = LookupInCompleteClassCache(class_name);
+ if (!complete_objc_class_type_sp)
+ return llvm::None;
+
+ CompilerType complete_class(
+ complete_objc_class_type_sp->GetFullCompilerType());
+ if (complete_class.GetCompleteType()) {
+ if (is_pointer_type)
+ return complete_class.GetPointerType();
+ else
+ return complete_class;
+ }
+
+ return llvm::None;
+}
diff --git a/include/lldb/Target/ObjCLanguageRuntime.h b/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
index 9eebf94630432..1925c78ed3420 100644
--- a/include/lldb/Target/ObjCLanguageRuntime.h
+++ b/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -1,9 +1,8 @@
//===-- ObjCLanguageRuntime.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,10 +16,10 @@
#include "llvm/Support/Casting.h"
+#include "lldb/Breakpoint/BreakpointPrecondition.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"
@@ -152,10 +151,10 @@ public:
const char *name, bool for_expression) = 0;
protected:
- std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_ap;
+ std::unique_ptr<ClangASTContext> m_scratch_ast_ctx_up;
};
- class ObjCExceptionPrecondition : public Breakpoint::BreakpointPrecondition {
+ class ObjCExceptionPrecondition : public BreakpointPrecondition {
public:
ObjCExceptionPrecondition();
@@ -172,6 +171,10 @@ public:
std::unordered_set<std::string> m_class_names;
};
+ static lldb::BreakpointPreconditionSP
+ GetBreakpointExceptionPrecondition(lldb::LanguageType language,
+ bool throw_bp);
+
class TaggedPointerVendor {
public:
virtual ~TaggedPointerVendor() = default;
@@ -190,6 +193,21 @@ public:
~ObjCLanguageRuntime() override;
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || LanguageRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
+ }
+
+ static ObjCLanguageRuntime *Get(Process &process) {
+ return llvm::cast_or_null<ObjCLanguageRuntime>(
+ process.GetLanguageRuntime(lldb::eLanguageTypeObjC));
+ }
+
virtual TaggedPointerVendor *GetTaggedPointerVendor() { return nullptr; }
typedef std::shared_ptr<EncodingToType> EncodingToTypeSP;
@@ -201,7 +219,7 @@ public:
ClassDescriptorSP GetNonKVOClassDescriptor(ValueObject &in_value);
virtual ClassDescriptorSP
- GetClassDescriptorFromClassName(const ConstString &class_name);
+ GetClassDescriptorFromClassName(ConstString class_name);
virtual ClassDescriptorSP GetClassDescriptorFromISA(ObjCISA isa);
@@ -217,9 +235,6 @@ public:
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,
@@ -235,6 +250,8 @@ public:
lldb::TypeSP LookupInCompleteClassCache(ConstString &name);
+ llvm::Optional<CompilerType> GetRuntimeType(CompilerType base_type) override;
+
virtual UtilityFunction *CreateObjectChecker(const char *) = 0;
virtual ObjCRuntimeVersions GetRuntimeVersion() const {
@@ -254,27 +271,18 @@ public:
}
}
- virtual ObjCISA GetISA(const ConstString &name);
+ virtual ObjCISA GetISA(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())
@@ -286,17 +294,19 @@ public:
return (m_has_new_literals_and_indexing == eLazyBoolYes);
}
- virtual void SymbolsDidLoad(const ModuleList &module_list) {
+ void SymbolsDidLoad(const ModuleList &module_list) override {
m_negative_complete_class_cache.clear();
}
bool GetTypeBitSize(const CompilerType &compiler_type,
uint64_t &size) override;
+ /// Check whether the name is "self" or "_cmd" and should show up in
+ /// "frame variable".
+ bool IsWhitelistedRuntimeValue(ConstString name) override;
+
protected:
- //------------------------------------------------------------------
// Classes that inherit from ObjCLanguageRuntime can see and modify these
- //------------------------------------------------------------------
ObjCLanguageRuntime(Process *process);
virtual bool CalculateHasNewLiteralsAndIndexing() { return false; }
@@ -387,12 +397,12 @@ protected:
CompleteClassMap m_complete_class_cache;
struct ConstStringSetHelpers {
- size_t operator()(const ConstString &arg) const // for hashing
+ size_t operator()(ConstString arg) const // for hashing
{
return (size_t)arg.GetCString();
}
- bool operator()(const ConstString &arg1,
- const ConstString &arg2) const // for equality
+ bool operator()(ConstString arg1,
+ ConstString arg2) const // for equality
{
return arg1.operator==(arg2);
}
@@ -402,7 +412,7 @@ protected:
CompleteClassSet;
CompleteClassSet m_negative_complete_class_cache;
- ISAToDescriptorIterator GetDescriptorIterator(const ConstString &name);
+ ISAToDescriptorIterator GetDescriptorIterator(ConstString name);
friend class ::CommandObjectObjC_ClassTable_Dump;
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
index 2c12cf9af6370..60549663db66e 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
@@ -1,9 +1,8 @@
//===-- RenderScriptExpressionOpts.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
index 647558171d1c6..3ec4e37b6db04 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h
@@ -1,9 +1,8 @@
//===-- RenderScriptExpressionOpts.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,7 @@ public:
RenderScriptRuntimeModulePass(const lldb_private::Process *process)
: ModulePass(ID), m_process_ptr(process) {}
- bool runOnModule(llvm::Module &module);
+ bool runOnModule(llvm::Module &module) override;
private:
const lldb_private::Process *m_process_ptr;
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
index fa775d9bfa94a..c9cd34cf379d0 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
@@ -1,14 +1,11 @@
//===-- RenderScriptRuntime.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "llvm/ADT/StringSwitch.h"
-
#include "RenderScriptRuntime.h"
#include "RenderScriptScriptGroup.h"
@@ -41,12 +38,18 @@
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Status.h"
+#include "llvm/ADT/StringSwitch.h"
+
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_renderscript;
#define FMT_COORD "(%" PRIu32 ", %" PRIu32 ", %" PRIu32 ")"
+char RenderScriptRuntime::ID = 0;
+
namespace {
// The empirical_type adds a basic level of validation to arbitrary data
@@ -591,7 +594,7 @@ struct RenderScriptRuntime::Element {
array_size; // Number of items in array, only needed for structs
ConstString type_name; // Name of type, only needed for structs
- static const ConstString &
+ static ConstString
GetFallbackStructName(); // Print this as the type name of a struct Element
// If we can't resolve the actual struct name
@@ -691,7 +694,7 @@ struct RenderScriptRuntime::AllocationDetails {
}
};
-const ConstString &RenderScriptRuntime::Element::GetFallbackStructName() {
+ConstString RenderScriptRuntime::Element::GetFallbackStructName() {
static const ConstString FallbackStructName("struct");
return FallbackStructName;
}
@@ -789,9 +792,7 @@ const uint32_t RenderScriptRuntime::AllocationDetails::RSTypeToFormat[][3] = {
// RS_TYPE_MATRIX_2X2
{eFormatVectorOfFloat32, eFormatVectorOfFloat32, sizeof(float) * 4}};
-//------------------------------------------------------------------
// Static Functions
-//------------------------------------------------------------------
LanguageRuntime *
RenderScriptRuntime::CreateInstance(Process *process,
lldb::LanguageType language) {
@@ -1029,17 +1030,13 @@ void RenderScriptRuntime::ModulesDidLoad(const ModuleList &module_list) {
}
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString RenderScriptRuntime::GetPluginName() {
return GetPluginNameStatic();
}
uint32_t RenderScriptRuntime::GetPluginVersion() { return 1; }
-bool RenderScriptRuntime::IsVTableName(const char *name) { return false; }
-
bool RenderScriptRuntime::GetDynamicTypeAndAddress(
ValueObject &in_value, lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name, Address &address,
@@ -1126,9 +1123,9 @@ bool RenderScriptRuntime::HookCallback(void *baton,
RuntimeHook *hook = (RuntimeHook *)baton;
ExecutionContext exe_ctx(ctx->exe_ctx_ref);
- RenderScriptRuntime *lang_rt =
- (RenderScriptRuntime *)exe_ctx.GetProcessPtr()->GetLanguageRuntime(
- eLanguageTypeExtRenderScript);
+ RenderScriptRuntime *lang_rt = llvm::cast<RenderScriptRuntime>(
+ exe_ctx.GetProcessPtr()->GetLanguageRuntime(
+ eLanguageTypeExtRenderScript));
lang_rt->HookCallback(hook, exe_ctx);
@@ -1212,7 +1209,7 @@ void RenderScriptRuntime::CaptureDebugHintScriptGroup2(
}
}
if (!group) {
- group.reset(new RSScriptGroupDescriptor);
+ group = std::make_shared<RSScriptGroupDescriptor>();
group->m_name = group_name;
m_scriptGroups.push_back(group);
} else {
@@ -1501,9 +1498,9 @@ void RenderScriptRuntime::CaptureAllocationDestroy(RuntimeHook *hook,
uint64_t(args[eRsContext]), uint64_t(args[eRsAlloc]));
for (auto iter = m_allocations.begin(); iter != m_allocations.end(); ++iter) {
- auto &allocation_ap = *iter; // get the unique pointer
- if (allocation_ap->address.isValid() &&
- *allocation_ap->address.get() == addr_t(args[eRsAlloc])) {
+ auto &allocation_up = *iter; // get the unique pointer
+ if (allocation_up->address.isValid() &&
+ *allocation_up->address.get() == addr_t(args[eRsAlloc])) {
m_allocations.erase(iter);
if (log)
log->Printf("%s - deleted allocation entry.", __FUNCTION__);
@@ -1975,8 +1972,8 @@ bool RenderScriptRuntime::JITTypePacked(AllocationDetails *alloc,
// We want 4 elements from packed data
const uint32_t num_exprs = 4;
- assert(num_exprs == (eExprTypeElemPtr - eExprTypeDimX + 1) &&
- "Invalid number of expressions");
+ static_assert(num_exprs == (eExprTypeElemPtr - eExprTypeDimX + 1),
+ "Invalid number of expressions");
char expr_bufs[num_exprs][jit_max_expr_size];
uint64_t results[num_exprs];
@@ -2034,8 +2031,8 @@ bool RenderScriptRuntime::JITElementPacked(Element &elem,
// We want 4 elements from packed data
const uint32_t num_exprs = 4;
- assert(num_exprs == (eExprElementFieldCount - eExprElementType + 1) &&
- "Invalid number of expressions");
+ static_assert(num_exprs == (eExprElementFieldCount - eExprElementType + 1),
+ "Invalid number of expressions");
char expr_bufs[num_exprs][jit_max_expr_size];
uint64_t results[num_exprs];
@@ -2093,8 +2090,8 @@ bool RenderScriptRuntime::JITSubelements(Element &elem,
}
const short num_exprs = 3;
- assert(num_exprs == (eExprSubelementsArrSize - eExprSubelementsId + 1) &&
- "Invalid number of expressions");
+ static_assert(num_exprs == (eExprSubelementsArrSize - eExprSubelementsId + 1),
+ "Invalid number of expressions");
char expr_buffer[jit_max_expr_size];
uint64_t results;
@@ -2362,7 +2359,7 @@ void RenderScriptRuntime::FindStructTypeName(Element &elem,
size_diff);
for (uint32_t i = 0; i < size_diff; ++i) {
- const ConstString &name = elem.children[num_children + i].type_name;
+ ConstString name = elem.children[num_children + i].type_name;
if (strcmp(name.AsCString(), "#rs_padding") < 0)
found = false;
}
@@ -2855,7 +2852,7 @@ bool RenderScriptRuntime::LoadModule(const lldb::ModuleSP &module_sp) {
switch (GetModuleKind(module_sp)) {
case eModuleKindKernelObj: {
RSModuleDescriptorSP module_desc;
- module_desc.reset(new RSModuleDescriptor(module_sp));
+ module_desc = std::make_shared<RSModuleDescriptor>(module_sp);
if (module_desc->ParseRSInfo()) {
m_rsmodules.push_back(module_desc);
module_desc->WarnIfVersionMismatch(GetProcess()
@@ -3593,7 +3590,7 @@ void RenderScriptRuntime::SetBreakAllKernels(bool do_break, TargetSP target) {
// Given the name of a kernel this function creates a breakpoint using our own
// breakpoint resolver, and returns the Breakpoint shared pointer.
BreakpointSP
-RenderScriptRuntime::CreateKernelBreakpoint(const ConstString &name) {
+RenderScriptRuntime::CreateKernelBreakpoint(ConstString name) {
Log *log(
GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS));
@@ -3621,7 +3618,7 @@ RenderScriptRuntime::CreateKernelBreakpoint(const ConstString &name) {
}
BreakpointSP
-RenderScriptRuntime::CreateReductionBreakpoint(const ConstString &name,
+RenderScriptRuntime::CreateReductionBreakpoint(ConstString name,
int kernel_types) {
Log *log(
GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS));
@@ -3862,7 +3859,7 @@ bool RenderScriptRuntime::PlaceBreakpointOnKernel(TargetSP target,
}
BreakpointSP
-RenderScriptRuntime::CreateScriptGroupBreakpoint(const ConstString &name,
+RenderScriptRuntime::CreateScriptGroupBreakpoint(ConstString name,
bool stop_on_all) {
Log *log(
GetLogIfAnyCategoriesSet(LIBLLDB_LOG_LANGUAGE | LIBLLDB_LOG_BREAKPOINTS));
@@ -3892,7 +3889,7 @@ RenderScriptRuntime::CreateScriptGroupBreakpoint(const ConstString &name,
bool RenderScriptRuntime::PlaceBreakpointOnScriptGroup(TargetSP target,
Stream &strm,
- const ConstString &name,
+ ConstString name,
bool multi) {
InitSearchFilter(target);
BreakpointSP bp = CreateScriptGroupBreakpoint(name, multi);
@@ -4125,9 +4122,9 @@ public:
~CommandObjectRenderScriptRuntimeModuleDump() override = default;
bool DoExecute(Args &command, CommandReturnObject &result) override {
- RenderScriptRuntime *runtime =
- (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
- eLanguageTypeExtRenderScript);
+ RenderScriptRuntime *runtime = llvm::cast<RenderScriptRuntime>(
+ m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
+ eLanguageTypeExtRenderScript));
runtime->DumpModules(result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
@@ -4160,9 +4157,9 @@ public:
~CommandObjectRenderScriptRuntimeKernelList() override = default;
bool DoExecute(Args &command, CommandReturnObject &result) override {
- RenderScriptRuntime *runtime =
- (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
- eLanguageTypeExtRenderScript);
+ RenderScriptRuntime *runtime = llvm::cast<RenderScriptRuntime>(
+ m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
+ eLanguageTypeExtRenderScript));
runtime->DumpKernels(result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
@@ -4407,9 +4404,9 @@ public:
return false;
}
- RenderScriptRuntime *runtime =
- (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
- eLanguageTypeExtRenderScript);
+ RenderScriptRuntime *runtime = llvm::cast<RenderScriptRuntime>(
+ m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
+ eLanguageTypeExtRenderScript));
auto &outstream = result.GetOutputStream();
auto &target = m_exe_ctx.GetTargetSP();
@@ -4591,9 +4588,9 @@ public:
~CommandObjectRenderScriptRuntimeContextDump() override = default;
bool DoExecute(Args &command, CommandReturnObject &result) override {
- RenderScriptRuntime *runtime =
- (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
- eLanguageTypeExtRenderScript);
+ RenderScriptRuntime *runtime = llvm::cast<RenderScriptRuntime>(
+ m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
+ eLanguageTypeExtRenderScript));
runtime->DumpContexts(result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
@@ -4983,9 +4980,9 @@ public:
~CommandObjectRenderScriptRuntimeStatus() override = default;
bool DoExecute(Args &command, CommandReturnObject &result) override {
- RenderScriptRuntime *runtime =
- (RenderScriptRuntime *)m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
- eLanguageTypeExtRenderScript);
+ RenderScriptRuntime *runtime = llvm::cast<RenderScriptRuntime>(
+ m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
+ eLanguageTypeExtRenderScript));
runtime->DumpStatus(result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
index 31714dd4a4539..3923221d4302c 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -1,9 +1,8 @@
//===-- RenderScriptRuntime.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,10 +19,11 @@
#include "llvm/ADT/StringRef.h"
#include "lldb/Core/Module.h"
#include "lldb/Expression/LLVMUserExpression.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/lldb-private.h"
+#include "Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.h"
+
namespace lldb_private {
namespace lldb_renderscript {
@@ -246,7 +246,7 @@ typedef std::vector<RSScriptGroupDescriptorSP> RSScriptGroupList;
class RSScriptGroupBreakpointResolver : public BreakpointResolver {
public:
- RSScriptGroupBreakpointResolver(Breakpoint *bp, const ConstString &name,
+ RSScriptGroupBreakpointResolver(Breakpoint *bp, ConstString name,
const RSScriptGroupList &groups,
bool stop_on_all)
: BreakpointResolver(bp, BreakpointResolver::NameResolver),
@@ -276,7 +276,7 @@ public:
protected:
const RSScriptGroupDescriptorSP
- FindScriptGroup(const ConstString &name) const {
+ FindScriptGroup(ConstString name) const {
for (auto sg : m_script_groups) {
if (ConstString::Compare(sg->m_name, name) == 0)
return sg;
@@ -302,9 +302,7 @@ public:
~RenderScriptRuntime() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -317,6 +315,16 @@ public:
static lldb_private::ConstString GetPluginNameStatic();
+ static char ID;
+
+ bool isA(const void *ClassID) const override {
+ return ClassID == &ID || CPPLanguageRuntime::isA(ClassID);
+ }
+
+ static bool classof(const LanguageRuntime *runtime) {
+ return runtime->isA(&ID);
+ }
+
static bool IsRenderScriptModule(const lldb::ModuleSP &module_sp);
static ModuleKind GetModuleKind(const lldb::ModuleSP &module_sp);
@@ -324,8 +332,6 @@ public:
static void ModulesDidLoad(const lldb::ProcessSP &process_sp,
const ModuleList &module_list);
- bool IsVTableName(const char *name) override;
-
bool GetDynamicTypeAndAddress(ValueObject &in_value,
lldb::DynamicValueType use_dynamic,
TypeAndOrName &class_type_or_name,
@@ -366,7 +372,7 @@ public:
int kernel_types = ~(0));
bool PlaceBreakpointOnScriptGroup(lldb::TargetSP target, Stream &strm,
- const ConstString &name, bool stop_on_all);
+ ConstString name, bool stop_on_all);
void SetBreakAllKernels(bool do_break, lldb::TargetSP target);
@@ -388,7 +394,7 @@ public:
return m_scriptGroups;
};
- bool IsKnownKernel(const ConstString &name) {
+ bool IsKnownKernel(ConstString name) {
for (const auto &module : m_rsmodules)
for (const auto &kernel : module->m_kernels)
if (kernel.m_name == name)
@@ -396,9 +402,7 @@ public:
return false;
}
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -429,12 +433,12 @@ protected:
bool EvalRSExpression(const char *expression, StackFrame *frame_ptr,
uint64_t *result);
- lldb::BreakpointSP CreateScriptGroupBreakpoint(const ConstString &name,
+ lldb::BreakpointSP CreateScriptGroupBreakpoint(ConstString name,
bool multi);
- lldb::BreakpointSP CreateKernelBreakpoint(const ConstString &name);
+ lldb::BreakpointSP CreateKernelBreakpoint(ConstString name);
- lldb::BreakpointSP CreateReductionBreakpoint(const ConstString &name,
+ lldb::BreakpointSP CreateReductionBreakpoint(ConstString name,
int kernel_types);
void BreakOnModuleKernels(
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
index 7786d686ad6a2..45d0d028d0474 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.cpp
@@ -1,9 +1,8 @@
//===-- RenderScriptScriptGroup.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h
index 5c5608c998620..c25e240f6d527 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptScriptGroup.h
@@ -1,9 +1,8 @@
//===-- RenderScriptScriptGroup.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
index 0b298c90a50b1..4725e8c5b0eb6 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp
@@ -1,9 +1,8 @@
//===-- RenderScriptx86ABIFixups.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -193,8 +192,9 @@ bool fixupX86StructRetCalls(llvm::Module &module) {
llvm::LoadInst *new_func_addr_load =
new llvm::LoadInst(new_func_ptr, "load_func_pointer", call_inst);
// and create a callinstruction from it
- llvm::CallInst *new_call_inst = llvm::CallInst::Create(
- new_func_addr_load, new_call_args, "new_func_call", call_inst);
+ llvm::CallInst *new_call_inst =
+ llvm::CallInst::Create(new_func_type, new_func_addr_load, new_call_args,
+ "new_func_call", call_inst);
new_call_inst->setCallingConv(call_inst->getCallingConv());
new_call_inst->setTailCall(call_inst->isTailCall());
llvm::LoadInst *lldb_save_result_address =
diff --git a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h
index b2caea49bd1e1..a5efc999aea4e 100644
--- a/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h
+++ b/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h
@@ -1,9 +1,8 @@
//===-- RenderScriptx86ABIFixups.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
index b9e49d1faa1bc..e0d2c5d0eef8c 100644
--- a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -1,9 +1,8 @@
//===-- MemoryHistoryASan.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,7 +30,7 @@ using namespace lldb_private;
MemoryHistorySP MemoryHistoryASan::CreateInstance(const ProcessSP &process_sp) {
if (!process_sp.get())
- return NULL;
+ return nullptr;
Target &target = process_sp->GetTarget();
@@ -137,8 +136,7 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp,
pcs.push_back(pc);
}
- HistoryThread *history_thread =
- new HistoryThread(*process_sp, tid, pcs, 0, false);
+ HistoryThread *history_thread = new HistoryThread(*process_sp, tid, pcs);
ThreadSP new_thread_sp(history_thread);
std::ostringstream thread_name_with_number;
thread_name_with_number << thread_name << " Thread " << tid;
@@ -149,8 +147,6 @@ static void CreateHistoryThreadFromValueObject(ProcessSP process_sp,
result.push_back(new_thread_sp);
}
-static constexpr std::chrono::seconds g_get_stack_function_timeout(2);
-
HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) {
HistoryThreads result;
@@ -178,7 +174,7 @@ HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) {
options.SetTryAllThreads(true);
options.SetStopOthers(true);
options.SetIgnoreBreakpoints(true);
- options.SetTimeout(g_get_stack_function_timeout);
+ options.SetTimeout(process_sp->GetUtilityExpressionTimeout());
options.SetPrefix(memory_history_asan_command_prefix);
options.SetAutoApplyFixIts(false);
options.SetLanguage(eLanguageTypeObjC_plus_plus);
diff --git a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
index c08acd0151ef1..266576b0cd964 100644
--- a/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
+++ b/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.h
@@ -1,9 +1,8 @@
//===-- MemoryHistoryASan.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
index 391ab75469674..512b5bebf07f7 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -1,9 +1,8 @@
//===-- ObjectContainerBSDArchive.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,18 +41,18 @@ using namespace lldb;
using namespace lldb_private;
ObjectContainerBSDArchive::Object::Object()
- : ar_name(), ar_date(0), ar_uid(0), ar_gid(0), ar_mode(0), ar_size(0),
- ar_file_offset(0), ar_file_size(0) {}
+ : ar_name(), modification_time(0), uid(0), gid(0), mode(0), size(0),
+ file_offset(0), file_size(0) {}
void ObjectContainerBSDArchive::Object::Clear() {
ar_name.Clear();
- ar_date = 0;
- ar_uid = 0;
- ar_gid = 0;
- ar_mode = 0;
- ar_size = 0;
- ar_file_offset = 0;
- ar_file_size = 0;
+ modification_time = 0;
+ uid = 0;
+ gid = 0;
+ mode = 0;
+ size = 0;
+ file_offset = 0;
+ file_size = 0;
}
lldb::offset_t
@@ -103,32 +102,32 @@ ObjectContainerBSDArchive::Object::Extract(const DataExtractor &data,
}
str.assign((const char *)data.GetData(&offset, 12), 12);
- ar_date = strtoul(str.c_str(), &err, 10);
+ modification_time = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 6), 6);
- ar_uid = strtoul(str.c_str(), &err, 10);
+ uid = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 6), 6);
- ar_gid = strtoul(str.c_str(), &err, 10);
+ gid = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 8), 8);
- ar_mode = strtoul(str.c_str(), &err, 8);
+ mode = strtoul(str.c_str(), &err, 8);
str.assign((const char *)data.GetData(&offset, 10), 10);
- ar_size = strtoul(str.c_str(), &err, 10);
+ size = strtoul(str.c_str(), &err, 10);
str.assign((const char *)data.GetData(&offset, 2), 2);
if (str == ARFMAG) {
if (ar_name_len > 0) {
const void *ar_name_ptr = data.GetData(&offset, ar_name_len);
// Make sure there was enough data for the string value and bail if not
- if (ar_name_ptr == NULL)
+ if (ar_name_ptr == nullptr)
return LLDB_INVALID_OFFSET;
str.assign((const char *)ar_name_ptr, ar_name_len);
ar_name.SetCString(str.c_str());
}
- ar_file_offset = offset;
- ar_file_size = ar_size - ar_name_len;
+ file_offset = offset;
+ file_size = size - ar_name_len;
return offset;
}
return LLDB_INVALID_OFFSET;
@@ -138,8 +137,8 @@ ObjectContainerBSDArchive::Archive::Archive(const lldb_private::ArchSpec &arch,
const llvm::sys::TimePoint<> &time,
lldb::offset_t file_offset,
lldb_private::DataExtractor &data)
- : m_arch(arch), m_time(time), m_file_offset(file_offset), m_objects(),
- m_data(data) {}
+ : m_arch(arch), m_modification_time(time), m_file_offset(file_offset),
+ m_objects(), m_data(data) {}
ObjectContainerBSDArchive::Archive::~Archive() {}
@@ -158,7 +157,7 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
m_objects.push_back(obj);
// Insert all of the C strings out of order for now...
m_object_name_to_index_map.Append(obj.ar_name, obj_idx);
- offset += obj.ar_file_size;
+ offset += obj.file_size;
obj.Clear();
} while (data.ValidOffset(offset));
@@ -170,28 +169,28 @@ size_t ObjectContainerBSDArchive::Archive::ParseObjects() {
ObjectContainerBSDArchive::Object *
ObjectContainerBSDArchive::Archive::FindObject(
- const ConstString &object_name,
- const llvm::sys::TimePoint<> &object_mod_time) {
+ ConstString object_name, const llvm::sys::TimePoint<> &object_mod_time) {
const ObjectNameToIndexMap::Entry *match =
m_object_name_to_index_map.FindFirstValueForName(object_name);
- if (match) {
- if (object_mod_time != llvm::sys::TimePoint<>()) {
- const uint64_t object_date = llvm::sys::toTimeT(object_mod_time);
- if (m_objects[match->value].ar_date == object_date)
- return &m_objects[match->value];
- const ObjectNameToIndexMap::Entry *next_match =
- m_object_name_to_index_map.FindNextValueForName(match);
- while (next_match) {
- if (m_objects[next_match->value].ar_date == object_date)
- return &m_objects[next_match->value];
- next_match =
- m_object_name_to_index_map.FindNextValueForName(next_match);
- }
- } else {
- return &m_objects[match->value];
- }
+ if (!match)
+ return nullptr;
+ if (object_mod_time == llvm::sys::TimePoint<>())
+ return &m_objects[match->value];
+
+ const uint64_t object_modification_date = llvm::sys::toTimeT(object_mod_time);
+ if (m_objects[match->value].modification_time == object_modification_date)
+ return &m_objects[match->value];
+
+ const ObjectNameToIndexMap::Entry *next_match =
+ m_object_name_to_index_map.FindNextValueForName(match);
+ while (next_match) {
+ if (m_objects[next_match->value].modification_time ==
+ object_modification_date)
+ return &m_objects[next_match->value];
+ next_match = m_object_name_to_index_map.FindNextValueForName(next_match);
}
- return NULL;
+
+ return nullptr;
}
ObjectContainerBSDArchive::Archive::shared_ptr
@@ -321,18 +320,18 @@ ObjectContainer *ObjectContainerBSDArchive::CreateInstance(
Archive::shared_ptr archive_sp(Archive::FindCachedArchive(
*file, module_sp->GetArchitecture(), module_sp->GetModificationTime(),
file_offset));
- std::unique_ptr<ObjectContainerBSDArchive> container_ap(
+ std::unique_ptr<ObjectContainerBSDArchive> container_up(
new ObjectContainerBSDArchive(module_sp, archive_data_sp,
archive_data_offset, file, file_offset,
length));
- if (container_ap.get()) {
+ if (container_up) {
if (archive_sp) {
// We already have this archive in our cache, use it
- container_ap->SetArchive(archive_sp);
- return container_ap.release();
- } else if (container_ap->ParseHeader())
- return container_ap.release();
+ container_up->SetArchive(archive_sp);
+ return container_up.release();
+ } else if (container_up->ParseHeader())
+ return container_up.release();
}
}
} else {
@@ -341,18 +340,18 @@ ObjectContainer *ObjectContainerBSDArchive::CreateInstance(
*file, module_sp->GetArchitecture(), module_sp->GetModificationTime(),
file_offset));
if (archive_sp) {
- std::unique_ptr<ObjectContainerBSDArchive> container_ap(
+ std::unique_ptr<ObjectContainerBSDArchive> container_up(
new ObjectContainerBSDArchive(module_sp, data_sp, data_offset, file,
file_offset, length));
- if (container_ap.get()) {
+ if (container_up) {
// We already have this archive in our cache, use it
- container_ap->SetArchive(archive_sp);
- return container_ap.release();
+ container_up->SetArchive(archive_sp);
+ return container_up.release();
}
}
}
- return NULL;
+ return nullptr;
}
bool ObjectContainerBSDArchive::MagicBytesMatch(const DataExtractor &data) {
@@ -379,7 +378,7 @@ void ObjectContainerBSDArchive::SetArchive(Archive::shared_ptr &archive_sp) {
ObjectContainerBSDArchive::~ObjectContainerBSDArchive() {}
bool ObjectContainerBSDArchive::ParseHeader() {
- if (m_archive_sp.get() == NULL) {
+ if (m_archive_sp.get() == nullptr) {
if (m_data.GetByteSize() > 0) {
ModuleSP module_sp(GetModule());
if (module_sp) {
@@ -392,7 +391,7 @@ bool ObjectContainerBSDArchive::ParseHeader() {
m_data.Clear();
}
}
- return m_archive_sp.get() != NULL;
+ return m_archive_sp.get() != nullptr;
}
void ObjectContainerBSDArchive::Dump(Stream *s) const {
@@ -426,20 +425,17 @@ ObjectFileSP ObjectContainerBSDArchive::GetObjectFile(const FileSpec *file) {
Object *object = m_archive_sp->FindObject(
module_sp->GetObjectName(), module_sp->GetObjectModificationTime());
if (object) {
- lldb::offset_t data_offset = object->ar_file_offset;
+ lldb::offset_t data_offset = object->file_offset;
return ObjectFile::FindPlugin(
- module_sp, file, m_offset + object->ar_file_offset,
- object->ar_file_size, m_archive_sp->GetData().GetSharedDataBuffer(),
- data_offset);
+ module_sp, file, m_offset + object->file_offset, object->file_size,
+ m_archive_sp->GetData().GetSharedDataBuffer(), data_offset);
}
}
}
return ObjectFileSP();
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ObjectContainerBSDArchive::GetPluginName() {
return GetPluginNameStatic();
}
@@ -481,16 +477,15 @@ size_t ObjectContainerBSDArchive::GetModuleSpecifications(
const Object *object = archive_sp->GetObjectAtIndex(idx);
if (object) {
const lldb::offset_t object_file_offset =
- file_offset + object->ar_file_offset;
- if (object->ar_file_offset < file_size &&
- file_size > object_file_offset) {
+ file_offset + object->file_offset;
+ if (object->file_offset < file_size && file_size > object_file_offset) {
if (ObjectFile::GetModuleSpecifications(
file, object_file_offset, file_size - object_file_offset,
specs)) {
ModuleSpec &spec =
specs.GetModuleSpecRefAtIndex(specs.GetSize() - 1);
llvm::sys::TimePoint<> object_mod_time(
- std::chrono::seconds(object->ar_date));
+ std::chrono::seconds(object->modification_time));
spec.GetObjectName() = object->ar_name;
spec.SetObjectOffset(object_file_offset);
spec.SetObjectSize(file_size - object_file_offset);
diff --git a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
index 86eaee1375a66..5d9c01315a66b 100644
--- a/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
+++ b/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
@@ -1,9 +1,8 @@
//===-- ObjectContainerBSDArchive.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,9 +31,7 @@ public:
~ObjectContainerBSDArchive() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -57,9 +54,7 @@ public:
static bool MagicBytesMatch(const lldb_private::DataExtractor &data);
- //------------------------------------------------------------------
// Member Functions
- //------------------------------------------------------------------
bool ParseHeader() override;
size_t GetNumObjects() const override {
@@ -72,9 +67,7 @@ public:
lldb::ObjectFileSP GetObjectFile(const lldb_private::FileSpec *file) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -87,20 +80,29 @@ protected:
lldb::offset_t Extract(const lldb_private::DataExtractor &data,
lldb::offset_t offset);
+ /// Object name in the archive.
+ lldb_private::ConstString ar_name;
+
+ /// Object modification time in the archive.
+ uint32_t modification_time;
+
+ /// Object user id in the archive.
+ uint16_t uid;
+
+ /// Object group id in the archive.
+ uint16_t gid;
- lldb_private::ConstString ar_name; // name
- uint32_t ar_date; // modification time
- uint16_t ar_uid; // user id
- uint16_t ar_gid; // group id
- uint16_t ar_mode; // octal file permissions
- uint32_t ar_size; // size in bytes
- lldb::offset_t ar_file_offset; // file offset in bytes from the beginning of
- // the file of the object data
- lldb::offset_t ar_file_size; // length of the object data
-
- typedef std::vector<Object> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
+ /// Object octal file permissions in the archive.
+ uint16_t mode;
+
+ /// Object size in bytes in the archive.
+ uint32_t size;
+
+ /// File offset in bytes from the beginning of the file of the object data.
+ lldb::offset_t file_offset;
+
+ /// Length of the object data.
+ lldb::offset_t file_size;
};
class Archive {
@@ -132,17 +134,19 @@ protected:
const Object *GetObjectAtIndex(size_t idx) {
if (idx < m_objects.size())
return &m_objects[idx];
- return NULL;
+ return nullptr;
}
size_t ParseObjects();
- Object *FindObject(const lldb_private::ConstString &object_name,
+ Object *FindObject(lldb_private::ConstString object_name,
const llvm::sys::TimePoint<> &object_mod_time);
lldb::offset_t GetFileOffset() const { return m_file_offset; }
- const llvm::sys::TimePoint<> &GetModificationTime() { return m_time; }
+ const llvm::sys::TimePoint<> &GetModificationTime() {
+ return m_modification_time;
+ }
const lldb_private::ArchSpec &GetArchitecture() const { return m_arch; }
@@ -154,13 +158,11 @@ protected:
protected:
typedef lldb_private::UniqueCStringMap<uint32_t> ObjectNameToIndexMap;
- //----------------------------------------------------------------------
// Member Variables
- //----------------------------------------------------------------------
lldb_private::ArchSpec m_arch;
- llvm::sys::TimePoint<> m_time;
+ llvm::sys::TimePoint<> m_modification_time;
lldb::offset_t m_file_offset;
- Object::collection m_objects;
+ std::vector<Object> m_objects;
ObjectNameToIndexMap m_object_name_to_index_map;
lldb_private::DataExtractor m_data; ///< The data for this object container
///so we don't lose data if the .a files
diff --git a/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
new file mode 100644
index 0000000000000..d489eaf11115a
--- /dev/null
+++ b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp
@@ -0,0 +1,411 @@
+//===-- BreakpadRecords.cpp ----------------------------------- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/FormatVariadic.h"
+
+using namespace lldb_private;
+using namespace lldb_private::breakpad;
+
+namespace {
+enum class Token { Unknown, Module, Info, CodeID, File, Func, Public, Stack, CFI, Init };
+}
+
+template<typename T>
+static T stringTo(llvm::StringRef Str);
+
+template <> Token stringTo<Token>(llvm::StringRef Str) {
+ return llvm::StringSwitch<Token>(Str)
+ .Case("MODULE", Token::Module)
+ .Case("INFO", Token::Info)
+ .Case("CODE_ID", Token::CodeID)
+ .Case("FILE", Token::File)
+ .Case("FUNC", Token::Func)
+ .Case("PUBLIC", Token::Public)
+ .Case("STACK", Token::Stack)
+ .Case("CFI", Token::CFI)
+ .Case("INIT", Token::Init)
+ .Default(Token::Unknown);
+}
+
+template <>
+llvm::Triple::OSType stringTo<llvm::Triple::OSType>(llvm::StringRef Str) {
+ using llvm::Triple;
+ return llvm::StringSwitch<Triple::OSType>(Str)
+ .Case("Linux", Triple::Linux)
+ .Case("mac", Triple::MacOSX)
+ .Case("windows", Triple::Win32)
+ .Default(Triple::UnknownOS);
+}
+
+template <>
+llvm::Triple::ArchType stringTo<llvm::Triple::ArchType>(llvm::StringRef Str) {
+ using llvm::Triple;
+ return llvm::StringSwitch<Triple::ArchType>(Str)
+ .Case("arm", Triple::arm)
+ .Cases("arm64", "arm64e", Triple::aarch64)
+ .Case("mips", Triple::mips)
+ .Case("ppc", Triple::ppc)
+ .Case("ppc64", Triple::ppc64)
+ .Case("s390", Triple::systemz)
+ .Case("sparc", Triple::sparc)
+ .Case("sparcv9", Triple::sparcv9)
+ .Case("x86", Triple::x86)
+ .Case("x86_64", Triple::x86_64)
+ .Default(Triple::UnknownArch);
+}
+
+template<typename T>
+static T consume(llvm::StringRef &Str) {
+ llvm::StringRef Token;
+ std::tie(Token, Str) = getToken(Str);
+ return stringTo<T>(Token);
+}
+
+/// Return the number of hex digits needed to encode an (POD) object of a given
+/// type.
+template <typename T> static constexpr size_t hex_digits() {
+ return 2 * sizeof(T);
+}
+
+static UUID parseModuleId(llvm::Triple::OSType os, llvm::StringRef str) {
+ struct data_t {
+ using uuid_t = uint8_t[16];
+ uuid_t uuid;
+ llvm::support::ubig32_t age;
+ } data;
+ static_assert(sizeof(data) == 20, "");
+ // The textual module id encoding should be between 33 and 40 bytes long,
+ // depending on the size of the age field, which is of variable length.
+ // The first three chunks of the id are encoded in big endian, so we need to
+ // byte-swap those.
+ if (str.size() <= hex_digits<data_t::uuid_t>() ||
+ str.size() > hex_digits<data_t>())
+ return UUID();
+ if (!all_of(str, llvm::isHexDigit))
+ return UUID();
+
+ llvm::StringRef uuid_str = str.take_front(hex_digits<data_t::uuid_t>());
+ llvm::StringRef age_str = str.drop_front(hex_digits<data_t::uuid_t>());
+
+ llvm::copy(fromHex(uuid_str), data.uuid);
+ uint32_t age;
+ bool success = to_integer(age_str, age, 16);
+ assert(success);
+ (void)success;
+ data.age = age;
+
+ // On non-windows, the age field should always be zero, so we don't include to
+ // match the native uuid format of these platforms.
+ return UUID::fromData(&data, os == llvm::Triple::Win32 ? sizeof(data)
+ : sizeof(data.uuid));
+}
+
+llvm::Optional<Record::Kind> Record::classify(llvm::StringRef Line) {
+ Token Tok = consume<Token>(Line);
+ switch (Tok) {
+ case Token::Module:
+ return Record::Module;
+ case Token::Info:
+ return Record::Info;
+ case Token::File:
+ return Record::File;
+ case Token::Func:
+ return Record::Func;
+ case Token::Public:
+ return Record::Public;
+ case Token::Stack:
+ Tok = consume<Token>(Line);
+ switch (Tok) {
+ case Token::CFI:
+ return Record::StackCFI;
+ default:
+ return llvm::None;
+ }
+
+ case Token::Unknown:
+ // Optimistically assume that any unrecognised token means this is a line
+ // record, those don't have a special keyword and start directly with a
+ // hex number. CODE_ID should never be at the start of a line, but if it
+ // is, it can be treated the same way as a garbled line record.
+ return Record::Line;
+
+ case Token::CodeID:
+ case Token::CFI:
+ case Token::Init:
+ // These should never appear at the start of a valid record.
+ return llvm::None;
+ }
+ llvm_unreachable("Fully covered switch above!");
+}
+
+llvm::Optional<ModuleRecord> ModuleRecord::parse(llvm::StringRef Line) {
+ // MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 a.out
+ if (consume<Token>(Line) != Token::Module)
+ return llvm::None;
+
+ llvm::Triple::OSType OS = consume<llvm::Triple::OSType>(Line);
+ if (OS == llvm::Triple::UnknownOS)
+ return llvm::None;
+
+ llvm::Triple::ArchType Arch = consume<llvm::Triple::ArchType>(Line);
+ if (Arch == llvm::Triple::UnknownArch)
+ return llvm::None;
+
+ llvm::StringRef Str;
+ std::tie(Str, Line) = getToken(Line);
+ UUID ID = parseModuleId(OS, Str);
+ if (!ID)
+ return llvm::None;
+
+ return ModuleRecord(OS, Arch, std::move(ID));
+}
+
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const ModuleRecord &R) {
+ return OS << "MODULE " << llvm::Triple::getOSTypeName(R.OS) << " "
+ << llvm::Triple::getArchTypeName(R.Arch) << " "
+ << R.ID.GetAsString();
+}
+
+llvm::Optional<InfoRecord> InfoRecord::parse(llvm::StringRef Line) {
+ // INFO CODE_ID 554889E55DC3CCCCCCCCCCCCCCCCCCCC [a.exe]
+ if (consume<Token>(Line) != Token::Info)
+ return llvm::None;
+
+ if (consume<Token>(Line) != Token::CodeID)
+ return llvm::None;
+
+ llvm::StringRef Str;
+ std::tie(Str, Line) = getToken(Line);
+ // If we don't have any text following the code ID (e.g. on linux), we should
+ // use this as the UUID. Otherwise, we should revert back to the module ID.
+ UUID ID;
+ if (Line.trim().empty()) {
+ if (Str.empty() || ID.SetFromStringRef(Str, Str.size() / 2) != Str.size())
+ return llvm::None;
+ }
+ return InfoRecord(std::move(ID));
+}
+
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const InfoRecord &R) {
+ return OS << "INFO CODE_ID " << R.ID.GetAsString();
+}
+
+llvm::Optional<FileRecord> FileRecord::parse(llvm::StringRef Line) {
+ // FILE number name
+ if (consume<Token>(Line) != Token::File)
+ return llvm::None;
+
+ llvm::StringRef Str;
+ size_t Number;
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, Number))
+ return llvm::None;
+
+ llvm::StringRef Name = Line.trim();
+ if (Name.empty())
+ return llvm::None;
+
+ return FileRecord(Number, Name);
+}
+
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const FileRecord &R) {
+ return OS << "FILE " << R.Number << " " << R.Name;
+}
+
+static bool parsePublicOrFunc(llvm::StringRef Line, bool &Multiple,
+ lldb::addr_t &Address, lldb::addr_t *Size,
+ lldb::addr_t &ParamSize, llvm::StringRef &Name) {
+ // PUBLIC [m] address param_size name
+ // or
+ // FUNC [m] address size param_size name
+
+ Token Tok = Size ? Token::Func : Token::Public;
+
+ if (consume<Token>(Line) != Tok)
+ return false;
+
+ llvm::StringRef Str;
+ std::tie(Str, Line) = getToken(Line);
+ Multiple = Str == "m";
+
+ if (Multiple)
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, Address, 16))
+ return false;
+
+ if (Tok == Token::Func) {
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, *Size, 16))
+ return false;
+ }
+
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, ParamSize, 16))
+ return false;
+
+ Name = Line.trim();
+ if (Name.empty())
+ return false;
+
+ return true;
+}
+
+llvm::Optional<FuncRecord> FuncRecord::parse(llvm::StringRef Line) {
+ bool Multiple;
+ lldb::addr_t Address, Size, ParamSize;
+ llvm::StringRef Name;
+
+ if (parsePublicOrFunc(Line, Multiple, Address, &Size, ParamSize, Name))
+ return FuncRecord(Multiple, Address, Size, ParamSize, Name);
+
+ return llvm::None;
+}
+
+bool breakpad::operator==(const FuncRecord &L, const FuncRecord &R) {
+ return L.Multiple == R.Multiple && L.Address == R.Address &&
+ L.Size == R.Size && L.ParamSize == R.ParamSize && L.Name == R.Name;
+}
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const FuncRecord &R) {
+ return OS << llvm::formatv("FUNC {0}{1:x-} {2:x-} {3:x-} {4}",
+ R.Multiple ? "m " : "", R.Address, R.Size,
+ R.ParamSize, R.Name);
+}
+
+llvm::Optional<LineRecord> LineRecord::parse(llvm::StringRef Line) {
+ lldb::addr_t Address;
+ llvm::StringRef Str;
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, Address, 16))
+ return llvm::None;
+
+ lldb::addr_t Size;
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, Size, 16))
+ return llvm::None;
+
+ uint32_t LineNum;
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, LineNum))
+ return llvm::None;
+
+ size_t FileNum;
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, FileNum))
+ return llvm::None;
+
+ return LineRecord(Address, Size, LineNum, FileNum);
+}
+
+bool breakpad::operator==(const LineRecord &L, const LineRecord &R) {
+ return L.Address == R.Address && L.Size == R.Size && L.LineNum == R.LineNum &&
+ L.FileNum == R.FileNum;
+}
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const LineRecord &R) {
+ return OS << llvm::formatv("{0:x-} {1:x-} {2} {3}", R.Address, R.Size,
+ R.LineNum, R.FileNum);
+}
+
+llvm::Optional<PublicRecord> PublicRecord::parse(llvm::StringRef Line) {
+ bool Multiple;
+ lldb::addr_t Address, ParamSize;
+ llvm::StringRef Name;
+
+ if (parsePublicOrFunc(Line, Multiple, Address, nullptr, ParamSize, Name))
+ return PublicRecord(Multiple, Address, ParamSize, Name);
+
+ return llvm::None;
+}
+
+bool breakpad::operator==(const PublicRecord &L, const PublicRecord &R) {
+ return L.Multiple == R.Multiple && L.Address == R.Address &&
+ L.ParamSize == R.ParamSize && L.Name == R.Name;
+}
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const PublicRecord &R) {
+ return OS << llvm::formatv("PUBLIC {0}{1:x-} {2:x-} {3}",
+ R.Multiple ? "m " : "", R.Address, R.ParamSize,
+ R.Name);
+}
+
+llvm::Optional<StackCFIRecord> StackCFIRecord::parse(llvm::StringRef Line) {
+ // STACK CFI INIT address size reg1: expr1 reg2: expr2 ...
+ // or
+ // STACK CFI address reg1: expr1 reg2: expr2 ...
+ // No token in exprN ends with a colon.
+
+ if (consume<Token>(Line) != Token::Stack)
+ return llvm::None;
+ if (consume<Token>(Line) != Token::CFI)
+ return llvm::None;
+
+ llvm::StringRef Str;
+ std::tie(Str, Line) = getToken(Line);
+
+ bool IsInitRecord = stringTo<Token>(Str) == Token::Init;
+ if (IsInitRecord)
+ std::tie(Str, Line) = getToken(Line);
+
+ lldb::addr_t Address;
+ if (!to_integer(Str, Address, 16))
+ return llvm::None;
+
+ llvm::Optional<lldb::addr_t> Size;
+ if (IsInitRecord) {
+ Size.emplace();
+ std::tie(Str, Line) = getToken(Line);
+ if (!to_integer(Str, *Size, 16))
+ return llvm::None;
+ }
+
+ return StackCFIRecord(Address, Size, Line.trim());
+}
+
+bool breakpad::operator==(const StackCFIRecord &L, const StackCFIRecord &R) {
+ return L.Address == R.Address && L.Size == R.Size &&
+ L.UnwindRules == R.UnwindRules;
+}
+
+llvm::raw_ostream &breakpad::operator<<(llvm::raw_ostream &OS,
+ const StackCFIRecord &R) {
+ OS << "STACK CFI ";
+ if (R.Size)
+ OS << "INIT ";
+ OS << llvm::formatv("{0:x-} ", R.Address);
+ if (R.Size)
+ OS << llvm::formatv("{0:x-} ", *R.Size);
+ return OS << " " << R.UnwindRules;
+}
+
+llvm::StringRef breakpad::toString(Record::Kind K) {
+ switch (K) {
+ case Record::Module:
+ return "MODULE";
+ case Record::Info:
+ return "INFO";
+ case Record::File:
+ return "FILE";
+ case Record::Func:
+ return "FUNC";
+ case Record::Line:
+ return "LINE";
+ case Record::Public:
+ return "PUBLIC";
+ case Record::StackCFI:
+ return "STACK CFI";
+ }
+ llvm_unreachable("Unknown record kind!");
+}
diff --git a/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
new file mode 100644
index 0000000000000..5d5cdb319c10e
--- /dev/null
+++ b/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.h
@@ -0,0 +1,163 @@
+//===-- BreakpadRecords.h ------------------------------------- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
+#define LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
+
+#include "lldb/Utility/UUID.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/FormatProviders.h"
+
+namespace lldb_private {
+namespace breakpad {
+
+class Record {
+public:
+ enum Kind { Module, Info, File, Func, Line, Public, StackCFI };
+
+ /// Attempt to guess the kind of the record present in the argument without
+ /// doing a full parse. The returned kind will always be correct for valid
+ /// records, but the full parse can still fail in case of corrupted input.
+ static llvm::Optional<Kind> classify(llvm::StringRef Line);
+
+protected:
+ Record(Kind K) : TheKind(K) {}
+
+ ~Record() = default;
+
+public:
+ Kind getKind() { return TheKind; }
+
+private:
+ Kind TheKind;
+};
+
+llvm::StringRef toString(Record::Kind K);
+inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, Record::Kind K) {
+ OS << toString(K);
+ return OS;
+}
+
+class ModuleRecord : public Record {
+public:
+ static llvm::Optional<ModuleRecord> parse(llvm::StringRef Line);
+ ModuleRecord(llvm::Triple::OSType OS, llvm::Triple::ArchType Arch, UUID ID)
+ : Record(Module), OS(OS), Arch(Arch), ID(std::move(ID)) {}
+
+ llvm::Triple::OSType OS;
+ llvm::Triple::ArchType Arch;
+ UUID ID;
+};
+
+inline bool operator==(const ModuleRecord &L, const ModuleRecord &R) {
+ return L.OS == R.OS && L.Arch == R.Arch && L.ID == R.ID;
+}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ModuleRecord &R);
+
+class InfoRecord : public Record {
+public:
+ static llvm::Optional<InfoRecord> parse(llvm::StringRef Line);
+ InfoRecord(UUID ID) : Record(Info), ID(std::move(ID)) {}
+
+ UUID ID;
+};
+
+inline bool operator==(const InfoRecord &L, const InfoRecord &R) {
+ return L.ID == R.ID;
+}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const InfoRecord &R);
+
+class FileRecord : public Record {
+public:
+ static llvm::Optional<FileRecord> parse(llvm::StringRef Line);
+ FileRecord(size_t Number, llvm::StringRef Name)
+ : Record(File), Number(Number), Name(Name) {}
+
+ size_t Number;
+ llvm::StringRef Name;
+};
+
+inline bool operator==(const FileRecord &L, const FileRecord &R) {
+ return L.Number == R.Number && L.Name == R.Name;
+}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FileRecord &R);
+
+class FuncRecord : public Record {
+public:
+ static llvm::Optional<FuncRecord> parse(llvm::StringRef Line);
+ FuncRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t Size,
+ lldb::addr_t ParamSize, llvm::StringRef Name)
+ : Record(Module), Multiple(Multiple), Address(Address), Size(Size),
+ ParamSize(ParamSize), Name(Name) {}
+
+ bool Multiple;
+ lldb::addr_t Address;
+ lldb::addr_t Size;
+ lldb::addr_t ParamSize;
+ llvm::StringRef Name;
+};
+
+bool operator==(const FuncRecord &L, const FuncRecord &R);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const FuncRecord &R);
+
+class LineRecord : public Record {
+public:
+ static llvm::Optional<LineRecord> parse(llvm::StringRef Line);
+ LineRecord(lldb::addr_t Address, lldb::addr_t Size, uint32_t LineNum,
+ size_t FileNum)
+ : Record(Line), Address(Address), Size(Size), LineNum(LineNum),
+ FileNum(FileNum) {}
+
+ lldb::addr_t Address;
+ lldb::addr_t Size;
+ uint32_t LineNum;
+ size_t FileNum;
+};
+
+bool operator==(const LineRecord &L, const LineRecord &R);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const LineRecord &R);
+
+class PublicRecord : public Record {
+public:
+ static llvm::Optional<PublicRecord> parse(llvm::StringRef Line);
+ PublicRecord(bool Multiple, lldb::addr_t Address, lldb::addr_t ParamSize,
+ llvm::StringRef Name)
+ : Record(Module), Multiple(Multiple), Address(Address),
+ ParamSize(ParamSize), Name(Name) {}
+
+ bool Multiple;
+ lldb::addr_t Address;
+ lldb::addr_t ParamSize;
+ llvm::StringRef Name;
+};
+
+bool operator==(const PublicRecord &L, const PublicRecord &R);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const PublicRecord &R);
+
+class StackCFIRecord : public Record {
+public:
+ static llvm::Optional<StackCFIRecord> parse(llvm::StringRef Line);
+ StackCFIRecord(lldb::addr_t Address, llvm::Optional<lldb::addr_t> Size,
+ llvm::StringRef UnwindRules)
+ : Record(StackCFI), Address(Address), Size(Size),
+ UnwindRules(UnwindRules) {}
+
+ lldb::addr_t Address;
+ llvm::Optional<lldb::addr_t> Size;
+ llvm::StringRef UnwindRules;
+};
+
+bool operator==(const StackCFIRecord &L, const StackCFIRecord &R);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const StackCFIRecord &R);
+
+} // namespace breakpad
+} // namespace lldb_private
+
+#endif // LLDB_PLUGINS_OBJECTFILE_BREAKPAD_BREAKPADRECORDS_H
diff --git a/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
index 917025030ada4..60dd9f9cecf0f 100644
--- a/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
+++ b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
@@ -1,18 +1,16 @@
//===-- ObjectFileBreakpad.cpp -------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
-#include "lldb/Utility/DataBuffer.h"
-#include "llvm/ADT/StringExtras.h"
using namespace lldb;
using namespace lldb_private;
@@ -24,164 +22,24 @@ struct Header {
UUID uuid;
static llvm::Optional<Header> parse(llvm::StringRef text);
};
-
-enum class Token { Unknown, Module, Info, File, Func, Public, Stack };
} // namespace
-static Token toToken(llvm::StringRef str) {
- return llvm::StringSwitch<Token>(str)
- .Case("MODULE", Token::Module)
- .Case("INFO", Token::Info)
- .Case("FILE", Token::File)
- .Case("FUNC", Token::Func)
- .Case("PUBLIC", Token::Public)
- .Case("STACK", Token::Stack)
- .Default(Token::Unknown);
-}
-
-static llvm::StringRef toString(Token t) {
- switch (t) {
- case Token::Unknown:
- return "";
- case Token::Module:
- return "MODULE";
- case Token::Info:
- return "INFO";
- case Token::File:
- return "FILE";
- case Token::Func:
- return "FUNC";
- case Token::Public:
- return "PUBLIC";
- case Token::Stack:
- return "STACK";
- }
- llvm_unreachable("Unknown token!");
-}
-
-static llvm::Triple::OSType toOS(llvm::StringRef str) {
- using llvm::Triple;
- return llvm::StringSwitch<Triple::OSType>(str)
- .Case("Linux", Triple::Linux)
- .Case("mac", Triple::MacOSX)
- .Case("windows", Triple::Win32)
- .Default(Triple::UnknownOS);
-}
-
-static llvm::Triple::ArchType toArch(llvm::StringRef str) {
- using llvm::Triple;
- return llvm::StringSwitch<Triple::ArchType>(str)
- .Case("arm", Triple::arm)
- .Case("arm64", Triple::aarch64)
- .Case("mips", Triple::mips)
- .Case("ppc", Triple::ppc)
- .Case("ppc64", Triple::ppc64)
- .Case("s390", Triple::systemz)
- .Case("sparc", Triple::sparc)
- .Case("sparcv9", Triple::sparcv9)
- .Case("x86", Triple::x86)
- .Case("x86_64", Triple::x86_64)
- .Default(Triple::UnknownArch);
-}
-
-static llvm::StringRef consume_front(llvm::StringRef &str, size_t n) {
- llvm::StringRef result = str.take_front(n);
- str = str.drop_front(n);
- return result;
-}
-
-static UUID parseModuleId(llvm::Triple::OSType os, llvm::StringRef str) {
- struct uuid_data {
- llvm::support::ulittle32_t uuid1;
- llvm::support::ulittle16_t uuid2[2];
- uint8_t uuid3[8];
- llvm::support::ulittle32_t age;
- } data;
- static_assert(sizeof(data) == 20, "");
- // The textual module id encoding should be between 33 and 40 bytes long,
- // depending on the size of the age field, which is of variable length.
- // The first three chunks of the id are encoded in big endian, so we need to
- // byte-swap those.
- if (str.size() < 33 || str.size() > 40)
- return UUID();
- uint32_t t;
- if (to_integer(consume_front(str, 8), t, 16))
- data.uuid1 = t;
- else
- return UUID();
- for (int i = 0; i < 2; ++i) {
- if (to_integer(consume_front(str, 4), t, 16))
- data.uuid2[i] = t;
- else
- return UUID();
- }
- for (int i = 0; i < 8; ++i) {
- if (!to_integer(consume_front(str, 2), data.uuid3[i], 16))
- return UUID();
- }
- if (to_integer(str, t, 16))
- data.age = t;
- else
- return UUID();
-
- // On non-windows, the age field should always be zero, so we don't include to
- // match the native uuid format of these platforms.
- return UUID::fromData(&data, os == llvm::Triple::Win32 ? 20 : 16);
-}
-
llvm::Optional<Header> Header::parse(llvm::StringRef text) {
- // A valid module should start with something like:
- // MODULE Linux x86_64 E5894855C35DCCCCCCCCCCCCCCCCCCCC0 a.out
- // optionally followed by
- // INFO CODE_ID 554889E55DC3CCCCCCCCCCCCCCCCCCCC [a.exe]
- llvm::StringRef token, line;
+ llvm::StringRef line;
std::tie(line, text) = text.split('\n');
- std::tie(token, line) = getToken(line);
- if (toToken(token) != Token::Module)
+ auto Module = ModuleRecord::parse(line);
+ if (!Module)
return llvm::None;
- std::tie(token, line) = getToken(line);
llvm::Triple triple;
- triple.setOS(toOS(token));
- if (triple.getOS() == llvm::Triple::UnknownOS)
- return llvm::None;
-
- std::tie(token, line) = getToken(line);
- triple.setArch(toArch(token));
- if (triple.getArch() == llvm::Triple::UnknownArch)
- return llvm::None;
-
- llvm::StringRef module_id;
- std::tie(module_id, line) = getToken(line);
+ triple.setArch(Module->Arch);
+ triple.setOS(Module->OS);
std::tie(line, text) = text.split('\n');
- std::tie(token, line) = getToken(line);
- if (token == "INFO") {
- std::tie(token, line) = getToken(line);
- if (token != "CODE_ID")
- return llvm::None;
- std::tie(token, line) = getToken(line);
- // If we don't have any text following the code id (e.g. on linux), we
- // should use the module id as UUID. Otherwise, we revert back to the module
- // id.
- if (line.trim().empty()) {
- UUID uuid;
- if (uuid.SetFromStringRef(token, token.size() / 2) != token.size())
- return llvm::None;
-
- return Header{ArchSpec(triple), uuid};
- }
- }
-
- // We reach here if we don't have a INFO CODE_ID section, or we chose not to
- // use it. In either case, we need to properly decode the module id, whose
- // fields are encoded in big-endian.
- UUID uuid = parseModuleId(triple.getOS(), module_id);
- if (!uuid)
- return llvm::None;
-
- return Header{ArchSpec(triple), uuid};
+ auto Info = InfoRecord::parse(line);
+ UUID uuid = Info && Info->ID ? Info->ID : Module->ID;
+ return Header{ArchSpec(triple), std::move(uuid)};
}
void ObjectFileBreakpad::Initialize() {
@@ -264,50 +122,45 @@ Symtab *ObjectFileBreakpad::GetSymtab() {
return nullptr;
}
-bool ObjectFileBreakpad::GetUUID(UUID *uuid) {
- *uuid = m_uuid;
- return true;
-}
-
void ObjectFileBreakpad::CreateSections(SectionList &unified_section_list) {
- if (m_sections_ap)
+ if (m_sections_up)
return;
- m_sections_ap = llvm::make_unique<SectionList>();
+ m_sections_up = llvm::make_unique<SectionList>();
- Token current_section = Token::Unknown;
+ llvm::Optional<Record::Kind> current_section;
offset_t section_start;
llvm::StringRef text = toStringRef(m_data.GetData());
uint32_t next_section_id = 1;
auto maybe_add_section = [&](const uint8_t *end_ptr) {
- if (current_section == Token::Unknown)
+ if (!current_section)
return; // We have been called before parsing the first line.
offset_t end_offset = end_ptr - m_data.GetDataStart();
auto section_sp = std::make_shared<Section>(
GetModule(), this, next_section_id++,
- ConstString(toString(current_section)), eSectionTypeOther,
+ ConstString(toString(*current_section)), eSectionTypeOther,
/*file_vm_addr*/ 0, /*vm_size*/ 0, section_start,
end_offset - section_start, /*log2align*/ 0, /*flags*/ 0);
- m_sections_ap->AddSection(section_sp);
+ m_sections_up->AddSection(section_sp);
unified_section_list.AddSection(section_sp);
};
while (!text.empty()) {
llvm::StringRef line;
std::tie(line, text) = text.split('\n');
- Token token = toToken(getToken(line).first);
- if (token == Token::Unknown) {
- // We assume this is a line record, which logically belongs to the Func
- // section. Errors will be handled when parsing the Func section.
- token = Token::Func;
+ llvm::Optional<Record::Kind> next_section = Record::classify(line);
+ if (next_section == Record::Line) {
+ // Line records logically belong to the preceding Func record, so we put
+ // them in the same section.
+ next_section = Record::Func;
}
- if (token == current_section)
+ if (next_section == current_section)
continue;
// Changing sections, finish off the previous one, if there was any.
maybe_add_section(line.bytes_begin());
// And start a new one.
- current_section = token;
+ current_section = next_section;
section_start = line.bytes_begin() - m_data.GetDataStart();
}
// Finally, add the last section.
diff --git a/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
index ba2a3ad30e5f9..e8885e0cc8982 100644
--- a/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
+++ b/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
@@ -1,9 +1,8 @@
//===-- ObjectFileBreakpad.h ---------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,16 +11,13 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/ArchSpec.h"
-#include "llvm/ADT/Triple.h"
namespace lldb_private {
namespace breakpad {
class ObjectFileBreakpad : public ObjectFile {
public:
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -47,16 +43,12 @@ public:
lldb::offset_t length,
ModuleSpecList &specs);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override { return GetPluginNameStatic(); }
uint32_t GetPluginVersion() override { return 1; }
- //------------------------------------------------------------------
// ObjectFile Protocol.
- //------------------------------------------------------------------
bool ParseHeader() override;
@@ -84,7 +76,7 @@ public:
ArchSpec GetArchitecture() override { return m_arch; }
- bool GetUUID(UUID *uuid) override;
+ UUID GetUUID() override { return m_uuid; }
FileSpecList GetDebugSymbolFilePaths() override { return FileSpecList(); }
diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index 3d4735286bf2a..aa9871071b0e0 100644
--- a/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -1,9 +1,8 @@
//===-- ELFHeader.cpp ----------------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,7 +18,6 @@ using namespace elf;
using namespace lldb;
using namespace llvm::ELF;
-//------------------------------------------------------------------------------
// Static utility functions.
//
// GetMaxU64 and GetMaxS64 wrap the similarly named methods from DataExtractor
@@ -68,7 +66,6 @@ static bool GetMaxS64(const lldb_private::DataExtractor &data,
return true;
}
-//------------------------------------------------------------------------------
// ELFHeader
ELFHeader::ELFHeader() { memset(this, 0, sizeof(ELFHeader)); }
@@ -117,7 +114,7 @@ void ELFHeader::ParseHeaderExtension(lldb_private::DataExtractor &data) {
bool ELFHeader::Parse(lldb_private::DataExtractor &data,
lldb::offset_t *offset) {
// Read e_ident. This provides byte order and address size info.
- if (data.GetU8(offset, &e_ident, EI_NIDENT) == NULL)
+ if (data.GetU8(offset, &e_ident, EI_NIDENT) == nullptr)
return false;
const unsigned byte_size = Is32Bit() ? 4 : 8;
@@ -125,11 +122,11 @@ bool ELFHeader::Parse(lldb_private::DataExtractor &data,
data.SetAddressByteSize(byte_size);
// Read e_type and e_machine.
- if (data.GetU16(offset, &e_type, 2) == NULL)
+ if (data.GetU16(offset, &e_type, 2) == nullptr)
return false;
// Read e_version.
- if (data.GetU32(offset, &e_version, 1) == NULL)
+ if (data.GetU32(offset, &e_version, 1) == nullptr)
return false;
// Read e_entry, e_phoff and e_shoff.
@@ -137,11 +134,11 @@ bool ELFHeader::Parse(lldb_private::DataExtractor &data,
return false;
// Read e_flags.
- if (data.GetU32(offset, &e_flags, 1) == NULL)
+ if (data.GetU32(offset, &e_flags, 1) == nullptr)
return false;
// Read e_ehsize, e_phentsize, e_phnum, e_shentsize, e_shnum and e_shstrndx.
- if (data.GetU16(offset, &e_ehsize, 6) == NULL)
+ if (data.GetU16(offset, &e_ehsize, 6) == nullptr)
return false;
// Initialize e_phnum, e_shnum, and e_shstrndx with the values read from the
@@ -216,7 +213,6 @@ unsigned ELFHeader::GetRelocationJumpSlotType() const {
return slot;
}
-//------------------------------------------------------------------------------
// ELFSectionHeader
ELFSectionHeader::ELFSectionHeader() {
@@ -228,7 +224,7 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data,
const unsigned byte_size = data.GetAddressByteSize();
// Read sh_name and sh_type.
- if (data.GetU32(offset, &sh_name, 2) == NULL)
+ if (data.GetU32(offset, &sh_name, 2) == nullptr)
return false;
// Read sh_flags.
@@ -240,7 +236,7 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data,
return false;
// Read sh_link and sh_info.
- if (data.GetU32(offset, &sh_link, 2) == NULL)
+ if (data.GetU32(offset, &sh_link, 2) == nullptr)
return false;
// Read sh_addralign and sh_entsize.
@@ -250,7 +246,6 @@ bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data,
return true;
}
-//------------------------------------------------------------------------------
// ELFSymbol
ELFSymbol::ELFSymbol() { memset(this, 0, sizeof(ELFSymbol)); }
@@ -327,7 +322,7 @@ bool ELFSymbol::Parse(const lldb_private::DataExtractor &data,
const bool parsing_32 = byte_size == 4;
// Read st_name.
- if (data.GetU32(offset, &st_name, 1) == NULL)
+ if (data.GetU32(offset, &st_name, 1) == nullptr)
return false;
if (parsing_32) {
@@ -336,29 +331,28 @@ bool ELFSymbol::Parse(const lldb_private::DataExtractor &data,
return false;
// Read st_info and st_other.
- if (data.GetU8(offset, &st_info, 2) == NULL)
+ if (data.GetU8(offset, &st_info, 2) == nullptr)
return false;
// Read st_shndx.
- if (data.GetU16(offset, &st_shndx, 1) == NULL)
+ if (data.GetU16(offset, &st_shndx, 1) == nullptr)
return false;
} else {
// Read st_info and st_other.
- if (data.GetU8(offset, &st_info, 2) == NULL)
+ if (data.GetU8(offset, &st_info, 2) == nullptr)
return false;
// Read st_shndx.
- if (data.GetU16(offset, &st_shndx, 1) == NULL)
+ if (data.GetU16(offset, &st_shndx, 1) == nullptr)
return false;
// Read st_value and st_size.
- if (data.GetU64(offset, &st_value, 2) == NULL)
+ if (data.GetU64(offset, &st_value, 2) == nullptr)
return false;
}
return true;
}
-//------------------------------------------------------------------------------
// ELFProgramHeader
ELFProgramHeader::ELFProgramHeader() {
@@ -371,7 +365,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
const bool parsing_32 = byte_size == 4;
// Read p_type;
- if (data.GetU32(offset, &p_type, 1) == NULL)
+ if (data.GetU32(offset, &p_type, 1) == nullptr)
return false;
if (parsing_32) {
@@ -380,7 +374,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
return false;
// Read p_flags.
- if (data.GetU32(offset, &p_flags, 1) == NULL)
+ if (data.GetU32(offset, &p_flags, 1) == nullptr)
return false;
// Read p_align.
@@ -388,7 +382,7 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
return false;
} else {
// Read p_flags.
- if (data.GetU32(offset, &p_flags, 1) == NULL)
+ if (data.GetU32(offset, &p_flags, 1) == nullptr)
return false;
// Read p_offset, p_vaddr, p_paddr, p_filesz, p_memsz and p_align.
@@ -399,7 +393,6 @@ bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data,
return true;
}
-//------------------------------------------------------------------------------
// ELFDynamic
ELFDynamic::ELFDynamic() { memset(this, 0, sizeof(ELFDynamic)); }
@@ -410,7 +403,6 @@ bool ELFDynamic::Parse(const lldb_private::DataExtractor &data,
return GetMaxS64(data, offset, &d_tag, byte_size, 2);
}
-//------------------------------------------------------------------------------
// ELFRel
ELFRel::ELFRel() { memset(this, 0, sizeof(ELFRel)); }
@@ -423,7 +415,6 @@ bool ELFRel::Parse(const lldb_private::DataExtractor &data,
return GetMaxU64(data, offset, &r_offset, byte_size, 2) != false;
}
-//------------------------------------------------------------------------------
// ELFRela
ELFRela::ELFRela() { memset(this, 0, sizeof(ELFRela)); }
diff --git a/source/Plugins/ObjectFile/ELF/ELFHeader.h b/source/Plugins/ObjectFile/ELF/ELFHeader.h
index faaf8be99d687..bb228e269d406 100644
--- a/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ b/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -1,13 +1,12 @@
//===-- ELFHeader.h ------------------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
-/// @file
+/// \file
/// Generic structures and typedefs for ELF files.
///
/// This file provides definitions for the various entities comprising an ELF
@@ -32,8 +31,7 @@ class DataExtractor;
namespace elf {
-//------------------------------------------------------------------------------
-/// @name ELF type definitions.
+/// \name ELF type definitions.
///
/// Types used to represent the various components of ELF structures. All
/// types are signed or unsigned integral types wide enough to hold values
@@ -50,8 +48,7 @@ typedef uint64_t elf_xword;
typedef int64_t elf_sxword;
//@}
-//------------------------------------------------------------------------------
-/// @class ELFHeader
+/// \class ELFHeader
/// Generic representation of an ELF file header.
///
/// This object is used to identify the general attributes on an ELF file and
@@ -81,93 +78,83 @@ struct ELFHeader {
ELFHeader();
- //--------------------------------------------------------------------------
/// Returns true if this is a 32 bit ELF file header.
///
- /// @return
+ /// \return
/// True if this is a 32 bit ELF file header.
bool Is32Bit() const {
return e_ident[llvm::ELF::EI_CLASS] == llvm::ELF::ELFCLASS32;
}
- //--------------------------------------------------------------------------
/// Returns true if this is a 64 bit ELF file header.
///
- /// @return
+ /// \return
/// True if this is a 64 bit ELF file header.
bool Is64Bit() const {
return e_ident[llvm::ELF::EI_CLASS] == llvm::ELF::ELFCLASS64;
}
- //--------------------------------------------------------------------------
/// The byte order of this ELF file header.
///
- /// @return
+ /// \return
/// The byte order of this ELF file as described by the header.
lldb::ByteOrder GetByteOrder() const;
- //--------------------------------------------------------------------------
/// The jump slot relocation type of this ELF.
unsigned GetRelocationJumpSlotType() const;
- //--------------------------------------------------------------------------
/// Check if there should be header extension in section header #0
///
- /// @return
+ /// \return
/// True if parsing the ELFHeader requires reading header extension
/// and false otherwise.
bool HasHeaderExtension() const;
- //--------------------------------------------------------------------------
/// Parse an ELFHeader entry starting at position \p offset and update the
/// data extractor with the address size and byte order attributes as
/// defined by the header.
///
- /// @param[in,out] data
+ /// \param[in,out] data
/// The DataExtractor to read from. Updated with the address size and
/// byte order attributes appropriate to this header.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFHeader was successfully read and false
/// otherwise.
bool Parse(lldb_private::DataExtractor &data, lldb::offset_t *offset);
- //--------------------------------------------------------------------------
/// Examines at most EI_NIDENT bytes starting from the given pointer and
/// determines if the magic ELF identification exists.
///
- /// @return
+ /// \return
/// True if the given sequence of bytes identifies an ELF file.
static bool MagicBytesMatch(const uint8_t *magic);
- //--------------------------------------------------------------------------
/// Examines at most EI_NIDENT bytes starting from the given address and
/// determines the address size of the underlying ELF file. This function
/// should only be called on an pointer for which MagicBytesMatch returns
/// true.
///
- /// @return
+ /// \return
/// The number of bytes forming an address in the ELF file (either 4 or
/// 8), else zero if the address size could not be determined.
static unsigned AddressSizeInBytes(const uint8_t *magic);
private:
- //--------------------------------------------------------------------------
/// Parse an ELFHeader header extension entry. This method is called by
/// Parse().
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from.
void ParseHeaderExtension(lldb_private::DataExtractor &data);
};
-//------------------------------------------------------------------------------
-/// @class ELFSectionHeader
+/// \class ELFSectionHeader
/// Generic representation of an ELF section header.
struct ELFSectionHeader {
elf_word sh_name; ///< Section name string index.
@@ -183,26 +170,24 @@ struct ELFSectionHeader {
ELFSectionHeader();
- //--------------------------------------------------------------------------
/// Parse an ELFSectionHeader entry from the given DataExtracter starting at
/// position \p offset.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from. The address size of the extractor
/// determines if a 32 or 64 bit object should be read.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFSectionHeader was successfully read and false
/// otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
};
-//------------------------------------------------------------------------------
-/// @class ELFProgramHeader
+/// \class ELFProgramHeader
/// Generic representation of an ELF program header.
struct ELFProgramHeader {
elf_word p_type; ///< Type of program segment.
@@ -220,22 +205,21 @@ struct ELFProgramHeader {
/// position \p offset. The address size of the DataExtractor determines if
/// a 32 or 64 bit object is to be parsed.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from. The address size of the extractor
/// determines if a 32 or 64 bit object should be read.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFProgramHeader was successfully read and false
/// otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
};
-//------------------------------------------------------------------------------
-/// @class ELFSymbol
+/// \class ELFSymbol
/// Represents a symbol within an ELF symbol table.
struct ELFSymbol {
elf_addr st_value; ///< Absolute or relocatable address.
@@ -270,15 +254,15 @@ struct ELFSymbol {
/// position \p offset. The address size of the DataExtractor determines if
/// a 32 or 64 bit object is to be parsed.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from. The address size of the extractor
/// determines if a 32 or 64 bit object should be read.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFSymbol was successfully read and false otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
@@ -287,8 +271,7 @@ struct ELFSymbol {
const lldb_private::SectionList *section_list);
};
-//------------------------------------------------------------------------------
-/// @class ELFDynamic
+/// \class ELFDynamic
/// Represents an entry in an ELF dynamic table.
struct ELFDynamic {
elf_sxword d_tag; ///< Type of dynamic table entry.
@@ -303,22 +286,21 @@ struct ELFDynamic {
/// position \p offset. The address size of the DataExtractor determines if
/// a 32 or 64 bit object is to be parsed.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from. The address size of the extractor
/// determines if a 32 or 64 bit object should be read.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFDynamic entry was successfully read and false
/// otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
};
-//------------------------------------------------------------------------------
-/// @class ELFRel
+/// \class ELFRel
/// Represents a relocation entry with an implicit addend.
struct ELFRel {
elf_addr r_offset; ///< Address of reference.
@@ -330,15 +312,15 @@ struct ELFRel {
/// \p offset. The address size of the DataExtractor determines if a 32 or
/// 64 bit object is to be parsed.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from. The address size of the extractor
/// determines if a 32 or 64 bit object should be read.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFRel entry was successfully read and false otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
@@ -359,8 +341,7 @@ struct ELFRel {
static unsigned RelocSymbol64(const ELFRel &rel) { return rel.r_info >> 32; }
};
-//------------------------------------------------------------------------------
-/// @class ELFRela
+/// \class ELFRela
/// Represents a relocation entry with an explicit addend.
struct ELFRela {
elf_addr r_offset; ///< Address of reference.
@@ -373,15 +354,15 @@ struct ELFRela {
/// \p offset. The address size of the DataExtractor determines if a 32 or
/// 64 bit object is to be parsed.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from. The address size of the extractor
/// determines if a 32 or 64 bit object should be read.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFRela entry was successfully read and false otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 9a6563afa0a01..d62afa34bbe81 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1,9 +1,8 @@
//===-- ObjectFileELF.cpp ------------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,7 +16,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
@@ -27,6 +25,7 @@
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/Timer.h"
@@ -56,8 +55,8 @@ namespace {
const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD";
const char *const LLDB_NT_OWNER_GNU = "GNU";
const char *const LLDB_NT_OWNER_NETBSD = "NetBSD";
+const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE";
const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD";
-const char *const LLDB_NT_OWNER_CSR = "csr";
const char *const LLDB_NT_OWNER_ANDROID = "Android";
const char *const LLDB_NT_OWNER_CORE = "CORE";
const char *const LLDB_NT_OWNER_LINUX = "LINUX";
@@ -71,8 +70,10 @@ const elf_word LLDB_NT_GNU_ABI_SIZE = 16;
const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03;
-const elf_word LLDB_NT_NETBSD_ABI_TAG = 0x01;
-const elf_word LLDB_NT_NETBSD_ABI_SIZE = 4;
+const elf_word LLDB_NT_NETBSD_IDENT_TAG = 1;
+const elf_word LLDB_NT_NETBSD_IDENT_DESCSZ = 4;
+const elf_word LLDB_NT_NETBSD_IDENT_NAMESZ = 7;
+const elf_word LLDB_NT_NETBSD_PROCINFO = 1;
// GNU ABI note OS constants
const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00;
@@ -115,7 +116,7 @@ const elf_word LLDB_NT_GNU_ABI_OS_SOLARIS = 0x02;
#define NT_METAG_TLS 0x502
//===----------------------------------------------------------------------===//
-/// @class ELFRelocation
+/// \class ELFRelocation
/// Generic wrapper for ELFRel and ELFRela.
///
/// This helper class allows us to parse both ELFRel and ELFRela relocation
@@ -125,7 +126,7 @@ public:
/// Constructs an ELFRelocation entry with a personality as given by @p
/// type.
///
- /// @param type Either DT_REL or DT_RELA. Any other value is invalid.
+ /// \param type Either DT_REL or DT_RELA. Any other value is invalid.
ELFRelocation(unsigned type);
~ELFRelocation();
@@ -161,7 +162,7 @@ ELFRelocation::ELFRelocation(unsigned type) {
reloc = new ELFRela();
else {
assert(false && "unexpected relocation type");
- reloc = static_cast<ELFRel *>(NULL);
+ reloc = static_cast<ELFRel *>(nullptr);
}
}
@@ -242,7 +243,7 @@ static user_id_t SegmentID(size_t PHdrIndex) { return ~PHdrIndex; }
bool ELFNote::Parse(const DataExtractor &data, lldb::offset_t *offset) {
// Read all fields.
- if (data.GetU32(offset, &n_namesz, 3) == NULL)
+ if (data.GetU32(offset, &n_namesz, 3) == nullptr)
return false;
// The name field is required to be nul-terminated, and n_namesz includes the
@@ -261,7 +262,7 @@ bool ELFNote::Parse(const DataExtractor &data, lldb::offset_t *offset) {
}
const char *cstr = data.GetCStr(offset, llvm::alignTo(n_namesz, 4));
- if (cstr == NULL) {
+ if (cstr == nullptr) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS));
if (log)
log->Printf("Failed to parse note name lacking nul terminator");
@@ -272,27 +273,6 @@ bool ELFNote::Parse(const DataExtractor &data, lldb::offset_t *offset) {
return true;
}
-static uint32_t kalimbaVariantFromElfFlags(const elf::elf_word e_flags) {
- const uint32_t dsp_rev = e_flags & 0xFF;
- uint32_t kal_arch_variant = LLDB_INVALID_CPUTYPE;
- switch (dsp_rev) {
- // TODO(mg11) Support more variants
- case 10:
- kal_arch_variant = llvm::Triple::KalimbaSubArch_v3;
- break;
- case 14:
- kal_arch_variant = llvm::Triple::KalimbaSubArch_v4;
- break;
- case 17:
- case 20:
- kal_arch_variant = llvm::Triple::KalimbaSubArch_v5;
- break;
- default:
- break;
- }
- return kal_arch_variant;
-}
-
static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) {
const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH;
uint32_t endian = header.e_ident[EI_DATA];
@@ -350,40 +330,13 @@ static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) {
if (header.e_machine == llvm::ELF::EM_MIPS)
return mipsVariantFromElfFlags(header);
- return llvm::ELF::EM_CSR_KALIMBA == header.e_machine
- ? kalimbaVariantFromElfFlags(header.e_flags)
- : LLDB_INVALID_CPUTYPE;
-}
-
-//! The kalimba toolchain identifies a code section as being
-//! one with the SHT_PROGBITS set in the section sh_type and the top
-//! bit in the 32-bit address field set.
-static lldb::SectionType
-kalimbaSectionType(const elf::ELFHeader &header,
- const elf::ELFSectionHeader &sect_hdr) {
- if (llvm::ELF::EM_CSR_KALIMBA != header.e_machine) {
- return eSectionTypeOther;
- }
-
- if (llvm::ELF::SHT_NOBITS == sect_hdr.sh_type) {
- return eSectionTypeZeroFill;
- }
-
- if (llvm::ELF::SHT_PROGBITS == sect_hdr.sh_type) {
- const lldb::addr_t KAL_CODE_BIT = 1 << 31;
- return KAL_CODE_BIT & sect_hdr.sh_addr ? eSectionTypeCode
- : eSectionTypeData;
- }
-
- return eSectionTypeOther;
+ return LLDB_INVALID_CPUTYPE;
}
// Arbitrary constant used as UUID prefix for core files.
const uint32_t ObjectFileELF::g_core_uuid_magic(0xE210C);
-//------------------------------------------------------------------
// Static methods.
-//------------------------------------------------------------------
void ObjectFileELF::Initialize() {
PluginManager::RegisterPlugin(GetPluginNameStatic(),
GetPluginDescriptionStatic(), CreateInstance,
@@ -436,14 +389,14 @@ ObjectFile *ObjectFileELF::CreateInstance(const lldb::ModuleSP &module_sp,
unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
if (address_size == 4 || address_size == 8) {
- std::unique_ptr<ObjectFileELF> objfile_ap(new ObjectFileELF(
+ std::unique_ptr<ObjectFileELF> objfile_up(new ObjectFileELF(
module_sp, data_sp, data_offset, file, file_offset, length));
- ArchSpec spec = objfile_ap->GetArchitecture();
- if (spec && objfile_ap->SetModulesArchitecture(spec))
- return objfile_ap.release();
+ ArchSpec spec = objfile_up->GetArchitecture();
+ if (spec && objfile_up->SetModulesArchitecture(spec))
+ return objfile_up.release();
}
- return NULL;
+ return nullptr;
}
ObjectFile *ObjectFileELF::CreateMemoryInstance(
@@ -454,15 +407,15 @@ ObjectFile *ObjectFileELF::CreateMemoryInstance(
if (ELFHeader::MagicBytesMatch(magic)) {
unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
if (address_size == 4 || address_size == 8) {
- std::unique_ptr<ObjectFileELF> objfile_ap(
+ std::unique_ptr<ObjectFileELF> objfile_up(
new ObjectFileELF(module_sp, data_sp, process_sp, header_addr));
- ArchSpec spec = objfile_ap->GetArchitecture();
- if (spec && objfile_ap->SetModulesArchitecture(spec))
- return objfile_ap.release();
+ ArchSpec spec = objfile_up->GetArchitecture();
+ if (spec && objfile_up->SetModulesArchitecture(spec))
+ return objfile_up.release();
}
}
}
- return NULL;
+ return nullptr;
}
bool ObjectFileELF::MagicBytesMatch(DataBufferSP &data_sp,
@@ -756,17 +709,13 @@ size_t ObjectFileELF::GetModuleSpecifications(
return specs.GetSize() - initial_count;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ObjectFileELF::GetPluginName() {
return GetPluginNameStatic();
}
uint32_t ObjectFileELF::GetPluginVersion() { return m_plugin_version; }
-//------------------------------------------------------------------
// ObjectFile protocol
-//------------------------------------------------------------------
ObjectFileELF::ObjectFileELF(const lldb::ModuleSP &module_sp,
DataBufferSP &data_sp, lldb::offset_t data_offset,
@@ -775,7 +724,7 @@ ObjectFileELF::ObjectFileELF(const lldb::ModuleSP &module_sp,
: ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset),
m_header(), m_uuid(), m_gnu_debuglink_file(), m_gnu_debuglink_crc(0),
m_program_headers(), m_section_headers(), m_dynamic_symbols(),
- m_filespec_ap(), m_entry_point_address(), m_arch_spec() {
+ m_filespec_up(), m_entry_point_address(), m_arch_spec() {
if (file)
m_file = *file;
::memset(&m_header, 0, sizeof(m_header));
@@ -788,7 +737,7 @@ ObjectFileELF::ObjectFileELF(const lldb::ModuleSP &module_sp,
: ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
m_header(), m_uuid(), m_gnu_debuglink_file(), m_gnu_debuglink_crc(0),
m_program_headers(), m_section_headers(), m_dynamic_symbols(),
- m_filespec_ap(), m_entry_point_address(), m_arch_spec() {
+ m_filespec_up(), m_entry_point_address(), m_arch_spec() {
::memset(&m_header, 0, sizeof(m_header));
}
@@ -897,49 +846,43 @@ bool ObjectFileELF::ParseHeader() {
return m_header.Parse(m_data, &offset);
}
-bool ObjectFileELF::GetUUID(lldb_private::UUID *uuid) {
+UUID ObjectFileELF::GetUUID() {
// Need to parse the section list to get the UUIDs, so make sure that's been
// done.
if (!ParseSectionHeaders() && GetType() != ObjectFile::eTypeCoreFile)
- return false;
+ return UUID();
- using u32le = llvm::support::ulittle32_t;
- if (m_uuid.IsValid()) {
- // We have the full build id uuid.
- *uuid = m_uuid;
- return true;
- } else if (GetType() == ObjectFile::eTypeCoreFile) {
- uint32_t core_notes_crc = 0;
+ if (!m_uuid) {
+ using u32le = llvm::support::ulittle32_t;
+ if (GetType() == ObjectFile::eTypeCoreFile) {
+ uint32_t core_notes_crc = 0;
- if (!ParseProgramHeaders())
- return false;
+ if (!ParseProgramHeaders())
+ return UUID();
- core_notes_crc = CalculateELFNotesSegmentsCRC32(m_program_headers, m_data);
+ core_notes_crc =
+ CalculateELFNotesSegmentsCRC32(m_program_headers, m_data);
- if (core_notes_crc) {
- // Use 8 bytes - first 4 bytes for *magic* prefix, mainly to make it look
- // different form .gnu_debuglink crc - followed by 4 bytes of note
- // segments crc.
- u32le data[] = {u32le(g_core_uuid_magic), u32le(core_notes_crc)};
- m_uuid = UUID::fromData(data, sizeof(data));
- }
- } else {
- if (!m_gnu_debuglink_crc)
- m_gnu_debuglink_crc =
- calc_gnu_debuglink_crc32(m_data.GetDataStart(), m_data.GetByteSize());
- if (m_gnu_debuglink_crc) {
- // Use 4 bytes of crc from the .gnu_debuglink section.
- u32le data(m_gnu_debuglink_crc);
- m_uuid = UUID::fromData(&data, sizeof(data));
+ if (core_notes_crc) {
+ // Use 8 bytes - first 4 bytes for *magic* prefix, mainly to make it
+ // look different form .gnu_debuglink crc - followed by 4 bytes of note
+ // segments crc.
+ u32le data[] = {u32le(g_core_uuid_magic), u32le(core_notes_crc)};
+ m_uuid = UUID::fromData(data, sizeof(data));
+ }
+ } else {
+ if (!m_gnu_debuglink_crc)
+ m_gnu_debuglink_crc = calc_gnu_debuglink_crc32(m_data.GetDataStart(),
+ m_data.GetByteSize());
+ if (m_gnu_debuglink_crc) {
+ // Use 4 bytes of crc from the .gnu_debuglink section.
+ u32le data(m_gnu_debuglink_crc);
+ m_uuid = UUID::fromData(&data, sizeof(data));
+ }
}
}
- if (m_uuid.IsValid()) {
- *uuid = m_uuid;
- return true;
- }
-
- return false;
+ return m_uuid;
}
lldb_private::FileSpecList ObjectFileELF::GetDebugSymbolFilePaths() {
@@ -957,7 +900,7 @@ uint32_t ObjectFileELF::GetDependentModules(FileSpecList &files) {
uint32_t num_specs = 0;
for (unsigned i = 0; i < num_modules; ++i) {
- if (files.AppendIfUnique(m_filespec_ap->GetFileSpecAtIndex(i)))
+ if (files.AppendIfUnique(m_filespec_up->GetFileSpecAtIndex(i)))
num_specs++;
}
@@ -1060,14 +1003,12 @@ Address ObjectFileELF::GetBaseAddress() {
return LLDB_INVALID_ADDRESS;
}
-//----------------------------------------------------------------------
// ParseDependentModules
-//----------------------------------------------------------------------
size_t ObjectFileELF::ParseDependentModules() {
- if (m_filespec_ap.get())
- return m_filespec_ap->GetSize();
+ if (m_filespec_up)
+ return m_filespec_up->GetSize();
- m_filespec_ap.reset(new FileSpecList());
+ m_filespec_up.reset(new FileSpecList());
if (!ParseSectionHeaders())
return 0;
@@ -1114,16 +1055,14 @@ size_t ObjectFileELF::ParseDependentModules() {
const char *lib_name = dynstr_data.PeekCStr(str_index);
FileSpec file_spec(lib_name);
FileSystem::Instance().Resolve(file_spec);
- m_filespec_ap->Append(file_spec);
+ m_filespec_up->Append(file_spec);
}
}
- return m_filespec_ap->GetSize();
+ return m_filespec_up->GetSize();
}
-//----------------------------------------------------------------------
// GetProgramHeaderInfo
-//----------------------------------------------------------------------
size_t ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
DataExtractor &object_data,
const ELFHeader &header) {
@@ -1158,9 +1097,7 @@ size_t ObjectFileELF::GetProgramHeaderInfo(ProgramHeaderColl &program_headers,
return program_headers.size();
}
-//----------------------------------------------------------------------
// ParseProgramHeaders
-//----------------------------------------------------------------------
bool ObjectFileELF::ParseProgramHeaders() {
return GetProgramHeaderInfo(m_program_headers, m_data, m_header) != 0;
}
@@ -1301,46 +1238,45 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
// The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
}
- // Process NetBSD ELF notes.
+ // Process NetBSD ELF executables and shared libraries
else if ((note.n_name == LLDB_NT_OWNER_NETBSD) &&
- (note.n_type == LLDB_NT_NETBSD_ABI_TAG) &&
- (note.n_descsz == LLDB_NT_NETBSD_ABI_SIZE)) {
- // Pull out the min version info.
+ (note.n_type == LLDB_NT_NETBSD_IDENT_TAG) &&
+ (note.n_descsz == LLDB_NT_NETBSD_IDENT_DESCSZ) &&
+ (note.n_namesz == LLDB_NT_NETBSD_IDENT_NAMESZ)) {
+ // Pull out the version info.
uint32_t version_info;
if (data.GetU32(&offset, &version_info, 1) == nullptr) {
error.SetErrorString("failed to read NetBSD ABI note payload");
return error;
}
-
+ // Convert the version info into a major/minor/patch number.
+ // #define __NetBSD_Version__ MMmmrrpp00
+ //
+ // M = major version
+ // m = minor version; a minor number of 99 indicates current.
+ // r = 0 (since NetBSD 3.0 not used)
+ // p = patchlevel
+ const uint32_t version_major = version_info / 100000000;
+ const uint32_t version_minor = (version_info % 100000000) / 1000000;
+ const uint32_t version_patch = (version_info % 10000) / 100;
+ // Set the elf OS version to NetBSD. Also clear the vendor.
+ arch_spec.GetTriple().setOSName(
+ llvm::formatv("netbsd{0}.{1}.{2}", version_major, version_minor,
+ version_patch).str());
+ arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
+ }
+ // Process NetBSD ELF core(5) notes
+ else if ((note.n_name == LLDB_NT_OWNER_NETBSDCORE) &&
+ (note.n_type == LLDB_NT_NETBSD_PROCINFO)) {
// Set the elf OS version to NetBSD. Also clear the vendor.
arch_spec.GetTriple().setOS(llvm::Triple::OSType::NetBSD);
arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
-
- if (log)
- log->Printf(
- "ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32,
- __FUNCTION__, version_info);
}
// Process OpenBSD ELF notes.
else if (note.n_name == LLDB_NT_OWNER_OPENBSD) {
// Set the elf OS version to OpenBSD. Also clear the vendor.
arch_spec.GetTriple().setOS(llvm::Triple::OSType::OpenBSD);
arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
- }
- // Process CSR kalimba notes
- else if ((note.n_type == LLDB_NT_GNU_ABI_TAG) &&
- (note.n_name == LLDB_NT_OWNER_CSR)) {
- arch_spec.GetTriple().setOS(llvm::Triple::OSType::UnknownOS);
- arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::CSR);
-
- // TODO At some point the description string could be processed.
- // It could provide a steer towards the kalimba variant which this ELF
- // targets.
- if (note.n_descsz) {
- const char *cstr =
- data.GetCStr(&offset, llvm::alignTo(note.n_descsz, 4));
- (void)cstr;
- }
} else if (note.n_name == LLDB_NT_OWNER_ANDROID) {
arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
arch_spec.GetTriple().setEnvironment(
@@ -1354,8 +1290,6 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data,
// the contents look like this in a 64 bit ELF core file: count =
// 0x000000000000000a (10) page_size = 0x0000000000001000 (4096) Index
// start end file_ofs path =====
- // ------------------ ------------------ ------------------
- // ------------------------------------- [ 0] 0x0000000000400000
// 0x0000000000401000 0x0000000000000000 /tmp/a.out [ 1]
// 0x0000000000600000 0x0000000000601000 0x0000000000000000 /tmp/a.out [
// 2] 0x0000000000601000 0x0000000000602000 0x0000000000000001 /tmp/a.out
@@ -1479,9 +1413,7 @@ void ObjectFileELF::ParseARMAttributes(DataExtractor &data, uint64_t length,
}
}
-//----------------------------------------------------------------------
// GetSectionHeaderInfo
-//----------------------------------------------------------------------
size_t ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl &section_headers,
DataExtractor &object_data,
const elf::ELFHeader &header,
@@ -1714,9 +1646,7 @@ ObjectFileELF::StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const {
return symbol_name.substr(0, pos);
}
-//----------------------------------------------------------------------
// ParseSectionHeaders
-//----------------------------------------------------------------------
size_t ObjectFileELF::ParseSectionHeaders() {
return GetSectionHeaderInfo(m_section_headers, m_data, m_header, m_uuid,
m_gnu_debuglink_file, m_gnu_debuglink_crc,
@@ -1726,12 +1656,12 @@ size_t ObjectFileELF::ParseSectionHeaders() {
const ObjectFileELF::ELFSectionHeaderInfo *
ObjectFileELF::GetSectionHeaderByIndex(lldb::user_id_t id) {
if (!ParseSectionHeaders())
- return NULL;
+ return nullptr;
if (id < m_section_headers.size())
return &m_section_headers[id];
- return NULL;
+ return nullptr;
}
lldb::user_id_t ObjectFileELF::GetSectionIndexByName(const char *name) {
@@ -1744,37 +1674,40 @@ lldb::user_id_t ObjectFileELF::GetSectionIndexByName(const char *name) {
}
static SectionType GetSectionTypeFromName(llvm::StringRef Name) {
+ if (Name.consume_front(".debug_") || Name.consume_front(".zdebug_")) {
+ return llvm::StringSwitch<SectionType>(Name)
+ .Case("abbrev", eSectionTypeDWARFDebugAbbrev)
+ .Case("abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
+ .Case("addr", eSectionTypeDWARFDebugAddr)
+ .Case("aranges", eSectionTypeDWARFDebugAranges)
+ .Case("cu_index", eSectionTypeDWARFDebugCuIndex)
+ .Case("frame", eSectionTypeDWARFDebugFrame)
+ .Case("info", eSectionTypeDWARFDebugInfo)
+ .Case("info.dwo", eSectionTypeDWARFDebugInfoDwo)
+ .Cases("line", "line.dwo", eSectionTypeDWARFDebugLine)
+ .Cases("line_str", "line_str.dwo", eSectionTypeDWARFDebugLineStr)
+ .Cases("loc", "loc.dwo", eSectionTypeDWARFDebugLoc)
+ .Cases("loclists", "loclists.dwo", eSectionTypeDWARFDebugLocLists)
+ .Case("macinfo", eSectionTypeDWARFDebugMacInfo)
+ .Cases("macro", "macro.dwo", eSectionTypeDWARFDebugMacro)
+ .Case("names", eSectionTypeDWARFDebugNames)
+ .Case("pubnames", eSectionTypeDWARFDebugPubNames)
+ .Case("pubtypes", eSectionTypeDWARFDebugPubTypes)
+ .Case("ranges", eSectionTypeDWARFDebugRanges)
+ .Case("rnglists", eSectionTypeDWARFDebugRngLists)
+ .Case("str", eSectionTypeDWARFDebugStr)
+ .Case("str.dwo", eSectionTypeDWARFDebugStrDwo)
+ .Case("str_offsets", eSectionTypeDWARFDebugStrOffsets)
+ .Case("str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
+ .Case("types", eSectionTypeDWARFDebugTypes)
+ .Case("types.dwo", eSectionTypeDWARFDebugTypesDwo)
+ .Default(eSectionTypeOther);
+ }
return llvm::StringSwitch<SectionType>(Name)
.Case(".ARM.exidx", eSectionTypeARMexidx)
.Case(".ARM.extab", eSectionTypeARMextab)
.Cases(".bss", ".tbss", eSectionTypeZeroFill)
.Cases(".data", ".tdata", eSectionTypeData)
- .Case(".debug_abbrev", eSectionTypeDWARFDebugAbbrev)
- .Case(".debug_abbrev.dwo", eSectionTypeDWARFDebugAbbrevDwo)
- .Case(".debug_addr", eSectionTypeDWARFDebugAddr)
- .Case(".debug_aranges", eSectionTypeDWARFDebugAranges)
- .Case(".debug_cu_index", eSectionTypeDWARFDebugCuIndex)
- .Case(".debug_frame", eSectionTypeDWARFDebugFrame)
- .Case(".debug_info", eSectionTypeDWARFDebugInfo)
- .Case(".debug_info.dwo", eSectionTypeDWARFDebugInfoDwo)
- .Cases(".debug_line", ".debug_line.dwo", eSectionTypeDWARFDebugLine)
- .Cases(".debug_line_str", ".debug_line_str.dwo",
- eSectionTypeDWARFDebugLineStr)
- .Cases(".debug_loc", ".debug_loc.dwo", eSectionTypeDWARFDebugLoc)
- .Cases(".debug_loclists", ".debug_loclists.dwo",
- eSectionTypeDWARFDebugLocLists)
- .Case(".debug_macinfo", eSectionTypeDWARFDebugMacInfo)
- .Cases(".debug_macro", ".debug_macro.dwo", eSectionTypeDWARFDebugMacro)
- .Case(".debug_names", eSectionTypeDWARFDebugNames)
- .Case(".debug_pubnames", eSectionTypeDWARFDebugPubNames)
- .Case(".debug_pubtypes", eSectionTypeDWARFDebugPubTypes)
- .Case(".debug_ranges", eSectionTypeDWARFDebugRanges)
- .Case(".debug_rnglists", eSectionTypeDWARFDebugRngLists)
- .Case(".debug_str", eSectionTypeDWARFDebugStr)
- .Case(".debug_str.dwo", eSectionTypeDWARFDebugStrDwo)
- .Case(".debug_str_offsets", eSectionTypeDWARFDebugStrOffsets)
- .Case(".debug_str_offsets.dwo", eSectionTypeDWARFDebugStrOffsetsDwo)
- .Case(".debug_types", eSectionTypeDWARFDebugTypes)
.Case(".eh_frame", eSectionTypeEHFrame)
.Case(".gnu_debugaltlink", eSectionTypeDWARFGNUDebugAltLink)
.Case(".gosymtab", eSectionTypeGoSymtab)
@@ -1798,14 +1731,7 @@ SectionType ObjectFileELF::GetSectionType(const ELFSectionHeaderInfo &H) const {
case SHT_DYNAMIC:
return eSectionTypeELFDynamicLinkInfo;
}
- SectionType Type = GetSectionTypeFromName(H.section_name.GetStringRef());
- if (Type == eSectionTypeOther) {
- // the kalimba toolchain assumes that ELF section names are free-form.
- // It does support linkscripts which (can) give rise to various
- // arbitrarily named sections being "Code" or "Data".
- Type = kalimbaSectionType(m_header, H);
- }
- return Type;
+ return GetSectionTypeFromName(H.section_name.GetStringRef());
}
static uint32_t GetTargetByteSize(SectionType Type, const ArchSpec &arch) {
@@ -1938,11 +1864,11 @@ public:
}
void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
- if (m_sections_ap)
+ if (m_sections_up)
return;
- m_sections_ap = llvm::make_unique<SectionList>();
- VMAddressProvider address_provider(CalculateType());
+ m_sections_up = llvm::make_unique<SectionList>();
+ VMAddressProvider address_provider(GetType());
size_t LoadID = 0;
for (const auto &EnumPHdr : llvm::enumerate(ProgramHeaders())) {
@@ -1961,7 +1887,7 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
eSectionTypeContainer, InfoOr->GetRangeBase(), InfoOr->GetByteSize(),
PHdr.p_offset, PHdr.p_filesz, Log2Align, /*flags*/ 0);
Segment->SetPermissions(GetPermissions(PHdr));
- m_sections_ap->AddSection(Segment);
+ m_sections_up->AddSection(Segment);
address_provider.AddSegment(*InfoOr, std::move(Segment));
}
@@ -2007,7 +1933,7 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
section_sp->SetPermissions(GetPermissions(header));
section_sp->SetIsThreadSpecific(header.sh_flags & SHF_TLS);
- (InfoOr->Segment ? InfoOr->Segment->GetChildren() : *m_sections_ap)
+ (InfoOr->Segment ? InfoOr->Segment->GetChildren() : *m_sections_up)
.AddSection(section_sp);
address_provider.AddSection(std::move(*InfoOr), std::move(section_sp));
}
@@ -2015,7 +1941,7 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
// For eTypeDebugInfo files, the Symbol Vendor will take care of updating the
// unified section list.
if (GetType() != eTypeDebugInfo)
- unified_section_list = *m_sections_ap;
+ unified_section_list = *m_sections_up;
}
// Find the arm/aarch64 mapping symbol character in the given symbol name.
@@ -2073,8 +1999,8 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
// custom extension and file name makes it highly unlikely that this will
// collide with anything else.
ConstString file_extension = m_file.GetFileNameExtension();
- bool skip_oatdata_oatexec = file_extension == ConstString(".oat") ||
- file_extension == ConstString(".odex");
+ bool skip_oatdata_oatexec =
+ file_extension == ".oat" || file_extension == ".odex";
ArchSpec arch = GetArchitecture();
ModuleSP module_sp(GetModule());
@@ -2166,7 +2092,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
if (symbol_type == eSymbolTypeInvalid && symbol.getType() != STT_SECTION) {
if (symbol_section_sp) {
- const ConstString &sect_name = symbol_section_sp->GetName();
+ ConstString sect_name = symbol_section_sp->GetName();
if (sect_name == text_section_name || sect_name == init_section_name ||
sect_name == fini_section_name || sect_name == ctors_section_name ||
sect_name == dtors_section_name) {
@@ -2262,11 +2188,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
* class
* accordingly.
*/
- const llvm::Triple::ArchType llvm_arch = arch.GetMachine();
- if (llvm_arch == llvm::Triple::mips ||
- llvm_arch == llvm::Triple::mipsel ||
- llvm_arch == llvm::Triple::mips64 ||
- llvm_arch == llvm::Triple::mips64el) {
+ if (arch.IsMIPS()) {
if (IS_MICROMIPS(symbol.st_other))
m_address_class_map[symbol.st_value] = AddressClass::eCodeAlternateISA;
else if ((symbol.st_value & 1) && (symbol_type == eSymbolTypeCode)) {
@@ -2310,7 +2232,7 @@ unsigned ObjectFileELF::ParseSymbols(Symtab *symtab, user_id_t start_id,
if (symbol_section_sp && module_section_list &&
module_section_list != section_list) {
- const ConstString &sect_name = symbol_section_sp->GetName();
+ ConstString sect_name = symbol_section_sp->GetName();
auto section_it = section_name_to_section.find(sect_name.GetCString());
if (section_it == section_name_to_section.end())
section_it =
@@ -2391,7 +2313,7 @@ unsigned ObjectFileELF::ParseSymbolTable(Symtab *symbol_table,
}
// Get section list for this object file.
- SectionList *section_list = m_sections_ap.get();
+ SectionList *section_list = m_sections_up.get();
if (!section_list)
return 0;
@@ -2457,7 +2379,7 @@ size_t ObjectFileELF::ParseDynamicSymbols() {
const ELFDynamic *ObjectFileELF::FindDynamicSymbol(unsigned tag) {
if (!ParseDynamicSymbols())
- return NULL;
+ return nullptr;
DynamicSymbolCollIter I = m_dynamic_symbols.begin();
DynamicSymbolCollIter E = m_dynamic_symbols.end();
@@ -2468,7 +2390,7 @@ const ELFDynamic *ObjectFileELF::FindDynamicSymbol(unsigned tag) {
return symbol;
}
- return NULL;
+ return nullptr;
}
unsigned ObjectFileELF::PLTRelocationType() {
@@ -2619,7 +2541,7 @@ ObjectFileELF::ParseTrampolineSymbols(Symtab *symbol_table, user_id_t start_id,
if (!sym_hdr)
return 0;
- SectionList *section_list = m_sections_ap.get();
+ SectionList *section_list = m_sections_up.get();
if (!section_list)
return 0;
@@ -2685,7 +2607,7 @@ unsigned ObjectFileELF::ApplyRelocations(
if (!rel.Parse(rel_data, &offset))
break;
- Symbol *symbol = NULL;
+ Symbol *symbol = nullptr;
if (hdr->Is32Bit()) {
switch (reloc_type(rel)) {
@@ -2804,7 +2726,7 @@ unsigned ObjectFileELF::RelocateDebugSections(const ELFSectionHeader *rel_hdr,
Symtab *ObjectFileELF::GetSymtab() {
ModuleSP module_sp(GetModule());
if (!module_sp)
- return NULL;
+ return nullptr;
// We always want to use the main object file so we (hopefully) only have one
// cached copy of our symtab, dynamic sections, etc.
@@ -2812,10 +2734,10 @@ Symtab *ObjectFileELF::GetSymtab() {
if (module_obj_file && module_obj_file != this)
return module_obj_file->GetSymtab();
- if (m_symtab_ap.get() == NULL) {
+ if (m_symtab_up == nullptr) {
SectionList *section_list = module_sp->GetSectionList();
if (!section_list)
- return NULL;
+ return nullptr;
uint64_t symbol_id = 0;
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
@@ -2836,8 +2758,8 @@ Symtab *ObjectFileELF::GetSymtab() {
.get();
}
if (symtab) {
- m_symtab_ap.reset(new Symtab(symtab->GetObjectFile()));
- symbol_id += ParseSymbolTable(m_symtab_ap.get(), symbol_id, symtab);
+ m_symtab_up.reset(new Symtab(symtab->GetObjectFile()));
+ symbol_id += ParseSymbolTable(m_symtab_up.get(), symbol_id, symtab);
}
// DT_JMPREL
@@ -2861,30 +2783,30 @@ Symtab *ObjectFileELF::GetSymtab() {
GetSectionHeaderByIndex(reloc_id);
assert(reloc_header);
- if (m_symtab_ap == nullptr)
- m_symtab_ap.reset(new Symtab(reloc_section->GetObjectFile()));
+ if (m_symtab_up == nullptr)
+ m_symtab_up.reset(new Symtab(reloc_section->GetObjectFile()));
- ParseTrampolineSymbols(m_symtab_ap.get(), symbol_id, reloc_header,
+ ParseTrampolineSymbols(m_symtab_up.get(), symbol_id, reloc_header,
reloc_id);
}
}
- DWARFCallFrameInfo *eh_frame = GetUnwindTable().GetEHFrameInfo();
- if (eh_frame) {
- if (m_symtab_ap == nullptr)
- m_symtab_ap.reset(new Symtab(this));
- ParseUnwindSymbols(m_symtab_ap.get(), eh_frame);
+ if (DWARFCallFrameInfo *eh_frame =
+ GetModule()->GetUnwindTable().GetEHFrameInfo()) {
+ if (m_symtab_up == nullptr)
+ m_symtab_up.reset(new Symtab(this));
+ ParseUnwindSymbols(m_symtab_up.get(), eh_frame);
}
// If we still don't have any symtab then create an empty instance to avoid
// do the section lookup next time.
- if (m_symtab_ap == nullptr)
- m_symtab_ap.reset(new Symtab(this));
+ if (m_symtab_up == nullptr)
+ m_symtab_up.reset(new Symtab(this));
- m_symtab_ap->CalculateSymbolSizes();
+ m_symtab_up->CalculateSymbolSizes();
}
- return m_symtab_ap.get();
+ return m_symtab_up.get();
}
void ObjectFileELF::RelocateSection(lldb_private::Section *section)
@@ -2991,7 +2913,6 @@ bool ObjectFileELF::IsStripped() {
//
// Dump the specifics of the runtime file container (such as any headers
// segments, sections, etc).
-//----------------------------------------------------------------------
void ObjectFileELF::Dump(Stream *s) {
ModuleSP module_sp(GetModule());
if (!module_sp) {
@@ -3016,20 +2937,18 @@ void ObjectFileELF::Dump(Stream *s) {
s->EOL();
SectionList *section_list = GetSectionList();
if (section_list)
- section_list->Dump(s, NULL, true, UINT32_MAX);
+ section_list->Dump(s, nullptr, true, UINT32_MAX);
Symtab *symtab = GetSymtab();
if (symtab)
- symtab->Dump(s, NULL, eSortOrderNone);
+ symtab->Dump(s, nullptr, eSortOrderNone);
s->EOL();
DumpDependentModules(s);
s->EOL();
}
-//----------------------------------------------------------------------
// DumpELFHeader
//
// Dump the ELF header to the specified output stream
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFHeader(Stream *s, const ELFHeader &header) {
s->PutCString("ELF Header\n");
s->Printf("e_ident[EI_MAG0 ] = 0x%2.2x\n", header.e_ident[EI_MAG0]);
@@ -3062,11 +2981,9 @@ void ObjectFileELF::DumpELFHeader(Stream *s, const ELFHeader &header) {
s->Printf("e_shstrndx = 0x%8.8x\n", header.e_shstrndx);
}
-//----------------------------------------------------------------------
// DumpELFHeader_e_type
//
// Dump an token value for the ELF header member e_type
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFHeader_e_type(Stream *s, elf_half e_type) {
switch (e_type) {
case ET_NONE:
@@ -3089,11 +3006,9 @@ void ObjectFileELF::DumpELFHeader_e_type(Stream *s, elf_half e_type) {
}
}
-//----------------------------------------------------------------------
// DumpELFHeader_e_ident_EI_DATA
//
// Dump an token value for the ELF header member e_ident[EI_DATA]
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFHeader_e_ident_EI_DATA(Stream *s,
unsigned char ei_data) {
switch (ei_data) {
@@ -3111,11 +3026,9 @@ void ObjectFileELF::DumpELFHeader_e_ident_EI_DATA(Stream *s,
}
}
-//----------------------------------------------------------------------
// DumpELFProgramHeader
//
// Dump a single ELF program header to the specified output stream
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFProgramHeader(Stream *s,
const ELFProgramHeader &ph) {
DumpELFProgramHeader_p_type(s, ph.p_type);
@@ -3128,12 +3041,10 @@ void ObjectFileELF::DumpELFProgramHeader(Stream *s,
s->Printf(") %8.8" PRIx64, ph.p_align);
}
-//----------------------------------------------------------------------
// DumpELFProgramHeader_p_type
//
// Dump an token value for the ELF program header member p_type which describes
// the type of the program header
-// ----------------------------------------------------------------------
void ObjectFileELF::DumpELFProgramHeader_p_type(Stream *s, elf_word p_type) {
const int kStrWidth = 15;
switch (p_type) {
@@ -3152,11 +3063,9 @@ void ObjectFileELF::DumpELFProgramHeader_p_type(Stream *s, elf_word p_type) {
}
}
-//----------------------------------------------------------------------
// DumpELFProgramHeader_p_flags
//
// Dump an token value for the ELF program header member p_flags
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFProgramHeader_p_flags(Stream *s, elf_word p_flags) {
*s << ((p_flags & PF_X) ? "PF_X" : " ")
<< (((p_flags & PF_X) && (p_flags & PF_W)) ? '+' : ' ')
@@ -3165,11 +3074,9 @@ void ObjectFileELF::DumpELFProgramHeader_p_flags(Stream *s, elf_word p_flags) {
<< ((p_flags & PF_R) ? "PF_R" : " ");
}
-//----------------------------------------------------------------------
// DumpELFProgramHeaders
//
// Dump all of the ELF program header to the specified output stream
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFProgramHeaders(Stream *s) {
if (!ParseProgramHeaders())
return;
@@ -3187,11 +3094,9 @@ void ObjectFileELF::DumpELFProgramHeaders(Stream *s) {
}
}
-//----------------------------------------------------------------------
// DumpELFSectionHeader
//
// Dump a single ELF section header to the specified output stream
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFSectionHeader(Stream *s,
const ELFSectionHeaderInfo &sh) {
s->Printf("%8.8x ", sh.sh_name);
@@ -3204,12 +3109,10 @@ void ObjectFileELF::DumpELFSectionHeader(Stream *s,
s->Printf(" %8.8" PRIx64 " %8.8" PRIx64, sh.sh_addralign, sh.sh_entsize);
}
-//----------------------------------------------------------------------
// DumpELFSectionHeader_sh_type
//
// Dump an token value for the ELF section header member sh_type which
// describes the type of the section
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFSectionHeader_sh_type(Stream *s, elf_word sh_type) {
const int kStrWidth = 12;
switch (sh_type) {
@@ -3235,11 +3138,9 @@ void ObjectFileELF::DumpELFSectionHeader_sh_type(Stream *s, elf_word sh_type) {
}
}
-//----------------------------------------------------------------------
// DumpELFSectionHeader_sh_flags
//
// Dump an token value for the ELF section header member sh_flags
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFSectionHeader_sh_flags(Stream *s,
elf_xword sh_flags) {
*s << ((sh_flags & SHF_WRITE) ? "WRITE" : " ")
@@ -3249,11 +3150,9 @@ void ObjectFileELF::DumpELFSectionHeader_sh_flags(Stream *s,
<< ((sh_flags & SHF_EXECINSTR) ? "EXECINSTR" : " ");
}
-//----------------------------------------------------------------------
// DumpELFSectionHeaders
//
// Dump all of the ELF section header to the specified output stream
-//----------------------------------------------------------------------
void ObjectFileELF::DumpELFSectionHeaders(Stream *s) {
if (!ParseSectionHeaders())
return;
@@ -3283,7 +3182,7 @@ void ObjectFileELF::DumpDependentModules(lldb_private::Stream *s) {
if (num_modules > 0) {
s->PutCString("Dependent Modules:\n");
for (unsigned i = 0; i < num_modules; ++i) {
- const FileSpec &spec = m_filespec_ap->GetFileSpecAtIndex(i);
+ const FileSpec &spec = m_filespec_up->GetFileSpecAtIndex(i);
s->Printf(" %s\n", spec.GetFilename().GetCString());
}
}
@@ -3299,7 +3198,7 @@ ArchSpec ObjectFileELF::GetArchitecture() {
}
if (CalculateType() == eTypeCoreFile &&
- m_arch_spec.TripleOSIsUnspecifiedUnknown()) {
+ !m_arch_spec.TripleOSWasSpecified()) {
// Core files don't have section headers yet they have PT_NOTE program
// headers that might shed more light on the architecture
for (const elf::ELFProgramHeader &H : ProgramHeaders()) {
@@ -3405,7 +3304,8 @@ size_t ObjectFileELF::ReadSectionData(Section *section,
return section->GetObjectFile()->ReadSectionData(section, section_data);
size_t result = ObjectFile::ReadSectionData(section, section_data);
- if (result == 0 || !section->Test(SHF_COMPRESSED))
+ if (result == 0 || !llvm::object::Decompressor::isCompressedELFSection(
+ section->Get(), section->GetName().GetStringRef()))
return result;
auto Decompressor = llvm::object::Decompressor::create(
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
index 08fd5bdc60a97..b63a5d14d4f5d 100644
--- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
+++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
@@ -1,9 +1,8 @@
//===-- ObjectFileELF.h --------------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,14 +33,14 @@ struct ELFNote {
/// Parse an ELFNote entry from the given DataExtractor starting at position
/// \p offset.
///
- /// @param[in] data
+ /// \param[in] data
/// The DataExtractor to read from.
///
- /// @param[in,out] offset
+ /// \param[in,out] offset
/// Pointer to an offset in the data. On return the offset will be
/// advanced by the number of bytes read.
///
- /// @return
+ /// \return
/// True if the ELFRel entry was successfully read and false otherwise.
bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
@@ -50,8 +49,7 @@ struct ELFNote {
}
};
-//------------------------------------------------------------------------------
-/// @class ObjectFileELF
+/// \class ObjectFileELF
/// Generic ELF object file reader.
///
/// This class provides a generic ELF (32/64 bit) reader plugin implementing
@@ -60,9 +58,7 @@ class ObjectFileELF : public lldb_private::ObjectFile {
public:
~ObjectFileELF() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -90,16 +86,12 @@ public:
static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
lldb::addr_t length);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
// ObjectFile Protocol.
- //------------------------------------------------------------------
bool ParseHeader() override;
bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
@@ -123,7 +115,7 @@ public:
lldb_private::ArchSpec GetArchitecture() override;
- bool GetUUID(lldb_private::UUID *uuid) override;
+ lldb_private::UUID GetUUID() override;
lldb_private::FileSpecList GetDebugSymbolFilePaths() override;
@@ -211,7 +203,7 @@ private:
/// List of file specifications corresponding to the modules (shared
/// libraries) on which this object file depends.
- mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_ap;
+ mutable std::unique_ptr<lldb_private::FileSpecList> m_filespec_up;
/// Cached value of the entry point for this module.
lldb_private::Address m_entry_point_address;
@@ -265,7 +257,7 @@ private:
lldb_private::ArchSpec &arch_spec);
/// Scans the dynamic section and locates all dependent modules (shared
- /// libraries) populating m_filespec_ap. This method will compute the
+ /// libraries) populating m_filespec_up. This method will compute the
/// dependent module list only once. Returns the number of dependent
/// modules parsed.
size_t ParseDependentModules();
@@ -275,7 +267,7 @@ private:
/// number of dynamic symbols parsed.
size_t ParseDynamicSymbols();
- /// Populates m_symtab_ap will all non-dynamic linker symbols. This method
+ /// Populates m_symtab_up will all non-dynamic linker symbols. This method
/// will parse the symbols only once. Returns the number of symbols parsed.
unsigned ParseSymbolTable(lldb_private::Symtab *symbol_table,
lldb::user_id_t start_id,
@@ -331,7 +323,7 @@ private:
/// Returns the section header with the given id or NULL.
const ELFSectionHeaderInfo *GetSectionHeaderByIndex(lldb::user_id_t id);
- /// @name ELF header dump routines
+ /// \name ELF header dump routines
//@{
static void DumpELFHeader(lldb_private::Stream *s,
const elf::ELFHeader &header);
@@ -343,7 +335,7 @@ private:
elf::elf_half e_type);
//@}
- /// @name ELF program header dump routines
+ /// \name ELF program header dump routines
//@{
void DumpELFProgramHeaders(lldb_private::Stream *s);
@@ -357,7 +349,7 @@ private:
elf::elf_word p_flags);
//@}
- /// @name ELF section header dump routines
+ /// \name ELF section header dump routines
//@{
void DumpELFSectionHeaders(lldb_private::Stream *s);
diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
index cfe61992be0d2..eaf973da38355 100644
--- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
+++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
@@ -1,9 +1,8 @@
//===-- ObjectFileJIT.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Host/Host.h"
@@ -29,6 +27,7 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
#include "lldb/Utility/UUID.h"
@@ -67,7 +66,7 @@ ObjectFile *ObjectFileJIT::CreateInstance(const lldb::ModuleSP &module_sp,
lldb::offset_t length) {
// JIT'ed object file is backed by the ObjectFileJITDelegate, never read from
// a file
- return NULL;
+ return nullptr;
}
ObjectFile *ObjectFileJIT::CreateMemoryInstance(const lldb::ModuleSP &module_sp,
@@ -76,7 +75,7 @@ ObjectFile *ObjectFileJIT::CreateMemoryInstance(const lldb::ModuleSP &module_sp,
lldb::addr_t header_addr) {
// JIT'ed object file is backed by the ObjectFileJITDelegate, never read from
// memory
- return NULL;
+ return nullptr;
}
size_t ObjectFileJIT::GetModuleSpecifications(
@@ -89,7 +88,7 @@ size_t ObjectFileJIT::GetModuleSpecifications(
ObjectFileJIT::ObjectFileJIT(const lldb::ModuleSP &module_sp,
const ObjectFileJITDelegateSP &delegate_sp)
- : ObjectFile(module_sp, NULL, 0, 0, DataBufferSP(), 0), m_delegate_wp() {
+ : ObjectFile(module_sp, nullptr, 0, 0, DataBufferSP(), 0), m_delegate_wp() {
if (delegate_sp) {
m_delegate_wp = delegate_sp;
m_data.SetByteOrder(delegate_sp->GetByteOrder());
@@ -116,18 +115,18 @@ Symtab *ObjectFileJIT::GetSymtab() {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_symtab_ap.get() == NULL) {
- m_symtab_ap.reset(new Symtab(this));
+ if (m_symtab_up == nullptr) {
+ m_symtab_up.reset(new Symtab(this));
std::lock_guard<std::recursive_mutex> symtab_guard(
- m_symtab_ap->GetMutex());
+ m_symtab_up->GetMutex());
ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
if (delegate_sp)
- delegate_sp->PopulateSymtab(this, *m_symtab_ap);
+ delegate_sp->PopulateSymtab(this, *m_symtab_up);
// TODO: get symbols from delegate
- m_symtab_ap->Finalize();
+ m_symtab_up->Finalize();
}
}
- return m_symtab_ap.get();
+ return m_symtab_up.get();
}
bool ObjectFileJIT::IsStripped() {
@@ -135,12 +134,12 @@ bool ObjectFileJIT::IsStripped() {
}
void ObjectFileJIT::CreateSections(SectionList &unified_section_list) {
- if (!m_sections_ap.get()) {
- m_sections_ap.reset(new SectionList());
+ if (!m_sections_up) {
+ m_sections_up.reset(new SectionList());
ObjectFileJITDelegateSP delegate_sp(m_delegate_wp.lock());
if (delegate_sp) {
- delegate_sp->PopulateSectionList(this, *m_sections_ap);
- unified_section_list = *m_sections_ap;
+ delegate_sp->PopulateSectionList(this, *m_sections_up);
+ unified_section_list = *m_sections_up;
}
}
}
@@ -160,16 +159,16 @@ void ObjectFileJIT::Dump(Stream *s) {
SectionList *sections = GetSectionList();
if (sections)
- sections->Dump(s, NULL, true, UINT32_MAX);
+ sections->Dump(s, nullptr, true, UINT32_MAX);
- if (m_symtab_ap.get())
- m_symtab_ap->Dump(s, NULL, eSortOrderNone);
+ if (m_symtab_up)
+ m_symtab_up->Dump(s, nullptr, eSortOrderNone);
}
}
-bool ObjectFileJIT::GetUUID(lldb_private::UUID *uuid) {
+UUID ObjectFileJIT::GetUUID() {
// TODO: maybe get from delegate, not needed for first pass
- return false;
+ return UUID();
}
uint32_t ObjectFileJIT::GetDependentModules(FileSpecList &files) {
@@ -195,9 +194,7 @@ ArchSpec ObjectFileJIT::GetArchitecture() {
return ArchSpec();
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString ObjectFileJIT::GetPluginName() {
return GetPluginNameStatic();
}
@@ -249,14 +246,12 @@ size_t ObjectFileJIT::ReadSectionData(
if (section->GetFileSize()) {
const void *src = (void *)(uintptr_t)section->GetFileOffset();
- DataBufferSP data_sp(
- new lldb_private::DataBufferHeap(src, section->GetFileSize()));
- if (data_sp) {
- section_data.SetData(data_sp, 0, data_sp->GetByteSize());
- section_data.SetByteOrder(GetByteOrder());
- section_data.SetAddressByteSize(GetAddressByteSize());
- return section_data.GetByteSize();
- }
+ DataBufferSP data_sp =
+ std::make_shared<DataBufferHeap>(src, section->GetFileSize());
+ section_data.SetData(data_sp, 0, data_sp->GetByteSize());
+ section_data.SetByteOrder(GetByteOrder());
+ section_data.SetAddressByteSize(GetAddressByteSize());
+ return section_data.GetByteSize();
}
section_data.Clear();
return 0;
diff --git a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
index 3d9e4748d3df3..99241126cd1a6 100644
--- a/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
+++ b/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
@@ -1,9 +1,8 @@
//===-- ObjectFileJIT.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,10 +12,8 @@
#include "lldb/Core/Address.h"
#include "lldb/Symbol/ObjectFile.h"
-//----------------------------------------------------------------------
// This class needs to be hidden as eventually belongs in a plugin that
// will export the ObjectFile protocol
-//----------------------------------------------------------------------
class ObjectFileJIT : public lldb_private::ObjectFile {
public:
ObjectFileJIT(const lldb::ModuleSP &module_sp,
@@ -24,9 +21,7 @@ public:
~ObjectFileJIT() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -51,9 +46,7 @@ public:
lldb::offset_t length,
lldb_private::ModuleSpecList &specs);
- //------------------------------------------------------------------
// Member Functions
- //------------------------------------------------------------------
bool ParseHeader() override;
bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
@@ -75,7 +68,7 @@ public:
lldb_private::ArchSpec GetArchitecture() override;
- bool GetUUID(lldb_private::UUID *uuid) override;
+ lldb_private::UUID GetUUID() override;
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
@@ -95,9 +88,7 @@ public:
ObjectFile::Strata CalculateStrata() override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index 89a0f22539365..c1fe0cc8dddaf 100644
--- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -1,15 +1,15 @@
//===-- OperatingSystemPython.cpp --------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_DISABLE_PYTHON
#include "OperatingSystemPython.h"
+
#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
#include "Plugins/Process/Utility/RegisterContextDummy.h"
#include "Plugins/Process/Utility/RegisterContextMemory.h"
@@ -32,6 +32,8 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -52,12 +54,12 @@ OperatingSystem *OperatingSystemPython::CreateInstance(Process *process,
FileSpec python_os_plugin_spec(process->GetPythonOSPluginPath());
if (python_os_plugin_spec &&
FileSystem::Instance().Exists(python_os_plugin_spec)) {
- std::unique_ptr<OperatingSystemPython> os_ap(
+ std::unique_ptr<OperatingSystemPython> os_up(
new OperatingSystemPython(process, python_os_plugin_spec));
- if (os_ap.get() && os_ap->IsValid())
- return os_ap.release();
+ if (os_up.get() && os_up->IsValid())
+ return os_up.release();
}
- return NULL;
+ return nullptr;
}
ConstString OperatingSystemPython::GetPluginNameStatic() {
@@ -72,15 +74,14 @@ const char *OperatingSystemPython::GetPluginDescriptionStatic() {
OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process,
const FileSpec &python_module_path)
- : OperatingSystem(process), m_thread_list_valobj_sp(), m_register_info_ap(),
- m_interpreter(NULL), m_python_object_sp() {
+ : OperatingSystem(process), m_thread_list_valobj_sp(), m_register_info_up(),
+ m_interpreter(nullptr), m_python_object_sp() {
if (!process)
return;
TargetSP target_sp = process->CalculateTarget();
if (!target_sp)
return;
- m_interpreter =
- target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ m_interpreter = target_sp->GetDebugger().GetScriptInterpreter();
if (m_interpreter) {
std::string os_plugin_class_name(
@@ -114,9 +115,9 @@ OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process,
OperatingSystemPython::~OperatingSystemPython() {}
DynamicRegisterInfo *OperatingSystemPython::GetDynamicRegisterInfo() {
- if (m_register_info_ap.get() == NULL) {
+ if (m_register_info_up == nullptr) {
if (!m_interpreter || !m_python_object_sp)
- return NULL;
+ return nullptr;
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS));
if (log)
@@ -127,19 +128,17 @@ DynamicRegisterInfo *OperatingSystemPython::GetDynamicRegisterInfo() {
StructuredData::DictionarySP dictionary =
m_interpreter->OSPlugin_RegisterInfo(m_python_object_sp);
if (!dictionary)
- return NULL;
+ return nullptr;
- m_register_info_ap.reset(new DynamicRegisterInfo(
+ m_register_info_up.reset(new DynamicRegisterInfo(
*dictionary, m_process->GetTarget().GetArchitecture()));
- assert(m_register_info_ap->GetNumRegisters() > 0);
- assert(m_register_info_ap->GetNumRegisterSets() > 0);
+ assert(m_register_info_up->GetNumRegisters() > 0);
+ assert(m_register_info_up->GetNumRegisterSets() > 0);
}
- return m_register_info_ap.get();
+ return m_register_info_up.get();
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString OperatingSystemPython::GetPluginName() {
return GetPluginNameStatic();
}
@@ -199,9 +198,9 @@ bool OperatingSystemPython::UpdateThreadList(ThreadList &old_thread_list,
StructuredData::ObjectSP thread_dict_obj =
threads_list->GetItemAtIndex(i);
if (auto thread_dict = thread_dict_obj->GetAsDictionary()) {
- ThreadSP thread_sp(
- CreateThreadFromThreadInfo(*thread_dict, core_thread_list,
- old_thread_list, core_used_map, NULL));
+ ThreadSP thread_sp(CreateThreadFromThreadInfo(
+ *thread_dict, core_thread_list, old_thread_list, core_used_map,
+ nullptr));
if (thread_sp)
new_thread_list.AddThread(thread_sp);
}
@@ -260,8 +259,8 @@ ThreadSP OperatingSystemPython::CreateThreadFromThreadInfo(
if (!thread_sp) {
if (did_create_ptr)
*did_create_ptr = true;
- thread_sp.reset(
- new ThreadMemory(*m_process, tid, name, queue, reg_data_addr));
+ thread_sp = std::make_shared<ThreadMemory>(*m_process, tid, name, queue,
+ reg_data_addr);
}
if (core_number < core_thread_list.GetSize(false)) {
@@ -322,8 +321,8 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread,
"= 0x%" PRIx64 ", 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64
") creating memory register context",
thread->GetID(), thread->GetProtocolID(), reg_data_addr);
- reg_ctx_sp.reset(new RegisterContextMemory(
- *thread, 0, *GetDynamicRegisterInfo(), reg_data_addr));
+ reg_ctx_sp = std::make_shared<RegisterContextMemory>(
+ *thread, 0, *GetDynamicRegisterInfo(), reg_data_addr);
} else {
// No register data address is provided, query the python plug-in to let it
// make up the data as it sees fit
@@ -356,8 +355,8 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread,
log->Printf("OperatingSystemPython::CreateRegisterContextForThread (tid "
"= 0x%" PRIx64 ") forcing a dummy register context",
thread->GetID());
- reg_ctx_sp.reset(new RegisterContextDummy(
- *thread, 0, target.GetArchitecture().GetAddressByteSize()));
+ reg_ctx_sp = std::make_shared<RegisterContextDummy>(
+ *thread, 0, target.GetArchitecture().GetAddressByteSize());
}
return reg_ctx_sp;
}
diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
index c812464fa7470..e76227ddb981a 100644
--- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
+++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
@@ -1,9 +1,8 @@
//===-- OperatingSystemPython.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,9 +27,7 @@ public:
~OperatingSystemPython() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static lldb_private::OperatingSystem *
CreateInstance(lldb_private::Process *process, bool force);
@@ -42,16 +39,12 @@ public:
static const char *GetPluginDescriptionStatic();
- //------------------------------------------------------------------
// lldb_private::PluginInterface Methods
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
// lldb_private::OperatingSystem Methods
- //------------------------------------------------------------------
bool UpdateThreadList(lldb_private::ThreadList &old_thread_list,
lldb_private::ThreadList &real_thread_list,
lldb_private::ThreadList &new_thread_list) override;
@@ -65,9 +58,7 @@ public:
lldb::StopInfoSP
CreateThreadStopReason(lldb_private::Thread *thread) override;
- //------------------------------------------------------------------
// Method for lazy creation of threads on demand
- //------------------------------------------------------------------
lldb::ThreadSP CreateThread(lldb::tid_t tid, lldb::addr_t context) override;
protected:
@@ -84,7 +75,7 @@ protected:
DynamicRegisterInfo *GetDynamicRegisterInfo();
lldb::ValueObjectSP m_thread_list_valobj_sp;
- std::unique_ptr<DynamicRegisterInfo> m_register_info_ap;
+ std::unique_ptr<DynamicRegisterInfo> m_register_info_up;
lldb_private::ScriptInterpreter *m_interpreter;
lldb_private::StructuredData::ObjectSP m_python_object_sp;
};
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index 59cce3a6bc2b3..946f0ea3a5cfe 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -1,9 +1,8 @@
//===-- PlatformFreeBSD.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,7 +38,6 @@ using namespace lldb_private::platform_freebsd;
static uint32_t g_initialize_count = 0;
-//------------------------------------------------------------------
PlatformSP PlatformFreeBSD::CreateInstance(bool force, const ArchSpec *arch) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
@@ -120,9 +118,7 @@ void PlatformFreeBSD::Terminate() {
PlatformPOSIX::Terminate();
}
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
PlatformFreeBSD::PlatformFreeBSD(bool is_host)
: PlatformPOSIX(is_host) // This is the local host platform
{}
@@ -266,7 +262,7 @@ lldb::ProcessSP PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info,
Status &error) {
lldb::ProcessSP process_sp;
if (IsHost()) {
- if (target == NULL) {
+ if (target == nullptr) {
TargetSP new_target_sp;
ArchSpec emptyArchSpec;
@@ -283,7 +279,7 @@ lldb::ProcessSP PlatformFreeBSD::Attach(ProcessAttachInfo &attach_info,
// even when debugging locally we are debugging remotely! Just like the
// darwin plugin.
process_sp = target->CreateProcess(
- attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+ attach_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
if (process_sp)
error = process_sp->Attach(attach_info);
diff --git a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index 274304834290b..e3a3aa7145f0b 100644
--- a/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -1,9 +1,8 @@
//===-- PlatformFreeBSD.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ public:
static void Terminate();
- //------------------------------------------------------------
// lldb_private::PluginInterface functions
- //------------------------------------------------------------
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
static ConstString GetPluginNameStatic(bool is_host);
@@ -38,9 +35,7 @@ public:
uint32_t GetPluginVersion() override { return 1; }
- //------------------------------------------------------------
// lldb_private::Platform functions
- //------------------------------------------------------------
const char *GetDescription() override {
return GetPluginDescriptionStatic(IsHost());
}
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index aadcf961c729a..63245d18fc5c3 100644
--- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -1,9 +1,8 @@
//===-- PlatformNetBSD.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,7 +36,6 @@ using namespace lldb_private::platform_netbsd;
static uint32_t g_initialize_count = 0;
-//------------------------------------------------------------------
PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
@@ -112,9 +110,7 @@ void PlatformNetBSD::Terminate() {
PlatformPOSIX::Terminate();
}
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
PlatformNetBSD::PlatformNetBSD(bool is_host)
: PlatformPOSIX(is_host) // This is the local host platform
{}
@@ -210,7 +206,7 @@ PlatformNetBSD::GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) {
// Figure out what shell we're planning on using.
const char *shell_name = strrchr(shell_string.c_str(), '/');
- if (shell_name == NULL)
+ if (shell_name == nullptr)
shell_name = shell_string.c_str();
else
shell_name++;
@@ -326,7 +322,7 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger,
// Handle the hijacking of process events.
if (listener_sp) {
const StateType state = process_sp->WaitForProcessToStop(
- llvm::None, NULL, false, listener_sp);
+ llvm::None, nullptr, false, listener_sp);
LLDB_LOG(log, "pid {0} state {0}", process_sp->GetID(), state);
}
diff --git a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
index 28a5d6713dd95..0584d92d6c99a 100644
--- a/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ b/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -1,9 +1,8 @@
//===-- PlatformNetBSD.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ public:
static void Terminate();
- //------------------------------------------------------------
// lldb_private::PluginInterface functions
- //------------------------------------------------------------
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
static ConstString GetPluginNameStatic(bool is_host);
@@ -38,9 +35,7 @@ public:
uint32_t GetPluginVersion() override { return 1; }
- //------------------------------------------------------------
// lldb_private::Platform functions
- //------------------------------------------------------------
const char *GetDescription() override {
return GetPluginDescriptionStatic(IsHost());
}
diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
index 7358acb61f79a..9dfb8844c574b 100644
--- a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
+++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
@@ -1,9 +1,8 @@
//===-- PlatformOpenBSD.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,7 +36,6 @@ using namespace lldb_private::platform_openbsd;
static uint32_t g_initialize_count = 0;
-//------------------------------------------------------------------
PlatformSP PlatformOpenBSD::CreateInstance(bool force, const ArchSpec *arch) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
@@ -118,9 +116,7 @@ void PlatformOpenBSD::Terminate() {
PlatformPOSIX::Terminate();
}
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
PlatformOpenBSD::PlatformOpenBSD(bool is_host)
: PlatformPOSIX(is_host) // This is the local host platform
{}
diff --git a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
index cb5e9bfe63926..3cb724f303251 100644
--- a/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
+++ b/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
@@ -1,9 +1,8 @@
//===-- PlatformOpenBSD.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ public:
static void Terminate();
- //------------------------------------------------------------
// lldb_private::PluginInterface functions
- //------------------------------------------------------------
static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch);
static ConstString GetPluginNameStatic(bool is_host);
@@ -38,9 +35,7 @@ public:
uint32_t GetPluginVersion() override { return 1; }
- //------------------------------------------------------------
// lldb_private::Platform functions
- //------------------------------------------------------------
const char *GetDescription() override {
return GetPluginDescriptionStatic(IsHost());
}
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index bfa1376d3151a..d10557596ff80 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -1,15 +1,13 @@
//===-- PlatformPOSIX.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "PlatformPOSIX.h"
-
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
@@ -23,11 +21,11 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
-#include "lldb/Target/ProcessLaunchInfo.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/CleanUp.h"
#include "lldb/Utility/DataBufferHeap.h"
@@ -38,34 +36,19 @@
using namespace lldb;
using namespace lldb_private;
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
PlatformPOSIX::PlatformPOSIX(bool is_host)
- : Platform(is_host), // This is the local host platform
+ : RemoteAwarePlatform(is_host), // This is the local host platform
m_option_group_platform_rsync(new OptionGroupPlatformRSync()),
m_option_group_platform_ssh(new OptionGroupPlatformSSH()),
- m_option_group_platform_caching(new OptionGroupPlatformCaching()),
- m_remote_platform_sp() {}
+ m_option_group_platform_caching(new OptionGroupPlatformCaching()) {}
-//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
PlatformPOSIX::~PlatformPOSIX() {}
-bool PlatformPOSIX::GetModuleSpec(const FileSpec &module_file_spec,
- const ArchSpec &arch,
- ModuleSpec &module_spec) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
- module_spec);
-
- return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
-}
-
lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
lldb_private::CommandInterpreter &interpreter) {
auto iter = m_options.find(&interpreter), end = m_options.end();
@@ -81,36 +64,6 @@ lldb_private::OptionGroupOptions *PlatformPOSIX::GetConnectionOptions(
return m_options.at(&interpreter).get();
}
-bool PlatformPOSIX::IsConnected() const {
- if (IsHost())
- return true;
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->IsConnected();
- return false;
-}
-
-lldb_private::Status PlatformPOSIX::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
- const Timeout<std::micro> &timeout) {
- if (IsHost())
- return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
- command_output, timeout);
- else {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->RunShellCommand(
- command, working_dir, status_ptr, signo_ptr, command_output, timeout);
- else
- return Status("unable to run a remote command without a platform");
- }
-}
-
Status
PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
lldb::ModuleSP &exe_module_sp,
@@ -253,105 +206,6 @@ PlatformPOSIX::ResolveExecutable(const ModuleSpec &module_spec,
return error;
}
-Status PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file,
- const UUID *uuid_ptr,
- FileSpec &local_file) {
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
- local_file);
-
- // Default to the local case
- local_file = platform_file;
- return Status();
-}
-
-bool PlatformPOSIX::GetProcessInfo(lldb::pid_t pid,
- ProcessInstanceInfo &process_info) {
- if (IsHost())
- return Platform::GetProcessInfo(pid, process_info);
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetProcessInfo(pid, process_info);
- return false;
-}
-
-uint32_t
-PlatformPOSIX::FindProcesses(const ProcessInstanceInfoMatch &match_info,
- ProcessInstanceInfoList &process_infos) {
- if (IsHost())
- return Platform::FindProcesses(match_info, process_infos);
- if (m_remote_platform_sp)
- return
- m_remote_platform_sp->FindProcesses(match_info, process_infos);
- return 0;
-}
-
-Status PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
- uint32_t file_permissions) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
- else
- return Platform::MakeDirectory(file_spec, file_permissions);
-}
-
-Status PlatformPOSIX::GetFilePermissions(const FileSpec &file_spec,
- uint32_t &file_permissions) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFilePermissions(file_spec,
- file_permissions);
- else
- return Platform::GetFilePermissions(file_spec, file_permissions);
-}
-
-Status PlatformPOSIX::SetFilePermissions(const FileSpec &file_spec,
- uint32_t file_permissions) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->SetFilePermissions(file_spec,
- file_permissions);
- else
- return Platform::SetFilePermissions(file_spec, file_permissions);
-}
-
-lldb::user_id_t PlatformPOSIX::OpenFile(const FileSpec &file_spec,
- uint32_t flags, uint32_t mode,
- Status &error) {
- if (IsHost())
- return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
- else
- return Platform::OpenFile(file_spec, flags, mode, error);
-}
-
-bool PlatformPOSIX::CloseFile(lldb::user_id_t fd, Status &error) {
- if (IsHost())
- return FileCache::GetInstance().CloseFile(fd, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->CloseFile(fd, error);
- else
- return Platform::CloseFile(fd, error);
-}
-
-uint64_t PlatformPOSIX::ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
- uint64_t dst_len, Status &error) {
- if (IsHost())
- return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
- else
- return Platform::ReadFile(fd, offset, dst, dst_len, error);
-}
-
-uint64_t PlatformPOSIX::WriteFile(lldb::user_id_t fd, uint64_t offset,
- const void *src, uint64_t src_len,
- Status &error) {
- if (IsHost())
- return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
- else
- return Platform::WriteFile(fd, offset, src, src_len, error);
-}
-
static uint32_t chown_file(Platform *platform, const char *path,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) {
@@ -369,8 +223,8 @@ static uint32_t chown_file(Platform *platform, const char *path,
command.Printf(":%d", gid);
command.Printf("%s", path);
int status;
- platform->RunShellCommand(command.GetData(), NULL, &status, NULL, NULL,
- std::chrono::seconds(10));
+ platform->RunShellCommand(command.GetData(), nullptr, &status, nullptr,
+ nullptr, std::chrono::seconds(10));
return status;
}
@@ -394,7 +248,7 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
StreamString command;
command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
- RunShellCommand(command.GetData(), NULL, &status, NULL, NULL,
+ RunShellCommand(command.GetData(), nullptr, &status, nullptr, nullptr,
std::chrono::seconds(10));
if (status != 0)
return Status("unable to perform copy");
@@ -425,8 +279,8 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
if (log)
log->Printf("[PutFile] Running command: %s\n", command.GetData());
int retcode;
- Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL,
- std::chrono::minutes(1));
+ Host::RunShellCommand(command.GetData(), nullptr, &retcode, nullptr,
+ nullptr, std::chrono::minutes(1));
if (retcode == 0) {
// Don't chown a local file for a remote system
// if (chown_file(this,dst_path.c_str(),uid,gid) != 0)
@@ -440,45 +294,6 @@ PlatformPOSIX::PutFile(const lldb_private::FileSpec &source,
return Platform::PutFile(source, destination, uid, gid);
}
-lldb::user_id_t PlatformPOSIX::GetFileSize(const FileSpec &file_spec) {
- if (IsHost()) {
- uint64_t Size;
- if (llvm::sys::fs::file_size(file_spec.GetPath(), Size))
- return 0;
- return Size;
- } else if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileSize(file_spec);
- else
- return Platform::GetFileSize(file_spec);
-}
-
-Status PlatformPOSIX::CreateSymlink(const FileSpec &src, const FileSpec &dst) {
- if (IsHost())
- return FileSystem::Instance().Symlink(src, dst);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->CreateSymlink(src, dst);
- else
- return Platform::CreateSymlink(src, dst);
-}
-
-bool PlatformPOSIX::GetFileExists(const FileSpec &file_spec) {
- if (IsHost())
- return FileSystem::Instance().Exists(file_spec);
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->GetFileExists(file_spec);
- else
- return Platform::GetFileExists(file_spec);
-}
-
-Status PlatformPOSIX::Unlink(const FileSpec &file_spec) {
- if (IsHost())
- return llvm::sys::fs::remove(file_spec.GetPath());
- else if (m_remote_platform_sp)
- return m_remote_platform_sp->Unlink(file_spec);
- else
- return Platform::Unlink(file_spec);
-}
-
lldb_private::Status PlatformPOSIX::GetFile(
const lldb_private::FileSpec &source, // remote file path
const lldb_private::FileSpec &destination) // local file path
@@ -500,7 +315,7 @@ lldb_private::Status PlatformPOSIX::GetFile(
StreamString cp_command;
cp_command.Printf("cp %s %s", src_path.c_str(), dst_path.c_str());
int status;
- RunShellCommand(cp_command.GetData(), NULL, &status, NULL, NULL,
+ RunShellCommand(cp_command.GetData(), nullptr, &status, nullptr, nullptr,
std::chrono::seconds(10));
if (status != 0)
return Status("unable to perform copy");
@@ -522,8 +337,8 @@ lldb_private::Status PlatformPOSIX::GetFile(
if (log)
log->Printf("[GetFile] Running command: %s\n", command.GetData());
int retcode;
- Host::RunShellCommand(command.GetData(), NULL, &retcode, NULL, NULL,
- std::chrono::minutes(1));
+ Host::RunShellCommand(command.GetData(), nullptr, &retcode, nullptr,
+ nullptr, std::chrono::minutes(1));
if (retcode == 0)
return Status();
// If we are here, rsync has failed - let's try the slow way before
@@ -622,103 +437,12 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() {
return "";
}
-bool PlatformPOSIX::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
- uint64_t &high) {
- if (IsHost())
- return Platform::CalculateMD5(file_spec, low, high);
- if (m_remote_platform_sp)
- return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
- return false;
-}
-
const lldb::UnixSignalsSP &PlatformPOSIX::GetRemoteUnixSignals() {
if (IsRemote() && m_remote_platform_sp)
return m_remote_platform_sp->GetRemoteUnixSignals();
return Platform::GetRemoteUnixSignals();
}
-FileSpec PlatformPOSIX::GetRemoteWorkingDirectory() {
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteWorkingDirectory();
- else
- return Platform::GetRemoteWorkingDirectory();
-}
-
-bool PlatformPOSIX::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
- else
- return Platform::SetRemoteWorkingDirectory(working_dir);
-}
-
-bool PlatformPOSIX::GetRemoteOSVersion() {
- if (m_remote_platform_sp) {
- m_os_version = m_remote_platform_sp->GetOSVersion();
- return !m_os_version.empty();
- }
- return false;
-}
-
-bool PlatformPOSIX::GetRemoteOSBuildString(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSBuildString(s);
- s.clear();
- return false;
-}
-
-Environment PlatformPOSIX::GetEnvironment() {
- if (IsRemote()) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetEnvironment();
- return Environment();
- }
- return Host::GetEnvironment();
-}
-
-bool PlatformPOSIX::GetRemoteOSKernelDescription(std::string &s) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
- s.clear();
- return false;
-}
-
-// Remote Platform subclasses need to override this function
-ArchSpec PlatformPOSIX::GetRemoteSystemArchitecture() {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetRemoteSystemArchitecture();
- return ArchSpec();
-}
-
-const char *PlatformPOSIX::GetHostname() {
- if (IsHost())
- return Platform::GetHostname();
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->GetHostname();
- return NULL;
-}
-
-const char *PlatformPOSIX::GetUserName(uint32_t uid) {
- // Check the cache in Platform in case we have already looked this uid up
- const char *user_name = Platform::GetUserName(uid);
- if (user_name)
- return user_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetUserName(uid);
- return NULL;
-}
-
-const char *PlatformPOSIX::GetGroupName(uint32_t gid) {
- const char *group_name = Platform::GetGroupName(gid);
- if (group_name)
- return group_name;
-
- if (IsRemote() && m_remote_platform_sp)
- return m_remote_platform_sp->GetGroupName(gid);
- return NULL;
-}
-
Status PlatformPOSIX::ConnectRemote(Args &args) {
Status error;
if (IsHost()) {
@@ -778,30 +502,6 @@ Status PlatformPOSIX::DisconnectRemote() {
return error;
}
-Status PlatformPOSIX::LaunchProcess(ProcessLaunchInfo &launch_info) {
- Status error;
-
- if (IsHost()) {
- error = Platform::LaunchProcess(launch_info);
- } else {
- if (m_remote_platform_sp)
- error = m_remote_platform_sp->LaunchProcess(launch_info);
- else
- error.SetErrorString("the platform is not currently connected");
- }
- return error;
-}
-
-lldb_private::Status PlatformPOSIX::KillProcess(const lldb::pid_t pid) {
- if (IsHost())
- return Platform::KillProcess(pid);
-
- if (m_remote_platform_sp)
- return m_remote_platform_sp->KillProcess(pid);
-
- return Status("the platform is not currently connected");
-}
-
lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
Debugger &debugger, Target *target,
Status &error) {
@@ -809,11 +509,11 @@ lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PLATFORM));
if (IsHost()) {
- if (target == NULL) {
+ if (target == nullptr) {
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(
- debugger, "", "", eLoadDependentsNo, NULL, new_target_sp);
+ debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
target = new_target_sp.get();
if (log)
log->Printf("PlatformPOSIX::%s created new target", __FUNCTION__);
@@ -837,7 +537,7 @@ lldb::ProcessSP PlatformPOSIX::Attach(ProcessAttachInfo &attach_info,
process_sp =
target->CreateProcess(attach_info.GetListenerForProcess(debugger),
- attach_info.GetProcessPluginName(), NULL);
+ attach_info.GetProcessPluginName(), nullptr);
if (process_sp) {
ListenerSP listener_sp = attach_info.GetHijackListener();
@@ -917,7 +617,7 @@ Status PlatformPOSIX::EvaluateLibdlExpression(
expr_options.SetLanguage(eLanguageTypeC_plus_plus);
expr_options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
// don't do the work to trap them.
- expr_options.SetTimeout(std::chrono::seconds(2));
+ expr_options.SetTimeout(process->GetUtilityExpressionTimeout());
Status expr_error;
ExpressionResults result =
@@ -1242,7 +942,7 @@ uint32_t PlatformPOSIX::DoLoadImage(lldb_private::Process *process,
options.SetUnwindOnError(true);
options.SetTrapExceptions(false); // dlopen can't throw exceptions, so
// don't do the work to trap them.
- options.SetTimeout(std::chrono::seconds(2));
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetIsForUtilityExpr(true);
Value return_value;
@@ -1335,19 +1035,6 @@ Status PlatformPOSIX::UnloadImage(lldb_private::Process *process,
return Status();
}
-lldb::ProcessSP PlatformPOSIX::ConnectProcess(llvm::StringRef connect_url,
- llvm::StringRef plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Status &error) {
- if (m_remote_platform_sp)
- return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
- debugger, target, error);
-
- return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
- error);
-}
-
llvm::StringRef
PlatformPOSIX::GetLibdlFunctionDeclarations(lldb_private::Process *process) {
return R"(
diff --git a/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
index 97333ef1eb7cb..5858f99088e60 100644
--- a/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ b/source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -1,9 +1,8 @@
//===-- PlatformPOSIX.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,123 +13,34 @@
#include <memory>
#include "lldb/Interpreter/Options.h"
-#include "lldb/Target/Platform.h"
+#include "lldb/Target/RemoteAwarePlatform.h"
-class PlatformPOSIX : public lldb_private::Platform {
+class PlatformPOSIX : public lldb_private::RemoteAwarePlatform {
public:
PlatformPOSIX(bool is_host);
~PlatformPOSIX() override;
- //------------------------------------------------------------
// lldb_private::Platform functions
- //------------------------------------------------------------
-
- bool GetModuleSpec(const lldb_private::FileSpec &module_file_spec,
- const lldb_private::ArchSpec &arch,
- lldb_private::ModuleSpec &module_spec) override;
lldb_private::OptionGroupOptions *
GetConnectionOptions(lldb_private::CommandInterpreter &interpreter) override;
- const char *GetHostname() override;
-
- const char *GetUserName(uint32_t uid) override;
-
- const char *GetGroupName(uint32_t gid) override;
-
lldb_private::Status PutFile(const lldb_private::FileSpec &source,
const lldb_private::FileSpec &destination,
uint32_t uid = UINT32_MAX,
uint32_t gid = UINT32_MAX) override;
- lldb::user_id_t OpenFile(const lldb_private::FileSpec &file_spec,
- uint32_t flags, uint32_t mode,
- lldb_private::Status &error) override;
-
- bool CloseFile(lldb::user_id_t fd, lldb_private::Status &error) override;
-
- uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst,
- uint64_t dst_len, lldb_private::Status &error) override;
-
- uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src,
- uint64_t src_len, lldb_private::Status &error) override;
-
- lldb::user_id_t GetFileSize(const lldb_private::FileSpec &file_spec) override;
-
- lldb_private::Status
- CreateSymlink(const lldb_private::FileSpec &src,
- const lldb_private::FileSpec &dst) override;
-
lldb_private::Status
GetFile(const lldb_private::FileSpec &source,
const lldb_private::FileSpec &destination) override;
- lldb_private::FileSpec GetRemoteWorkingDirectory() override;
-
- bool
- SetRemoteWorkingDirectory(const lldb_private::FileSpec &working_dir) override;
-
- bool GetRemoteOSVersion() override;
-
- bool GetRemoteOSBuildString(std::string &s) override;
-
- bool GetRemoteOSKernelDescription(std::string &s) override;
-
- lldb_private::ArchSpec GetRemoteSystemArchitecture() override;
-
const lldb::UnixSignalsSP &GetRemoteUnixSignals() override;
- lldb_private::Environment GetEnvironment() override;
-
- bool IsConnected() const override;
-
- lldb_private::Status RunShellCommand(
- const char *command, // Shouldn't be nullptr
- const lldb_private::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
- const lldb_private::Timeout<std::micro> &timeout) override;
-
lldb_private::Status ResolveExecutable(
const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const lldb_private::FileSpecList *module_search_paths_ptr) override;
- lldb_private::Status
- GetFileWithUUID(const lldb_private::FileSpec &platform_file,
- const lldb_private::UUID *uuid,
- lldb_private::FileSpec &local_file) override;
-
- bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
-
- uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
- lldb_private::ProcessInstanceInfoList &process_infos) override;
-
- lldb_private::Status MakeDirectory(const lldb_private::FileSpec &file_spec,
- uint32_t mode) override;
-
- lldb_private::Status
- GetFilePermissions(const lldb_private::FileSpec &file_spec,
- uint32_t &file_permissions) override;
-
- lldb_private::Status
- SetFilePermissions(const lldb_private::FileSpec &file_spec,
- uint32_t file_permissions) override;
-
- bool GetFileExists(const lldb_private::FileSpec &file_spec) override;
-
- lldb_private::Status Unlink(const lldb_private::FileSpec &file_spec) override;
-
- lldb_private::Status
- LaunchProcess(lldb_private::ProcessLaunchInfo &launch_info) override;
-
- lldb_private::Status KillProcess(const lldb::pid_t pid) override;
-
lldb::ProcessSP Attach(lldb_private::ProcessAttachInfo &attach_info,
lldb_private::Debugger &debugger,
lldb_private::Target *target, // Can be nullptr, if
@@ -150,9 +60,6 @@ public:
std::string GetPlatformSpecificConnectionInformation() override;
- bool CalculateMD5(const lldb_private::FileSpec &file_spec, uint64_t &low,
- uint64_t &high) override;
-
void CalculateTrapHandlerSymbolNames() override;
lldb_private::Status ConnectRemote(lldb_private::Args &args) override;
@@ -168,12 +75,6 @@ public:
lldb_private::Status UnloadImage(lldb_private::Process *process,
uint32_t image_token) override;
- lldb::ProcessSP ConnectProcess(llvm::StringRef connect_url,
- llvm::StringRef plugin_name,
- lldb_private::Debugger &debugger,
- lldb_private::Target *target,
- lldb_private::Status &error) override;
-
size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
lldb_private::Status &error) override;
@@ -190,8 +91,6 @@ protected:
std::map<lldb_private::CommandInterpreter *,
std::unique_ptr<lldb_private::OptionGroupOptions>>
m_options;
- lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a
- // remote POSIX-compliant OS
lldb_private::Status
EvaluateLibdlExpression(lldb_private::Process *process, const char *expr_cstr,
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index f6ace706ca3f0..9c52b59e2b06d 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -1,9 +1,8 @@
//===-- PlatformRemoteGDBServer.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,6 +24,7 @@
#include "lldb/Target/Target.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/UriParser.h"
@@ -109,7 +109,8 @@ Status PlatformRemoteGDBServer::ResolveExecutable(
if (resolved_module_spec.GetArchitecture().IsValid() ||
resolved_module_spec.GetUUID().IsValid()) {
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
+ module_search_paths_ptr, nullptr,
+ nullptr);
if (exe_module_sp && exe_module_sp->GetObjectFile())
return error;
@@ -123,7 +124,8 @@ Status PlatformRemoteGDBServer::ResolveExecutable(
idx, resolved_module_spec.GetArchitecture());
++idx) {
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
- module_search_paths_ptr, NULL, NULL);
+ module_search_paths_ptr, nullptr,
+ nullptr);
// Did we find an executable using one of the
if (error.Success()) {
if (exe_module_sp && exe_module_sp->GetObjectFile())
@@ -195,19 +197,15 @@ Status PlatformRemoteGDBServer::GetFileWithUUID(const FileSpec &platform_file,
return Status();
}
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
PlatformRemoteGDBServer::PlatformRemoteGDBServer()
: Platform(false), // This is a remote platform
m_gdb_client() {}
-//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
PlatformRemoteGDBServer::~PlatformRemoteGDBServer() {}
bool PlatformRemoteGDBServer::GetSupportedArchitectureAtIndex(uint32_t idx,
@@ -337,33 +335,24 @@ Status PlatformRemoteGDBServer::DisconnectRemote() {
const char *PlatformRemoteGDBServer::GetHostname() {
m_gdb_client.GetHostname(m_name);
if (m_name.empty())
- return NULL;
+ return nullptr;
return m_name.c_str();
}
-const char *PlatformRemoteGDBServer::GetUserName(uint32_t uid) {
- // Try and get a cache user name first
- const char *cached_user_name = Platform::GetUserName(uid);
- if (cached_user_name)
- return cached_user_name;
+llvm::Optional<std::string>
+PlatformRemoteGDBServer::DoGetUserName(UserIDResolver::id_t uid) {
std::string name;
if (m_gdb_client.GetUserName(uid, name))
- return SetCachedUserName(uid, name.c_str(), name.size());
-
- SetUserNameNotFound(uid); // Negative cache so we don't keep sending packets
- return NULL;
+ return std::move(name);
+ return llvm::None;
}
-const char *PlatformRemoteGDBServer::GetGroupName(uint32_t gid) {
- const char *cached_group_name = Platform::GetGroupName(gid);
- if (cached_group_name)
- return cached_group_name;
+llvm::Optional<std::string>
+PlatformRemoteGDBServer::DoGetGroupName(UserIDResolver::id_t gid) {
std::string name;
if (m_gdb_client.GetGroupName(gid, name))
- return SetCachedGroupName(gid, name.c_str(), name.size());
-
- SetGroupNameNotFound(gid); // Negative cache so we don't keep sending packets
- return NULL;
+ return std::move(name);
+ return llvm::None;
}
uint32_t PlatformRemoteGDBServer::FindProcesses(
@@ -482,11 +471,11 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
GetHostname());
} else {
- if (target == NULL) {
+ if (target == nullptr) {
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(
- debugger, "", "", eLoadDependentsNo, NULL, new_target_sp);
+ debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
@@ -497,7 +486,7 @@ lldb::ProcessSP PlatformRemoteGDBServer::DebugProcess(
// The darwin always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
process_sp = target->CreateProcess(launch_info.GetListener(),
- "gdb-remote", NULL);
+ "gdb-remote", nullptr);
if (process_sp) {
error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
@@ -568,11 +557,11 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach(
error.SetErrorStringWithFormat("unable to launch a GDB server on '%s'",
GetHostname());
} else {
- if (target == NULL) {
+ if (target == nullptr) {
TargetSP new_target_sp;
error = debugger.GetTargetList().CreateTarget(
- debugger, "", "", eLoadDependentsNo, NULL, new_target_sp);
+ debugger, "", "", eLoadDependentsNo, nullptr, new_target_sp);
target = new_target_sp.get();
} else
error.Clear();
@@ -582,8 +571,9 @@ lldb::ProcessSP PlatformRemoteGDBServer::Attach(
// The darwin always currently uses the GDB remote debugger plug-in
// so even when debugging locally we are debugging remotely!
- process_sp = target->CreateProcess(
- attach_info.GetListenerForProcess(debugger), "gdb-remote", NULL);
+ process_sp =
+ target->CreateProcess(attach_info.GetListenerForProcess(debugger),
+ "gdb-remote", nullptr);
if (process_sp) {
error = process_sp->ConnectRemote(nullptr, connect_url.c_str());
if (error.Success()) {
diff --git a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 7abb33423bc1b..c774daa8ab73c 100644
--- a/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -1,10 +1,9 @@
//===-- PlatformRemoteGDBServer.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,7 +19,7 @@
namespace lldb_private {
namespace platform_gdb_server {
-class PlatformRemoteGDBServer : public Platform {
+class PlatformRemoteGDBServer : public Platform, private UserIDResolver {
public:
static void Initialize();
@@ -34,18 +33,14 @@ public:
PlatformRemoteGDBServer();
- virtual ~PlatformRemoteGDBServer();
+ ~PlatformRemoteGDBServer() override;
- //------------------------------------------------------------
// lldb_private::PluginInterface functions
- //------------------------------------------------------------
ConstString GetPluginName() override { return GetPluginNameStatic(); }
uint32_t GetPluginVersion() override { return 1; }
- //------------------------------------------------------------
// lldb_private::Platform functions
- //------------------------------------------------------------
Status
ResolveExecutable(const ModuleSpec &module_spec, lldb::ModuleSP &module_sp,
const FileSpecList *module_search_paths_ptr) override;
@@ -101,9 +96,7 @@ public:
// name if connected.
const char *GetHostname() override;
- const char *GetUserName(uint32_t uid) override;
-
- const char *GetGroupName(uint32_t gid) override;
+ UserIDResolver &GetUserIDResolver() override { return *this; }
bool IsConnected() const override;
@@ -196,6 +189,9 @@ private:
const std::string &platform_hostname,
uint16_t port, const char *socket_name);
+ llvm::Optional<std::string> DoGetUserName(UserIDResolver::id_t uid) override;
+ llvm::Optional<std::string> DoGetGroupName(UserIDResolver::id_t uid) override;
+
DISALLOW_COPY_AND_ASSIGN(PlatformRemoteGDBServer);
};
diff --git a/source/Plugins/Process/Darwin/CFBundle.cpp b/source/Plugins/Process/Darwin/CFBundle.cpp
index 7b080e60cdb3a..3cdd2fa575e79 100644
--- a/source/Plugins/Process/Darwin/CFBundle.cpp
+++ b/source/Plugins/Process/Darwin/CFBundle.cpp
@@ -1,9 +1,8 @@
//===-- CFBundle.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -14,37 +13,27 @@
#include "CFBundle.h"
#include "CFString.h"
-//----------------------------------------------------------------------
// CFBundle constructor
-//----------------------------------------------------------------------
CFBundle::CFBundle(const char *path)
: CFReleaser<CFBundleRef>(), m_bundle_url() {
if (path && path[0])
SetPath(path);
}
-//----------------------------------------------------------------------
// CFBundle copy constructor
-//----------------------------------------------------------------------
CFBundle::CFBundle(const CFBundle &rhs)
: CFReleaser<CFBundleRef>(rhs), m_bundle_url(rhs.m_bundle_url) {}
-//----------------------------------------------------------------------
// CFBundle copy constructor
-//----------------------------------------------------------------------
CFBundle &CFBundle::operator=(const CFBundle &rhs) {
*this = rhs;
return *this;
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
CFBundle::~CFBundle() {}
-//----------------------------------------------------------------------
// Set the path for a bundle by supplying a
-//----------------------------------------------------------------------
bool CFBundle::SetPath(const char *path) {
CFAllocatorRef alloc = kCFAllocatorDefault;
// Release our old bundle and ULR
diff --git a/source/Plugins/Process/Darwin/CFBundle.h b/source/Plugins/Process/Darwin/CFBundle.h
index 09957af534b35..f49dc30f1f8f7 100644
--- a/source/Plugins/Process/Darwin/CFBundle.h
+++ b/source/Plugins/Process/Darwin/CFBundle.h
@@ -1,9 +1,8 @@
//===-- CFBundle.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -18,9 +17,7 @@
class CFBundle : public CFReleaser<CFBundleRef> {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CFBundle(const char *path = NULL);
CFBundle(const CFBundle &rhs);
CFBundle &operator=(const CFBundle &rhs);
diff --git a/source/Plugins/Process/Darwin/CFString.cpp b/source/Plugins/Process/Darwin/CFString.cpp
index b87afe9991816..4dcc05c866576 100644
--- a/source/Plugins/Process/Darwin/CFString.cpp
+++ b/source/Plugins/Process/Darwin/CFString.cpp
@@ -1,9 +1,8 @@
//===-- CFString.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -15,19 +14,13 @@
#include <glob.h>
#include <string>
-//----------------------------------------------------------------------
// CFString constructor
-//----------------------------------------------------------------------
CFString::CFString(CFStringRef s) : CFReleaser<CFStringRef>(s) {}
-//----------------------------------------------------------------------
// CFString copy constructor
-//----------------------------------------------------------------------
CFString::CFString(const CFString &rhs) : CFReleaser<CFStringRef>(rhs) {}
-//----------------------------------------------------------------------
// CFString copy constructor
-//----------------------------------------------------------------------
CFString &CFString::operator=(const CFString &rhs) {
if (this != &rhs)
*this = rhs;
@@ -42,9 +35,7 @@ CFString::CFString(const char *cstr, CFStringEncoding cstr_encoding)
}
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
CFString::~CFString() {}
const char *CFString::GetFileSystemRepresentation(std::string &s) {
diff --git a/source/Plugins/Process/Darwin/CFString.h b/source/Plugins/Process/Darwin/CFString.h
index 18d60a5a74bd8..d1bd5682689e8 100644
--- a/source/Plugins/Process/Darwin/CFString.h
+++ b/source/Plugins/Process/Darwin/CFString.h
@@ -1,9 +1,8 @@
//===-- CFString.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -19,9 +18,7 @@
class CFString : public CFReleaser<CFStringRef> {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
CFString(CFStringRef cf_str = NULL);
CFString(const char *s, CFStringEncoding encoding = kCFStringEncodingUTF8);
CFString(const CFString &rhs);
diff --git a/source/Plugins/Process/Darwin/CFUtils.h b/source/Plugins/Process/Darwin/CFUtils.h
index a904cd0ea6f07..b567524ce63a3 100644
--- a/source/Plugins/Process/Darwin/CFUtils.h
+++ b/source/Plugins/Process/Darwin/CFUtils.h
@@ -1,9 +1,8 @@
//===-- CFUtils.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -18,11 +17,9 @@
#ifdef __cplusplus
-//----------------------------------------------------------------------
// Templatized CF helper class that can own any CF pointer and will
// call CFRelease() on any valid pointer it owns unless that pointer is
// explicitly released using the release() member function.
-//----------------------------------------------------------------------
template <class T> class CFReleaser {
public:
// Type names for the avlue
diff --git a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
index 95659725ce2ec..3ec410fe7d768 100644
--- a/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
+++ b/source/Plugins/Process/Darwin/DarwinProcessLauncher.cpp
@@ -1,9 +1,8 @@
//===-- DarwinProcessLauncher.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -149,17 +148,13 @@ static Status ForkChildForPTraceDebugging(const char *path, char const *argv[],
memset(fork_error, 0, sizeof(fork_error));
*pid = static_cast<::pid_t>(pty.Fork(fork_error, sizeof(fork_error)));
if (*pid < 0) {
- //--------------------------------------------------------------
// Status during fork.
- //--------------------------------------------------------------
*pid = static_cast<::pid_t>(LLDB_INVALID_PROCESS_ID);
error.SetErrorStringWithFormat("%s(): fork failed: %s", __FUNCTION__,
fork_error);
return error;
} else if (pid == 0) {
- //--------------------------------------------------------------
// Child process
- //--------------------------------------------------------------
// Debug this process.
::ptrace(PT_TRACE_ME, 0, 0, 0);
@@ -187,9 +182,7 @@ static Status ForkChildForPTraceDebugging(const char *path, char const *argv[],
// call and if the exec fails it will exit the child process below.
::exit(127);
} else {
- //--------------------------------------------------------------
// Parent process
- //--------------------------------------------------------------
// Let the child have its own process group. We need to execute this call
// in both the child and parent to avoid a race condition between the two
// processes.
diff --git a/source/Plugins/Process/Darwin/DarwinProcessLauncher.h b/source/Plugins/Process/Darwin/DarwinProcessLauncher.h
index a0e8ce5cb9dcd..0e65b56a143e0 100644
--- a/source/Plugins/Process/Darwin/DarwinProcessLauncher.h
+++ b/source/Plugins/Process/Darwin/DarwinProcessLauncher.h
@@ -1,9 +1,8 @@
//===-- DarwinProcessLauncher.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,15 +27,15 @@ namespace darwin_process_launcher {
// =============================================================================
/// Launches a process for debugging.
///
-/// @param[inout] launch_info
+/// \param[inout] launch_info
/// Specifies details about the process to launch (e.g. path, architecture,
/// etc.). On output, includes the launched ProcessID (pid).
///
-/// @param[out] pty_master_fd
+/// \param[out] pty_master_fd
/// Returns the master side of the pseudo-terminal used to communicate
/// with stdin/stdout from the launched process. May be nullptr.
///
-/// @param[out] launch_flavor
+/// \param[out] launch_flavor
/// Contains the launch flavor used when launching the process.
// =============================================================================
Status
diff --git a/source/Plugins/Process/Darwin/LaunchFlavor.h b/source/Plugins/Process/Darwin/LaunchFlavor.h
index 7b161712cffdf..cfd76d1b9c3c2 100644
--- a/source/Plugins/Process/Darwin/LaunchFlavor.h
+++ b/source/Plugins/Process/Darwin/LaunchFlavor.h
@@ -1,9 +1,8 @@
//===-- LaunchFlavor.h ---------------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Darwin/MachException.cpp b/source/Plugins/Process/Darwin/MachException.cpp
index 353f2df321395..70ad6736a7487 100644
--- a/source/Plugins/Process/Darwin/MachException.cpp
+++ b/source/Plugins/Process/Darwin/MachException.cpp
@@ -1,9 +1,8 @@
//===-- MachException.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/source/Plugins/Process/Darwin/MachException.h b/source/Plugins/Process/Darwin/MachException.h
index 2da6a36a921e4..18e49173b0200 100644
--- a/source/Plugins/Process/Darwin/MachException.h
+++ b/source/Plugins/Process/Darwin/MachException.h
@@ -1,9 +1,8 @@
//===-- MachException.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp b/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
index 70d9a5248fd9d..fe7de27e0ee68 100644
--- a/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
+++ b/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
@@ -1,9 +1,8 @@
//===-- NativeProcessDarwin.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,9 +37,7 @@ using namespace lldb_private;
using namespace lldb_private::process_darwin;
using namespace lldb_private::darwin_process_launcher;
-// -----------------------------------------------------------------------------
// Hidden Impl
-// -----------------------------------------------------------------------------
namespace {
struct hack_task_dyld_info {
@@ -49,9 +46,7 @@ struct hack_task_dyld_info {
};
}
-// -----------------------------------------------------------------------------
// Public Static Methods
-// -----------------------------------------------------------------------------
Status NativeProcessProtocol::Launch(
ProcessLaunchInfo &launch_info,
@@ -154,9 +149,7 @@ Status NativeProcessProtocol::Attach(
return error;
}
-// -----------------------------------------------------------------------------
// ctor/dtor
-// -----------------------------------------------------------------------------
NativeProcessDarwin::NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd)
: NativeProcessProtocol(pid), m_task(TASK_NULL), m_did_exec(false),
@@ -171,23 +164,13 @@ NativeProcessDarwin::NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd)
NativeProcessDarwin::~NativeProcessDarwin() {}
-// -----------------------------------------------------------------------------
// Instance methods
-// -----------------------------------------------------------------------------
Status NativeProcessDarwin::FinalizeLaunch(LaunchFlavor launch_flavor,
MainLoop &main_loop) {
Status error;
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-#if 0
- m_path = path;
- size_t i;
- char const *arg;
- for (i=0; (arg = argv[i]) != NULL; i++)
- m_args.push_back(arg);
-#endif
-
error = StartExceptionThread();
if (!error.Success()) {
if (log)
@@ -1548,9 +1531,7 @@ Status NativeProcessDarwin::GetFileLoadAddress(const llvm::StringRef &file_name,
return error;
}
-// -----------------------------------------------------------------
// NativeProcessProtocol protected interface
-// -----------------------------------------------------------------
Status NativeProcessDarwin::GetSoftwareBreakpointTrapOpcode(
size_t trap_opcode_size_hint, size_t &actual_opcode_size,
const uint8_t *&trap_opcode_bytes) {
diff --git a/source/Plugins/Process/Darwin/NativeProcessDarwin.h b/source/Plugins/Process/Darwin/NativeProcessDarwin.h
index 9abdd5360eba5..6741d4ddc5d8f 100644
--- a/source/Plugins/Process/Darwin/NativeProcessDarwin.h
+++ b/source/Plugins/Process/Darwin/NativeProcessDarwin.h
@@ -1,9 +1,8 @@
//===-- NativeProcessDarwin.h --------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -41,7 +40,7 @@ class Scalar;
namespace process_darwin {
-/// @class NativeProcessDarwin
+/// \class NativeProcessDarwin
/// Manages communication with the inferior (debugee) process.
///
/// Upon construction, this class prepares and launches an inferior process
@@ -60,9 +59,7 @@ class NativeProcessDarwin : public NativeProcessProtocol {
public:
~NativeProcessDarwin() override;
- // -----------------------------------------------------------------
// NativeProcessProtocol Interface
- // -----------------------------------------------------------------
Status Resume(const ResumeActionList &resume_actions) override;
Status Halt() override;
@@ -113,9 +110,7 @@ public:
task_t GetTask() const { return m_task; }
- // -----------------------------------------------------------------
// Interface used by NativeRegisterContext-derived classes.
- // -----------------------------------------------------------------
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
void *data = nullptr, size_t data_size = 0,
long *result = nullptr);
@@ -123,18 +118,14 @@ public:
bool SupportHardwareSingleStepping() const;
protected:
- // -----------------------------------------------------------------
// NativeProcessProtocol protected interface
- // -----------------------------------------------------------------
Status
GetSoftwareBreakpointTrapOpcode(size_t trap_opcode_size_hint,
size_t &actual_opcode_size,
const uint8_t *&trap_opcode_bytes) override;
private:
- // -----------------------------------------------------------------
/// Mach task-related Member Variables
- // -----------------------------------------------------------------
// The task port for the inferior process.
mutable task_t m_task;
@@ -146,9 +137,7 @@ private:
// The CPU type of this process.
mutable cpu_type_t m_cpu_type;
- // -----------------------------------------------------------------
/// Exception/Signal Handling Member Variables
- // -----------------------------------------------------------------
// Exception port on which we will receive child exceptions
mach_port_t m_exception_port;
@@ -176,15 +165,11 @@ private:
// interrupt signal (if this is non-zero).
int m_auto_resume_signo;
- // -----------------------------------------------------------------
/// Thread-related Member Variables
- // -----------------------------------------------------------------
NativeThreadListDarwin m_thread_list;
ResumeActionList m_thread_actions;
- // -----------------------------------------------------------------
/// Process Lifetime Member Variable
- // -----------------------------------------------------------------
// The pipe over which the waitpid thread and the main loop will
// communicate.
@@ -196,12 +181,9 @@ private:
// waitpid reader callback handle.
MainLoop::ReadHandleUP m_waitpid_reader_handle;
- // -----------------------------------------------------------------
// Private Instance Methods
- // -----------------------------------------------------------------
NativeProcessDarwin(lldb::pid_t pid, int pty_master_fd);
- // -----------------------------------------------------------------
/// Finalize the launch.
///
/// This method associates the NativeProcessDarwin instance with the host
@@ -209,19 +191,18 @@ private:
/// listener to the inferior exception port, ptracing the process, and the
/// like.
///
- /// @param[in] launch_flavor
+ /// \param[in] launch_flavor
/// The launch flavor that was used to launch the process.
///
- /// @param[in] main_loop
+ /// \param[in] main_loop
/// The main loop that will run the process monitor. Work
/// that needs to be done (e.g. reading files) gets registered
/// here along with callbacks to process the work.
///
- /// @return
+ /// \return
/// Any error that occurred during the aforementioned
/// operations. Failure here will force termination of the
/// launched process and debugging session.
- // -----------------------------------------------------------------
Status FinalizeLaunch(LaunchFlavor launch_flavor, MainLoop &main_loop);
Status SaveExceptionPortInfo();
@@ -318,7 +299,7 @@ private:
Status FixupBreakpointPCAsNeeded(NativeThreadDarwin &thread);
/// Writes a siginfo_t structure corresponding to the given thread
- /// ID to the memory region pointed to by @p siginfo.
+ /// ID to the memory region pointed to by \p siginfo.
Status GetSignalInfo(lldb::tid_t tid, void *siginfo);
/// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG)
diff --git a/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp b/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
index 521c6d5c8fd03..bcd6d8c2c4c1e 100644
--- a/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
+++ b/source/Plugins/Process/Darwin/NativeThreadDarwin.cpp
@@ -1,9 +1,8 @@
//===-- NativeThreadDarwin.cpp -------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -139,7 +138,7 @@ bool NativeThreadDarwin::NotifyException(MachException::Data &exc) {
// Allow the arch specific protocol to process (MachException::Data &)exc
// first before possible reassignment of m_stop_exception with exc. See
// also MachThread::GetStopException().
- bool handled = m_arch_ap->NotifyException(exc);
+ bool handled = m_arch_up->NotifyException(exc);
if (m_stop_exception.IsValid())
{
@@ -176,7 +175,7 @@ bool NativeThreadDarwin::ShouldStop(bool &step_more) const {
}
else
{
- if (m_arch_ap->StepNotComplete())
+ if (m_arch_up->StepNotComplete())
{
step_more = true;
return false;
@@ -218,7 +217,7 @@ void NativeThreadDarwin::ThreadDidStop() {
// When this method gets called, the process state is still in the state it
// was in while running so we can act accordingly.
- m_arch_ap->ThreadDidStop();
+ m_arch_up->ThreadDidStop();
// We may have suspended this thread so the primary thread could step
diff --git a/source/Plugins/Process/Darwin/NativeThreadDarwin.h b/source/Plugins/Process/Darwin/NativeThreadDarwin.h
index f66f8fe8738ca..616a9a7b9bf00 100644
--- a/source/Plugins/Process/Darwin/NativeThreadDarwin.h
+++ b/source/Plugins/Process/Darwin/NativeThreadDarwin.h
@@ -1,9 +1,8 @@
//===-- NativeThreadDarwin.h ---------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -46,9 +45,7 @@ public:
lldb::tid_t unique_thread_id = 0,
::thread_t mach_thread_port = 0);
- // -----------------------------------------------------------------
// NativeThreadProtocol Interface
- // -----------------------------------------------------------------
std::string GetName() override;
lldb::StateType GetState() override;
@@ -63,21 +60,17 @@ public:
Status RemoveWatchpoint(lldb::addr_t addr) override;
- // -----------------------------------------------------------------
// New methods that are fine for others to call.
- // -----------------------------------------------------------------
void Dump(Stream &stream) const;
private:
- // -----------------------------------------------------------------
// Interface for friend classes
- // -----------------------------------------------------------------
- /// Resumes the thread. If @p signo is anything but
+ /// Resumes the thread. If \p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
Status Resume(uint32_t signo);
- /// Single steps the thread. If @p signo is anything but
+ /// Single steps the thread. If \p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the thread.
Status SingleStep(uint32_t signo);
@@ -119,20 +112,16 @@ private:
Status RequestStop();
- // -------------------------------------------------------------------------
/// Return the mach thread port number for this thread.
///
- /// @return
+ /// \return
/// The mach port number for this thread. Returns NULL_THREAD
/// when the thread is invalid.
- // -------------------------------------------------------------------------
thread_t GetMachPortNumber() const { return m_mach_thread_port; }
static bool MachPortNumberIsValid(::thread_t thread);
- // ---------------------------------------------------------------------
// Private interface
- // ---------------------------------------------------------------------
bool GetIdentifierInfo();
void MaybeLogStateChange(lldb::StateType new_state);
@@ -145,9 +134,7 @@ private:
inline void MaybeCleanupSingleStepWorkaround();
- // -----------------------------------------------------------------
// Member Variables
- // -----------------------------------------------------------------
// The mach thread port for the thread.
::thread_t m_mach_thread_port;
diff --git a/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp b/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
index 4ff662e420972..89de92a6df4d1 100644
--- a/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
+++ b/source/Plugins/Process/Darwin/NativeThreadListDarwin.cpp
@@ -1,10 +1,9 @@
//===-- NativeThreadListDarwin.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -549,7 +548,6 @@ uint32_t NativeThreadListDarwin::ProcessDidStop(NativeProcessDarwin &process) {
return (uint32_t)m_threads.size();
}
-//----------------------------------------------------------------------
// Check each thread in our thread list to see if we should notify our client
// of the current halt in execution.
//
@@ -559,7 +557,6 @@ uint32_t NativeThreadListDarwin::ProcessDidStop(NativeProcessDarwin &process) {
// RETURNS
// true if we should stop and notify our clients
// false if we should resume our child process and skip notification
-//----------------------------------------------------------------------
bool NativeThreadListDarwin::ShouldStop(bool &step_more) {
std::lock_guard<std::recursive_mutex> locker(m_threads_mutex);
for (auto thread_sp : m_threads) {
diff --git a/source/Plugins/Process/Darwin/NativeThreadListDarwin.h b/source/Plugins/Process/Darwin/NativeThreadListDarwin.h
index 7b59afb96e958..9ab0a7c8c8023 100644
--- a/source/Plugins/Process/Darwin/NativeThreadListDarwin.h
+++ b/source/Plugins/Process/Darwin/NativeThreadListDarwin.h
@@ -1,10 +1,9 @@
//===-- NativeThreadListDarwin.h --------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
index fce0be22678eb..749835531279b 100644
--- a/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
+++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.cpp
@@ -1,9 +1,8 @@
//===-- FreeBSDThread.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,7 +51,7 @@ using namespace lldb;
using namespace lldb_private;
FreeBSDThread::FreeBSDThread(Process &process, lldb::tid_t tid)
- : Thread(process, tid), m_frame_ap(), m_breakpoint(),
+ : Thread(process, tid), m_frame_up(), m_breakpoint(),
m_thread_name_valid(false), m_thread_name(), m_posix_thread(nullptr) {
Log *log(ProcessPOSIXLog::GetLogIfAllCategoriesSet(POSIX_LOG_THREAD));
LLDB_LOGV(log, "tid = {0}", tid);
@@ -277,10 +276,10 @@ bool FreeBSDThread::CalculateStopInfo() {
}
Unwind *FreeBSDThread::GetUnwinder() {
- if (!m_unwinder_ap)
- m_unwinder_ap.reset(new UnwindLLDB(*this));
+ if (!m_unwinder_up)
+ m_unwinder_up.reset(new UnwindLLDB(*this));
- return m_unwinder_ap.get();
+ return m_unwinder_up.get();
}
void FreeBSDThread::DidStop() {
diff --git a/source/Plugins/Process/FreeBSD/FreeBSDThread.h b/source/Plugins/Process/FreeBSD/FreeBSDThread.h
index a8559fe8b2ca9..6d3c253a519e6 100644
--- a/source/Plugins/Process/FreeBSD/FreeBSDThread.h
+++ b/source/Plugins/Process/FreeBSD/FreeBSDThread.h
@@ -1,9 +1,8 @@
//===-- FreeBSDThread.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,14 +19,11 @@ class ProcessMessage;
class ProcessMonitor;
class POSIXBreakpointProtocol;
-//------------------------------------------------------------------------------
// @class FreeBSDThread
// Abstraction of a FreeBSD thread.
class FreeBSDThread : public lldb_private::Thread {
public:
- //------------------------------------------------------------------
// Constructors and destructors
- //------------------------------------------------------------------
FreeBSDThread(lldb_private::Process &process, lldb::tid_t tid);
virtual ~FreeBSDThread();
@@ -51,7 +47,6 @@ public:
lldb::addr_t GetThreadPointer() override;
- //--------------------------------------------------------------------------
// These functions provide a mapping from the register offset
// back to the register index or name for use in debugging or log
// output.
@@ -62,14 +57,12 @@ public:
const char *GetRegisterNameFromOffset(unsigned offset);
- //--------------------------------------------------------------------------
// These methods form a specialized interface to POSIX threads.
//
bool Resume();
void Notify(const ProcessMessage &message);
- //--------------------------------------------------------------------------
// These methods provide an interface to watchpoints
//
bool EnableHardwareWatchpoint(lldb_private::Watchpoint *wp);
@@ -87,7 +80,7 @@ protected:
return m_posix_thread;
}
- std::unique_ptr<lldb_private::StackFrame> m_frame_ap;
+ std::unique_ptr<lldb_private::StackFrame> m_frame_up;
lldb::BreakpointSiteSP m_breakpoint;
@@ -111,7 +104,6 @@ protected:
lldb_private::Unwind *GetUnwinder() override;
- //--------------------------------------------------------------------------
// FreeBSDThread internal API.
// POSIXThread override
diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
index 9c75c26e379b5..71f012944a9a8 100644
--- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
+++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.cpp
@@ -1,9 +1,8 @@
//===-- POSIXStopInfo.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
index ff3693107170b..88fb7f31fe06b 100644
--- a/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
+++ b/source/Plugins/Process/FreeBSD/POSIXStopInfo.h
@@ -1,9 +1,8 @@
//===-- POSIXStopInfo.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,7 @@
#include <string>
//===----------------------------------------------------------------------===//
-/// @class POSIXStopInfo
+/// \class POSIXStopInfo
/// Simple base class for all POSIX-specific StopInfo objects.
///
class POSIXStopInfo : public lldb_private::StopInfo {
@@ -26,7 +25,7 @@ public:
};
//===----------------------------------------------------------------------===//
-/// @class POSIXLimboStopInfo
+/// \class POSIXLimboStopInfo
/// Represents the stop state of a process ready to exit.
///
class POSIXLimboStopInfo : public POSIXStopInfo {
@@ -45,7 +44,7 @@ public:
};
//===----------------------------------------------------------------------===//
-/// @class POSIXNewThreadStopInfo
+/// \class POSIXNewThreadStopInfo
/// Represents the stop state of process when a new thread is spawned.
///
diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
index a13d4bcc4ecb5..770794569f729 100644
--- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -1,10 +1,9 @@
//===-- ProcessFreeBSD.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -65,7 +64,6 @@ UnixSignalsSP &GetFreeBSDSignals() {
}
}
-//------------------------------------------------------------------------------
// Static functions.
lldb::ProcessSP
@@ -97,7 +95,6 @@ const char *ProcessFreeBSD::GetPluginDescriptionStatic() {
return "Process plugin for FreeBSD";
}
-//------------------------------------------------------------------------------
// ProcessInterface protocol.
lldb_private::ConstString ProcessFreeBSD::GetPluginName() {
@@ -251,7 +248,6 @@ void ProcessFreeBSD::SendMessage(const ProcessMessage &message) {
m_message_queue.push(message);
}
-//------------------------------------------------------------------------------
// Constructors and destructors.
ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp,
@@ -270,7 +266,6 @@ ProcessFreeBSD::ProcessFreeBSD(lldb::TargetSP target_sp,
ProcessFreeBSD::~ProcessFreeBSD() { delete m_monitor; }
-//------------------------------------------------------------------------------
// Process protocol.
void ProcessFreeBSD::Finalize() {
Process::Finalize();
@@ -836,7 +831,6 @@ size_t ProcessFreeBSD::PutSTDIN(const char *buf, size_t len, Status &error) {
return status;
}
-//------------------------------------------------------------------------------
// Utility functions.
bool ProcessFreeBSD::HasExited() {
@@ -882,7 +876,7 @@ bool ProcessFreeBSD::IsAThreadRunning() {
return is_running;
}
-const DataBufferSP ProcessFreeBSD::GetAuxvData() {
+lldb_private::DataExtractor ProcessFreeBSD::GetAuxvData() {
// If we're the local platform, we can ask the host for auxv data.
PlatformSP platform_sp = GetTarget().GetPlatform();
assert(platform_sp && platform_sp->IsHost());
@@ -896,7 +890,7 @@ const DataBufferSP ProcessFreeBSD::GetAuxvData() {
buf_sp.reset();
}
- return buf_sp;
+ return DataExtractor(buf_sp, GetByteOrder(), GetAddressByteSize());
}
struct EmulatorBaton {
@@ -1026,21 +1020,17 @@ bool ProcessFreeBSD::IsSoftwareStepBreakpoint(lldb::tid_t tid) {
bool ProcessFreeBSD::SupportHardwareSingleStepping() const {
lldb_private::ArchSpec arch = GetTarget().GetArchitecture();
- if (arch.GetMachine() == llvm::Triple::arm ||
- arch.GetMachine() == llvm::Triple::mips64 ||
- arch.GetMachine() == llvm::Triple::mips64el ||
- arch.GetMachine() == llvm::Triple::mips ||
- arch.GetMachine() == llvm::Triple::mipsel)
+ if (arch.GetMachine() == llvm::Triple::arm || arch.IsMIPS())
return false;
return true;
}
Status ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) {
- std::unique_ptr<EmulateInstruction> emulator_ap(
+ std::unique_ptr<EmulateInstruction> emulator_up(
EmulateInstruction::FindPlugin(GetTarget().GetArchitecture(),
eInstructionTypePCModifying, nullptr));
- if (emulator_ap == nullptr)
+ if (emulator_up == nullptr)
return Status("Instruction emulator not found!");
FreeBSDThread *thread = static_cast<FreeBSDThread *>(
@@ -1051,17 +1041,17 @@ Status ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) {
lldb::RegisterContextSP register_context_sp = thread->GetRegisterContext();
EmulatorBaton baton(this, register_context_sp.get());
- emulator_ap->SetBaton(&baton);
- emulator_ap->SetReadMemCallback(&ReadMemoryCallback);
- emulator_ap->SetReadRegCallback(&ReadRegisterCallback);
- emulator_ap->SetWriteMemCallback(&WriteMemoryCallback);
- emulator_ap->SetWriteRegCallback(&WriteRegisterCallback);
+ emulator_up->SetBaton(&baton);
+ emulator_up->SetReadMemCallback(&ReadMemoryCallback);
+ emulator_up->SetReadRegCallback(&ReadRegisterCallback);
+ emulator_up->SetWriteMemCallback(&WriteMemoryCallback);
+ emulator_up->SetWriteRegCallback(&WriteRegisterCallback);
- if (!emulator_ap->ReadInstruction())
+ if (!emulator_up->ReadInstruction())
return Status("Read instruction failed!");
bool emulation_result =
- emulator_ap->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC);
+ emulator_up->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC);
const RegisterInfo *reg_info_pc = register_context_sp->GetRegisterInfo(
eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
auto pc_it =
@@ -1078,7 +1068,7 @@ Status ProcessFreeBSD::SetupSoftwareSingleStepping(lldb::tid_t tid) {
// PC modifying instruction should be successful. The failure most
// likely caused by a not supported instruction which don't modify PC.
next_pc =
- register_context_sp->GetPC() + emulator_ap->GetOpcode().GetByteSize();
+ register_context_sp->GetPC() + emulator_up->GetOpcode().GetByteSize();
} else {
// The instruction emulation failed after it modified the PC. It is an
// unknown error where we can't continue because the next instruction is
diff --git a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
index 7ed2a56cd5499..536da0c0aa70e 100644
--- a/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
+++ b/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
@@ -1,10 +1,9 @@
//===-- ProcessFreeBSD.h ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@ class FreeBSDThread;
class ProcessFreeBSD : public lldb_private::Process {
public:
- //------------------------------------------------------------------
// Static functions.
- //------------------------------------------------------------------
static lldb::ProcessSP
CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
const lldb_private::FileSpec *crash_file_path);
@@ -39,9 +36,7 @@ public:
static const char *GetPluginDescriptionStatic();
- //------------------------------------------------------------------
// Constructors and destructors
- //------------------------------------------------------------------
ProcessFreeBSD(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
lldb::UnixSignalsSP &unix_signals_sp);
@@ -49,17 +44,13 @@ public:
virtual lldb_private::Status WillResume() override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
virtual lldb_private::ConstString GetPluginName() override;
virtual uint32_t GetPluginVersion() override;
public:
- //------------------------------------------------------------------
// Process protocol.
- //------------------------------------------------------------------
void Finalize() override;
bool CanDebug(lldb::TargetSP target_sp,
@@ -136,9 +127,8 @@ public:
size_t PutSTDIN(const char *buf, size_t len,
lldb_private::Status &error) override;
- const lldb::DataBufferSP GetAuxvData() override;
+ lldb_private::DataExtractor GetAuxvData() override;
- //--------------------------------------------------------------------------
// ProcessFreeBSD internal API.
/// Registers the given message with this process.
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
index 617ae3030f105..4b9225db5e390 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -1,9 +1,8 @@
//===-- ProcessMonitor.cpp ------------------------------------ -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -141,7 +140,6 @@ extern long PtraceWrapper(int req, lldb::pid_t pid, void *addr, int data) {
PtraceWrapper((req), (pid), (addr), (data))
#endif
-//------------------------------------------------------------------------------
// Static implementations of ProcessMonitor::ReadMemory and
// ProcessMonitor::WriteMemory. This enables mutual recursion between these
// functions without needed to go thru the thread funnel.
@@ -168,7 +166,7 @@ static size_t DoWriteMemory(lldb::pid_t pid, lldb::addr_t vm_addr,
pi_desc.piod_op = PIOD_WRITE_D;
pi_desc.piod_offs = (void *)vm_addr;
- pi_desc.piod_addr = (void *)buf;
+ pi_desc.piod_addr = const_cast<void *>(buf);
pi_desc.piod_len = size;
if (PTRACE(PT_IO, pid, (caddr_t)&pi_desc, 0) < 0) {
@@ -196,8 +194,7 @@ static bool EnsureFDFlags(int fd, int flags, Status &error) {
return true;
}
-//------------------------------------------------------------------------------
-/// @class Operation
+/// \class Operation
/// Represents a ProcessMonitor operation.
///
/// Under FreeBSD, it is not possible to ptrace() from any other thread but
@@ -214,8 +211,7 @@ public:
virtual void Execute(ProcessMonitor *monitor) = 0;
};
-//------------------------------------------------------------------------------
-/// @class ReadOperation
+/// \class ReadOperation
/// Implements ProcessMonitor::ReadMemory.
class ReadOperation : public Operation {
public:
@@ -240,8 +236,7 @@ void ReadOperation::Execute(ProcessMonitor *monitor) {
m_result = DoReadMemory(pid, m_addr, m_buff, m_size, m_error);
}
-//------------------------------------------------------------------------------
-/// @class WriteOperation
+/// \class WriteOperation
/// Implements ProcessMonitor::WriteMemory.
class WriteOperation : public Operation {
public:
@@ -266,8 +261,7 @@ void WriteOperation::Execute(ProcessMonitor *monitor) {
m_result = DoWriteMemory(pid, m_addr, m_buff, m_size, m_error);
}
-//------------------------------------------------------------------------------
-/// @class ReadRegOperation
+/// \class ReadRegOperation
/// Implements ProcessMonitor::ReadRegisterValue.
class ReadRegOperation : public Operation {
public:
@@ -306,8 +300,7 @@ void ReadRegOperation::Execute(ProcessMonitor *monitor) {
}
}
-//------------------------------------------------------------------------------
-/// @class WriteRegOperation
+/// \class WriteRegOperation
/// Implements ProcessMonitor::WriteRegisterValue.
class WriteRegOperation : public Operation {
public:
@@ -339,8 +332,7 @@ void WriteRegOperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class ReadDebugRegOperation
+/// \class ReadDebugRegOperation
/// Implements ProcessMonitor::ReadDebugRegisterValue.
class ReadDebugRegOperation : public Operation {
public:
@@ -374,8 +366,7 @@ void ReadDebugRegOperation::Execute(ProcessMonitor *monitor) {
}
}
-//------------------------------------------------------------------------------
-/// @class WriteDebugRegOperation
+/// \class WriteDebugRegOperation
/// Implements ProcessMonitor::WriteDebugRegisterValue.
class WriteDebugRegOperation : public Operation {
public:
@@ -407,8 +398,7 @@ void WriteDebugRegOperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class ReadGPROperation
+/// \class ReadGPROperation
/// Implements ProcessMonitor::ReadGPR.
class ReadGPROperation : public Operation {
public:
@@ -434,8 +424,7 @@ void ReadGPROperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class ReadFPROperation
+/// \class ReadFPROperation
/// Implements ProcessMonitor::ReadFPR.
class ReadFPROperation : public Operation {
public:
@@ -457,8 +446,7 @@ void ReadFPROperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class WriteGPROperation
+/// \class WriteGPROperation
/// Implements ProcessMonitor::WriteGPR.
class WriteGPROperation : public Operation {
public:
@@ -480,8 +468,7 @@ void WriteGPROperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class WriteFPROperation
+/// \class WriteFPROperation
/// Implements ProcessMonitor::WriteFPR.
class WriteFPROperation : public Operation {
public:
@@ -503,8 +490,7 @@ void WriteFPROperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class ResumeOperation
+/// \class ResumeOperation
/// Implements ProcessMonitor::Resume.
class ResumeOperation : public Operation {
public:
@@ -534,8 +520,7 @@ void ResumeOperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class SingleStepOperation
+/// \class SingleStepOperation
/// Implements ProcessMonitor::SingleStep.
class SingleStepOperation : public Operation {
public:
@@ -562,8 +547,7 @@ void SingleStepOperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class LwpInfoOperation
+/// \class LwpInfoOperation
/// Implements ProcessMonitor::GetLwpInfo.
class LwpInfoOperation : public Operation {
public:
@@ -591,8 +575,7 @@ void LwpInfoOperation::Execute(ProcessMonitor *monitor) {
}
}
-//------------------------------------------------------------------------------
-/// @class ThreadSuspendOperation
+/// \class ThreadSuspendOperation
/// Implements ProcessMonitor::ThreadSuspend.
class ThreadSuspendOperation : public Operation {
public:
@@ -611,8 +594,7 @@ void ThreadSuspendOperation::Execute(ProcessMonitor *monitor) {
m_result = !PTRACE(m_suspend ? PT_SUSPEND : PT_RESUME, m_tid, NULL, 0);
}
-//------------------------------------------------------------------------------
-/// @class EventMessageOperation
+/// \class EventMessageOperation
/// Implements ProcessMonitor::GetEventMessage.
class EventMessageOperation : public Operation {
public:
@@ -641,8 +623,7 @@ void EventMessageOperation::Execute(ProcessMonitor *monitor) {
}
}
-//------------------------------------------------------------------------------
-/// @class KillOperation
+/// \class KillOperation
/// Implements ProcessMonitor::Kill.
class KillOperation : public Operation {
public:
@@ -663,8 +644,7 @@ void KillOperation::Execute(ProcessMonitor *monitor) {
m_result = true;
}
-//------------------------------------------------------------------------------
-/// @class DetachOperation
+/// \class DetachOperation
/// Implements ProcessMonitor::Detach.
class DetachOperation : public Operation {
public:
@@ -709,7 +689,6 @@ ProcessMonitor::AttachArgs::AttachArgs(ProcessMonitor *monitor, lldb::pid_t pid)
ProcessMonitor::AttachArgs::~AttachArgs() {}
-//------------------------------------------------------------------------------
/// The basic design of the ProcessMonitor is built around two threads.
///
/// One thread (@see SignalThread) simply blocks on a call to waitpid()
@@ -729,7 +708,7 @@ ProcessMonitor::ProcessMonitor(
const lldb_private::ProcessLaunchInfo & /* launch_info */,
lldb_private::Status &error)
: m_process(static_cast<ProcessFreeBSD *>(process)),
- m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
+ m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(LLDB_INVALID_PROCESS_ID), m_terminal_fd(-1), m_operation(0) {
using namespace std::placeholders;
std::unique_ptr<LaunchArgs> args(
@@ -759,7 +738,7 @@ ProcessMonitor::ProcessMonitor(
m_monitor_thread = Host::StartMonitoringChildProcess(
std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
GetPID(), true);
- if (!m_monitor_thread.IsJoinable()) {
+ if (!m_monitor_thread->IsJoinable()) {
error.SetErrorToGenericError();
error.SetErrorString("Process launch failed.");
return;
@@ -768,8 +747,8 @@ ProcessMonitor::ProcessMonitor(
ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
lldb_private::Status &error)
- : m_process(static_cast<ProcessFreeBSD *>(process)), m_pid(pid),
- m_terminal_fd(-1), m_operation(0) {
+ : m_process(static_cast<ProcessFreeBSD *>(process)),
+ m_operation_thread(nullptr), m_monitor_thread(nullptr), m_pid(pid), m_terminal_fd(-1), m_operation(0) {
using namespace std::placeholders;
sem_init(&m_operation_pending, 0, 0);
@@ -797,7 +776,7 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
m_monitor_thread = Host::StartMonitoringChildProcess(
std::bind(&ProcessMonitor::MonitorCallback, this, _1, _2, _3, _4),
GetPID(), true);
- if (!m_monitor_thread.IsJoinable()) {
+ if (!m_monitor_thread->IsJoinable()) {
error.SetErrorToGenericError();
error.SetErrorString("Process attach failed.");
return;
@@ -806,16 +785,17 @@ ProcessMonitor::ProcessMonitor(ProcessFreeBSD *process, lldb::pid_t pid,
ProcessMonitor::~ProcessMonitor() { StopMonitor(); }
-//------------------------------------------------------------------------------
// Thread setup and tear down.
void ProcessMonitor::StartLaunchOpThread(LaunchArgs *args, Status &error) {
static const char *g_thread_name = "lldb.process.freebsd.operation";
- if (m_operation_thread.IsJoinable())
+ if (m_operation_thread->IsJoinable())
return;
m_operation_thread =
- ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args, &error);
+ ThreadLauncher::LaunchThread(g_thread_name, LaunchOpThread, args);
+ if (!m_operation_thread)
+ error = m_operation_thread.takeError();
}
void *ProcessMonitor::LaunchOpThread(void *arg) {
@@ -977,11 +957,14 @@ void ProcessMonitor::StartAttachOpThread(AttachArgs *args,
lldb_private::Status &error) {
static const char *g_thread_name = "lldb.process.freebsd.operation";
- if (m_operation_thread.IsJoinable())
+ if (m_operation_thread->IsJoinable())
return;
m_operation_thread =
- ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args, &error);
+ ThreadLauncher::LaunchThread(g_thread_name, AttachOpThread, args);
+
+ if (!m_operation_thread)
+ error = m_operation_thread.takeError();
}
void *ProcessMonitor::AttachOpThread(void *arg) {
@@ -1388,7 +1371,8 @@ lldb_private::Status ProcessMonitor::Detach(lldb::tid_t tid) {
bool ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd,
int flags) {
- int target_fd = open(file_spec.GetCString(), flags, 0666);
+ int target_fd = llvm::sys::RetryAfterSignal(-1, open,
+ file_spec.GetCString(), flags, 0666);
if (target_fd == -1)
return false;
@@ -1400,10 +1384,10 @@ bool ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd,
}
void ProcessMonitor::StopMonitoringChildProcess() {
- if (m_monitor_thread.IsJoinable()) {
- m_monitor_thread.Cancel();
- m_monitor_thread.Join(nullptr);
- m_monitor_thread.Reset();
+ if (m_monitor_thread->IsJoinable()) {
+ m_monitor_thread->Cancel();
+ m_monitor_thread->Join(nullptr);
+ m_monitor_thread->Reset();
}
}
@@ -1438,10 +1422,10 @@ void ProcessMonitor::StopMonitor() {
bool ProcessMonitor::WaitForInitialTIDStop(lldb::tid_t tid) { return true; }
void ProcessMonitor::StopOpThread() {
- if (!m_operation_thread.IsJoinable())
+ if (!m_operation_thread->IsJoinable())
return;
- m_operation_thread.Cancel();
- m_operation_thread.Join(nullptr);
- m_operation_thread.Reset();
+ m_operation_thread->Cancel();
+ m_operation_thread->Join(nullptr);
+ m_operation_thread->Reset();
}
diff --git a/source/Plugins/Process/FreeBSD/ProcessMonitor.h b/source/Plugins/Process/FreeBSD/ProcessMonitor.h
index ca7c4e03966c8..2adcc449c5c63 100644
--- a/source/Plugins/Process/FreeBSD/ProcessMonitor.h
+++ b/source/Plugins/Process/FreeBSD/ProcessMonitor.h
@@ -1,9 +1,8 @@
//===-- ProcessMonitor.h -------------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,7 +27,7 @@ class Scalar;
class ProcessFreeBSD;
class Operation;
-/// @class ProcessMonitor
+/// \class ProcessMonitor
/// Manages communication with the inferior (debugee) process.
///
/// Upon construction, this class prepares and launches an inferior process
@@ -77,14 +76,14 @@ public:
/// -1.
int GetTerminalFD() const { return m_terminal_fd; }
- /// Reads @p size bytes from address @vm_adder in the inferior process
+ /// Reads \p size bytes from address @vm_adder in the inferior process
/// address space.
///
/// This method is provided to implement Process::DoReadMemory.
size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
lldb_private::Status &error);
- /// Writes @p size bytes from address @p vm_adder in the inferior process
+ /// Writes \p size bytes from address \p vm_adder in the inferior process
/// address space.
///
/// This method is provided to implement Process::DoWriteMemory.
@@ -152,7 +151,7 @@ public:
size_t GetCurrentThreadIDs(std::vector<lldb::tid_t> &thread_ids);
/// Writes a ptrace_lwpinfo structure corresponding to the given thread ID
- /// to the memory region pointed to by @p lwpinfo.
+ /// to the memory region pointed to by \p lwpinfo.
bool GetLwpInfo(lldb::tid_t tid, void *lwpinfo, int &error_no);
/// Suspends or unsuspends a thread prior to process resume or step.
@@ -163,11 +162,11 @@ public:
/// message.
bool GetEventMessage(lldb::tid_t tid, unsigned long *message);
- /// Resumes the process. If @p signo is anything but
+ /// Resumes the process. If \p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process.
bool Resume(lldb::tid_t unused, uint32_t signo);
- /// Single steps the process. If @p signo is anything but
+ /// Single steps the process. If \p signo is anything but
/// LLDB_INVALID_SIGNAL_NUMBER, deliver that signal to the process.
bool SingleStep(lldb::tid_t unused, uint32_t signo);
@@ -184,8 +183,8 @@ public:
private:
ProcessFreeBSD *m_process;
- lldb_private::HostThread m_operation_thread;
- lldb_private::HostThread m_monitor_thread;
+ llvm::Expected<lldb_private::HostThread> m_operation_thread;
+ llvm::Expected<lldb_private::HostThread> m_monitor_thread;
lldb::pid_t m_pid;
int m_terminal_fd;
@@ -209,7 +208,7 @@ private:
lldb_private::Status m_error; // Set if process operation failed.
};
- /// @class LauchArgs
+ /// \class LauchArgs
///
/// Simple structure to pass data to the thread responsible for launching a
/// child process.
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h
index 32973abd9207a..cf52a065232cf 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIX.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,8 +13,7 @@
#include "lldb/Target/RegisterContext.h"
#include "lldb/Utility/ArchSpec.h"
-//------------------------------------------------------------------------------
-/// @class POSIXBreakpointProtocol
+/// \class POSIXBreakpointProtocol
///
/// Extends RegisterClass with a few virtual operations useful on POSIX.
class POSIXBreakpointProtocol {
@@ -28,7 +26,7 @@ public:
/// implementation simply returns true for architectures which do not
/// require any update.
///
- /// @return
+ /// \return
/// True if the operation succeeded and false otherwise.
virtual bool UpdateAfterBreakpoint() = 0;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
index 0642a30ade700..f0c4526357cc6 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_arm.cpp -----------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -156,7 +155,7 @@ bool RegisterContextPOSIXProcessMonitor_arm::ReadAllRegisterValues(
DataBufferSP &data_sp) {
bool success = false;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR() && ReadFPR()) {
+ if (ReadGPR() && ReadFPR()) {
uint8_t *dst = data_sp->GetBytes();
success = dst != 0;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h
index 6aa71c24f1cda..b376967df99ce 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_arm.h --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
index b35ee18d6a965..147f4b56a8040 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_arm64.cpp -----------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -165,7 +164,7 @@ bool RegisterContextPOSIXProcessMonitor_arm64::ReadAllRegisterValues(
lldb::DataBufferSP &data_sp) {
bool success = false;
data_sp.reset(new lldb_private::DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR() && ReadFPR()) {
+ if (ReadGPR() && ReadFPR()) {
uint8_t *dst = data_sp->GetBytes();
success = dst != 0;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
index 8591c83be5415..d54d34e89cad2 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_arm64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_arm64.h --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
index 17df44cf85ee0..db9b5a6a038cb 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_mips64.cpp -----------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -161,7 +160,7 @@ bool RegisterContextPOSIXProcessMonitor_mips64::ReadAllRegisterValues(
DataBufferSP &data_sp) {
bool success = false;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR() && ReadFPR()) {
+ if (ReadGPR() && ReadFPR()) {
uint8_t *dst = data_sp->GetBytes();
success = dst != 0;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
index 6f57b0d9cd652..a482cd3f1e1c3 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_mips64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_mips64.h -------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
index a8d75963ea6b0..77694733fa395 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_powerpc.cpp ----------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -171,7 +170,7 @@ bool RegisterContextPOSIXProcessMonitor_powerpc::ReadAllRegisterValues(
DataBufferSP &data_sp) {
bool success = false;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR() && ReadFPR()) {
+ if (ReadGPR() && ReadFPR()) {
uint8_t *dst = data_sp->GetBytes();
success = dst != 0;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h
index 188ddea7d4736..17b649feebf1f 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_powerpc.h
@@ -1,10 +1,9 @@
//===-- RegisterContextPOSIXProcessMonitor_powerpc.h -------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
index 68fd5ac13bb0b..3046d97f153c9 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_x86.cpp --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -345,7 +344,7 @@ bool RegisterContextPOSIXProcessMonitor_x86_64::ReadAllRegisterValues(
DataBufferSP &data_sp) {
bool success = false;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR() && ReadFPR()) {
+ if (ReadGPR() && ReadFPR()) {
uint8_t *dst = data_sp->GetBytes();
success = dst != 0;
diff --git a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h
index 8c654f97dcd9f..c9dc02a88e015 100644
--- a/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h
+++ b/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXProcessMonitor_x86.h ----------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index a1b7d7df4553c..32d20d2b1215d 100644
--- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -1,9 +1,8 @@
//===-- NativeProcessNetBSD.cpp ------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -55,9 +54,7 @@ static Status EnsureFDFlags(int fd, int flags) {
return error;
}
-// -----------------------------------------------------------------------------
// Public Static Methods
-// -----------------------------------------------------------------------------
llvm::Expected<std::unique_ptr<NativeProcessProtocol>>
NativeProcessNetBSD::Factory::Launch(ProcessLaunchInfo &launch_info,
@@ -137,9 +134,7 @@ NativeProcessNetBSD::Factory::Attach(
return std::move(process_up);
}
-// -----------------------------------------------------------------------------
// Public Instance Methods
-// -----------------------------------------------------------------------------
NativeProcessNetBSD::NativeProcessNetBSD(::pid_t pid, int terminal_fd,
NativeDelegate &delegate,
@@ -243,12 +238,25 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
SetState(StateType::eStateStopped, true);
} break;
case TRAP_DBREG: {
+ // Find the thread.
+ NativeThreadNetBSD* thread = nullptr;
+ for (const auto &t : m_threads) {
+ if (t->GetID() == info.psi_lwpid) {
+ thread = static_cast<NativeThreadNetBSD *>(t.get());
+ break;
+ }
+ }
+ if (!thread) {
+ LLDB_LOG(log,
+ "thread not found in m_threads, pid = {0}, LWP = {1}",
+ GetID(), info.psi_lwpid);
+ break;
+ }
+
// If a watchpoint was hit, report it
- uint32_t wp_index;
- Status error = static_cast<NativeThreadNetBSD &>(*m_threads[info.psi_lwpid])
- .GetRegisterContext()
- .GetWatchpointHitIndex(
- wp_index, (uintptr_t)info.psi_siginfo.si_addr);
+ uint32_t wp_index = LLDB_INVALID_INDEX32;
+ Status error = thread->GetRegisterContext().GetWatchpointHitIndex(
+ wp_index, (uintptr_t)info.psi_siginfo.si_addr);
if (error.Fail())
LLDB_LOG(log,
"received error while checking for watchpoint hits, pid = "
@@ -263,11 +271,9 @@ void NativeProcessNetBSD::MonitorSIGTRAP(lldb::pid_t pid) {
}
// If a breakpoint was hit, report it
- uint32_t bp_index;
- error = static_cast<NativeThreadNetBSD &>(*m_threads[info.psi_lwpid])
- .GetRegisterContext()
- .GetHardwareBreakHitIndex(bp_index,
- (uintptr_t)info.psi_siginfo.si_addr);
+ uint32_t bp_index = LLDB_INVALID_INDEX32;
+ error = thread->GetRegisterContext().GetHardwareBreakHitIndex(
+ bp_index, (uintptr_t)info.psi_siginfo.si_addr);
if (error.Fail())
LLDB_LOG(log,
"received error while checking for hardware "
@@ -666,7 +672,8 @@ Status NativeProcessNetBSD::Attach() {
int wstatus;
// Need to use WALLSIG otherwise we receive an error with errno=ECHLD At this
// point we should have a thread stopped if waitpid succeeds.
- if ((wstatus = waitpid(m_pid, NULL, WALLSIG)) < 0)
+ if ((wstatus = llvm::sys::RetryAfterSignal(-1, waitpid,
+ m_pid, nullptr, WALLSIG)) < 0)
return Status(errno, eErrorTypePOSIX);
/* Initialize threads */
@@ -699,10 +706,10 @@ Status NativeProcessNetBSD::ReadMemory(lldb::addr_t addr, void *buf,
io.piod_addr = dst + bytes_read;
Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
- if (error.Fail())
+ if (error.Fail() || io.piod_len == 0)
return error;
- bytes_read = io.piod_len;
+ bytes_read += io.piod_len;
io.piod_len = size - bytes_read;
} while (bytes_read < size);
@@ -727,10 +734,10 @@ Status NativeProcessNetBSD::WriteMemory(lldb::addr_t addr, const void *buf,
io.piod_offs = (void *)(addr + bytes_written);
Status error = NativeProcessNetBSD::PtraceWrapper(PT_IO, GetID(), &io);
- if (error.Fail())
+ if (error.Fail() || io.piod_len == 0)
return error;
- bytes_written = io.piod_len;
+ bytes_written += io.piod_len;
io.piod_len = size - bytes_written;
} while (bytes_written < size);
diff --git a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
index a3f1c4c6a06a3..e85ca3b7a9250 100644
--- a/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
+++ b/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
@@ -1,9 +1,8 @@
//===-- NativeProcessNetBSD.h --------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,7 +18,7 @@
namespace lldb_private {
namespace process_netbsd {
-/// @class NativeProcessNetBSD
+/// \class NativeProcessNetBSD
/// Manages communication with the inferior (debugee) process.
///
/// Upon construction, this class prepares and launches an inferior process
@@ -39,9 +38,7 @@ public:
MainLoop &mainloop) const override;
};
- // ---------------------------------------------------------------------
// NativeProcessProtocol Interface
- // ---------------------------------------------------------------------
Status Resume(const ResumeActionList &resume_actions) override;
Status Halt() override;
@@ -84,9 +81,7 @@ public:
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
GetAuxvData() const override;
- // ---------------------------------------------------------------------
// Interface used by NativeRegisterContext-derived classes.
- // ---------------------------------------------------------------------
static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
int data = 0, int *result = nullptr);
@@ -96,9 +91,7 @@ private:
LazyBool m_supports_mem_region = eLazyBoolCalculate;
std::vector<std::pair<MemoryRegionInfo, FileSpec>> m_mem_region_cache;
- // ---------------------------------------------------------------------
// Private Instance Methods
- // ---------------------------------------------------------------------
NativeProcessNetBSD(::pid_t pid, int terminal_fd, NativeDelegate &delegate,
const ArchSpec &arch, MainLoop &mainloop);
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
index d4fef6342439d..3a9caaad74c86 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
@@ -1,9 +1,8 @@
//===-- NativeRegisterContextNetBSD.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,81 +24,8 @@ NativeRegisterContextNetBSD::NativeRegisterContextNetBSD(
: NativeRegisterContextRegisterInfo(native_thread,
reg_info_interface_p) {}
-Status NativeRegisterContextNetBSD::ReadGPR() {
- void *buf = GetGPRBuffer();
- if (!buf)
- return Status("GPR buffer is NULL");
-
- return DoReadGPR(buf);
-}
-
-Status NativeRegisterContextNetBSD::WriteGPR() {
- void *buf = GetGPRBuffer();
- if (!buf)
- return Status("GPR buffer is NULL");
-
- return DoWriteGPR(buf);
-}
-
-Status NativeRegisterContextNetBSD::ReadFPR() {
- void *buf = GetFPRBuffer();
- if (!buf)
- return Status("FPR buffer is NULL");
-
- return DoReadFPR(buf);
-}
-
-Status NativeRegisterContextNetBSD::WriteFPR() {
- void *buf = GetFPRBuffer();
- if (!buf)
- return Status("FPR buffer is NULL");
-
- return DoWriteFPR(buf);
-}
-
-Status NativeRegisterContextNetBSD::ReadDBR() {
- void *buf = GetDBRBuffer();
- if (!buf)
- return Status("DBR buffer is NULL");
-
- return DoReadDBR(buf);
-}
-
-Status NativeRegisterContextNetBSD::WriteDBR() {
- void *buf = GetDBRBuffer();
- if (!buf)
- return Status("DBR buffer is NULL");
-
- return DoWriteDBR(buf);
-}
-
-Status NativeRegisterContextNetBSD::DoReadGPR(void *buf) {
- return NativeProcessNetBSD::PtraceWrapper(PT_GETREGS, GetProcessPid(), buf,
- m_thread.GetID());
-}
-
-Status NativeRegisterContextNetBSD::DoWriteGPR(void *buf) {
- return NativeProcessNetBSD::PtraceWrapper(PT_SETREGS, GetProcessPid(), buf,
- m_thread.GetID());
-}
-
-Status NativeRegisterContextNetBSD::DoReadFPR(void *buf) {
- return NativeProcessNetBSD::PtraceWrapper(PT_GETFPREGS, GetProcessPid(), buf,
- m_thread.GetID());
-}
-
-Status NativeRegisterContextNetBSD::DoWriteFPR(void *buf) {
- return NativeProcessNetBSD::PtraceWrapper(PT_SETFPREGS, GetProcessPid(), buf,
- m_thread.GetID());
-}
-
-Status NativeRegisterContextNetBSD::DoReadDBR(void *buf) {
- return NativeProcessNetBSD::PtraceWrapper(PT_GETDBREGS, GetProcessPid(), buf,
- m_thread.GetID());
-}
-
-Status NativeRegisterContextNetBSD::DoWriteDBR(void *buf) {
- return NativeProcessNetBSD::PtraceWrapper(PT_SETDBREGS, GetProcessPid(), buf,
+Status NativeRegisterContextNetBSD::DoRegisterSet(int ptrace_req, void *buf) {
+ return NativeProcessNetBSD::PtraceWrapper(ptrace_req, GetProcessPid(), buf,
m_thread.GetID());
}
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
index b81430e7f5acf..f5dd0c33b6778 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
@@ -1,9 +1,8 @@
//===-- NativeRegisterContextNetBSD.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,35 +32,7 @@ public:
NativeThreadProtocol &native_thread);
protected:
- virtual Status ReadGPR();
- virtual Status WriteGPR();
-
- virtual Status ReadFPR();
- virtual Status WriteFPR();
-
- virtual Status ReadDBR();
- virtual Status WriteDBR();
-
- virtual void *GetGPRBuffer() { return nullptr; }
- virtual size_t GetGPRSize() {
- return GetRegisterInfoInterface().GetGPRSize();
- }
-
- virtual void *GetFPRBuffer() { return nullptr; }
- virtual size_t GetFPRSize() { return 0; }
-
- virtual void *GetDBRBuffer() { return nullptr; }
- virtual size_t GetDBRSize() { return 0; }
-
- virtual Status DoReadGPR(void *buf);
- virtual Status DoWriteGPR(void *buf);
-
- virtual Status DoReadFPR(void *buf);
- virtual Status DoWriteFPR(void *buf);
-
- virtual Status DoReadDBR(void *buf);
- virtual Status DoWriteDBR(void *buf);
-
+ Status DoRegisterSet(int req, void *buf);
virtual NativeProcessNetBSD &GetProcess();
virtual ::pid_t GetProcessPid();
};
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
index 78da3527122f8..a7cd637bf826b 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- NativeRegisterContextNetBSD_x86_64.cpp ---------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,8 +20,12 @@
// clang-format off
#include <sys/types.h>
+#include <sys/ptrace.h>
#include <sys/sysctl.h>
+#include <sys/uio.h>
#include <x86/cpu.h>
+#include <x86/cpu_extended_state.h>
+#include <x86/specialreg.h>
#include <elf.h>
#include <err.h>
#include <stdint.h>
@@ -32,9 +35,7 @@
using namespace lldb_private;
using namespace lldb_private::process_netbsd;
-// ----------------------------------------------------------------------------
// Private namespace.
-// ----------------------------------------------------------------------------
namespace {
// x86 64-bit general purpose registers.
@@ -93,58 +94,6 @@ static const RegisterSet g_reg_sets_x86_64[k_num_register_sets] = {
};
#define REG_CONTEXT_SIZE (GetRegisterInfoInterface().GetGPRSize())
-
-const int fpu_present = []() -> int {
- int mib[2];
- int error;
- size_t len;
- int val;
-
- len = sizeof(val);
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_FPU_PRESENT;
-
- error = sysctl(mib, __arraycount(mib), &val, &len, NULL, 0);
- if (error)
- errx(EXIT_FAILURE, "sysctl");
-
- return val;
-}();
-
-const int osfxsr = []() -> int {
- int mib[2];
- int error;
- size_t len;
- int val;
-
- len = sizeof(val);
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_OSFXSR;
-
- error = sysctl(mib, __arraycount(mib), &val, &len, NULL, 0);
- if (error)
- errx(EXIT_FAILURE, "sysctl");
-
- return val;
-}();
-
-const int fpu_save = []() -> int {
- int mib[2];
- int error;
- size_t len;
- int val;
-
- len = sizeof(val);
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_FPU_SAVE;
-
- error = sysctl(mib, __arraycount(mib), &val, &len, NULL, 0);
- if (error)
- errx(EXIT_FAILURE, "sysctl");
-
- return val;
-}();
-
} // namespace
NativeRegisterContextNetBSD *
@@ -153,9 +102,7 @@ NativeRegisterContextNetBSD::CreateHostNativeRegisterContextNetBSD(
return new NativeRegisterContextNetBSD_x86_64(target_arch, native_thread);
}
-// ----------------------------------------------------------------------------
// NativeRegisterContextNetBSD_x86_64 members.
-// ----------------------------------------------------------------------------
static RegisterInfoInterface *
CreateRegisterInfoInterface(const ArchSpec &target_arch) {
@@ -202,9 +149,9 @@ int NativeRegisterContextNetBSD_x86_64::GetSetForNativeRegNum(
if (reg_num <= k_last_gpr_x86_64)
return GPRegSet;
else if (reg_num <= k_last_fpr_x86_64)
- return (fpu_present == 1 && osfxsr == 1 && fpu_save >= 1) ? FPRegSet : -1;
+ return FPRegSet;
else if (reg_num <= k_last_avx_x86_64)
- return -1; // AVX
+ return XStateRegSet; // AVX
else if (reg_num <= k_last_mpxr_x86_64)
return -1; // MPXR
else if (reg_num <= k_last_mpxc_x86_64)
@@ -215,37 +162,46 @@ int NativeRegisterContextNetBSD_x86_64::GetSetForNativeRegNum(
return -1;
}
-int NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
+Status NativeRegisterContextNetBSD_x86_64::ReadRegisterSet(uint32_t set) {
switch (set) {
case GPRegSet:
- ReadGPR();
- return 0;
+ return DoRegisterSet(PT_GETREGS, &m_gpr_x86_64);
case FPRegSet:
- ReadFPR();
- return 0;
+ return DoRegisterSet(PT_GETFPREGS, &m_fpr_x86_64);
case DBRegSet:
- ReadDBR();
- return 0;
- default:
- break;
+ return DoRegisterSet(PT_GETDBREGS, &m_dbr_x86_64);
+ case XStateRegSet:
+#ifdef HAVE_XSTATE
+ {
+ struct iovec iov = {&m_xstate_x86_64, sizeof(m_xstate_x86_64)};
+ return DoRegisterSet(PT_GETXSTATE, &iov);
+ }
+#else
+ return Status("XState is not supported by the kernel");
+#endif
}
- return -1;
+ llvm_unreachable("NativeRegisterContextNetBSD_x86_64::ReadRegisterSet");
}
-int NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
+
+Status NativeRegisterContextNetBSD_x86_64::WriteRegisterSet(uint32_t set) {
switch (set) {
case GPRegSet:
- WriteGPR();
- return 0;
+ return DoRegisterSet(PT_SETREGS, &m_gpr_x86_64);
case FPRegSet:
- WriteFPR();
- return 0;
+ return DoRegisterSet(PT_SETFPREGS, &m_fpr_x86_64);
case DBRegSet:
- WriteDBR();
- return 0;
- default:
- break;
+ return DoRegisterSet(PT_SETDBREGS, &m_dbr_x86_64);
+ case XStateRegSet:
+#ifdef HAVE_XSTATE
+ {
+ struct iovec iov = {&m_xstate_x86_64, sizeof(m_xstate_x86_64)};
+ return DoRegisterSet(PT_SETXSTATE, &iov);
+ }
+#else
+ return Status("XState is not supported by the kernel");
+#endif
}
- return -1;
+ llvm_unreachable("NativeRegisterContextNetBSD_x86_64::WriteRegisterSet");
}
Status
@@ -277,13 +233,9 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
return error;
}
- if (ReadRegisterSet(set) != 0) {
- // This is likely an internal register for lldb use only and should not be
- // directly queried.
- error.SetErrorStringWithFormat(
- "reading register set for register \"%s\" failed", reg_info->name);
+ error = ReadRegisterSet(set);
+ if (error.Fail())
return error;
- }
switch (reg) {
case lldb_rax_x86_64:
@@ -407,7 +359,7 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
case lldb_mm5_x86_64:
case lldb_mm6_x86_64:
case lldb_mm7_x86_64:
- reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_mm0_x86_64],
+ reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_87_ac[reg - lldb_mm0_x86_64],
reg_info->byte_size, endian::InlHostByteOrder());
break;
case lldb_xmm0_x86_64:
@@ -429,6 +381,39 @@ NativeRegisterContextNetBSD_x86_64::ReadRegister(const RegisterInfo *reg_info,
reg_value.SetBytes(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_xmm0_x86_64],
reg_info->byte_size, endian::InlHostByteOrder());
break;
+ case lldb_ymm0_x86_64:
+ case lldb_ymm1_x86_64:
+ case lldb_ymm2_x86_64:
+ case lldb_ymm3_x86_64:
+ case lldb_ymm4_x86_64:
+ case lldb_ymm5_x86_64:
+ case lldb_ymm6_x86_64:
+ case lldb_ymm7_x86_64:
+ case lldb_ymm8_x86_64:
+ case lldb_ymm9_x86_64:
+ case lldb_ymm10_x86_64:
+ case lldb_ymm11_x86_64:
+ case lldb_ymm12_x86_64:
+ case lldb_ymm13_x86_64:
+ case lldb_ymm14_x86_64:
+ case lldb_ymm15_x86_64:
+#ifdef HAVE_XSTATE
+ if (!(m_xstate_x86_64.xs_rfbm & XCR0_SSE) ||
+ !(m_xstate_x86_64.xs_rfbm & XCR0_YMM_Hi128)) {
+ error.SetErrorStringWithFormat("register \"%s\" not supported by CPU/kernel",
+ reg_info->name);
+ } else {
+ uint32_t reg_index = reg - lldb_ymm0_x86_64;
+ YMMReg ymm = XStateToYMM(
+ m_xstate_x86_64.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
+ m_xstate_x86_64.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+ reg_value.SetBytes(ymm.bytes, reg_info->byte_size,
+ endian::InlHostByteOrder());
+ }
+#else
+ error.SetErrorString("XState queries not supported by the kernel");
+#endif
+ break;
case lldb_dr0_x86_64:
case lldb_dr1_x86_64:
case lldb_dr2_x86_64:
@@ -473,13 +458,9 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
return error;
}
- if (ReadRegisterSet(set) != 0) {
- // This is likely an internal register for lldb use only and should not be
- // directly queried.
- error.SetErrorStringWithFormat(
- "reading register set for register \"%s\" failed", reg_info->name);
+ error = ReadRegisterSet(set);
+ if (error.Fail())
return error;
- }
switch (reg) {
case lldb_rax_x86_64:
@@ -603,7 +584,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
case lldb_mm5_x86_64:
case lldb_mm6_x86_64:
case lldb_mm7_x86_64:
- ::memcpy(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_mm0_x86_64],
+ ::memcpy(&m_fpr_x86_64.fxstate.fx_87_ac[reg - lldb_mm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
break;
case lldb_xmm0_x86_64:
@@ -625,6 +606,39 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
::memcpy(&m_fpr_x86_64.fxstate.fx_xmm[reg - lldb_xmm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
break;
+ case lldb_ymm0_x86_64:
+ case lldb_ymm1_x86_64:
+ case lldb_ymm2_x86_64:
+ case lldb_ymm3_x86_64:
+ case lldb_ymm4_x86_64:
+ case lldb_ymm5_x86_64:
+ case lldb_ymm6_x86_64:
+ case lldb_ymm7_x86_64:
+ case lldb_ymm8_x86_64:
+ case lldb_ymm9_x86_64:
+ case lldb_ymm10_x86_64:
+ case lldb_ymm11_x86_64:
+ case lldb_ymm12_x86_64:
+ case lldb_ymm13_x86_64:
+ case lldb_ymm14_x86_64:
+ case lldb_ymm15_x86_64:
+#ifdef HAVE_XSTATE
+ if (!(m_xstate_x86_64.xs_rfbm & XCR0_SSE) ||
+ !(m_xstate_x86_64.xs_rfbm & XCR0_YMM_Hi128)) {
+ error.SetErrorStringWithFormat("register \"%s\" not supported by CPU/kernel",
+ reg_info->name);
+ } else {
+ uint32_t reg_index = reg - lldb_ymm0_x86_64;
+ YMMReg ymm;
+ ::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize());
+ YMMToXState(ymm,
+ m_xstate_x86_64.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
+ m_xstate_x86_64.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+ }
+#else
+ error.SetErrorString("XState not supported by the kernel");
+#endif
+ break;
case lldb_dr0_x86_64:
case lldb_dr1_x86_64:
case lldb_dr2_x86_64:
@@ -637,10 +651,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
break;
}
- if (WriteRegisterSet(set) != 0)
- error.SetErrorStringWithFormat("failed to write register set");
-
- return error;
+ return WriteRegisterSet(set);
}
Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
@@ -648,25 +659,11 @@ Status NativeRegisterContextNetBSD_x86_64::ReadAllRegisterValues(
Status error;
data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (!data_sp) {
- error.SetErrorStringWithFormat(
- "failed to allocate DataBufferHeap instance of size %" PRIu64,
- REG_CONTEXT_SIZE);
- return error;
- }
-
- error = ReadGPR();
+ error = ReadRegisterSet(GPRegSet);
if (error.Fail())
return error;
uint8_t *dst = data_sp->GetBytes();
- if (dst == nullptr) {
- error.SetErrorStringWithFormat("DataBufferHeap instance of size %" PRIu64
- " returned a null pointer",
- REG_CONTEXT_SIZE);
- return error;
- }
-
::memcpy(dst, &m_gpr_x86_64, GetRegisterInfoInterface().GetGPRSize());
dst += GetRegisterInfoInterface().GetGPRSize();
@@ -707,7 +704,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteAllRegisterValues(
}
::memcpy(&m_gpr_x86_64, src, GetRegisterInfoInterface().GetGPRSize());
- error = WriteGPR();
+ error = WriteRegisterSet(GPRegSet);
if (error.Fail())
return error;
src += GetRegisterInfoInterface().GetGPRSize();
@@ -767,7 +764,7 @@ Status NativeRegisterContextNetBSD_x86_64::IsWatchpointVacant(uint32_t wp_index,
uint64_t control_bits = reg_value.GetAsUInt64();
- is_vacant = !(control_bits & (1 << (2 * wp_index)));
+ is_vacant = !(control_bits & (1 << (2 * wp_index + 1)));
return error;
}
@@ -806,7 +803,7 @@ Status NativeRegisterContextNetBSD_x86_64::SetHardwareWatchpointWithIndex(
return error;
// for watchpoints 0, 1, 2, or 3, respectively, set bits 1, 3, 5, or 7
- uint64_t enable_bit = 1 << (2 * wp_index);
+ uint64_t enable_bit = 1 << (2 * wp_index + 1);
// set bits 16-17, 20-21, 24-25, or 28-29
// with 0b01 for write, and 0b11 for read/write
diff --git a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
index c55ddfec66156..0fed16542a953 100644
--- a/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
+++ b/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
@@ -1,9 +1,8 @@
//===-- NativeRegisterContextNetBSD_x86_64.h --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,6 +14,7 @@
// clang-format off
#include <sys/param.h>
#include <sys/types.h>
+#include <sys/ptrace.h>
#include <machine/reg.h>
// clang-format on
@@ -22,6 +22,10 @@
#include "Plugins/Process/Utility/RegisterContext_x86.h"
#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
+#if defined(PT_GETXSTATE) && defined(PT_SETXSTATE)
+#define HAVE_XSTATE
+#endif
+
namespace lldb_private {
namespace process_netbsd {
@@ -67,24 +71,22 @@ public:
uint32_t NumSupportedHardwareWatchpoints() override;
-protected:
- void *GetGPRBuffer() override { return &m_gpr_x86_64; }
- void *GetFPRBuffer() override { return &m_fpr_x86_64; }
- void *GetDBRBuffer() override { return &m_dbr_x86_64; }
-
private:
// Private member types.
- enum { GPRegSet, FPRegSet, DBRegSet };
+ enum { GPRegSet, FPRegSet, DBRegSet, XStateRegSet };
// Private member variables.
struct reg m_gpr_x86_64;
struct fpreg m_fpr_x86_64;
struct dbreg m_dbr_x86_64;
+#ifdef HAVE_XSTATE
+ struct xstate m_xstate_x86_64;
+#endif
int GetSetForNativeRegNum(int reg_num) const;
- int ReadRegisterSet(uint32_t set);
- int WriteRegisterSet(uint32_t set);
+ Status ReadRegisterSet(uint32_t set);
+ Status WriteRegisterSet(uint32_t set);
};
} // namespace process_netbsd
diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
index 6f5d1120e40da..e25975c93446e 100644
--- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
+++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
@@ -1,9 +1,8 @@
//===-- NativeThreadNetBSD.cpp -------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
index 72426244c1127..015d8995db34a 100644
--- a/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
+++ b/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
@@ -1,9 +1,8 @@
//===-- NativeThreadNetBSD.h ---------------------------------- -*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,9 +26,7 @@ class NativeThreadNetBSD : public NativeThreadProtocol {
public:
NativeThreadNetBSD(NativeProcessNetBSD &process, lldb::tid_t tid);
- // ---------------------------------------------------------------------
// NativeThreadProtocol Interface
- // ---------------------------------------------------------------------
std::string GetName() override;
lldb::StateType GetState() override;
@@ -49,9 +46,7 @@ public:
Status RemoveHardwareBreakpoint(lldb::addr_t addr) override;
private:
- // ---------------------------------------------------------------------
// Interface for friend classes
- // ---------------------------------------------------------------------
void SetStoppedBySignal(uint32_t signo, const siginfo_t *info = nullptr);
void SetStoppedByBreakpoint();
@@ -62,9 +57,7 @@ private:
void SetRunning();
void SetStepping();
- // ---------------------------------------------------------------------
// Member Variables
- // ---------------------------------------------------------------------
lldb::StateType m_state;
ThreadStopInfo m_stop_info;
std::unique_ptr<NativeRegisterContext> m_reg_context_up;
diff --git a/source/Plugins/Process/POSIX/CrashReason.cpp b/source/Plugins/Process/POSIX/CrashReason.cpp
index 4b24d31226a99..70c2687e3b8c0 100644
--- a/source/Plugins/Process/POSIX/CrashReason.cpp
+++ b/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -1,9 +1,8 @@
//===-- CrashReason.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/POSIX/CrashReason.h b/source/Plugins/Process/POSIX/CrashReason.h
index 57abe47b46b23..9b4784a1e68e1 100644
--- a/source/Plugins/Process/POSIX/CrashReason.h
+++ b/source/Plugins/Process/POSIX/CrashReason.h
@@ -1,9 +1,8 @@
//===-- CrashReason.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/POSIX/NativeProcessELF.cpp b/source/Plugins/Process/POSIX/NativeProcessELF.cpp
new file mode 100644
index 0000000000000..559b16c8fd692
--- /dev/null
+++ b/source/Plugins/Process/POSIX/NativeProcessELF.cpp
@@ -0,0 +1,110 @@
+//===-- NativeProcessELF.cpp ---------------------------------- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "NativeProcessELF.h"
+
+#include "lldb/Utility/DataExtractor.h"
+
+namespace lldb_private {
+
+llvm::Optional<uint64_t>
+NativeProcessELF::GetAuxValue(enum AuxVector::EntryType type) {
+ if (m_aux_vector == nullptr) {
+ auto buffer_or_error = GetAuxvData();
+ if (!buffer_or_error)
+ return llvm::None;
+ DataExtractor auxv_data(buffer_or_error.get()->getBufferStart(),
+ buffer_or_error.get()->getBufferSize(),
+ GetByteOrder(), GetAddressByteSize());
+ m_aux_vector = llvm::make_unique<AuxVector>(auxv_data);
+ }
+
+ return m_aux_vector->GetAuxValue(type);
+}
+
+lldb::addr_t NativeProcessELF::GetSharedLibraryInfoAddress() {
+ if (!m_shared_library_info_addr.hasValue()) {
+ if (GetAddressByteSize() == 8)
+ m_shared_library_info_addr =
+ GetELFImageInfoAddress<llvm::ELF::Elf64_Ehdr, llvm::ELF::Elf64_Phdr,
+ llvm::ELF::Elf64_Dyn>();
+ else
+ m_shared_library_info_addr =
+ GetELFImageInfoAddress<llvm::ELF::Elf32_Ehdr, llvm::ELF::Elf32_Phdr,
+ llvm::ELF::Elf32_Dyn>();
+ }
+
+ return m_shared_library_info_addr.getValue();
+}
+
+template <typename ELF_EHDR, typename ELF_PHDR, typename ELF_DYN>
+lldb::addr_t NativeProcessELF::GetELFImageInfoAddress() {
+ llvm::Optional<uint64_t> maybe_phdr_addr =
+ GetAuxValue(AuxVector::AUXV_AT_PHDR);
+ llvm::Optional<uint64_t> maybe_phdr_entry_size =
+ GetAuxValue(AuxVector::AUXV_AT_PHENT);
+ llvm::Optional<uint64_t> maybe_phdr_num_entries =
+ GetAuxValue(AuxVector::AUXV_AT_PHNUM);
+ if (!maybe_phdr_addr || !maybe_phdr_entry_size || !maybe_phdr_num_entries)
+ return LLDB_INVALID_ADDRESS;
+ lldb::addr_t phdr_addr = *maybe_phdr_addr;
+ size_t phdr_entry_size = *maybe_phdr_entry_size;
+ size_t phdr_num_entries = *maybe_phdr_num_entries;
+
+ // Find the PT_DYNAMIC segment (.dynamic section) in the program header and
+ // what the load bias by calculating the difference of the program header
+ // load address and its virtual address.
+ lldb::offset_t load_bias;
+ bool found_load_bias = false;
+ lldb::addr_t dynamic_section_addr = 0;
+ uint64_t dynamic_section_size = 0;
+ bool found_dynamic_section = false;
+ ELF_PHDR phdr_entry;
+ for (size_t i = 0; i < phdr_num_entries; i++) {
+ size_t bytes_read;
+ auto error = ReadMemory(phdr_addr + i * phdr_entry_size, &phdr_entry,
+ sizeof(phdr_entry), bytes_read);
+ if (!error.Success())
+ return LLDB_INVALID_ADDRESS;
+ if (phdr_entry.p_type == llvm::ELF::PT_PHDR) {
+ load_bias = phdr_addr - phdr_entry.p_vaddr;
+ found_load_bias = true;
+ }
+
+ if (phdr_entry.p_type == llvm::ELF::PT_DYNAMIC) {
+ dynamic_section_addr = phdr_entry.p_vaddr;
+ dynamic_section_size = phdr_entry.p_memsz;
+ found_dynamic_section = true;
+ }
+ }
+
+ if (!found_load_bias || !found_dynamic_section)
+ return LLDB_INVALID_ADDRESS;
+
+ // Find the DT_DEBUG entry in the .dynamic section
+ dynamic_section_addr += load_bias;
+ ELF_DYN dynamic_entry;
+ size_t dynamic_num_entries = dynamic_section_size / sizeof(dynamic_entry);
+ for (size_t i = 0; i < dynamic_num_entries; i++) {
+ size_t bytes_read;
+ auto error = ReadMemory(dynamic_section_addr + i * sizeof(dynamic_entry),
+ &dynamic_entry, sizeof(dynamic_entry), bytes_read);
+ if (!error.Success())
+ return LLDB_INVALID_ADDRESS;
+ // Return the &DT_DEBUG->d_ptr which points to r_debug which contains the
+ // link_map.
+ if (dynamic_entry.d_tag == llvm::ELF::DT_DEBUG) {
+ return dynamic_section_addr + i * sizeof(dynamic_entry) +
+ sizeof(dynamic_entry.d_tag);
+ }
+ }
+
+ return LLDB_INVALID_ADDRESS;
+}
+
+} // namespace lldb_private \ No newline at end of file
diff --git a/source/Plugins/Process/POSIX/NativeProcessELF.h b/source/Plugins/Process/POSIX/NativeProcessELF.h
new file mode 100644
index 0000000000000..84dc8d08a3406
--- /dev/null
+++ b/source/Plugins/Process/POSIX/NativeProcessELF.h
@@ -0,0 +1,46 @@
+//===-- NativeProcessELF.h ------------------------------------ -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_NativeProcessELF_H_
+#define liblldb_NativeProcessELF_H_
+
+#include "Plugins/Process/Utility/AuxVector.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+#include "llvm/BinaryFormat/ELF.h"
+
+namespace lldb_private {
+
+/// \class NativeProcessELF
+/// Abstract class that extends \a NativeProcessProtocol with ELF specific
+/// logic. Meant to be subclassed by ELF based NativeProcess* implementations.
+class NativeProcessELF : public NativeProcessProtocol {
+ using NativeProcessProtocol::NativeProcessProtocol;
+
+protected:
+ template <typename T> struct ELFLinkMap {
+ T l_addr;
+ T l_name;
+ T l_ld;
+ T l_next;
+ T l_prev;
+ };
+
+ llvm::Optional<uint64_t> GetAuxValue(enum AuxVector::EntryType type);
+
+ lldb::addr_t GetSharedLibraryInfoAddress() override;
+
+ template <typename ELF_EHDR, typename ELF_PHDR, typename ELF_DYN>
+ lldb::addr_t GetELFImageInfoAddress();
+
+ std::unique_ptr<AuxVector> m_aux_vector;
+ llvm::Optional<lldb::addr_t> m_shared_library_info_addr;
+};
+
+} // namespace lldb_private
+
+#endif \ No newline at end of file
diff --git a/source/Plugins/Process/POSIX/ProcessMessage.cpp b/source/Plugins/Process/POSIX/ProcessMessage.cpp
index 48f2a7844cf7a..aa8449131a689 100644
--- a/source/Plugins/Process/POSIX/ProcessMessage.cpp
+++ b/source/Plugins/Process/POSIX/ProcessMessage.cpp
@@ -1,9 +1,8 @@
//===-- ProcessMessage.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@ const char *ProcessMessage::PrintKind(Kind kind) {
chcar str[8];
sprintf(str, "%d", reason);
#else
- const char *str = NULL;
+ const char *str = nullptr;
switch (kind) {
case eInvalidMessage:
diff --git a/source/Plugins/Process/POSIX/ProcessMessage.h b/source/Plugins/Process/POSIX/ProcessMessage.h
index 3c596ca685497..d9c10caaa95e9 100644
--- a/source/Plugins/Process/POSIX/ProcessMessage.h
+++ b/source/Plugins/Process/POSIX/ProcessMessage.h
@@ -1,9 +1,8 @@
//===-- ProcessMessage.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -45,33 +44,33 @@ public:
lldb::tid_t GetTID() const { return m_tid; }
- /// Indicates that the process @p pid has successfully attached.
+ /// Indicates that the process \p pid has successfully attached.
static ProcessMessage Attach(lldb::pid_t pid) {
return ProcessMessage(pid, eAttachMessage);
}
- /// Indicates that the thread @p tid is about to exit with status @p status.
+ /// Indicates that the thread \p tid is about to exit with status \p status.
static ProcessMessage Limbo(lldb::tid_t tid, int status) {
return ProcessMessage(tid, eLimboMessage, status);
}
- /// Indicates that the thread @p tid had the signal @p signum delivered.
+ /// Indicates that the thread \p tid had the signal \p signum delivered.
static ProcessMessage Signal(lldb::tid_t tid, int signum) {
return ProcessMessage(tid, eSignalMessage, signum);
}
- /// Indicates that a signal @p signum generated by the debugging process was
- /// delivered to the thread @p tid.
+ /// Indicates that a signal \p signum generated by the debugging process was
+ /// delivered to the thread \p tid.
static ProcessMessage SignalDelivered(lldb::tid_t tid, int signum) {
return ProcessMessage(tid, eSignalDeliveredMessage, signum);
}
- /// Indicates that the thread @p tid encountered a trace point.
+ /// Indicates that the thread \p tid encountered a trace point.
static ProcessMessage Trace(lldb::tid_t tid) {
return ProcessMessage(tid, eTraceMessage);
}
- /// Indicates that the thread @p tid encountered a break point.
+ /// Indicates that the thread \p tid encountered a break point.
static ProcessMessage Break(lldb::tid_t tid) {
return ProcessMessage(tid, eBreakpointMessage);
}
@@ -80,7 +79,7 @@ public:
return ProcessMessage(tid, eWatchpointMessage, 0, wp_addr);
}
- /// Indicates that the thread @p tid crashed.
+ /// Indicates that the thread \p tid crashed.
static ProcessMessage Crash(lldb::pid_t pid, CrashReason reason, int signo,
lldb::addr_t fault_addr) {
ProcessMessage message(pid, eCrashMessage, signo, fault_addr);
@@ -88,18 +87,18 @@ public:
return message;
}
- /// Indicates that the thread @p child_tid was spawned.
+ /// Indicates that the thread \p child_tid was spawned.
static ProcessMessage NewThread(lldb::tid_t parent_tid,
lldb::tid_t child_tid) {
return ProcessMessage(parent_tid, eNewThreadMessage, child_tid);
}
- /// Indicates that the thread @p tid is about to exit with status @p status.
+ /// Indicates that the thread \p tid is about to exit with status \p status.
static ProcessMessage Exit(lldb::tid_t tid, int status) {
return ProcessMessage(tid, eExitMessage, status);
}
- /// Indicates that the thread @p pid has exec'd.
+ /// Indicates that the thread \p pid has exec'd.
static ProcessMessage Exec(lldb::tid_t tid) {
return ProcessMessage(tid, eExecMessage);
}
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
index f1beb0f7f7388..a17558bfe7c65 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
+++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.cpp
@@ -1,10 +1,9 @@
//===-- ProcessPOSIXLog.cpp ---------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
index 3ac798b3d4b3d..c0147c43410fb 100644
--- a/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
+++ b/source/Plugins/Process/POSIX/ProcessPOSIXLog.h
@@ -1,10 +1,9 @@
//===-- ProcessPOSIXLog.h -----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/ARMDefines.h b/source/Plugins/Process/Utility/ARMDefines.h
index 84c2cf19be7b1..1f7eb54d10e7c 100644
--- a/source/Plugins/Process/Utility/ARMDefines.h
+++ b/source/Plugins/Process/Utility/ARMDefines.h
@@ -1,15 +1,16 @@
-//===-- lldb_ARMDefines.h ---------------------------------------*- C++ -*-===//
+//===-- ARMDefines.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef lldb_ARMDefines_h_
#define lldb_ARMDefines_h_
+#include "llvm/Support/ErrorHandling.h"
+
#include <cassert>
#include <cstdint>
@@ -18,14 +19,14 @@
namespace lldb_private {
// ARM shifter types
-typedef enum {
+enum ARM_ShifterType {
SRType_LSL,
SRType_LSR,
SRType_ASR,
SRType_ROR,
SRType_RRX,
SRType_Invalid
-} ARM_ShifterType;
+};
// ARM conditions // Meaning (integer) Meaning (floating-point)
// Condition flags
@@ -69,8 +70,6 @@ typedef enum {
static inline const char *ARMCondCodeToString(uint32_t CC) {
switch (CC) {
- default:
- assert(0 && "Unknown condition code");
case COND_EQ:
return "eq";
case COND_NE:
@@ -102,6 +101,7 @@ static inline const char *ARMCondCodeToString(uint32_t CC) {
case COND_AL:
return "al";
}
+ llvm_unreachable("Unknown condition code");
}
static inline bool ARMConditionPassed(const uint32_t condition,
diff --git a/source/Plugins/Process/Utility/ARMUtils.h b/source/Plugins/Process/Utility/ARMUtils.h
index 2c14dc936cbc2..d860348818d33 100644
--- a/source/Plugins/Process/Utility/ARMUtils.h
+++ b/source/Plugins/Process/Utility/ARMUtils.h
@@ -1,9 +1,8 @@
//===-- ARMUtils.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/AuxVector.cpp b/source/Plugins/Process/Utility/AuxVector.cpp
new file mode 100644
index 0000000000000..aab164ff93a64
--- /dev/null
+++ b/source/Plugins/Process/Utility/AuxVector.cpp
@@ -0,0 +1,96 @@
+//===-- AuxVector.cpp -------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AuxVector.h"
+
+AuxVector::AuxVector(const lldb_private::DataExtractor &data) {
+ ParseAuxv(data);
+}
+
+void AuxVector::ParseAuxv(const lldb_private::DataExtractor &data) {
+ lldb::offset_t offset = 0;
+ const size_t value_type_size = data.GetAddressByteSize() * 2;
+ while (data.ValidOffsetForDataOfSize(offset, value_type_size)) {
+ // We're not reading an address but an int that could be 32 or 64 bit
+ // depending on the address size, which is what GetAddress does.
+ const uint64_t type = data.GetAddress(&offset);
+ const uint64_t value = data.GetAddress(&offset);
+ if (type == AUXV_AT_NULL)
+ break;
+ if (type == AUXV_AT_IGNORE)
+ continue;
+
+ m_auxv_entries[type] = value;
+ }
+}
+
+llvm::Optional<uint64_t>
+AuxVector::GetAuxValue(enum EntryType entry_type) const {
+ auto it = m_auxv_entries.find(static_cast<uint64_t>(entry_type));
+ if (it != m_auxv_entries.end())
+ return it->second;
+ return llvm::None;
+}
+
+void AuxVector::DumpToLog(lldb_private::Log *log) const {
+ if (!log)
+ return;
+
+ log->PutCString("AuxVector: ");
+ for (auto entry : m_auxv_entries) {
+ log->Printf(" %s [%" PRIu64 "]: %" PRIx64,
+ GetEntryName(static_cast<EntryType>(entry.first)), entry.first,
+ entry.second);
+ }
+}
+
+const char *AuxVector::GetEntryName(EntryType type) const {
+ const char *name = "AT_???";
+
+#define ENTRY_NAME(_type) \
+ _type: \
+ name = &#_type[5]
+ switch (type) {
+ case ENTRY_NAME(AUXV_AT_NULL); break;
+ case ENTRY_NAME(AUXV_AT_IGNORE); break;
+ case ENTRY_NAME(AUXV_AT_EXECFD); break;
+ case ENTRY_NAME(AUXV_AT_PHDR); break;
+ case ENTRY_NAME(AUXV_AT_PHENT); break;
+ case ENTRY_NAME(AUXV_AT_PHNUM); break;
+ case ENTRY_NAME(AUXV_AT_PAGESZ); break;
+ case ENTRY_NAME(AUXV_AT_BASE); break;
+ case ENTRY_NAME(AUXV_AT_FLAGS); break;
+ case ENTRY_NAME(AUXV_AT_ENTRY); break;
+ case ENTRY_NAME(AUXV_AT_NOTELF); break;
+ case ENTRY_NAME(AUXV_AT_UID); break;
+ case ENTRY_NAME(AUXV_AT_EUID); break;
+ case ENTRY_NAME(AUXV_AT_GID); break;
+ case ENTRY_NAME(AUXV_AT_EGID); break;
+ case ENTRY_NAME(AUXV_AT_CLKTCK); break;
+ case ENTRY_NAME(AUXV_AT_PLATFORM); break;
+ case ENTRY_NAME(AUXV_AT_HWCAP); break;
+ case ENTRY_NAME(AUXV_AT_FPUCW); break;
+ case ENTRY_NAME(AUXV_AT_DCACHEBSIZE); break;
+ case ENTRY_NAME(AUXV_AT_ICACHEBSIZE); break;
+ case ENTRY_NAME(AUXV_AT_UCACHEBSIZE); break;
+ case ENTRY_NAME(AUXV_AT_IGNOREPPC); break;
+ case ENTRY_NAME(AUXV_AT_SECURE); break;
+ case ENTRY_NAME(AUXV_AT_BASE_PLATFORM); break;
+ case ENTRY_NAME(AUXV_AT_RANDOM); break;
+ case ENTRY_NAME(AUXV_AT_EXECFN); break;
+ case ENTRY_NAME(AUXV_AT_SYSINFO); break;
+ case ENTRY_NAME(AUXV_AT_SYSINFO_EHDR); break;
+ case ENTRY_NAME(AUXV_AT_L1I_CACHESHAPE); break;
+ case ENTRY_NAME(AUXV_AT_L1D_CACHESHAPE); break;
+ case ENTRY_NAME(AUXV_AT_L2_CACHESHAPE); break;
+ case ENTRY_NAME(AUXV_AT_L3_CACHESHAPE); break;
+ }
+#undef ENTRY_NAME
+
+ return name;
+}
diff --git a/source/Plugins/Process/Utility/AuxVector.h b/source/Plugins/Process/Utility/AuxVector.h
new file mode 100644
index 0000000000000..c16be68aedb18
--- /dev/null
+++ b/source/Plugins/Process/Utility/AuxVector.h
@@ -0,0 +1,73 @@
+//===-- AuxVector.h ---------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_AuxVector_H_
+#define liblldb_AuxVector_H_
+
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Log.h"
+#include <unordered_map>
+
+class AuxVector {
+
+public:
+ AuxVector(const lldb_private::DataExtractor &data);
+
+ /// Constants describing the type of entry.
+ /// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
+ /// information. Added AUXV prefix to avoid potential conflicts with system-
+ /// defined macros
+ enum EntryType {
+ AUXV_AT_NULL = 0, ///< End of auxv.
+ AUXV_AT_IGNORE = 1, ///< Ignore entry.
+ AUXV_AT_EXECFD = 2, ///< File descriptor of program.
+ AUXV_AT_PHDR = 3, ///< Program headers.
+ AUXV_AT_PHENT = 4, ///< Size of program header.
+ AUXV_AT_PHNUM = 5, ///< Number of program headers.
+ AUXV_AT_PAGESZ = 6, ///< Page size.
+ AUXV_AT_BASE = 7, ///< Interpreter base address.
+ AUXV_AT_FLAGS = 8, ///< Flags.
+ AUXV_AT_ENTRY = 9, ///< Program entry point.
+ AUXV_AT_NOTELF = 10, ///< Set if program is not an ELF.
+ AUXV_AT_UID = 11, ///< UID.
+ AUXV_AT_EUID = 12, ///< Effective UID.
+ AUXV_AT_GID = 13, ///< GID.
+ AUXV_AT_EGID = 14, ///< Effective GID.
+ AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
+ AUXV_AT_PLATFORM = 15, ///< String identifying platform.
+ AUXV_AT_HWCAP =
+ 16, ///< Machine dependent hints about processor capabilities.
+ AUXV_AT_FPUCW = 18, ///< Used FPU control word.
+ AUXV_AT_DCACHEBSIZE = 19, ///< Data cache block size.
+ AUXV_AT_ICACHEBSIZE = 20, ///< Instruction cache block size.
+ AUXV_AT_UCACHEBSIZE = 21, ///< Unified cache block size.
+ AUXV_AT_IGNOREPPC = 22, ///< Entry should be ignored.
+ AUXV_AT_SECURE = 23, ///< Boolean, was exec setuid-like?
+ AUXV_AT_BASE_PLATFORM = 24, ///< String identifying real platforms.
+ AUXV_AT_RANDOM = 25, ///< Address of 16 random bytes.
+ AUXV_AT_EXECFN = 31, ///< Filename of executable.
+ AUXV_AT_SYSINFO = 32, ///< Pointer to the global system page used for system
+ /// calls and other nice things.
+ AUXV_AT_SYSINFO_EHDR = 33,
+ AUXV_AT_L1I_CACHESHAPE = 34, ///< Shapes of the caches.
+ AUXV_AT_L1D_CACHESHAPE = 35,
+ AUXV_AT_L2_CACHESHAPE = 36,
+ AUXV_AT_L3_CACHESHAPE = 37,
+ };
+
+ llvm::Optional<uint64_t> GetAuxValue(enum EntryType entry_type) const;
+ void DumpToLog(lldb_private::Log *log) const;
+ const char *GetEntryName(EntryType type) const;
+
+private:
+ void ParseAuxv(const lldb_private::DataExtractor &data);
+
+ std::unordered_map<uint64_t, uint64_t> m_auxv_entries;
+};
+
+#endif
diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
index dcbf474fa55ab..1afe4d920599d 100644
--- a/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
+++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
@@ -1,9 +1,8 @@
//===-- DynamicRegisterInfo.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -68,7 +67,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
for (uint32_t i = 0; i < num_sets; ++i) {
ConstString set_name;
if (sets->GetItemAtIndexAsString(i, set_name) && !set_name.IsEmpty()) {
- m_sets.push_back({ set_name.AsCString(), NULL, 0, NULL });
+ m_sets.push_back({set_name.AsCString(), nullptr, 0, nullptr});
} else {
Clear();
printf("error: register sets must have valid names\n");
@@ -303,7 +302,7 @@ DynamicRegisterInfo::SetRegisterInfo(const StructuredData::Dictionary &dict,
llvm::StringRef format_str;
if (reg_info_dict->GetValueForKeyAsString("format", format_str, nullptr)) {
if (OptionArgParser::ToFormat(format_str.str().c_str(), reg_info.format,
- NULL)
+ nullptr)
.Fail()) {
Clear();
printf("error: invalid 'format' value in register dictionary\n");
@@ -415,7 +414,7 @@ void DynamicRegisterInfo::AddRegister(RegisterInfo &reg_info,
const uint32_t reg_num = m_regs.size();
reg_info.name = reg_name.AsCString();
assert(reg_info.name);
- reg_info.alt_name = reg_alt_name.AsCString(NULL);
+ reg_info.alt_name = reg_alt_name.AsCString(nullptr);
uint32_t i;
if (reg_info.value_regs) {
for (i = 0; reg_info.value_regs[i] != LLDB_INVALID_REGNUM; ++i)
@@ -481,7 +480,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
if (m_value_regs_map.find(i) != m_value_regs_map.end())
m_regs[i].value_regs = m_value_regs_map[i].data();
else
- m_regs[i].value_regs = NULL;
+ m_regs[i].value_regs = nullptr;
}
// Expand all invalidation dependencies
@@ -530,7 +529,7 @@ void DynamicRegisterInfo::Finalize(const ArchSpec &arch) {
if (m_invalidate_regs_map.find(i) != m_invalidate_regs_map.end())
m_regs[i].invalidate_regs = m_invalidate_regs_map[i].data();
else
- m_regs[i].invalidate_regs = NULL;
+ m_regs[i].invalidate_regs = nullptr;
}
// Check if we need to automatically set the generic registers in case they
@@ -640,19 +639,19 @@ const RegisterInfo *
DynamicRegisterInfo::GetRegisterInfoAtIndex(uint32_t i) const {
if (i < m_regs.size())
return &m_regs[i];
- return NULL;
+ return nullptr;
}
RegisterInfo *DynamicRegisterInfo::GetRegisterInfoAtIndex(uint32_t i) {
if (i < m_regs.size())
return &m_regs[i];
- return NULL;
+ return nullptr;
}
const RegisterSet *DynamicRegisterInfo::GetRegisterSet(uint32_t i) const {
if (i < m_sets.size())
return &m_sets[i];
- return NULL;
+ return nullptr;
}
uint32_t DynamicRegisterInfo::GetRegisterSetIndexByName(ConstString &set_name,
@@ -665,7 +664,7 @@ uint32_t DynamicRegisterInfo::GetRegisterSetIndexByName(ConstString &set_name,
m_set_names.push_back(set_name);
m_set_reg_nums.resize(m_set_reg_nums.size() + 1);
- RegisterSet new_set = {set_name.AsCString(), NULL, 0, NULL};
+ RegisterSet new_set = {set_name.AsCString(), nullptr, 0, nullptr};
m_sets.push_back(new_set);
return m_sets.size() - 1;
}
@@ -747,7 +746,7 @@ void DynamicRegisterInfo::Dump() const {
}
const lldb_private::RegisterInfo *DynamicRegisterInfo::GetRegisterInfo(
- const lldb_private::ConstString &reg_name) const {
+ lldb_private::ConstString reg_name) const {
for (auto &reg_info : m_regs) {
// We can use pointer comparison since we used a ConstString to set the
// "name" member in AddRegister()
@@ -755,5 +754,5 @@ const lldb_private::RegisterInfo *DynamicRegisterInfo::GetRegisterInfo(
return &reg_info;
}
}
- return NULL;
+ return nullptr;
}
diff --git a/source/Plugins/Process/Utility/DynamicRegisterInfo.h b/source/Plugins/Process/Utility/DynamicRegisterInfo.h
index 68f3902e0c961..aacf547e187d6 100644
--- a/source/Plugins/Process/Utility/DynamicRegisterInfo.h
+++ b/source/Plugins/Process/Utility/DynamicRegisterInfo.h
@@ -1,9 +1,8 @@
//===-- DynamicRegisterInfo.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -65,9 +64,7 @@ public:
void Clear();
protected:
- //------------------------------------------------------------------
// Classes that inherit from DynamicRegisterInfo can see and modify these
- //------------------------------------------------------------------
typedef std::vector<lldb_private::RegisterInfo> reg_collection;
typedef std::vector<lldb_private::RegisterSet> set_collection;
typedef std::vector<uint32_t> reg_num_collection;
@@ -78,7 +75,7 @@ protected:
typedef std::map<uint32_t, dwarf_opcode> dynamic_reg_size_map;
const lldb_private::RegisterInfo *
- GetRegisterInfo(const lldb_private::ConstString &reg_name) const;
+ GetRegisterInfo(lldb_private::ConstString reg_name) const;
void MoveFrom(DynamicRegisterInfo &&info);
diff --git a/source/Plugins/Process/Utility/FreeBSDSignals.cpp b/source/Plugins/Process/Utility/FreeBSDSignals.cpp
index 0b56b6093559b..9f63a594e054e 100644
--- a/source/Plugins/Process/Utility/FreeBSDSignals.cpp
+++ b/source/Plugins/Process/Utility/FreeBSDSignals.cpp
@@ -1,9 +1,8 @@
//===-- FreeBSDSignals.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/FreeBSDSignals.h b/source/Plugins/Process/Utility/FreeBSDSignals.h
index 174025cabb82a..75462f3c76ffb 100644
--- a/source/Plugins/Process/Utility/FreeBSDSignals.h
+++ b/source/Plugins/Process/Utility/FreeBSDSignals.h
@@ -1,9 +1,8 @@
//===-- FreeBSDSignals.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/GDBRemoteSignals.cpp b/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
index cc0537c2a8b34..ed35273ce3fee 100644
--- a/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
+++ b/source/Plugins/Process/Utility/GDBRemoteSignals.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteSignals.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/GDBRemoteSignals.h b/source/Plugins/Process/Utility/GDBRemoteSignals.h
index 79d8ec3fbbafa..a02dd0604e67e 100644
--- a/source/Plugins/Process/Utility/GDBRemoteSignals.h
+++ b/source/Plugins/Process/Utility/GDBRemoteSignals.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteSignals.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/HistoryThread.cpp b/source/Plugins/Process/Utility/HistoryThread.cpp
index 4983dcdb51428..3cb5831726232 100644
--- a/source/Plugins/Process/Utility/HistoryThread.cpp
+++ b/source/Plugins/Process/Utility/HistoryThread.cpp
@@ -1,15 +1,15 @@
//===-- HistoryThread.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/lldb-private.h"
#include "Plugins/Process/Utility/HistoryThread.h"
+
#include "Plugins/Process/Utility/HistoryUnwind.h"
#include "Plugins/Process/Utility/RegisterContextHistory.h"
@@ -17,20 +17,20 @@
#include "lldb/Target/StackFrameList.h"
#include "lldb/Utility/Log.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
// Constructor
HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
- std::vector<lldb::addr_t> pcs, uint32_t stop_id,
- bool stop_id_is_valid)
+ std::vector<lldb::addr_t> pcs)
: Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
- m_pcs(pcs), m_stop_id(stop_id), m_stop_id_is_valid(stop_id_is_valid),
- m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
+ m_pcs(pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS), m_queue_name(),
m_thread_name(), m_originating_unique_thread_id(tid),
m_queue_id(LLDB_INVALID_QUEUE_ID) {
- m_unwinder_ap.reset(new HistoryUnwind(*this, pcs, stop_id_is_valid));
+ m_unwinder_up.reset(new HistoryUnwind(*this, pcs));
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p HistoryThread::HistoryThread", static_cast<void *>(this));
@@ -49,23 +49,24 @@ HistoryThread::~HistoryThread() {
lldb::RegisterContextSP HistoryThread::GetRegisterContext() {
RegisterContextSP rctx;
if (m_pcs.size() > 0) {
- rctx.reset(new RegisterContextHistory(
- *this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]));
+ rctx = std::make_shared<RegisterContextHistory>(
+ *this, 0, GetProcess()->GetAddressByteSize(), m_pcs[0]);
}
return rctx;
}
lldb::RegisterContextSP
HistoryThread::CreateRegisterContextForFrame(StackFrame *frame) {
- return m_unwinder_ap->CreateRegisterContextForFrame(frame);
+ return m_unwinder_up->CreateRegisterContextForFrame(frame);
}
lldb::StackFrameListSP HistoryThread::GetStackFrameList() {
// FIXME do not throw away the lock after we acquire it..
std::unique_lock<std::mutex> lock(m_framelist_mutex);
lock.unlock();
- if (m_framelist.get() == NULL) {
- m_framelist.reset(new StackFrameList(*this, StackFrameListSP(), true));
+ if (m_framelist.get() == nullptr) {
+ m_framelist =
+ std::make_shared<StackFrameList>(*this, StackFrameListSP(), true);
}
return m_framelist;
diff --git a/source/Plugins/Process/Utility/HistoryThread.h b/source/Plugins/Process/Utility/HistoryThread.h
index dc24922e7c17e..1e26586401724 100644
--- a/source/Plugins/Process/Utility/HistoryThread.h
+++ b/source/Plugins/Process/Utility/HistoryThread.h
@@ -1,9 +1,8 @@
//===-- HistoryThread.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,22 +22,18 @@
namespace lldb_private {
-//----------------------------------------------------------------------
-/// @class HistoryThread HistoryThread.h "HistoryThread.h"
+/// \class HistoryThread HistoryThread.h "HistoryThread.h"
/// A thread object representing a backtrace from a previous point in the
/// process execution
///
/// This subclass of Thread is used to provide a backtrace from earlier in
-/// process execution. It is given a backtrace list of pc addresses and
-/// optionally a stop_id of when those pc addresses were collected, and it
+/// process execution. It is given a backtrace list of pc addresses and it
/// will create stack frames for them.
-//----------------------------------------------------------------------
class HistoryThread : public lldb_private::Thread {
public:
HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
- std::vector<lldb::addr_t> pcs, uint32_t stop_id,
- bool stop_id_is_valid);
+ std::vector<lldb::addr_t> pcs);
~HistoryThread() override;
@@ -83,8 +78,6 @@ protected:
mutable std::mutex m_framelist_mutex;
lldb::StackFrameListSP m_framelist;
std::vector<lldb::addr_t> m_pcs;
- uint32_t m_stop_id;
- bool m_stop_id_is_valid;
uint64_t m_extended_unwind_token;
std::string m_queue_name;
diff --git a/source/Plugins/Process/Utility/HistoryUnwind.cpp b/source/Plugins/Process/Utility/HistoryUnwind.cpp
index 4f0ecba613bfa..7d473bff8200a 100644
--- a/source/Plugins/Process/Utility/HistoryUnwind.cpp
+++ b/source/Plugins/Process/Utility/HistoryUnwind.cpp
@@ -1,9 +1,8 @@
//===-- HistoryUnwind.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,14 +16,15 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
// Constructor
-HistoryUnwind::HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
- bool stop_id_is_valid)
- : Unwind(thread), m_pcs(pcs), m_stop_id_is_valid(stop_id_is_valid) {}
+HistoryUnwind::HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs)
+ : Unwind(thread), m_pcs(pcs) {}
// Destructor
@@ -33,7 +33,6 @@ HistoryUnwind::~HistoryUnwind() {}
void HistoryUnwind::DoClear() {
std::lock_guard<std::recursive_mutex> guard(m_unwind_mutex);
m_pcs.clear();
- m_stop_id_is_valid = false;
}
lldb::RegisterContextSP
@@ -43,9 +42,9 @@ HistoryUnwind::DoCreateRegisterContextForFrame(StackFrame *frame) {
addr_t pc = frame->GetFrameCodeAddress().GetLoadAddress(
&frame->GetThread()->GetProcess()->GetTarget());
if (pc != LLDB_INVALID_ADDRESS) {
- rctx.reset(new RegisterContextHistory(
+ rctx = std::make_shared<RegisterContextHistory>(
*frame->GetThread().get(), frame->GetConcreteFrameIndex(),
- frame->GetThread()->GetProcess()->GetAddressByteSize(), pc));
+ frame->GetThread()->GetProcess()->GetAddressByteSize(), pc);
}
}
return rctx;
diff --git a/source/Plugins/Process/Utility/HistoryUnwind.h b/source/Plugins/Process/Utility/HistoryUnwind.h
index 2cbfb680ef49c..6c4522e6b35b9 100644
--- a/source/Plugins/Process/Utility/HistoryUnwind.h
+++ b/source/Plugins/Process/Utility/HistoryUnwind.h
@@ -1,9 +1,8 @@
//===-- HistoryUnwind.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,8 +18,7 @@ namespace lldb_private {
class HistoryUnwind : public lldb_private::Unwind {
public:
- HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs,
- bool stop_id_is_valid);
+ HistoryUnwind(Thread &thread, std::vector<lldb::addr_t> pcs);
~HistoryUnwind() override;
@@ -36,7 +34,6 @@ protected:
private:
std::vector<lldb::addr_t> m_pcs;
- bool m_stop_id_is_valid;
};
} // namespace lldb_private
diff --git a/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp b/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
index 5c51a035ec665..9beaf2fc7ac87 100644
--- a/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
+++ b/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp
@@ -1,9 +1,8 @@
//===-- InferiorCallPOSIX.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,7 +38,7 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr,
unsigned flags, addr_t fd, addr_t offset) {
Thread *thread =
process->GetThreadList().GetExpressionExecutionThread().get();
- if (thread == NULL)
+ if (thread == nullptr)
return false;
const bool append = true;
@@ -61,7 +60,7 @@ bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr,
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug(false);
- options.SetTimeout(std::chrono::milliseconds(500));
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetTrapExceptions(false);
addr_t prot_arg;
@@ -127,7 +126,7 @@ bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
addr_t length) {
Thread *thread =
process->GetThreadList().GetExpressionExecutionThread().get();
- if (thread == NULL)
+ if (thread == nullptr)
return false;
const bool append = true;
@@ -149,7 +148,7 @@ bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr,
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug(false);
- options.SetTimeout(std::chrono::milliseconds(500));
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetTrapExceptions(false);
AddressRange munmap_range;
@@ -189,7 +188,7 @@ bool lldb_private::InferiorCall(Process *process, const Address *address,
addr_t &returned_func, bool trap_exceptions) {
Thread *thread =
process->GetThreadList().GetExpressionExecutionThread().get();
- if (thread == NULL || address == NULL)
+ if (thread == nullptr || address == nullptr)
return false;
EvaluateExpressionOptions options;
@@ -198,7 +197,7 @@ bool lldb_private::InferiorCall(Process *process, const Address *address,
options.SetIgnoreBreakpoints(true);
options.SetTryAllThreads(true);
options.SetDebug(false);
- options.SetTimeout(std::chrono::milliseconds(500));
+ options.SetTimeout(process->GetUtilityExpressionTimeout());
options.SetTrapExceptions(trap_exceptions);
ClangASTContext *clang_ast_context =
diff --git a/source/Plugins/Process/Utility/InferiorCallPOSIX.h b/source/Plugins/Process/Utility/InferiorCallPOSIX.h
index 07bde5bf09b33..04316801b351d 100644
--- a/source/Plugins/Process/Utility/InferiorCallPOSIX.h
+++ b/source/Plugins/Process/Utility/InferiorCallPOSIX.h
@@ -1,9 +1,8 @@
//===-- InferiorCallPOSIX.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/InstructionUtils.h b/source/Plugins/Process/Utility/InstructionUtils.h
index 186d525ce499c..f74933e691eeb 100644
--- a/source/Plugins/Process/Utility/InstructionUtils.h
+++ b/source/Plugins/Process/Utility/InstructionUtils.h
@@ -1,9 +1,8 @@
//===-- InstructionUtils.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/LinuxProcMaps.cpp b/source/Plugins/Process/Utility/LinuxProcMaps.cpp
index d45bf6dcd84fc..1ba432aa542bf 100644
--- a/source/Plugins/Process/Utility/LinuxProcMaps.cpp
+++ b/source/Plugins/Process/Utility/LinuxProcMaps.cpp
@@ -1,9 +1,8 @@
//===-- LinuxProcMaps.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/LinuxProcMaps.h b/source/Plugins/Process/Utility/LinuxProcMaps.h
index e6eabb28fc825..e1f0e48ac5c95 100644
--- a/source/Plugins/Process/Utility/LinuxProcMaps.h
+++ b/source/Plugins/Process/Utility/LinuxProcMaps.h
@@ -1,9 +1,8 @@
//===-- LinuxProcMaps.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/LinuxSignals.cpp b/source/Plugins/Process/Utility/LinuxSignals.cpp
index 6f1f67ac35706..bef47cd263071 100644
--- a/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -1,9 +1,8 @@
//===-- LinuxSignals.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/LinuxSignals.h b/source/Plugins/Process/Utility/LinuxSignals.h
index f93a9d2e36d19..7ad8cfcbef683 100644
--- a/source/Plugins/Process/Utility/LinuxSignals.h
+++ b/source/Plugins/Process/Utility/LinuxSignals.h
@@ -1,9 +1,8 @@
//===-- LinuxSignals.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/MipsLinuxSignals.cpp b/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
index b6f3b34893bf2..d8e5426ab5a5b 100644
--- a/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
+++ b/source/Plugins/Process/Utility/MipsLinuxSignals.cpp
@@ -1,10 +1,9 @@
//===-- MipsLinuxSignals.cpp ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/MipsLinuxSignals.h b/source/Plugins/Process/Utility/MipsLinuxSignals.h
index 2796f6b8e4d7e..b5e3ed86f568c 100644
--- a/source/Plugins/Process/Utility/MipsLinuxSignals.h
+++ b/source/Plugins/Process/Utility/MipsLinuxSignals.h
@@ -1,10 +1,9 @@
//===-- MipsLinuxSignals.h ------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
index 3a9d497711c0f..be61cfdd73745 100644
--- a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
+++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.cpp
@@ -1,9 +1,8 @@
//===-- NativeRegisterContextRegisterInfo.cpp -------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
index 8f2e4409105fa..b285c477cd963 100644
--- a/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
+++ b/source/Plugins/Process/Utility/NativeRegisterContextRegisterInfo.h
@@ -1,9 +1,8 @@
//===-- NativeRegisterContextRegisterInfo.h ---------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/NetBSDSignals.cpp b/source/Plugins/Process/Utility/NetBSDSignals.cpp
index a4baab9ac85f9..29967deb7e9b4 100644
--- a/source/Plugins/Process/Utility/NetBSDSignals.cpp
+++ b/source/Plugins/Process/Utility/NetBSDSignals.cpp
@@ -1,9 +1,8 @@
//===-- NetBSDSignals.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/NetBSDSignals.h b/source/Plugins/Process/Utility/NetBSDSignals.h
index 7bb57fa0c0d66..bf7399a890603 100644
--- a/source/Plugins/Process/Utility/NetBSDSignals.h
+++ b/source/Plugins/Process/Utility/NetBSDSignals.h
@@ -1,9 +1,8 @@
//===-- NetBSDSignals.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h b/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
index ff57464be2def..ef40162984f12 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwinConstants.h
@@ -1,9 +1,8 @@
//===-- RegisterContextDarwinConstants.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
index 9ad896abd0b4c..e804a4d251f73 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextDarwin_arm.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,6 +19,8 @@
#include "Plugins/Process/Utility/InstructionUtils.h"
+#include <memory>
+
// Support building against older versions of LLVM, this macro was added
// recently.
#ifndef LLVM_EXTENSION
@@ -197,7 +198,7 @@ static RegisterInfo g_register_infos[] = {
// =============== =============== =========================
// ===================== =============
{"r0",
- NULL,
+ nullptr,
4,
GPR_OFFSET(0),
eEncodingUint,
@@ -208,7 +209,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r1",
- NULL,
+ nullptr,
4,
GPR_OFFSET(1),
eEncodingUint,
@@ -219,7 +220,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r2",
- NULL,
+ nullptr,
4,
GPR_OFFSET(2),
eEncodingUint,
@@ -230,7 +231,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r3",
- NULL,
+ nullptr,
4,
GPR_OFFSET(3),
eEncodingUint,
@@ -241,7 +242,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r4",
- NULL,
+ nullptr,
4,
GPR_OFFSET(4),
eEncodingUint,
@@ -252,7 +253,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r5",
- NULL,
+ nullptr,
4,
GPR_OFFSET(5),
eEncodingUint,
@@ -263,7 +264,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r6",
- NULL,
+ nullptr,
4,
GPR_OFFSET(6),
eEncodingUint,
@@ -274,7 +275,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r7",
- NULL,
+ nullptr,
4,
GPR_OFFSET(7),
eEncodingUint,
@@ -286,7 +287,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r8",
- NULL,
+ nullptr,
4,
GPR_OFFSET(8),
eEncodingUint,
@@ -297,7 +298,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r9",
- NULL,
+ nullptr,
4,
GPR_OFFSET(9),
eEncodingUint,
@@ -308,7 +309,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r10",
- NULL,
+ nullptr,
4,
GPR_OFFSET(10),
eEncodingUint,
@@ -320,7 +321,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r11",
- NULL,
+ nullptr,
4,
GPR_OFFSET(11),
eEncodingUint,
@@ -332,7 +333,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"r12",
- NULL,
+ nullptr,
4,
GPR_OFFSET(12),
eEncodingUint,
@@ -393,7 +394,7 @@ static RegisterInfo g_register_infos[] = {
0},
{"s0",
- NULL,
+ nullptr,
4,
FPU_OFFSET(0),
eEncodingIEEE754,
@@ -405,7 +406,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s1",
- NULL,
+ nullptr,
4,
FPU_OFFSET(1),
eEncodingIEEE754,
@@ -417,7 +418,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s2",
- NULL,
+ nullptr,
4,
FPU_OFFSET(2),
eEncodingIEEE754,
@@ -429,7 +430,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s3",
- NULL,
+ nullptr,
4,
FPU_OFFSET(3),
eEncodingIEEE754,
@@ -441,7 +442,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s4",
- NULL,
+ nullptr,
4,
FPU_OFFSET(4),
eEncodingIEEE754,
@@ -453,7 +454,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s5",
- NULL,
+ nullptr,
4,
FPU_OFFSET(5),
eEncodingIEEE754,
@@ -465,7 +466,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s6",
- NULL,
+ nullptr,
4,
FPU_OFFSET(6),
eEncodingIEEE754,
@@ -477,7 +478,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s7",
- NULL,
+ nullptr,
4,
FPU_OFFSET(7),
eEncodingIEEE754,
@@ -489,7 +490,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s8",
- NULL,
+ nullptr,
4,
FPU_OFFSET(8),
eEncodingIEEE754,
@@ -501,7 +502,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s9",
- NULL,
+ nullptr,
4,
FPU_OFFSET(9),
eEncodingIEEE754,
@@ -513,7 +514,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s10",
- NULL,
+ nullptr,
4,
FPU_OFFSET(10),
eEncodingIEEE754,
@@ -525,7 +526,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s11",
- NULL,
+ nullptr,
4,
FPU_OFFSET(11),
eEncodingIEEE754,
@@ -537,7 +538,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s12",
- NULL,
+ nullptr,
4,
FPU_OFFSET(12),
eEncodingIEEE754,
@@ -549,7 +550,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s13",
- NULL,
+ nullptr,
4,
FPU_OFFSET(13),
eEncodingIEEE754,
@@ -561,7 +562,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s14",
- NULL,
+ nullptr,
4,
FPU_OFFSET(14),
eEncodingIEEE754,
@@ -573,7 +574,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s15",
- NULL,
+ nullptr,
4,
FPU_OFFSET(15),
eEncodingIEEE754,
@@ -585,7 +586,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s16",
- NULL,
+ nullptr,
4,
FPU_OFFSET(16),
eEncodingIEEE754,
@@ -597,7 +598,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s17",
- NULL,
+ nullptr,
4,
FPU_OFFSET(17),
eEncodingIEEE754,
@@ -609,7 +610,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s18",
- NULL,
+ nullptr,
4,
FPU_OFFSET(18),
eEncodingIEEE754,
@@ -621,7 +622,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s19",
- NULL,
+ nullptr,
4,
FPU_OFFSET(19),
eEncodingIEEE754,
@@ -633,7 +634,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s20",
- NULL,
+ nullptr,
4,
FPU_OFFSET(20),
eEncodingIEEE754,
@@ -645,7 +646,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s21",
- NULL,
+ nullptr,
4,
FPU_OFFSET(21),
eEncodingIEEE754,
@@ -657,7 +658,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s22",
- NULL,
+ nullptr,
4,
FPU_OFFSET(22),
eEncodingIEEE754,
@@ -669,7 +670,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s23",
- NULL,
+ nullptr,
4,
FPU_OFFSET(23),
eEncodingIEEE754,
@@ -681,7 +682,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s24",
- NULL,
+ nullptr,
4,
FPU_OFFSET(24),
eEncodingIEEE754,
@@ -693,7 +694,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s25",
- NULL,
+ nullptr,
4,
FPU_OFFSET(25),
eEncodingIEEE754,
@@ -705,7 +706,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s26",
- NULL,
+ nullptr,
4,
FPU_OFFSET(26),
eEncodingIEEE754,
@@ -717,7 +718,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s27",
- NULL,
+ nullptr,
4,
FPU_OFFSET(27),
eEncodingIEEE754,
@@ -729,7 +730,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s28",
- NULL,
+ nullptr,
4,
FPU_OFFSET(28),
eEncodingIEEE754,
@@ -741,7 +742,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s29",
- NULL,
+ nullptr,
4,
FPU_OFFSET(29),
eEncodingIEEE754,
@@ -753,7 +754,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s30",
- NULL,
+ nullptr,
4,
FPU_OFFSET(30),
eEncodingIEEE754,
@@ -765,7 +766,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"s31",
- NULL,
+ nullptr,
4,
FPU_OFFSET(31),
eEncodingIEEE754,
@@ -777,7 +778,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"fpscr",
- NULL,
+ nullptr,
4,
FPU_OFFSET(32),
eEncodingUint,
@@ -790,7 +791,7 @@ static RegisterInfo g_register_infos[] = {
0},
{"exception",
- NULL,
+ nullptr,
4,
EXC_OFFSET(0),
eEncodingUint,
@@ -802,7 +803,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"fsr",
- NULL,
+ nullptr,
4,
EXC_OFFSET(1),
eEncodingUint,
@@ -814,7 +815,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
0},
{"far",
- NULL,
+ nullptr,
4,
EXC_OFFSET(2),
eEncodingUint,
@@ -943,7 +944,7 @@ RegisterContextDarwin_arm::GetRegisterInfoAtIndex(size_t reg) {
assert(k_num_register_infos == k_num_registers);
if (reg < k_num_registers)
return &g_register_infos[reg];
- return NULL;
+ return nullptr;
}
size_t RegisterContextDarwin_arm::GetRegisterInfosCount() {
@@ -959,11 +960,9 @@ const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
-//----------------------------------------------------------------------
// Register set definitions. The first definitions at register set index of
// zero is for all registers, followed by other registers sets. The register
// information for the all register set need not be filled in.
-//----------------------------------------------------------------------
static const RegisterSet g_reg_sets[] = {
{
"General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums,
@@ -980,12 +979,10 @@ size_t RegisterContextDarwin_arm::GetRegisterSetCount() {
const RegisterSet *RegisterContextDarwin_arm::GetRegisterSet(size_t reg_set) {
if (reg_set < k_num_regsets)
return &g_reg_sets[reg_set];
- return NULL;
+ return nullptr;
}
-//----------------------------------------------------------------------
// Register information definitions for 32 bit i386.
-//----------------------------------------------------------------------
int RegisterContextDarwin_arm::GetSetForNativeRegNum(int reg) {
if (reg < fpu_s0)
return GPRRegSet;
@@ -1297,7 +1294,7 @@ bool RegisterContextDarwin_arm::WriteRegister(const RegisterInfo *reg_info,
bool RegisterContextDarwin_arm::ReadAllRegisterValues(
lldb::DataBufferSP &data_sp) {
- data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
+ data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
if (data_sp && ReadGPR(false) == KERN_SUCCESS &&
ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) {
uint8_t *dst = data_sp->GetBytes();
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
index b46946d608bc2..d7c1809a32228 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterContextDarwin_arm.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
index b478645e035df..85d518a487bf1 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.cpp
@@ -1,10 +1,9 @@
//===-- RegisterContextDarwin_arm64.cpp ---------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,8 @@
#include "Plugins/Process/Utility/InstructionUtils.h"
+#include <memory>
+
// Support building against older versions of LLVM, this macro was added
// recently.
#ifndef LLVM_EXTENSION
@@ -66,9 +67,7 @@ using namespace lldb_private;
sizeof(RegisterContextDarwin_arm64::FPU) + \
sizeof(RegisterContextDarwin_arm64::EXC))
-//-----------------------------------------------------------------------------
// Include RegisterInfos_arm64 to declare our g_register_infos_arm64 structure.
-//-----------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_ARM64_STRUCT
#include "RegisterInfos_arm64.h"
#undef DECLARE_REGISTER_INFOS_ARM64_STRUCT
@@ -123,7 +122,7 @@ RegisterContextDarwin_arm64::GetRegisterInfoAtIndex(size_t reg) {
assert(k_num_register_infos == k_num_registers);
if (reg < k_num_registers)
return &g_register_infos_arm64_le[reg];
- return NULL;
+ return nullptr;
}
size_t RegisterContextDarwin_arm64::GetRegisterInfosCount() {
@@ -139,11 +138,9 @@ const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
-//----------------------------------------------------------------------
// Register set definitions. The first definitions at register set index of
// zero is for all registers, followed by other registers sets. The register
// information for the all register set need not be filled in.
-//----------------------------------------------------------------------
static const RegisterSet g_reg_sets[] = {
{
"General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums,
@@ -160,12 +157,10 @@ size_t RegisterContextDarwin_arm64::GetRegisterSetCount() {
const RegisterSet *RegisterContextDarwin_arm64::GetRegisterSet(size_t reg_set) {
if (reg_set < k_num_regsets)
return &g_reg_sets[reg_set];
- return NULL;
+ return nullptr;
}
-//----------------------------------------------------------------------
// Register information definitions for arm64
-//----------------------------------------------------------------------
int RegisterContextDarwin_arm64::GetSetForNativeRegNum(int reg) {
if (reg < fpu_v0)
return GPRRegSet;
@@ -428,7 +423,7 @@ bool RegisterContextDarwin_arm64::ReadRegister(const RegisterInfo *reg_info,
case fpu_v29:
case fpu_v30:
case fpu_v31:
- value.SetBytes(fpu.v[reg].bytes.buffer, reg_info->byte_size,
+ value.SetBytes(fpu.v[reg - fpu_v0].bytes.buffer, reg_info->byte_size,
endian::InlHostByteOrder());
break;
@@ -620,7 +615,8 @@ bool RegisterContextDarwin_arm64::WriteRegister(const RegisterInfo *reg_info,
case fpu_v29:
case fpu_v30:
case fpu_v31:
- ::memcpy(fpu.v[reg].bytes.buffer, value.GetBytes(), value.GetByteSize());
+ ::memcpy(fpu.v[reg - fpu_v0].bytes.buffer, value.GetBytes(),
+ value.GetByteSize());
break;
case fpu_fpsr:
@@ -649,9 +645,9 @@ bool RegisterContextDarwin_arm64::WriteRegister(const RegisterInfo *reg_info,
bool RegisterContextDarwin_arm64::ReadAllRegisterValues(
lldb::DataBufferSP &data_sp) {
- data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR(false) == KERN_SUCCESS &&
- ReadFPU(false) == KERN_SUCCESS && ReadEXC(false) == KERN_SUCCESS) {
+ data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
+ if (ReadGPR(false) == KERN_SUCCESS && ReadFPU(false) == KERN_SUCCESS &&
+ ReadEXC(false) == KERN_SUCCESS) {
uint8_t *dst = data_sp->GetBytes();
::memcpy(dst, &gpr, sizeof(gpr));
dst += sizeof(gpr);
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
index 9e826d85af085..2f691c807d50b 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_arm64.h
@@ -1,10 +1,9 @@
//===-- RegisterContextDarwin_arm64.h -----------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
index c9e4b37a17f36..820d280c37f7b 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.cpp
@@ -1,14 +1,11 @@
//===-- RegisterContextDarwin_i386.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include <stddef.h>
-
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
@@ -18,6 +15,10 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
+#include <stddef.h>
+
+#include <memory>
+
// Support building against older versions of LLVM, this macro was added
// recently.
#ifndef LLVM_EXTENSION
@@ -175,42 +176,42 @@ static RegisterInfo g_register_infos[] = {
// =============================== =======================
// =================== ========================= ==================
// =================
- {DEFINE_GPR(eax, NULL),
+ {DEFINE_GPR(eax, nullptr),
{ehframe_eax, dwarf_eax, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
gpr_eax},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(ebx, NULL),
+ {DEFINE_GPR(ebx, nullptr),
{ehframe_ebx, dwarf_ebx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
gpr_ebx},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(ecx, NULL),
+ {DEFINE_GPR(ecx, nullptr),
{ehframe_ecx, dwarf_ecx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
gpr_ecx},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(edx, NULL),
+ {DEFINE_GPR(edx, nullptr),
{ehframe_edx, dwarf_edx, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
gpr_edx},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(edi, NULL),
+ {DEFINE_GPR(edi, nullptr),
{ehframe_edi, dwarf_edi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
gpr_edi},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(esi, NULL),
+ {DEFINE_GPR(esi, nullptr),
{ehframe_esi, dwarf_esi, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
gpr_esi},
nullptr,
@@ -231,7 +232,7 @@ static RegisterInfo g_register_infos[] = {
nullptr,
nullptr,
0},
- {DEFINE_GPR(ss, NULL),
+ {DEFINE_GPR(ss, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_ss},
nullptr,
@@ -252,35 +253,35 @@ static RegisterInfo g_register_infos[] = {
nullptr,
nullptr,
0},
- {DEFINE_GPR(cs, NULL),
+ {DEFINE_GPR(cs, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_cs},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(ds, NULL),
+ {DEFINE_GPR(ds, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_ds},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(es, NULL),
+ {DEFINE_GPR(es, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_es},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(fs, NULL),
+ {DEFINE_GPR(fs, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_fs},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(gs, NULL),
+ {DEFINE_GPR(gs, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_gs},
nullptr,
@@ -426,7 +427,7 @@ RegisterContextDarwin_i386::GetRegisterInfoAtIndex(size_t reg) {
assert(k_num_register_infos == k_num_registers);
if (reg < k_num_registers)
return &g_register_infos[reg];
- return NULL;
+ return nullptr;
}
size_t RegisterContextDarwin_i386::GetRegisterInfosCount() {
@@ -459,11 +460,9 @@ const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
-//----------------------------------------------------------------------
// Register set definitions. The first definitions at register set index of
// zero is for all registers, followed by other registers sets. The register
// information for the all register set need not be filled in.
-//----------------------------------------------------------------------
static const RegisterSet g_reg_sets[] = {
{
"General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums,
@@ -480,12 +479,10 @@ size_t RegisterContextDarwin_i386::GetRegisterSetCount() {
const RegisterSet *RegisterContextDarwin_i386::GetRegisterSet(size_t reg_set) {
if (reg_set < k_num_regsets)
return &g_reg_sets[reg_set];
- return NULL;
+ return nullptr;
}
-//----------------------------------------------------------------------
// Register information definitions for 32 bit i386.
-//----------------------------------------------------------------------
int RegisterContextDarwin_i386::GetSetForNativeRegNum(int reg_num) {
if (reg_num < fpu_fcw)
return GPRRegSet;
@@ -832,9 +829,8 @@ bool RegisterContextDarwin_i386::WriteRegister(const RegisterInfo *reg_info,
bool RegisterContextDarwin_i386::ReadAllRegisterValues(
lldb::DataBufferSP &data_sp) {
- data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 &&
- ReadEXC(false) == 0) {
+ data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
+ if (ReadGPR(false) == 0 && ReadFPU(false) == 0 && ReadEXC(false) == 0) {
uint8_t *dst = data_sp->GetBytes();
::memcpy(dst, &gpr, sizeof(gpr));
dst += sizeof(gpr);
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
index ad6a1e48fc34a..e52f0fe63250c 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_i386.h
@@ -1,9 +1,8 @@
//===-- RegisterContextDarwin_i386.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
index 95460308857a9..62e512adc9f7f 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextDarwin_x86_64.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,6 +10,8 @@
#include <stdarg.h>
#include <stddef.h>
+#include <memory>
+
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Endian.h"
@@ -194,42 +195,42 @@ static RegisterInfo g_register_infos[] = {
// =============================== ======================
// =================== ========================== ====================
// ===================
- {DEFINE_GPR(rax, NULL),
+ {DEFINE_GPR(rax, nullptr),
{ehframe_dwarf_gpr_rax, ehframe_dwarf_gpr_rax, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_rax},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(rbx, NULL),
+ {DEFINE_GPR(rbx, nullptr),
{ehframe_dwarf_gpr_rbx, ehframe_dwarf_gpr_rbx, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_rbx},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(rcx, NULL),
+ {DEFINE_GPR(rcx, nullptr),
{ehframe_dwarf_gpr_rcx, ehframe_dwarf_gpr_rcx, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_rcx},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(rdx, NULL),
+ {DEFINE_GPR(rdx, nullptr),
{ehframe_dwarf_gpr_rdx, ehframe_dwarf_gpr_rdx, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_rdx},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(rdi, NULL),
+ {DEFINE_GPR(rdi, nullptr),
{ehframe_dwarf_gpr_rdi, ehframe_dwarf_gpr_rdi, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_rdi},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(rsi, NULL),
+ {DEFINE_GPR(rsi, nullptr),
{ehframe_dwarf_gpr_rsi, ehframe_dwarf_gpr_rsi, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_rsi},
nullptr,
@@ -250,56 +251,56 @@ static RegisterInfo g_register_infos[] = {
nullptr,
nullptr,
0},
- {DEFINE_GPR(r8, NULL),
+ {DEFINE_GPR(r8, nullptr),
{ehframe_dwarf_gpr_r8, ehframe_dwarf_gpr_r8, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r8},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r9, NULL),
+ {DEFINE_GPR(r9, nullptr),
{ehframe_dwarf_gpr_r9, ehframe_dwarf_gpr_r9, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r9},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r10, NULL),
+ {DEFINE_GPR(r10, nullptr),
{ehframe_dwarf_gpr_r10, ehframe_dwarf_gpr_r10, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r10},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r11, NULL),
+ {DEFINE_GPR(r11, nullptr),
{ehframe_dwarf_gpr_r11, ehframe_dwarf_gpr_r11, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r11},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r12, NULL),
+ {DEFINE_GPR(r12, nullptr),
{ehframe_dwarf_gpr_r12, ehframe_dwarf_gpr_r12, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r12},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r13, NULL),
+ {DEFINE_GPR(r13, nullptr),
{ehframe_dwarf_gpr_r13, ehframe_dwarf_gpr_r13, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r13},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r14, NULL),
+ {DEFINE_GPR(r14, nullptr),
{ehframe_dwarf_gpr_r14, ehframe_dwarf_gpr_r14, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r14},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(r15, NULL),
+ {DEFINE_GPR(r15, nullptr),
{ehframe_dwarf_gpr_r15, ehframe_dwarf_gpr_r15, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_r15},
nullptr,
@@ -320,21 +321,21 @@ static RegisterInfo g_register_infos[] = {
nullptr,
nullptr,
0},
- {DEFINE_GPR(cs, NULL),
+ {DEFINE_GPR(cs, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_cs},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(fs, NULL),
+ {DEFINE_GPR(fs, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_fs},
nullptr,
nullptr,
nullptr,
0},
- {DEFINE_GPR(gs, NULL),
+ {DEFINE_GPR(gs, nullptr),
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
LLDB_INVALID_REGNUM, gpr_gs},
nullptr,
@@ -488,7 +489,7 @@ RegisterContextDarwin_x86_64::GetRegisterInfoAtIndex(size_t reg) {
assert(k_num_register_infos == k_num_registers);
if (reg < k_num_registers)
return &g_register_infos[reg];
- return NULL;
+ return nullptr;
}
size_t RegisterContextDarwin_x86_64::GetRegisterInfosCount() {
@@ -520,11 +521,9 @@ const size_t k_num_gpr_registers = llvm::array_lengthof(g_gpr_regnums);
const size_t k_num_fpu_registers = llvm::array_lengthof(g_fpu_regnums);
const size_t k_num_exc_registers = llvm::array_lengthof(g_exc_regnums);
-//----------------------------------------------------------------------
// Register set definitions. The first definitions at register set index of
// zero is for all registers, followed by other registers sets. The register
// information for the all register set need not be filled in.
-//----------------------------------------------------------------------
static const RegisterSet g_reg_sets[] = {
{
"General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums,
@@ -542,7 +541,7 @@ const RegisterSet *
RegisterContextDarwin_x86_64::GetRegisterSet(size_t reg_set) {
if (reg_set < k_num_regsets)
return &g_reg_sets[reg_set];
- return NULL;
+ return nullptr;
}
int RegisterContextDarwin_x86_64::GetSetForNativeRegNum(int reg_num) {
@@ -910,9 +909,8 @@ bool RegisterContextDarwin_x86_64::WriteRegister(const RegisterInfo *reg_info,
bool RegisterContextDarwin_x86_64::ReadAllRegisterValues(
lldb::DataBufferSP &data_sp) {
- data_sp.reset(new DataBufferHeap(REG_CONTEXT_SIZE, 0));
- if (data_sp && ReadGPR(false) == 0 && ReadFPU(false) == 0 &&
- ReadEXC(false) == 0) {
+ data_sp = std::make_shared<DataBufferHeap>(REG_CONTEXT_SIZE, 0);
+ if (ReadGPR(false) == 0 && ReadFPU(false) == 0 && ReadEXC(false) == 0) {
uint8_t *dst = data_sp->GetBytes();
::memcpy(dst, &gpr, sizeof(gpr));
dst += sizeof(gpr);
diff --git a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
index 6d94bf75aad4b..1a65a4f28b339 100644
--- a/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextDarwin_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextDarwin_x86_64.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.cpp b/source/Plugins/Process/Utility/RegisterContextDummy.cpp
index c51c30f45a5de..6832b6095931b 100644
--- a/source/Plugins/Process/Utility/RegisterContextDummy.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextDummy.cpp
@@ -1,10 +1,9 @@
//===-- RegisterContextDummy.cpp ---------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -50,8 +49,8 @@ RegisterContextDummy::RegisterContextDummy(Thread &thread,
m_pc_reg_info.byte_size = address_byte_size;
m_pc_reg_info.encoding = eEncodingUint;
m_pc_reg_info.format = eFormatPointer;
- m_pc_reg_info.invalidate_regs = NULL;
- m_pc_reg_info.value_regs = NULL;
+ m_pc_reg_info.invalidate_regs = nullptr;
+ m_pc_reg_info.value_regs = nullptr;
m_pc_reg_info.kinds[eRegisterKindEHFrame] = LLDB_INVALID_REGNUM;
m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM;
m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
@@ -72,7 +71,7 @@ size_t RegisterContextDummy::GetRegisterCount() { return 1; }
const lldb_private::RegisterInfo *
RegisterContextDummy::GetRegisterInfoAtIndex(size_t reg) {
if (reg)
- return NULL;
+ return nullptr;
return &m_pc_reg_info;
}
@@ -81,7 +80,7 @@ size_t RegisterContextDummy::GetRegisterSetCount() { return 1; }
const lldb_private::RegisterSet *
RegisterContextDummy::GetRegisterSet(size_t reg_set) {
if (reg_set)
- return NULL;
+ return nullptr;
return &m_reg_set0;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextDummy.h b/source/Plugins/Process/Utility/RegisterContextDummy.h
index d5608616c896c..bdaa2217d2077 100644
--- a/source/Plugins/Process/Utility/RegisterContextDummy.h
+++ b/source/Plugins/Process/Utility/RegisterContextDummy.h
@@ -1,10 +1,9 @@
//===-- RegisterContextDummy.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,9 +51,7 @@ public:
uint32_t num) override;
private:
- //------------------------------------------------------------------
// For RegisterContextLLDB only
- //------------------------------------------------------------------
lldb_private::RegisterSet m_reg_set0; // register set 0 (PC only)
lldb_private::RegisterInfo m_pc_reg_info;
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
index 4ccfa2a16fef6..b90b381082672 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_i386.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -54,9 +53,7 @@ struct UserArea {
#define DR_SIZE sizeof(uint32_t)
#define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(dbreg, dr[reg_index]))
-//---------------------------------------------------------------------------
// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_I386_STRUCT
#include "RegisterInfos_i386.h"
#undef DECLARE_REGISTER_INFOS_I386_STRUCT
@@ -73,7 +70,7 @@ const RegisterInfo *RegisterContextFreeBSD_i386::GetRegisterInfo() const {
return g_register_infos_i386;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
index 35a79c14abfcb..7aadf3a0a4c9f 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_i386.h
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_i386.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
index 55a72b2a31b4f..4331ef5ad14ec 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_mips64.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -80,10 +79,8 @@ typedef struct _GPR {
uint64_t dummy;
} GPR_freebsd_mips;
-//---------------------------------------------------------------------------
// Include RegisterInfos_mips64 to declare our g_register_infos_mips64
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_MIPS64_STRUCT
#include "RegisterInfos_mips64.h"
#undef DECLARE_REGISTER_INFOS_MIPS64_STRUCT
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
index 5e5de71ad72e8..96f02b4440c56 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_mips64.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp
index efa4cc6d81825..4f869eb3b1771 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_powerpc.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -169,10 +168,8 @@ typedef struct _VMX {
uint32_t vscr;
} VMX;
-//---------------------------------------------------------------------------
// Include RegisterInfos_powerpc to declare our g_register_infos_powerpc
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_POWERPC_STRUCT
#include "RegisterInfos_powerpc.h"
#undef DECLARE_REGISTER_INFOS_POWERPC_STRUCT
@@ -191,7 +188,7 @@ size_t RegisterContextFreeBSD_powerpc::GetGPRSize() const {
const RegisterInfo *RegisterContextFreeBSD_powerpc::GetRegisterInfo() const {
// assert (m_target_arch.GetCore() == ArchSpec::eCore_powerpc);
llvm_unreachable("Abstract class!");
- return NULL;
+ return nullptr;
}
uint32_t RegisterContextFreeBSD_powerpc::GetRegisterCount() const { return 0; }
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
index b74d0ea75469f..ba2751194d168 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h
@@ -1,10 +1,9 @@
//===-- RegisterContextFreeBSD_powerpc.h -------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
index 4bbbd5c3d0a66..bcf3951ee0775 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_x86_64.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -62,10 +61,8 @@ struct UserArea {
#define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
-//---------------------------------------------------------------------------
// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_X86_64_STRUCT
#include "RegisterInfos_x86_64.h"
#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
@@ -89,10 +86,8 @@ GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
g_register_infos.insert(g_register_infos.end(), &base_info[0],
&base_info[k_num_registers_i386]);
-//---------------------------------------------------------------------------
// Include RegisterInfos_x86_64 to update the g_register_infos structure
// with x86_64 offsets.
-//---------------------------------------------------------------------------
#define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
#include "RegisterInfos_x86_64.h"
#undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
diff --git a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
index dc30f1783b41b..c379e1a5cd75f 100644
--- a/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextFreeBSD_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextFreeBSD_x86_64.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.cpp b/source/Plugins/Process/Utility/RegisterContextHistory.cpp
index c9b77663a8038..c19a2bfae668a 100644
--- a/source/Plugins/Process/Utility/RegisterContextHistory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextHistory.cpp
@@ -1,10 +1,9 @@
//===-- RegisterContextHistory.cpp ---------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,8 +50,8 @@ RegisterContextHistory::RegisterContextHistory(Thread &thread,
m_pc_reg_info.byte_size = address_byte_size;
m_pc_reg_info.encoding = eEncodingUint;
m_pc_reg_info.format = eFormatPointer;
- m_pc_reg_info.invalidate_regs = NULL;
- m_pc_reg_info.value_regs = NULL;
+ m_pc_reg_info.invalidate_regs = nullptr;
+ m_pc_reg_info.value_regs = nullptr;
m_pc_reg_info.kinds[eRegisterKindEHFrame] = LLDB_INVALID_REGNUM;
m_pc_reg_info.kinds[eRegisterKindDWARF] = LLDB_INVALID_REGNUM;
m_pc_reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_PC;
@@ -73,7 +72,7 @@ size_t RegisterContextHistory::GetRegisterCount() { return 1; }
const lldb_private::RegisterInfo *
RegisterContextHistory::GetRegisterInfoAtIndex(size_t reg) {
if (reg)
- return NULL;
+ return nullptr;
return &m_pc_reg_info;
}
@@ -82,7 +81,7 @@ size_t RegisterContextHistory::GetRegisterSetCount() { return 1; }
const lldb_private::RegisterSet *
RegisterContextHistory::GetRegisterSet(size_t reg_set) {
if (reg_set)
- return NULL;
+ return nullptr;
return &m_reg_set0;
}
diff --git a/source/Plugins/Process/Utility/RegisterContextHistory.h b/source/Plugins/Process/Utility/RegisterContextHistory.h
index 01b3624f8c5b8..952e4263d9559 100644
--- a/source/Plugins/Process/Utility/RegisterContextHistory.h
+++ b/source/Plugins/Process/Utility/RegisterContextHistory.h
@@ -1,10 +1,9 @@
//===-- RegisterContextHistory.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,9 +51,7 @@ public:
uint32_t num) override;
private:
- //------------------------------------------------------------------
// For RegisterContextLLDB only
- //------------------------------------------------------------------
lldb_private::RegisterSet m_reg_set0; // register set 0 (PC only)
lldb_private::RegisterInfo m_pc_reg_info;
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
index 8c420a87e1b03..76646d8897d19 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextLLDB.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,6 +34,8 @@
#include "RegisterContextLLDB.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -112,7 +113,7 @@ void RegisterContextLLDB::InitializeZerothFrame() {
ExecutionContext exe_ctx(m_thread.shared_from_this());
RegisterContextSP reg_ctx_sp = m_thread.GetRegisterContext();
- if (reg_ctx_sp.get() == NULL) {
+ if (reg_ctx_sp.get() == nullptr) {
m_frame_type = eNotAValidFrame;
UnwindLogMsg("frame does not have a register context");
return;
@@ -238,14 +239,13 @@ void RegisterContextLLDB::InitializeZerothFrame() {
if (m_sym_ctx_valid) {
func_unwinders_sp =
- pc_module_sp->GetObjectFile()
- ->GetUnwindTable()
- .GetFuncUnwindersContainingAddress(m_current_pc, m_sym_ctx);
+ pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
+ m_current_pc, m_sym_ctx);
}
if (func_unwinders_sp.get() != nullptr)
call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(
- process->GetTarget(), m_current_offset_backed_up_one);
+ process->GetTarget(), m_thread);
if (call_site_unwind_plan.get() != nullptr) {
m_fallback_unwind_plan_sp = call_site_unwind_plan;
@@ -370,7 +370,8 @@ void RegisterContextLLDB::InitializeNonZerothFrame() {
if (abi) {
m_fast_unwind_plan_sp.reset();
- m_full_unwind_plan_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric));
+ m_full_unwind_plan_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
abi->CreateDefaultUnwindPlan(*m_full_unwind_plan_sp);
if (m_frame_type != eSkipFrame) // don't override eSkipFrame
{
@@ -663,16 +664,15 @@ UnwindPlanSP RegisterContextLLDB::GetFastUnwindPlanForFrame() {
ModuleSP pc_module_sp(m_current_pc.GetModule());
if (!m_current_pc.IsValid() || !pc_module_sp ||
- pc_module_sp->GetObjectFile() == NULL)
+ pc_module_sp->GetObjectFile() == nullptr)
return unwind_plan_sp;
if (IsFrameZero())
return unwind_plan_sp;
FuncUnwindersSP func_unwinders_sp(
- pc_module_sp->GetObjectFile()
- ->GetUnwindTable()
- .GetFuncUnwindersContainingAddress(m_current_pc, m_sym_ctx));
+ pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
+ m_current_pc, m_sym_ctx));
if (!func_unwinders_sp)
return unwind_plan_sp;
@@ -715,10 +715,10 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
UnwindPlanSP arch_default_unwind_plan_sp;
ExecutionContext exe_ctx(m_thread.shared_from_this());
Process *process = exe_ctx.GetProcessPtr();
- ABI *abi = process ? process->GetABI().get() : NULL;
+ ABI *abi = process ? process->GetABI().get() : nullptr;
if (abi) {
- arch_default_unwind_plan_sp.reset(
- new UnwindPlan(lldb::eRegisterKindGeneric));
+ arch_default_unwind_plan_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
abi->CreateDefaultUnwindPlan(*arch_default_unwind_plan_sp);
} else {
UnwindLogMsg(
@@ -743,7 +743,7 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// This is for jumping to memory regions without any information available.
if ((!m_sym_ctx_valid ||
- (m_sym_ctx.function == NULL && m_sym_ctx.symbol == NULL)) &&
+ (m_sym_ctx.function == nullptr && m_sym_ctx.symbol == nullptr)) &&
behaves_like_zeroth_frame && m_current_pc.IsValid()) {
uint32_t permissions;
addr_t current_pc_addr =
@@ -753,7 +753,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
process->GetLoadAddressPermissions(current_pc_addr, permissions) &&
(permissions & ePermissionsExecutable) == 0)) {
if (abi) {
- unwind_plan_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric));
+ unwind_plan_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
abi->CreateFunctionEntryUnwindPlan(*unwind_plan_sp);
m_frame_type = eNormalFrame;
return unwind_plan_sp;
@@ -764,7 +765,7 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// No Module for the current pc, try using the architecture default unwind.
ModuleSP pc_module_sp(m_current_pc.GetModule());
if (!m_current_pc.IsValid() || !pc_module_sp ||
- pc_module_sp->GetObjectFile() == NULL) {
+ pc_module_sp->GetObjectFile() == nullptr) {
m_frame_type = eNormalFrame;
return arch_default_unwind_plan_sp;
}
@@ -772,9 +773,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
FuncUnwindersSP func_unwinders_sp;
if (m_sym_ctx_valid) {
func_unwinders_sp =
- pc_module_sp->GetObjectFile()
- ->GetUnwindTable()
- .GetFuncUnwindersContainingAddress(m_current_pc, m_sym_ctx);
+ pc_module_sp->GetUnwindTable().GetFuncUnwindersContainingAddress(
+ m_current_pc, m_sym_ctx);
}
// No FuncUnwinders available for this pc (stripped function symbols, lldb
@@ -792,9 +792,9 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// Even with -fomit-frame-pointer, we can try eh_frame to get back on
// track.
DWARFCallFrameInfo *eh_frame =
- pc_module_sp->GetObjectFile()->GetUnwindTable().GetEHFrameInfo();
+ pc_module_sp->GetUnwindTable().GetEHFrameInfo();
if (eh_frame) {
- unwind_plan_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric));
+ unwind_plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (eh_frame->GetUnwindPlan(m_current_pc, *unwind_plan_sp))
return unwind_plan_sp;
else
@@ -802,9 +802,9 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
}
ArmUnwindInfo *arm_exidx =
- pc_module_sp->GetObjectFile()->GetUnwindTable().GetArmUnwindInfo();
+ pc_module_sp->GetUnwindTable().GetArmUnwindInfo();
if (arm_exidx) {
- unwind_plan_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric));
+ unwind_plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (arm_exidx->GetUnwindPlan(exe_ctx.GetTargetRef(), m_current_pc,
*unwind_plan_sp))
return unwind_plan_sp;
@@ -822,8 +822,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// unwind out of sigtramp.
if (m_frame_type == eTrapHandlerFrame && process) {
m_fast_unwind_plan_sp.reset();
- unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan(
- process->GetTarget(), m_current_offset_backed_up_one);
+ unwind_plan_sp =
+ func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc) &&
unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes) {
return unwind_plan_sp;
@@ -844,8 +844,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// normally we would call GetUnwindPlanAtCallSite() -- because CallSite may
// return an unwind plan sourced from either eh_frame (that's what we
// intend) or compact unwind (this won't work)
- unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan(
- process->GetTarget(), m_current_offset_backed_up_one);
+ unwind_plan_sp =
+ func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because the "
"DynamicLoader suggested we prefer it",
@@ -858,7 +858,7 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// the assembly language instructions
if (behaves_like_zeroth_frame && process) {
unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
- process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+ process->GetTarget(), m_thread);
if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress(m_current_pc)) {
if (unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) {
// We probably have an UnwindPlan created by inspecting assembly
@@ -873,8 +873,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// location what helps in the most common cases when the instruction
// emulation fails.
UnwindPlanSP call_site_unwind_plan =
- func_unwinders_sp->GetUnwindPlanAtCallSite(
- process->GetTarget(), m_current_offset_backed_up_one);
+ func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(),
+ m_thread);
if (call_site_unwind_plan &&
call_site_unwind_plan.get() != unwind_plan_sp.get() &&
call_site_unwind_plan->GetSourceName() !=
@@ -884,21 +884,39 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp;
}
}
- UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
+ UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because this "
+ "is the non-call site unwind plan and this is a "
+ "zeroth frame",
unwind_plan_sp->GetSourceName().GetCString());
return unwind_plan_sp;
}
+
+ // If we're on the first instruction of a function, and we have an
+ // architectural default UnwindPlan for the initial instruction of a
+ // function, use that.
+ if (m_current_offset == 0) {
+ unwind_plan_sp =
+ func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
+ m_thread);
+ if (unwind_plan_sp) {
+ UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because we are at "
+ "the first instruction of a function",
+ unwind_plan_sp->GetSourceName().GetCString());
+ return unwind_plan_sp;
+ }
+ }
}
// Typically this is unwind info from an eh_frame section intended for
// exception handling; only valid at call sites
if (process) {
unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite(
- process->GetTarget(), m_current_offset_backed_up_one);
+ process->GetTarget(), m_thread);
}
int valid_offset = -1;
if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp, valid_offset)) {
- UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
+ UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because this "
+ "is the call-site unwind plan",
unwind_plan_sp->GetSourceName().GetCString());
return unwind_plan_sp;
}
@@ -908,7 +926,7 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// call-site assembly inspection UnwindPlan if possible.
if (process) {
unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite(
- process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+ process->GetTarget(), m_thread);
}
if (unwind_plan_sp &&
unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) {
@@ -923,8 +941,8 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
// code it is often written in a way that it valid at all location what
// helps in the most common cases when the instruction emulation fails.
UnwindPlanSP call_site_unwind_plan =
- func_unwinders_sp->GetUnwindPlanAtCallSite(
- process->GetTarget(), m_current_offset_backed_up_one);
+ func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(),
+ m_thread);
if (call_site_unwind_plan &&
call_site_unwind_plan.get() != unwind_plan_sp.get() &&
call_site_unwind_plan->GetSourceName() !=
@@ -936,30 +954,18 @@ UnwindPlanSP RegisterContextLLDB::GetFullUnwindPlanForFrame() {
}
if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp, valid_offset)) {
- UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
+ UnwindLogMsgVerbose("frame uses %s for full UnwindPlan because we "
+ "failed to find a call-site unwind plan that would work",
unwind_plan_sp->GetSourceName().GetCString());
return unwind_plan_sp;
}
- // If we're on the first instruction of a function, and we have an
- // architectural default UnwindPlan for the initial instruction of a
- // function, use that.
- if (m_current_offset_backed_up_one == 0) {
- unwind_plan_sp =
- func_unwinders_sp->GetUnwindPlanArchitectureDefaultAtFunctionEntry(
- m_thread);
- if (unwind_plan_sp) {
- UnwindLogMsgVerbose("frame uses %s for full UnwindPlan",
- unwind_plan_sp->GetSourceName().GetCString());
- return unwind_plan_sp;
- }
- }
-
// If nothing else, use the architectural default UnwindPlan and hope that
// does the job.
if (arch_default_unwind_plan_sp)
UnwindLogMsgVerbose(
- "frame uses %s for full UnwindPlan",
+ "frame uses %s for full UnwindPlan because we are falling back "
+ "to the arch default plan",
arch_default_unwind_plan_sp->GetSourceName().GetCString());
else
UnwindLogMsg(
@@ -1345,7 +1351,7 @@ RegisterContextLLDB::SavedLocationForRegister(
// register, we may be able to fall back to some ABI-defined default. For
// example, some ABIs allow to determine the caller's SP via the CFA. Also,
// the ABI may set volatile registers to the undefined state.
- ABI *abi = process ? process->GetABI().get() : NULL;
+ ABI *abi = process ? process->GetABI().get() : nullptr;
if (abi) {
const RegisterInfo *reg_info =
GetRegisterInfoAtIndex(regnum.GetAsKind(eRegisterKindLLDB));
@@ -1509,9 +1515,11 @@ RegisterContextLLDB::SavedLocationForRegister(
DWARFExpression dwarfexpr(opcode_ctx, dwarfdata, nullptr, 0,
unwindplan_regloc.GetDWARFExpressionLength());
dwarfexpr.SetRegisterKind(unwindplan_registerkind);
+ Value cfa_val = Scalar(m_cfa);
+ cfa_val.SetValueType(Value::eValueTypeLoadAddress);
Value result;
Status error;
- if (dwarfexpr.Evaluate(&exe_ctx, this, 0, nullptr, nullptr, result,
+ if (dwarfexpr.Evaluate(&exe_ctx, this, 0, &cfa_val, nullptr, result,
&error)) {
addr_t val;
val = result.GetScalar().ULongLong();
@@ -1696,10 +1704,10 @@ bool RegisterContextLLDB::TryFallbackUnwindPlan() {
}
bool RegisterContextLLDB::ForceSwitchToFallbackUnwindPlan() {
- if (m_fallback_unwind_plan_sp.get() == NULL)
+ if (m_fallback_unwind_plan_sp.get() == nullptr)
return false;
- if (m_full_unwind_plan_sp.get() == NULL)
+ if (m_full_unwind_plan_sp.get() == nullptr)
return false;
if (m_full_unwind_plan_sp.get() == m_fallback_unwind_plan_sp.get() ||
@@ -2061,7 +2069,7 @@ void RegisterContextLLDB::UnwindLogMsg(const char *fmt, ...) {
va_start(args, fmt);
char *logmsg;
- if (vasprintf(&logmsg, fmt, args) == -1 || logmsg == NULL) {
+ if (vasprintf(&logmsg, fmt, args) == -1 || logmsg == nullptr) {
if (logmsg)
free(logmsg);
va_end(args);
@@ -2082,7 +2090,7 @@ void RegisterContextLLDB::UnwindLogMsgVerbose(const char *fmt, ...) {
va_start(args, fmt);
char *logmsg;
- if (vasprintf(&logmsg, fmt, args) == -1 || logmsg == NULL) {
+ if (vasprintf(&logmsg, fmt, args) == -1 || logmsg == nullptr) {
if (logmsg)
free(logmsg);
va_end(args);
diff --git a/source/Plugins/Process/Utility/RegisterContextLLDB.h b/source/Plugins/Process/Utility/RegisterContextLLDB.h
index 50f12c6f8541a..64dd394d233be 100644
--- a/source/Plugins/Process/Utility/RegisterContextLLDB.h
+++ b/source/Plugins/Process/Utility/RegisterContextLLDB.h
@@ -1,10 +1,9 @@
//===-- RegisterContextLLDB.h --------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -111,15 +110,13 @@ private:
// user somehow.
bool IsSkipFrame() const;
- //------------------------------------------------------------------
/// Determines if a SymbolContext is a trap handler or not
///
/// Given a SymbolContext, determines if this is a trap handler function
/// aka asynchronous signal handler.
///
- /// @return
+ /// \return
/// Returns true if the SymbolContext is a trap handler.
- //------------------------------------------------------------------
bool IsTrapHandlerSymbol(lldb_private::Process *process,
const lldb_private::SymbolContext &m_sym_ctx) const;
@@ -155,7 +152,6 @@ private:
const lldb_private::RegisterInfo *reg_info,
const lldb_private::RegisterValue &value);
- //------------------------------------------------------------------
/// If the unwind has to the caller frame has failed, try something else
///
/// If lldb is using an assembly language based UnwindPlan for a frame and
@@ -164,12 +160,10 @@ private:
/// better. This is mostly helping to work around problems where the
/// assembly language inspection fails on hand-written assembly code.
///
- /// @return
+ /// \return
/// Returns true if a fallback unwindplan was found & was installed.
- //------------------------------------------------------------------
bool TryFallbackUnwindPlan();
- //------------------------------------------------------------------
/// Switch to the fallback unwind plan unconditionally without any safety
/// checks that it is providing better results than the normal unwind plan.
///
@@ -177,7 +171,6 @@ private:
/// found to be fundamentally incorrect/impossible.
///
/// Returns true if it was able to install the fallback unwind plan.
- //------------------------------------------------------------------
bool ForceSwitchToFallbackUnwindPlan();
// Get the contents of a general purpose (address-size) register for this
@@ -250,9 +243,7 @@ private:
lldb_private::UnwindLLDB &m_parent_unwind; // The UnwindLLDB that is creating
// this RegisterContextLLDB
- //------------------------------------------------------------------
// For RegisterContextLLDB only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(RegisterContextLLDB);
};
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
index 2cb17cb182e29..79979639dc7ee 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_i386.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -82,9 +81,7 @@ struct UserArea {
#define DR_OFFSET(reg_index) (DR_0_OFFSET + (reg_index * 4))
#define FPR_SIZE(reg) sizeof(((FPR_i386 *)NULL)->reg)
-//---------------------------------------------------------------------------
// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_I386_STRUCT
#include "RegisterInfos_i386.h"
#undef DECLARE_REGISTER_INFOS_I386_STRUCT
@@ -93,8 +90,8 @@ RegisterContextLinux_i386::RegisterContextLinux_i386(
const ArchSpec &target_arch)
: RegisterInfoInterface(target_arch) {
RegisterInfo orig_ax = {"orig_eax",
- NULL,
- sizeof(((GPR *)NULL)->orig_eax),
+ nullptr,
+ sizeof(((GPR *)nullptr)->orig_eax),
(LLVM_EXTENSION offsetof(GPR, orig_eax)),
eEncodingUint,
eFormatHex,
@@ -117,7 +114,7 @@ const RegisterInfo *RegisterContextLinux_i386::GetRegisterInfo() const {
return g_register_infos_i386;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_i386.h b/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
index fbf803789cc1c..5567a1ac42e50 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_i386.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
index 7b16531dcc894..fc60fea791761 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_mips.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -22,9 +21,7 @@
using namespace lldb_private;
using namespace lldb;
-//---------------------------------------------------------------------------
// Include RegisterInfos_mips to declare our g_register_infos_mips structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_MIPS_STRUCT
#include "RegisterInfos_mips.h"
#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
@@ -119,7 +116,7 @@ const RegisterInfo *RegisterContextLinux_mips::GetRegisterInfo() const {
return g_register_infos_mips;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
index a16c4ecd15f86..e637dfc15e4d6 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips.h
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_mips.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
index 1bb16c701126c..3927883c47a42 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_mips64.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -23,19 +22,15 @@
using namespace lldb;
using namespace lldb_private;
-//---------------------------------------------------------------------------
// Include RegisterInfos_mips64 to declare our g_register_infos_mips64
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_MIPS64_STRUCT
#define LINUX_MIPS64
#include "RegisterInfos_mips64.h"
#undef LINUX_MIPS64
#undef DECLARE_REGISTER_INFOS_MIPS64_STRUCT
-//---------------------------------------------------------------------------
// Include RegisterInfos_mips to declare our g_register_infos_mips structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_MIPS_STRUCT
#include "RegisterInfos_mips.h"
#undef DECLARE_REGISTER_INFOS_MIPS_STRUCT
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
index d3ca9d75300e2..ca0f0140a22d3 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_mips64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_mips64.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp
index 5a7f5a125246b..d6401d788ab2b 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_s390x.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
using namespace lldb_private;
using namespace lldb;
-//---------------------------------------------------------------------------
// Include RegisterInfos_s390x to declare our g_register_infos_s390x structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_S390X_STRUCT
#include "RegisterInfos_s390x.h"
#undef DECLARE_REGISTER_INFOS_S390X_STRUCT
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h
index 556cc2e124844..10810c97af80a 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_s390x.h
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_s390x.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
index 526b3eca81aeb..640d5bc022569 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_x86_64.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -76,10 +75,8 @@ struct UserArea {
(LLVM_EXTENSION offsetof(UserArea, dbg) + \
LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
-//---------------------------------------------------------------------------
// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_X86_64_STRUCT
#include "RegisterInfos_x86_64.h"
#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
@@ -103,10 +100,8 @@ GetRegisterInfo_i386(const lldb_private::ArchSpec &arch) {
g_register_infos.insert(g_register_infos.end(), &base_info[0],
&base_info[k_num_registers_i386]);
-//---------------------------------------------------------------------------
// Include RegisterInfos_x86_64 to update the g_register_infos structure
// with x86_64 offsets.
-//---------------------------------------------------------------------------
#define UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
#include "RegisterInfos_x86_64.h"
#undef UPDATE_REGISTER_INFOS_I386_STRUCT_WITH_X86_64_OFFSETS
@@ -162,8 +157,8 @@ RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(
m_register_info_count(GetRegisterInfoCount(target_arch)),
m_user_register_count(GetUserRegisterInfoCount(target_arch)) {
RegisterInfo orig_ax = {"orig_rax",
- NULL,
- sizeof(((GPR *)NULL)->orig_rax),
+ nullptr,
+ sizeof(((GPR *)nullptr)->orig_rax),
(LLVM_EXTENSION offsetof(GPR, orig_rax)),
eEncodingUint,
eFormatHex,
diff --git a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
index 99a4cb7367909..02f273cb02c96 100644
--- a/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextLinux_x86_64.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
index c0a6084cd7237..bc78c1d6160c2 100644
--- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMacOSXFrameBackchain.cpp -----------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,18 +19,14 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// RegisterContextMacOSXFrameBackchain constructor
-//----------------------------------------------------------------------
RegisterContextMacOSXFrameBackchain::RegisterContextMacOSXFrameBackchain(
Thread &thread, uint32_t concrete_frame_idx,
const UnwindMacOSXFrameBackchain::Cursor &cursor)
: RegisterContext(thread, concrete_frame_idx), m_cursor(cursor),
m_cursor_is_valid(true) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
RegisterContextMacOSXFrameBackchain::~RegisterContextMacOSXFrameBackchain() {}
void RegisterContextMacOSXFrameBackchain::InvalidateAllRegisters() {
diff --git a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
index 69e23c2782fd6..36e5538daa8a5 100644
--- a/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
+++ b/source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMacOSXFrameBackchain.h -------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp b/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
index 69522ace1a684..c7042ab5137a8 100644
--- a/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMach_arm.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMach_arm.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMach_arm.h b/source/Plugins/Process/Utility/RegisterContextMach_arm.h
index 5ea47f214e258..8b2425a193bec 100644
--- a/source/Plugins/Process/Utility/RegisterContextMach_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextMach_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMach_arm.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp b/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
index 94138605239ee..e631ab9bb26cb 100644
--- a/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMach_i386.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMach_i386.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMach_i386.h b/source/Plugins/Process/Utility/RegisterContextMach_i386.h
index a7e29e96b267d..b8835561e98c9 100644
--- a/source/Plugins/Process/Utility/RegisterContextMach_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextMach_i386.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMach_i386.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
index e523b95ee9743..db17d7d88778e 100644
--- a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMach_x86_64.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
index c73bdda79713e..688009aef8af8 100644
--- a/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextMach_x86_64.h
@@ -1,10 +1,9 @@
//===-- RegisterContextMach_x86_64.h ------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.cpp b/source/Plugins/Process/Utility/RegisterContextMemory.cpp
index f05c07f6c8e13..946d4fa9f8e55 100644
--- a/source/Plugins/Process/Utility/RegisterContextMemory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextMemory.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMemory.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// RegisterContextMemory constructor
-//----------------------------------------------------------------------
RegisterContextMemory::RegisterContextMemory(Thread &thread,
uint32_t concrete_frame_idx,
DynamicRegisterInfo &reg_infos,
@@ -41,9 +38,7 @@ RegisterContextMemory::RegisterContextMemory(Thread &thread,
m_reg_data.SetData(reg_data_sp);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
RegisterContextMemory::~RegisterContextMemory() {}
void RegisterContextMemory::InvalidateAllRegisters() {
diff --git a/source/Plugins/Process/Utility/RegisterContextMemory.h b/source/Plugins/Process/Utility/RegisterContextMemory.h
index cdf2a5446e1e6..68223eaeffd7d 100644
--- a/source/Plugins/Process/Utility/RegisterContextMemory.h
+++ b/source/Plugins/Process/Utility/RegisterContextMemory.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMemory.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,13 +39,11 @@ public:
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
- //------------------------------------------------------------------
// If all of the thread register are in a contiguous buffer in
// memory, then the default ReadRegister/WriteRegister and
// ReadAllRegisterValues/WriteAllRegisterValues will work. If thread
// registers are not contiguous, clients will want to subclass this
// class and modify the read/write functions as needed.
- //------------------------------------------------------------------
bool ReadRegister(const lldb_private::RegisterInfo *reg_info,
lldb_private::RegisterValue &reg_value) override;
diff --git a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
index ca7a0139ccc03..e620ff66c9226 100644
--- a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextNetBSD_x86_64.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -78,10 +77,8 @@ struct UserArea {
LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
-//---------------------------------------------------------------------------
// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_X86_64_STRUCT
#include "RegisterInfos_x86_64.h"
#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
diff --git a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
index 6b1998148d61b..4820ef8d17ba7 100644
--- a/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextNetBSD_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextNetBSD_x86_64.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
index 1f958105b10bf..06eac6f7f9910 100644
--- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextOpenBSD_i386.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -51,9 +50,7 @@ struct UserArea {
#define DR_SIZE sizeof(uint32_t)
#define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(dbreg, dr[reg_index]))
-//---------------------------------------------------------------------------
// Include RegisterInfos_i386 to declare our g_register_infos_i386 structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_I386_STRUCT
#include "RegisterInfos_i386.h"
#undef DECLARE_REGISTER_INFOS_I386_STRUCT
@@ -70,7 +67,7 @@ const RegisterInfo *RegisterContextOpenBSD_i386::GetRegisterInfo() const {
return g_register_infos_i386;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
index d3c13008bece7..992ce0959fdfe 100644
--- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_i386.h
@@ -1,9 +1,8 @@
//===-- RegisterContextOpenBSD_i386.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
index e7ff0732ffecb..e210196d921d4 100644
--- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextOpenBSD_x86_64.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -59,10 +58,8 @@ struct UserArea {
#define DR_OFFSET(reg_index) (LLVM_EXTENSION offsetof(DBG, dr[reg_index]))
-//---------------------------------------------------------------------------
// Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64
// structure.
-//---------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_X86_64_STRUCT
#include "RegisterInfos_x86_64.h"
#undef DECLARE_REGISTER_INFOS_X86_64_STRUCT
diff --git a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
index aa2b7733f3895..9c76e7211132b 100644
--- a/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterContextOpenBSD_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextOpenBSD_x86_64.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
index b0e53cfcc91fc..821e2aa73b5b1 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_arm.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -87,7 +86,7 @@ RegisterContextPOSIX_arm::RegisterContextPOSIX_arm(
lldb_private::Thread &thread, uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info)
: lldb_private::RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
switch (register_info->m_target_arch.GetMachine()) {
case llvm::Triple::arm:
@@ -132,14 +131,14 @@ size_t RegisterContextPOSIX_arm::GetRegisterCount() {
}
size_t RegisterContextPOSIX_arm::GetGPRSize() {
- return m_register_info_ap->GetGPRSize();
+ return m_register_info_up->GetGPRSize();
}
const lldb_private::RegisterInfo *RegisterContextPOSIX_arm::GetRegisterInfo() {
// Commonly, this method is overridden and g_register_infos is copied and
// specialized. So, use GetRegisterInfo() rather than g_register_infos in
// this scope.
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const lldb_private::RegisterInfo *
@@ -147,7 +146,7 @@ RegisterContextPOSIX_arm::GetRegisterInfoAtIndex(size_t reg) {
if (reg < m_reg_info.num_registers)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_arm::GetRegisterSetCount() {
@@ -163,15 +162,15 @@ size_t RegisterContextPOSIX_arm::GetRegisterSetCount() {
const lldb_private::RegisterSet *
RegisterContextPOSIX_arm::GetRegisterSet(size_t set) {
if (IsRegisterSetAvailable(set)) {
- switch (m_register_info_ap->m_target_arch.GetMachine()) {
+ switch (m_register_info_up->m_target_arch.GetMachine()) {
case llvm::Triple::arm:
return &g_reg_sets_arm[set];
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
const char *RegisterContextPOSIX_arm::GetRegisterName(unsigned reg) {
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
index 4b5a8fe95a4f8..603ba76430e6d 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_arm.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -84,7 +83,7 @@ protected:
struct RegisterContextPOSIX_arm::FPU
m_fpr; // floating-point registers including extended register sets.
std::unique_ptr<lldb_private::RegisterInfoInterface>
- m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
+ m_register_info_up; // Register Info Interface (FreeBSD or Linux)
// Determines if an extended register set is supported on the processor
// running the inferior process.
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
index 8b00dfc81eab3..99b897d441b59 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_arm64.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -106,7 +105,7 @@ RegisterContextPOSIX_arm64::RegisterContextPOSIX_arm64(
lldb_private::Thread &thread, uint32_t concrete_frame_idx,
lldb_private::RegisterInfoInterface *register_info)
: lldb_private::RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
switch (register_info->m_target_arch.GetMachine()) {
case llvm::Triple::aarch64:
@@ -151,7 +150,7 @@ size_t RegisterContextPOSIX_arm64::GetRegisterCount() {
}
size_t RegisterContextPOSIX_arm64::GetGPRSize() {
- return m_register_info_ap->GetGPRSize();
+ return m_register_info_up->GetGPRSize();
}
const lldb_private::RegisterInfo *
@@ -159,7 +158,7 @@ RegisterContextPOSIX_arm64::GetRegisterInfo() {
// Commonly, this method is overridden and g_register_infos is copied and
// specialized. So, use GetRegisterInfo() rather than g_register_infos in
// this scope.
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const lldb_private::RegisterInfo *
@@ -167,7 +166,7 @@ RegisterContextPOSIX_arm64::GetRegisterInfoAtIndex(size_t reg) {
if (reg < m_reg_info.num_registers)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() {
@@ -183,15 +182,15 @@ size_t RegisterContextPOSIX_arm64::GetRegisterSetCount() {
const lldb_private::RegisterSet *
RegisterContextPOSIX_arm64::GetRegisterSet(size_t set) {
if (IsRegisterSetAvailable(set)) {
- switch (m_register_info_ap->m_target_arch.GetMachine()) {
+ switch (m_register_info_up->m_target_arch.GetMachine()) {
case llvm::Triple::aarch64:
return &g_reg_sets_arm64[set];
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
const char *RegisterContextPOSIX_arm64::GetRegisterName(unsigned reg) {
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
index 603c12d830d9d..49a49b69da6b3 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_arm64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_arm64.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -84,7 +83,7 @@ protected:
struct RegisterContextPOSIX_arm64::FPU
m_fpr; // floating-point registers including extended register sets.
std::unique_ptr<lldb_private::RegisterInfoInterface>
- m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
+ m_register_info_up; // Register Info Interface (FreeBSD or Linux)
// Determines if an extended register set is supported on the processor
// running the inferior process.
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
index 9270d09f7293e..f1fa3035b2ef7 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_mips64.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -45,7 +44,7 @@ RegisterContextPOSIX_mips64::RegisterContextPOSIX_mips64(
Thread &thread, uint32_t concrete_frame_idx,
RegisterInfoInterface *register_info)
: RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
m_num_registers = GetRegisterCount();
int set = GetRegisterSetCount();
@@ -78,18 +77,18 @@ unsigned RegisterContextPOSIX_mips64::GetRegisterSize(unsigned reg) {
}
size_t RegisterContextPOSIX_mips64::GetRegisterCount() {
- return m_register_info_ap->GetRegisterCount();
+ return m_register_info_up->GetRegisterCount();
}
size_t RegisterContextPOSIX_mips64::GetGPRSize() {
- return m_register_info_ap->GetGPRSize();
+ return m_register_info_up->GetGPRSize();
}
const RegisterInfo *RegisterContextPOSIX_mips64::GetRegisterInfo() {
// Commonly, this method is overridden and g_register_infos is copied and
// specialized. So, use GetRegisterInfo() rather than g_register_infos in
// this scope.
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const RegisterInfo *
@@ -97,26 +96,26 @@ RegisterContextPOSIX_mips64::GetRegisterInfoAtIndex(size_t reg) {
if (reg < m_num_registers)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_mips64::GetRegisterSetCount() {
- ArchSpec target_arch = m_register_info_ap->GetTargetArchitecture();
+ ArchSpec target_arch = m_register_info_up->GetTargetArchitecture();
switch (target_arch.GetTriple().getOS()) {
case llvm::Triple::Linux: {
if ((target_arch.GetMachine() == llvm::Triple::mipsel) ||
(target_arch.GetMachine() == llvm::Triple::mips)) {
- const auto *context = static_cast<const RegisterContextLinux_mips *>
- (m_register_info_ap.get());
+ const auto *context = static_cast<const RegisterContextLinux_mips *>(
+ m_register_info_up.get());
return context->GetRegisterSetCount();
}
- const auto *context = static_cast<const RegisterContextLinux_mips64 *>
- (m_register_info_ap.get());
+ const auto *context = static_cast<const RegisterContextLinux_mips64 *>(
+ m_register_info_up.get());
return context->GetRegisterSetCount();
}
default: {
- const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>
- (m_register_info_ap.get());
+ const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>(
+ m_register_info_up.get());
return context->GetRegisterSetCount();
}
@@ -124,22 +123,22 @@ size_t RegisterContextPOSIX_mips64::GetRegisterSetCount() {
}
const RegisterSet *RegisterContextPOSIX_mips64::GetRegisterSet(size_t set) {
- ArchSpec target_arch = m_register_info_ap->GetTargetArchitecture();
+ ArchSpec target_arch = m_register_info_up->GetTargetArchitecture();
switch (target_arch.GetTriple().getOS()) {
case llvm::Triple::Linux: {
if ((target_arch.GetMachine() == llvm::Triple::mipsel) ||
(target_arch.GetMachine() == llvm::Triple::mips)) {
- const auto *context = static_cast<const RegisterContextLinux_mips *>
- (m_register_info_ap.get());
+ const auto *context = static_cast<const RegisterContextLinux_mips *>(
+ m_register_info_up.get());
return context->GetRegisterSet(set);
}
- const auto *context = static_cast<const RegisterContextLinux_mips64 *>
- (m_register_info_ap.get());
+ const auto *context = static_cast<const RegisterContextLinux_mips64 *>(
+ m_register_info_up.get());
return context->GetRegisterSet(set);
}
default: {
- const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>
- (m_register_info_ap.get());
+ const auto *context = static_cast<const RegisterContextFreeBSD_mips64 *>(
+ m_register_info_up.get());
return context->GetRegisterSet(set);
}
}
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
index 09cfd42b9c519..c507e14bd5b69 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_mips64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_mips64.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -62,7 +61,7 @@ protected:
uint32_t m_num_registers;
uint8_t m_registers_count[register_set_count];
std::unique_ptr<lldb_private::RegisterInfoInterface>
- m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
+ m_register_info_up; // Register Info Interface (FreeBSD or Linux)
// Determines if an extended register set is supported on the processor
// running the inferior process.
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
index 47a8e2c3f9e90..a78e9ed37947d 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.cpp
@@ -1,10 +1,9 @@
//===-- RegisterContextPOSIX_powerpc.cpp -------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -94,7 +93,7 @@ RegisterContextPOSIX_powerpc::RegisterContextPOSIX_powerpc(
Thread &thread, uint32_t concrete_frame_idx,
RegisterInfoInterface *register_info)
: RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
}
RegisterContextPOSIX_powerpc::~RegisterContextPOSIX_powerpc() {}
@@ -119,14 +118,14 @@ size_t RegisterContextPOSIX_powerpc::GetRegisterCount() {
}
size_t RegisterContextPOSIX_powerpc::GetGPRSize() {
- return m_register_info_ap->GetGPRSize();
+ return m_register_info_up->GetGPRSize();
}
const RegisterInfo *RegisterContextPOSIX_powerpc::GetRegisterInfo() {
// Commonly, this method is overridden and g_register_infos is copied and
// specialized. So, use GetRegisterInfo() rather than g_register_infos in
// this scope.
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const RegisterInfo *
@@ -134,7 +133,7 @@ RegisterContextPOSIX_powerpc::GetRegisterInfoAtIndex(size_t reg) {
if (reg < k_num_registers_powerpc)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_powerpc::GetRegisterSetCount() {
@@ -151,7 +150,7 @@ const RegisterSet *RegisterContextPOSIX_powerpc::GetRegisterSet(size_t set) {
if (IsRegisterSetAvailable(set))
return &g_reg_sets_powerpc[set];
else
- return NULL;
+ return nullptr;
}
const char *RegisterContextPOSIX_powerpc::GetRegisterName(unsigned reg) {
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
index 3260cb1ce8bc1..1a21a717b22b2 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_powerpc.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_powerpc.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
class ProcessMonitor;
-// ---------------------------------------------------------------------------
// Internal codes for all powerpc registers.
-// ---------------------------------------------------------------------------
enum {
k_first_gpr_powerpc,
gpr_r0_powerpc = k_first_gpr_powerpc,
@@ -178,7 +175,7 @@ protected:
m_fpr_powerpc[k_num_fpr_registers_powerpc]; // floating point registers.
uint32_t m_vmx_powerpc[k_num_vmx_registers_powerpc][4];
std::unique_ptr<lldb_private::RegisterInfoInterface>
- m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
+ m_register_info_up; // Register Info Interface (FreeBSD or Linux)
// Determines if an extended register set is supported on the processor
// running the inferior process.
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
index ef221c963dc48..02546c0ed16fa 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_ppc64le.cpp -------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -116,7 +115,7 @@ RegisterContextPOSIX_ppc64le::RegisterContextPOSIX_ppc64le(
Thread &thread, uint32_t concrete_frame_idx,
RegisterInfoInterface *register_info)
: RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
}
void RegisterContextPOSIX_ppc64le::InvalidateAllRegisters() {}
@@ -137,14 +136,14 @@ size_t RegisterContextPOSIX_ppc64le::GetRegisterCount() {
}
size_t RegisterContextPOSIX_ppc64le::GetGPRSize() {
- return m_register_info_ap->GetGPRSize();
+ return m_register_info_up->GetGPRSize();
}
const RegisterInfo *RegisterContextPOSIX_ppc64le::GetRegisterInfo() {
// Commonly, this method is overridden and g_register_infos is copied and
// specialized. So, use GetRegisterInfo() rather than g_register_infos in
// this scope.
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const RegisterInfo *
@@ -152,7 +151,7 @@ RegisterContextPOSIX_ppc64le::GetRegisterInfoAtIndex(size_t reg) {
if (reg < k_num_registers_ppc64le)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_ppc64le::GetRegisterSetCount() {
@@ -169,7 +168,7 @@ const RegisterSet *RegisterContextPOSIX_ppc64le::GetRegisterSet(size_t set) {
if (IsRegisterSetAvailable(set))
return &g_reg_sets_ppc64le[set];
else
- return NULL;
+ return nullptr;
}
const char *RegisterContextPOSIX_ppc64le::GetRegisterName(unsigned reg) {
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h
index 9159819f17c4f..37079775a3c73 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_ppc64le.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_ppc64le.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -56,7 +55,7 @@ protected:
// VSX registers.
uint64_t m_vsx_ppc64le[k_num_vsx_registers_ppc64le * 2];
- std::unique_ptr<lldb_private::RegisterInfoInterface> m_register_info_ap;
+ std::unique_ptr<lldb_private::RegisterInfoInterface> m_register_info_up;
// Determines if an extended register set is supported on the processor
// running the inferior process.
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
index 24f131099be4e..e040e5075721e 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_s390x.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -82,7 +81,7 @@ RegisterContextPOSIX_s390x::RegisterContextPOSIX_s390x(
Thread &thread, uint32_t concrete_frame_idx,
RegisterInfoInterface *register_info)
: RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
switch (register_info->m_target_arch.GetMachine()) {
case llvm::Triple::systemz:
@@ -106,7 +105,7 @@ void RegisterContextPOSIX_s390x::Invalidate() {}
void RegisterContextPOSIX_s390x::InvalidateAllRegisters() {}
const RegisterInfo *RegisterContextPOSIX_s390x::GetRegisterInfo() {
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const RegisterInfo *
@@ -114,7 +113,7 @@ RegisterContextPOSIX_s390x::GetRegisterInfoAtIndex(size_t reg) {
if (reg < m_reg_info.num_registers)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_s390x::GetRegisterCount() {
@@ -152,15 +151,15 @@ size_t RegisterContextPOSIX_s390x::GetRegisterSetCount() {
const RegisterSet *RegisterContextPOSIX_s390x::GetRegisterSet(size_t set) {
if (IsRegisterSetAvailable(set)) {
- switch (m_register_info_ap->m_target_arch.GetMachine()) {
+ switch (m_register_info_up->m_target_arch.GetMachine()) {
case llvm::Triple::systemz:
return &g_reg_sets_s390x[set];
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
lldb::ByteOrder RegisterContextPOSIX_s390x::GetByteOrder() {
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
index 7a7b6bddd6aa6..54993ce6c3ec7 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_s390x.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_s390x.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -59,7 +58,7 @@ protected:
};
RegInfo m_reg_info;
- std::unique_ptr<lldb_private::RegisterInfoInterface> m_register_info_ap;
+ std::unique_ptr<lldb_private::RegisterInfoInterface> m_register_info_up;
virtual bool IsRegisterSetAvailable(size_t set_index);
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
index 78f561a0f04fc..4d5991f08f1d9 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_x86.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -319,7 +318,7 @@ RegisterContextPOSIX_x86::RegisterContextPOSIX_x86(
Thread &thread, uint32_t concrete_frame_idx,
RegisterInfoInterface *register_info)
: RegisterContext(thread, concrete_frame_idx) {
- m_register_info_ap.reset(register_info);
+ m_register_info_up.reset(register_info);
switch (register_info->m_target_arch.GetMachine()) {
case llvm::Triple::x86:
@@ -405,7 +404,7 @@ size_t RegisterContextPOSIX_x86::GetRegisterCount() {
}
size_t RegisterContextPOSIX_x86::GetGPRSize() {
- return m_register_info_ap->GetGPRSize();
+ return m_register_info_up->GetGPRSize();
}
size_t RegisterContextPOSIX_x86::GetFXSAVEOffset() {
@@ -416,7 +415,7 @@ const RegisterInfo *RegisterContextPOSIX_x86::GetRegisterInfo() {
// Commonly, this method is overridden and g_register_infos is copied and
// specialized. So, use GetRegisterInfo() rather than g_register_infos in
// this scope.
- return m_register_info_ap->GetRegisterInfo();
+ return m_register_info_up->GetRegisterInfo();
}
const RegisterInfo *
@@ -424,7 +423,7 @@ RegisterContextPOSIX_x86::GetRegisterInfoAtIndex(size_t reg) {
if (reg < m_reg_info.num_registers)
return &GetRegisterInfo()[reg];
else
- return NULL;
+ return nullptr;
}
size_t RegisterContextPOSIX_x86::GetRegisterSetCount() {
@@ -439,17 +438,17 @@ size_t RegisterContextPOSIX_x86::GetRegisterSetCount() {
const RegisterSet *RegisterContextPOSIX_x86::GetRegisterSet(size_t set) {
if (IsRegisterSetAvailable(set)) {
- switch (m_register_info_ap->m_target_arch.GetMachine()) {
+ switch (m_register_info_up->m_target_arch.GetMachine()) {
case llvm::Triple::x86:
return &g_reg_sets_i386[set];
case llvm::Triple::x86_64:
return &g_reg_sets_x86_64[set];
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
const char *RegisterContextPOSIX_x86::GetRegisterName(unsigned reg) {
@@ -475,22 +474,13 @@ bool RegisterContextPOSIX_x86::CopyYMMtoXSTATE(uint32_t reg,
return false;
if (byte_order == eByteOrderLittle) {
- ::memcpy(m_fpr.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
- m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes, sizeof(XMMReg));
- ::memcpy(m_fpr.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
- m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
- sizeof(YMMHReg));
+ uint32_t reg_no = reg - m_reg_info.first_ymm;
+ YMMToXState(m_ymm_set.ymm[reg_no],
+ m_fpr.fxsave.xmm[reg_no].bytes,
+ m_fpr.xsave.ymmh[reg_no].bytes);
return true;
}
- if (byte_order == eByteOrderBig) {
- ::memcpy(m_fpr.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
- m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
- sizeof(XMMReg));
- ::memcpy(m_fpr.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
- m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes, sizeof(YMMHReg));
- return true;
- }
return false; // unsupported or invalid byte order
}
@@ -501,24 +491,13 @@ bool RegisterContextPOSIX_x86::CopyXSTATEtoYMM(uint32_t reg,
return false;
if (byte_order == eByteOrderLittle) {
- ::memcpy(m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes,
- m_fpr.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
- sizeof(XMMReg));
- ::memcpy(m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
- m_fpr.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
- sizeof(YMMHReg));
+ uint32_t reg_no = reg - m_reg_info.first_ymm;
+ m_ymm_set.ymm[reg_no] = XStateToYMM(
+ m_fpr.fxsave.xmm[reg_no].bytes,
+ m_fpr.xsave.ymmh[reg_no].bytes);
return true;
}
- if (byte_order == eByteOrderBig) {
- ::memcpy(m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes + sizeof(XMMReg),
- m_fpr.fxsave.xmm[reg - m_reg_info.first_ymm].bytes,
- sizeof(XMMReg));
- ::memcpy(m_ymm_set.ymm[reg - m_reg_info.first_ymm].bytes,
- m_fpr.xsave.ymmh[reg - m_reg_info.first_ymm].bytes,
- sizeof(YMMHReg));
- return true;
- }
return false; // unsupported or invalid byte order
}
diff --git a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
index b6db45e55bbf8..932f97bb567fa 100644
--- a/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
+++ b/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIX_x86.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,9 +50,7 @@ public:
uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind,
uint32_t num) override;
- //---------------------------------------------------------------------------
// Note: prefer kernel definitions over user-land
- //---------------------------------------------------------------------------
enum FPRType {
eNotValid = 0,
eFSAVE, // TODO
@@ -149,7 +146,7 @@ protected:
// register sets.
lldb_private::YMM m_ymm_set; // copy of ymmh and xmm register halves.
std::unique_ptr<lldb_private::RegisterInfoInterface>
- m_register_info_ap; // Register Info Interface (FreeBSD or Linux)
+ m_register_info_up; // Register Info Interface (FreeBSD or Linux)
// Determines if an extended register set is supported on the processor
// running the inferior process.
diff --git a/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp b/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
index 96ad139f73645..bcf60cc7a3384 100644
--- a/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
+++ b/source/Plugins/Process/Utility/RegisterContextThreadMemory.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextThreadMemory.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -55,9 +54,7 @@ void RegisterContextThreadMemory::UpdateRegisterContext() {
}
}
-//------------------------------------------------------------------
// Subclasses must override these functions
-//------------------------------------------------------------------
void RegisterContextThreadMemory::InvalidateAllRegisters() {
UpdateRegisterContext();
if (m_reg_ctx_sp)
@@ -76,7 +73,7 @@ RegisterContextThreadMemory::GetRegisterInfoAtIndex(size_t reg) {
UpdateRegisterContext();
if (m_reg_ctx_sp)
return m_reg_ctx_sp->GetRegisterInfoAtIndex(reg);
- return NULL;
+ return nullptr;
}
size_t RegisterContextThreadMemory::GetRegisterSetCount() {
@@ -90,7 +87,7 @@ const RegisterSet *RegisterContextThreadMemory::GetRegisterSet(size_t reg_set) {
UpdateRegisterContext();
if (m_reg_ctx_sp)
return m_reg_ctx_sp->GetRegisterSet(reg_set);
- return NULL;
+ return nullptr;
}
bool RegisterContextThreadMemory::ReadRegister(const RegisterInfo *reg_info,
diff --git a/source/Plugins/Process/Utility/RegisterContextThreadMemory.h b/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
index 0d50c73a31a95..09a679ab2c9f4 100644
--- a/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
+++ b/source/Plugins/Process/Utility/RegisterContextThreadMemory.h
@@ -1,9 +1,8 @@
//===-- RegisterContextThreadMemory.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContext_mips.h b/source/Plugins/Process/Utility/RegisterContext_mips.h
index da470bd827327..7780be51baad6 100644
--- a/source/Plugins/Process/Utility/RegisterContext_mips.h
+++ b/source/Plugins/Process/Utility/RegisterContext_mips.h
@@ -1,9 +1,8 @@
//===-- RegisterContext_mips.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContext_powerpc.h b/source/Plugins/Process/Utility/RegisterContext_powerpc.h
index 73242952c6d08..1ffcbeb5ec48c 100644
--- a/source/Plugins/Process/Utility/RegisterContext_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterContext_powerpc.h
@@ -1,10 +1,9 @@
//===-- RegisterContext_powerpc.h --------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterContext_s390x.h b/source/Plugins/Process/Utility/RegisterContext_s390x.h
index 90803dc167857..2cf39e9eb8e2a 100644
--- a/source/Plugins/Process/Utility/RegisterContext_s390x.h
+++ b/source/Plugins/Process/Utility/RegisterContext_s390x.h
@@ -1,18 +1,15 @@
//===-- RegisterContext_s390x.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef liblldb_RegisterContext_s390x_h_
#define liblldb_RegisterContext_s390x_h_
-//---------------------------------------------------------------------------
// SystemZ ehframe, dwarf regnums
-//---------------------------------------------------------------------------
// EHFrame and DWARF Register numbers (eRegisterKindEHFrame &
// eRegisterKindDWARF)
diff --git a/source/Plugins/Process/Utility/RegisterContext_x86.h b/source/Plugins/Process/Utility/RegisterContext_x86.h
index e3ff492d707ae..2b79f778aa563 100644
--- a/source/Plugins/Process/Utility/RegisterContext_x86.h
+++ b/source/Plugins/Process/Utility/RegisterContext_x86.h
@@ -1,9 +1,8 @@
//===-- RegisterContext_x86.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,9 +16,7 @@
#include "llvm/Support/Compiler.h"
namespace lldb_private {
-//---------------------------------------------------------------------------
// i386 ehframe, dwarf regnums
-//---------------------------------------------------------------------------
// Register numbers seen in eh_frame (eRegisterKindEHFrame) on i386 systems
// (non-Darwin)
@@ -132,9 +129,7 @@ enum {
dwarf_bnd3_i386,
};
-//---------------------------------------------------------------------------
// AMD x86_64, AMD64, Intel EM64T, or Intel 64 ehframe, dwarf regnums
-//---------------------------------------------------------------------------
// EHFrame and DWARF Register numbers (eRegisterKindEHFrame &
// eRegisterKindDWARF)
@@ -242,9 +237,7 @@ enum {
// dwarf_k7_x86_64,
};
-//---------------------------------------------------------------------------
// Generic floating-point registers
-//---------------------------------------------------------------------------
struct MMSReg {
uint8_t bytes[10];
@@ -283,9 +276,7 @@ struct FXSAVE {
uint8_t padding2[40];
};
-//---------------------------------------------------------------------------
// Extended floating-point registers
-//---------------------------------------------------------------------------
struct YMMHReg {
uint8_t bytes[16]; // 16 * 8 bits for the high bytes of each YMM register
@@ -341,7 +332,7 @@ LLVM_PACKED_END
// x86 extensions to FXSAVE (i.e. for AVX and MPX processors)
LLVM_PACKED_START
-struct LLVM_ALIGNAS(16) XSAVE {
+struct XSAVE {
FXSAVE i387; // floating point registers typical in i387_fxsave_struct
XSAVE_HDR header; // The xsave_hdr_struct can be used to determine if the
// following extensions are usable
@@ -362,6 +353,22 @@ union FPR {
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
+// Convenience function to combine YMM register data from XSAVE-style input.
+inline YMMReg XStateToYMM(const void* xmm_bytes, const void* ymmh_bytes) {
+ YMMReg ret;
+
+ ::memcpy(ret.bytes, xmm_bytes, sizeof(XMMReg));
+ ::memcpy(ret.bytes + sizeof(XMMReg), ymmh_bytes, sizeof(YMMHReg));
+
+ return ret;
+}
+
+// Convenience function to copy YMM register data into XSAVE-style output.
+inline void YMMToXState(const YMMReg& input, void* xmm_bytes, void* ymmh_bytes) {
+ ::memcpy(xmm_bytes, input.bytes, sizeof(XMMReg));
+ ::memcpy(ymmh_bytes, input.bytes + sizeof(XMMReg), sizeof(YMMHReg));
+}
+
} // namespace lldb_private
#endif
diff --git a/source/Plugins/Process/Utility/RegisterInfoInterface.h b/source/Plugins/Process/Utility/RegisterInfoInterface.h
index 5d7ad89ad3949..4b58e749adce6 100644
--- a/source/Plugins/Process/Utility/RegisterInfoInterface.h
+++ b/source/Plugins/Process/Utility/RegisterInfoInterface.h
@@ -1,9 +1,8 @@
//===-- RegisterInfoInterface.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,11 +15,9 @@
namespace lldb_private {
-///------------------------------------------------------------------------------
-/// @class RegisterInfoInterface
+/// \class RegisterInfoInterface
///
/// RegisterInfo interface to patch RegisterInfo structure for archs.
-///------------------------------------------------------------------------------
class RegisterInfoInterface {
public:
RegisterInfoInterface(const lldb_private::ArchSpec &target_arch)
diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
index 0111b842509ba..d392d3be1c41c 100644
--- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.cpp
@@ -1,9 +1,8 @@
//===-- RegisterInfoPOSIX_arm.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -44,9 +43,7 @@ using namespace lldb_private;
(sizeof(RegisterInfoPOSIX_arm::GPR) + sizeof(RegisterInfoPOSIX_arm::FPU) + \
sizeof(RegisterInfoPOSIX_arm::EXC))
-//-----------------------------------------------------------------------------
// Include RegisterInfos_arm to declare our g_register_infos_arm structure.
-//-----------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_ARM_STRUCT
#include "RegisterInfos_arm.h"
#undef DECLARE_REGISTER_INFOS_ARM_STRUCT
@@ -58,7 +55,7 @@ GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
return g_register_infos_arm;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
index d90aec1c5116f..39c2047600aa4 100644
--- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterInfoPOSIX_arm.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
index 1b145e0a173b8..f7471526d0548 100644
--- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterInfoPOSIX_arm64.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -49,9 +48,7 @@
sizeof(RegisterInfoPOSIX_arm64::FPU) + \
sizeof(RegisterInfoPOSIX_arm64::EXC))
-//-----------------------------------------------------------------------------
// Include RegisterInfos_arm64 to declare our g_register_infos_arm64 structure.
-//-----------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_ARM64_STRUCT
#include "RegisterInfos_arm64.h"
#undef DECLARE_REGISTER_INFOS_ARM64_STRUCT
@@ -63,7 +60,7 @@ GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
return g_register_infos_arm64_le;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
index af770760cbf48..ace179a818140 100644
--- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
@@ -1,9 +1,8 @@
//===-- RegisterInfoPOSIX_arm64.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
index e5e7350fe68ad..35051a3ce095f 100644
--- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.cpp
@@ -1,9 +1,8 @@
//===-- RegisterInfoPOSIX_ppc64le.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
#include "RegisterInfoPOSIX_ppc64le.h"
-//-----------------------------------------------------------------------------
// Include RegisterInfoPOSIX_ppc64le to declare our g_register_infos_ppc64le
-//-----------------------------------------------------------------------------
#define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
#include "RegisterInfos_ppc64le.h"
#undef DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
@@ -30,7 +27,7 @@ GetRegisterInfoPtr(const lldb_private::ArchSpec &target_arch) {
return g_register_infos_ppc64le;
default:
assert(false && "Unhandled target architecture.");
- return NULL;
+ return nullptr;
}
}
diff --git a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h
index 411ab05c2b13d..c4d4d3b546e2a 100644
--- a/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h
+++ b/source/Plugins/Process/Utility/RegisterInfoPOSIX_ppc64le.h
@@ -1,9 +1,8 @@
//===-- RegisterInfoPOSIX_ppc64le.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_arm.h b/source/Plugins/Process/Utility/RegisterInfos_arm.h
index ec951ea8a391b..74b9e3b2db322 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_arm.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_arm.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_arm64.h b/source/Plugins/Process/Utility/RegisterInfos_arm64.h
index 039d98ecdd2d6..4ee0b528f2290 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_arm64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_arm64.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_arm64.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_i386.h b/source/Plugins/Process/Utility/RegisterInfos_i386.h
index f8947876d15f4..72ff904520adc 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_i386.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_i386.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_i386.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_mips.h b/source/Plugins/Process/Utility/RegisterInfos_mips.h
index 36483c068d266..08201fd1191c6 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_mips.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_mips.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_mips.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_mips64.h b/source/Plugins/Process/Utility/RegisterInfos_mips64.h
index 0194074f34f25..b6e218ea4414c 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_mips64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_mips64.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_mips64.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_powerpc.h b/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
index c0d47f0d991f7..51be31f8e0284 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_powerpc.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_powerpc.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_ppc64.h b/source/Plugins/Process/Utility/RegisterInfos_ppc64.h
index dbd87ad71a45c..1086d3db0b062 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_ppc64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_ppc64.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_ppc64.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h b/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h
index e6fa17b607587..0b099a53d8755 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_ppc64le.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_ppc64le.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_s390x.h b/source/Plugins/Process/Utility/RegisterInfos_s390x.h
index b750be4116a5e..11344ff8ee797 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_s390x.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_s390x.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_s390x.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/RegisterInfos_x86_64.h b/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
index 651536cb60450..4a3b3c73fd6b9 100644
--- a/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
+++ b/source/Plugins/Process/Utility/RegisterInfos_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterInfos_x86_64.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.cpp b/source/Plugins/Process/Utility/StopInfoMachException.cpp
index de0821eb42530..588015a51ef16 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -1,9 +1,8 @@
//===-- StopInfoMachException.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,11 +37,11 @@ const char *StopInfoMachException::GetDescription() {
target ? target->GetArchitecture().GetMachine()
: llvm::Triple::UnknownArch;
- const char *exc_desc = NULL;
+ const char *exc_desc = nullptr;
const char *code_label = "code";
- const char *code_desc = NULL;
+ const char *code_desc = nullptr;
const char *subcode_label = "subcode";
- const char *subcode_desc = NULL;
+ const char *subcode_desc = nullptr;
#if defined(__APPLE__)
char code_desc_buf[32];
@@ -594,7 +593,7 @@ StopInfoSP StopInfoMachException::CreateStopReasonWithMachException(
// the thread ID so we must always report the breakpoint regardless
// of the thread.
if (bp_site_sp->ValidForThisThread(&thread) ||
- thread.GetProcess()->GetOperatingSystem() != NULL)
+ thread.GetProcess()->GetOperatingSystem() != nullptr)
return StopInfo::CreateStopReasonWithBreakpointSiteID(
thread, bp_site_sp->GetID());
else if (is_trace_if_actual_breakpoint_missing)
diff --git a/source/Plugins/Process/Utility/StopInfoMachException.h b/source/Plugins/Process/Utility/StopInfoMachException.h
index 027ed80e8a984..74c05812ab002 100644
--- a/source/Plugins/Process/Utility/StopInfoMachException.h
+++ b/source/Plugins/Process/Utility/StopInfoMachException.h
@@ -1,9 +1,8 @@
//===-- StopInfoMachException.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@ namespace lldb_private {
class StopInfoMachException : public StopInfo {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
StopInfoMachException(Thread &thread, uint32_t exc_type,
uint32_t exc_data_count, uint64_t exc_code,
uint64_t exc_subcode)
diff --git a/source/Plugins/Process/Utility/ThreadMemory.cpp b/source/Plugins/Process/Utility/ThreadMemory.cpp
index 0c7c195815a46..80b04bb14f77a 100644
--- a/source/Plugins/Process/Utility/ThreadMemory.cpp
+++ b/source/Plugins/Process/Utility/ThreadMemory.cpp
@@ -1,14 +1,14 @@
//===-- ThreadMemory.cpp ----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Plugins/Process/Utility/ThreadMemory.h"
+
#include "Plugins/Process/Utility/RegisterContextThreadMemory.h"
#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/Process.h"
@@ -16,6 +16,8 @@
#include "lldb/Target/StopInfo.h"
#include "lldb/Target/Unwind.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -45,8 +47,8 @@ void ThreadMemory::ClearStackFrames() {
RegisterContextSP ThreadMemory::GetRegisterContext() {
if (!m_reg_context_sp)
- m_reg_context_sp.reset(
- new RegisterContextThreadMemory(*this, m_register_data_addr));
+ m_reg_context_sp = std::make_shared<RegisterContextThreadMemory>(
+ *this, m_register_data_addr);
return m_reg_context_sp;
}
diff --git a/source/Plugins/Process/Utility/ThreadMemory.h b/source/Plugins/Process/Utility/ThreadMemory.h
index c966ca03a017a..85bc1451e4a0e 100644
--- a/source/Plugins/Process/Utility/ThreadMemory.h
+++ b/source/Plugins/Process/Utility/ThreadMemory.h
@@ -1,9 +1,8 @@
//===-- ThreadMemory.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.cpp b/source/Plugins/Process/Utility/UnwindLLDB.cpp
index b34c87230bd15..38209fb249483 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.cpp
+++ b/source/Plugins/Process/Utility/UnwindLLDB.cpp
@@ -1,9 +1,8 @@
//===-- UnwindLLDB.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,7 +50,7 @@ uint32_t UnwindLLDB::DoGetFrameCount() {
return 0;
ProcessSP process_sp(m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
while (AddOneMoreFrame(abi)) {
#if DEBUG_FRAME_SPEED
@@ -74,13 +73,13 @@ bool UnwindLLDB::AddFirstFrame() {
return true;
ProcessSP process_sp(m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
// First, set up the 0th (initial) frame
CursorSP first_cursor_sp(new Cursor());
RegisterContextLLDBSP reg_ctx_sp(new RegisterContextLLDB(
m_thread, RegisterContextLLDBSP(), first_cursor_sp->sctx, 0, *this));
- if (reg_ctx_sp.get() == NULL)
+ if (reg_ctx_sp.get() == nullptr)
goto unwind_done;
if (!reg_ctx_sp->IsValid())
@@ -148,7 +147,7 @@ UnwindLLDB::CursorSP UnwindLLDB::GetOneMoreFrame(ABI *abi) {
return nullptr;
}
- if (reg_ctx_sp.get() == NULL) {
+ if (reg_ctx_sp.get() == nullptr) {
// If the RegisterContextLLDB has a fallback UnwindPlan, it will switch to
// that and return true. Subsequent calls to TryFallbackUnwindPlan() will
// return false.
@@ -403,7 +402,7 @@ bool UnwindLLDB::DoGetFrameInfoAtIndex(uint32_t idx, addr_t &cfa, addr_t &pc) {
}
ProcessSP process_sp(m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
while (idx >= m_frames.size() && AddOneMoreFrame(abi))
;
@@ -431,7 +430,7 @@ UnwindLLDB::DoCreateRegisterContextForFrame(StackFrame *frame) {
}
ProcessSP process_sp(m_thread.GetProcess());
- ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ ABI *abi = process_sp ? process_sp->GetABI().get() : nullptr;
while (idx >= m_frames.size()) {
if (!AddOneMoreFrame(abi))
diff --git a/source/Plugins/Process/Utility/UnwindLLDB.h b/source/Plugins/Process/Utility/UnwindLLDB.h
index aec7b66d93540..c512929c185b4 100644
--- a/source/Plugins/Process/Utility/UnwindLLDB.h
+++ b/source/Plugins/Process/Utility/UnwindLLDB.h
@@ -1,9 +1,8 @@
//===-- UnwindLLDB.h --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -94,7 +93,6 @@ protected:
uint32_t lldb_regnum, lldb_private::UnwindLLDB::RegisterLocation &regloc,
uint32_t starting_frame_num, bool pc_register);
- //------------------------------------------------------------------
/// Provide the list of user-specified trap handler functions
///
/// The Platform is one source of trap handler function names; that
@@ -102,10 +100,9 @@ protected:
/// into an array of ConstStrings before it can be used - we only want
/// to do that once per thread so it's here in the UnwindLLDB object.
///
- /// @return
+ /// \return
/// Vector of ConstStrings of trap handler function names. May be
/// empty.
- //------------------------------------------------------------------
const std::vector<ConstString> &GetUserSpecifiedTrapHandlerFunctionNames() {
return m_user_supplied_trap_handler_functions;
}
@@ -139,12 +136,10 @@ private:
std::vector<ConstString> m_user_supplied_trap_handler_functions;
- //-----------------------------------------------------------------
// Check if Full UnwindPlan of First frame is valid or not.
// If not then try Fallback UnwindPlan of the frame. If Fallback
// UnwindPlan succeeds then update the Full UnwindPlan with the
// Fallback UnwindPlan.
- //-----------------------------------------------------------------
void UpdateUnwindPlanForFirstFrameIfInvalid(ABI *abi);
CursorSP GetOneMoreFrame(ABI *abi);
@@ -153,9 +148,7 @@ private:
bool AddFirstFrame();
- //------------------------------------------------------------------
// For UnwindLLDB only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(UnwindLLDB);
};
diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
index ae0b9fb0a5269..7dc5a5f5fdd1b 100644
--- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
+++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.cpp
@@ -1,9 +1,8 @@
//===-- UnwindMacOSXFrameBackchain.cpp --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,8 @@
#include "RegisterContextMacOSXFrameBackchain.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -66,8 +67,8 @@ UnwindMacOSXFrameBackchain::DoCreateRegisterContextForFrame(StackFrame *frame) {
uint32_t concrete_idx = frame->GetConcreteFrameIndex();
const uint32_t frame_count = GetFrameCount();
if (concrete_idx < frame_count)
- reg_ctx_sp.reset(new RegisterContextMacOSXFrameBackchain(
- m_thread, concrete_idx, m_cursors[concrete_idx]));
+ reg_ctx_sp = std::make_shared<RegisterContextMacOSXFrameBackchain>(
+ m_thread, concrete_idx, m_cursors[concrete_idx]);
return reg_ctx_sp;
}
@@ -78,7 +79,7 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386(
StackFrame *first_frame = exe_ctx.GetFramePtr();
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return 0;
struct Frame_i386 {
@@ -120,7 +121,7 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_i386(
SymbolContext first_frame_sc(
first_frame->GetSymbolContext(resolve_scope));
- const AddressRange *addr_range_ptr = NULL;
+ const AddressRange *addr_range_ptr = nullptr;
AddressRange range;
if (first_frame_sc.function)
addr_range_ptr = &first_frame_sc.function->GetAddressRange();
@@ -168,7 +169,7 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64(
m_cursors.clear();
Process *process = exe_ctx.GetProcessPtr();
- if (process == NULL)
+ if (process == nullptr)
return 0;
StackFrame *first_frame = exe_ctx.GetFramePtr();
@@ -211,7 +212,7 @@ size_t UnwindMacOSXFrameBackchain::GetStackFrameData_x86_64(
SymbolContext first_frame_sc(
first_frame->GetSymbolContext(resolve_scope));
- const AddressRange *addr_range_ptr = NULL;
+ const AddressRange *addr_range_ptr = nullptr;
AddressRange range;
if (first_frame_sc.function)
addr_range_ptr = &first_frame_sc.function->GetAddressRange();
diff --git a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
index 9ee0b08ca09a3..2208bcc2f2e4f 100644
--- a/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
+++ b/source/Plugins/Process/Utility/UnwindMacOSXFrameBackchain.h
@@ -1,9 +1,8 @@
//===-- UnwindMacOSXFrameBackchain.h ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -47,9 +46,7 @@ private:
size_t
GetStackFrameData_x86_64(const lldb_private::ExecutionContext &exe_ctx);
- //------------------------------------------------------------------
// For UnwindMacOSXFrameBackchain only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(UnwindMacOSXFrameBackchain);
};
diff --git a/source/Plugins/Process/Utility/lldb-arm-register-enums.h b/source/Plugins/Process/Utility/lldb-arm-register-enums.h
index 49473bb885f21..39cbf01ea9d27 100644
--- a/source/Plugins/Process/Utility/lldb-arm-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-arm-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-arm-register-enums.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-//---------------------------------------------------------------------------
// Internal codes for all ARM registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_arm = 0,
gpr_r0_arm = k_first_gpr_arm,
diff --git a/source/Plugins/Process/Utility/lldb-arm64-register-enums.h b/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
index 7181ce4481957..cc414dcde3cfe 100644
--- a/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-arm64-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-arm64-register-enums.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-//---------------------------------------------------------------------------
// Internal codes for all ARM64 registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_arm64,
gpr_x0_arm64 = k_first_gpr_arm64,
diff --git a/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h b/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
index 61929365b7361..d97f771224267 100644
--- a/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-mips-freebsd-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-mips-freebsd-register-enums.h ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-//---------------------------------------------------------------------------
// Internal codes for all mips registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_mips64,
gpr_zero_mips64 = k_first_gpr_mips64,
diff --git a/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h b/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
index 0ecf3e366db06..2f68b8022c9ae 100644
--- a/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-mips-linux-register-enums.h
@@ -1,10 +1,9 @@
//===-- lldb-mips-linux-register-enums.h -------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,9 +13,7 @@
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-//---------------------------------------------------------------------------
// Internal codes for all mips registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_mips,
gpr_zero_mips = k_first_gpr_mips,
@@ -149,9 +146,7 @@ enum {
k_num_msa_registers_mips
};
-//---------------------------------------------------------------------------
// Internal codes for all mips64 registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_mips64,
gpr_zero_mips64 = k_first_gpr_mips64,
diff --git a/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h b/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h
index 9ea81c00b6668..6edf7ee3864d9 100644
--- a/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-ppc64-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-ppc64-register-enums.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,9 +11,7 @@
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-// ---------------------------------------------------------------------------
// Internal codes for all ppc64 registers.
-// ---------------------------------------------------------------------------
enum {
k_first_gpr_ppc64,
gpr_r0_ppc64 = k_first_gpr_ppc64,
diff --git a/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h b/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h
index 675804d132680..0c381a5f39182 100644
--- a/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-ppc64le-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-ppc64le-register-enums.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,9 +11,7 @@
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-// ---------------------------------------------------------------------------
// Internal codes for all ppc64le registers.
-// ---------------------------------------------------------------------------
enum {
k_first_gpr_ppc64le,
gpr_r0_ppc64le = k_first_gpr_ppc64le,
diff --git a/source/Plugins/Process/Utility/lldb-s390x-register-enums.h b/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
index 65ff92f39bcac..bd66261082904 100644
--- a/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-s390x-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-s390x-register-enums.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-//---------------------------------------------------------------------------
// Internal codes for all s390x registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_s390x,
lldb_r0_s390x = k_first_gpr_s390x,
diff --git a/source/Plugins/Process/Utility/lldb-x86-register-enums.h b/source/Plugins/Process/Utility/lldb-x86-register-enums.h
index 770ec5a5f3ef8..0d2149c835736 100644
--- a/source/Plugins/Process/Utility/lldb-x86-register-enums.h
+++ b/source/Plugins/Process/Utility/lldb-x86-register-enums.h
@@ -1,9 +1,8 @@
//===-- lldb-x86-register-enums.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,9 +12,7 @@
namespace lldb_private {
// LLDB register codes (e.g. RegisterKind == eRegisterKindLLDB)
-//---------------------------------------------------------------------------
// Internal codes for all i386 registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_i386,
lldb_eax_i386 = k_first_gpr_i386,
@@ -136,9 +133,7 @@ enum {
k_num_mpx_registers_i386,
};
-//---------------------------------------------------------------------------
// Internal codes for all x86_64 registers.
-//---------------------------------------------------------------------------
enum {
k_first_gpr_x86_64,
lldb_rax_x86_64 = k_first_gpr_x86_64,
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 7d66461c15bcb..980169e16c51d 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -1,14 +1,14 @@
//===-- ProcessElfCore.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <stdlib.h>
+#include <memory>
#include <mutex>
#include "lldb/Core/Module.h"
@@ -66,8 +66,8 @@ lldb::ProcessSP ProcessElfCore::CreateInstance(lldb::TargetSP target_sp,
lldb::offset_t data_offset = 0;
if (elf_header.Parse(data, &data_offset)) {
if (elf_header.e_type == llvm::ELF::ET_CORE)
- process_sp.reset(
- new ProcessElfCore(target_sp, listener_sp, *crash_file));
+ process_sp = std::make_shared<ProcessElfCore>(target_sp, listener_sp,
+ *crash_file);
}
}
}
@@ -80,7 +80,7 @@ bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp,
if (!m_core_module_sp && FileSystem::Instance().Exists(m_core_file)) {
ModuleSpec core_module_spec(m_core_file, target_sp->GetArchitecture());
Status error(ModuleList::GetSharedModule(core_module_spec, m_core_module_sp,
- NULL, NULL, NULL));
+ nullptr, nullptr, nullptr));
if (m_core_module_sp) {
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
if (core_objfile && core_objfile->GetType() == ObjectFile::eTypeCoreFile)
@@ -90,17 +90,13 @@ bool ProcessElfCore::CanDebug(lldb::TargetSP target_sp,
return false;
}
-//----------------------------------------------------------------------
// ProcessElfCore constructor
-//----------------------------------------------------------------------
ProcessElfCore::ProcessElfCore(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
const FileSpec &core_file)
: Process(target_sp, listener_sp), m_core_file(core_file) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ProcessElfCore::~ProcessElfCore() {
Clear();
// We need to call finalize on the process before destroying ourselves to
@@ -110,9 +106,7 @@ ProcessElfCore::~ProcessElfCore() {
Finalize();
}
-//----------------------------------------------------------------------
// PluginInterface
-//----------------------------------------------------------------------
ConstString ProcessElfCore::GetPluginName() { return GetPluginNameStatic(); }
uint32_t ProcessElfCore::GetPluginVersion() { return 1; }
@@ -146,9 +140,7 @@ lldb::addr_t ProcessElfCore::AddAddressRangeFromLoadSegment(
return addr;
}
-//----------------------------------------------------------------------
// Process Control
-//----------------------------------------------------------------------
Status ProcessElfCore::DoLoadCore() {
Status error;
if (!m_core_module_sp) {
@@ -157,7 +149,7 @@ Status ProcessElfCore::DoLoadCore() {
}
ObjectFileELF *core = (ObjectFileELF *)(m_core_module_sp->GetObjectFile());
- if (core == NULL) {
+ if (core == nullptr) {
error.SetErrorString("invalid core object file");
return error;
}
@@ -244,7 +236,8 @@ Status ProcessElfCore::DoLoadCore() {
exe_module_spec.GetFileSpec().SetFile(
m_nt_file_entries[0].path.GetCString(), FileSpec::Style::native);
if (exe_module_spec.GetFileSpec()) {
- exe_module_sp = GetTarget().GetSharedModule(exe_module_spec);
+ exe_module_sp = GetTarget().GetOrCreateModule(exe_module_spec,
+ true /* notify */);
if (exe_module_sp)
GetTarget().SetExecutableModule(exe_module_sp, eLoadDependentsNo);
}
@@ -254,10 +247,10 @@ Status ProcessElfCore::DoLoadCore() {
}
lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
- if (m_dyld_ap.get() == NULL)
- m_dyld_ap.reset(DynamicLoader::FindPlugin(
+ if (m_dyld_up.get() == nullptr)
+ m_dyld_up.reset(DynamicLoader::FindPlugin(
this, DynamicLoaderPOSIXDYLD::GetPluginNameStatic().GetCString()));
- return m_dyld_ap.get();
+ return m_dyld_up.get();
}
bool ProcessElfCore::UpdateThreadList(ThreadList &old_thread_list,
@@ -278,15 +271,11 @@ void ProcessElfCore::RefreshStateAfterStop() {}
Status ProcessElfCore::DoDestroy() { return Status(); }
-//------------------------------------------------------------------
// Process Queries
-//------------------------------------------------------------------
bool ProcessElfCore::IsAlive() { return true; }
-//------------------------------------------------------------------
// Process Memory
-//------------------------------------------------------------------
size_t ProcessElfCore::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
Status &error) {
// Don't allow the caching that lldb_private::Process::ReadMemory does since
@@ -338,13 +327,13 @@ size_t ProcessElfCore::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
Status &error) {
ObjectFile *core_objfile = m_core_module_sp->GetObjectFile();
- if (core_objfile == NULL)
+ if (core_objfile == nullptr)
return 0;
// Get the address range
const VMRangeToFileOffset::Entry *address_range =
m_core_aranges.FindEntryThatContains(addr);
- if (address_range == NULL || address_range->GetRangeEnd() < addr) {
+ if (address_range == nullptr || address_range->GetRangeEnd() < addr) {
error.SetErrorStringWithFormat("core file does not contain 0x%" PRIx64,
addr);
return 0;
@@ -446,16 +435,48 @@ static void ParseFreeBSDPrStatus(ThreadData &thread_data,
thread_data.gpregset = DataExtractor(data, offset, len);
}
-static void ParseNetBSDProcInfo(ThreadData &thread_data,
- const DataExtractor &data) {
+static llvm::Error ParseNetBSDProcInfo(const DataExtractor &data,
+ uint32_t &cpi_nlwps,
+ uint32_t &cpi_signo,
+ uint32_t &cpi_siglwp,
+ uint32_t &cpi_pid) {
lldb::offset_t offset = 0;
- int version = data.GetU32(&offset);
+ uint32_t version = data.GetU32(&offset);
if (version != 1)
- return;
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Unsupported procinfo version",
+ llvm::inconvertibleErrorCode());
- offset += 4;
- thread_data.signo = data.GetU32(&offset);
+ uint32_t cpisize = data.GetU32(&offset);
+ if (cpisize != NETBSD::NT_PROCINFO_SIZE)
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Unsupported procinfo size",
+ llvm::inconvertibleErrorCode());
+
+ cpi_signo = data.GetU32(&offset); /* killing signal */
+
+ offset += NETBSD::NT_PROCINFO_CPI_SIGCODE_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SIGPEND_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SIGMASK_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SIGIGNORE_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SIGCATCH_SIZE;
+ cpi_pid = data.GetU32(&offset);
+ offset += NETBSD::NT_PROCINFO_CPI_PPID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_PGRP_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_RUID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_EUID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SVUID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_RGID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_EGID_SIZE;
+ offset += NETBSD::NT_PROCINFO_CPI_SVGID_SIZE;
+ cpi_nlwps = data.GetU32(&offset); /* number of LWPs */
+
+ offset += NETBSD::NT_PROCINFO_CPI_NAME_SIZE;
+ cpi_siglwp = data.GetU32(&offset); /* LWP target of killing signal */
+
+ return llvm::Error::success();
}
static void ParseOpenBSDProcInfo(ThreadData &thread_data,
@@ -541,37 +562,159 @@ llvm::Error ProcessElfCore::parseFreeBSDNotes(llvm::ArrayRef<CoreNote> notes) {
return llvm::Error::success();
}
+/// NetBSD specific Thread context from PT_NOTE segment
+///
+/// NetBSD ELF core files use notes to provide information about
+/// the process's state. The note name is "NetBSD-CORE" for
+/// information that is global to the process, and "NetBSD-CORE@nn",
+/// where "nn" is the lwpid of the LWP that the information belongs
+/// to (such as register state).
+///
+/// NetBSD uses the following note identifiers:
+///
+/// ELF_NOTE_NETBSD_CORE_PROCINFO (value 1)
+/// Note is a "netbsd_elfcore_procinfo" structure.
+/// ELF_NOTE_NETBSD_CORE_AUXV (value 2; since NetBSD 8.0)
+/// Note is an array of AuxInfo structures.
+///
+/// NetBSD also uses ptrace(2) request numbers (the ones that exist in
+/// machine-dependent space) to identify register info notes. The
+/// info in such notes is in the same format that ptrace(2) would
+/// export that information.
+///
+/// For more information see /usr/include/sys/exec_elf.h
+///
llvm::Error ProcessElfCore::parseNetBSDNotes(llvm::ArrayRef<CoreNote> notes) {
ThreadData thread_data;
- for (const auto &note : notes) {
- // NetBSD per-thread information is stored in notes named "NetBSD-CORE@nnn"
- // so match on the initial part of the string.
- if (!llvm::StringRef(note.info.n_name).startswith("NetBSD-CORE"))
- continue;
+ bool had_nt_regs = false;
- switch (note.info.n_type) {
- case NETBSD::NT_PROCINFO:
- ParseNetBSDProcInfo(thread_data, note.data);
- break;
- case NETBSD::NT_AUXV:
- m_auxv = note.data;
- break;
+ // To be extracted from struct netbsd_elfcore_procinfo
+ // Used to sanity check of the LWPs of the process
+ uint32_t nlwps = 0;
+ uint32_t signo; // killing signal
+ uint32_t siglwp; // LWP target of killing signal
+ uint32_t pr_pid;
- case NETBSD::NT_AMD64_REGS:
- if (GetArchitecture().GetMachine() == llvm::Triple::x86_64)
- thread_data.gpregset = note.data;
- break;
- default:
- thread_data.notes.push_back(note);
- break;
+ for (const auto &note : notes) {
+ llvm::StringRef name = note.info.n_name;
+
+ if (name == "NetBSD-CORE") {
+ if (note.info.n_type == NETBSD::NT_PROCINFO) {
+ llvm::Error error = ParseNetBSDProcInfo(note.data, nlwps, signo,
+ siglwp, pr_pid);
+ if (error)
+ return error;
+ SetID(pr_pid);
+ } else if (note.info.n_type == NETBSD::NT_AUXV) {
+ m_auxv = note.data;
+ }
+ } else if (name.consume_front("NetBSD-CORE@")) {
+ lldb::tid_t tid;
+ if (name.getAsInteger(10, tid))
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Cannot convert LWP ID "
+ "to integer",
+ llvm::inconvertibleErrorCode());
+
+ switch (GetArchitecture().GetMachine()) {
+ case llvm::Triple::aarch64: {
+ // Assume order PT_GETREGS, PT_GETFPREGS
+ if (note.info.n_type == NETBSD::AARCH64::NT_REGS) {
+ // If this is the next thread, push the previous one first.
+ if (had_nt_regs) {
+ m_thread_data.push_back(thread_data);
+ thread_data = ThreadData();
+ had_nt_regs = false;
+ }
+
+ thread_data.gpregset = note.data;
+ thread_data.tid = tid;
+ if (thread_data.gpregset.GetByteSize() == 0)
+ return llvm::make_error<llvm::StringError>(
+ "Could not find general purpose registers note in core file.",
+ llvm::inconvertibleErrorCode());
+ had_nt_regs = true;
+ } else if (note.info.n_type == NETBSD::AARCH64::NT_FPREGS) {
+ if (!had_nt_regs || tid != thread_data.tid)
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Unexpected order "
+ "of NOTEs PT_GETFPREG before PT_GETREG",
+ llvm::inconvertibleErrorCode());
+ thread_data.notes.push_back(note);
+ }
+ } break;
+ case llvm::Triple::x86_64: {
+ // Assume order PT_GETREGS, PT_GETFPREGS
+ if (note.info.n_type == NETBSD::AMD64::NT_REGS) {
+ // If this is the next thread, push the previous one first.
+ if (had_nt_regs) {
+ m_thread_data.push_back(thread_data);
+ thread_data = ThreadData();
+ had_nt_regs = false;
+ }
+
+ thread_data.gpregset = note.data;
+ thread_data.tid = tid;
+ if (thread_data.gpregset.GetByteSize() == 0)
+ return llvm::make_error<llvm::StringError>(
+ "Could not find general purpose registers note in core file.",
+ llvm::inconvertibleErrorCode());
+ had_nt_regs = true;
+ } else if (note.info.n_type == NETBSD::AMD64::NT_FPREGS) {
+ if (!had_nt_regs || tid != thread_data.tid)
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Unexpected order "
+ "of NOTEs PT_GETFPREG before PT_GETREG",
+ llvm::inconvertibleErrorCode());
+ thread_data.notes.push_back(note);
+ }
+ } break;
+ default:
+ break;
+ }
}
}
- if (thread_data.gpregset.GetByteSize() == 0) {
+
+ // Push the last thread.
+ if (had_nt_regs)
+ m_thread_data.push_back(thread_data);
+
+ if (m_thread_data.empty())
return llvm::make_error<llvm::StringError>(
- "Could not find general purpose registers note in core file.",
+ "Error parsing NetBSD core(5) notes: No threads information "
+ "specified in notes",
+ llvm::inconvertibleErrorCode());
+
+ if (m_thread_data.size() != nlwps)
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Mismatch between the number "
+ "of LWPs in netbsd_elfcore_procinfo and the number of LWPs specified "
+ "by MD notes",
llvm::inconvertibleErrorCode());
+
+ // Signal targeted at the whole process.
+ if (siglwp == 0) {
+ for (auto &data : m_thread_data)
+ data.signo = signo;
}
- m_thread_data.push_back(thread_data);
+ // Signal destined for a particular LWP.
+ else {
+ bool passed = false;
+
+ for (auto &data : m_thread_data) {
+ if (data.tid == siglwp) {
+ data.signo = signo;
+ passed = true;
+ break;
+ }
+ }
+
+ if (!passed)
+ return llvm::make_error<llvm::StringError>(
+ "Error parsing NetBSD core(5) notes: Signal passed to unknown LWP",
+ llvm::inconvertibleErrorCode());
+ }
+
return llvm::Error::success();
}
@@ -751,11 +894,11 @@ ArchSpec ProcessElfCore::GetArchitecture() {
return arch;
}
-const lldb::DataBufferSP ProcessElfCore::GetAuxvData() {
+DataExtractor ProcessElfCore::GetAuxvData() {
const uint8_t *start = m_auxv.GetDataStart();
size_t len = m_auxv.GetByteSize();
lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(start, len));
- return buffer;
+ return DataExtractor(buffer, GetByteOrder(), GetAddressByteSize());
}
bool ProcessElfCore::GetProcessInfo(ProcessInstanceInfo &info) {
diff --git a/source/Plugins/Process/elf-core/ProcessElfCore.h b/source/Plugins/Process/elf-core/ProcessElfCore.h
index 2c7268662fefa..829fe9ac71991 100644
--- a/source/Plugins/Process/elf-core/ProcessElfCore.h
+++ b/source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -1,9 +1,8 @@
//===-- ProcessElfCore.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Notes about Linux Process core dumps:
// 1) Linux core dump is stored as ELF file.
@@ -31,9 +30,7 @@ struct ThreadData;
class ProcessElfCore : public lldb_private::Process {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
static lldb::ProcessSP
CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
const lldb_private::FileSpec *crash_file_path);
@@ -46,37 +43,27 @@ public:
static const char *GetPluginDescriptionStatic();
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
ProcessElfCore(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
const lldb_private::FileSpec &core_file);
~ProcessElfCore() override;
- //------------------------------------------------------------------
// Check if a given Process
- //------------------------------------------------------------------
bool CanDebug(lldb::TargetSP target_sp,
bool plugin_specified_by_name) override;
- //------------------------------------------------------------------
// Creating a new process, or attaching to an existing one
- //------------------------------------------------------------------
lldb_private::Status DoLoadCore() override;
lldb_private::DynamicLoader *GetDynamicLoader() override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
// Process Control
- //------------------------------------------------------------------
lldb_private::Status DoDestroy() override;
void RefreshStateAfterStop() override;
@@ -89,16 +76,12 @@ public:
return error;
}
- //------------------------------------------------------------------
// Process Queries
- //------------------------------------------------------------------
bool IsAlive() override;
bool WarnBeforeDetach() const override { return false; }
- //------------------------------------------------------------------
// Process Memory
- //------------------------------------------------------------------
size_t ReadMemory(lldb::addr_t addr, void *buf, size_t size,
lldb_private::Status &error) override;
@@ -114,7 +97,7 @@ public:
lldb_private::ArchSpec GetArchitecture();
// Returns AUXV structure found in the core file
- const lldb::DataBufferSP GetAuxvData() override;
+ lldb_private::DataExtractor GetAuxvData() override;
bool GetProcessInfo(lldb_private::ProcessInstanceInfo &info) override;
@@ -132,9 +115,7 @@ private:
lldb_private::ConstString path;
};
- //------------------------------------------------------------------
// For ProcessElfCore only
- //------------------------------------------------------------------
typedef lldb_private::Range<lldb::addr_t, lldb::addr_t> FileRange;
typedef lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t, FileRange>
VMRangeToFileOffset;
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
index 80c6c0207a1ea..fa05c457fc617 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_arm.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,14 +11,16 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/RegisterValue.h"
+#include <memory>
+
using namespace lldb_private;
RegisterContextCorePOSIX_arm::RegisterContextCorePOSIX_arm(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_arm(thread, 0, register_info) {
- m_gpr_buffer.reset(
- new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
+ gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
index a98d64caee17a..adda43ebccbc9 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_arm.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
index 017646b44b5c2..e477c438ba12d 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
@@ -1,25 +1,27 @@
//===-- RegisterContextPOSIXCore_arm64.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "RegisterContextPOSIXCore_arm64.h"
+
#include "Plugins/Process/elf-core/RegisterUtilities.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/RegisterValue.h"
+#include <memory>
+
using namespace lldb_private;
RegisterContextCorePOSIX_arm64::RegisterContextCorePOSIX_arm64(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_arm64(thread, 0, register_info) {
- m_gpr_buffer.reset(
- new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
+ gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
}
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
index c519b15571893..de6d819c29ce2 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_arm64.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
index beeb9b666ccdf..3601f3b3b216a 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_mips64.cpp ---------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,21 +11,23 @@
#include "lldb/Target/Thread.h"
#include "lldb/Utility/RegisterValue.h"
+#include <memory>
+
using namespace lldb_private;
RegisterContextCorePOSIX_mips64::RegisterContextCorePOSIX_mips64(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_mips64(thread, 0, register_info) {
- m_gpr_buffer.reset(
- new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
+ gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
DataExtractor fpregset = getRegset(
notes, register_info->GetTargetArchitecture().GetTriple(), FPR_Desc);
- m_fpr_buffer.reset(
- new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr_buffer = std::make_shared<DataBufferHeap>(fpregset.GetDataStart(),
+ fpregset.GetByteSize());
m_fpr.SetData(m_fpr_buffer);
m_fpr.SetByteOrder(fpregset.GetByteOrder());
}
@@ -51,7 +52,7 @@ bool RegisterContextCorePOSIX_mips64::ReadRegister(const RegisterInfo *reg_info,
RegisterValue &value) {
lldb::offset_t offset = reg_info->byte_offset;
- lldb_private::ArchSpec arch = m_register_info_ap->GetTargetArchitecture();
+ lldb_private::ArchSpec arch = m_register_info_up->GetTargetArchitecture();
uint64_t v;
if (IsGPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
if (reg_info->byte_size == 4 && !(arch.GetMachine() == llvm::Triple::mips64el))
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
index cf1d8a5bc2d11..999c9451573bd 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_mips64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_mips64.h -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
index d4f86b3547842..6984bf4ee9b8f 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_powerpc.cpp --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,27 +12,29 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/RegisterValue.h"
+#include <memory>
+
using namespace lldb_private;
RegisterContextCorePOSIX_powerpc::RegisterContextCorePOSIX_powerpc(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_powerpc(thread, 0, register_info) {
- m_gpr_buffer.reset(
- new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
+ gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
ArchSpec arch = register_info->GetTargetArchitecture();
DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
- m_fpr_buffer.reset(
- new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr_buffer = std::make_shared<DataBufferHeap>(fpregset.GetDataStart(),
+ fpregset.GetByteSize());
m_fpr.SetData(m_fpr_buffer);
m_fpr.SetByteOrder(fpregset.GetByteOrder());
DataExtractor vregset = getRegset(notes, arch.GetTriple(), PPC_VMX_Desc);
- m_vec_buffer.reset(
- new DataBufferHeap(vregset.GetDataStart(), vregset.GetByteSize()));
+ m_vec_buffer = std::make_shared<DataBufferHeap>(vregset.GetDataStart(),
+ vregset.GetByteSize());
m_vec.SetData(m_vec_buffer);
m_vec.SetByteOrder(vregset.GetByteOrder());
}
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
index c352ab5912ff0..7684c0b31837f 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_powerpc.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_powerpc.h ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
index 8116a1c7ea57b..0eebf474f60ec 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_ppc64le.cpp --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,33 +15,35 @@
#include "Plugins/Process/Utility/lldb-ppc64le-register-enums.h"
#include "Plugins/Process/elf-core/RegisterUtilities.h"
+#include <memory>
+
using namespace lldb_private;
RegisterContextCorePOSIX_ppc64le::RegisterContextCorePOSIX_ppc64le(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_ppc64le(thread, 0, register_info) {
- m_gpr_buffer.reset(
- new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
+ gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
ArchSpec arch = register_info->GetTargetArchitecture();
DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
- m_fpr_buffer.reset(
- new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr_buffer = std::make_shared<DataBufferHeap>(fpregset.GetDataStart(),
+ fpregset.GetByteSize());
m_fpr.SetData(m_fpr_buffer);
m_fpr.SetByteOrder(fpregset.GetByteOrder());
DataExtractor vmxregset = getRegset(notes, arch.GetTriple(), PPC_VMX_Desc);
- m_vmx_buffer.reset(
- new DataBufferHeap(vmxregset.GetDataStart(), vmxregset.GetByteSize()));
+ m_vmx_buffer = std::make_shared<DataBufferHeap>(vmxregset.GetDataStart(),
+ vmxregset.GetByteSize());
m_vmx.SetData(m_vmx_buffer);
m_vmx.SetByteOrder(vmxregset.GetByteOrder());
DataExtractor vsxregset = getRegset(notes, arch.GetTriple(), PPC_VSX_Desc);
- m_vsx_buffer.reset(
- new DataBufferHeap(vsxregset.GetDataStart(), vsxregset.GetByteSize()));
+ m_vsx_buffer = std::make_shared<DataBufferHeap>(vsxregset.GetDataStart(),
+ vsxregset.GetByteSize());
m_vsx.SetData(m_vsx_buffer);
m_vsx.SetByteOrder(vsxregset.GetByteOrder());
}
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h
index c860781d60be9..6e01d23dd656d 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_ppc64le.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_ppc64le.h ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
index 875bb1647281c..d84fc3e743958 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_s390x.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,21 +12,23 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/RegisterValue.h"
+#include <memory>
+
using namespace lldb_private;
RegisterContextCorePOSIX_s390x::RegisterContextCorePOSIX_s390x(
Thread &thread, RegisterInfoInterface *register_info,
const DataExtractor &gpregset, llvm::ArrayRef<CoreNote> notes)
: RegisterContextPOSIX_s390x(thread, 0, register_info) {
- m_gpr_buffer.reset(
- new DataBufferHeap(gpregset.GetDataStart(), gpregset.GetByteSize()));
+ m_gpr_buffer = std::make_shared<DataBufferHeap>(gpregset.GetDataStart(),
+ gpregset.GetByteSize());
m_gpr.SetData(m_gpr_buffer);
m_gpr.SetByteOrder(gpregset.GetByteOrder());
DataExtractor fpregset = getRegset(
notes, register_info->GetTargetArchitecture().GetTriple(), FPR_Desc);
- m_fpr_buffer.reset(
- new DataBufferHeap(fpregset.GetDataStart(), fpregset.GetByteSize()));
+ m_fpr_buffer = std::make_shared<DataBufferHeap>(fpregset.GetDataStart(),
+ fpregset.GetByteSize());
m_fpr.SetData(m_fpr_buffer);
m_fpr.SetByteOrder(fpregset.GetByteOrder());
}
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
index 0df136372bdda..729617649c4fa 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_s390x.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_s390x.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
index 27295492f43df..4454857e17991 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_x86_64.cpp ---------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
index 509624174a89e..f41991c240d2a 100644
--- a/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
+++ b/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextPOSIXCore_x86_64.h -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterUtilities.cpp b/source/Plugins/Process/elf-core/RegisterUtilities.cpp
index 3837abadd0f6c..c8829d612b316 100644
--- a/source/Plugins/Process/elf-core/RegisterUtilities.cpp
+++ b/source/Plugins/Process/elf-core/RegisterUtilities.cpp
@@ -1,9 +1,8 @@
//===-- RegisterUtilities.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/elf-core/RegisterUtilities.h b/source/Plugins/Process/elf-core/RegisterUtilities.h
index 9170d94c04b6d..d3b3373150f8f 100644
--- a/source/Plugins/Process/elf-core/RegisterUtilities.h
+++ b/source/Plugins/Process/elf-core/RegisterUtilities.h
@@ -1,9 +1,8 @@
//===-- RegisterUtilities.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,9 +27,46 @@ enum {
}
namespace NETBSD {
-enum { NT_PROCINFO = 1, NT_AUXV, NT_AMD64_REGS = 33, NT_AMD64_FPREGS = 35 };
+enum { NT_PROCINFO = 1, NT_AUXV = 2 };
+
+/* Size in bytes */
+enum { NT_PROCINFO_SIZE = 160 };
+
+/* Size in bytes */
+enum {
+ NT_PROCINFO_CPI_VERSION_SIZE = 4,
+ NT_PROCINFO_CPI_CPISIZE_SIZE = 4,
+ NT_PROCINFO_CPI_SIGNO_SIZE = 4,
+ NT_PROCINFO_CPI_SIGCODE_SIZE = 4,
+ NT_PROCINFO_CPI_SIGPEND_SIZE = 16,
+ NT_PROCINFO_CPI_SIGMASK_SIZE = 16,
+ NT_PROCINFO_CPI_SIGIGNORE_SIZE = 16,
+ NT_PROCINFO_CPI_SIGCATCH_SIZE = 16,
+ NT_PROCINFO_CPI_PID_SIZE = 4,
+ NT_PROCINFO_CPI_PPID_SIZE = 4,
+ NT_PROCINFO_CPI_PGRP_SIZE = 4,
+ NT_PROCINFO_CPI_SID_SIZE = 4,
+ NT_PROCINFO_CPI_RUID_SIZE = 4,
+ NT_PROCINFO_CPI_EUID_SIZE = 4,
+ NT_PROCINFO_CPI_SVUID_SIZE = 4,
+ NT_PROCINFO_CPI_RGID_SIZE = 4,
+ NT_PROCINFO_CPI_EGID_SIZE = 4,
+ NT_PROCINFO_CPI_SVGID_SIZE = 4,
+ NT_PROCINFO_CPI_NLWPS_SIZE = 4,
+ NT_PROCINFO_CPI_NAME_SIZE = 32,
+ NT_PROCINFO_CPI_SIGLWP_SIZE = 4,
+};
+
+namespace AARCH64 {
+enum { NT_REGS = 32, NT_FPREGS = 34 };
+}
+
+namespace AMD64 {
+enum { NT_REGS = 33, NT_FPREGS = 35 };
}
+} // namespace NETBSD
+
namespace OPENBSD {
enum {
NT_PROCINFO = 10,
@@ -92,7 +128,8 @@ constexpr RegsetDesc FPR_Desc[] = {
// The result from FXSAVE is in NT_PRXFPREG for i386 core files
{llvm::Triple::Linux, llvm::Triple::x86, LINUX::NT_PRXFPREG},
{llvm::Triple::Linux, llvm::Triple::UnknownArch, LINUX::NT_FPREGSET},
- {llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::NT_AMD64_FPREGS},
+ {llvm::Triple::NetBSD, llvm::Triple::aarch64, NETBSD::AARCH64::NT_FPREGS},
+ {llvm::Triple::NetBSD, llvm::Triple::x86_64, NETBSD::AMD64::NT_FPREGS},
{llvm::Triple::OpenBSD, llvm::Triple::UnknownArch, OPENBSD::NT_FPREGS},
};
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.cpp b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index d9b90c8e902e7..a5d1fc4a7bfff 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -1,9 +1,8 @@
//===-- ThreadElfCore.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -39,12 +38,12 @@
#include "RegisterContextPOSIXCore_x86_64.h"
#include "ThreadElfCore.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Construct a Thread object with given data
-//----------------------------------------------------------------------
ThreadElfCore::ThreadElfCore(Process &process, const ThreadData &td)
: Thread(process, td.tid), m_thread_name(td.name), m_thread_reg_ctx_sp(),
m_signo(td.signo), m_gpregset_data(td.gpregset), m_notes(td.notes) {}
@@ -111,6 +110,9 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
case llvm::Triple::NetBSD: {
switch (arch.GetMachine()) {
+ case llvm::Triple::aarch64:
+ reg_interface = new RegisterInfoPOSIX_arm64(arch);
+ break;
case llvm::Triple::x86_64:
reg_interface = new RegisterContextNetBSD_x86_64(arch);
break;
@@ -187,40 +189,40 @@ ThreadElfCore::CreateRegisterContextForFrame(StackFrame *frame) {
switch (arch.GetMachine()) {
case llvm::Triple::aarch64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm64(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_arm64>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::arm:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_arm(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_arm>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::mipsel:
case llvm::Triple::mips:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_mips64>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_mips64(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_mips64>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::ppc:
case llvm::Triple::ppc64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_powerpc(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_powerpc>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::ppc64le:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_ppc64le(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_ppc64le>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::systemz:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_s390x(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_s390x>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_x86_64(
- *this, reg_interface, m_gpregset_data, m_notes));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_x86_64>(
+ *this, reg_interface, m_gpregset_data, m_notes);
break;
default:
break;
@@ -244,9 +246,7 @@ bool ThreadElfCore::CalculateStopInfo() {
return false;
}
-//----------------------------------------------------------------
// Parse PRSTATUS from NOTE entry
-//----------------------------------------------------------------
ELFLinuxPrStatus::ELFLinuxPrStatus() {
memset(this, 0, sizeof(ELFLinuxPrStatus));
}
@@ -254,6 +254,7 @@ ELFLinuxPrStatus::ELFLinuxPrStatus() {
size_t ELFLinuxPrStatus::GetSize(const lldb_private::ArchSpec &arch) {
constexpr size_t mips_linux_pr_status_size_o32 = 96;
constexpr size_t mips_linux_pr_status_size_n32 = 72;
+ constexpr size_t num_ptr_size_members = 10;
if (arch.IsMIPS()) {
std::string abi = arch.GetTargetABI();
assert(!abi.empty() && "ABI is not set");
@@ -265,15 +266,14 @@ size_t ELFLinuxPrStatus::GetSize(const lldb_private::ArchSpec &arch) {
return mips_linux_pr_status_size_n32;
}
switch (arch.GetCore()) {
- case lldb_private::ArchSpec::eCore_s390x_generic:
- case lldb_private::ArchSpec::eCore_x86_64_x86_64:
- case lldb_private::ArchSpec::eCore_ppc64le_generic:
- return sizeof(ELFLinuxPrStatus);
case lldb_private::ArchSpec::eCore_x86_32_i386:
case lldb_private::ArchSpec::eCore_x86_32_i486:
return 72;
default:
- return 0;
+ if (arch.GetAddressByteSize() == 8)
+ return sizeof(ELFLinuxPrStatus);
+ else
+ return sizeof(ELFLinuxPrStatus) - num_ptr_size_members * 4;
}
}
@@ -320,9 +320,7 @@ Status ELFLinuxPrStatus::Parse(const DataExtractor &data,
return error;
}
-//----------------------------------------------------------------
// Parse PRPSINFO from NOTE entry
-//----------------------------------------------------------------
ELFLinuxPrPsInfo::ELFLinuxPrPsInfo() {
memset(this, 0, sizeof(ELFLinuxPrPsInfo));
}
@@ -398,9 +396,7 @@ Status ELFLinuxPrPsInfo::Parse(const DataExtractor &data,
return error;
}
-//----------------------------------------------------------------
// Parse SIGINFO from NOTE entry
-//----------------------------------------------------------------
ELFLinuxSigInfo::ELFLinuxSigInfo() { memset(this, 0, sizeof(ELFLinuxSigInfo)); }
size_t ELFLinuxSigInfo::GetSize(const lldb_private::ArchSpec &arch) {
diff --git a/source/Plugins/Process/elf-core/ThreadElfCore.h b/source/Plugins/Process/elf-core/ThreadElfCore.h
index 167fd6edc4ce3..ddcf35013b345 100644
--- a/source/Plugins/Process/elf-core/ThreadElfCore.h
+++ b/source/Plugins/Process/elf-core/ThreadElfCore.h
@@ -1,9 +1,8 @@
//===-- ThreadElfCore.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -150,7 +149,7 @@ public:
const char *GetName() override {
if (m_thread_name.empty())
- return NULL;
+ return nullptr;
return m_thread_name.c_str();
}
@@ -162,9 +161,7 @@ public:
}
protected:
- //------------------------------------------------------------------
// Member variables.
- //------------------------------------------------------------------
std::string m_thread_name;
lldb::RegisterContextSP m_thread_reg_ctx_sp;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
index a3a4aa053261b..fe7ef6b3aceab 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteClientBase.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "llvm/ADT/StringExtras.h"
-#include "lldb/Target/Process.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/LLDBAssert.h"
@@ -287,7 +285,7 @@ bool GDBRemoteClientBase::ShouldStop(const UnixSignals &signals,
void GDBRemoteClientBase::OnRunPacketSent(bool first) {
if (first)
- BroadcastEvent(eBroadcastBitRunPacketSent, NULL);
+ BroadcastEvent(eBroadcastBitRunPacketSent, nullptr);
}
///////////////////////////////////////
@@ -367,7 +365,7 @@ void GDBRemoteClientBase::Lock::SyncWithContinueThread(bool interrupt) {
// packet. Let's interrupt it.
const char ctrl_c = '\x03';
ConnectionStatus status = eConnectionStatusSuccess;
- size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, NULL);
+ size_t bytes_written = m_comm.Write(&ctrl_c, 1, status, nullptr);
if (bytes_written == 0) {
--m_comm.m_async_count;
if (log)
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
index 3d84ce0ebe188..54f69e8caac68 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteClientBase.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteClientBase.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,7 +27,7 @@ public:
// =========================================================================
/// Process asynchronously-received structured data.
///
- /// @param[in] data
+ /// \param[in] data
/// The complete data packet, expected to start with JSON-async.
// =========================================================================
virtual void HandleAsyncStructuredDataPacket(llvm::StringRef data) = 0;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index 72c1314a7c943..11052eff948f9 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunication.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,13 +19,14 @@
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/Pipe.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/common/TCPSocket.h"
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
#include "lldb/Target/Platform.h"
-#include "lldb/Target/Process.h"
+#include "lldb/Utility/Event.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
@@ -42,8 +42,7 @@
#define DEBUGSERVER_BASENAME "lldb-server"
#endif
-#if defined(__APPLE__)
-#define HAVE_LIBCOMPRESSION
+#if defined(HAVE_LIBCOMPRESSION)
#include <compression.h>
#endif
@@ -55,9 +54,7 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
-//----------------------------------------------------------------------
// GDBRemoteCommunication constructor
-//----------------------------------------------------------------------
GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
const char *listener_name)
: Communication(comm_name),
@@ -68,22 +65,19 @@ GDBRemoteCommunication::GDBRemoteCommunication(const char *comm_name,
#endif
m_echo_number(0), m_supports_qEcho(eLazyBoolCalculate), m_history(512),
m_send_acks(true), m_compression_type(CompressionType::None),
- m_listen_url(), m_decompression_scratch_type(CompressionType::None),
- m_decompression_scratch(nullptr) {
- // Unused unless HAVE_LIBCOMPRESSION is defined.
- (void)m_decompression_scratch_type;
+ m_listen_url() {
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
GDBRemoteCommunication::~GDBRemoteCommunication() {
if (IsConnected()) {
Disconnect();
}
+#if defined(HAVE_LIBCOMPRESSION)
if (m_decompression_scratch)
free (m_decompression_scratch);
+#endif
// Stop the communications read thread which is used to parse all incoming
// packets. This function will block until the read thread returns.
@@ -104,7 +98,7 @@ size_t GDBRemoteCommunication::SendAck() {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
ConnectionStatus status = eConnectionStatusSuccess;
char ch = '+';
- const size_t bytes_written = Write(&ch, 1, status, NULL);
+ const size_t bytes_written = Write(&ch, 1, status, nullptr);
if (log)
log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
m_history.AddPacket(ch, GDBRemoteCommunicationHistory::ePacketTypeSend,
@@ -116,7 +110,7 @@ size_t GDBRemoteCommunication::SendNack() {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
ConnectionStatus status = eConnectionStatusSuccess;
char ch = '-';
- const size_t bytes_written = Write(&ch, 1, status, NULL);
+ const size_t bytes_written = Write(&ch, 1, status, nullptr);
if (log)
log->Printf("<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
m_history.AddPacket(ch, GDBRemoteCommunicationHistory::ePacketTypeSend,
@@ -126,14 +120,14 @@ size_t GDBRemoteCommunication::SendNack() {
GDBRemoteCommunication::PacketResult
GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) {
- StreamString packet(0, 4, eByteOrderBig);
- packet.PutChar('$');
- packet.Write(payload.data(), payload.size());
- packet.PutChar('#');
- packet.PutHex8(CalculcateChecksum(payload));
- std::string packet_str = packet.GetString();
-
- return SendRawPacketNoLock(packet_str);
+ StreamString packet(0, 4, eByteOrderBig);
+ packet.PutChar('$');
+ packet.Write(payload.data(), payload.size());
+ packet.PutChar('#');
+ packet.PutHex8(CalculcateChecksum(payload));
+ std::string packet_str = packet.GetString();
+
+ return SendRawPacketNoLock(packet_str);
}
GDBRemoteCommunication::PacketResult
@@ -144,7 +138,7 @@ GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef packet,
ConnectionStatus status = eConnectionStatusSuccess;
const char *packet_data = packet.data();
const size_t packet_length = packet.size();
- size_t bytes_written = Write(packet_data, packet_length, status, NULL);
+ size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
if (log) {
size_t binary_start_offset = 0;
if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==
@@ -280,7 +274,7 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet,
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
// Check for a packet from our cache first without trying any reading...
- if (CheckForPacket(NULL, 0, packet) != PacketType::Invalid)
+ if (CheckForPacket(nullptr, 0, packet) != PacketType::Invalid)
return PacketResult::Success;
bool timed_out = false;
@@ -303,7 +297,6 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet,
case eConnectionStatusTimedOut:
case eConnectionStatusInterrupted:
if (sync_on_timeout) {
- //------------------------------------------------------------------
/// Sync the remote GDB server and make sure we get a response that
/// corresponds to what we send.
///
@@ -326,7 +319,6 @@ GDBRemoteCommunication::WaitForPacketNoLock(StringExtractorGDBRemote &packet,
/// packets. So if we timeout, we need to ensure that we can get
/// back on track. If we can't get back on track, we must
/// disconnect.
- //------------------------------------------------------------------
bool sync_success = false;
bool got_actual_response = false;
// We timed out, we need to sync back up with the
@@ -478,7 +470,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
content_length = hash_mark_idx - content_start;
std::string bufsize_str(m_bytes.data() + 2, i - 2 - 1);
errno = 0;
- decompressed_bufsize = ::strtoul(bufsize_str.c_str(), NULL, 10);
+ decompressed_bufsize = ::strtoul(bufsize_str.c_str(), nullptr, 10);
if (errno != 0 || decompressed_bufsize == ULONG_MAX) {
m_bytes.erase(0, size_of_first_packet);
return false;
@@ -491,7 +483,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
packet_checksum_cstr[0] = m_bytes[checksum_idx];
packet_checksum_cstr[1] = m_bytes[checksum_idx + 1];
packet_checksum_cstr[2] = '\0';
- long packet_checksum = strtol(packet_checksum_cstr, NULL, 16);
+ long packet_checksum = strtol(packet_checksum_cstr, nullptr, 16);
long actual_checksum = CalculcateChecksum(
llvm::StringRef(m_bytes).substr(1, hash_mark_idx - 1));
@@ -549,7 +541,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
#if defined(HAVE_LIBCOMPRESSION)
if (m_compression_type == CompressionType::ZlibDeflate ||
m_compression_type == CompressionType::LZFSE ||
- m_compression_type == CompressionType::LZ4 ||
+ m_compression_type == CompressionType::LZ4 ||
m_compression_type == CompressionType::LZMA) {
compression_algorithm compression_type;
if (m_compression_type == CompressionType::LZFSE)
@@ -586,7 +578,7 @@ bool GDBRemoteCommunication::DecompressPacket() {
if (decompressed_bufsize != ULONG_MAX && decompressed_buffer != nullptr) {
decompressed_bytes = compression_decode_buffer(
decompressed_buffer, decompressed_bufsize,
- (uint8_t *)unescaped_content.data(), unescaped_content.size(),
+ (uint8_t *)unescaped_content.data(), unescaped_content.size(),
m_decompression_scratch, compression_type);
}
}
@@ -856,7 +848,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
::isxdigit(m_bytes[checksum_idx + 1])) {
if (GetSendAcks()) {
const char *packet_checksum_cstr = &m_bytes[checksum_idx];
- char packet_checksum = strtol(packet_checksum_cstr, NULL, 16);
+ char packet_checksum = strtol(packet_checksum_cstr, nullptr, 16);
char actual_checksum = CalculcateChecksum(
llvm::StringRef(m_bytes).slice(content_start, content_end));
success = packet_checksum == actual_checksum;
@@ -896,22 +888,23 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len,
Status GDBRemoteCommunication::StartListenThread(const char *hostname,
uint16_t port) {
- Status error;
- if (m_listen_thread.IsJoinable()) {
- error.SetErrorString("listen thread already running");
- } else {
- char listen_url[512];
- if (hostname && hostname[0])
- snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname,
- port);
- else
- snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
- m_listen_url = listen_url;
- SetConnection(new ConnectionFileDescriptor());
- m_listen_thread = ThreadLauncher::LaunchThread(
- listen_url, GDBRemoteCommunication::ListenThread, this, &error);
- }
- return error;
+ if (m_listen_thread.IsJoinable())
+ return Status("listen thread already running");
+
+ char listen_url[512];
+ if (hostname && hostname[0])
+ snprintf(listen_url, sizeof(listen_url), "listen://%s:%i", hostname, port);
+ else
+ snprintf(listen_url, sizeof(listen_url), "listen://%i", port);
+ m_listen_url = listen_url;
+ SetConnection(new ConnectionFileDescriptor());
+ llvm::Expected<HostThread> listen_thread = ThreadLauncher::LaunchThread(
+ listen_url, GDBRemoteCommunication::ListenThread, this);
+ if (!listen_thread)
+ return Status(listen_thread.takeError());
+ m_listen_thread = *listen_thread;
+
+ return Status();
}
bool GDBRemoteCommunication::JoinListenThread() {
@@ -931,9 +924,9 @@ GDBRemoteCommunication::ListenThread(lldb::thread_arg_t arg) {
// Do the listen on another thread so we can continue on...
if (connection->Connect(comm->m_listen_url.c_str(), &error) !=
eConnectionStatusSuccess)
- comm->SetConnection(NULL);
+ comm->SetConnection(nullptr);
}
- return NULL;
+ return {};
}
Status GDBRemoteCommunication::StartDebugserverProcess(
@@ -952,16 +945,18 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
char debugserver_path[PATH_MAX];
FileSpec &debugserver_file_spec = launch_info.GetExecutableFile();
+ Environment host_env = Host::GetEnvironment();
+
// Always check to see if we have an environment override for the path to the
// debugserver to use and use it if we do.
- const char *env_debugserver_path = getenv("LLDB_DEBUGSERVER_PATH");
- if (env_debugserver_path) {
+ std::string env_debugserver_path = host_env.lookup("LLDB_DEBUGSERVER_PATH");
+ if (!env_debugserver_path.empty()) {
debugserver_file_spec.SetFile(env_debugserver_path,
FileSpec::Style::native);
if (log)
log->Printf("GDBRemoteCommunication::%s() gdb-remote stub exe path set "
"from environment variable: %s",
- __FUNCTION__, env_debugserver_path);
+ __FUNCTION__, env_debugserver_path.c_str());
} else
debugserver_file_spec = g_debugserver_file_spec;
bool debugserver_exists =
@@ -980,8 +975,11 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
g_debugserver_file_spec = debugserver_file_spec;
} else {
- debugserver_file_spec =
- platform->LocateExecutable(DEBUGSERVER_BASENAME);
+ if (platform)
+ debugserver_file_spec =
+ platform->LocateExecutable(DEBUGSERVER_BASENAME);
+ else
+ debugserver_file_spec.Clear();
if (debugserver_file_spec) {
// Platform::LocateExecutable() wouldn't return a path if it doesn't
// exist
@@ -1004,7 +1002,6 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
Args &debugserver_args = launch_info.GetArguments();
debugserver_args.Clear();
- char arg_cstr[PATH_MAX];
// Start args with "debugserver /file/path -r --"
debugserver_args.AppendArgument(llvm::StringRef(debugserver_path));
@@ -1114,29 +1111,27 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
}
}
}
-
- const char *env_debugserver_log_file = getenv("LLDB_DEBUGSERVER_LOG_FILE");
- if (env_debugserver_log_file) {
- ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-file=%s",
- env_debugserver_log_file);
- debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
+ std::string env_debugserver_log_file =
+ host_env.lookup("LLDB_DEBUGSERVER_LOG_FILE");
+ if (!env_debugserver_log_file.empty()) {
+ debugserver_args.AppendArgument(
+ llvm::formatv("--log-file={0}", env_debugserver_log_file).str());
}
#if defined(__APPLE__)
const char *env_debugserver_log_flags =
getenv("LLDB_DEBUGSERVER_LOG_FLAGS");
if (env_debugserver_log_flags) {
- ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-flags=%s",
- env_debugserver_log_flags);
- debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
+ debugserver_args.AppendArgument(
+ llvm::formatv("--log-flags={0}", env_debugserver_log_flags).str());
}
#else
- const char *env_debugserver_log_channels =
- getenv("LLDB_SERVER_LOG_CHANNELS");
- if (env_debugserver_log_channels) {
- ::snprintf(arg_cstr, sizeof(arg_cstr), "--log-channels=%s",
- env_debugserver_log_channels);
- debugserver_args.AppendArgument(llvm::StringRef(arg_cstr));
+ std::string env_debugserver_log_channels =
+ host_env.lookup("LLDB_SERVER_LOG_CHANNELS");
+ if (!env_debugserver_log_channels.empty()) {
+ debugserver_args.AppendArgument(
+ llvm::formatv("--log-channels={0}", env_debugserver_log_channels)
+ .str());
}
#endif
@@ -1148,15 +1143,15 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
char env_var_name[64];
snprintf(env_var_name, sizeof(env_var_name),
"LLDB_DEBUGSERVER_EXTRA_ARG_%" PRIu32, env_var_index++);
- const char *extra_arg = getenv(env_var_name);
- has_env_var = extra_arg != nullptr;
+ std::string extra_arg = host_env.lookup(env_var_name);
+ has_env_var = !extra_arg.empty();
if (has_env_var) {
debugserver_args.AppendArgument(llvm::StringRef(extra_arg));
if (log)
log->Printf("GDBRemoteCommunication::%s adding env var %s contents "
"to stub command line (%s)",
- __FUNCTION__, env_var_name, extra_arg);
+ __FUNCTION__, env_var_name, extra_arg.c_str());
}
} while (has_env_var);
@@ -1166,7 +1161,7 @@ Status GDBRemoteCommunication::StartDebugserverProcess(
}
// Copy the current environment to the gdbserver/debugserver instance
- launch_info.GetEnvironment() = Host::GetEnvironment();
+ launch_info.GetEnvironment() = host_env;
// Close STDIN, STDOUT and STDERR.
launch_info.AppendCloseFileAction(STDIN_FILENO);
@@ -1266,7 +1261,7 @@ void GDBRemoteCommunication::DumpHistory(Stream &strm) { m_history.Dump(strm); }
void GDBRemoteCommunication::SetHistoryStream(llvm::raw_ostream *strm) {
m_history.SetStream(strm);
-};
+}
llvm::Error
GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
@@ -1284,13 +1279,14 @@ GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
llvm::SmallString<32> remote_addr;
llvm::raw_svector_ostream(remote_addr)
- << "connect://localhost:" << listen_socket.GetLocalPortNumber();
+ << "connect://127.0.0.1:" << listen_socket.GetLocalPortNumber();
std::unique_ptr<ConnectionFileDescriptor> conn_up(
new ConnectionFileDescriptor());
- if (conn_up->Connect(remote_addr, nullptr) != lldb::eConnectionStatusSuccess)
- return llvm::make_error<llvm::StringError>("Unable to connect",
- llvm::inconvertibleErrorCode());
+ Status status;
+ if (conn_up->Connect(remote_addr, &status) != lldb::eConnectionStatusSuccess)
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Unable to connect: %s", status.AsCString());
client.SetConnection(conn_up.release());
if (llvm::Error error = accept_status.get().ToError())
@@ -1302,14 +1298,14 @@ GDBRemoteCommunication::ConnectLocally(GDBRemoteCommunication &client,
GDBRemoteCommunication::ScopedTimeout::ScopedTimeout(
GDBRemoteCommunication &gdb_comm, std::chrono::seconds timeout)
- : m_gdb_comm(gdb_comm), m_timeout_modified(false) {
- auto curr_timeout = gdb_comm.GetPacketTimeout();
- // Only update the timeout if the timeout is greater than the current
- // timeout. If the current timeout is larger, then just use that.
- if (curr_timeout < timeout) {
- m_timeout_modified = true;
- m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
- }
+ : m_gdb_comm(gdb_comm), m_timeout_modified(false) {
+ auto curr_timeout = gdb_comm.GetPacketTimeout();
+ // Only update the timeout if the timeout is greater than the current
+ // timeout. If the current timeout is larger, then just use that.
+ if (curr_timeout < timeout) {
+ m_timeout_modified = true;
+ m_saved_timeout = m_gdb_comm.SetPacketTimeout(timeout);
+ }
}
GDBRemoteCommunication::ScopedTimeout::~ScopedTimeout() {
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
index 369eb25b1dfac..bb777a5c26a73 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunication.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,6 +18,7 @@
#include <vector>
#include "lldb/Core/Communication.h"
+#include "lldb/Host/Config.h"
#include "lldb/Host/HostThread.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Listener.h"
@@ -29,14 +29,14 @@
namespace lldb_private {
namespace process_gdb_remote {
-typedef enum {
+enum GDBStoppointType {
eStoppointInvalid = -1,
eBreakpointSoftware = 0,
eBreakpointHardware,
eWatchpointWrite,
eWatchpointRead,
eWatchpointReadWrite
-} GDBStoppointType;
+};
enum class CompressionType {
None = 0, // no compression
@@ -109,13 +109,11 @@ public:
bool GetSendAcks() { return m_send_acks; }
- //------------------------------------------------------------------
// Set the global packet timeout.
//
// For clients, this is the timeout that gets used when sending
// packets and waiting for responses. For servers, this is used when waiting
// for ACKs.
- //------------------------------------------------------------------
std::chrono::seconds SetPacketTimeout(std::chrono::seconds packet_timeout) {
const auto old_packet_timeout = m_packet_timeout;
m_packet_timeout = packet_timeout;
@@ -124,10 +122,8 @@ public:
std::chrono::seconds GetPacketTimeout() const { return m_packet_timeout; }
- //------------------------------------------------------------------
// Start a debugserver instance on the current host using the
// supplied connection URL.
- //------------------------------------------------------------------
Status StartDebugserverProcess(
const char *url,
Platform *platform, // If non nullptr, then check with the platform for
@@ -218,8 +214,10 @@ private:
HostThread m_listen_thread;
std::string m_listen_url;
- CompressionType m_decompression_scratch_type;
- void *m_decompression_scratch;
+#if defined(HAVE_LIBCOMPRESSION)
+ CompressionType m_decompression_scratch_type = CompressionType::None;
+ void *m_decompression_scratch = nullptr;
+#endif
DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunication);
};
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 1e12ea6b2d566..9797184026e06 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationClient.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,7 +37,9 @@
#include "llvm/ADT/StringSwitch.h"
#if defined(__APPLE__)
+#ifndef HAVE_LIBCOMPRESSION
#define HAVE_LIBCOMPRESSION
+#endif
#include <compression.h>
#endif
@@ -47,9 +48,7 @@ using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
using namespace std::chrono;
-//----------------------------------------------------------------------
// GDBRemoteCommunicationClient constructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationClient::GDBRemoteCommunicationClient()
: GDBRemoteClientBase("gdb-remote.client", "gdb-remote.client.rx_packet"),
m_supports_not_sending_acks(eLazyBoolCalculate),
@@ -104,9 +103,7 @@ GDBRemoteCommunicationClient::GDBRemoteCommunicationClient()
m_supported_async_json_packets_sp(), m_qXfer_memory_map(),
m_qXfer_memory_map_loaded(false) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationClient::~GDBRemoteCommunicationClient() {
if (IsConnected())
Disconnect();
@@ -389,14 +386,14 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() {
std::vector<std::string> supported_compressions;
compressions += sizeof("SupportedCompressions=") - 1;
const char *end_of_compressions = strchr(compressions, ';');
- if (end_of_compressions == NULL) {
+ if (end_of_compressions == nullptr) {
end_of_compressions = strchr(compressions, '\0');
}
const char *current_compression = compressions;
while (current_compression < end_of_compressions) {
const char *next_compression_name = strchr(current_compression, ',');
const char *end_of_this_word = next_compression_name;
- if (next_compression_name == NULL ||
+ if (next_compression_name == nullptr ||
end_of_compressions < next_compression_name) {
end_of_this_word = end_of_compressions;
}
@@ -778,7 +775,7 @@ int GDBRemoteCommunicationClient::SendArgumentsPacket(
std::vector<const char *> argv;
FileSpec exe_file = launch_info.GetExecutableFile();
std::string exe_path;
- const char *arg = NULL;
+ const char *arg = nullptr;
const Args &launch_args = launch_info.GetArguments();
if (exe_file)
exe_path = exe_file.GetPath(false);
@@ -789,7 +786,7 @@ int GDBRemoteCommunicationClient::SendArgumentsPacket(
}
if (!exe_path.empty()) {
argv.push_back(exe_path.c_str());
- for (uint32_t i = 1; (arg = launch_args.GetArgumentAtIndex(i)) != NULL;
+ for (uint32_t i = 1; (arg = launch_args.GetArgumentAtIndex(i)) != nullptr;
++i) {
if (arg)
argv.push_back(arg);
@@ -1097,7 +1094,7 @@ const char *GDBRemoteCommunicationClient::GetGDBServerProgramName() {
if (!m_gdb_server_name.empty())
return m_gdb_server_name.c_str();
}
- return NULL;
+ return nullptr;
}
uint32_t GDBRemoteCommunicationClient::GetGDBServerProgramVersion() {
@@ -1714,28 +1711,22 @@ lldb_private::Status
GDBRemoteCommunicationClient::GetWatchpointsTriggerAfterInstruction(
bool &after, const ArchSpec &arch) {
Status error;
- llvm::Triple::ArchType atype = arch.GetMachine();
+ llvm::Triple triple = arch.GetTriple();
// we assume watchpoints will happen after running the relevant opcode and we
// only want to override this behavior if we have explicitly received a
// qHostInfo telling us otherwise
if (m_qHostInfo_is_valid != eLazyBoolYes) {
- // On targets like MIPS and ppc64le, watchpoint exceptions are always
+ // On targets like MIPS and ppc64, watchpoint exceptions are always
// generated before the instruction is executed. The connected target may
// not support qHostInfo or qWatchpointSupportInfo packets.
- after =
- !(atype == llvm::Triple::mips || atype == llvm::Triple::mipsel ||
- atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el ||
- atype == llvm::Triple::ppc64le);
+ after = !(triple.isMIPS() || triple.isPPC64());
} else {
- // For MIPS and ppc64le, set m_watchpoints_trigger_after_instruction to
+ // For MIPS and ppc64, set m_watchpoints_trigger_after_instruction to
// eLazyBoolNo if it is not calculated before.
- if ((m_watchpoints_trigger_after_instruction == eLazyBoolCalculate &&
- (atype == llvm::Triple::mips || atype == llvm::Triple::mipsel ||
- atype == llvm::Triple::mips64 || atype == llvm::Triple::mips64el)) ||
- atype == llvm::Triple::ppc64le) {
+ if (m_watchpoints_trigger_after_instruction == eLazyBoolCalculate &&
+ (triple.isMIPS() || triple.isPPC64()))
m_watchpoints_trigger_after_instruction = eLazyBoolNo;
- }
after = (m_watchpoints_trigger_after_instruction != eLazyBoolNo);
}
@@ -1747,7 +1738,7 @@ int GDBRemoteCommunicationClient::SetSTDIN(const FileSpec &file_spec) {
std::string path{file_spec.GetPath(false)};
StreamString packet;
packet.PutCString("QSetSTDIN:");
- packet.PutCStringAsRawHex8(path.c_str());
+ packet.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response, false) ==
@@ -1767,7 +1758,7 @@ int GDBRemoteCommunicationClient::SetSTDOUT(const FileSpec &file_spec) {
std::string path{file_spec.GetPath(false)};
StreamString packet;
packet.PutCString("QSetSTDOUT:");
- packet.PutCStringAsRawHex8(path.c_str());
+ packet.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response, false) ==
@@ -1787,7 +1778,7 @@ int GDBRemoteCommunicationClient::SetSTDERR(const FileSpec &file_spec) {
std::string path{file_spec.GetPath(false)};
StreamString packet;
packet.PutCString("QSetSTDERR:");
- packet.PutCStringAsRawHex8(path.c_str());
+ packet.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response, false) ==
@@ -1823,7 +1814,7 @@ int GDBRemoteCommunicationClient::SetWorkingDir(const FileSpec &working_dir) {
std::string path{working_dir.GetPath(false)};
StreamString packet;
packet.PutCString("QSetWorkingDir:");
- packet.PutCStringAsRawHex8(path.c_str());
+ packet.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response, false) ==
@@ -2060,6 +2051,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat);
assert(triple.getObjectFormat() != llvm::Triple::Wasm);
+ assert(triple.getObjectFormat() != llvm::Triple::XCOFF);
switch (triple.getObjectFormat()) {
case llvm::Triple::MachO:
m_process_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
@@ -2071,6 +2063,7 @@ bool GDBRemoteCommunicationClient::GetCurrentProcessInfo(bool allow_lazy) {
m_process_arch.SetArchitecture(eArchTypeCOFF, cpu, sub);
break;
case llvm::Triple::Wasm:
+ case llvm::Triple::XCOFF:
if (log)
log->Printf("error: not supported target architecture");
return false;
@@ -2793,7 +2786,7 @@ lldb_private::Status GDBRemoteCommunicationClient::RunShellCommand(
if (working_dir) {
std::string path{working_dir.GetPath(false)};
stream.PutChar(',');
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
}
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
@@ -2830,7 +2823,7 @@ Status GDBRemoteCommunicationClient::MakeDirectory(const FileSpec &file_spec,
stream.PutCString("qPlatform_mkdir:");
stream.PutHex32(file_permissions);
stream.PutChar(',');
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
llvm::StringRef packet = stream.GetString();
StringExtractorGDBRemote response;
@@ -2852,7 +2845,7 @@ GDBRemoteCommunicationClient::SetFilePermissions(const FileSpec &file_spec,
stream.PutCString("qPlatform_chmod:");
stream.PutHex32(file_permissions);
stream.PutChar(',');
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
llvm::StringRef packet = stream.GetString();
StringExtractorGDBRemote response;
@@ -2893,7 +2886,7 @@ GDBRemoteCommunicationClient::OpenFile(const lldb_private::FileSpec &file_spec,
stream.PutCString("vFile:open:");
if (path.empty())
return UINT64_MAX;
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
stream.PutChar(',');
stream.PutHex32(flags);
stream.PutChar(',');
@@ -2924,7 +2917,7 @@ lldb::user_id_t GDBRemoteCommunicationClient::GetFileSize(
std::string path(file_spec.GetPath(false));
lldb_private::StreamString stream;
stream.PutCString("vFile:size:");
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
PacketResult::Success) {
@@ -2943,7 +2936,7 @@ GDBRemoteCommunicationClient::GetFilePermissions(const FileSpec &file_spec,
Status error;
lldb_private::StreamString stream;
stream.PutCString("vFile:mode:");
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
PacketResult::Success) {
@@ -3045,9 +3038,9 @@ Status GDBRemoteCommunicationClient::CreateSymlink(const FileSpec &src,
stream.PutCString("vFile:symlink:");
// the unix symlink() command reverses its parameters where the dst if first,
// so we follow suit here
- stream.PutCStringAsRawHex8(dst_path.c_str());
+ stream.PutStringAsRawHex8(dst_path);
stream.PutChar(',');
- stream.PutCStringAsRawHex8(src_path.c_str());
+ stream.PutStringAsRawHex8(src_path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
PacketResult::Success) {
@@ -3078,7 +3071,7 @@ Status GDBRemoteCommunicationClient::Unlink(const FileSpec &file_spec) {
stream.PutCString("vFile:unlink:");
// the unix symlink() command reverses its parameters where the dst if first,
// so we follow suit here
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
PacketResult::Success) {
@@ -3108,7 +3101,7 @@ bool GDBRemoteCommunicationClient::GetFileExists(
std::string path(file_spec.GetPath(false));
lldb_private::StreamString stream;
stream.PutCString("vFile:exists:");
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
PacketResult::Success) {
@@ -3127,7 +3120,7 @@ bool GDBRemoteCommunicationClient::CalculateMD5(
std::string path(file_spec.GetPath(false));
lldb_private::StreamString stream;
stream.PutCString("vFile:MD5:");
- stream.PutCStringAsRawHex8(path.c_str());
+ stream.PutStringAsRawHex8(path);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(stream.GetString(), response, false) ==
PacketResult::Success) {
@@ -3508,10 +3501,10 @@ bool GDBRemoteCommunicationClient::GetModuleInfo(
StreamString packet;
packet.PutCString("qModuleInfo:");
- packet.PutCStringAsRawHex8(module_path.c_str());
+ packet.PutStringAsRawHex8(module_path);
packet.PutCString(";");
const auto &triple = arch_spec.GetTriple().getTriple();
- packet.PutCStringAsRawHex8(triple.c_str());
+ packet.PutStringAsRawHex8(triple);
StringExtractorGDBRemote response;
if (SendPacketAndWaitForResponse(packet.GetString(), response, false) !=
@@ -3955,7 +3948,7 @@ Status GDBRemoteCommunicationClient::SendSignalsToIgnore(
}
Status GDBRemoteCommunicationClient::ConfigureRemoteStructuredData(
- const ConstString &type_name, const StructuredData::ObjectSP &config_sp) {
+ ConstString type_name, const StructuredData::ObjectSP &config_sp) {
Status error;
if (type_name.GetLength() == 0) {
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index 37d53ab425f59..de85c9f8b67b3 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationClient.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,12 +17,15 @@
#include <string>
#include <vector>
-#include "lldb/Target/Process.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/StreamGDBRemote.h"
#include "lldb/Utility/StructuredData.h"
+#if defined(_WIN32)
+#include "lldb/Host/windows/PosixApi.h"
+#endif
#include "llvm/ADT/Optional.h"
+#include "llvm/Support/VersionTuple.h"
namespace lldb_private {
namespace process_gdb_remote {
@@ -34,10 +36,8 @@ public:
~GDBRemoteCommunicationClient() override;
- //------------------------------------------------------------------
// After connecting, send the handshake to the server to make sure
// we are communicating with it.
- //------------------------------------------------------------------
bool HandshakeWithServer(Status *error_ptr);
// For packets which specify a range of output to be returned,
@@ -85,39 +85,35 @@ public:
bool KillSpawnedProcess(lldb::pid_t pid);
- //------------------------------------------------------------------
/// Sends a GDB remote protocol 'A' packet that delivers program
/// arguments to the remote server.
///
- /// @param[in] argv
+ /// \param[in] argv
/// A NULL terminated array of const C strings to use as the
/// arguments.
///
- /// @return
+ /// \return
/// Zero if the response was "OK", a positive value if the
/// the response was "Exx" where xx are two hex digits, or
/// -1 if the call is unsupported or any other unexpected
/// response was received.
- //------------------------------------------------------------------
int SendArgumentsPacket(const ProcessLaunchInfo &launch_info);
- //------------------------------------------------------------------
/// Sends a "QEnvironment:NAME=VALUE" packet that will build up the
/// environment that will get used when launching an application
/// in conjunction with the 'A' packet. This function can be called
/// multiple times in a row in order to pass on the desired
/// environment that the inferior should be launched with.
///
- /// @param[in] name_equal_value
+ /// \param[in] name_equal_value
/// A NULL terminated C string that contains a single environment
/// in the format "NAME=VALUE".
///
- /// @return
+ /// \return
/// Zero if the response was "OK", a positive value if the
/// the response was "Exx" where xx are two hex digits, or
/// -1 if the call is unsupported or any other unexpected
/// response was received.
- //------------------------------------------------------------------
int SendEnvironmentPacket(char const *name_equal_value);
int SendEnvironment(const Environment &env);
@@ -126,102 +122,88 @@ public:
int SendLaunchEventDataPacket(const char *data,
bool *was_supported = nullptr);
- //------------------------------------------------------------------
/// Sends a "vAttach:PID" where PID is in hex.
///
- /// @param[in] pid
+ /// \param[in] pid
/// A process ID for the remote gdb server to attach to.
///
- /// @param[out] response
+ /// \param[out] response
/// The response received from the gdb server. If the return
/// value is zero, \a response will contain a stop reply
/// packet.
///
- /// @return
+ /// \return
/// Zero if the attach was successful, or an error indicating
/// an error code.
- //------------------------------------------------------------------
int SendAttach(lldb::pid_t pid, StringExtractorGDBRemote &response);
- //------------------------------------------------------------------
/// Sends a GDB remote protocol 'I' packet that delivers stdin
/// data to the remote process.
///
- /// @param[in] data
+ /// \param[in] data
/// A pointer to stdin data.
///
- /// @param[in] data_len
+ /// \param[in] data_len
/// The number of bytes available at \a data.
///
- /// @return
+ /// \return
/// Zero if the attach was successful, or an error indicating
/// an error code.
- //------------------------------------------------------------------
int SendStdinNotification(const char *data, size_t data_len);
- //------------------------------------------------------------------
/// Sets the path to use for stdin/out/err for a process
/// that will be launched with the 'A' packet.
///
- /// @param[in] path
+ /// \param[in] path
/// The path to use for stdin/out/err
///
- /// @return
+ /// \return
/// Zero if the for success, or an error code for failure.
- //------------------------------------------------------------------
int SetSTDIN(const FileSpec &file_spec);
int SetSTDOUT(const FileSpec &file_spec);
int SetSTDERR(const FileSpec &file_spec);
- //------------------------------------------------------------------
/// Sets the disable ASLR flag to \a enable for a process that will
/// be launched with the 'A' packet.
///
- /// @param[in] enable
+ /// \param[in] enable
/// A boolean value indicating whether to disable ASLR or not.
///
- /// @return
+ /// \return
/// Zero if the for success, or an error code for failure.
- //------------------------------------------------------------------
int SetDisableASLR(bool enable);
- //------------------------------------------------------------------
/// Sets the DetachOnError flag to \a enable for the process controlled by the
/// stub.
///
- /// @param[in] enable
+ /// \param[in] enable
/// A boolean value indicating whether to detach on error or not.
///
- /// @return
+ /// \return
/// Zero if the for success, or an error code for failure.
- //------------------------------------------------------------------
int SetDetachOnError(bool enable);
- //------------------------------------------------------------------
/// Sets the working directory to \a path for a process that will
/// be launched with the 'A' packet for non platform based
/// connections. If this packet is sent to a GDB server that
/// implements the platform, it will change the current working
/// directory for the platform process.
///
- /// @param[in] working_dir
+ /// \param[in] working_dir
/// The path to a directory to use when launching our process
///
- /// @return
+ /// \return
/// Zero if the for success, or an error code for failure.
- //------------------------------------------------------------------
int SetWorkingDir(const FileSpec &working_dir);
- //------------------------------------------------------------------
/// Gets the current working directory of a remote platform GDB
/// server.
///
- /// @param[out] working_dir
+ /// \param[out] working_dir
/// The current working directory on the remote platform.
///
- /// @return
+ /// \return
/// Boolean for success
- //------------------------------------------------------------------
bool GetWorkingDir(FileSpec &working_dir);
lldb::addr_t AllocateMemory(size_t size, uint32_t permissions);
@@ -456,21 +438,18 @@ public:
// Sends QPassSignals packet to the server with given signals to ignore.
Status SendSignalsToIgnore(llvm::ArrayRef<int32_t> signals);
- //------------------------------------------------------------------
/// Return the feature set supported by the gdb-remote server.
///
/// This method returns the remote side's response to the qSupported
/// packet. The response is the complete string payload returned
/// to the client.
///
- /// @return
+ /// \return
/// The string returned by the server to the qSupported query.
- //------------------------------------------------------------------
const std::string &GetServerSupportedFeatures() const {
return m_qSupported_response;
}
- //------------------------------------------------------------------
/// Return the array of async JSON packet types supported by the remote.
///
/// This method returns the remote side's array of supported JSON
@@ -486,18 +465,15 @@ public:
/// A plugin indicates whether it knows how to handle a type_name.
/// If so, it can be used to process the async JSON packet.
///
- /// @return
+ /// \return
/// The string returned by the server to the qSupported query.
- //------------------------------------------------------------------
lldb_private::StructuredData::Array *GetSupportedStructuredDataPlugins();
- //------------------------------------------------------------------
/// Configure a StructuredData feature on the remote end.
///
- /// @see \b Process::ConfigureStructuredData(...) for details.
- //------------------------------------------------------------------
+ /// \see \b Process::ConfigureStructuredData(...) for details.
Status
- ConfigureRemoteStructuredData(const ConstString &type_name,
+ ConfigureRemoteStructuredData(ConstString type_name,
const StructuredData::ObjectSP &config_sp);
lldb::user_id_t SendStartTracePacket(const TraceOptions &options,
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
index 69b13f2a3acb6..bcddb4faf8634 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationHistory.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -46,7 +45,7 @@ void GDBRemoteCommunicationHistory::AddPacket(char packet_char, PacketType type,
m_packets[idx].bytes_transmitted = bytes_transmitted;
m_packets[idx].packet_idx = m_total_packet_count;
m_packets[idx].tid = llvm::get_threadid();
- if (m_stream && type == ePacketTypeRecv)
+ if (m_stream)
m_packets[idx].Serialize(*m_stream);
}
@@ -63,7 +62,7 @@ void GDBRemoteCommunicationHistory::AddPacket(const std::string &src,
m_packets[idx].bytes_transmitted = bytes_transmitted;
m_packets[idx].packet_idx = m_total_packet_count;
m_packets[idx].tid = llvm::get_threadid();
- if (m_stream && type == ePacketTypeRecv)
+ if (m_stream)
m_packets[idx].Serialize(*m_stream);
}
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
index d0ca6a0235c9b..85f112b506236 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationHistory.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationHistory.h--------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
index 6a78eb20992e0..417f5737a30ff 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationReplayServer.cpp ------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,12 +30,49 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
+/// Check if the given expected packet matches the actual packet.
+static bool unexpected(llvm::StringRef expected, llvm::StringRef actual) {
+ // The 'expected' string contains the raw data, including the leading $ and
+ // trailing checksum. The 'actual' string contains only the packet's content.
+ if (expected.contains(actual))
+ return false;
+ // Contains a PID which might be different.
+ if (expected.contains("vAttach"))
+ return false;
+ // Contains a ascii-hex-path.
+ if (expected.contains("QSetSTD"))
+ return false;
+ // Contains environment values.
+ if (expected.contains("QEnvironment"))
+ return false;
+
+ return true;
+}
+
+/// Check if we should reply to the given packet.
+static bool skip(llvm::StringRef data) {
+ assert(!data.empty() && "Empty packet?");
+
+ // We've already acknowledge the '+' packet so we're done here.
+ if (data == "+")
+ return true;
+
+ /// Don't 't reply to ^C. We need this because of stop reply packets, which
+ /// are only returned when the target halts. Reproducers synchronize these
+ /// 'asynchronous' replies, by recording them as a regular replies to the
+ /// previous packet (e.g. vCont). As a result, we should ignore real
+ /// asynchronous requests.
+ if (data.data()[0] == 0x03)
+ return true;
+
+ return false;
+}
+
GDBRemoteCommunicationReplayServer::GDBRemoteCommunicationReplayServer()
- : GDBRemoteCommunication("gdb-remote.server",
- "gdb-remote.server.rx_packet"),
- m_async_broadcaster(nullptr, "lldb.gdb-remote.server.async-broadcaster"),
+ : GDBRemoteCommunication("gdb-replay", "gdb-replay.rx_packet"),
+ m_async_broadcaster(nullptr, "lldb.gdb-replay.async-broadcaster"),
m_async_listener_sp(
- Listener::MakeListener("lldb.gdb-remote.server.async-listener")),
+ Listener::MakeListener("lldb.gdb-replay.async-listener")),
m_async_thread_state_mutex(), m_skip_acks(false) {
m_async_broadcaster.SetEventName(eBroadcastBitAsyncContinue,
"async thread continue");
@@ -56,6 +92,8 @@ GDBRemoteCommunicationReplayServer::~GDBRemoteCommunicationReplayServer() {
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
Timeout<std::micro> timeout, Status &error, bool &interrupt, bool &quit) {
+ std::lock_guard<std::recursive_mutex> guard(m_async_thread_state_mutex);
+
StringExtractorGDBRemote packet;
PacketResult packet_result = WaitForPacketNoLock(packet, timeout, false);
@@ -71,32 +109,65 @@ GDBRemoteCommunicationReplayServer::GetPacketAndSendResponse(
m_async_broadcaster.BroadcastEvent(eBroadcastBitAsyncContinue);
- if (m_skip_acks) {
- const StringExtractorGDBRemote::ServerPacketType packet_type =
- packet.GetServerPacketType();
- switch (packet_type) {
- case StringExtractorGDBRemote::eServerPacketType_nack:
- case StringExtractorGDBRemote::eServerPacketType_ack:
- return PacketResult::Success;
- default:
- break;
- }
- } else if (packet.GetStringRef() == "QStartNoAckMode") {
- m_skip_acks = true;
+ // Check if we should reply to this packet.
+ if (skip(packet.GetStringRef()))
+ return PacketResult::Success;
+
+ // This completes the handshake. Since m_send_acks was true, we can unset it
+ // already.
+ if (packet.GetStringRef() == "QStartNoAckMode")
m_send_acks = false;
- }
+ // A QEnvironment packet is sent for every environment variable. If the
+ // number of environment variables is different during replay, the replies
+ // become out of sync.
+ if (packet.GetStringRef().find("QEnvironment") == 0)
+ return SendRawPacketNoLock("$OK#9a");
+
+ Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
while (!m_packet_history.empty()) {
// Pop last packet from the history.
GDBRemoteCommunicationHistory::Entry entry = m_packet_history.back();
m_packet_history.pop_back();
- // We only care about what we received from the server. Skip everything
- // the client sent.
- if (entry.type != GDBRemoteCommunicationHistory::ePacketTypeRecv)
+ // We've handled the handshake implicitly before. Skip the packet and move
+ // on.
+ if (entry.packet.data == "+")
+ continue;
+
+ if (entry.type == GDBRemoteCommunicationHistory::ePacketTypeSend) {
+ if (unexpected(entry.packet.data, packet.GetStringRef())) {
+ LLDB_LOG(log,
+ "GDBRemoteCommunicationReplayServer expected packet: '{0}'",
+ entry.packet.data);
+ LLDB_LOG(log, "GDBRemoteCommunicationReplayServer actual packet: '{0}'",
+ packet.GetStringRef());
+ assert(false && "Encountered unexpected packet during replay");
+ return PacketResult::ErrorSendFailed;
+ }
+
+ // Ignore QEnvironment packets as they're handled earlier.
+ if (entry.packet.data.find("QEnvironment") == 1) {
+ assert(m_packet_history.back().type ==
+ GDBRemoteCommunicationHistory::ePacketTypeRecv);
+ m_packet_history.pop_back();
+ }
+
+ continue;
+ }
+
+ if (entry.type == GDBRemoteCommunicationHistory::ePacketTypeInvalid) {
+ LLDB_LOG(
+ log,
+ "GDBRemoteCommunicationReplayServer skipped invalid packet: '{0}'",
+ packet.GetStringRef());
continue;
+ }
- return SendRawPacketNoLock(entry.packet.data, true);
+ LLDB_LOG(log,
+ "GDBRemoteCommunicationReplayServer replied to '{0}' with '{1}'",
+ packet.GetStringRef(), entry.packet.data);
+ return SendRawPacketNoLock(entry.packet.data);
}
quit = true;
@@ -132,9 +203,16 @@ bool GDBRemoteCommunicationReplayServer::StartAsyncThread() {
if (!m_async_thread.IsJoinable()) {
// Create a thread that watches our internal state and controls which
// events make it to clients (into the DCProcess event queue).
- m_async_thread = ThreadLauncher::LaunchThread(
- "<lldb.gdb-remote.server.async>",
- GDBRemoteCommunicationReplayServer::AsyncThread, this, nullptr);
+ llvm::Expected<HostThread> async_thread = ThreadLauncher::LaunchThread(
+ "<lldb.gdb-replay.async>",
+ GDBRemoteCommunicationReplayServer::AsyncThread, this);
+ if (!async_thread) {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(async_thread.takeError()));
+ return false;
+ }
+ m_async_thread = *async_thread;
}
// Wait for handshake.
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
index 5b840c8459b71..26d65e265463b 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationReplayServer.h --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
index 026f78117a0c4..49cbeb023fd55 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServer.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -107,13 +106,29 @@ GDBRemoteCommunicationServer::SendErrorResponse(const Status &error) {
if (m_send_error_strings) {
lldb_private::StreamString packet;
packet.Printf("E%2.2x;", static_cast<uint8_t>(error.GetError()));
- packet.PutCStringAsRawHex8(error.AsCString());
+ packet.PutStringAsRawHex8(error.AsCString());
return SendPacketNoLock(packet.GetString());
} else
return SendErrorResponse(error.GetError());
}
GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServer::SendErrorResponse(llvm::Error error) {
+ std::unique_ptr<llvm::ErrorInfoBase> EIB;
+ std::unique_ptr<PacketUnimplementedError> PUE;
+ llvm::handleAllErrors(
+ std::move(error),
+ [&](std::unique_ptr<PacketUnimplementedError> E) { PUE = std::move(E); },
+ [&](std::unique_ptr<llvm::ErrorInfoBase> E) { EIB = std::move(E); });
+
+ if (EIB)
+ return SendErrorResponse(Status(llvm::Error(std::move(EIB))));
+ if (PUE)
+ return SendUnimplementedResponse(PUE->message().c_str());
+ return SendErrorResponse(Status("Unknown Error"));
+}
+
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServer::Handle_QErrorStringEnable(
StringExtractorGDBRemote &packet) {
m_send_error_strings = true;
@@ -139,3 +154,5 @@ GDBRemoteCommunicationServer::SendOKResponse() {
bool GDBRemoteCommunicationServer::HandshakeWithClient() {
return GetAck() == PacketResult::Success;
}
+
+char PacketUnimplementedError::ID;
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
index 082fb0d854243..86f0abf45e067 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServer.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,6 +15,9 @@
#include "GDBRemoteCommunication.h"
#include "lldb/lldb-private-forward.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+
class StringExtractorGDBRemote;
namespace lldb_private {
@@ -60,6 +62,8 @@ protected:
PacketResult SendErrorResponse(const Status &error);
+ PacketResult SendErrorResponse(llvm::Error error);
+
PacketResult SendUnimplementedResponse(const char *packet);
PacketResult SendErrorResponse(uint8_t error);
@@ -73,6 +77,18 @@ private:
DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServer);
};
+class PacketUnimplementedError
+ : public llvm::ErrorInfo<PacketUnimplementedError, llvm::StringError> {
+public:
+ static char ID;
+ using llvm::ErrorInfo<PacketUnimplementedError,
+ llvm::StringError>::ErrorInfo; // inherit constructors
+ PacketUnimplementedError(const llvm::Twine &S)
+ : ErrorInfo(S, llvm::errc::not_supported) {}
+
+ PacketUnimplementedError() : ErrorInfo(llvm::errc::not_supported) {}
+};
+
} // namespace process_gdb_remote
} // namespace lldb_private
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
index f11ef4f1bbf84..d095c7a057ad4 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServerCommon.cpp ------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include <errno.h>
-
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
@@ -22,20 +20,20 @@
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/File.h"
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Host/SafeMachO.h"
#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Target/FileAction.h"
#include "lldb/Target/Platform.h"
-#include "lldb/Target/Process.h"
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamGDBRemote.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StructuredData.h"
#include "llvm/ADT/Triple.h"
#include "ProcessGDBRemoteLog.h"
@@ -57,9 +55,7 @@ const static uint32_t g_default_packet_timeout_sec = 20; // seconds
const static uint32_t g_default_packet_timeout_sec = 0; // not specified
#endif
-//----------------------------------------------------------------------
// GDBRemoteCommunicationServerCommon constructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon(
const char *comm_name, const char *listener_name)
: GDBRemoteCommunicationServer(comm_name, listener_name),
@@ -178,9 +174,7 @@ GDBRemoteCommunicationServerCommon::GDBRemoteCommunicationServerCommon(
&GDBRemoteCommunicationServerCommon::Handle_vFile_unlink);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationServerCommon::~GDBRemoteCommunicationServerCommon() {}
GDBRemoteCommunication::PacketResult
@@ -193,13 +187,13 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
ArchSpec host_arch(HostInfo::GetArchitecture());
const llvm::Triple &host_triple = host_arch.GetTriple();
response.PutCString("triple:");
- response.PutCStringAsRawHex8(host_triple.getTriple().c_str());
+ response.PutStringAsRawHex8(host_triple.getTriple());
response.Printf(";ptrsize:%u;", host_arch.GetAddressByteSize());
const char *distribution_id = host_arch.GetDistributionId().AsCString();
if (distribution_id) {
response.PutCString("distribution_id:");
- response.PutCStringAsRawHex8(distribution_id);
+ response.PutStringAsRawHex8(distribution_id);
response.PutCString(";");
}
@@ -215,8 +209,7 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
if (sub != LLDB_INVALID_CPUTYPE)
response.Printf("cpusubtype:%u;", sub);
- if (cpu == llvm::MachO::CPU_TYPE_ARM
- || cpu == llvm::MachO::CPU_TYPE_ARM64) {
+ if (cpu == llvm::MachO::CPU_TYPE_ARM || cpu == llvm::MachO::CPU_TYPE_ARM64) {
// Indicate the OS type.
#if defined(TARGET_OS_TV) && TARGET_OS_TV == 1
response.PutCString("ostype:tvos;");
@@ -240,11 +233,7 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
if (host_arch.GetMachine() == llvm::Triple::aarch64 ||
host_arch.GetMachine() == llvm::Triple::aarch64_be ||
host_arch.GetMachine() == llvm::Triple::arm ||
- host_arch.GetMachine() == llvm::Triple::armeb ||
- host_arch.GetMachine() == llvm::Triple::mips64 ||
- host_arch.GetMachine() == llvm::Triple::mips64el ||
- host_arch.GetMachine() == llvm::Triple::mips ||
- host_arch.GetMachine() == llvm::Triple::mipsel)
+ host_arch.GetMachine() == llvm::Triple::armeb || host_arch.IsMIPS())
response.Printf("watchpoint_exceptions_received:before;");
else
response.Printf("watchpoint_exceptions_received:after;");
@@ -274,12 +263,12 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
std::string s;
if (HostInfo::GetOSBuildString(s)) {
response.PutCString("os_build:");
- response.PutCStringAsRawHex8(s.c_str());
+ response.PutStringAsRawHex8(s);
response.PutChar(';');
}
if (HostInfo::GetOSKernelDescription(s)) {
response.PutCString("os_kernel:");
- response.PutCStringAsRawHex8(s.c_str());
+ response.PutStringAsRawHex8(s);
response.PutChar(';');
}
@@ -290,12 +279,12 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
// actually have a hostname as far as the remote lldb that is connecting to
// this lldb-platform is concerned
response.PutCString("hostname:");
- response.PutCStringAsRawHex8("127.0.0.1");
+ response.PutStringAsRawHex8("127.0.0.1");
response.PutChar(';');
#else // #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
if (HostInfo::GetHostname(s)) {
response.PutCString("hostname:");
- response.PutCStringAsRawHex8(s.c_str());
+ response.PutStringAsRawHex8(s);
response.PutChar(';');
}
#endif // #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
@@ -303,7 +292,7 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
#else // #if defined(__APPLE__)
if (HostInfo::GetHostname(s)) {
response.PutCString("hostname:");
- response.PutCStringAsRawHex8(s.c_str());
+ response.PutStringAsRawHex8(s);
response.PutChar(';');
}
#endif // #if defined(__APPLE__)
@@ -439,10 +428,10 @@ GDBRemoteCommunicationServerCommon::Handle_qUserName(
packet.SetFilePos(::strlen("qUserName:"));
uint32_t uid = packet.GetU32(UINT32_MAX);
if (uid != UINT32_MAX) {
- std::string name;
- if (HostInfo::LookupUserName(uid, name)) {
+ if (llvm::Optional<llvm::StringRef> name =
+ HostInfo::GetUserIDResolver().GetUserName(uid)) {
StreamString response;
- response.PutCStringAsRawHex8(name.c_str());
+ response.PutStringAsRawHex8(*name);
return SendPacketNoLock(response.GetString());
}
}
@@ -460,10 +449,10 @@ GDBRemoteCommunicationServerCommon::Handle_qGroupName(
packet.SetFilePos(::strlen("qGroupName:"));
uint32_t gid = packet.GetU32(UINT32_MAX);
if (gid != UINT32_MAX) {
- std::string name;
- if (HostInfo::LookupGroupName(gid, name)) {
+ if (llvm::Optional<llvm::StringRef> name =
+ HostInfo::GetUserIDResolver().GetGroupName(gid)) {
StreamString response;
- response.PutCStringAsRawHex8(name.c_str());
+ response.PutStringAsRawHex8(*name);
return SendPacketNoLock(response.GetString());
}
}
@@ -511,18 +500,19 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Open(
packet.GetHexByteStringTerminatedBy(path, ',');
if (!path.empty()) {
if (packet.GetChar() == ',') {
- uint32_t flags =
- File::ConvertOpenOptionsForPOSIXOpen(packet.GetHexMaxU32(false, 0));
+ uint32_t flags = packet.GetHexMaxU32(false, 0);
if (packet.GetChar() == ',') {
mode_t mode = packet.GetHexMaxU32(false, 0600);
- Status error;
FileSpec path_spec(path);
FileSystem::Instance().Resolve(path_spec);
- int fd = ::open(path_spec.GetCString(), flags, mode);
- const int save_errno = fd == -1 ? errno : 0;
+ File file;
+ // Do not close fd.
+ Status error =
+ FileSystem::Instance().Open(file, path_spec, flags, mode, false);
+ const int save_errno = error.GetError();
StreamString response;
response.PutChar('F');
- response.Printf("%i", fd);
+ response.Printf("%i", file.GetDescriptor());
if (save_errno)
response.Printf(",%i", save_errno);
return SendPacketNoLock(response.GetString());
@@ -537,12 +527,13 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Close(
StringExtractorGDBRemote &packet) {
packet.SetFilePos(::strlen("vFile:close:"));
int fd = packet.GetS32(-1);
- Status error;
int err = -1;
int save_errno = 0;
if (fd >= 0) {
- err = close(fd);
- save_errno = err == -1 ? errno : 0;
+ File file(fd, true);
+ Status error = file.Close();
+ err = 0;
+ save_errno = error.GetError();
} else {
save_errno = EINVAL;
}
@@ -557,26 +548,23 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_Close(
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_pRead(
StringExtractorGDBRemote &packet) {
-#ifdef _WIN32
- // Not implemented on Windows
- return SendUnimplementedResponse(
- "GDBRemoteCommunicationServerCommon::Handle_vFile_pRead() unimplemented");
-#else
StreamGDBRemote response;
packet.SetFilePos(::strlen("vFile:pread:"));
int fd = packet.GetS32(-1);
if (packet.GetChar() == ',') {
- uint64_t count = packet.GetU64(UINT64_MAX);
+ size_t count = packet.GetU64(UINT64_MAX);
if (packet.GetChar() == ',') {
- uint64_t offset = packet.GetU64(UINT32_MAX);
+ off_t offset = packet.GetU64(UINT32_MAX);
if (count == UINT64_MAX) {
response.Printf("F-1:%i", EINVAL);
return SendPacketNoLock(response.GetString());
}
std::string buffer(count, 0);
- const ssize_t bytes_read = ::pread(fd, &buffer[0], buffer.size(), offset);
- const int save_errno = bytes_read == -1 ? errno : 0;
+ File file(fd, false);
+ Status error = file.Read(static_cast<void *>(&buffer[0]), count, offset);
+ const ssize_t bytes_read = error.Success() ? count : -1;
+ const int save_errno = error.GetError();
response.PutChar('F');
response.Printf("%zi", bytes_read);
if (save_errno)
@@ -589,17 +577,11 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_pRead(
}
}
return SendErrorResponse(21);
-
-#endif
}
GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite(
StringExtractorGDBRemote &packet) {
-#ifdef _WIN32
- return SendUnimplementedResponse("GDBRemoteCommunicationServerCommon::Handle_"
- "vFile_pWrite() unimplemented");
-#else
packet.SetFilePos(::strlen("vFile:pwrite:"));
StreamGDBRemote response;
@@ -611,9 +593,12 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite(
if (packet.GetChar() == ',') {
std::string buffer;
if (packet.GetEscapedBinaryData(buffer)) {
- const ssize_t bytes_written =
- ::pwrite(fd, buffer.data(), buffer.size(), offset);
- const int save_errno = bytes_written == -1 ? errno : 0;
+ File file(fd, false);
+ size_t count = buffer.size();
+ Status error =
+ file.Write(static_cast<const void *>(&buffer[0]), count, offset);
+ const ssize_t bytes_written = error.Success() ? count : -1;
+ const int save_errno = error.GetError();
response.Printf("%zi", bytes_written);
if (save_errno)
response.Printf(",%i", save_errno);
@@ -624,7 +609,6 @@ GDBRemoteCommunicationServerCommon::Handle_vFile_pWrite(
}
}
return SendErrorResponse(27);
-#endif
}
GDBRemoteCommunication::PacketResult
@@ -972,7 +956,8 @@ GDBRemoteCommunicationServerCommon::Handle_QLaunchArch(
const uint32_t bytes_left = packet.GetBytesLeft();
if (bytes_left > 0) {
const char *arch_triple = packet.Peek();
- m_process_launch_info.SetArchitecture(HostInfo::GetAugmentedArchSpec(arch_triple));
+ m_process_launch_info.SetArchitecture(
+ HostInfo::GetAugmentedArchSpec(arch_triple));
return SendOKResponse();
}
return SendErrorResponse(13);
@@ -1086,24 +1071,25 @@ GDBRemoteCommunicationServerCommon::Handle_qModuleInfo(
StreamGDBRemote response;
if (uuid_str.empty()) {
- auto Result = llvm::sys::fs::md5_contents(matched_module_spec.GetFileSpec().GetPath());
+ auto Result = llvm::sys::fs::md5_contents(
+ matched_module_spec.GetFileSpec().GetPath());
if (!Result)
return SendErrorResponse(5);
response.PutCString("md5:");
- response.PutCStringAsRawHex8(Result->digest().c_str());
+ response.PutStringAsRawHex8(Result->digest());
} else {
response.PutCString("uuid:");
- response.PutCStringAsRawHex8(uuid_str.c_str());
+ response.PutStringAsRawHex8(uuid_str);
}
response.PutChar(';');
const auto &module_arch = matched_module_spec.GetArchitecture();
response.PutCString("triple:");
- response.PutCStringAsRawHex8(module_arch.GetTriple().getTriple().c_str());
+ response.PutStringAsRawHex8(module_arch.GetTriple().getTriple());
response.PutChar(';');
response.PutCString("file_path:");
- response.PutCStringAsRawHex8(matched_module_spec.GetFileSpec().GetCString());
+ response.PutStringAsRawHex8(matched_module_spec.GetFileSpec().GetCString());
response.PutChar(';');
response.PutCString("file_offset:");
response.PutHex64(file_offset);
@@ -1181,13 +1167,13 @@ void GDBRemoteCommunicationServerCommon::CreateProcessInfoResponse(
proc_info.GetUserID(), proc_info.GetGroupID(),
proc_info.GetEffectiveUserID(), proc_info.GetEffectiveGroupID());
response.PutCString("name:");
- response.PutCStringAsRawHex8(proc_info.GetExecutableFile().GetCString());
+ response.PutStringAsRawHex8(proc_info.GetExecutableFile().GetCString());
response.PutChar(';');
const ArchSpec &proc_arch = proc_info.GetArchitecture();
if (proc_arch.IsValid()) {
const llvm::Triple &proc_triple = proc_arch.GetTriple();
response.PutCString("triple:");
- response.PutCStringAsRawHex8(proc_triple.getTriple().c_str());
+ response.PutStringAsRawHex8(proc_triple.getTriple());
response.PutChar(';');
}
}
@@ -1221,7 +1207,7 @@ void GDBRemoteCommunicationServerCommon::
#else
// We'll send the triple.
response.PutCString("triple:");
- response.PutCStringAsRawHex8(proc_triple.getTriple().c_str());
+ response.PutStringAsRawHex8(proc_triple.getTriple());
response.PutChar(';');
#endif
std::string ostype = proc_triple.getOSName();
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
index f3825bb367917..5255463124703 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServerCommon.h --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,7 @@
#include <string>
-#include "lldb/Target/Process.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/lldb-private-forward.h"
#include "GDBRemoteCommunicationServer.h"
@@ -132,17 +131,15 @@ protected:
});
}
- //------------------------------------------------------------------
/// Launch a process with the current launch settings.
///
/// This method supports running an lldb-gdbserver or similar
/// server in a situation where the startup code has been provided
/// with all the information for a child process to be launched.
///
- /// @return
+ /// \return
/// An Status object indicating the success or failure of the
/// launch.
- //------------------------------------------------------------------
virtual Status LaunchProcess() = 0;
virtual FileSpec FindModuleFile(const std::string &module_path,
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index cdb63e72f6bdb..196607665bbaf 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServerLLGS.cpp --------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,6 +20,7 @@
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/Debug.h"
#include "lldb/Host/File.h"
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
@@ -28,7 +28,6 @@
#include "lldb/Host/common/NativeProcessProtocol.h"
#include "lldb/Host/common/NativeRegisterContext.h"
#include "lldb/Host/common/NativeThreadProtocol.h"
-#include "lldb/Target/FileAction.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/DataBuffer.h"
@@ -52,9 +51,7 @@ using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
using namespace llvm;
-//----------------------------------------------------------------------
// GDBRemote Errors
-//----------------------------------------------------------------------
namespace {
enum GDBRemoteServerError {
@@ -66,9 +63,7 @@ enum GDBRemoteServerError {
};
}
-//----------------------------------------------------------------------
// GDBRemoteCommunicationServerLLGS constructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationServerLLGS::GDBRemoteCommunicationServerLLGS(
MainLoop &mainloop, const NativeProcessProtocol::Factory &process_factory)
: GDBRemoteCommunicationServerCommon("gdb-remote.server",
@@ -149,8 +144,8 @@ void GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() {
StringExtractorGDBRemote::eServerPacketType_qWatchpointSupportInfo,
&GDBRemoteCommunicationServerLLGS::Handle_qWatchpointSupportInfo);
RegisterMemberFunctionHandler(
- StringExtractorGDBRemote::eServerPacketType_qXfer_auxv_read,
- &GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read);
+ StringExtractorGDBRemote::eServerPacketType_qXfer,
+ &GDBRemoteCommunicationServerLLGS::Handle_qXfer);
RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_s,
&GDBRemoteCommunicationServerLLGS::Handle_s);
RegisterMemberFunctionHandler(
@@ -192,6 +187,9 @@ void GDBRemoteCommunicationServerLLGS::RegisterPacketHandlers() {
StringExtractorGDBRemote::eServerPacketType_jTraceConfigRead,
&GDBRemoteCommunicationServerLLGS::Handle_jTraceConfigRead);
+ RegisterMemberFunctionHandler(StringExtractorGDBRemote::eServerPacketType_g,
+ &GDBRemoteCommunicationServerLLGS::Handle_g);
+
RegisterPacketHandler(StringExtractorGDBRemote::eServerPacketType_k,
[this](StringExtractorGDBRemote packet, Status &error,
bool &interrupt, bool &quit) {
@@ -623,7 +621,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
} else {
// The thread name contains special chars, send as hex bytes.
response.PutCString("hexname:");
- response.PutCStringAsRawHex8(thread_name.c_str());
+ response.PutStringAsRawHex8(thread_name);
}
response.PutChar(';');
}
@@ -663,7 +661,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
response.PutCString("jstopinfo:");
StreamString unescaped_response;
threads_info_sp->Write(unescaped_response);
- response.PutCStringAsRawHex8(unescaped_response.GetData());
+ response.PutStringAsRawHex8(unescaped_response.GetData());
response.PutChar(';');
} else
LLDB_LOG(log, "failed to prepare a jstopinfo field for pid {0}",
@@ -764,7 +762,7 @@ GDBRemoteCommunicationServerLLGS::SendStopReplyPacketForThread(
if (!description.empty()) {
// Description may contains special chars, send as hex bytes.
response.PutCString("description:");
- response.PutCStringAsRawHex8(description.c_str());
+ response.PutStringAsRawHex8(description);
response.PutChar(';');
} else if ((tid_stop_info.reason == eStopReasonException) &&
tid_stop_info.details.exception.type) {
@@ -1341,7 +1339,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qGetWorkingDir(
FileSpec working_dir{m_process_launch_info.GetWorkingDirectory()};
if (working_dir) {
StreamString response;
- response.PutCStringAsRawHex8(working_dir.GetCString());
+ response.PutStringAsRawHex8(working_dir.GetCString());
return SendPacketNoLock(response.GetString());
}
@@ -1897,6 +1895,61 @@ GDBRemoteCommunicationServerLLGS::Handle_qsThreadInfo(
}
GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_g(StringExtractorGDBRemote &packet) {
+ Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
+
+ // Move past packet name.
+ packet.SetFilePos(strlen("g"));
+
+ // Get the thread to use.
+ NativeThreadProtocol *thread = GetThreadFromSuffix(packet);
+ if (!thread) {
+ LLDB_LOG(log, "failed, no thread available");
+ return SendErrorResponse(0x15);
+ }
+
+ // Get the thread's register context.
+ NativeRegisterContext &reg_ctx = thread->GetRegisterContext();
+
+ std::vector<uint8_t> regs_buffer;
+ for (uint32_t reg_num = 0; reg_num < reg_ctx.GetUserRegisterCount();
+ ++reg_num) {
+ const RegisterInfo *reg_info = reg_ctx.GetRegisterInfoAtIndex(reg_num);
+
+ if (reg_info == nullptr) {
+ LLDB_LOG(log, "failed to get register info for register index {0}",
+ reg_num);
+ return SendErrorResponse(0x15);
+ }
+
+ if (reg_info->value_regs != nullptr)
+ continue; // skip registers that are contained in other registers
+
+ RegisterValue reg_value;
+ Status error = reg_ctx.ReadRegister(reg_info, reg_value);
+ if (error.Fail()) {
+ LLDB_LOG(log, "failed to read register at index {0}", reg_num);
+ return SendErrorResponse(0x15);
+ }
+
+ if (reg_info->byte_offset + reg_info->byte_size >= regs_buffer.size())
+ // Resize the buffer to guarantee it can store the register offsetted
+ // data.
+ regs_buffer.resize(reg_info->byte_offset + reg_info->byte_size);
+
+ // Copy the register offsetted data to the buffer.
+ memcpy(regs_buffer.data() + reg_info->byte_offset, reg_value.GetBytes(),
+ reg_info->byte_size);
+ }
+
+ // Write the response.
+ StreamGDBRemote response;
+ response.PutBytesAsRawHex8(regs_buffer.data(), regs_buffer.size());
+
+ return SendPacketNoLock(response.GetString());
+}
+
+GDBRemoteCommunication::PacketResult
GDBRemoteCommunicationServerLLGS::Handle_p(StringExtractorGDBRemote &packet) {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
@@ -2426,7 +2479,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo(
// Return the error message.
response.PutCString("error:");
- response.PutCStringAsRawHex8(error.AsCString());
+ response.PutStringAsRawHex8(error.AsCString());
response.PutChar(';');
} else {
// Range start and size.
@@ -2454,7 +2507,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qMemoryRegionInfo(
ConstString name = region_info.GetName();
if (name) {
response.PutCString("name:");
- response.PutCStringAsRawHex8(name.AsCString());
+ response.PutStringAsRawHex8(name.AsCString());
response.PutChar(';');
}
}
@@ -2694,94 +2747,99 @@ GDBRemoteCommunicationServerLLGS::Handle_s(StringExtractorGDBRemote &packet) {
return PacketResult::Success;
}
-GDBRemoteCommunication::PacketResult
-GDBRemoteCommunicationServerLLGS::Handle_qXfer_auxv_read(
- StringExtractorGDBRemote &packet) {
-// *BSD impls should be able to do this too.
-#if defined(__linux__) || defined(__NetBSD__)
- Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
-
- // Parse out the offset.
- packet.SetFilePos(strlen("qXfer:auxv:read::"));
- if (packet.GetBytesLeft() < 1)
- return SendIllFormedResponse(packet,
- "qXfer:auxv:read:: packet missing offset");
-
- const uint64_t auxv_offset =
- packet.GetHexMaxU64(false, std::numeric_limits<uint64_t>::max());
- if (auxv_offset == std::numeric_limits<uint64_t>::max())
- return SendIllFormedResponse(packet,
- "qXfer:auxv:read:: packet missing offset");
-
- // Parse out comma.
- if (packet.GetBytesLeft() < 1 || packet.GetChar() != ',')
- return SendIllFormedResponse(
- packet, "qXfer:auxv:read:: packet missing comma after offset");
-
- // Parse out the length.
- const uint64_t auxv_length =
- packet.GetHexMaxU64(false, std::numeric_limits<uint64_t>::max());
- if (auxv_length == std::numeric_limits<uint64_t>::max())
- return SendIllFormedResponse(packet,
- "qXfer:auxv:read:: packet missing length");
-
- // Grab the auxv data if we need it.
- if (!m_active_auxv_buffer_up) {
+llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
+GDBRemoteCommunicationServerLLGS::ReadXferObject(llvm::StringRef object,
+ llvm::StringRef annex) {
+ if (object == "auxv") {
// Make sure we have a valid process.
if (!m_debugged_process_up ||
(m_debugged_process_up->GetID() == LLDB_INVALID_PROCESS_ID)) {
- if (log)
- log->Printf(
- "GDBRemoteCommunicationServerLLGS::%s failed, no process available",
- __FUNCTION__);
- return SendErrorResponse(0x10);
+ return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "No process available");
}
// Grab the auxv data.
auto buffer_or_error = m_debugged_process_up->GetAuxvData();
- if (!buffer_or_error) {
- std::error_code ec = buffer_or_error.getError();
- LLDB_LOG(log, "no auxv data retrieved: {0}", ec.message());
- return SendErrorResponse(ec.value());
- }
- m_active_auxv_buffer_up = std::move(*buffer_or_error);
+ if (!buffer_or_error)
+ return llvm::errorCodeToError(buffer_or_error.getError());
+ return std::move(*buffer_or_error);
}
+ return llvm::make_error<PacketUnimplementedError>(
+ "Xfer object not supported");
+}
+
+GDBRemoteCommunication::PacketResult
+GDBRemoteCommunicationServerLLGS::Handle_qXfer(
+ StringExtractorGDBRemote &packet) {
+ SmallVector<StringRef, 5> fields;
+ // The packet format is "qXfer:<object>:<action>:<annex>:offset,length"
+ StringRef(packet.GetStringRef()).split(fields, ':', 4);
+ if (fields.size() != 5)
+ return SendIllFormedResponse(packet, "malformed qXfer packet");
+ StringRef &xfer_object = fields[1];
+ StringRef &xfer_action = fields[2];
+ StringRef &xfer_annex = fields[3];
+ StringExtractor offset_data(fields[4]);
+ if (xfer_action != "read")
+ return SendUnimplementedResponse("qXfer action not supported");
+ // Parse offset.
+ const uint64_t xfer_offset =
+ offset_data.GetHexMaxU64(false, std::numeric_limits<uint64_t>::max());
+ if (xfer_offset == std::numeric_limits<uint64_t>::max())
+ return SendIllFormedResponse(packet, "qXfer packet missing offset");
+ // Parse out comma.
+ if (offset_data.GetChar() != ',')
+ return SendIllFormedResponse(packet,
+ "qXfer packet missing comma after offset");
+ // Parse out the length.
+ const uint64_t xfer_length =
+ offset_data.GetHexMaxU64(false, std::numeric_limits<uint64_t>::max());
+ if (xfer_length == std::numeric_limits<uint64_t>::max())
+ return SendIllFormedResponse(packet, "qXfer packet missing length");
+
+ // Get a previously constructed buffer if it exists or create it now.
+ std::string buffer_key = (xfer_object + xfer_action + xfer_annex).str();
+ auto buffer_it = m_xfer_buffer_map.find(buffer_key);
+ if (buffer_it == m_xfer_buffer_map.end()) {
+ auto buffer_up = ReadXferObject(xfer_object, xfer_annex);
+ if (!buffer_up)
+ return SendErrorResponse(buffer_up.takeError());
+ buffer_it = m_xfer_buffer_map
+ .insert(std::make_pair(buffer_key, std::move(*buffer_up)))
+ .first;
+ }
+
+ // Send back the response
StreamGDBRemote response;
bool done_with_buffer = false;
-
- llvm::StringRef buffer = m_active_auxv_buffer_up->getBuffer();
- if (auxv_offset >= buffer.size()) {
+ llvm::StringRef buffer = buffer_it->second->getBuffer();
+ if (xfer_offset >= buffer.size()) {
// We have nothing left to send. Mark the buffer as complete.
response.PutChar('l');
done_with_buffer = true;
} else {
// Figure out how many bytes are available starting at the given offset.
- buffer = buffer.drop_front(auxv_offset);
-
+ buffer = buffer.drop_front(xfer_offset);
// Mark the response type according to whether we're reading the remainder
- // of the auxv data.
- if (auxv_length >= buffer.size()) {
+ // of the data.
+ if (xfer_length >= buffer.size()) {
// There will be nothing left to read after this
response.PutChar('l');
done_with_buffer = true;
} else {
// There will still be bytes to read after this request.
response.PutChar('m');
- buffer = buffer.take_front(auxv_length);
+ buffer = buffer.take_front(xfer_length);
}
-
// Now write the data in encoded binary form.
response.PutEscapedBytes(buffer.data(), buffer.size());
}
if (done_with_buffer)
- m_active_auxv_buffer_up.reset();
+ m_xfer_buffer_map.erase(buffer_it);
return SendPacketNoLock(response.GetString());
-#else
- return SendUnimplementedResponse("not implemented on this platform");
-#endif
}
GDBRemoteCommunication::PacketResult
@@ -3206,8 +3264,8 @@ uint32_t GDBRemoteCommunicationServerLLGS::GetNextSavedRegistersID() {
void GDBRemoteCommunicationServerLLGS::ClearProcessSpecificData() {
Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
- LLDB_LOG(log, "clearing auxv buffer: {0}", m_active_auxv_buffer_up.get());
- m_active_auxv_buffer_up.reset();
+ LLDB_LOG(log, "clearing {0} xfer buffers", m_xfer_buffer_map.size());
+ m_xfer_buffer_map.clear();
}
FileSpec
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
index a085a3cc17dd1..068ea52caaaf0 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServerLLGS.h ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,43 +31,35 @@ class GDBRemoteCommunicationServerLLGS
: public GDBRemoteCommunicationServerCommon,
public NativeProcessProtocol::NativeDelegate {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
GDBRemoteCommunicationServerLLGS(
MainLoop &mainloop,
const NativeProcessProtocol::Factory &process_factory);
void SetLaunchInfo(const ProcessLaunchInfo &info);
- //------------------------------------------------------------------
/// Launch a process with the current launch settings.
///
/// This method supports running an lldb-gdbserver or similar
/// server in a situation where the startup code has been provided
/// with all the information for a child process to be launched.
///
- /// @return
+ /// \return
/// An Status object indicating the success or failure of the
/// launch.
- //------------------------------------------------------------------
Status LaunchProcess() override;
- //------------------------------------------------------------------
/// Attach to a process.
///
/// This method supports attaching llgs to a process accessible via the
/// configured Platform.
///
- /// @return
+ /// \return
/// An Status object indicating the success or failure of the
/// attach operation.
- //------------------------------------------------------------------
Status AttachToProcess(lldb::pid_t pid);
- //------------------------------------------------------------------
// NativeProcessProtocol::NativeDelegate overrides
- //------------------------------------------------------------------
void InitializeDelegate(NativeProcessProtocol *process) override;
void ProcessStateChanged(NativeProcessProtocol *process,
@@ -91,7 +82,7 @@ protected:
MainLoop::ReadHandleUP m_stdio_handle_up;
lldb::StateType m_inferior_prev_state = lldb::StateType::eStateInvalid;
- std::unique_ptr<llvm::MemoryBuffer> m_active_auxv_buffer_up;
+ llvm::StringMap<std::unique_ptr<llvm::MemoryBuffer>> m_xfer_buffer_map;
std::mutex m_saved_registers_mutex;
std::unordered_map<uint32_t, lldb::DataBufferSP> m_saved_registers_map;
uint32_t m_next_saved_registers_id = 1;
@@ -159,7 +150,7 @@ protected:
PacketResult Handle_s(StringExtractorGDBRemote &packet);
- PacketResult Handle_qXfer_auxv_read(StringExtractorGDBRemote &packet);
+ PacketResult Handle_qXfer(StringExtractorGDBRemote &packet);
PacketResult Handle_QSaveRegisterState(StringExtractorGDBRemote &packet);
@@ -187,6 +178,8 @@ protected:
PacketResult Handle_QPassSignals(StringExtractorGDBRemote &packet);
+ PacketResult Handle_g(StringExtractorGDBRemote &packet);
+
void SetCurrentThreadID(lldb::tid_t tid);
lldb::tid_t GetCurrentThreadID() const;
@@ -200,6 +193,9 @@ protected:
FileSpec FindModuleFile(const std::string &module_path,
const ArchSpec &arch) override;
+ llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
+ ReadXferObject(llvm::StringRef object, llvm::StringRef annex);
+
private:
void HandleInferiorState_Exited(NativeProcessProtocol *process);
@@ -223,9 +219,7 @@ private:
void StopSTDIOForwarding();
- //------------------------------------------------------------------
// For GDBRemoteCommunicationServerLLGS only
- //------------------------------------------------------------------
DISALLOW_COPY_AND_ASSIGN(GDBRemoteCommunicationServerLLGS);
};
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
index 3521ddafbb166..6deb75f2f0211 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServerPlatform.cpp ----------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,11 +21,10 @@
#include "lldb/Host/Config.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
+#include "lldb/Host/FileAction.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/HostInfo.h"
-#include "lldb/Target/FileAction.h"
#include "lldb/Target/Platform.h"
-#include "lldb/Target/Process.h"
#include "lldb/Target/UnixSignals.h"
#include "lldb/Utility/JSON.h"
#include "lldb/Utility/Log.h"
@@ -41,9 +39,7 @@ using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
-//----------------------------------------------------------------------
// GDBRemoteCommunicationServerPlatform constructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
const Socket::SocketProtocol socket_protocol, const char *socket_scheme)
: GDBRemoteCommunicationServerCommon("gdb-remote.server",
@@ -87,9 +83,7 @@ GDBRemoteCommunicationServerPlatform::GDBRemoteCommunicationServerPlatform(
});
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
GDBRemoteCommunicationServerPlatform::~GDBRemoteCommunicationServerPlatform() {}
Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer(
@@ -121,25 +115,24 @@ Status GDBRemoteCommunicationServerPlatform::LaunchGDBServer(
this, std::placeholders::_1),
false);
- llvm::StringRef platform_scheme;
- llvm::StringRef platform_ip;
- int platform_port;
- llvm::StringRef platform_path;
- std::string platform_uri = GetConnection()->GetURI();
- bool ok = UriParser::Parse(platform_uri, platform_scheme, platform_ip,
- platform_port, platform_path);
- UNUSED_IF_ASSERT_DISABLED(ok);
- assert(ok);
-
std::ostringstream url;
// debugserver does not accept the URL scheme prefix.
#if !defined(__APPLE__)
url << m_socket_scheme << "://";
#endif
uint16_t *port_ptr = &port;
- if (m_socket_protocol == Socket::ProtocolTcp)
+ if (m_socket_protocol == Socket::ProtocolTcp) {
+ llvm::StringRef platform_scheme;
+ llvm::StringRef platform_ip;
+ int platform_port;
+ llvm::StringRef platform_path;
+ std::string platform_uri = GetConnection()->GetURI();
+ bool ok = UriParser::Parse(platform_uri, platform_scheme, platform_ip,
+ platform_port, platform_path);
+ UNUSED_IF_ASSERT_DISABLED(ok);
+ assert(ok);
url << platform_ip.str() << ":" << port;
- else {
+ } else {
socket_name = GetDomainSocketPath("gdbserver").GetPath();
url << socket_name;
port_ptr = nullptr;
@@ -207,7 +200,7 @@ GDBRemoteCommunicationServerPlatform::Handle_qLaunchGDBServer(
port + m_port_offset);
if (!socket_name.empty()) {
response.PutCString("socket_name:");
- response.PutCStringAsRawHex8(socket_name.c_str());
+ response.PutStringAsRawHex8(socket_name);
response.PutChar(';');
}
@@ -399,7 +392,7 @@ GDBRemoteCommunicationServerPlatform::Handle_jSignalsInfo(
StringExtractorGDBRemote &packet) {
StructuredData::Array signal_array;
- const auto &signals = Host::GetUnixSignals();
+ lldb::UnixSignalsSP signals = UnixSignals::CreateForHost();
for (auto signo = signals->GetFirstSignalNumber();
signo != LLDB_INVALID_SIGNAL_NUMBER;
signo = signals->GetNextSignalNumber(signo)) {
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
index df51e0367d1d2..eacc99a012db5 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteCommunicationServerPlatform.h ------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,7 +35,6 @@ public:
// a port chosen by the OS.
void SetPortMap(PortMap &&port_map);
- //----------------------------------------------------------------------
// If we are using a port map where we can only use certain ports,
// get the next available port.
//
@@ -44,7 +42,6 @@ public:
//
// If we aren't using a port map, return 0 to indicate we should bind to
// port 0 and then figure out which port we used.
- //----------------------------------------------------------------------
uint16_t GetNextAvailablePort();
bool AssociatePortWithProcess(uint16_t port, lldb::pid_t pid);
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index e58f47f4befef..a77e659a55fa2 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -1,9 +1,8 @@
//===-- GDBRemoteRegisterContext.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,13 +22,13 @@
#include "Utility/ARM_ehframe_Registers.h"
#include "lldb/Utility/StringExtractorGDBRemote.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
-//----------------------------------------------------------------------
// GDBRemoteRegisterContext constructor
-//----------------------------------------------------------------------
GDBRemoteRegisterContext::GDBRemoteRegisterContext(
ThreadGDBRemote &thread, uint32_t concrete_frame_idx,
GDBRemoteDynamicRegisterInfo &reg_info, bool read_all_at_once)
@@ -47,9 +46,7 @@ GDBRemoteRegisterContext::GDBRemoteRegisterContext(
m_reg_data.SetByteOrder(thread.GetProcess()->GetByteOrder());
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
GDBRemoteRegisterContext::~GDBRemoteRegisterContext() {}
void GDBRemoteRegisterContext::InvalidateAllRegisters() {
@@ -101,7 +98,7 @@ bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info,
bool GDBRemoteRegisterContext::PrivateSetRegisterValue(
uint32_t reg, llvm::ArrayRef<uint8_t> data) {
const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
- if (reg_info == NULL)
+ if (reg_info == nullptr)
return false;
// Invalidate if needed
@@ -125,7 +122,7 @@ bool GDBRemoteRegisterContext::PrivateSetRegisterValue(
bool GDBRemoteRegisterContext::PrivateSetRegisterValue(uint32_t reg,
uint64_t new_reg_val) {
const RegisterInfo *reg_info = GetRegisterInfoAtIndex(reg);
- if (reg_info == NULL)
+ if (reg_info == nullptr)
return false;
// Early in process startup, we can get a thread that has an invalid byte
@@ -151,7 +148,7 @@ bool GDBRemoteRegisterContext::PrivateSetRegisterValue(uint32_t reg,
uint8_t *dst = const_cast<uint8_t *>(
m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
- if (dst == NULL)
+ if (dst == nullptr)
return false;
if (data.CopyByteOrderedData(0, // src offset
@@ -186,7 +183,7 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info,
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = exe_ctx.GetThreadPtr();
- if (process == NULL || thread == NULL)
+ if (process == nullptr || thread == nullptr)
return false;
GDBRemoteCommunicationClient &gdb_comm(
@@ -206,6 +203,14 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info,
if (buffer_sp->GetByteSize() >= m_reg_data.GetByteSize()) {
SetAllRegisterValid(true);
return true;
+ } else {
+ Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_THREAD |
+ GDBR_LOG_PACKETS));
+ if (log)
+ log->Printf ("error: GDBRemoteRegisterContext::ReadRegisterBytes tried to read the "
+ "entire register context at once, expected at least %" PRId64 " bytes "
+ "but only got %" PRId64 " bytes.", m_reg_data.GetByteSize(),
+ buffer_sp->GetByteSize());
}
}
return false;
@@ -223,7 +228,7 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info,
// We have a valid primordial register as our constituent. Grab the
// corresponding register info.
const RegisterInfo *prim_reg_info = GetRegisterInfoAtIndex(prim_reg);
- if (prim_reg_info == NULL)
+ if (prim_reg_info == nullptr)
success = false;
else {
// Read the containing register if it hasn't already been read
@@ -248,10 +253,8 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const RegisterInfo *reg_info,
}
if (&data != &m_reg_data) {
-#if defined(LLDB_CONFIGURATION_DEBUG)
assert(m_reg_data.GetByteSize() >=
reg_info->byte_offset + reg_info->byte_size);
-#endif
// If our register context and our register info disagree, which should
// never happen, don't read past the end of the buffer.
if (m_reg_data.GetByteSize() < reg_info->byte_offset + reg_info->byte_size)
@@ -298,16 +301,14 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info,
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = exe_ctx.GetThreadPtr();
- if (process == NULL || thread == NULL)
+ if (process == nullptr || thread == nullptr)
return false;
GDBRemoteCommunicationClient &gdb_comm(
((ProcessGDBRemote *)process)->GetGDBRemote());
-#if defined(LLDB_CONFIGURATION_DEBUG)
assert(m_reg_data.GetByteSize() >=
reg_info->byte_offset + reg_info->byte_size);
-#endif
// If our register context and our register info disagree, which should never
// happen, don't overwrite past the end of the buffer.
@@ -318,7 +319,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info,
uint8_t *dst = const_cast<uint8_t *>(
m_reg_data.PeekData(reg_info->byte_offset, reg_info->byte_size));
- if (dst == NULL)
+ if (dst == nullptr)
return false;
if (data.CopyByteOrderedData(data_offset, // src offset
@@ -360,7 +361,7 @@ bool GDBRemoteRegisterContext::WriteRegisterBytes(const RegisterInfo *reg_info,
// We have a valid primordial register as our constituent. Grab the
// corresponding register info.
const RegisterInfo *value_reg_info = GetRegisterInfoAtIndex(reg);
- if (value_reg_info == NULL)
+ if (value_reg_info == nullptr)
success = false;
else
success = SetPrimordialRegister(value_reg_info, gdb_comm);
@@ -408,7 +409,7 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues(
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = exe_ctx.GetThreadPtr();
- if (process == NULL || thread == NULL)
+ if (process == nullptr || thread == nullptr)
return false;
GDBRemoteCommunicationClient &gdb_comm(
@@ -433,7 +434,7 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues(
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = exe_ctx.GetThreadPtr();
- if (process == NULL || thread == NULL)
+ if (process == nullptr || thread == nullptr)
return false;
GDBRemoteCommunicationClient &gdb_comm(
@@ -451,7 +452,7 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues(
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = exe_ctx.GetThreadPtr();
- if (process == NULL || thread == NULL)
+ if (process == nullptr || thread == nullptr)
return false;
GDBRemoteCommunicationClient &gdb_comm(
@@ -473,7 +474,8 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues(
// individually and store them as binary data in a buffer.
const RegisterInfo *reg_info;
- for (uint32_t i = 0; (reg_info = GetRegisterInfoAtIndex(i)) != NULL; i++) {
+ for (uint32_t i = 0; (reg_info = GetRegisterInfoAtIndex(i)) != nullptr;
+ i++) {
if (reg_info
->value_regs) // skip registers that are slices of real registers
continue;
@@ -481,8 +483,8 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues(
// ReadRegisterBytes saves the contents of the register in to the
// m_reg_data buffer
}
- data_sp.reset(new DataBufferHeap(m_reg_data.GetDataStart(),
- m_reg_info.GetRegisterDataByteSize()));
+ data_sp = std::make_shared<DataBufferHeap>(
+ m_reg_data.GetDataStart(), m_reg_info.GetRegisterDataByteSize());
return true;
} else {
@@ -507,14 +509,14 @@ bool GDBRemoteRegisterContext::ReadAllRegisterValues(
bool GDBRemoteRegisterContext::WriteAllRegisterValues(
const lldb::DataBufferSP &data_sp) {
- if (!data_sp || data_sp->GetBytes() == NULL || data_sp->GetByteSize() == 0)
+ if (!data_sp || data_sp->GetBytes() == nullptr || data_sp->GetByteSize() == 0)
return false;
ExecutionContext exe_ctx(CalculateThread());
Process *process = exe_ctx.GetProcessPtr();
Thread *thread = exe_ctx.GetThreadPtr();
- if (process == NULL || thread == NULL)
+ if (process == nullptr || thread == nullptr)
return false;
GDBRemoteCommunicationClient &gdb_comm(
@@ -556,9 +558,9 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues(
uint64_t size_by_highest_offset = 0;
for (uint32_t reg_idx = 0;
- (reg_info = GetRegisterInfoAtIndex(reg_idx)) != NULL; ++reg_idx) {
+ (reg_info = GetRegisterInfoAtIndex(reg_idx)) != nullptr; ++reg_idx) {
size_including_slice_registers += reg_info->byte_size;
- if (reg_info->value_regs == NULL)
+ if (reg_info->value_regs == nullptr)
size_not_including_slice_registers += reg_info->byte_size;
if (reg_info->byte_offset >= size_by_highest_offset)
size_by_highest_offset = reg_info->byte_offset + reg_info->byte_size;
@@ -590,7 +592,7 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues(
// keep track of the size of each reg & compute offset based on that.
uint32_t running_byte_offset = 0;
for (uint32_t reg_idx = 0;
- (reg_info = GetRegisterInfoAtIndex(reg_idx)) != NULL;
+ (reg_info = GetRegisterInfoAtIndex(reg_idx)) != nullptr;
++reg_idx, running_byte_offset += reg_info->byte_size) {
// Skip composite aka slice registers (e.g. eax is a slice of rax).
if (reg_info->value_regs)
@@ -636,7 +638,7 @@ bool GDBRemoteRegisterContext::WriteAllRegisterValues(
}
uint32_t num_restored = 0;
const RegisterInfo *reg_info;
- for (uint32_t i = 0; (reg_info = GetRegisterInfoAtIndex(i)) != NULL;
+ for (uint32_t i = 0; (reg_info = GetRegisterInfoAtIndex(i)) != nullptr;
i++) {
if (reg_info->value_regs) // skip registers that are slices of real
// registers
diff --git a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
index 6e8f3306669f3..25e9b716f8cbb 100644
--- a/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ b/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -1,9 +1,8 @@
//===-- GDBRemoteRegisterContext.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 797f63d537a17..a6fdd8dd07070 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1,9 +1,8 @@
//===-- ProcessGDBRemote.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,6 +23,7 @@
#include <algorithm>
#include <csignal>
#include <map>
+#include <memory>
#include <mutex>
#include <sstream>
@@ -41,7 +41,6 @@
#include "lldb/Host/PosixApi.h"
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/StringConvert.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Host/ThreadLauncher.h"
#include "lldb/Host/XML.h"
#include "lldb/Interpreter/CommandInterpreter.h"
@@ -54,6 +53,7 @@
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Interpreter/Options.h"
#include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
@@ -111,12 +111,40 @@ void DumpProcessGDBRemotePacketHistory(void *p, const char *path) {
namespace {
static constexpr PropertyDefinition g_properties[] = {
- {"packet-timeout", OptionValue::eTypeUInt64, true, 1, NULL, {},
+ {"packet-timeout",
+ OptionValue::eTypeUInt64,
+ true,
+ 5
+#if defined(__has_feature)
+#if __has_feature(address_sanitizer)
+ * 2
+#endif
+#endif
+ ,
+ nullptr,
+ {},
"Specify the default packet timeout in seconds."},
- {"target-definition-file", OptionValue::eTypeFileSpec, true, 0, NULL, {},
- "The file that provides the description for remote target registers."}};
-
-enum { ePropertyPacketTimeout, ePropertyTargetDefinitionFile };
+ {"target-definition-file",
+ OptionValue::eTypeFileSpec,
+ true,
+ 0,
+ nullptr,
+ {},
+ "The file that provides the description for remote target registers."},
+ {"use-libraries-svr4",
+ OptionValue::eTypeBoolean,
+ true,
+ false,
+ nullptr,
+ {},
+ "If true, the libraries-svr4 feature will be used to get a hold of the "
+ "process's loaded modules."}};
+
+enum {
+ ePropertyPacketTimeout,
+ ePropertyTargetDefinitionFile,
+ ePropertyUseSVR4
+};
class PluginProperties : public Properties {
public:
@@ -125,26 +153,32 @@ public:
}
PluginProperties() : Properties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
m_collection_sp->Initialize(g_properties);
}
- virtual ~PluginProperties() {}
+ ~PluginProperties() override {}
uint64_t GetPacketTimeout() {
const uint32_t idx = ePropertyPacketTimeout;
return m_collection_sp->GetPropertyAtIndexAsUInt64(
- NULL, idx, g_properties[idx].default_uint_value);
+ nullptr, idx, g_properties[idx].default_uint_value);
}
bool SetPacketTimeout(uint64_t timeout) {
const uint32_t idx = ePropertyPacketTimeout;
- return m_collection_sp->SetPropertyAtIndexAsUInt64(NULL, idx, timeout);
+ return m_collection_sp->SetPropertyAtIndexAsUInt64(nullptr, idx, timeout);
}
FileSpec GetTargetDefinitionFile() const {
const uint32_t idx = ePropertyTargetDefinitionFile;
- return m_collection_sp->GetPropertyAtIndexAsFileSpec(NULL, idx);
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+ }
+
+ bool GetUseSVR4() const {
+ const uint32_t idx = ePropertyUseSVR4;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_properties[idx].default_uint_value != 0);
}
};
@@ -153,25 +187,27 @@ typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP;
static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() {
static ProcessKDPPropertiesSP g_settings_sp;
if (!g_settings_sp)
- g_settings_sp.reset(new PluginProperties());
+ g_settings_sp = std::make_shared<PluginProperties>();
return g_settings_sp;
}
class ProcessGDBRemoteProvider
: public repro::Provider<ProcessGDBRemoteProvider> {
public:
+ struct Info {
+ static const char *name;
+ static const char *file;
+ };
+
ProcessGDBRemoteProvider(const FileSpec &directory) : Provider(directory) {
- m_info.name = "gdb-remote";
- m_info.files.push_back("gdb-remote.yaml");
}
raw_ostream *GetHistoryStream() {
- FileSpec history_file =
- GetRoot().CopyByAppendingPathComponent("gdb-remote.yaml");
+ FileSpec history_file = GetRoot().CopyByAppendingPathComponent(Info::file);
std::error_code EC;
m_stream_up = llvm::make_unique<raw_fd_ostream>(history_file.GetPath(), EC,
- sys::fs::OpenFlags::F_None);
+ sys::fs::OpenFlags::F_Text);
return m_stream_up.get();
}
@@ -191,6 +227,8 @@ private:
};
char ProcessGDBRemoteProvider::ID = 0;
+const char *ProcessGDBRemoteProvider::Info::name = "gdb-remote";
+const char *ProcessGDBRemoteProvider::Info::file = "gdb-remote.yaml";
} // namespace
@@ -239,8 +277,8 @@ ProcessGDBRemote::CreateInstance(lldb::TargetSP target_sp,
ListenerSP listener_sp,
const FileSpec *crash_file_path) {
lldb::ProcessSP process_sp;
- if (crash_file_path == NULL)
- process_sp.reset(new ProcessGDBRemote(target_sp, listener_sp));
+ if (crash_file_path == nullptr)
+ process_sp = std::make_shared<ProcessGDBRemote>(target_sp, listener_sp);
return process_sp;
}
@@ -275,15 +313,13 @@ bool ProcessGDBRemote::CanDebug(lldb::TargetSP target_sp,
return true;
}
-//----------------------------------------------------------------------
// ProcessGDBRemote constructor
-//----------------------------------------------------------------------
ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
ListenerSP listener_sp)
: Process(target_sp, listener_sp),
m_debugserver_pid(LLDB_INVALID_PROCESS_ID), m_last_stop_packet_mutex(),
m_register_info(),
- m_async_broadcaster(NULL, "lldb.process.gdb-remote.async-broadcaster"),
+ m_async_broadcaster(nullptr, "lldb.process.gdb-remote.async-broadcaster"),
m_async_listener_sp(
Listener::MakeListener("lldb.process.gdb-remote.async-listener")),
m_async_thread_state_mutex(), m_thread_ids(), m_thread_pcs(),
@@ -340,9 +376,7 @@ ProcessGDBRemote::ProcessGDBRemote(lldb::TargetSP target_sp,
m_gdb_comm.SetPacketTimeout(std::chrono::seconds(timeout_seconds));
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ProcessGDBRemote::~ProcessGDBRemote() {
// m_mach_process.UnregisterNotificationCallbacks (this);
Clear();
@@ -360,9 +394,7 @@ ProcessGDBRemote::~ProcessGDBRemote() {
KillDebugserverProcess();
}
-//----------------------------------------------------------------------
// PluginInterface
-//----------------------------------------------------------------------
ConstString ProcessGDBRemote::GetPluginName() { return GetPluginNameStatic(); }
uint32_t ProcessGDBRemote::GetPluginVersion() { return 1; }
@@ -370,7 +402,7 @@ uint32_t ProcessGDBRemote::GetPluginVersion() { return 1; }
bool ProcessGDBRemote::ParsePythonTargetDefinition(
const FileSpec &target_definition_fspec) {
ScriptInterpreter *interpreter =
- GetTarget().GetDebugger().GetCommandInterpreter().GetScriptInterpreter();
+ GetTarget().GetDebugger().GetScriptInterpreter();
Status error;
StructuredData::ObjectSP module_object_sp(
interpreter->LoadPluginModule(target_definition_fspec, error));
@@ -540,8 +572,8 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
std::vector<uint32_t> invalidate_regs;
std::vector<uint8_t> dwarf_opcode_bytes;
RegisterInfo reg_info = {
- NULL, // Name
- NULL, // Alt name
+ nullptr, // Name
+ nullptr, // Alt name
0, // byte size
reg_offset, // offset
eEncodingUint, // encoding
@@ -553,10 +585,10 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
reg_num, // process plugin reg num
reg_num // native register number
},
- NULL,
- NULL,
- NULL, // Dwarf expression opcode bytes pointer
- 0 // Dwarf expression opcode bytes length
+ nullptr,
+ nullptr,
+ nullptr, // Dwarf expression opcode bytes pointer
+ 0 // Dwarf expression opcode bytes length
};
while (response.GetNameColonValue(name, value)) {
@@ -576,7 +608,7 @@ void ProcessGDBRemote::BuildDynamicRegisterInfo(bool force) {
reg_info.encoding = encoding;
} else if (name.equals("format")) {
Format format = eFormatInvalid;
- if (OptionArgParser::ToFormat(value.str().c_str(), format, NULL)
+ if (OptionArgParser::ToFormat(value.str().c_str(), format, nullptr)
.Success())
reg_info.format = format;
else {
@@ -796,9 +828,7 @@ Status ProcessGDBRemote::WillLaunchOrAttach() {
return error;
}
-//----------------------------------------------------------------------
// Process Control
-//----------------------------------------------------------------------
Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
ProcessLaunchInfo &launch_info) {
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
@@ -883,8 +913,8 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
// since 'O' packets can really slow down debugging if the inferior
// does a lot of output.
if ((!stdin_file_spec || !stdout_file_spec || !stderr_file_spec) &&
- pty.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, NULL, 0)) {
- FileSpec slave_name{pty.GetSlaveName(NULL, 0)};
+ pty.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, nullptr, 0)) {
+ FileSpec slave_name{pty.GetSlaveName(nullptr, 0)};
if (!stdin_file_spec)
stdin_file_spec = slave_name;
@@ -928,7 +958,7 @@ Status ProcessGDBRemote::DoLaunch(lldb_private::Module *exe_module,
GetTarget().GetArchitecture().GetArchitectureName());
const char *launch_event_data = launch_info.GetLaunchEventData();
- if (launch_event_data != NULL && *launch_event_data != '\0')
+ if (launch_event_data != nullptr && *launch_event_data != '\0')
m_gdb_comm.SendLaunchEventDataPacket(launch_event_data);
if (working_dir) {
@@ -1013,14 +1043,14 @@ Status ProcessGDBRemote::ConnectToDebugserver(llvm::StringRef connect_url) {
if (log)
log->Printf("ProcessGDBRemote::%s Connecting to %s", __FUNCTION__,
connect_url.str().c_str());
- std::unique_ptr<ConnectionFileDescriptor> conn_ap(
+ std::unique_ptr<ConnectionFileDescriptor> conn_up(
new ConnectionFileDescriptor());
- if (conn_ap.get()) {
+ if (conn_up) {
const uint32_t max_retry_count = 50;
uint32_t retry_count = 0;
while (!m_gdb_comm.IsConnected()) {
- if (conn_ap->Connect(connect_url, &error) == eConnectionStatusSuccess) {
- m_gdb_comm.SetConnection(conn_ap.release());
+ if (conn_up->Connect(connect_url, &error) == eConnectionStatusSuccess) {
+ m_gdb_comm.SetConnection(conn_up.release());
break;
} else if (error.WasInterrupted()) {
// If we were interrupted, don't keep retrying.
@@ -1702,7 +1732,7 @@ bool ProcessGDBRemote::UpdateThreadList(ThreadList &old_thread_list,
ThreadSP thread_sp(
old_thread_list_copy.RemoveThreadByProtocolID(tid, false));
if (!thread_sp) {
- thread_sp.reset(new ThreadGDBRemote(*this, tid));
+ thread_sp = std::make_shared<ThreadGDBRemote>(*this, tid);
LLDB_LOGV(log, "Making new thread: {0} for thread ID: {1:x}.",
thread_sp.get(), thread_sp->GetID());
} else {
@@ -1818,7 +1848,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
if (!thread_sp) {
// Create the thread if we need to
- thread_sp.reset(new ThreadGDBRemote(*this, tid));
+ thread_sp = std::make_shared<ThreadGDBRemote>(*this, tid);
m_thread_list_real.AddThread(thread_sp);
}
}
@@ -1842,7 +1872,7 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
gdb_thread->PrivateSetRegisterValue(pair.first, buffer_sp->GetData());
}
- thread_sp->SetName(thread_name.empty() ? NULL : thread_name.c_str());
+ thread_sp->SetName(thread_name.empty() ? nullptr : thread_name.c_str());
gdb_thread->SetThreadDispatchQAddr(thread_dispatch_qaddr);
// Check if the GDB server was able to provide the queue name, kind and
@@ -2421,6 +2451,15 @@ void ProcessGDBRemote::RefreshStateAfterStop() {
// Scope for the lock
{
+ // Check to see if SetThreadStopInfo() filled in m_thread_ids?
+ if (m_thread_ids.empty()) {
+ // No, we need to fetch the thread list manually
+ UpdateThreadIDList();
+ }
+ // We might set some stop info's so make sure the thread list is up to
+ // date before we do that or we might overwrite what was computed here.
+ UpdateThreadListIfNeeded();
+
// Lock the thread stack while we access it
std::lock_guard<std::recursive_mutex> guard(m_last_stop_packet_mutex);
// Get the number of stop packets on the stack
@@ -2435,13 +2474,7 @@ void ProcessGDBRemote::RefreshStateAfterStop() {
// Clear the thread stop stack
m_stop_packet_stack.clear();
}
-
- // Check to see if SetThreadStopInfo() filled in m_thread_ids?
- if (m_thread_ids.empty()) {
- // No, we need to fetch the thread list manually
- UpdateThreadIDList();
- }
-
+
// If we have queried for a default thread id
if (m_initial_tid != LLDB_INVALID_THREAD_ID) {
m_thread_list.SetSelectedThreadByID(m_initial_tid);
@@ -2711,9 +2744,7 @@ void ProcessGDBRemote::SetUnixSignals(const UnixSignalsSP &signals_sp) {
Process::SetUnixSignals(std::make_shared<GDBRemoteSignals>(signals_sp));
}
-//------------------------------------------------------------------
// Process Queries
-//------------------------------------------------------------------
bool ProcessGDBRemote::IsAlive() {
return m_gdb_comm.IsConnected() && Process::IsAlive();
@@ -2757,9 +2788,7 @@ void ProcessGDBRemote::WillPublicStop() {
}
}
-//------------------------------------------------------------------
// Process Memory
-//------------------------------------------------------------------
size_t ProcessGDBRemote::DoReadMemory(addr_t addr, void *buf, size_t size,
Status &error) {
GetMaxMemorySize();
@@ -3120,14 +3149,12 @@ Status ProcessGDBRemote::DoDeallocateMemory(lldb::addr_t addr) {
return error;
}
-//------------------------------------------------------------------
// Process STDIO
-//------------------------------------------------------------------
size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len,
Status &error) {
if (m_stdio_communication.IsConnected()) {
ConnectionStatus status;
- m_stdio_communication.Write(src, src_len, status, NULL);
+ m_stdio_communication.Write(src, src_len, status, nullptr);
} else if (m_stdin_forward) {
m_gdb_comm.SendStdinNotification(src, src_len);
}
@@ -3136,7 +3163,7 @@ size_t ProcessGDBRemote::PutSTDIN(const char *src, size_t src_len,
Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) {
Status error;
- assert(bp_site != NULL);
+ assert(bp_site != nullptr);
// Get logging info
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS));
@@ -3262,7 +3289,7 @@ Status ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) {
Status ProcessGDBRemote::DisableBreakpointSite(BreakpointSite *bp_site) {
Status error;
- assert(bp_site != NULL);
+ assert(bp_site != nullptr);
addr_t addr = bp_site->GetLoadAddress();
user_id_t site_id = bp_site->GetID();
Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_BREAKPOINTS));
@@ -3432,16 +3459,10 @@ Status ProcessGDBRemote::ConnectToReplayServer(repro::Loader *loader) {
if (!loader)
return Status("No loader provided.");
- auto provider_info = loader->GetProviderInfo("gdb-remote");
- if (!provider_info)
- return Status("No provider for gdb-remote.");
-
- if (provider_info->files.empty())
- return Status("Provider for gdb-remote contains no files.");
-
// Construct replay history path.
- FileSpec history_file = loader->GetRoot().CopyByAppendingPathComponent(
- provider_info->files.front());
+ FileSpec history_file = loader->GetFile<ProcessGDBRemoteProvider::Info>();
+ if (!history_file)
+ return Status("No provider for gdb-remote.");
// Enable replay mode.
m_replay_mode = true;
@@ -3679,9 +3700,15 @@ bool ProcessGDBRemote::StartAsyncThread() {
// Create a thread that watches our internal state and controls which
// events make it to clients (into the DCProcess event queue).
- m_async_thread =
- ThreadLauncher::LaunchThread("<lldb.process.gdb-remote.async>",
- ProcessGDBRemote::AsyncThread, this, NULL);
+ llvm::Expected<HostThread> async_thread = ThreadLauncher::LaunchThread(
+ "<lldb.process.gdb-remote.async>", ProcessGDBRemote::AsyncThread, this);
+ if (!async_thread) {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(async_thread.takeError()));
+ return false;
+ }
+ m_async_thread = *async_thread;
} else if (log)
log->Printf("ProcessGDBRemote::%s () - Called when Async thread was "
"already running.",
@@ -3775,7 +3802,7 @@ thread_result_t ProcessGDBRemote::AsyncThread(void *arg) {
") got eBroadcastBitAsyncContinue: %s",
__FUNCTION__, arg, process->GetID(), continue_cstr);
- if (::strstr(continue_cstr, "vAttach") == NULL)
+ if (::strstr(continue_cstr, "vAttach") == nullptr)
process->SetPrivateState(eStateRunning);
StringExtractorGDBRemote response;
@@ -3841,11 +3868,11 @@ thread_result_t ProcessGDBRemote::AsyncThread(void *arg) {
// the "E87" error code from debugserver -- this indicates that
// the process is not debuggable. Return a slightly more
// helpful error message about why the attach failed.
- if (::strstr(continue_cstr, "vAttach") != NULL &&
+ if (::strstr(continue_cstr, "vAttach") != nullptr &&
response.GetError() == 0x87) {
process->SetExitStatus(-1, "cannot attach to process due to "
"System Integrity Protection");
- } else if (::strstr(continue_cstr, "vAttach") != NULL &&
+ } else if (::strstr(continue_cstr, "vAttach") != nullptr &&
response.GetStatus().Fail()) {
process->SetExitStatus(-1, response.GetStatus().AsCString());
} else {
@@ -3920,7 +3947,7 @@ thread_result_t ProcessGDBRemote::AsyncThread(void *arg) {
") thread exiting...",
__FUNCTION__, arg, process->GetID());
- return NULL;
+ return {};
}
// uint32_t
@@ -4016,7 +4043,7 @@ bool ProcessGDBRemote::StartNoticingNewThreads() {
}
}
}
- return m_thread_create_bp_sp.get() != NULL;
+ return m_thread_create_bp_sp.get() != nullptr;
}
bool ProcessGDBRemote::StopNoticingNewThreads() {
@@ -4031,9 +4058,9 @@ bool ProcessGDBRemote::StopNoticingNewThreads() {
}
DynamicLoader *ProcessGDBRemote::GetDynamicLoader() {
- if (m_dyld_ap.get() == NULL)
- m_dyld_ap.reset(DynamicLoader::FindPlugin(this, NULL));
- return m_dyld_ap.get();
+ if (m_dyld_up.get() == nullptr)
+ m_dyld_up.reset(DynamicLoader::FindPlugin(this, nullptr));
+ return m_dyld_up.get();
}
Status ProcessGDBRemote::SendEventData(const char *data) {
@@ -4053,17 +4080,17 @@ Status ProcessGDBRemote::SendEventData(const char *data) {
return error;
}
-const DataBufferSP ProcessGDBRemote::GetAuxvData() {
+DataExtractor ProcessGDBRemote::GetAuxvData() {
DataBufferSP buf;
if (m_gdb_comm.GetQXferAuxvReadSupported()) {
std::string response_string;
if (m_gdb_comm.SendPacketsAndConcatenateResponses("qXfer:auxv:read::",
response_string) ==
GDBRemoteCommunication::PacketResult::Success)
- buf.reset(new DataBufferHeap(response_string.c_str(),
- response_string.length()));
+ buf = std::make_shared<DataBufferHeap>(response_string.c_str(),
+ response_string.length());
}
- return buf;
+ return DataExtractor(buf, GetByteOrder(), GetAddressByteSize());
}
StructuredData::ObjectSP
@@ -4212,7 +4239,7 @@ StructuredData::ObjectSP ProcessGDBRemote::GetSharedCacheInfo() {
}
Status ProcessGDBRemote::ConfigureStructuredData(
- const ConstString &type_name, const StructuredData::ObjectSP &config_sp) {
+ ConstString type_name, const StructuredData::ObjectSP &config_sp) {
return m_gdb_comm.ConfigureRemoteStructuredData(type_name, config_sp);
}
@@ -4373,8 +4400,8 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
bool encoding_set = false;
bool format_set = false;
RegisterInfo reg_info = {
- NULL, // Name
- NULL, // Alt name
+ nullptr, // Name
+ nullptr, // Alt name
0, // byte size
reg_offset, // offset
eEncodingUint, // encoding
@@ -4386,10 +4413,10 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
cur_reg_num, // process plugin reg num
cur_reg_num // native register number
},
- NULL,
- NULL,
- NULL, // Dwarf Expression opcode bytes pointer
- 0 // Dwarf Expression opcode bytes length
+ nullptr,
+ nullptr,
+ nullptr, // Dwarf Expression opcode bytes pointer
+ 0 // Dwarf Expression opcode bytes length
};
reg_node.ForEachAttribute([&target_info, &gdb_group, &gdb_type,
@@ -4423,7 +4450,8 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
} else if (name == "format") {
format_set = true;
Format format = eFormatInvalid;
- if (OptionArgParser::ToFormat(value.data(), format, NULL).Success())
+ if (OptionArgParser::ToFormat(value.data(), format, nullptr)
+ .Success())
reg_info.format = format;
else if (value == "vector-sint8")
reg_info.format = eFormatVectorOfSInt8;
@@ -4499,8 +4527,15 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
// Only update the register set name if we didn't get a "reg_set"
// attribute. "set_name" will be empty if we didn't have a "reg_set"
// attribute.
- if (!set_name && !gdb_group.empty())
- set_name.SetCString(gdb_group.c_str());
+ if (!set_name) {
+ if (!gdb_group.empty()) {
+ set_name.SetCString(gdb_group.c_str());
+ } else {
+ // If no register group name provided anywhere,
+ // we'll create a 'general' register set
+ set_name.SetCString("general");
+ }
+ }
reg_info.byte_offset = reg_offset;
assert(reg_info.byte_size != 0);
@@ -4525,38 +4560,33 @@ bool ParseRegisters(XMLNode feature_node, GdbServerTargetInfo &target_info,
} // namespace
-// query the target of gdb-remote for extended target information return:
-// 'true' on success
-// 'false' on failure
-bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) {
- // Make sure LLDB has an XML parser it can use first
- if (!XMLDocument::XMLEnabled())
- return false;
-
- // redirect libxml2's error handler since the default prints to stdout
-
- GDBRemoteCommunicationClient &comm = m_gdb_comm;
-
- // check that we have extended feature read support
- if (!comm.GetQXferFeaturesReadSupported())
- return false;
-
+// This method fetches a register description feature xml file from
+// the remote stub and adds registers/register groupsets/architecture
+// information to the current process. It will call itself recursively
+// for nested register definition files. It returns true if it was able
+// to fetch and parse an xml file.
+bool ProcessGDBRemote::GetGDBServerRegisterInfoXMLAndProcess(ArchSpec &arch_to_use,
+ std::string xml_filename,
+ uint32_t &cur_reg_num,
+ uint32_t &reg_offset) {
// request the target xml file
std::string raw;
lldb_private::Status lldberr;
- if (!comm.ReadExtFeature(ConstString("features"), ConstString("target.xml"),
+ if (!m_gdb_comm.ReadExtFeature(ConstString("features"),
+ ConstString(xml_filename.c_str()),
raw, lldberr)) {
return false;
}
XMLDocument xml_document;
- if (xml_document.ParseMemory(raw.c_str(), raw.size(), "target.xml")) {
+ if (xml_document.ParseMemory(raw.c_str(), raw.size(), xml_filename.c_str())) {
GdbServerTargetInfo target_info;
+ std::vector<XMLNode> feature_nodes;
+ // The top level feature XML file will start with a <target> tag.
XMLNode target_node = xml_document.GetRootElement("target");
if (target_node) {
- std::vector<XMLNode> feature_nodes;
target_node.ForEachChildElement([&target_info, &feature_nodes](
const XMLNode &node) -> bool {
llvm::StringRef name = node.GetName();
@@ -4594,32 +4624,48 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) {
}
return true; // Keep iterating through all children of the target_node
});
+ } else {
+ // In an included XML feature file, we're already "inside" the <target>
+ // tag of the initial XML file; this included file will likely only have
+ // a <feature> tag. Need to check for any more included files in this
+ // <feature> element.
+ XMLNode feature_node = xml_document.GetRootElement("feature");
+ if (feature_node) {
+ feature_nodes.push_back(feature_node);
+ feature_node.ForEachChildElement([&target_info](
+ const XMLNode &node) -> bool {
+ llvm::StringRef name = node.GetName();
+ if (name == "xi:include" || name == "include") {
+ llvm::StringRef href = node.GetAttributeValue("href");
+ if (!href.empty())
+ target_info.includes.push_back(href.str());
+ }
+ return true;
+ });
+ }
+ }
- // If the target.xml includes an architecture entry like
- // <architecture>i386:x86-64</architecture> (seen from VMWare ESXi)
- // <architecture>arm</architecture> (seen from Segger JLink on unspecified arm board)
- // use that if we don't have anything better.
- if (!arch_to_use.IsValid() && !target_info.arch.empty()) {
- if (target_info.arch == "i386:x86-64") {
- // We don't have any information about vendor or OS.
- arch_to_use.SetTriple("x86_64--");
- GetTarget().MergeArchitecture(arch_to_use);
- }
-
- // SEGGER J-Link jtag boards send this very-generic arch name,
- // we'll need to use this if we have absolutely nothing better
- // to work with or the register definitions won't be accepted.
- if (target_info.arch == "arm") {
- arch_to_use.SetTriple("arm--");
- GetTarget().MergeArchitecture(arch_to_use);
- }
+ // If the target.xml includes an architecture entry like
+ // <architecture>i386:x86-64</architecture> (seen from VMWare ESXi)
+ // <architecture>arm</architecture> (seen from Segger JLink on unspecified arm board)
+ // use that if we don't have anything better.
+ if (!arch_to_use.IsValid() && !target_info.arch.empty()) {
+ if (target_info.arch == "i386:x86-64") {
+ // We don't have any information about vendor or OS.
+ arch_to_use.SetTriple("x86_64--");
+ GetTarget().MergeArchitecture(arch_to_use);
}
- // Initialize these outside of ParseRegisters, since they should not be
- // reset inside each include feature
- uint32_t cur_reg_num = 0;
- uint32_t reg_offset = 0;
+ // SEGGER J-Link jtag boards send this very-generic arch name,
+ // we'll need to use this if we have absolutely nothing better
+ // to work with or the register definitions won't be accepted.
+ if (target_info.arch == "arm") {
+ arch_to_use.SetTriple("arm--");
+ GetTarget().MergeArchitecture(arch_to_use);
+ }
+ }
+ if (arch_to_use.IsValid()) {
// Don't use Process::GetABI, this code gets called from DidAttach, and
// in that context we haven't set the Target's architecture yet, so the
// ABI is also potentially incorrect.
@@ -4630,26 +4676,31 @@ bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) {
}
for (const auto &include : target_info.includes) {
- // request register file
- std::string xml_data;
- if (!comm.ReadExtFeature(ConstString("features"), ConstString(include),
- xml_data, lldberr))
- continue;
-
- XMLDocument include_xml_document;
- include_xml_document.ParseMemory(xml_data.data(), xml_data.size(),
- include.c_str());
- XMLNode include_feature_node =
- include_xml_document.GetRootElement("feature");
- if (include_feature_node) {
- ParseRegisters(include_feature_node, target_info,
- this->m_register_info, abi_to_use_sp, cur_reg_num,
- reg_offset);
- }
+ GetGDBServerRegisterInfoXMLAndProcess(arch_to_use, include,
+ cur_reg_num, reg_offset);
}
- this->m_register_info.Finalize(arch_to_use);
}
+ } else {
+ return false;
}
+ return true;
+}
+
+// query the target of gdb-remote for extended target information returns
+// true on success (got register definitions), false on failure (did not).
+bool ProcessGDBRemote::GetGDBServerRegisterInfo(ArchSpec &arch_to_use) {
+ // Make sure LLDB has an XML parser it can use first
+ if (!XMLDocument::XMLEnabled())
+ return false;
+
+ // check that we have extended feature read support
+ if (!m_gdb_comm.GetQXferFeaturesReadSupported())
+ return false;
+
+ uint32_t cur_reg_num = 0;
+ uint32_t reg_offset = 0;
+ if (GetGDBServerRegisterInfoXMLAndProcess (arch_to_use, "target.xml", cur_reg_num, reg_offset))
+ this->m_register_info.Finalize(arch_to_use);
return m_register_info.GetNumRegisters() > 0;
}
@@ -4664,9 +4715,10 @@ Status ProcessGDBRemote::GetLoadedModuleList(LoadedModuleInfoList &list) {
log->Printf("ProcessGDBRemote::%s", __FUNCTION__);
GDBRemoteCommunicationClient &comm = m_gdb_comm;
+ bool can_use_svr4 = GetGlobalPluginProperties()->GetUseSVR4();
// check that we have extended feature read support
- if (comm.GetQXferLibrariesSVR4ReadSupported()) {
+ if (can_use_svr4 && comm.GetQXferLibrariesSVR4ReadSupported()) {
list.clear();
// request the loaded library list
@@ -4929,7 +4981,7 @@ Status ProcessGDBRemote::GetFileLoadAddress(const FileSpec &file,
StreamString packet;
packet.PutCString("qFileLoadAddress:");
- packet.PutCStringAsRawHex8(file_path.c_str());
+ packet.PutStringAsRawHex8(file_path);
StringExtractorGDBRemote response;
if (m_gdb_comm.SendPacketAndWaitForResponse(packet.GetString(), response,
@@ -5140,7 +5192,7 @@ public:
"Tests packet speeds of various sizes to determine "
"the performance characteristics of the GDB remote "
"connection. ",
- NULL),
+ nullptr),
m_option_group(),
m_num_packets(LLDB_OPT_SET_1, false, "count", 'c', 0, eArgTypeCount,
"The number of packets to send of each varying size "
@@ -5165,7 +5217,7 @@ public:
m_option_group.Finalize();
}
- ~CommandObjectProcessGDBRemoteSpeedTest() {}
+ ~CommandObjectProcessGDBRemoteSpeedTest() override {}
Options *GetOptions() override { return &m_option_group; }
@@ -5214,9 +5266,9 @@ private:
public:
CommandObjectProcessGDBRemotePacketHistory(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "process plugin packet history",
- "Dumps the packet history buffer. ", NULL) {}
+ "Dumps the packet history buffer. ", nullptr) {}
- ~CommandObjectProcessGDBRemotePacketHistory() {}
+ ~CommandObjectProcessGDBRemotePacketHistory() override {}
bool DoExecute(Args &command, CommandReturnObject &result) override {
const size_t argc = command.GetArgumentCount();
@@ -5245,9 +5297,9 @@ public:
: CommandObjectParsed(
interpreter, "process plugin packet xfer-size",
"Maximum size that lldb will try to read/write one one chunk.",
- NULL) {}
+ nullptr) {}
- ~CommandObjectProcessGDBRemotePacketXferSize() {}
+ ~CommandObjectProcessGDBRemotePacketXferSize() override {}
bool DoExecute(Args &command, CommandReturnObject &result) override {
const size_t argc = command.GetArgumentCount();
@@ -5265,7 +5317,7 @@ public:
if (process) {
const char *packet_size = command.GetArgumentAtIndex(0);
errno = 0;
- uint64_t user_specified_max = strtoul(packet_size, NULL, 10);
+ uint64_t user_specified_max = strtoul(packet_size, nullptr, 10);
if (errno == 0 && user_specified_max != 0) {
process->SetUserSpecifiedMaxMemoryTransferSize(user_specified_max);
result.SetStatus(eReturnStatusSuccessFinishResult);
@@ -5287,9 +5339,9 @@ public:
"The packet header and footer will automatically "
"be added to the packet prior to sending and "
"stripped from the result.",
- NULL) {}
+ nullptr) {}
- ~CommandObjectProcessGDBRemotePacketSend() {}
+ ~CommandObjectProcessGDBRemotePacketSend() override {}
bool DoExecute(Args &command, CommandReturnObject &result) override {
const size_t argc = command.GetArgumentCount();
@@ -5315,7 +5367,7 @@ public:
output_strm.Printf(" packet: %s\n", packet_cstr);
std::string &response_str = response.GetStringRef();
- if (strstr(packet_cstr, "qGetProfileData") != NULL) {
+ if (strstr(packet_cstr, "qGetProfileData") != nullptr) {
response_str = process->HarmonizeThreadIdsForProfileData(response);
}
@@ -5340,7 +5392,7 @@ public:
"encoded into a valid 'qRcmd' packet, sent and the "
"response will be printed.") {}
- ~CommandObjectProcessGDBRemotePacketMonitor() {}
+ ~CommandObjectProcessGDBRemotePacketMonitor() override {}
bool DoExecute(llvm::StringRef command,
CommandReturnObject &result) override {
@@ -5383,7 +5435,7 @@ public:
CommandObjectProcessGDBRemotePacket(CommandInterpreter &interpreter)
: CommandObjectMultiword(interpreter, "process plugin packet",
"Commands that deal with GDB remote packets.",
- NULL) {
+ nullptr) {
LoadSubCommand(
"history",
CommandObjectSP(
@@ -5404,7 +5456,7 @@ public:
interpreter)));
}
- ~CommandObjectProcessGDBRemotePacket() {}
+ ~CommandObjectProcessGDBRemotePacket() override {}
};
class CommandObjectMultiwordProcessGDBRemote : public CommandObjectMultiword {
@@ -5419,12 +5471,12 @@ public:
CommandObjectSP(new CommandObjectProcessGDBRemotePacket(interpreter)));
}
- ~CommandObjectMultiwordProcessGDBRemote() {}
+ ~CommandObjectMultiwordProcessGDBRemote() override {}
};
CommandObject *ProcessGDBRemote::GetPluginCommandObject() {
if (!m_command_sp)
- m_command_sp.reset(new CommandObjectMultiwordProcessGDBRemote(
- GetTarget().GetDebugger().GetCommandInterpreter()));
+ m_command_sp = std::make_shared<CommandObjectMultiwordProcessGDBRemote>(
+ GetTarget().GetDebugger().GetCommandInterpreter());
return m_command_sp.get();
}
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 14a5237e43451..9c41fc2e5e988 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -1,9 +1,8 @@
//===-- ProcessGDBRemote.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -68,17 +67,13 @@ public:
static const char *GetPluginDescriptionStatic();
- //------------------------------------------------------------------
// Check if a given Process
- //------------------------------------------------------------------
bool CanDebug(lldb::TargetSP target_sp,
bool plugin_specified_by_name) override;
CommandObject *GetPluginCommandObject() override;
- //------------------------------------------------------------------
// Creating a new process, or attaching to an existing one
- //------------------------------------------------------------------
Status WillLaunch(Module *module) override;
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
@@ -103,16 +98,12 @@ public:
void DidAttach(ArchSpec &process_arch) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- //------------------------------------------------------------------
// Process Control
- //------------------------------------------------------------------
Status WillResume() override;
Status DoResume() override;
@@ -131,18 +122,14 @@ public:
void SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
- //------------------------------------------------------------------
// Process Queries
- //------------------------------------------------------------------
bool IsAlive() override;
lldb::addr_t GetImageInfoAddress() override;
void WillPublicStop() override;
- //------------------------------------------------------------------
// Process Memory
- //------------------------------------------------------------------
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
Status &error) override;
@@ -160,21 +147,15 @@ public:
Status DoDeallocateMemory(lldb::addr_t ptr) override;
- //------------------------------------------------------------------
// Process STDIO
- //------------------------------------------------------------------
size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override;
- //----------------------------------------------------------------------
// Process Breakpoints
- //----------------------------------------------------------------------
Status EnableBreakpointSite(BreakpointSite *bp_site) override;
Status DisableBreakpointSite(BreakpointSite *bp_site) override;
- //----------------------------------------------------------------------
// Process Watchpoints
- //----------------------------------------------------------------------
Status EnableWatchpoint(Watchpoint *wp, bool notify = true) override;
Status DisableWatchpoint(Watchpoint *wp, bool notify = true) override;
@@ -206,9 +187,7 @@ public:
Status SendEventData(const char *data) override;
- //----------------------------------------------------------------------
// Override DidExit so we can disconnect from the remote GDB server
- //----------------------------------------------------------------------
void DidExit() override;
void SetUserSpecifiedMaxMemoryTransferSize(uint64_t user_specified_max);
@@ -235,7 +214,7 @@ public:
lldb::addr_t image_count) override;
Status
- ConfigureStructuredData(const ConstString &type_name,
+ ConfigureStructuredData(ConstString type_name,
const StructuredData::ObjectSP &config_sp) override;
StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos() override;
@@ -256,9 +235,7 @@ protected:
friend class GDBRemoteCommunicationClient;
friend class GDBRemoteRegisterContext;
- //------------------------------------------------------------------
/// Broadcaster event bits definitions.
- //------------------------------------------------------------------
enum {
eBroadcastBitAsyncContinue = (1 << 0),
eBroadcastBitAsyncThreadShouldExit = (1 << 1),
@@ -313,9 +290,7 @@ protected:
using FlashRange = FlashRangeVector::Entry;
FlashRangeVector m_erased_flash_ranges;
- //----------------------------------------------------------------------
// Accessors
- //----------------------------------------------------------------------
bool IsRunning(lldb::StateType state) {
return state == lldb::eStateRunning || IsStepping(state);
}
@@ -349,7 +324,7 @@ protected:
bool ParsePythonTargetDefinition(const FileSpec &target_definition_fspec);
- const lldb::DataBufferSP GetAuxvData() override;
+ DataExtractor GetAuxvData() override;
StructuredData::ObjectSP GetExtendedInfoForThread(lldb::tid_t tid);
@@ -408,6 +383,11 @@ protected:
DynamicLoader *GetDynamicLoader() override;
+ bool GetGDBServerRegisterInfoXMLAndProcess(ArchSpec &arch_to_use,
+ std::string xml_filename,
+ uint32_t &cur_reg_num,
+ uint32_t &reg_offset);
+
// Query remote GDBServer for register information
bool GetGDBServerRegisterInfo(ArchSpec &arch);
@@ -428,9 +408,7 @@ protected:
bool HasErased(FlashRange range);
private:
- //------------------------------------------------------------------
// For ProcessGDBRemote only
- //------------------------------------------------------------------
std::string m_partial_profile_data;
std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
uint64_t m_last_signals_version = 0;
@@ -440,9 +418,7 @@ private:
lldb::user_id_t break_id,
lldb::user_id_t break_loc_id);
- //------------------------------------------------------------------
// ContinueDelegate interface
- //------------------------------------------------------------------
void HandleAsyncStdout(llvm::StringRef out) override;
void HandleAsyncMisc(llvm::StringRef data) override;
void HandleStopReply() override;
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
index 8f16b83907cf6..8cadc45824b3e 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.cpp
@@ -1,9 +1,8 @@
//===-- ProcessGDBRemoteLog.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
index d4981df88d8da..d9b8d4536afe1 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h
@@ -1,9 +1,8 @@
//===-- ProcessGDBRemoteLog.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
index db7dc3eae0ba4..6607bce4488b4 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp
@@ -1,9 +1,8 @@
//===-- ThreadGDBRemote.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,18 +20,18 @@
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/StringExtractorGDBRemote.h"
#include "ProcessGDBRemote.h"
#include "ProcessGDBRemoteLog.h"
-#include "lldb/Utility/StringExtractorGDBRemote.h"
+
+#include <memory>
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::process_gdb_remote;
-//----------------------------------------------------------------------
// Thread Registers
-//----------------------------------------------------------------------
ThreadGDBRemote::ThreadGDBRemote(Process &process, lldb::tid_t tid)
: Thread(process, tid), m_thread_name(), m_dispatch_queue_name(),
@@ -308,9 +307,9 @@ ThreadGDBRemote::CreateRegisterContextForFrame(StackFrame *frame) {
// supported.
bool read_all_registers_at_once =
!gdb_process->GetGDBRemote().GetpPacketSupported(GetID());
- reg_ctx_sp.reset(new GDBRemoteRegisterContext(
+ reg_ctx_sp = std::make_shared<GDBRemoteRegisterContext>(
*this, concrete_frame_idx, gdb_process->m_register_info,
- read_all_registers_at_once));
+ read_all_registers_at_once);
}
} else {
Unwind *unwinder = GetUnwinder();
diff --git a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
index 4485a9cdc4c36..c74be169abaf7 100644
--- a/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
+++ b/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h
@@ -1,9 +1,8 @@
//===-- ThreadGDBRemote.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,13 +11,14 @@
#include <string>
-#include "lldb/Target/Process.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/StructuredData.h"
class StringExtractor;
namespace lldb_private {
+class Process;
+
namespace process_gdb_remote {
class ProcessGDBRemote;
diff --git a/source/Plugins/Process/minidump/MinidumpParser.cpp b/source/Plugins/Process/minidump/MinidumpParser.cpp
index d4053ca70b943..ff015aa54b763 100644
--- a/source/Plugins/Process/minidump/MinidumpParser.cpp
+++ b/source/Plugins/Process/minidump/MinidumpParser.cpp
@@ -1,9 +1,8 @@
//===-- MinidumpParser.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,8 +10,9 @@
#include "NtStructures.h"
#include "RegisterContextMinidump_x86_32.h"
-#include "lldb/Utility/LLDBAssert.h"
#include "Plugins/Process/Utility/LinuxProcMaps.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Log.h"
// C includes
// C++ includes
@@ -24,47 +24,33 @@
using namespace lldb_private;
using namespace minidump;
-llvm::Optional<MinidumpParser>
-MinidumpParser::Create(const lldb::DataBufferSP &data_buf_sp) {
- if (data_buf_sp->GetByteSize() < sizeof(MinidumpHeader)) {
- return llvm::None;
- }
- return MinidumpParser(data_buf_sp);
+llvm::Expected<MinidumpParser>
+MinidumpParser::Create(const lldb::DataBufferSP &data_sp) {
+ auto ExpectedFile = llvm::object::MinidumpFile::create(
+ llvm::MemoryBufferRef(toStringRef(data_sp->GetData()), "minidump"));
+ if (!ExpectedFile)
+ return ExpectedFile.takeError();
+
+ return MinidumpParser(data_sp, std::move(*ExpectedFile));
}
-MinidumpParser::MinidumpParser(const lldb::DataBufferSP &data_buf_sp)
- : m_data_sp(data_buf_sp) {}
+MinidumpParser::MinidumpParser(lldb::DataBufferSP data_sp,
+ std::unique_ptr<llvm::object::MinidumpFile> file)
+ : m_data_sp(std::move(data_sp)), m_file(std::move(file)) {}
llvm::ArrayRef<uint8_t> MinidumpParser::GetData() {
return llvm::ArrayRef<uint8_t>(m_data_sp->GetBytes(),
m_data_sp->GetByteSize());
}
-llvm::ArrayRef<uint8_t>
-MinidumpParser::GetStream(MinidumpStreamType stream_type) {
- auto iter = m_directory_map.find(static_cast<uint32_t>(stream_type));
- if (iter == m_directory_map.end())
- return {};
-
- // check if there is enough data
- if (iter->second.rva + iter->second.data_size > m_data_sp->GetByteSize())
- return {};
-
- return llvm::ArrayRef<uint8_t>(m_data_sp->GetBytes() + iter->second.rva,
- iter->second.data_size);
-}
-
-llvm::Optional<std::string> MinidumpParser::GetMinidumpString(uint32_t rva) {
- auto arr_ref = m_data_sp->GetData();
- if (rva > arr_ref.size())
- return llvm::None;
- arr_ref = arr_ref.drop_front(rva);
- return parseMinidumpString(arr_ref);
+llvm::ArrayRef<uint8_t> MinidumpParser::GetStream(StreamType stream_type) {
+ return m_file->getRawStream(stream_type)
+ .getValueOr(llvm::ArrayRef<uint8_t>());
}
-UUID MinidumpParser::GetModuleUUID(const MinidumpModule *module) {
+UUID MinidumpParser::GetModuleUUID(const minidump::Module *module) {
auto cv_record =
- GetData().slice(module->CV_record.rva, module->CV_record.data_size);
+ GetData().slice(module->CvRecord.RVA, module->CvRecord.DataSize);
// Read the CV record signature
const llvm::support::ulittle32_t *signature = nullptr;
@@ -73,60 +59,68 @@ UUID MinidumpParser::GetModuleUUID(const MinidumpModule *module) {
return UUID();
const CvSignature cv_signature =
- static_cast<CvSignature>(static_cast<const uint32_t>(*signature));
+ static_cast<CvSignature>(static_cast<uint32_t>(*signature));
if (cv_signature == CvSignature::Pdb70) {
- // PDB70 record
const CvRecordPdb70 *pdb70_uuid = nullptr;
Status error = consumeObject(cv_record, pdb70_uuid);
- if (!error.Fail()) {
- auto arch = GetArchitecture();
- // For Apple targets we only need a 16 byte UUID so that we can match
- // the UUID in the Module to actual UUIDs from the built binaries. The
- // "Age" field is zero in breakpad minidump files for Apple targets, so
- // we restrict the UUID to the "Uuid" field so we have a UUID we can use
- // to match.
- if (arch.GetTriple().getVendor() == llvm::Triple::Apple)
- return UUID::fromData(pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
- else
- return UUID::fromData(pdb70_uuid, sizeof(*pdb70_uuid));
+ if (error.Fail())
+ return UUID();
+
+ CvRecordPdb70 swapped;
+ if (!GetArchitecture().GetTriple().isOSBinFormatELF()) {
+ // LLDB's UUID class treats the data as a sequence of bytes, but breakpad
+ // interprets it as a sequence of little-endian fields, which it converts
+ // to big-endian when converting to text. Swap the bytes to big endian so
+ // that the string representation comes out right.
+ swapped = *pdb70_uuid;
+ llvm::sys::swapByteOrder(swapped.Uuid.Data1);
+ llvm::sys::swapByteOrder(swapped.Uuid.Data2);
+ llvm::sys::swapByteOrder(swapped.Uuid.Data3);
+ llvm::sys::swapByteOrder(swapped.Age);
+ pdb70_uuid = &swapped;
}
+ if (pdb70_uuid->Age != 0)
+ return UUID::fromOptionalData(pdb70_uuid, sizeof(*pdb70_uuid));
+ return UUID::fromOptionalData(&pdb70_uuid->Uuid, sizeof(pdb70_uuid->Uuid));
} else if (cv_signature == CvSignature::ElfBuildId)
- return UUID::fromData(cv_record);
+ return UUID::fromOptionalData(cv_record);
return UUID();
}
-llvm::ArrayRef<MinidumpThread> MinidumpParser::GetThreads() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::ThreadList);
+llvm::ArrayRef<minidump::Thread> MinidumpParser::GetThreads() {
+ auto ExpectedThreads = GetMinidumpFile().getThreadList();
+ if (ExpectedThreads)
+ return *ExpectedThreads;
- if (data.size() == 0)
- return llvm::None;
-
- return MinidumpThread::ParseThreadList(data);
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD),
+ ExpectedThreads.takeError(),
+ "Failed to read thread list: {0}");
+ return {};
}
llvm::ArrayRef<uint8_t>
-MinidumpParser::GetThreadContext(const MinidumpLocationDescriptor &location) {
- if (location.rva + location.data_size > GetData().size())
+MinidumpParser::GetThreadContext(const LocationDescriptor &location) {
+ if (location.RVA + location.DataSize > GetData().size())
return {};
- return GetData().slice(location.rva, location.data_size);
+ return GetData().slice(location.RVA, location.DataSize);
}
llvm::ArrayRef<uint8_t>
-MinidumpParser::GetThreadContext(const MinidumpThread &td) {
- return GetThreadContext(td.thread_context);
+MinidumpParser::GetThreadContext(const minidump::Thread &td) {
+ return GetThreadContext(td.Context);
}
llvm::ArrayRef<uint8_t>
-MinidumpParser::GetThreadContextWow64(const MinidumpThread &td) {
+MinidumpParser::GetThreadContextWow64(const minidump::Thread &td) {
// On Windows, a 32-bit process can run on a 64-bit machine under WOW64. If
// the minidump was captured with a 64-bit debugger, then the CONTEXT we just
// grabbed from the mini_dump_thread is the one for the 64-bit "native"
// process rather than the 32-bit "guest" process we care about. In this
// case, we can get the 32-bit CONTEXT from the TEB (Thread Environment
// Block) of the 64-bit process.
- auto teb_mem = GetMemory(td.teb, sizeof(TEB64));
+ auto teb_mem = GetMemory(td.EnvironmentBlock, sizeof(TEB64));
if (teb_mem.empty())
return {};
@@ -149,24 +143,19 @@ MinidumpParser::GetThreadContextWow64(const MinidumpThread &td) {
// stored in the first slot of the 64-bit TEB (wow64teb.Reserved1[0]).
}
-const MinidumpSystemInfo *MinidumpParser::GetSystemInfo() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::SystemInfo);
-
- if (data.size() == 0)
- return nullptr;
-
- return MinidumpSystemInfo::Parse(data);
-}
-
ArchSpec MinidumpParser::GetArchitecture() {
if (m_arch.IsValid())
return m_arch;
// Set the architecture in m_arch
- const MinidumpSystemInfo *system_info = GetSystemInfo();
+ llvm::Expected<const SystemInfo &> system_info = m_file->getSystemInfo();
- if (!system_info)
+ if (!system_info) {
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS),
+ system_info.takeError(),
+ "Failed to read SystemInfo stream: {0}");
return m_arch;
+ }
// TODO what to do about big endiand flavors of arm ?
// TODO set the arm subarch stuff if the minidump has info about it
@@ -174,21 +163,17 @@ ArchSpec MinidumpParser::GetArchitecture() {
llvm::Triple triple;
triple.setVendor(llvm::Triple::VendorType::UnknownVendor);
- const MinidumpCPUArchitecture arch =
- static_cast<const MinidumpCPUArchitecture>(
- static_cast<const uint32_t>(system_info->processor_arch));
-
- switch (arch) {
- case MinidumpCPUArchitecture::X86:
+ switch (system_info->ProcessorArch) {
+ case ProcessorArchitecture::X86:
triple.setArch(llvm::Triple::ArchType::x86);
break;
- case MinidumpCPUArchitecture::AMD64:
+ case ProcessorArchitecture::AMD64:
triple.setArch(llvm::Triple::ArchType::x86_64);
break;
- case MinidumpCPUArchitecture::ARM:
+ case ProcessorArchitecture::ARM:
triple.setArch(llvm::Triple::ArchType::arm);
break;
- case MinidumpCPUArchitecture::ARM64:
+ case ProcessorArchitecture::ARM64:
triple.setArch(llvm::Triple::ArchType::aarch64);
break;
default:
@@ -196,48 +181,49 @@ ArchSpec MinidumpParser::GetArchitecture() {
break;
}
- const MinidumpOSPlatform os = static_cast<const MinidumpOSPlatform>(
- static_cast<const uint32_t>(system_info->platform_id));
-
// TODO add all of the OSes that Minidump/breakpad distinguishes?
- switch (os) {
- case MinidumpOSPlatform::Win32S:
- case MinidumpOSPlatform::Win32Windows:
- case MinidumpOSPlatform::Win32NT:
- case MinidumpOSPlatform::Win32CE:
+ switch (system_info->PlatformId) {
+ case OSPlatform::Win32S:
+ case OSPlatform::Win32Windows:
+ case OSPlatform::Win32NT:
+ case OSPlatform::Win32CE:
triple.setOS(llvm::Triple::OSType::Win32);
break;
- case MinidumpOSPlatform::Linux:
+ case OSPlatform::Linux:
triple.setOS(llvm::Triple::OSType::Linux);
break;
- case MinidumpOSPlatform::MacOSX:
+ case OSPlatform::MacOSX:
triple.setOS(llvm::Triple::OSType::MacOSX);
triple.setVendor(llvm::Triple::Apple);
break;
- case MinidumpOSPlatform::IOS:
+ case OSPlatform::IOS:
triple.setOS(llvm::Triple::OSType::IOS);
triple.setVendor(llvm::Triple::Apple);
break;
- case MinidumpOSPlatform::Android:
+ case OSPlatform::Android:
triple.setOS(llvm::Triple::OSType::Linux);
triple.setEnvironment(llvm::Triple::EnvironmentType::Android);
break;
default: {
triple.setOS(llvm::Triple::OSType::UnknownOS);
- std::string csd_version;
- if (auto s = GetMinidumpString(system_info->csd_version_rva))
- csd_version = *s;
- if (csd_version.find("Linux") != std::string::npos)
- triple.setOS(llvm::Triple::OSType::Linux);
- break;
+ auto ExpectedCSD = m_file->getString(system_info->CSDVersionRVA);
+ if (!ExpectedCSD) {
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS),
+ ExpectedCSD.takeError(),
+ "Failed to CSD Version string: {0}");
+ } else {
+ if (ExpectedCSD->find("Linux") != std::string::npos)
+ triple.setOS(llvm::Triple::OSType::Linux);
}
+ break;
+ }
}
m_arch.SetTriple(triple);
return m_arch;
}
const MinidumpMiscInfo *MinidumpParser::GetMiscInfo() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::MiscInfo);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::MiscInfo);
if (data.size() == 0)
return nullptr;
@@ -246,7 +232,7 @@ const MinidumpMiscInfo *MinidumpParser::GetMiscInfo() {
}
llvm::Optional<LinuxProcStatus> MinidumpParser::GetLinuxProcStatus() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::LinuxProcStatus);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::LinuxProcStatus);
if (data.size() == 0)
return llvm::None;
@@ -268,41 +254,47 @@ llvm::Optional<lldb::pid_t> MinidumpParser::GetPid() {
return llvm::None;
}
-llvm::ArrayRef<MinidumpModule> MinidumpParser::GetModuleList() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::ModuleList);
+llvm::ArrayRef<minidump::Module> MinidumpParser::GetModuleList() {
+ auto ExpectedModules = GetMinidumpFile().getModuleList();
+ if (ExpectedModules)
+ return *ExpectedModules;
- if (data.size() == 0)
- return {};
-
- return MinidumpModule::ParseModuleList(data);
+ LLDB_LOG_ERROR(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES),
+ ExpectedModules.takeError(),
+ "Failed to read module list: {0}");
+ return {};
}
-std::vector<const MinidumpModule *> MinidumpParser::GetFilteredModuleList() {
- llvm::ArrayRef<MinidumpModule> modules = GetModuleList();
+std::vector<const minidump::Module *> MinidumpParser::GetFilteredModuleList() {
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
+ auto ExpectedModules = GetMinidumpFile().getModuleList();
+ if (!ExpectedModules) {
+ LLDB_LOG_ERROR(log, ExpectedModules.takeError(),
+ "Failed to read module list: {0}");
+ return {};
+ }
+
// map module_name -> filtered_modules index
typedef llvm::StringMap<size_t> MapType;
MapType module_name_to_filtered_index;
- std::vector<const MinidumpModule *> filtered_modules;
-
- llvm::Optional<std::string> name;
- std::string module_name;
+ std::vector<const minidump::Module *> filtered_modules;
- for (const auto &module : modules) {
- name = GetMinidumpString(module.module_name_rva);
-
- if (!name)
+ for (const auto &module : *ExpectedModules) {
+ auto ExpectedName = m_file->getString(module.ModuleNameRVA);
+ if (!ExpectedName) {
+ LLDB_LOG_ERROR(log, ExpectedName.takeError(),
+ "Failed to get module name: {0}");
continue;
-
- module_name = name.getValue();
-
+ }
+
MapType::iterator iter;
bool inserted;
// See if we have inserted this module aready into filtered_modules. If we
// haven't insert an entry into module_name_to_filtered_index with the
// index where we will insert it if it isn't in the vector already.
std::tie(iter, inserted) = module_name_to_filtered_index.try_emplace(
- module_name, filtered_modules.size());
+ *ExpectedName, filtered_modules.size());
if (inserted) {
// This module has not been seen yet, insert it into filtered_modules at
@@ -314,7 +306,7 @@ std::vector<const MinidumpModule *> MinidumpParser::GetFilteredModuleList() {
// times when they are mapped discontiguously, so find the module with
// the lowest "base_of_image" and use that as the filtered module.
auto dup_module = filtered_modules[iter->second];
- if (module.base_of_image < dup_module->base_of_image)
+ if (module.BaseOfImage < dup_module->BaseOfImage)
filtered_modules[iter->second] = &module;
}
}
@@ -322,7 +314,7 @@ std::vector<const MinidumpModule *> MinidumpParser::GetFilteredModuleList() {
}
const MinidumpExceptionStream *MinidumpParser::GetExceptionStream() {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::Exception);
+ llvm::ArrayRef<uint8_t> data = GetStream(StreamType::Exception);
if (data.size() == 0)
return nullptr;
@@ -332,30 +324,30 @@ const MinidumpExceptionStream *MinidumpParser::GetExceptionStream() {
llvm::Optional<minidump::Range>
MinidumpParser::FindMemoryRange(lldb::addr_t addr) {
- llvm::ArrayRef<uint8_t> data = GetStream(MinidumpStreamType::MemoryList);
- llvm::ArrayRef<uint8_t> data64 = GetStream(MinidumpStreamType::Memory64List);
-
- if (data.empty() && data64.empty())
- return llvm::None;
-
- if (!data.empty()) {
- llvm::ArrayRef<MinidumpMemoryDescriptor> memory_list =
- MinidumpMemoryDescriptor::ParseMemoryList(data);
-
- if (memory_list.empty())
- return llvm::None;
-
- for (const auto &memory_desc : memory_list) {
- const MinidumpLocationDescriptor &loc_desc = memory_desc.memory;
- const lldb::addr_t range_start = memory_desc.start_of_memory_range;
- const size_t range_size = loc_desc.data_size;
-
- if (loc_desc.rva + loc_desc.data_size > GetData().size())
+ llvm::ArrayRef<uint8_t> data64 = GetStream(StreamType::Memory64List);
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
+
+ auto ExpectedMemory = GetMinidumpFile().getMemoryList();
+ if (!ExpectedMemory) {
+ LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
+ "Failed to read memory list: {0}");
+ } else {
+ for (const auto &memory_desc : *ExpectedMemory) {
+ const LocationDescriptor &loc_desc = memory_desc.Memory;
+ const lldb::addr_t range_start = memory_desc.StartOfMemoryRange;
+ const size_t range_size = loc_desc.DataSize;
+
+ if (loc_desc.RVA + loc_desc.DataSize > GetData().size())
return llvm::None;
if (range_start <= addr && addr < range_start + range_size) {
- return minidump::Range(range_start,
- GetData().slice(loc_desc.rva, range_size));
+ auto ExpectedSlice = GetMinidumpFile().getRawData(loc_desc);
+ if (!ExpectedSlice) {
+ LLDB_LOG_ERROR(log, ExpectedSlice.takeError(),
+ "Failed to get memory slice: {0}");
+ return llvm::None;
+ }
+ return minidump::Range(range_start, *ExpectedSlice);
}
}
}
@@ -418,7 +410,7 @@ llvm::ArrayRef<uint8_t> MinidumpParser::GetMemory(lldb::addr_t addr,
static bool
CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser,
std::vector<MemoryRegionInfo> &regions) {
- auto data = parser.GetStream(MinidumpStreamType::LinuxMaps);
+ auto data = parser.GetStream(StreamType::LinuxMaps);
if (data.empty())
return false;
ParseLinuxMapRegions(llvm::toStringRef(data),
@@ -434,7 +426,7 @@ CreateRegionsCacheFromLinuxMaps(MinidumpParser &parser,
static bool
CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser,
std::vector<MemoryRegionInfo> &regions) {
- auto data = parser.GetStream(MinidumpStreamType::MemoryInfoList);
+ auto data = parser.GetStream(StreamType::MemoryInfoList);
if (data.empty())
return false;
auto mem_info_list = MinidumpMemoryInfo::ParseMemoryInfoList(data);
@@ -459,19 +451,20 @@ CreateRegionsCacheFromMemoryInfoList(MinidumpParser &parser,
static bool
CreateRegionsCacheFromMemoryList(MinidumpParser &parser,
std::vector<MemoryRegionInfo> &regions) {
- auto data = parser.GetStream(MinidumpStreamType::MemoryList);
- if (data.empty())
- return false;
- auto memory_list = MinidumpMemoryDescriptor::ParseMemoryList(data);
- if (memory_list.empty())
+ Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_MODULES);
+ auto ExpectedMemory = parser.GetMinidumpFile().getMemoryList();
+ if (!ExpectedMemory) {
+ LLDB_LOG_ERROR(log, ExpectedMemory.takeError(),
+ "Failed to read memory list: {0}");
return false;
- regions.reserve(memory_list.size());
- for (const auto &memory_desc : memory_list) {
- if (memory_desc.memory.data_size == 0)
+ }
+ regions.reserve(ExpectedMemory->size());
+ for (const MemoryDescriptor &memory_desc : *ExpectedMemory) {
+ if (memory_desc.Memory.DataSize == 0)
continue;
MemoryRegionInfo region;
- region.GetRange().SetRangeBase(memory_desc.start_of_memory_range);
- region.GetRange().SetByteSize(memory_desc.memory.data_size);
+ region.GetRange().SetRangeBase(memory_desc.StartOfMemoryRange);
+ region.GetRange().SetByteSize(memory_desc.Memory.DataSize);
region.SetReadable(MemoryRegionInfo::eYes);
region.SetMapped(MemoryRegionInfo::eYes);
regions.push_back(region);
@@ -484,7 +477,7 @@ static bool
CreateRegionsCacheFromMemory64List(MinidumpParser &parser,
std::vector<MemoryRegionInfo> &regions) {
llvm::ArrayRef<uint8_t> data =
- parser.GetStream(MinidumpStreamType::Memory64List);
+ parser.GetStream(StreamType::Memory64List);
if (data.empty())
return false;
llvm::ArrayRef<MinidumpMemoryDescriptor64> memory64_list;
@@ -564,120 +557,14 @@ const MemoryRegionInfos &MinidumpParser::GetMemoryRegions() {
return m_regions;
}
-Status MinidumpParser::Initialize() {
- Status error;
-
- lldbassert(m_directory_map.empty());
-
- llvm::ArrayRef<uint8_t> header_data(m_data_sp->GetBytes(),
- sizeof(MinidumpHeader));
- const MinidumpHeader *header = MinidumpHeader::Parse(header_data);
- if (header == nullptr) {
- error.SetErrorString("invalid minidump: can't parse the header");
- return error;
- }
-
- // A minidump without at least one stream is clearly ill-formed
- if (header->streams_count == 0) {
- error.SetErrorString("invalid minidump: no streams present");
- return error;
- }
-
- struct FileRange {
- uint32_t offset = 0;
- uint32_t size = 0;
-
- FileRange(uint32_t offset, uint32_t size) : offset(offset), size(size) {}
- uint32_t end() const { return offset + size; }
- };
-
- const uint32_t file_size = m_data_sp->GetByteSize();
-
- // Build a global minidump file map, checking for:
- // - overlapping streams/data structures
- // - truncation (streams pointing past the end of file)
- std::vector<FileRange> minidump_map;
-
- // Add the minidump header to the file map
- if (sizeof(MinidumpHeader) > file_size) {
- error.SetErrorString("invalid minidump: truncated header");
- return error;
- }
- minidump_map.emplace_back( 0, sizeof(MinidumpHeader) );
-
- // Add the directory entries to the file map
- FileRange directory_range(header->stream_directory_rva,
- header->streams_count *
- sizeof(MinidumpDirectory));
- if (directory_range.end() > file_size) {
- error.SetErrorString("invalid minidump: truncated streams directory");
- return error;
- }
- minidump_map.push_back(directory_range);
-
- // Parse stream directory entries
- llvm::ArrayRef<uint8_t> directory_data(
- m_data_sp->GetBytes() + directory_range.offset, directory_range.size);
- for (uint32_t i = 0; i < header->streams_count; ++i) {
- const MinidumpDirectory *directory_entry = nullptr;
- error = consumeObject(directory_data, directory_entry);
- if (error.Fail())
- return error;
- if (directory_entry->stream_type == 0) {
- // Ignore dummy streams (technically ill-formed, but a number of
- // existing minidumps seem to contain such streams)
- if (directory_entry->location.data_size == 0)
- continue;
- error.SetErrorString("invalid minidump: bad stream type");
- return error;
- }
- // Update the streams map, checking for duplicate stream types
- if (!m_directory_map
- .insert({directory_entry->stream_type, directory_entry->location})
- .second) {
- error.SetErrorString("invalid minidump: duplicate stream type");
- return error;
- }
- // Ignore the zero-length streams for layout checks
- if (directory_entry->location.data_size != 0) {
- minidump_map.emplace_back(directory_entry->location.rva,
- directory_entry->location.data_size);
- }
- }
-
- // Sort the file map ranges by start offset
- llvm::sort(minidump_map.begin(), minidump_map.end(),
- [](const FileRange &a, const FileRange &b) {
- return a.offset < b.offset;
- });
-
- // Check for overlapping streams/data structures
- for (size_t i = 1; i < minidump_map.size(); ++i) {
- const auto &prev_range = minidump_map[i - 1];
- if (prev_range.end() > minidump_map[i].offset) {
- error.SetErrorString("invalid minidump: overlapping streams");
- return error;
- }
- }
-
- // Check for streams past the end of file
- const auto &last_range = minidump_map.back();
- if (last_range.end() > file_size) {
- error.SetErrorString("invalid minidump: truncated stream");
- return error;
- }
-
- return error;
-}
-
-#define ENUM_TO_CSTR(ST) case (uint32_t)MinidumpStreamType::ST: return #ST
+#define ENUM_TO_CSTR(ST) \
+ case StreamType::ST: \
+ return #ST
llvm::StringRef
-MinidumpParser::GetStreamTypeAsString(uint32_t stream_type) {
+MinidumpParser::GetStreamTypeAsString(StreamType stream_type) {
switch (stream_type) {
ENUM_TO_CSTR(Unused);
- ENUM_TO_CSTR(Reserved0);
- ENUM_TO_CSTR(Reserved1);
ENUM_TO_CSTR(ThreadList);
ENUM_TO_CSTR(ModuleList);
ENUM_TO_CSTR(MemoryList);
@@ -698,6 +585,7 @@ MinidumpParser::GetStreamTypeAsString(uint32_t stream_type) {
ENUM_TO_CSTR(JavascriptData);
ENUM_TO_CSTR(SystemMemoryInfo);
ENUM_TO_CSTR(ProcessVMCounters);
+ ENUM_TO_CSTR(LastReserved);
ENUM_TO_CSTR(BreakpadInfo);
ENUM_TO_CSTR(AssertionInfo);
ENUM_TO_CSTR(LinuxCPUInfo);
@@ -711,6 +599,17 @@ MinidumpParser::GetStreamTypeAsString(uint32_t stream_type) {
ENUM_TO_CSTR(LinuxProcStat);
ENUM_TO_CSTR(LinuxProcUptime);
ENUM_TO_CSTR(LinuxProcFD);
+ ENUM_TO_CSTR(FacebookAppCustomData);
+ ENUM_TO_CSTR(FacebookBuildID);
+ ENUM_TO_CSTR(FacebookAppVersionName);
+ ENUM_TO_CSTR(FacebookJavaStack);
+ ENUM_TO_CSTR(FacebookDalvikInfo);
+ ENUM_TO_CSTR(FacebookUnwindSymbols);
+ ENUM_TO_CSTR(FacebookDumpErrorLog);
+ ENUM_TO_CSTR(FacebookAppStateLog);
+ ENUM_TO_CSTR(FacebookAbortReason);
+ ENUM_TO_CSTR(FacebookThreadName);
+ ENUM_TO_CSTR(FacebookLogcat);
}
return "unknown stream type";
}
diff --git a/source/Plugins/Process/minidump/MinidumpParser.h b/source/Plugins/Process/minidump/MinidumpParser.h
index 07ea6aa908ff5..fce64f0ed5fc4 100644
--- a/source/Plugins/Process/minidump/MinidumpParser.h
+++ b/source/Plugins/Process/minidump/MinidumpParser.h
@@ -1,9 +1,8 @@
//===-- MinidumpParser.h -----------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,6 +21,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Object/Minidump.h"
// C includes
@@ -41,31 +41,30 @@ struct Range {
Range(lldb::addr_t start, llvm::ArrayRef<uint8_t> range_ref)
: start(start), range_ref(range_ref) {}
+
+ friend bool operator==(const Range &lhs, const Range &rhs) {
+ return lhs.start == rhs.start && lhs.range_ref == rhs.range_ref;
+ }
};
class MinidumpParser {
public:
- static llvm::Optional<MinidumpParser>
+ static llvm::Expected<MinidumpParser>
Create(const lldb::DataBufferSP &data_buf_sp);
llvm::ArrayRef<uint8_t> GetData();
- llvm::ArrayRef<uint8_t> GetStream(MinidumpStreamType stream_type);
-
- llvm::Optional<std::string> GetMinidumpString(uint32_t rva);
+ llvm::ArrayRef<uint8_t> GetStream(StreamType stream_type);
- UUID GetModuleUUID(const MinidumpModule* module);
+ UUID GetModuleUUID(const minidump::Module *module);
- llvm::ArrayRef<MinidumpThread> GetThreads();
+ llvm::ArrayRef<minidump::Thread> GetThreads();
- llvm::ArrayRef<uint8_t>
- GetThreadContext(const MinidumpLocationDescriptor &location);
+ llvm::ArrayRef<uint8_t> GetThreadContext(const LocationDescriptor &location);
- llvm::ArrayRef<uint8_t> GetThreadContext(const MinidumpThread &td);
+ llvm::ArrayRef<uint8_t> GetThreadContext(const minidump::Thread &td);
- llvm::ArrayRef<uint8_t> GetThreadContextWow64(const MinidumpThread &td);
-
- const MinidumpSystemInfo *GetSystemInfo();
+ llvm::ArrayRef<uint8_t> GetThreadContextWow64(const minidump::Thread &td);
ArchSpec GetArchitecture();
@@ -75,13 +74,13 @@ public:
llvm::Optional<lldb::pid_t> GetPid();
- llvm::ArrayRef<MinidumpModule> GetModuleList();
+ llvm::ArrayRef<minidump::Module> GetModuleList();
// There are cases in which there is more than one record in the ModuleList
// for the same module name.(e.g. when the binary has non contiguous segments)
// So this function returns a filtered module list - if it finds records that
// have the same name, it keeps the copy with the lowest load address.
- std::vector<const MinidumpModule *> GetFilteredModuleList();
+ std::vector<const minidump::Module *> GetFilteredModuleList();
const MinidumpExceptionStream *GetExceptionStream();
@@ -93,24 +92,19 @@ public:
const MemoryRegionInfos &GetMemoryRegions();
- // Perform consistency checks and initialize internal data structures
- Status Initialize();
-
- static llvm::StringRef GetStreamTypeAsString(uint32_t stream_type);
+ static llvm::StringRef GetStreamTypeAsString(StreamType stream_type);
- const llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> &
- GetDirectoryMap() const {
- return m_directory_map;
- }
+ llvm::object::MinidumpFile &GetMinidumpFile() { return *m_file; }
private:
- MinidumpParser(const lldb::DataBufferSP &data_buf_sp);
+ MinidumpParser(lldb::DataBufferSP data_sp,
+ std::unique_ptr<llvm::object::MinidumpFile> file);
MemoryRegionInfo FindMemoryRegion(lldb::addr_t load_addr) const;
private:
lldb::DataBufferSP m_data_sp;
- llvm::DenseMap<uint32_t, MinidumpLocationDescriptor> m_directory_map;
+ std::unique_ptr<llvm::object::MinidumpFile> m_file;
ArchSpec m_arch;
MemoryRegionInfos m_regions;
bool m_parsed_regions = false;
diff --git a/source/Plugins/Process/minidump/MinidumpTypes.cpp b/source/Plugins/Process/minidump/MinidumpTypes.cpp
index 7b1900e34ef1e..d7fc6e43d090c 100644
--- a/source/Plugins/Process/minidump/MinidumpTypes.cpp
+++ b/source/Plugins/Process/minidump/MinidumpTypes.cpp
@@ -1,9 +1,8 @@
//===-- MinidumpTypes.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,96 +14,6 @@
using namespace lldb_private;
using namespace minidump;
-const MinidumpHeader *MinidumpHeader::Parse(llvm::ArrayRef<uint8_t> &data) {
- const MinidumpHeader *header = nullptr;
- Status error = consumeObject(data, header);
-
- const MinidumpHeaderConstants signature =
- static_cast<const MinidumpHeaderConstants>(
- static_cast<const uint32_t>(header->signature));
- const MinidumpHeaderConstants version =
- static_cast<const MinidumpHeaderConstants>(
- static_cast<const uint32_t>(header->version) & 0x0000ffff);
- // the high 16 bits of the version field are implementation specific
-
- if (error.Fail() || signature != MinidumpHeaderConstants::Signature ||
- version != MinidumpHeaderConstants::Version)
- return nullptr;
-
- return header;
-}
-
-// Minidump string
-llvm::Optional<std::string>
-lldb_private::minidump::parseMinidumpString(llvm::ArrayRef<uint8_t> &data) {
- std::string result;
-
- const uint32_t *source_length_ptr;
- Status error = consumeObject(data, source_length_ptr);
-
- // Copy non-aligned source_length data into aligned memory.
- uint32_t source_length;
- std::memcpy(&source_length, source_length_ptr, sizeof(source_length));
-
- if (error.Fail() || source_length > data.size() || source_length % 2 != 0)
- return llvm::None;
-
- auto source_start = reinterpret_cast<const llvm::UTF16 *>(data.data());
- // source_length is the length of the string in bytes we need the length of
- // the string in UTF-16 characters/code points (16 bits per char) that's why
- // it's divided by 2
- const auto source_end = source_start + source_length / 2;
- // resize to worst case length
- result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * source_length / 2);
- auto result_start = reinterpret_cast<llvm::UTF8 *>(&result[0]);
- const auto result_end = result_start + result.size();
- llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end,
- llvm::strictConversion);
- const auto result_size =
- std::distance(reinterpret_cast<llvm::UTF8 *>(&result[0]), result_start);
- result.resize(result_size); // shrink to actual length
-
- return result;
-}
-
-// MinidumpThread
-const MinidumpThread *MinidumpThread::Parse(llvm::ArrayRef<uint8_t> &data) {
- const MinidumpThread *thread = nullptr;
- Status error = consumeObject(data, thread);
- if (error.Fail())
- return nullptr;
-
- return thread;
-}
-
-llvm::ArrayRef<MinidumpThread>
-MinidumpThread::ParseThreadList(llvm::ArrayRef<uint8_t> &data) {
- const auto orig_size = data.size();
- const llvm::support::ulittle32_t *thread_count;
- Status error = consumeObject(data, thread_count);
- if (error.Fail() || *thread_count * sizeof(MinidumpThread) > data.size())
- return {};
-
- // Compilers might end up padding an extra 4 bytes depending on how the
- // structure is padded by the compiler and the #pragma pack settings.
- if (4 + *thread_count * sizeof(MinidumpThread) < orig_size)
- data = data.drop_front(4);
-
- return llvm::ArrayRef<MinidumpThread>(
- reinterpret_cast<const MinidumpThread *>(data.data()), *thread_count);
-}
-
-// MinidumpSystemInfo
-const MinidumpSystemInfo *
-MinidumpSystemInfo::Parse(llvm::ArrayRef<uint8_t> &data) {
- const MinidumpSystemInfo *system_info;
- Status error = consumeObject(data, system_info);
- if (error.Fail())
- return nullptr;
-
- return system_info;
-}
-
// MinidumpMiscInfo
const MinidumpMiscInfo *MinidumpMiscInfo::Parse(llvm::ArrayRef<uint8_t> &data) {
const MinidumpMiscInfo *misc_info;
@@ -116,8 +25,7 @@ const MinidumpMiscInfo *MinidumpMiscInfo::Parse(llvm::ArrayRef<uint8_t> &data) {
}
llvm::Optional<lldb::pid_t> MinidumpMiscInfo::GetPid() const {
- uint32_t pid_flag =
- static_cast<const uint32_t>(MinidumpMiscInfoFlags::ProcessID);
+ uint32_t pid_flag = static_cast<uint32_t>(MinidumpMiscInfoFlags::ProcessID);
if (flags1 & pid_flag)
return llvm::Optional<lldb::pid_t>(process_id);
@@ -149,33 +57,6 @@ LinuxProcStatus::Parse(llvm::ArrayRef<uint8_t> &data) {
lldb::pid_t LinuxProcStatus::GetPid() const { return pid; }
-// Module stuff
-const MinidumpModule *MinidumpModule::Parse(llvm::ArrayRef<uint8_t> &data) {
- const MinidumpModule *module = nullptr;
- Status error = consumeObject(data, module);
- if (error.Fail())
- return nullptr;
-
- return module;
-}
-
-llvm::ArrayRef<MinidumpModule>
-MinidumpModule::ParseModuleList(llvm::ArrayRef<uint8_t> &data) {
- const auto orig_size = data.size();
- const llvm::support::ulittle32_t *modules_count;
- Status error = consumeObject(data, modules_count);
- if (error.Fail() || *modules_count * sizeof(MinidumpModule) > data.size())
- return {};
-
- // Compilers might end up padding an extra 4 bytes depending on how the
- // structure is padded by the compiler and the #pragma pack settings.
- if (4 + *modules_count * sizeof(MinidumpModule) < orig_size)
- data = data.drop_front(4);
-
- return llvm::ArrayRef<MinidumpModule>(
- reinterpret_cast<const MinidumpModule *>(data.data()), *modules_count);
-}
-
// Exception stuff
const MinidumpExceptionStream *
MinidumpExceptionStream::Parse(llvm::ArrayRef<uint8_t> &data) {
@@ -187,25 +68,6 @@ MinidumpExceptionStream::Parse(llvm::ArrayRef<uint8_t> &data) {
return exception_stream;
}
-llvm::ArrayRef<MinidumpMemoryDescriptor>
-MinidumpMemoryDescriptor::ParseMemoryList(llvm::ArrayRef<uint8_t> &data) {
- const auto orig_size = data.size();
- const llvm::support::ulittle32_t *mem_ranges_count;
- Status error = consumeObject(data, mem_ranges_count);
- if (error.Fail() ||
- *mem_ranges_count * sizeof(MinidumpMemoryDescriptor) > data.size())
- return {};
-
- // Compilers might end up padding an extra 4 bytes depending on how the
- // structure is padded by the compiler and the #pragma pack settings.
- if (4 + *mem_ranges_count * sizeof(MinidumpMemoryDescriptor) < orig_size)
- data = data.drop_front(4);
-
- return llvm::makeArrayRef(
- reinterpret_cast<const MinidumpMemoryDescriptor *>(data.data()),
- *mem_ranges_count);
-}
-
std::pair<llvm::ArrayRef<MinidumpMemoryDescriptor64>, uint64_t>
MinidumpMemoryDescriptor64::ParseMemory64List(llvm::ArrayRef<uint8_t> &data) {
const llvm::support::ulittle64_t *mem_ranges_count;
diff --git a/source/Plugins/Process/minidump/MinidumpTypes.h b/source/Plugins/Process/minidump/MinidumpTypes.h
index a5ea215d2548b..b4878e82de5de 100644
--- a/source/Plugins/Process/minidump/MinidumpTypes.h
+++ b/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -1,9 +1,8 @@
//===-- MinidumpTypes.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/Minidump.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Endian.h"
@@ -32,14 +32,9 @@ namespace lldb_private {
namespace minidump {
-LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
-
-enum class MinidumpHeaderConstants : uint32_t {
- Signature = 0x504d444d, // 'PMDM'
- Version = 0x0000a793, // 42899
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ Signature)
+using namespace llvm::minidump;
-};
+LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
enum class CvSignature : uint32_t {
Pdb70 = 0x53445352, // RSDS
@@ -49,124 +44,18 @@ enum class CvSignature : uint32_t {
// Reference:
// https://crashpad.chromium.org/doxygen/structcrashpad_1_1CodeViewRecordPDB70.html
struct CvRecordPdb70 {
- uint8_t Uuid[16];
+ struct {
+ llvm::support::ulittle32_t Data1;
+ llvm::support::ulittle16_t Data2;
+ llvm::support::ulittle16_t Data3;
+ uint8_t Data4[8];
+ } Uuid;
llvm::support::ulittle32_t Age;
// char PDBFileName[];
};
static_assert(sizeof(CvRecordPdb70) == 20,
"sizeof CvRecordPdb70 is not correct!");
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680394.aspx
-enum class MinidumpStreamType : uint32_t {
- Unused = 0,
- Reserved0 = 1,
- Reserved1 = 2,
- ThreadList = 3,
- ModuleList = 4,
- MemoryList = 5,
- Exception = 6,
- SystemInfo = 7,
- ThreadExList = 8,
- Memory64List = 9,
- CommentA = 10,
- CommentW = 11,
- HandleData = 12,
- FunctionTable = 13,
- UnloadedModuleList = 14,
- MiscInfo = 15,
- MemoryInfoList = 16,
- ThreadInfoList = 17,
- HandleOperationList = 18,
- Token = 19,
- JavascriptData = 20,
- SystemMemoryInfo = 21,
- ProcessVMCounters = 22,
- LastReserved = 0x0000ffff,
-
- /* Breakpad extension types. 0x4767 = "Gg" */
- BreakpadInfo = 0x47670001,
- AssertionInfo = 0x47670002,
- /* These are additional minidump stream values which are specific to
- * the linux breakpad implementation. */
- LinuxCPUInfo = 0x47670003, /* /proc/cpuinfo */
- LinuxProcStatus = 0x47670004, /* /proc/$x/status */
- LinuxLSBRelease = 0x47670005, /* /etc/lsb-release */
- LinuxCMDLine = 0x47670006, /* /proc/$x/cmdline */
- LinuxEnviron = 0x47670007, /* /proc/$x/environ */
- LinuxAuxv = 0x47670008, /* /proc/$x/auxv */
- LinuxMaps = 0x47670009, /* /proc/$x/maps */
- LinuxDSODebug = 0x4767000A,
- LinuxProcStat = 0x4767000B, /* /proc/$x/stat */
- LinuxProcUptime = 0x4767000C, /* uptime */
- LinuxProcFD = 0x4767000D, /* /proc/$x/fb */
-};
-
-// for MinidumpSystemInfo.processor_arch
-enum class MinidumpCPUArchitecture : uint16_t {
- X86 = 0, /* PROCESSOR_ARCHITECTURE_INTEL */
- MIPS = 1, /* PROCESSOR_ARCHITECTURE_MIPS */
- Alpha = 2, /* PROCESSOR_ARCHITECTURE_ALPHA */
- PPC = 3, /* PROCESSOR_ARCHITECTURE_PPC */
- SHX = 4, /* PROCESSOR_ARCHITECTURE_SHX (Super-H) */
- ARM = 5, /* PROCESSOR_ARCHITECTURE_ARM */
- IA64 = 6, /* PROCESSOR_ARCHITECTURE_IA64 */
- Alpha64 = 7, /* PROCESSOR_ARCHITECTURE_ALPHA64 */
- MSIL = 8, /* PROCESSOR_ARCHITECTURE_MSIL
- * (Microsoft Intermediate Language) */
- AMD64 = 9, /* PROCESSOR_ARCHITECTURE_AMD64 */
- X86Win64 = 10, /* PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 (WoW64) */
- SPARC = 0x8001, /* Breakpad-defined value for SPARC */
- PPC64 = 0x8002, /* Breakpad-defined value for PPC64 */
- ARM64 = 0x8003, /* Breakpad-defined value for ARM64 */
- MIPS64 = 0x8004, /* Breakpad-defined value for MIPS64 */
- Unknown = 0xffff /* PROCESSOR_ARCHITECTURE_UNKNOWN */
-};
-
-// for MinidumpSystemInfo.platform_id
-enum class MinidumpOSPlatform : uint32_t {
- Win32S = 0, /* VER_PLATFORM_WIN32s (Windows 3.1) */
- Win32Windows = 1, /* VER_PLATFORM_WIN32_WINDOWS (Windows 95-98-Me) */
- Win32NT = 2, /* VER_PLATFORM_WIN32_NT (Windows NT, 2000+) */
- Win32CE = 3, /* VER_PLATFORM_WIN32_CE, VER_PLATFORM_WIN32_HH
- * (Windows CE, Windows Mobile, "Handheld") */
-
- /* The following values are Breakpad-defined. */
- Unix = 0x8000, /* Generic Unix-ish */
- MacOSX = 0x8101, /* Mac OS X/Darwin */
- IOS = 0x8102, /* iOS */
- Linux = 0x8201, /* Linux */
- Solaris = 0x8202, /* Solaris */
- Android = 0x8203, /* Android */
- PS3 = 0x8204, /* PS3 */
- NaCl = 0x8205 /* Native Client (NaCl) */
-};
-
-// For MinidumpCPUInfo.arm_cpu_info.elf_hwcaps.
-// This matches the Linux kernel definitions from <asm/hwcaps.h>
-enum class MinidumpPCPUInformationARMElfHwCaps : uint32_t {
- SWP = (1 << 0),
- Half = (1 << 1),
- Thumb = (1 << 2),
- _26BIT = (1 << 3),
- FastMult = (1 << 4),
- FPA = (1 << 5),
- VFP = (1 << 6),
- EDSP = (1 << 7),
- Java = (1 << 8),
- IWMMXT = (1 << 9),
- Crunch = (1 << 10),
- ThumbEE = (1 << 11),
- Neon = (1 << 12),
- VFPv3 = (1 << 13),
- VFPv3D16 = (1 << 14),
- TLS = (1 << 15),
- VFPv4 = (1 << 16),
- IDIVA = (1 << 17),
- IDIVT = (1 << 18),
- LLVM_MARK_AS_BITMASK_ENUM(/* LargestValue = */ IDIVT)
-};
-
enum class MinidumpMiscInfoFlags : uint32_t {
ProcessID = (1 << 0),
ProcessTimes = (1 << 1),
@@ -186,50 +75,6 @@ Status consumeObject(llvm::ArrayRef<uint8_t> &Buffer, const T *&Object) {
return error;
}
-// parse a MinidumpString which is with UTF-16
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680395(v=vs.85).aspx
-llvm::Optional<std::string> parseMinidumpString(llvm::ArrayRef<uint8_t> &data);
-
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680378(v=vs.85).aspx
-struct MinidumpHeader {
- llvm::support::ulittle32_t signature;
- llvm::support::ulittle32_t
- version; // The high 16 bits of version field are implementation specific
- llvm::support::ulittle32_t streams_count;
- llvm::support::ulittle32_t
- stream_directory_rva; // offset of the stream directory
- llvm::support::ulittle32_t checksum;
- llvm::support::ulittle32_t time_date_stamp; // time_t format
- llvm::support::ulittle64_t flags;
-
- static const MinidumpHeader *Parse(llvm::ArrayRef<uint8_t> &data);
-};
-static_assert(sizeof(MinidumpHeader) == 32,
- "sizeof MinidumpHeader is not correct!");
-
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680383.aspx
-struct MinidumpLocationDescriptor {
- llvm::support::ulittle32_t data_size;
- llvm::support::ulittle32_t rva;
-};
-static_assert(sizeof(MinidumpLocationDescriptor) == 8,
- "sizeof MinidumpLocationDescriptor is not correct!");
-
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680384(v=vs.85).aspx
-struct MinidumpMemoryDescriptor {
- llvm::support::ulittle64_t start_of_memory_range;
- MinidumpLocationDescriptor memory;
-
- static llvm::ArrayRef<MinidumpMemoryDescriptor>
- ParseMemoryList(llvm::ArrayRef<uint8_t> &data);
-};
-static_assert(sizeof(MinidumpMemoryDescriptor) == 16,
- "sizeof MinidumpMemoryDescriptor is not correct!");
-
struct MinidumpMemoryDescriptor64 {
llvm::support::ulittle64_t start_of_memory_range;
llvm::support::ulittle64_t data_size;
@@ -241,15 +86,6 @@ static_assert(sizeof(MinidumpMemoryDescriptor64) == 16,
"sizeof MinidumpMemoryDescriptor64 is not correct!");
// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680365.aspx
-struct MinidumpDirectory {
- llvm::support::ulittle32_t stream_type;
- MinidumpLocationDescriptor location;
-};
-static_assert(sizeof(MinidumpDirectory) == 12,
- "sizeof MinidumpDirectory is not correct!");
-
-// Reference:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680385(v=vs.85).aspx
struct MinidumpMemoryInfoListHeader {
llvm::support::ulittle32_t size_of_header;
@@ -333,72 +169,6 @@ struct MinidumpMemoryInfo {
static_assert(sizeof(MinidumpMemoryInfo) == 48,
"sizeof MinidumpMemoryInfo is not correct!");
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680517(v=vs.85).aspx
-struct MinidumpThread {
- llvm::support::ulittle32_t thread_id;
- llvm::support::ulittle32_t suspend_count;
- llvm::support::ulittle32_t priority_class;
- llvm::support::ulittle32_t priority;
- llvm::support::ulittle64_t teb;
- MinidumpMemoryDescriptor stack;
- MinidumpLocationDescriptor thread_context;
-
- static const MinidumpThread *Parse(llvm::ArrayRef<uint8_t> &data);
-
- static llvm::ArrayRef<MinidumpThread>
- ParseThreadList(llvm::ArrayRef<uint8_t> &data);
-};
-static_assert(sizeof(MinidumpThread) == 48,
- "sizeof MinidumpThread is not correct!");
-
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680396(v=vs.85).aspx
-union MinidumpCPUInfo {
- struct {
- llvm::support::ulittle32_t vendor_id[3]; /* cpuid 0: ebx, edx, ecx */
- llvm::support::ulittle32_t version_information; /* cpuid 1: eax */
- llvm::support::ulittle32_t feature_information; /* cpuid 1: edx */
- llvm::support::ulittle32_t
- amd_extended_cpu_features; /* cpuid 0x80000001, ebx */
- } x86_cpu_info;
- struct {
- llvm::support::ulittle32_t cpuid;
- llvm::support::ulittle32_t elf_hwcaps; /* linux specific, 0 otherwise */
- } arm_cpu_info;
- struct {
- llvm::support::ulittle64_t processor_features[2];
- } other_cpu_info;
-};
-static_assert(sizeof(MinidumpCPUInfo) == 24,
- "sizeof MinidumpCPUInfo is not correct!");
-
-// Reference:
-// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680396(v=vs.85).aspx
-struct MinidumpSystemInfo {
- llvm::support::ulittle16_t processor_arch;
- llvm::support::ulittle16_t processor_level;
- llvm::support::ulittle16_t processor_revision;
-
- uint8_t number_of_processors;
- uint8_t product_type;
-
- llvm::support::ulittle32_t major_version;
- llvm::support::ulittle32_t minor_version;
- llvm::support::ulittle32_t build_number;
- llvm::support::ulittle32_t platform_id;
- llvm::support::ulittle32_t csd_version_rva;
-
- llvm::support::ulittle16_t suit_mask;
- llvm::support::ulittle16_t reserved2;
-
- MinidumpCPUInfo cpu;
-
- static const MinidumpSystemInfo *Parse(llvm::ArrayRef<uint8_t> &data);
-};
-static_assert(sizeof(MinidumpSystemInfo) == 56,
- "sizeof MinidumpSystemInfo is not correct!");
-
// TODO misc2, misc3 ?
// Reference:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms680389(v=vs.85).aspx
@@ -432,46 +202,6 @@ private:
LinuxProcStatus() = default;
};
-// MinidumpModule stuff
-struct MinidumpVSFixedFileInfo {
- llvm::support::ulittle32_t signature;
- llvm::support::ulittle32_t struct_version;
- llvm::support::ulittle32_t file_version_hi;
- llvm::support::ulittle32_t file_version_lo;
- llvm::support::ulittle32_t product_version_hi;
- llvm::support::ulittle32_t product_version_lo;
- // file_flags_mask - identifies valid bits in fileFlags
- llvm::support::ulittle32_t file_flags_mask;
- llvm::support::ulittle32_t file_flags;
- llvm::support::ulittle32_t file_os;
- llvm::support::ulittle32_t file_type;
- llvm::support::ulittle32_t file_subtype;
- llvm::support::ulittle32_t file_date_hi;
- llvm::support::ulittle32_t file_date_lo;
-};
-static_assert(sizeof(MinidumpVSFixedFileInfo) == 52,
- "sizeof MinidumpVSFixedFileInfo is not correct!");
-
-struct MinidumpModule {
- llvm::support::ulittle64_t base_of_image;
- llvm::support::ulittle32_t size_of_image;
- llvm::support::ulittle32_t checksum;
- llvm::support::ulittle32_t time_date_stamp;
- llvm::support::ulittle32_t module_name_rva;
- MinidumpVSFixedFileInfo version_info;
- MinidumpLocationDescriptor CV_record;
- MinidumpLocationDescriptor misc_record;
- llvm::support::ulittle32_t reserved0[2];
- llvm::support::ulittle32_t reserved1[2];
-
- static const MinidumpModule *Parse(llvm::ArrayRef<uint8_t> &data);
-
- static llvm::ArrayRef<MinidumpModule>
- ParseModuleList(llvm::ArrayRef<uint8_t> &data);
-};
-static_assert(sizeof(MinidumpModule) == 108,
- "sizeof MinidumpVSFixedFileInfo is not correct!");
-
// Exception stuff
struct MinidumpException {
enum : unsigned {
@@ -494,7 +224,7 @@ struct MinidumpExceptionStream {
llvm::support::ulittle32_t thread_id;
llvm::support::ulittle32_t alignment;
MinidumpException exception_record;
- MinidumpLocationDescriptor thread_context;
+ LocationDescriptor thread_context;
static const MinidumpExceptionStream *Parse(llvm::ArrayRef<uint8_t> &data);
};
diff --git a/source/Plugins/Process/minidump/NtStructures.h b/source/Plugins/Process/minidump/NtStructures.h
index c0afd77358cd6..fdb0cfb7981ef 100644
--- a/source/Plugins/Process/minidump/NtStructures.h
+++ b/source/Plugins/Process/minidump/NtStructures.h
@@ -1,9 +1,8 @@
//===-- NtStructures.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/ProcessMinidump.cpp b/source/Plugins/Process/minidump/ProcessMinidump.cpp
index c5cca7ea62c69..a7fc42cad16c9 100644
--- a/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ b/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -1,13 +1,13 @@
//===-- ProcessMinidump.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ProcessMinidump.h"
+
#include "ThreadMinidump.h"
#include "lldb/Core/DumpDataExtractor.h"
@@ -29,64 +29,93 @@
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
-
+#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Threading.h"
#include "Plugins/Process/Utility/StopInfoMachException.h"
-// C includes
-// C++ includes
+#include <memory>
using namespace lldb;
using namespace lldb_private;
using namespace minidump;
-//------------------------------------------------------------------
-/// A placeholder module used for minidumps, where the original
-/// object files may not be available (so we can't parse the object
-/// files to extract the set of sections/segments)
-///
-/// This placeholder module has a single synthetic section (.module_image)
-/// which represents the module memory range covering the whole module.
-//------------------------------------------------------------------
-class PlaceholderModule : public Module {
+namespace {
+
+/// A minimal ObjectFile implementation providing a dummy object file for the
+/// cases when the real module binary is not available. This allows the module
+/// to show up in "image list" and symbols to be added to it.
+class PlaceholderObjectFile : public ObjectFile {
public:
- PlaceholderModule(const ModuleSpec &module_spec) :
- Module(module_spec.GetFileSpec(), module_spec.GetArchitecture()) {
- if (module_spec.GetUUID().IsValid())
- SetUUID(module_spec.GetUUID());
- }
-
- // Creates a synthetic module section covering the whole module image (and
- // sets the section load address as well)
- void CreateImageSection(const MinidumpModule *module, Target& target) {
- const ConstString section_name(".module_image");
- lldb::SectionSP section_sp(new Section(
- shared_from_this(), // Module to which this section belongs.
- nullptr, // ObjectFile
- 0, // Section ID.
- section_name, // Section name.
- eSectionTypeContainer, // Section type.
- module->base_of_image, // VM address.
- module->size_of_image, // VM size in bytes of this section.
- 0, // Offset of this section in the file.
- module->size_of_image, // Size of the section as found in the file.
- 12, // Alignment of the section (log2)
- 0, // Flags for this section.
- 1)); // Number of host bytes per target byte
- section_sp->SetPermissions(ePermissionsExecutable | ePermissionsReadable);
- GetSectionList()->AddSection(section_sp);
- target.GetSectionLoadList().SetSectionLoadAddress(
- section_sp, module->base_of_image);
+ PlaceholderObjectFile(const lldb::ModuleSP &module_sp,
+ const ModuleSpec &module_spec, lldb::offset_t base,
+ lldb::offset_t size)
+ : ObjectFile(module_sp, &module_spec.GetFileSpec(), /*file_offset*/ 0,
+ /*length*/ 0, /*data_sp*/ nullptr, /*data_offset*/ 0),
+ m_arch(module_spec.GetArchitecture()), m_uuid(module_spec.GetUUID()),
+ m_base(base), m_size(size) {
+ m_symtab_up = llvm::make_unique<Symtab>(this);
}
-ObjectFile *GetObjectFile() override { return nullptr; }
+ ConstString GetPluginName() override { return ConstString("placeholder"); }
+ uint32_t GetPluginVersion() override { return 1; }
+ bool ParseHeader() override { return true; }
+ Type CalculateType() override { return eTypeUnknown; }
+ Strata CalculateStrata() override { return eStrataUnknown; }
+ uint32_t GetDependentModules(FileSpecList &file_list) override { return 0; }
+ bool IsExecutable() const override { return false; }
+ ArchSpec GetArchitecture() override { return m_arch; }
+ UUID GetUUID() override { return m_uuid; }
+ Symtab *GetSymtab() override { return m_symtab_up.get(); }
+ bool IsStripped() override { return true; }
+ ByteOrder GetByteOrder() const override { return m_arch.GetByteOrder(); }
+
+ uint32_t GetAddressByteSize() const override {
+ return m_arch.GetAddressByteSize();
+ }
- SectionList *GetSectionList() override {
- return Module::GetUnifiedSectionList();
+ Address GetBaseAddress() override {
+ return Address(m_sections_up->GetSectionAtIndex(0), 0);
}
+
+ void CreateSections(SectionList &unified_section_list) override {
+ m_sections_up = llvm::make_unique<SectionList>();
+ auto section_sp = std::make_shared<Section>(
+ GetModule(), this, /*sect_id*/ 0, ConstString(".module_image"),
+ eSectionTypeOther, m_base, m_size, /*file_offset*/ 0, /*file_size*/ 0,
+ /*log2align*/ 0, /*flags*/ 0);
+ section_sp->SetPermissions(ePermissionsReadable | ePermissionsExecutable);
+ m_sections_up->AddSection(section_sp);
+ unified_section_list.AddSection(std::move(section_sp));
+ }
+
+ bool SetLoadAddress(Target &target, addr_t value,
+ bool value_is_offset) override {
+ assert(!value_is_offset);
+ assert(value == m_base);
+
+ // Create sections if they haven't been created already.
+ GetModule()->GetSectionList();
+ assert(m_sections_up->GetNumSections(0) == 1);
+
+ target.GetSectionLoadList().SetSectionLoadAddress(
+ m_sections_up->GetSectionAtIndex(0), m_base);
+ return true;
+ }
+
+ void Dump(Stream *s) override {
+ s->Format("Placeholder object file for {0} loaded at [{1:x}-{2:x})\n",
+ GetFileSpec(), m_base, m_base + m_size);
+ }
+
+private:
+ ArchSpec m_arch;
+ UUID m_uuid;
+ lldb::offset_t m_base;
+ lldb::offset_t m_size;
};
+} // namespace
ConstString ProcessMinidump::GetPluginNameStatic() {
static ConstString g_name("minidump");
@@ -105,18 +134,14 @@ lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp,
lldb::ProcessSP process_sp;
// Read enough data for the Minidump header
- constexpr size_t header_size = sizeof(MinidumpHeader);
+ constexpr size_t header_size = sizeof(Header);
auto DataPtr = FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(),
header_size, 0);
if (!DataPtr)
return nullptr;
lldbassert(DataPtr->GetByteSize() == header_size);
-
- // first, only try to parse the header, beacuse we need to be fast
- llvm::ArrayRef<uint8_t> HeaderBytes = DataPtr->GetData();
- const MinidumpHeader *header = MinidumpHeader::Parse(HeaderBytes);
- if (header == nullptr)
+ if (identify_magic(toStringRef(DataPtr->GetData())) != llvm::file_magic::minidump)
return nullptr;
auto AllData =
@@ -124,13 +149,8 @@ lldb::ProcessSP ProcessMinidump::CreateInstance(lldb::TargetSP target_sp,
if (!AllData)
return nullptr;
- auto minidump_parser = MinidumpParser::Create(AllData);
- // check if the parser object is valid
- if (!minidump_parser)
- return nullptr;
-
return std::make_shared<ProcessMinidump>(target_sp, listener_sp, *crash_file,
- minidump_parser.getValue());
+ std::move(AllData));
}
bool ProcessMinidump::CanDebug(lldb::TargetSP target_sp,
@@ -141,9 +161,9 @@ bool ProcessMinidump::CanDebug(lldb::TargetSP target_sp,
ProcessMinidump::ProcessMinidump(lldb::TargetSP target_sp,
lldb::ListenerSP listener_sp,
const FileSpec &core_file,
- MinidumpParser minidump_parser)
- : Process(target_sp, listener_sp), m_minidump_parser(minidump_parser),
- m_core_file(core_file), m_is_wow64(false) {}
+ DataBufferSP core_data)
+ : Process(target_sp, listener_sp), m_core_file(core_file),
+ m_core_data(std::move(core_data)), m_is_wow64(false) {}
ProcessMinidump::~ProcessMinidump() {
Clear();
@@ -169,12 +189,12 @@ void ProcessMinidump::Terminate() {
}
Status ProcessMinidump::DoLoadCore() {
- Status error;
+ auto expected_parser = MinidumpParser::Create(m_core_data);
+ if (!expected_parser)
+ return Status(expected_parser.takeError());
+ m_minidump_parser = std::move(*expected_parser);
- // Minidump parser initialization & consistency checks
- error = m_minidump_parser.Initialize();
- if (error.Fail())
- return error;
+ Status error;
// Do we support the minidump's architecture?
ArchSpec arch = GetArchitecture();
@@ -193,11 +213,11 @@ Status ProcessMinidump::DoLoadCore() {
}
GetTarget().SetArchitecture(arch, true /*set_platform*/);
- m_thread_list = m_minidump_parser.GetThreads();
- m_active_exception = m_minidump_parser.GetExceptionStream();
+ m_thread_list = m_minidump_parser->GetThreads();
+ m_active_exception = m_minidump_parser->GetExceptionStream();
ReadModuleList();
- llvm::Optional<lldb::pid_t> pid = m_minidump_parser.GetPid();
+ llvm::Optional<lldb::pid_t> pid = m_minidump_parser->GetPid();
if (!pid) {
error.SetErrorString("failed to parse PID");
return error;
@@ -268,7 +288,7 @@ size_t ProcessMinidump::ReadMemory(lldb::addr_t addr, void *buf, size_t size,
size_t ProcessMinidump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
Status &error) {
- llvm::ArrayRef<uint8_t> mem = m_minidump_parser.GetMemory(addr, size);
+ llvm::ArrayRef<uint8_t> mem = m_minidump_parser->GetMemory(addr, size);
if (mem.empty()) {
error.SetErrorString("could not parse memory info");
return 0;
@@ -280,7 +300,7 @@ size_t ProcessMinidump::DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
ArchSpec ProcessMinidump::GetArchitecture() {
if (!m_is_wow64) {
- return m_minidump_parser.GetArchitecture();
+ return m_minidump_parser->GetArchitecture();
}
llvm::Triple triple;
@@ -292,13 +312,13 @@ ArchSpec ProcessMinidump::GetArchitecture() {
Status ProcessMinidump::GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) {
- range_info = m_minidump_parser.GetMemoryRegionInfo(load_addr);
+ range_info = m_minidump_parser->GetMemoryRegionInfo(load_addr);
return Status();
}
Status ProcessMinidump::GetMemoryRegions(
lldb_private::MemoryRegionInfos &region_list) {
- region_list = m_minidump_parser.GetMemoryRegions();
+ region_list = m_minidump_parser->GetMemoryRegions();
return Status();
}
@@ -306,20 +326,20 @@ void ProcessMinidump::Clear() { Process::m_thread_list.Clear(); }
bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
ThreadList &new_thread_list) {
- for (const MinidumpThread& thread : m_thread_list) {
- MinidumpLocationDescriptor context_location = thread.thread_context;
+ for (const minidump::Thread &thread : m_thread_list) {
+ LocationDescriptor context_location = thread.Context;
// If the minidump contains an exception context, use it
if (m_active_exception != nullptr &&
- m_active_exception->thread_id == thread.thread_id) {
+ m_active_exception->thread_id == thread.ThreadId) {
context_location = m_active_exception->thread_context;
}
llvm::ArrayRef<uint8_t> context;
if (!m_is_wow64)
- context = m_minidump_parser.GetThreadContext(context_location);
+ context = m_minidump_parser->GetThreadContext(context_location);
else
- context = m_minidump_parser.GetThreadContextWow64(thread);
+ context = m_minidump_parser->GetThreadContextWow64(thread);
lldb::ThreadSP thread_sp(new ThreadMinidump(*this, thread, context));
new_thread_list.AddThread(thread_sp);
@@ -328,39 +348,60 @@ bool ProcessMinidump::UpdateThreadList(ThreadList &old_thread_list,
}
void ProcessMinidump::ReadModuleList() {
- std::vector<const MinidumpModule *> filtered_modules =
- m_minidump_parser.GetFilteredModuleList();
+ std::vector<const minidump::Module *> filtered_modules =
+ m_minidump_parser->GetFilteredModuleList();
+
+ Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES));
for (auto module : filtered_modules) {
- llvm::Optional<std::string> name =
- m_minidump_parser.GetMinidumpString(module->module_name_rva);
-
- if (!name)
- continue;
-
- Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES));
- if (log) {
- log->Printf("ProcessMinidump::%s found module: name: %s %#010" PRIx64
- "-%#010" PRIx64 " size: %" PRIu32,
- __FUNCTION__, name.getValue().c_str(),
- uint64_t(module->base_of_image),
- module->base_of_image + module->size_of_image,
- uint32_t(module->size_of_image));
- }
+ std::string name = cantFail(m_minidump_parser->GetMinidumpFile().getString(
+ module->ModuleNameRVA));
+ LLDB_LOG(log, "found module: name: {0} {1:x10}-{2:x10} size: {3}", name,
+ module->BaseOfImage, module->BaseOfImage + module->SizeOfImage,
+ module->SizeOfImage);
// check if the process is wow64 - a 32 bit windows process running on a
// 64 bit windows
- if (llvm::StringRef(name.getValue()).endswith_lower("wow64.dll")) {
+ if (llvm::StringRef(name).endswith_lower("wow64.dll")) {
m_is_wow64 = true;
}
- const auto uuid = m_minidump_parser.GetModuleUUID(module);
- auto file_spec = FileSpec(name.getValue(), GetArchitecture().GetTriple());
- FileSystem::Instance().Resolve(file_spec);
+ const auto uuid = m_minidump_parser->GetModuleUUID(module);
+ auto file_spec = FileSpec(name, GetArchitecture().GetTriple());
ModuleSpec module_spec(file_spec, uuid);
+ module_spec.GetArchitecture() = GetArchitecture();
Status error;
- lldb::ModuleSP module_sp = GetTarget().GetSharedModule(module_spec, &error);
- if (!module_sp || error.Fail()) {
+ // Try and find a module with a full UUID that matches. This function will
+ // add the module to the target if it finds one.
+ lldb::ModuleSP module_sp = GetTarget().GetOrCreateModule(module_spec,
+ true /* notify */, &error);
+ if (!module_sp) {
+ // Try and find a module without specifying the UUID and only looking for
+ // the file given a basename. We then will look for a partial UUID match
+ // if we find any matches. This function will add the module to the
+ // target if it finds one, so we need to remove the module from the target
+ // if the UUID doesn't match during our manual UUID verification. This
+ // allows the "target.exec-search-paths" setting to specify one or more
+ // directories that contain executables that can be searched for matches.
+ ModuleSpec basename_module_spec(module_spec);
+ basename_module_spec.GetUUID().Clear();
+ basename_module_spec.GetFileSpec().GetDirectory().Clear();
+ module_sp = GetTarget().GetOrCreateModule(basename_module_spec,
+ true /* notify */, &error);
+ if (module_sp) {
+ // We consider the module to be a match if the minidump UUID is a
+ // prefix of the actual UUID, or if either of the UUIDs are empty.
+ const auto dmp_bytes = uuid.GetBytes();
+ const auto mod_bytes = module_sp->GetUUID().GetBytes();
+ const bool match = dmp_bytes.empty() || mod_bytes.empty() ||
+ mod_bytes.take_front(dmp_bytes.size()) == dmp_bytes;
+ if (!match) {
+ GetTarget().GetImages().Remove(module_sp);
+ module_sp.reset();
+ }
+ }
+ }
+ if (!module_sp) {
// We failed to locate a matching local object file. Fortunately, the
// minidump format encodes enough information about each module's memory
// range to allow us to create placeholder modules.
@@ -368,26 +409,18 @@ void ProcessMinidump::ReadModuleList() {
// This enables most LLDB functionality involving address-to-module
// translations (ex. identifing the module for a stack frame PC) and
// modules/sections commands (ex. target modules list, ...)
- if (log) {
- log->Printf("Unable to locate the matching object file, creating a "
- "placeholder module for: %s",
- name.getValue().c_str());
- }
-
- auto placeholder_module =
- std::make_shared<PlaceholderModule>(module_spec);
- placeholder_module->CreateImageSection(module, GetTarget());
- module_sp = placeholder_module;
- GetTarget().GetImages().Append(module_sp);
- }
-
- if (log) {
- log->Printf("ProcessMinidump::%s load module: name: %s", __FUNCTION__,
- name.getValue().c_str());
+ LLDB_LOG(log,
+ "Unable to locate the matching object file, creating a "
+ "placeholder module for: {0}",
+ name);
+
+ module_sp = Module::CreateModuleFromObjectFile<PlaceholderObjectFile>(
+ module_spec, module->BaseOfImage, module->SizeOfImage);
+ GetTarget().GetImages().Append(module_sp, true /* notify */);
}
bool load_addr_changed = false;
- module_sp->SetLoadAddress(GetTarget(), module->base_of_image, false,
+ module_sp->SetLoadAddress(GetTarget(), module->BaseOfImage, false,
load_addr_changed);
}
}
@@ -410,10 +443,10 @@ bool ProcessMinidump::GetProcessInfo(ProcessInstanceInfo &info) {
// try to set up symbolic breakpoints, which in turn may force loading more
// debug information than needed.
JITLoaderList &ProcessMinidump::GetJITLoaders() {
- if (!m_jit_loaders_ap) {
- m_jit_loaders_ap = llvm::make_unique<JITLoaderList>();
+ if (!m_jit_loaders_up) {
+ m_jit_loaders_up = llvm::make_unique<JITLoaderList>();
}
- return *m_jit_loaders_ap;
+ return *m_jit_loaders_up;
}
#define INIT_BOOL(VAR, LONG, SHORT, DESC) \
@@ -437,10 +470,23 @@ private:
OptionGroupBoolean m_dump_linux_proc_uptime;
OptionGroupBoolean m_dump_linux_proc_fd;
OptionGroupBoolean m_dump_linux_all;
+ OptionGroupBoolean m_fb_app_data;
+ OptionGroupBoolean m_fb_build_id;
+ OptionGroupBoolean m_fb_version;
+ OptionGroupBoolean m_fb_java_stack;
+ OptionGroupBoolean m_fb_dalvik;
+ OptionGroupBoolean m_fb_unwind;
+ OptionGroupBoolean m_fb_error_log;
+ OptionGroupBoolean m_fb_app_state;
+ OptionGroupBoolean m_fb_abort;
+ OptionGroupBoolean m_fb_thread;
+ OptionGroupBoolean m_fb_logcat;
+ OptionGroupBoolean m_fb_all;
void SetDefaultOptionsIfNoneAreSet() {
if (m_dump_all.GetOptionValue().GetCurrentValue() ||
m_dump_linux_all.GetOptionValue().GetCurrentValue() ||
+ m_fb_all.GetOptionValue().GetCurrentValue() ||
m_dump_directory.GetOptionValue().GetCurrentValue() ||
m_dump_linux_cpuinfo.GetOptionValue().GetCurrentValue() ||
m_dump_linux_proc_status.GetOptionValue().GetCurrentValue() ||
@@ -451,7 +497,18 @@ private:
m_dump_linux_maps.GetOptionValue().GetCurrentValue() ||
m_dump_linux_proc_stat.GetOptionValue().GetCurrentValue() ||
m_dump_linux_proc_uptime.GetOptionValue().GetCurrentValue() ||
- m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue())
+ m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue() ||
+ m_fb_app_data.GetOptionValue().GetCurrentValue() ||
+ m_fb_build_id.GetOptionValue().GetCurrentValue() ||
+ m_fb_version.GetOptionValue().GetCurrentValue() ||
+ m_fb_java_stack.GetOptionValue().GetCurrentValue() ||
+ m_fb_dalvik.GetOptionValue().GetCurrentValue() ||
+ m_fb_unwind.GetOptionValue().GetCurrentValue() ||
+ m_fb_error_log.GetOptionValue().GetCurrentValue() ||
+ m_fb_app_state.GetOptionValue().GetCurrentValue() ||
+ m_fb_abort.GetOptionValue().GetCurrentValue() ||
+ m_fb_thread.GetOptionValue().GetCurrentValue() ||
+ m_fb_logcat.GetOptionValue().GetCurrentValue())
return;
// If no options were set, then dump everything
m_dump_all.GetOptionValue().SetCurrentValue(true);
@@ -506,11 +563,46 @@ private:
return DumpLinux() ||
m_dump_linux_proc_fd.GetOptionValue().GetCurrentValue();
}
+ bool DumpFacebook() const {
+ return DumpAll() || m_fb_all.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookAppData() const {
+ return DumpFacebook() || m_fb_app_data.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookBuildID() const {
+ return DumpFacebook() || m_fb_build_id.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookVersionName() const {
+ return DumpFacebook() || m_fb_version.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookJavaStack() const {
+ return DumpFacebook() || m_fb_java_stack.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookDalvikInfo() const {
+ return DumpFacebook() || m_fb_dalvik.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookUnwindSymbols() const {
+ return DumpFacebook() || m_fb_unwind.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookErrorLog() const {
+ return DumpFacebook() || m_fb_error_log.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookAppStateLog() const {
+ return DumpFacebook() || m_fb_app_state.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookAbortReason() const {
+ return DumpFacebook() || m_fb_abort.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookThreadName() const {
+ return DumpFacebook() || m_fb_thread.GetOptionValue().GetCurrentValue();
+ }
+ bool DumpFacebookLogcat() const {
+ return DumpFacebook() || m_fb_logcat.GetOptionValue().GetCurrentValue();
+ }
public:
-
CommandObjectProcessMinidumpDump(CommandInterpreter &interpreter)
: CommandObjectParsed(interpreter, "process plugin dump",
- "Dump information from the minidump file.", NULL),
+ "Dump information from the minidump file.", nullptr),
m_option_group(),
INIT_BOOL(m_dump_all, "all", 'a',
"Dump the everything in the minidump."),
@@ -537,7 +629,30 @@ public:
INIT_BOOL(m_dump_linux_proc_fd, "fd", 'f',
"Dump linux /proc/<pid>/fd."),
INIT_BOOL(m_dump_linux_all, "linux", 'l',
- "Dump all linux streams.") {
+ "Dump all linux streams."),
+ INIT_BOOL(m_fb_app_data, "fb-app-data", 1,
+ "Dump Facebook application custom data."),
+ INIT_BOOL(m_fb_build_id, "fb-build-id", 2,
+ "Dump the Facebook build ID."),
+ INIT_BOOL(m_fb_version, "fb-version", 3,
+ "Dump Facebook application version string."),
+ INIT_BOOL(m_fb_java_stack, "fb-java-stack", 4,
+ "Dump Facebook java stack."),
+ INIT_BOOL(m_fb_dalvik, "fb-dalvik-info", 5,
+ "Dump Facebook Dalvik info."),
+ INIT_BOOL(m_fb_unwind, "fb-unwind-symbols", 6,
+ "Dump Facebook unwind symbols."),
+ INIT_BOOL(m_fb_error_log, "fb-error-log", 7,
+ "Dump Facebook error log."),
+ INIT_BOOL(m_fb_app_state, "fb-app-state-log", 8,
+ "Dump Facebook java stack."),
+ INIT_BOOL(m_fb_abort, "fb-abort-reason", 9,
+ "Dump Facebook abort reason."),
+ INIT_BOOL(m_fb_thread, "fb-thread-name", 10,
+ "Dump Facebook thread name."),
+ INIT_BOOL(m_fb_logcat, "fb-logcat", 11,
+ "Dump Facebook logcat."),
+ INIT_BOOL(m_fb_all, "facebook", 12, "Dump all Facebook streams.") {
APPEND_OPT(m_dump_all);
APPEND_OPT(m_dump_directory);
APPEND_OPT(m_dump_linux_cpuinfo);
@@ -551,10 +666,22 @@ public:
APPEND_OPT(m_dump_linux_proc_uptime);
APPEND_OPT(m_dump_linux_proc_fd);
APPEND_OPT(m_dump_linux_all);
+ APPEND_OPT(m_fb_app_data);
+ APPEND_OPT(m_fb_build_id);
+ APPEND_OPT(m_fb_version);
+ APPEND_OPT(m_fb_java_stack);
+ APPEND_OPT(m_fb_dalvik);
+ APPEND_OPT(m_fb_unwind);
+ APPEND_OPT(m_fb_error_log);
+ APPEND_OPT(m_fb_app_state);
+ APPEND_OPT(m_fb_abort);
+ APPEND_OPT(m_fb_thread);
+ APPEND_OPT(m_fb_logcat);
+ APPEND_OPT(m_fb_all);
m_option_group.Finalize();
}
- ~CommandObjectProcessMinidumpDump() {}
+ ~CommandObjectProcessMinidumpDump() override {}
Options *GetOptions() override { return &m_option_group; }
@@ -572,31 +699,33 @@ public:
m_interpreter.GetExecutionContext().GetProcessPtr());
result.SetStatus(eReturnStatusSuccessFinishResult);
Stream &s = result.GetOutputStream();
- MinidumpParser &minidump = process->m_minidump_parser;
+ MinidumpParser &minidump = *process->m_minidump_parser;
if (DumpDirectory()) {
- s.Printf("RVA SIZE TYPE MinidumpStreamType\n");
+ s.Printf("RVA SIZE TYPE StreamType\n");
s.Printf("---------- ---------- ---------- --------------------------\n");
- for (const auto &pair: minidump.GetDirectoryMap())
- s.Printf("0x%8.8x 0x%8.8x 0x%8.8x %s\n", (uint32_t)pair.second.rva,
- (uint32_t)pair.second.data_size, pair.first,
- MinidumpParser::GetStreamTypeAsString(pair.first).data());
+ for (const auto &stream_desc : minidump.GetMinidumpFile().streams())
+ s.Printf(
+ "0x%8.8x 0x%8.8x 0x%8.8x %s\n", (uint32_t)stream_desc.Location.RVA,
+ (uint32_t)stream_desc.Location.DataSize,
+ (unsigned)(StreamType)stream_desc.Type,
+ MinidumpParser::GetStreamTypeAsString(stream_desc.Type).data());
s.Printf("\n");
}
- auto DumpTextStream = [&](MinidumpStreamType stream_type,
+ auto DumpTextStream = [&](StreamType stream_type,
llvm::StringRef label) -> void {
auto bytes = minidump.GetStream(stream_type);
if (!bytes.empty()) {
if (label.empty())
- label = MinidumpParser::GetStreamTypeAsString((uint32_t)stream_type);
+ label = MinidumpParser::GetStreamTypeAsString(stream_type);
s.Printf("%s:\n%s\n\n", label.data(), bytes.data());
}
};
- auto DumpBinaryStream = [&](MinidumpStreamType stream_type,
+ auto DumpBinaryStream = [&](StreamType stream_type,
llvm::StringRef label) -> void {
auto bytes = minidump.GetStream(stream_type);
if (!bytes.empty()) {
if (label.empty())
- label = MinidumpParser::GetStreamTypeAsString((uint32_t)stream_type);
+ label = MinidumpParser::GetStreamTypeAsString(stream_type);
s.Printf("%s:\n", label.data());
DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
process->GetAddressByteSize());
@@ -607,25 +736,67 @@ public:
};
if (DumpLinuxCPUInfo())
- DumpTextStream(MinidumpStreamType::LinuxCPUInfo, "/proc/cpuinfo");
+ DumpTextStream(StreamType::LinuxCPUInfo, "/proc/cpuinfo");
if (DumpLinuxProcStatus())
- DumpTextStream(MinidumpStreamType::LinuxProcStatus, "/proc/PID/status");
+ DumpTextStream(StreamType::LinuxProcStatus, "/proc/PID/status");
if (DumpLinuxLSBRelease())
- DumpTextStream(MinidumpStreamType::LinuxLSBRelease, "/etc/lsb-release");
+ DumpTextStream(StreamType::LinuxLSBRelease, "/etc/lsb-release");
if (DumpLinuxCMDLine())
- DumpTextStream(MinidumpStreamType::LinuxCMDLine, "/proc/PID/cmdline");
+ DumpTextStream(StreamType::LinuxCMDLine, "/proc/PID/cmdline");
if (DumpLinuxEnviron())
- DumpTextStream(MinidumpStreamType::LinuxEnviron, "/proc/PID/environ");
+ DumpTextStream(StreamType::LinuxEnviron, "/proc/PID/environ");
if (DumpLinuxAuxv())
- DumpBinaryStream(MinidumpStreamType::LinuxAuxv, "/proc/PID/auxv");
+ DumpBinaryStream(StreamType::LinuxAuxv, "/proc/PID/auxv");
if (DumpLinuxMaps())
- DumpTextStream(MinidumpStreamType::LinuxMaps, "/proc/PID/maps");
+ DumpTextStream(StreamType::LinuxMaps, "/proc/PID/maps");
if (DumpLinuxProcStat())
- DumpTextStream(MinidumpStreamType::LinuxProcStat, "/proc/PID/stat");
+ DumpTextStream(StreamType::LinuxProcStat, "/proc/PID/stat");
if (DumpLinuxProcUptime())
- DumpTextStream(MinidumpStreamType::LinuxProcUptime, "uptime");
+ DumpTextStream(StreamType::LinuxProcUptime, "uptime");
if (DumpLinuxProcFD())
- DumpTextStream(MinidumpStreamType::LinuxProcFD, "/proc/PID/fd");
+ DumpTextStream(StreamType::LinuxProcFD, "/proc/PID/fd");
+ if (DumpFacebookAppData())
+ DumpTextStream(StreamType::FacebookAppCustomData,
+ "Facebook App Data");
+ if (DumpFacebookBuildID()) {
+ auto bytes = minidump.GetStream(StreamType::FacebookBuildID);
+ if (bytes.size() >= 4) {
+ DataExtractor data(bytes.data(), bytes.size(), eByteOrderLittle,
+ process->GetAddressByteSize());
+ lldb::offset_t offset = 0;
+ uint32_t build_id = data.GetU32(&offset);
+ s.Printf("Facebook Build ID:\n");
+ s.Printf("%u\n", build_id);
+ s.Printf("\n");
+ }
+ }
+ if (DumpFacebookVersionName())
+ DumpTextStream(StreamType::FacebookAppVersionName,
+ "Facebook Version String");
+ if (DumpFacebookJavaStack())
+ DumpTextStream(StreamType::FacebookJavaStack,
+ "Facebook Java Stack");
+ if (DumpFacebookDalvikInfo())
+ DumpTextStream(StreamType::FacebookDalvikInfo,
+ "Facebook Dalvik Info");
+ if (DumpFacebookUnwindSymbols())
+ DumpBinaryStream(StreamType::FacebookUnwindSymbols,
+ "Facebook Unwind Symbols Bytes");
+ if (DumpFacebookErrorLog())
+ DumpTextStream(StreamType::FacebookDumpErrorLog,
+ "Facebook Error Log");
+ if (DumpFacebookAppStateLog())
+ DumpTextStream(StreamType::FacebookAppStateLog,
+ "Faceook Application State Log");
+ if (DumpFacebookAbortReason())
+ DumpTextStream(StreamType::FacebookAbortReason,
+ "Facebook Abort Reason");
+ if (DumpFacebookThreadName())
+ DumpTextStream(StreamType::FacebookThreadName,
+ "Facebook Thread Name");
+ if (DumpFacebookLogcat())
+ DumpTextStream(StreamType::FacebookLogcat,
+ "Facebook Logcat");
return true;
}
};
@@ -640,12 +811,12 @@ public:
CommandObjectSP(new CommandObjectProcessMinidumpDump(interpreter)));
}
- ~CommandObjectMultiwordProcessMinidump() {}
+ ~CommandObjectMultiwordProcessMinidump() override {}
};
CommandObject *ProcessMinidump::GetPluginCommandObject() {
if (!m_command_sp)
- m_command_sp.reset(new CommandObjectMultiwordProcessMinidump(
- GetTarget().GetDebugger().GetCommandInterpreter()));
+ m_command_sp = std::make_shared<CommandObjectMultiwordProcessMinidump>(
+ GetTarget().GetDebugger().GetCommandInterpreter());
return m_command_sp.get();
}
diff --git a/source/Plugins/Process/minidump/ProcessMinidump.h b/source/Plugins/Process/minidump/ProcessMinidump.h
index 30347b79e1c17..c39040f61dc5e 100644
--- a/source/Plugins/Process/minidump/ProcessMinidump.h
+++ b/source/Plugins/Process/minidump/ProcessMinidump.h
@@ -1,9 +1,8 @@
//===-- ProcessMinidump.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,7 +41,7 @@ public:
static const char *GetPluginDescriptionStatic();
ProcessMinidump(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp,
- const FileSpec &core_file, MinidumpParser minidump_parser);
+ const FileSpec &core_file, lldb::DataBufferSP code_data);
~ProcessMinidump() override;
@@ -93,7 +92,7 @@ public:
return error;
}
- MinidumpParser m_minidump_parser;
+ llvm::Optional<MinidumpParser> m_minidump_parser;
protected:
void Clear();
@@ -107,7 +106,8 @@ protected:
private:
FileSpec m_core_file;
- llvm::ArrayRef<MinidumpThread> m_thread_list;
+ lldb::DataBufferSP m_core_data;
+ llvm::ArrayRef<minidump::Thread> m_thread_list;
const MinidumpExceptionStream *m_active_exception;
lldb::CommandObjectSP m_command_sp;
bool m_is_wow64;
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
index 93c3ba70b9e7e..f2e456097dfcc 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_ARM.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,33 +29,35 @@ using namespace minidump;
#define DEF_R(i) \
{ \
"r" #i, nullptr, 4, OFFSET(r) + i * 4, eEncodingUint, eFormatHex, \
- {INV, dwarf_r##i, INV, INV, reg_r##i}, nullptr, nullptr, nullptr, 0 \
+ {dwarf_r##i, dwarf_r##i, INV, INV, reg_r##i}, \
+ nullptr, nullptr, nullptr, 0 \
}
#define DEF_R_ARG(i, n) \
{ \
"r" #i, "arg" #n, 4, OFFSET(r) + i * 4, eEncodingUint, eFormatHex, \
- {INV, dwarf_r##i, LLDB_REGNUM_GENERIC_ARG1 + i, INV, reg_r##i}, \
+ {dwarf_r##i, dwarf_r##i, LLDB_REGNUM_GENERIC_ARG1 + i, INV, reg_r##i}, \
nullptr, nullptr, nullptr, 0 \
}
#define DEF_D(i) \
{ \
"d" #i, nullptr, 8, OFFSET(d) + i * 8, eEncodingVector, \
- eFormatVectorOfUInt8, {INV, dwarf_d##i, INV, INV, reg_d##i}, \
+ eFormatVectorOfUInt8, {dwarf_d##i, dwarf_d##i, INV, INV, reg_d##i}, \
nullptr, nullptr, nullptr, 0 \
}
#define DEF_S(i) \
{ \
"s" #i, nullptr, 4, OFFSET(s) + i * 4, eEncodingIEEE754, eFormatFloat, \
- {INV, dwarf_s##i, INV, INV, reg_s##i}, nullptr, nullptr, nullptr, 0 \
+ {dwarf_s##i, dwarf_s##i, INV, INV, reg_s##i}, \
+ nullptr, nullptr, nullptr, 0 \
}
#define DEF_Q(i) \
{ \
"q" #i, nullptr, 16, OFFSET(q) + i * 16, eEncodingVector, \
- eFormatVectorOfUInt8, {INV, dwarf_q##i, INV, INV, reg_q##i}, \
+ eFormatVectorOfUInt8, {dwarf_q##i, dwarf_q##i, INV, INV, reg_q##i}, \
nullptr, nullptr, nullptr, 0 \
}
@@ -462,7 +463,7 @@ static RegisterSet g_reg_sets[] = {
constexpr size_t k_num_reg_sets = llvm::array_lengthof(g_reg_sets);
RegisterContextMinidump_ARM::RegisterContextMinidump_ARM(
- Thread &thread, const DataExtractor &data, bool apple)
+ lldb_private::Thread &thread, const DataExtractor &data, bool apple)
: RegisterContext(thread, 0), m_apple(apple) {
lldb::offset_t offset = 0;
m_regs.context_flags = data.GetU32(&offset);
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
index 959611a1491d8..eff8cdfef00a0 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_ARM.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
index 3582e7d018676..bbd0e14a32673 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_ARM64.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,8 +28,8 @@ using namespace minidump;
#define DEF_X(i) \
{ \
"x" #i, nullptr, 8, OFFSET(x) + i * 8, eEncodingUint, eFormatHex, \
- {INV, arm64_dwarf::x##i, INV, INV, reg_x##i}, nullptr, nullptr, \
- nullptr, 0 \
+ {arm64_dwarf::x##i, arm64_dwarf::x##i, INV, INV, reg_x##i}, \
+ nullptr, nullptr, nullptr, 0 \
}
#define DEF_W(i) \
@@ -42,15 +41,15 @@ using namespace minidump;
#define DEF_X_ARG(i, n) \
{ \
"x" #i, "arg" #n, 8, OFFSET(x) + i * 8, eEncodingUint, eFormatHex, \
- {INV, arm64_dwarf::x##i, LLDB_REGNUM_GENERIC_ARG1 + i, INV, reg_x##i}, \
- nullptr, nullptr, nullptr, 0 \
+ {arm64_dwarf::x##i, arm64_dwarf::x##i, LLDB_REGNUM_GENERIC_ARG1 + i, \
+ INV, reg_x##i}, nullptr, nullptr, nullptr, 0 \
}
#define DEF_V(i) \
{ \
"v" #i, nullptr, 16, OFFSET(v) + i * 16, eEncodingVector, \
- eFormatVectorOfUInt8, {INV, arm64_dwarf::v##i, INV, INV, reg_v##i}, \
- nullptr, nullptr, nullptr, 0 \
+ eFormatVectorOfUInt8, {arm64_dwarf::v##i, arm64_dwarf::v##i, INV, INV, \
+ reg_v##i}, nullptr, nullptr, nullptr, 0 \
}
#define DEF_D(i) \
@@ -314,7 +313,7 @@ static RegisterInfo g_reg_infos[] = {
OFFSET(x) + 29 * 8,
eEncodingUint,
eFormatHex,
- {INV, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, INV, reg_fp},
+ {arm64_dwarf::x29, arm64_dwarf::x29, LLDB_REGNUM_GENERIC_FP, INV, reg_fp},
nullptr,
nullptr,
nullptr,
@@ -325,7 +324,7 @@ static RegisterInfo g_reg_infos[] = {
OFFSET(x) + 30 * 8,
eEncodingUint,
eFormatHex,
- {INV, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, INV, reg_lr},
+ {arm64_dwarf::x30, arm64_dwarf::x30, LLDB_REGNUM_GENERIC_RA, INV, reg_lr},
nullptr,
nullptr,
nullptr,
@@ -336,7 +335,7 @@ static RegisterInfo g_reg_infos[] = {
OFFSET(x) + 31 * 8,
eEncodingUint,
eFormatHex,
- {INV, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, INV, reg_sp},
+ {arm64_dwarf::x31, arm64_dwarf::x31, LLDB_REGNUM_GENERIC_SP, INV, reg_sp},
nullptr,
nullptr,
nullptr,
@@ -347,7 +346,7 @@ static RegisterInfo g_reg_infos[] = {
OFFSET(pc),
eEncodingUint,
eFormatHex,
- {INV, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, INV, reg_pc},
+ {arm64_dwarf::pc, arm64_dwarf::pc, LLDB_REGNUM_GENERIC_PC, INV, reg_pc},
nullptr,
nullptr,
nullptr,
@@ -770,7 +769,7 @@ static RegisterSet g_reg_sets[] = {
constexpr size_t k_num_reg_sets = llvm::array_lengthof(g_reg_sets);
RegisterContextMinidump_ARM64::RegisterContextMinidump_ARM64(
- Thread &thread, const DataExtractor &data)
+ lldb_private::Thread &thread, const DataExtractor &data)
: RegisterContext(thread, 0) {
lldb::offset_t offset = 0;
m_regs.context_flags = data.GetU64(&offset);
@@ -783,7 +782,7 @@ RegisterContextMinidump_ARM64::RegisterContextMinidump_ARM64(
auto regs_data = data.GetData(&offset, sizeof(m_regs.v));
if (regs_data)
memcpy(m_regs.v, regs_data, sizeof(m_regs.v));
- assert(k_num_regs == k_num_reg_infos);
+ static_assert(k_num_regs == k_num_reg_infos, "");
}
size_t RegisterContextMinidump_ARM64::GetRegisterCount() { return k_num_regs; }
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
index ee47b1577e522..f9e7f39eea607 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_ARM64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_ARM64.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
index 1fdbb5e3f1e59..8ac2abb220938 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_x86_32.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
index 38c2ffca49389..d787f78ec7d37 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_32.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_x86_32.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
index eaa155de8eb9b..515ccf6b2c3c4 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_x86_64.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
index 30ce9065e1414..34ddd477a9d12 100644
--- a/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
+++ b/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.h
@@ -1,9 +1,8 @@
//===-- RegisterContextMinidump_x86_64.h ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/Process/minidump/ThreadMinidump.cpp b/source/Plugins/Process/minidump/ThreadMinidump.cpp
index f4c136577719c..5262de5a94c4e 100644
--- a/source/Plugins/Process/minidump/ThreadMinidump.cpp
+++ b/source/Plugins/Process/minidump/ThreadMinidump.cpp
@@ -1,13 +1,13 @@
//===-- ThreadMinidump.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "ThreadMinidump.h"
+
#include "ProcessMinidump.h"
#include "RegisterContextMinidump_ARM.h"
@@ -27,14 +27,15 @@
#include "lldb/Utility/DataExtractor.h"
#include "lldb/Utility/Log.h"
+#include <memory>
using namespace lldb;
using namespace lldb_private;
using namespace minidump;
-ThreadMinidump::ThreadMinidump(Process &process, const MinidumpThread &td,
+ThreadMinidump::ThreadMinidump(Process &process, const minidump::Thread &td,
llvm::ArrayRef<uint8_t> gpregset_data)
- : Thread(process, td.thread_id), m_thread_reg_ctx_sp(),
+ : Thread(process, td.ThreadId), m_thread_reg_ctx_sp(),
m_gpregset_data(gpregset_data) {}
ThreadMinidump::~ThreadMinidump() {}
@@ -72,8 +73,9 @@ ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) {
lldb::DataBufferSP buf =
ConvertMinidumpContext_x86_32(m_gpregset_data, reg_interface);
DataExtractor gpregset(buf, lldb::eByteOrderLittle, 4);
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_x86_64(
- *this, reg_interface, gpregset, {}));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_x86_64>(
+ *this, reg_interface, gpregset,
+ llvm::ArrayRef<lldb_private::CoreNote>());
break;
}
case llvm::Triple::x86_64: {
@@ -81,22 +83,24 @@ ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) {
lldb::DataBufferSP buf =
ConvertMinidumpContext_x86_64(m_gpregset_data, reg_interface);
DataExtractor gpregset(buf, lldb::eByteOrderLittle, 8);
- m_thread_reg_ctx_sp.reset(new RegisterContextCorePOSIX_x86_64(
- *this, reg_interface, gpregset, {}));
+ m_thread_reg_ctx_sp = std::make_shared<RegisterContextCorePOSIX_x86_64>(
+ *this, reg_interface, gpregset,
+ llvm::ArrayRef<lldb_private::CoreNote>());
break;
}
case llvm::Triple::aarch64: {
DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(),
lldb::eByteOrderLittle, 8);
- m_thread_reg_ctx_sp.reset(new RegisterContextMinidump_ARM64(*this, data));
+ m_thread_reg_ctx_sp =
+ std::make_shared<RegisterContextMinidump_ARM64>(*this, data);
break;
}
case llvm::Triple::arm: {
DataExtractor data(m_gpregset_data.data(), m_gpregset_data.size(),
lldb::eByteOrderLittle, 8);
const bool apple = arch.GetTriple().getVendor() == llvm::Triple::Apple;
- m_thread_reg_ctx_sp.reset(
- new RegisterContextMinidump_ARM(*this, data, apple));
+ m_thread_reg_ctx_sp =
+ std::make_shared<RegisterContextMinidump_ARM>(*this, data, apple);
break;
}
default:
@@ -104,8 +108,8 @@ ThreadMinidump::CreateRegisterContextForFrame(StackFrame *frame) {
}
reg_ctx_sp = m_thread_reg_ctx_sp;
- } else if (m_unwinder_ap) {
- reg_ctx_sp = m_unwinder_ap->CreateRegisterContextForFrame(frame);
+ } else if (m_unwinder_up) {
+ reg_ctx_sp = m_unwinder_up->CreateRegisterContextForFrame(frame);
}
return reg_ctx_sp;
diff --git a/source/Plugins/Process/minidump/ThreadMinidump.h b/source/Plugins/Process/minidump/ThreadMinidump.h
index 45364facaa562..44c41bc9f50ea 100644
--- a/source/Plugins/Process/minidump/ThreadMinidump.h
+++ b/source/Plugins/Process/minidump/ThreadMinidump.h
@@ -1,9 +1,8 @@
//===-- ThreadMinidump.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,7 @@ namespace minidump {
class ThreadMinidump : public Thread {
public:
- ThreadMinidump(Process &process, const MinidumpThread &td,
+ ThreadMinidump(Process &process, const minidump::Thread &td,
llvm::ArrayRef<uint8_t> gpregset_data);
~ThreadMinidump() override;
diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
index 4bd4c6a029a0f..7b95983795530 100644
--- a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
+++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.cpp
@@ -1,9 +1,8 @@
//===-- ScriptInterpreterNone.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StringList.h"
@@ -22,21 +20,21 @@
using namespace lldb;
using namespace lldb_private;
-ScriptInterpreterNone::ScriptInterpreterNone(CommandInterpreter &interpreter)
- : ScriptInterpreter(interpreter, eScriptLanguageNone) {}
+ScriptInterpreterNone::ScriptInterpreterNone(Debugger &debugger)
+ : ScriptInterpreter(debugger, eScriptLanguageNone) {}
ScriptInterpreterNone::~ScriptInterpreterNone() {}
bool ScriptInterpreterNone::ExecuteOneLine(llvm::StringRef command,
CommandReturnObject *,
const ExecuteScriptOptions &) {
- m_interpreter.GetDebugger().GetErrorFile()->PutCString(
+ m_debugger.GetErrorFile()->PutCString(
"error: there is no embedded script interpreter in this mode.\n");
return false;
}
void ScriptInterpreterNone::ExecuteInterpreterLoop() {
- m_interpreter.GetDebugger().GetErrorFile()->PutCString(
+ m_debugger.GetErrorFile()->PutCString(
"error: there is no embedded script interpreter in this mode.\n");
}
@@ -53,8 +51,8 @@ void ScriptInterpreterNone::Initialize() {
void ScriptInterpreterNone::Terminate() {}
lldb::ScriptInterpreterSP
-ScriptInterpreterNone::CreateInstance(CommandInterpreter &interpreter) {
- return std::make_shared<ScriptInterpreterNone>(interpreter);
+ScriptInterpreterNone::CreateInstance(Debugger &debugger) {
+ return std::make_shared<ScriptInterpreterNone>(debugger);
}
lldb_private::ConstString ScriptInterpreterNone::GetPluginNameStatic() {
diff --git a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
index 8937d9843f875..242065cc23e86 100644
--- a/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
+++ b/source/Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h
@@ -1,9 +1,8 @@
//===-- ScriptInterpreterNone.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,7 @@ namespace lldb_private {
class ScriptInterpreterNone : public ScriptInterpreter {
public:
- ScriptInterpreterNone(CommandInterpreter &interpreter);
+ ScriptInterpreterNone(Debugger &debugger);
~ScriptInterpreterNone() override;
@@ -26,23 +25,18 @@ public:
void ExecuteInterpreterLoop() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
- static lldb::ScriptInterpreterSP
- CreateInstance(CommandInterpreter &interpreter);
+ static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger);
static lldb_private::ConstString GetPluginNameStatic();
static const char *GetPluginDescriptionStatic();
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 7e96dd9893c87..29dd037efd86b 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1,9 +1,8 @@
//===-- PythonDataObjects.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,12 +20,12 @@
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Utility/Stream.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
#include <stdio.h>
-#include "llvm/ADT/StringSwitch.h"
-
using namespace lldb_private;
using namespace lldb;
@@ -34,13 +33,11 @@ void StructuredPythonObject::Dump(Stream &s, bool pretty_print) const {
s << "Python Obj: 0x" << GetValue();
}
-//----------------------------------------------------------------------
// PythonObject
-//----------------------------------------------------------------------
void PythonObject::Dump(Stream &strm) const {
if (m_py_obj) {
- FILE *file = ::tmpfile();
+ FILE *file = llvm::sys::RetryAfterSignal(nullptr, ::tmpfile);
if (file) {
::PyObject_Print(m_py_obj, file, 0);
const long length = ftell(file);
@@ -78,6 +75,8 @@ PyObjectType PythonObject::GetObjectType() const {
#endif
if (PythonByteArray::Check(m_py_obj))
return PyObjectType::ByteArray;
+ if (PythonBoolean::Check(m_py_obj))
+ return PyObjectType::Boolean;
if (PythonInteger::Check(m_py_obj))
return PyObjectType::Integer;
if (PythonFile::Check(m_py_obj))
@@ -108,7 +107,7 @@ PythonString PythonObject::Str() const {
PythonObject
PythonObject::ResolveNameWithDictionary(llvm::StringRef name,
const PythonDictionary &dict) {
- size_t dot_pos = name.find_first_of('.');
+ size_t dot_pos = name.find('.');
llvm::StringRef piece = name.substr(0, dot_pos);
PythonObject result = dict.GetItemForKey(PythonString(piece));
if (dot_pos == llvm::StringRef::npos) {
@@ -132,7 +131,7 @@ PythonObject PythonObject::ResolveName(llvm::StringRef name) const {
// refers to the `sys` module, and `name` == "path.append", then it will find
// the function `sys.path.append`.
- size_t dot_pos = name.find_first_of('.');
+ size_t dot_pos = name.find('.');
if (dot_pos == llvm::StringRef::npos) {
// No dots in the name, we should be able to find the value immediately as
// an attribute of `m_py_obj`.
@@ -179,6 +178,9 @@ StructuredData::ObjectSP PythonObject::CreateStructuredObject() const {
case PyObjectType::Dictionary:
return PythonDictionary(PyRefType::Borrowed, m_py_obj)
.CreateStructuredDictionary();
+ case PyObjectType::Boolean:
+ return PythonBoolean(PyRefType::Borrowed, m_py_obj)
+ .CreateStructuredBoolean();
case PyObjectType::Integer:
return PythonInteger(PyRefType::Borrowed, m_py_obj)
.CreateStructuredInteger();
@@ -198,9 +200,7 @@ StructuredData::ObjectSP PythonObject::CreateStructuredObject() const {
}
}
-//----------------------------------------------------------------------
// PythonString
-//----------------------------------------------------------------------
PythonBytes::PythonBytes() : PythonObject() {}
PythonBytes::PythonBytes(llvm::ArrayRef<uint8_t> bytes) : PythonObject() {
@@ -215,8 +215,6 @@ PythonBytes::PythonBytes(PyRefType type, PyObject *py_obj) : PythonObject() {
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a string
}
-PythonBytes::PythonBytes(const PythonBytes &object) : PythonObject(object) {}
-
PythonBytes::~PythonBytes() {}
bool PythonBytes::Check(PyObject *py_obj) {
@@ -334,16 +332,12 @@ StructuredData::StringSP PythonByteArray::CreateStructuredString() const {
return result;
}
-//----------------------------------------------------------------------
// PythonString
-//----------------------------------------------------------------------
PythonString::PythonString(PyRefType type, PyObject *py_obj) : PythonObject() {
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a string
}
-PythonString::PythonString(const PythonString &object) : PythonObject(object) {}
-
PythonString::PythonString(llvm::StringRef string) : PythonObject() {
SetString(string);
}
@@ -434,9 +428,7 @@ StructuredData::StringSP PythonString::CreateStructuredString() const {
return result;
}
-//----------------------------------------------------------------------
// PythonInteger
-//----------------------------------------------------------------------
PythonInteger::PythonInteger() : PythonObject() {}
@@ -445,9 +437,6 @@ PythonInteger::PythonInteger(PyRefType type, PyObject *py_obj)
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a integer type
}
-PythonInteger::PythonInteger(const PythonInteger &object)
- : PythonObject(object) {}
-
PythonInteger::PythonInteger(int64_t value) : PythonObject() {
SetInteger(value);
}
@@ -526,9 +515,51 @@ StructuredData::IntegerSP PythonInteger::CreateStructuredInteger() const {
return result;
}
-//----------------------------------------------------------------------
+// PythonBoolean
+
+PythonBoolean::PythonBoolean(PyRefType type, PyObject *py_obj)
+ : PythonObject() {
+ Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a boolean type
+}
+
+PythonBoolean::PythonBoolean(bool value) {
+ SetValue(value);
+}
+
+bool PythonBoolean::Check(PyObject *py_obj) {
+ return py_obj ? PyBool_Check(py_obj) : false;
+}
+
+void PythonBoolean::Reset(PyRefType type, PyObject *py_obj) {
+ // Grab the desired reference type so that if we end up rejecting `py_obj` it
+ // still gets decremented if necessary.
+ PythonObject result(type, py_obj);
+
+ if (!PythonBoolean::Check(py_obj)) {
+ PythonObject::Reset();
+ return;
+ }
+
+ // Calling PythonObject::Reset(const PythonObject&) will lead to stack
+ // overflow since it calls back into the virtual implementation.
+ PythonObject::Reset(PyRefType::Borrowed, result.get());
+}
+
+bool PythonBoolean::GetValue() const {
+ return m_py_obj ? PyObject_IsTrue(m_py_obj) : false;
+}
+
+void PythonBoolean::SetValue(bool value) {
+ PythonObject::Reset(PyRefType::Owned, PyBool_FromLong(value));
+}
+
+StructuredData::BooleanSP PythonBoolean::CreateStructuredBoolean() const {
+ StructuredData::BooleanSP result(new StructuredData::Boolean);
+ result->SetValue(GetValue());
+ return result;
+}
+
// PythonList
-//----------------------------------------------------------------------
PythonList::PythonList(PyInitialValue value) : PythonObject() {
if (value == PyInitialValue::Empty)
@@ -543,8 +574,6 @@ PythonList::PythonList(PyRefType type, PyObject *py_obj) : PythonObject() {
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a list
}
-PythonList::PythonList(const PythonList &list) : PythonObject(list) {}
-
PythonList::~PythonList() {}
bool PythonList::Check(PyObject *py_obj) {
@@ -607,9 +636,7 @@ StructuredData::ArraySP PythonList::CreateStructuredArray() const {
return result;
}
-//----------------------------------------------------------------------
// PythonTuple
-//----------------------------------------------------------------------
PythonTuple::PythonTuple(PyInitialValue value) : PythonObject() {
if (value == PyInitialValue::Empty)
@@ -624,8 +651,6 @@ PythonTuple::PythonTuple(PyRefType type, PyObject *py_obj) : PythonObject() {
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a tuple
}
-PythonTuple::PythonTuple(const PythonTuple &tuple) : PythonObject(tuple) {}
-
PythonTuple::PythonTuple(std::initializer_list<PythonObject> objects) {
m_py_obj = PyTuple_New(objects.size());
@@ -703,9 +728,7 @@ StructuredData::ArraySP PythonTuple::CreateStructuredArray() const {
return result;
}
-//----------------------------------------------------------------------
// PythonDictionary
-//----------------------------------------------------------------------
PythonDictionary::PythonDictionary(PyInitialValue value) : PythonObject() {
if (value == PyInitialValue::Empty)
@@ -717,9 +740,6 @@ PythonDictionary::PythonDictionary(PyRefType type, PyObject *py_obj)
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a dictionary
}
-PythonDictionary::PythonDictionary(const PythonDictionary &object)
- : PythonObject(object) {}
-
PythonDictionary::~PythonDictionary() {}
bool PythonDictionary::Check(PyObject *py_obj) {
@@ -789,8 +809,6 @@ PythonModule::PythonModule(PyRefType type, PyObject *py_obj) {
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a module
}
-PythonModule::PythonModule(const PythonModule &dict) : PythonObject(dict) {}
-
PythonModule::~PythonModule() {}
PythonModule PythonModule::BuiltinsModule() {
@@ -845,9 +863,6 @@ PythonCallable::PythonCallable(PyRefType type, PyObject *py_obj) {
Reset(type, py_obj); // Use "Reset()" to ensure that py_obj is a callable
}
-PythonCallable::PythonCallable(const PythonCallable &callable)
- : PythonObject(callable) {}
-
PythonCallable::~PythonCallable() {}
bool PythonCallable::Check(PyObject *py_obj) {
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 7cd98df28ee07..049ce90bb1b1c 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -1,9 +1,8 @@
//===-- PythonDataObjects.h--------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,13 +14,8 @@
// LLDB Python header must be included first
#include "lldb-python.h"
-#include "lldb/Utility/Flags.h"
-
#include "lldb/Host/File.h"
-#include "lldb/Interpreter/OptionValue.h"
-#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/StructuredData.h"
-#include "lldb/lldb-defines.h"
#include "llvm/ADT/ArrayRef.h"
@@ -58,6 +52,7 @@ private:
enum class PyObjectType {
Unknown,
None,
+ Boolean,
Integer,
Dictionary,
List,
@@ -203,7 +198,6 @@ public:
explicit PythonBytes(llvm::ArrayRef<uint8_t> bytes);
PythonBytes(const uint8_t *bytes, size_t length);
PythonBytes(PyRefType type, PyObject *o);
- PythonBytes(const PythonBytes &object);
~PythonBytes() override;
@@ -255,7 +249,6 @@ public:
explicit PythonString(llvm::StringRef string);
explicit PythonString(const char *string);
PythonString(PyRefType type, PyObject *o);
- PythonString(const PythonString &object);
~PythonString() override;
@@ -280,7 +273,6 @@ public:
PythonInteger();
explicit PythonInteger(int64_t value);
PythonInteger(PyRefType type, PyObject *o);
- PythonInteger(const PythonInteger &object);
~PythonInteger() override;
@@ -298,13 +290,34 @@ public:
StructuredData::IntegerSP CreateStructuredInteger() const;
};
+class PythonBoolean : public PythonObject {
+public:
+ PythonBoolean() = default;
+ explicit PythonBoolean(bool value);
+ PythonBoolean(PyRefType type, PyObject *o);
+
+ ~PythonBoolean() override = default;
+
+ static bool Check(PyObject *py_obj);
+
+ // Bring in the no-argument base class version
+ using PythonObject::Reset;
+
+ void Reset(PyRefType type, PyObject *py_obj) override;
+
+ bool GetValue() const;
+
+ void SetValue(bool value);
+
+ StructuredData::BooleanSP CreateStructuredBoolean() const;
+};
+
class PythonList : public PythonObject {
public:
PythonList() {}
explicit PythonList(PyInitialValue value);
explicit PythonList(int list_size);
PythonList(PyRefType type, PyObject *o);
- PythonList(const PythonList &list);
~PythonList() override;
@@ -332,7 +345,6 @@ public:
explicit PythonTuple(PyInitialValue value);
explicit PythonTuple(int tuple_size);
PythonTuple(PyRefType type, PyObject *o);
- PythonTuple(const PythonTuple &tuple);
PythonTuple(std::initializer_list<PythonObject> objects);
PythonTuple(std::initializer_list<PyObject *> objects);
@@ -359,7 +371,6 @@ public:
PythonDictionary() {}
explicit PythonDictionary(PyInitialValue value);
PythonDictionary(PyRefType type, PyObject *o);
- PythonDictionary(const PythonDictionary &dict);
~PythonDictionary() override;
@@ -384,7 +395,6 @@ class PythonModule : public PythonObject {
public:
PythonModule();
PythonModule(PyRefType type, PyObject *o);
- PythonModule(const PythonModule &dict);
~PythonModule() override;
@@ -417,7 +427,6 @@ public:
PythonCallable();
PythonCallable(PyRefType type, PyObject *o);
- PythonCallable(const PythonCallable &dict);
~PythonCallable() override;
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp
index d28a8033820a2..c9d834ce6868b 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.cpp
@@ -1,9 +1,8 @@
//===-- PythonExceptionState.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h
index 20f4b4c6329d5..3a88aa037776b 100644
--- a/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h
+++ b/source/Plugins/ScriptInterpreter/Python/PythonExceptionState.h
@@ -1,9 +1,8 @@
//===-- PythonExceptionState.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 41cb443d4f1e1..2d2b68ceaaa6b 100644
--- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1,9 +1,8 @@
//===-- ScriptInterpreterPython.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,17 +17,10 @@
#include "PythonDataObjects.h"
#include "PythonExceptionState.h"
-#include "ScriptInterpreterPython.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <mutex>
-#include <string>
+#include "ScriptInterpreterPythonImpl.h"
-#include "lldb/API/SBValue.h"
#include "lldb/API/SBFrame.h"
-#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/API/SBValue.h"
#include "lldb/Breakpoint/StoppointCallbackContext.h"
#include "lldb/Breakpoint/WatchpointOptions.h"
#include "lldb/Core/Communication.h"
@@ -54,68 +46,146 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FileSystem.h"
+#include <memory>
+#include <mutex>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string>
+
using namespace lldb;
using namespace lldb_private;
-static ScriptInterpreterPython::SWIGInitCallback g_swig_init_callback = nullptr;
-static ScriptInterpreterPython::SWIGBreakpointCallbackFunction
- g_swig_breakpoint_callback = nullptr;
-static ScriptInterpreterPython::SWIGWatchpointCallbackFunction
- g_swig_watchpoint_callback = nullptr;
-static ScriptInterpreterPython::SWIGPythonTypeScriptCallbackFunction
- g_swig_typescript_callback = nullptr;
-static ScriptInterpreterPython::SWIGPythonCreateSyntheticProvider
- g_swig_synthetic_script = nullptr;
-static ScriptInterpreterPython::SWIGPythonCreateCommandObject
- g_swig_create_cmd = nullptr;
-static ScriptInterpreterPython::SWIGPythonCalculateNumChildren
- g_swig_calc_children = nullptr;
-static ScriptInterpreterPython::SWIGPythonGetChildAtIndex
- g_swig_get_child_index = nullptr;
-static ScriptInterpreterPython::SWIGPythonGetIndexOfChildWithName
- g_swig_get_index_child = nullptr;
-static ScriptInterpreterPython::SWIGPythonCastPyObjectToSBValue
- g_swig_cast_to_sbvalue = nullptr;
-static ScriptInterpreterPython::SWIGPythonGetValueObjectSPFromSBValue
- g_swig_get_valobj_sp_from_sbvalue = nullptr;
-static ScriptInterpreterPython::SWIGPythonUpdateSynthProviderInstance
- g_swig_update_provider = nullptr;
-static ScriptInterpreterPython::SWIGPythonMightHaveChildrenSynthProviderInstance
- g_swig_mighthavechildren_provider = nullptr;
-static ScriptInterpreterPython::SWIGPythonGetValueSynthProviderInstance
- g_swig_getvalue_provider = nullptr;
-static ScriptInterpreterPython::SWIGPythonCallCommand g_swig_call_command =
- nullptr;
-static ScriptInterpreterPython::SWIGPythonCallCommandObject
- g_swig_call_command_object = nullptr;
-static ScriptInterpreterPython::SWIGPythonCallModuleInit
- g_swig_call_module_init = nullptr;
-static ScriptInterpreterPython::SWIGPythonCreateOSPlugin
- g_swig_create_os_plugin = nullptr;
-static ScriptInterpreterPython::SWIGPythonCreateFrameRecognizer
- g_swig_create_frame_recognizer = nullptr;
-static ScriptInterpreterPython::SWIGPythonGetRecognizedArguments
- g_swig_get_recognized_arguments = nullptr;
-static ScriptInterpreterPython::SWIGPythonScriptKeyword_Process
- g_swig_run_script_keyword_process = nullptr;
-static ScriptInterpreterPython::SWIGPythonScriptKeyword_Thread
- g_swig_run_script_keyword_thread = nullptr;
-static ScriptInterpreterPython::SWIGPythonScriptKeyword_Target
- g_swig_run_script_keyword_target = nullptr;
-static ScriptInterpreterPython::SWIGPythonScriptKeyword_Frame
- g_swig_run_script_keyword_frame = nullptr;
-static ScriptInterpreterPython::SWIGPythonScriptKeyword_Value
- g_swig_run_script_keyword_value = nullptr;
-static ScriptInterpreterPython::SWIGPython_GetDynamicSetting g_swig_plugin_get =
- nullptr;
-static ScriptInterpreterPython::SWIGPythonCreateScriptedThreadPlan
- g_swig_thread_plan_script = nullptr;
-static ScriptInterpreterPython::SWIGPythonCallThreadPlan
- g_swig_call_thread_plan = nullptr;
-static ScriptInterpreterPython::SWIGPythonCreateScriptedBreakpointResolver
- g_swig_bkpt_resolver_script = nullptr;
-static ScriptInterpreterPython::SWIGPythonCallBreakpointResolver
- g_swig_call_bkpt_resolver = nullptr;
+// Defined in the SWIG source file
+#if PY_MAJOR_VERSION >= 3
+extern "C" PyObject *PyInit__lldb(void);
+
+#define LLDBSwigPyInit PyInit__lldb
+
+#else
+extern "C" void init_lldb(void);
+
+#define LLDBSwigPyInit init_lldb
+#endif
+
+// These prototypes are the Pythonic implementations of the required callbacks.
+// Although these are scripting-language specific, their definition depends on
+// the public API.
+extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
+ const char *python_function_name, const char *session_dictionary_name,
+ const lldb::StackFrameSP &sb_frame,
+ const lldb::BreakpointLocationSP &sb_bp_loc);
+
+extern "C" bool LLDBSwigPythonWatchpointCallbackFunction(
+ const char *python_function_name, const char *session_dictionary_name,
+ const lldb::StackFrameSP &sb_frame, const lldb::WatchpointSP &sb_wp);
+
+extern "C" bool LLDBSwigPythonCallTypeScript(
+ const char *python_function_name, void *session_dictionary,
+ const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
+ const lldb::TypeSummaryOptionsSP &options_sp, std::string &retval);
+
+extern "C" void *
+LLDBSwigPythonCreateSyntheticProvider(const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ValueObjectSP &valobj_sp);
+
+extern "C" void *
+LLDBSwigPythonCreateCommandObject(const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::DebuggerSP debugger_sp);
+
+extern "C" void *LLDBSwigPythonCreateScriptedThreadPlan(
+ const char *python_class_name, const char *session_dictionary_name,
+ const lldb::ThreadPlanSP &thread_plan_sp);
+
+extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor,
+ const char *method_name,
+ Event *event_sp, bool &got_error);
+
+extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver(
+ const char *python_class_name, const char *session_dictionary_name,
+ lldb_private::StructuredDataImpl *args, lldb::BreakpointSP &bkpt_sp);
+
+extern "C" unsigned int
+LLDBSwigPythonCallBreakpointResolver(void *implementor, const char *method_name,
+ lldb_private::SymbolContext *sym_ctx);
+
+extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor,
+ uint32_t max);
+
+extern "C" void *LLDBSwigPython_GetChildAtIndex(void *implementor,
+ uint32_t idx);
+
+extern "C" int LLDBSwigPython_GetIndexOfChildWithName(void *implementor,
+ const char *child_name);
+
+extern "C" void *LLDBSWIGPython_CastPyObjectToSBValue(void *data);
+
+extern lldb::ValueObjectSP
+LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data);
+
+extern "C" bool LLDBSwigPython_UpdateSynthProviderInstance(void *implementor);
+
+extern "C" bool
+LLDBSwigPython_MightHaveChildrenSynthProviderInstance(void *implementor);
+
+extern "C" void *
+LLDBSwigPython_GetValueSynthProviderInstance(void *implementor);
+
+extern "C" bool
+LLDBSwigPythonCallCommand(const char *python_function_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP &debugger, const char *args,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+extern "C" bool
+LLDBSwigPythonCallCommandObject(void *implementor, lldb::DebuggerSP &debugger,
+ const char *args,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ lldb::ExecutionContextRefSP exe_ctx_ref_sp);
+
+extern "C" bool
+LLDBSwigPythonCallModuleInit(const char *python_module_name,
+ const char *session_dictionary_name,
+ lldb::DebuggerSP &debugger);
+
+extern "C" void *
+LLDBSWIGPythonCreateOSPlugin(const char *python_class_name,
+ const char *session_dictionary_name,
+ const lldb::ProcessSP &process_sp);
+
+extern "C" void *
+LLDBSWIGPython_CreateFrameRecognizer(const char *python_class_name,
+ const char *session_dictionary_name);
+
+extern "C" void *
+LLDBSwigPython_GetRecognizedArguments(void *implementor,
+ const lldb::StackFrameSP &frame_sp);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::ProcessSP &process, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordThread(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::ThreadSP &thread, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordTarget(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::TargetSP &target, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordFrame(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::StackFrameSP &frame, std::string &output);
+
+extern "C" bool LLDBSWIGPythonRunScriptKeywordValue(
+ const char *python_function_name, const char *session_dictionary_name,
+ lldb::ValueObjectSP &value, std::string &output);
+
+extern "C" void *
+LLDBSWIGPython_GetDynamicSetting(void *module, const char *setting,
+ const lldb::TargetSP &target_sp);
static bool g_initialized = false;
@@ -138,7 +208,7 @@ public:
InitializePythonHome();
// Register _lldb as a built-in module.
- PyImport_AppendInittab("_lldb", g_swig_init_callback);
+ PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
// Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
// calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you
@@ -156,7 +226,7 @@ public:
if (m_was_already_initialized) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked",
- m_was_already_initialized == PyGILState_UNLOCKED ? "un" : "");
+ m_gil_state == PyGILState_UNLOCKED ? "un" : "");
PyGILState_Release(m_gil_state);
} else {
// We initialized the threads in this function, just unlock the GIL.
@@ -176,10 +246,33 @@ private:
static char g_python_home[] = LLDB_PYTHON_HOME;
#endif
Py_SetPythonHome(g_python_home);
+#else
+#if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
+ // For Darwin, the only Python version supported is the one shipped in the
+ // OS OS and linked with lldb. Other installation of Python may have higher
+ // priorities in the path, overriding PYTHONHOME and causing
+ // problems/incompatibilities. In order to avoid confusion, always hardcode
+ // the PythonHome to be right, as it's not going to change.
+ static char path[] =
+ "/System/Library/Frameworks/Python.framework/Versions/2.7";
+ Py_SetPythonHome(path);
+#endif
#endif
}
void InitializeThreadsPrivate() {
+// Since Python 3.7 `Py_Initialize` calls `PyEval_InitThreads` inside itself,
+// so there is no way to determine whether the embedded interpreter
+// was already initialized by some external code. `PyEval_ThreadsInitialized`
+// would always return `true` and `PyGILState_Ensure/Release` flow would be
+// executed instead of unlocking GIL with `PyEval_SaveThread`. When
+// an another thread calls `PyGILState_Ensure` it would get stuck in deadlock.
+#if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7) || (PY_MAJOR_VERSION > 3)
+ // The only case we should go further and acquire the GIL: it is unlocked.
+ if (PyGILState_Check())
+ return;
+#endif
+
if (PyEval_ThreadsInitialized()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
@@ -198,11 +291,98 @@ private:
PyGILState_STATE m_gil_state;
bool m_was_already_initialized;
};
+} // namespace
+
+void ScriptInterpreterPython::ComputePythonDirForApple(
+ llvm::SmallVectorImpl<char> &path) {
+ auto style = llvm::sys::path::Style::posix;
+
+ llvm::StringRef path_ref(path.begin(), path.size());
+ auto rbegin = llvm::sys::path::rbegin(path_ref, style);
+ auto rend = llvm::sys::path::rend(path_ref);
+ auto framework = std::find(rbegin, rend, "LLDB.framework");
+ if (framework == rend) {
+ ComputePythonDirForPosix(path);
+ return;
+ }
+ path.resize(framework - rend);
+ llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
}
-ScriptInterpreterPython::Locker::Locker(ScriptInterpreterPython *py_interpreter,
- uint16_t on_entry, uint16_t on_leave,
- FILE *in, FILE *out, FILE *err)
+void ScriptInterpreterPython::ComputePythonDirForPosix(
+ llvm::SmallVectorImpl<char> &path) {
+ auto style = llvm::sys::path::Style::posix;
+#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
+ // Build the path by backing out of the lib dir, then building with whatever
+ // the real python interpreter uses. (e.g. lib for most, lib64 on RHEL
+ // x86_64).
+ llvm::sys::path::remove_filename(path, style);
+ llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
+#else
+ llvm::sys::path::append(path, style,
+ "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
+ llvm::Twine(PY_MINOR_VERSION),
+ "site-packages");
+#endif
+}
+
+void ScriptInterpreterPython::ComputePythonDirForWindows(
+ llvm::SmallVectorImpl<char> &path) {
+ auto style = llvm::sys::path::Style::windows;
+ llvm::sys::path::remove_filename(path, style);
+ llvm::sys::path::append(path, style, "lib", "site-packages");
+
+ // This will be injected directly through FileSpec.GetDirectory().SetString(),
+ // so we need to normalize manually.
+ std::replace(path.begin(), path.end(), '\\', '/');
+}
+
+FileSpec ScriptInterpreterPython::GetPythonDir() {
+ static FileSpec g_spec = []() {
+ FileSpec spec = HostInfo::GetShlibDir();
+ if (!spec)
+ return FileSpec();
+ llvm::SmallString<64> path;
+ spec.GetPath(path);
+
+#if defined(__APPLE__)
+ ComputePythonDirForApple(path);
+#elif defined(_WIN32)
+ ComputePythonDirForWindows(path);
+#else
+ ComputePythonDirForPosix(path);
+#endif
+ spec.GetDirectory().SetString(path);
+ return spec;
+ }();
+ return g_spec;
+}
+
+lldb_private::ConstString ScriptInterpreterPython::GetPluginNameStatic() {
+ static ConstString g_name("script-python");
+ return g_name;
+}
+
+const char *ScriptInterpreterPython::GetPluginDescriptionStatic() {
+ return "Embedded Python interpreter";
+}
+
+void ScriptInterpreterPython::Initialize() {
+ static llvm::once_flag g_once_flag;
+
+ llvm::call_once(g_once_flag, []() {
+ PluginManager::RegisterPlugin(GetPluginNameStatic(),
+ GetPluginDescriptionStatic(),
+ lldb::eScriptLanguagePython,
+ ScriptInterpreterPythonImpl::CreateInstance);
+ });
+}
+
+void ScriptInterpreterPython::Terminate() {}
+
+ScriptInterpreterPythonImpl::Locker::Locker(
+ ScriptInterpreterPythonImpl *py_interpreter, uint16_t on_entry,
+ uint16_t on_leave, FILE *in, FILE *out, FILE *err)
: ScriptInterpreterLocker(),
m_teardown_session((on_leave & TearDownSession) == TearDownSession),
m_python_interpreter(py_interpreter) {
@@ -215,7 +395,7 @@ ScriptInterpreterPython::Locker::Locker(ScriptInterpreterPython *py_interpreter,
}
}
-bool ScriptInterpreterPython::Locker::DoAcquireLock() {
+bool ScriptInterpreterPythonImpl::Locker::DoAcquireLock() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
m_GILState = PyGILState_Ensure();
LLDB_LOGV(log, "Ensured PyGILState. Previous state = {0}locked",
@@ -231,15 +411,15 @@ bool ScriptInterpreterPython::Locker::DoAcquireLock() {
return true;
}
-bool ScriptInterpreterPython::Locker::DoInitSession(uint16_t on_entry_flags,
- FILE *in, FILE *out,
- FILE *err) {
+bool ScriptInterpreterPythonImpl::Locker::DoInitSession(uint16_t on_entry_flags,
+ FILE *in, FILE *out,
+ FILE *err) {
if (!m_python_interpreter)
return false;
return m_python_interpreter->EnterSession(on_entry_flags, in, out, err);
}
-bool ScriptInterpreterPython::Locker::DoFreeLock() {
+bool ScriptInterpreterPythonImpl::Locker::DoFreeLock() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
LLDB_LOGV(log, "Releasing PyGILState. Returning to state = {0}locked",
m_GILState == PyGILState_UNLOCKED ? "un" : "");
@@ -248,29 +428,26 @@ bool ScriptInterpreterPython::Locker::DoFreeLock() {
return true;
}
-bool ScriptInterpreterPython::Locker::DoTearDownSession() {
+bool ScriptInterpreterPythonImpl::Locker::DoTearDownSession() {
if (!m_python_interpreter)
return false;
m_python_interpreter->LeaveSession();
return true;
}
-ScriptInterpreterPython::Locker::~Locker() {
+ScriptInterpreterPythonImpl::Locker::~Locker() {
if (m_teardown_session)
DoTearDownSession();
DoFreeLock();
}
-ScriptInterpreterPython::ScriptInterpreterPython(
- CommandInterpreter &interpreter)
- : ScriptInterpreter(interpreter, eScriptLanguagePython),
- IOHandlerDelegateMultiline("DONE"), m_saved_stdin(), m_saved_stdout(),
- m_saved_stderr(), m_main_module(), m_lldb_module(),
+ScriptInterpreterPythonImpl::ScriptInterpreterPythonImpl(Debugger &debugger)
+ : ScriptInterpreterPython(debugger), m_saved_stdin(), m_saved_stdout(),
+ m_saved_stderr(), m_main_module(),
m_session_dict(PyInitialValue::Invalid),
m_sys_module_dict(PyInitialValue::Invalid), m_run_one_line_function(),
m_run_one_line_str_global(),
- m_dictionary_name(
- interpreter.GetDebugger().GetInstanceName().AsCString()),
+ m_dictionary_name(m_debugger.GetInstanceName().AsCString()),
m_terminal_state(), m_active_io_handler(eIOHandlerNone),
m_session_is_active(false), m_pty_slave_is_open(false),
m_valid_session(true), m_lock_count(0), m_command_thread_state(nullptr) {
@@ -280,8 +457,7 @@ ScriptInterpreterPython::ScriptInterpreterPython(
StreamString run_string;
run_string.Printf("%s = dict()", m_dictionary_name.c_str());
- Locker locker(this, ScriptInterpreterPython::Locker::AcquireLock,
- ScriptInterpreterPython::Locker::FreeAcquiredLock);
+ Locker locker(this, Locker::AcquireLock, Locker::FreeAcquiredLock);
PyRun_SimpleString(run_string.GetData());
run_string.Clear();
@@ -317,12 +493,11 @@ ScriptInterpreterPython::ScriptInterpreterPython(
run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64
"; pydoc.pager = pydoc.plainpager')",
- m_dictionary_name.c_str(),
- interpreter.GetDebugger().GetID());
+ m_dictionary_name.c_str(), m_debugger.GetID());
PyRun_SimpleString(run_string.GetData());
}
-ScriptInterpreterPython::~ScriptInterpreterPython() {
+ScriptInterpreterPythonImpl::~ScriptInterpreterPythonImpl() {
// the session dictionary may hold objects with complex state which means
// that they may need to be torn down with some level of smarts and that, in
// turn, requires a valid thread state force Python to procure itself such a
@@ -333,104 +508,14 @@ ScriptInterpreterPython::~ScriptInterpreterPython() {
PyGILState_Release(gil_state);
}
-void ScriptInterpreterPython::Initialize() {
- static llvm::once_flag g_once_flag;
-
- llvm::call_once(g_once_flag, []() {
- PluginManager::RegisterPlugin(GetPluginNameStatic(),
- GetPluginDescriptionStatic(),
- lldb::eScriptLanguagePython, CreateInstance);
- });
-}
-
-void ScriptInterpreterPython::Terminate() {}
-
-lldb::ScriptInterpreterSP
-ScriptInterpreterPython::CreateInstance(CommandInterpreter &interpreter) {
- return std::make_shared<ScriptInterpreterPython>(interpreter);
-}
-
-lldb_private::ConstString ScriptInterpreterPython::GetPluginNameStatic() {
- static ConstString g_name("script-python");
- return g_name;
-}
-
-const char *ScriptInterpreterPython::GetPluginDescriptionStatic() {
- return "Embedded Python interpreter";
-}
-
-void ScriptInterpreterPython::ComputePythonDirForApple(
- llvm::SmallVectorImpl<char> &path) {
- auto style = llvm::sys::path::Style::posix;
-
- llvm::StringRef path_ref(path.begin(), path.size());
- auto rbegin = llvm::sys::path::rbegin(path_ref, style);
- auto rend = llvm::sys::path::rend(path_ref);
- auto framework = std::find(rbegin, rend, "LLDB.framework");
- if (framework == rend) {
- ComputePythonDirForPosix(path);
- return;
- }
- path.resize(framework - rend);
- llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
-}
-
-void ScriptInterpreterPython::ComputePythonDirForPosix(
- llvm::SmallVectorImpl<char> &path) {
- auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
- // Build the path by backing out of the lib dir, then building with whatever
- // the real python interpreter uses. (e.g. lib for most, lib64 on RHEL
- // x86_64).
- llvm::sys::path::remove_filename(path, style);
- llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
- llvm::sys::path::append(path, style,
- "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
- llvm::Twine(PY_MINOR_VERSION),
- "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
- llvm::SmallVectorImpl<char> &path) {
- auto style = llvm::sys::path::Style::windows;
- llvm::sys::path::remove_filename(path, style);
- llvm::sys::path::append(path, style, "lib", "site-packages");
-
- // This will be injected directly through FileSpec.GetDirectory().SetString(),
- // so we need to normalize manually.
- std::replace(path.begin(), path.end(), '\\', '/');
-}
-
-FileSpec ScriptInterpreterPython::GetPythonDir() {
- static FileSpec g_spec = []() {
- FileSpec spec = HostInfo::GetShlibDir();
- if (!spec)
- return FileSpec();
- llvm::SmallString<64> path;
- spec.GetPath(path);
-
-#if defined(__APPLE__)
- ComputePythonDirForApple(path);
-#elif defined(_WIN32)
- ComputePythonDirForWindows(path);
-#else
- ComputePythonDirForPosix(path);
-#endif
- spec.GetDirectory().SetString(path);
- return spec;
- }();
- return g_spec;
-}
-
-lldb_private::ConstString ScriptInterpreterPython::GetPluginName() {
+lldb_private::ConstString ScriptInterpreterPythonImpl::GetPluginName() {
return GetPluginNameStatic();
}
-uint32_t ScriptInterpreterPython::GetPluginVersion() { return 1; }
+uint32_t ScriptInterpreterPythonImpl::GetPluginVersion() { return 1; }
-void ScriptInterpreterPython::IOHandlerActivated(IOHandler &io_handler) {
+void ScriptInterpreterPythonImpl::IOHandlerActivated(IOHandler &io_handler,
+ bool interactive) {
const char *instructions = nullptr;
switch (m_active_io_handler) {
@@ -451,17 +536,17 @@ def function (frame, bp_loc, internal_dict):
if (instructions) {
StreamFileSP output_sp(io_handler.GetOutputStreamFile());
- if (output_sp) {
+ if (output_sp && interactive) {
output_sp->PutCString(instructions);
output_sp->Flush();
}
}
}
-void ScriptInterpreterPython::IOHandlerInputComplete(IOHandler &io_handler,
- std::string &data) {
+void ScriptInterpreterPythonImpl::IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &data) {
io_handler.SetIsDone(true);
- bool batch_mode = m_interpreter.GetBatchCommandMode();
+ bool batch_mode = m_debugger.GetCommandInterpreter().GetBatchCommandMode();
switch (m_active_io_handler) {
case eIOHandlerNone:
@@ -473,18 +558,18 @@ void ScriptInterpreterPython::IOHandlerInputComplete(IOHandler &io_handler,
if (!bp_options)
continue;
- auto data_ap = llvm::make_unique<CommandDataPython>();
- if (!data_ap)
+ auto data_up = llvm::make_unique<CommandDataPython>();
+ if (!data_up)
break;
- data_ap->user_source.SplitIntoLines(data);
+ data_up->user_source.SplitIntoLines(data);
- if (GenerateBreakpointCommandCallbackData(data_ap->user_source,
- data_ap->script_source)
+ if (GenerateBreakpointCommandCallbackData(data_up->user_source,
+ data_up->script_source)
.Success()) {
auto baton_sp = std::make_shared<BreakpointOptions::CommandBaton>(
- std::move(data_ap));
+ std::move(data_up));
bp_options->SetCallback(
- ScriptInterpreterPython::BreakpointCallbackFunction, baton_sp);
+ ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
} else if (!batch_mode) {
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
if (error_sp) {
@@ -498,15 +583,15 @@ void ScriptInterpreterPython::IOHandlerInputComplete(IOHandler &io_handler,
case eIOHandlerWatchpoint: {
WatchpointOptions *wp_options =
(WatchpointOptions *)io_handler.GetUserData();
- auto data_ap = llvm::make_unique<WatchpointOptions::CommandData>();
- data_ap->user_source.SplitIntoLines(data);
+ auto data_up = llvm::make_unique<WatchpointOptions::CommandData>();
+ data_up->user_source.SplitIntoLines(data);
- if (GenerateWatchpointCommandCallbackData(data_ap->user_source,
- data_ap->script_source)) {
+ if (GenerateWatchpointCommandCallbackData(data_up->user_source,
+ data_up->script_source)) {
auto baton_sp =
- std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_ap));
+ std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_up));
wp_options->SetCallback(
- ScriptInterpreterPython::WatchpointCallbackFunction, baton_sp);
+ ScriptInterpreterPythonImpl::WatchpointCallbackFunction, baton_sp);
} else if (!batch_mode) {
StreamFileSP error_sp = io_handler.GetErrorStreamFile();
if (error_sp) {
@@ -519,9 +604,14 @@ void ScriptInterpreterPython::IOHandlerInputComplete(IOHandler &io_handler,
}
}
-void ScriptInterpreterPython::ResetOutputFileHandle(FILE *fh) {}
+lldb::ScriptInterpreterSP
+ScriptInterpreterPythonImpl::CreateInstance(Debugger &debugger) {
+ return std::make_shared<ScriptInterpreterPythonImpl>(debugger);
+}
-void ScriptInterpreterPython::SaveTerminalState(int fd) {
+void ScriptInterpreterPythonImpl::ResetOutputFileHandle(FILE *fh) {}
+
+void ScriptInterpreterPythonImpl::SaveTerminalState(int fd) {
// Python mucks with the terminal state of STDIN. If we can possibly avoid
// this by setting the file handles up correctly prior to entering the
// interpreter we should. For now we save and restore the terminal state on
@@ -529,7 +619,7 @@ void ScriptInterpreterPython::SaveTerminalState(int fd) {
m_terminal_state.Save(fd, false);
}
-void ScriptInterpreterPython::RestoreTerminalState() {
+void ScriptInterpreterPythonImpl::RestoreTerminalState() {
// Python mucks with the terminal state of STDIN. If we can possibly avoid
// this by setting the file handles up correctly prior to entering the
// interpreter we should. For now we save and restore the terminal state on
@@ -537,10 +627,10 @@ void ScriptInterpreterPython::RestoreTerminalState() {
m_terminal_state.Restore();
}
-void ScriptInterpreterPython::LeaveSession() {
+void ScriptInterpreterPythonImpl::LeaveSession() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
if (log)
- log->PutCString("ScriptInterpreterPython::LeaveSession()");
+ log->PutCString("ScriptInterpreterPythonImpl::LeaveSession()");
// checking that we have a valid thread state - since we use our own
// threading and locking in some (rare) cases during cleanup Python may end
@@ -572,9 +662,9 @@ void ScriptInterpreterPython::LeaveSession() {
m_session_is_active = false;
}
-bool ScriptInterpreterPython::SetStdHandle(File &file, const char *py_name,
- PythonFile &save_file,
- const char *mode) {
+bool ScriptInterpreterPythonImpl::SetStdHandle(File &file, const char *py_name,
+ PythonFile &save_file,
+ const char *mode) {
if (file.IsValid()) {
// Flush the file before giving it to python to avoid interleaved output.
file.Flush();
@@ -592,15 +682,15 @@ bool ScriptInterpreterPython::SetStdHandle(File &file, const char *py_name,
return false;
}
-bool ScriptInterpreterPython::EnterSession(uint16_t on_entry_flags, FILE *in,
- FILE *out, FILE *err) {
+bool ScriptInterpreterPythonImpl::EnterSession(uint16_t on_entry_flags,
+ FILE *in, FILE *out, FILE *err) {
// If we have already entered the session, without having officially 'left'
// it, then there is no need to 'enter' it again.
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
if (m_session_is_active) {
if (log)
log->Printf(
- "ScriptInterpreterPython::EnterSession(on_entry_flags=0x%" PRIx16
+ "ScriptInterpreterPythonImpl::EnterSession(on_entry_flags=0x%" PRIx16
") session is already active, returning without doing anything",
on_entry_flags);
return false;
@@ -608,7 +698,8 @@ bool ScriptInterpreterPython::EnterSession(uint16_t on_entry_flags, FILE *in,
if (log)
log->Printf(
- "ScriptInterpreterPython::EnterSession(on_entry_flags=0x%" PRIx16 ")",
+ "ScriptInterpreterPythonImpl::EnterSession(on_entry_flags=0x%" PRIx16
+ ")",
on_entry_flags);
m_session_is_active = true;
@@ -617,11 +708,10 @@ bool ScriptInterpreterPython::EnterSession(uint16_t on_entry_flags, FILE *in,
if (on_entry_flags & Locker::InitGlobals) {
run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64,
- m_dictionary_name.c_str(),
- GetCommandInterpreter().GetDebugger().GetID());
+ m_dictionary_name.c_str(), m_debugger.GetID());
run_string.Printf(
"; lldb.debugger = lldb.SBDebugger.FindDebuggerWithID (%" PRIu64 ")",
- GetCommandInterpreter().GetDebugger().GetID());
+ m_debugger.GetID());
run_string.PutCString("; lldb.target = lldb.debugger.GetSelectedTarget()");
run_string.PutCString("; lldb.process = lldb.target.GetProcess()");
run_string.PutCString("; lldb.thread = lldb.process.GetSelectedThread ()");
@@ -631,11 +721,10 @@ bool ScriptInterpreterPython::EnterSession(uint16_t on_entry_flags, FILE *in,
// If we aren't initing the globals, we should still always set the
// debugger (since that is always unique.)
run_string.Printf("run_one_line (%s, 'lldb.debugger_unique_id = %" PRIu64,
- m_dictionary_name.c_str(),
- GetCommandInterpreter().GetDebugger().GetID());
+ m_dictionary_name.c_str(), m_debugger.GetID());
run_string.Printf(
"; lldb.debugger = lldb.SBDebugger.FindDebuggerWithID (%" PRIu64 ")",
- GetCommandInterpreter().GetDebugger().GetID());
+ m_debugger.GetID());
run_string.PutCString("')");
}
@@ -652,8 +741,7 @@ bool ScriptInterpreterPython::EnterSession(uint16_t on_entry_flags, FILE *in,
lldb::StreamFileSP out_sp;
lldb::StreamFileSP err_sp;
if (!in_file.IsValid() || !out_file.IsValid() || !err_file.IsValid())
- m_interpreter.GetDebugger().AdoptTopIOHandlerFilesIfInvalid(in_sp, out_sp,
- err_sp);
+ m_debugger.AdoptTopIOHandlerFilesIfInvalid(in_sp, out_sp, err_sp);
if (on_entry_flags & Locker::NoSTDIN) {
m_saved_stdin.Reset();
@@ -681,13 +769,13 @@ bool ScriptInterpreterPython::EnterSession(uint16_t on_entry_flags, FILE *in,
return true;
}
-PythonObject &ScriptInterpreterPython::GetMainModule() {
+PythonObject &ScriptInterpreterPythonImpl::GetMainModule() {
if (!m_main_module.IsValid())
m_main_module.Reset(PyRefType::Borrowed, PyImport_AddModule("__main__"));
return m_main_module;
}
-PythonDictionary &ScriptInterpreterPython::GetSessionDictionary() {
+PythonDictionary &ScriptInterpreterPythonImpl::GetSessionDictionary() {
if (m_session_dict.IsValid())
return m_session_dict;
@@ -705,7 +793,7 @@ PythonDictionary &ScriptInterpreterPython::GetSessionDictionary() {
return m_session_dict;
}
-PythonDictionary &ScriptInterpreterPython::GetSysModuleDictionary() {
+PythonDictionary &ScriptInterpreterPythonImpl::GetSysModuleDictionary() {
if (m_sys_module_dict.IsValid())
return m_sys_module_dict;
@@ -732,7 +820,7 @@ static std::string GenerateUniqueName(const char *base_name_wanted,
return sstr.GetString();
}
-bool ScriptInterpreterPython::GetEmbeddedInterpreterModuleObjects() {
+bool ScriptInterpreterPythonImpl::GetEmbeddedInterpreterModuleObjects() {
if (m_run_one_line_function.IsValid())
return true;
@@ -762,7 +850,7 @@ static void ReadThreadBytesReceived(void *baton, const void *src,
}
}
-bool ScriptInterpreterPython::ExecuteOneLine(
+bool ScriptInterpreterPythonImpl::ExecuteOneLine(
llvm::StringRef command, CommandReturnObject *result,
const ExecuteScriptOptions &options) {
std::string command_str = command.str();
@@ -777,13 +865,13 @@ bool ScriptInterpreterPython::ExecuteOneLine(
// another string to pass to PyRun_SimpleString messes up the escaping. So
// we use the following more complicated method to pass the command string
// directly down to Python.
- Debugger &debugger = m_interpreter.GetDebugger();
+ Debugger &debugger = m_debugger;
StreamFileSP input_file_sp;
StreamFileSP output_file_sp;
StreamFileSP error_file_sp;
Communication output_comm(
- "lldb.ScriptInterpreterPython.ExecuteOneLine.comm");
+ "lldb.ScriptInterpreterPythonImpl.ExecuteOneLine.comm");
bool join_read_thread = false;
if (options.GetEnableIO()) {
if (result) {
@@ -797,22 +885,22 @@ bool ScriptInterpreterPython::ExecuteOneLine(
#if defined(_WIN32)
lldb::file_t read_file = pipe.GetReadNativeHandle();
pipe.ReleaseReadFileDescriptor();
- std::unique_ptr<ConnectionGenericFile> conn_ap(
+ std::unique_ptr<ConnectionGenericFile> conn_up(
new ConnectionGenericFile(read_file, true));
#else
- std::unique_ptr<ConnectionFileDescriptor> conn_ap(
+ std::unique_ptr<ConnectionFileDescriptor> conn_up(
new ConnectionFileDescriptor(pipe.ReleaseReadFileDescriptor(),
true));
#endif
- if (conn_ap->IsConnected()) {
- output_comm.SetConnection(conn_ap.release());
+ if (conn_up->IsConnected()) {
+ output_comm.SetConnection(conn_up.release());
output_comm.SetReadThreadBytesReceivedCallback(
ReadThreadBytesReceived, &result->GetOutputStream());
output_comm.StartReadThread();
join_read_thread = true;
FILE *outfile_handle =
fdopen(pipe.ReleaseWriteFileDescriptor(), "w");
- output_file_sp.reset(new StreamFile(outfile_handle, true));
+ output_file_sp = std::make_shared<StreamFile>(outfile_handle, true);
error_file_sp = output_file_sp;
if (outfile_handle)
::setbuf(outfile_handle, nullptr);
@@ -828,12 +916,12 @@ bool ScriptInterpreterPython::ExecuteOneLine(
debugger.AdoptTopIOHandlerFilesIfInvalid(input_file_sp, output_file_sp,
error_file_sp);
} else {
- input_file_sp.reset(new StreamFile());
+ input_file_sp = std::make_shared<StreamFile>();
FileSystem::Instance().Open(input_file_sp->GetFile(),
FileSpec(FileSystem::DEV_NULL),
File::eOpenOptionRead);
- output_file_sp.reset(new StreamFile());
+ output_file_sp = std::make_shared<StreamFile>();
FileSystem::Instance().Open(output_file_sp->GetFile(),
FileSpec(FileSystem::DEV_NULL),
File::eOpenOptionWrite);
@@ -856,15 +944,11 @@ bool ScriptInterpreterPython::ExecuteOneLine(
// happen.
Locker locker(
this,
- ScriptInterpreterPython::Locker::AcquireLock |
- ScriptInterpreterPython::Locker::InitSession |
- (options.GetSetLLDBGlobals()
- ? ScriptInterpreterPython::Locker::InitGlobals
- : 0) |
+ Locker::AcquireLock | Locker::InitSession |
+ (options.GetSetLLDBGlobals() ? Locker::InitGlobals : 0) |
((result && result->GetInteractive()) ? 0 : Locker::NoSTDIN),
- ScriptInterpreterPython::Locker::FreeAcquiredLock |
- ScriptInterpreterPython::Locker::TearDownSession,
- in_file, out_file, err_file);
+ Locker::FreeAcquiredLock | Locker::TearDownSession, in_file, out_file,
+ err_file);
// Find the correct script interpreter dictionary in the main module.
PythonDictionary &session_dict = GetSessionDictionary();
@@ -924,82 +1008,11 @@ bool ScriptInterpreterPython::ExecuteOneLine(
return false;
}
-class IOHandlerPythonInterpreter : public IOHandler {
-public:
- IOHandlerPythonInterpreter(Debugger &debugger,
- ScriptInterpreterPython *python)
- : IOHandler(debugger, IOHandler::Type::PythonInterpreter),
- m_python(python) {}
-
- ~IOHandlerPythonInterpreter() override {}
-
- ConstString GetControlSequence(char ch) override {
- if (ch == 'd')
- return ConstString("quit()\n");
- return ConstString();
- }
-
- void Run() override {
- if (m_python) {
- int stdin_fd = GetInputFD();
- if (stdin_fd >= 0) {
- Terminal terminal(stdin_fd);
- TerminalState terminal_state;
- const bool is_a_tty = terminal.IsATerminal();
-
- if (is_a_tty) {
- terminal_state.Save(stdin_fd, false);
- terminal.SetCanonical(false);
- terminal.SetEcho(true);
- }
-
- ScriptInterpreterPython::Locker locker(
- m_python, ScriptInterpreterPython::Locker::AcquireLock |
- ScriptInterpreterPython::Locker::InitSession |
- ScriptInterpreterPython::Locker::InitGlobals,
- ScriptInterpreterPython::Locker::FreeAcquiredLock |
- ScriptInterpreterPython::Locker::TearDownSession);
-
- // The following call drops into the embedded interpreter loop and
- // stays there until the user chooses to exit from the Python
- // interpreter. This embedded interpreter will, as any Python code that
- // performs I/O, unlock the GIL before a system call that can hang, and
- // lock it when the syscall has returned.
-
- // We need to surround the call to the embedded interpreter with calls
- // to PyGILState_Ensure and PyGILState_Release (using the Locker
- // above). This is because Python has a global lock which must be held
- // whenever we want to touch any Python objects. Otherwise, if the user
- // calls Python code, the interpreter state will be off, and things
- // could hang (it's happened before).
-
- StreamString run_string;
- run_string.Printf("run_python_interpreter (%s)",
- m_python->GetDictionaryName());
- PyRun_SimpleString(run_string.GetData());
-
- if (is_a_tty)
- terminal_state.Restore();
- }
- }
- SetIsDone(true);
- }
-
- void Cancel() override {}
-
- bool Interrupt() override { return m_python->Interrupt(); }
-
- void GotEOF() override {}
-
-protected:
- ScriptInterpreterPython *m_python;
-};
-
-void ScriptInterpreterPython::ExecuteInterpreterLoop() {
+void ScriptInterpreterPythonImpl::ExecuteInterpreterLoop() {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
- Debugger &debugger = GetCommandInterpreter().GetDebugger();
+ Debugger &debugger = m_debugger;
// At the moment, the only time the debugger does not have an input file
// handle is when this is called directly from Python, in which case it is
@@ -1016,7 +1029,7 @@ void ScriptInterpreterPython::ExecuteInterpreterLoop() {
}
}
-bool ScriptInterpreterPython::Interrupt() {
+bool ScriptInterpreterPythonImpl::Interrupt() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_SCRIPT));
if (IsExecutingPython()) {
@@ -1028,29 +1041,27 @@ bool ScriptInterpreterPython::Interrupt() {
PyThreadState_Swap(state);
int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);
if (log)
- log->Printf("ScriptInterpreterPython::Interrupt() sending "
+ log->Printf("ScriptInterpreterPythonImpl::Interrupt() sending "
"PyExc_KeyboardInterrupt (tid = %li, num_threads = %i)...",
tid, num_threads);
return true;
}
}
if (log)
- log->Printf("ScriptInterpreterPython::Interrupt() python code not running, "
- "can't interrupt");
+ log->Printf(
+ "ScriptInterpreterPythonImpl::Interrupt() python code not running, "
+ "can't interrupt");
return false;
}
-bool ScriptInterpreterPython::ExecuteOneLineWithReturn(
+bool ScriptInterpreterPythonImpl::ExecuteOneLineWithReturn(
llvm::StringRef in_string, ScriptInterpreter::ScriptReturnType return_type,
void *ret_value, const ExecuteScriptOptions &options) {
- Locker locker(this, ScriptInterpreterPython::Locker::AcquireLock |
- ScriptInterpreterPython::Locker::InitSession |
- (options.GetSetLLDBGlobals()
- ? ScriptInterpreterPython::Locker::InitGlobals
- : 0) |
- Locker::NoSTDIN,
- ScriptInterpreterPython::Locker::FreeAcquiredLock |
- ScriptInterpreterPython::Locker::TearDownSession);
+ Locker locker(this,
+ Locker::AcquireLock | Locker::InitSession |
+ (options.GetSetLLDBGlobals() ? Locker::InitGlobals : 0) |
+ Locker::NoSTDIN,
+ Locker::FreeAcquiredLock | Locker::TearDownSession);
PythonObject py_return;
PythonObject &main_module = GetMainModule();
@@ -1195,18 +1206,15 @@ bool ScriptInterpreterPython::ExecuteOneLineWithReturn(
return ret_success;
}
-Status ScriptInterpreterPython::ExecuteMultipleLines(
+Status ScriptInterpreterPythonImpl::ExecuteMultipleLines(
const char *in_string, const ExecuteScriptOptions &options) {
Status error;
- Locker locker(this, ScriptInterpreterPython::Locker::AcquireLock |
- ScriptInterpreterPython::Locker::InitSession |
- (options.GetSetLLDBGlobals()
- ? ScriptInterpreterPython::Locker::InitGlobals
- : 0) |
- Locker::NoSTDIN,
- ScriptInterpreterPython::Locker::FreeAcquiredLock |
- ScriptInterpreterPython::Locker::TearDownSession);
+ Locker locker(this,
+ Locker::AcquireLock | Locker::InitSession |
+ (options.GetSetLLDBGlobals() ? Locker::InitGlobals : 0) |
+ Locker::NoSTDIN,
+ Locker::FreeAcquiredLock | Locker::TearDownSession);
PythonObject return_value;
PythonObject &main_module = GetMainModule();
@@ -1256,31 +1264,32 @@ Status ScriptInterpreterPython::ExecuteMultipleLines(
return error;
}
-void ScriptInterpreterPython::CollectDataForBreakpointCommandCallback(
+void ScriptInterpreterPythonImpl::CollectDataForBreakpointCommandCallback(
std::vector<BreakpointOptions *> &bp_options_vec,
CommandReturnObject &result) {
m_active_io_handler = eIOHandlerBreakpoint;
- m_interpreter.GetPythonCommandsFromIOHandler(" ", *this, true,
- &bp_options_vec);
+ m_debugger.GetCommandInterpreter().GetPythonCommandsFromIOHandler(
+ " ", *this, true, &bp_options_vec);
}
-void ScriptInterpreterPython::CollectDataForWatchpointCommandCallback(
+void ScriptInterpreterPythonImpl::CollectDataForWatchpointCommandCallback(
WatchpointOptions *wp_options, CommandReturnObject &result) {
m_active_io_handler = eIOHandlerWatchpoint;
- m_interpreter.GetPythonCommandsFromIOHandler(" ", *this, true, wp_options);
+ m_debugger.GetCommandInterpreter().GetPythonCommandsFromIOHandler(
+ " ", *this, true, wp_options);
}
-void ScriptInterpreterPython::SetBreakpointCommandCallbackFunction(
+void ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction(
BreakpointOptions *bp_options, const char *function_name) {
// For now just cons up a oneliner that calls the provided function.
std::string oneliner("return ");
oneliner += function_name;
oneliner += "(frame, bp_loc, internal_dict)";
- m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback(
+ m_debugger.GetScriptInterpreter()->SetBreakpointCommandCallback(
bp_options, oneliner.c_str());
}
-Status ScriptInterpreterPython::SetBreakpointCommandCallback(
+Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
BreakpointOptions *bp_options,
std::unique_ptr<BreakpointOptions::CommandData> &cmd_data_up) {
Status error;
@@ -1291,59 +1300,59 @@ Status ScriptInterpreterPython::SetBreakpointCommandCallback(
}
auto baton_sp =
std::make_shared<BreakpointOptions::CommandBaton>(std::move(cmd_data_up));
- bp_options->SetCallback(ScriptInterpreterPython::BreakpointCallbackFunction,
- baton_sp);
+ bp_options->SetCallback(
+ ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
return error;
}
// Set a Python one-liner as the callback for the breakpoint.
-Status ScriptInterpreterPython::SetBreakpointCommandCallback(
+Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
BreakpointOptions *bp_options, const char *command_body_text) {
- auto data_ap = llvm::make_unique<CommandDataPython>();
+ auto data_up = llvm::make_unique<CommandDataPython>();
// Split the command_body_text into lines, and pass that to
// GenerateBreakpointCommandCallbackData. That will wrap the body in an
// auto-generated function, and return the function name in script_source.
// That is what the callback will actually invoke.
- data_ap->user_source.SplitIntoLines(command_body_text);
- Status error = GenerateBreakpointCommandCallbackData(data_ap->user_source,
- data_ap->script_source);
+ data_up->user_source.SplitIntoLines(command_body_text);
+ Status error = GenerateBreakpointCommandCallbackData(data_up->user_source,
+ data_up->script_source);
if (error.Success()) {
auto baton_sp =
- std::make_shared<BreakpointOptions::CommandBaton>(std::move(data_ap));
- bp_options->SetCallback(ScriptInterpreterPython::BreakpointCallbackFunction,
- baton_sp);
+ std::make_shared<BreakpointOptions::CommandBaton>(std::move(data_up));
+ bp_options->SetCallback(
+ ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
return error;
} else
return error;
}
// Set a Python one-liner as the callback for the watchpoint.
-void ScriptInterpreterPython::SetWatchpointCommandCallback(
+void ScriptInterpreterPythonImpl::SetWatchpointCommandCallback(
WatchpointOptions *wp_options, const char *oneliner) {
- auto data_ap = llvm::make_unique<WatchpointOptions::CommandData>();
+ auto data_up = llvm::make_unique<WatchpointOptions::CommandData>();
// It's necessary to set both user_source and script_source to the oneliner.
// The former is used to generate callback description (as in watchpoint
// command list) while the latter is used for Python to interpret during the
// actual callback.
- data_ap->user_source.AppendString(oneliner);
- data_ap->script_source.assign(oneliner);
+ data_up->user_source.AppendString(oneliner);
+ data_up->script_source.assign(oneliner);
- if (GenerateWatchpointCommandCallbackData(data_ap->user_source,
- data_ap->script_source)) {
+ if (GenerateWatchpointCommandCallbackData(data_up->user_source,
+ data_up->script_source)) {
auto baton_sp =
- std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_ap));
- wp_options->SetCallback(ScriptInterpreterPython::WatchpointCallbackFunction,
- baton_sp);
+ std::make_shared<WatchpointOptions::CommandBaton>(std::move(data_up));
+ wp_options->SetCallback(
+ ScriptInterpreterPythonImpl::WatchpointCallbackFunction, baton_sp);
}
return;
}
-Status ScriptInterpreterPython::ExportFunctionDefinitionToInterpreter(
+Status ScriptInterpreterPythonImpl::ExportFunctionDefinitionToInterpreter(
StringList &function_def) {
// Convert StringList to one long, newline delimited, const char *.
std::string function_def_string(function_def.CopyList());
@@ -1354,8 +1363,8 @@ Status ScriptInterpreterPython::ExportFunctionDefinitionToInterpreter(
return error;
}
-Status ScriptInterpreterPython::GenerateFunction(const char *signature,
- const StringList &input) {
+Status ScriptInterpreterPythonImpl::GenerateFunction(const char *signature,
+ const StringList &input) {
Status error;
int num_lines = input.GetSize();
if (num_lines == 0) {
@@ -1411,7 +1420,7 @@ Status ScriptInterpreterPython::GenerateFunction(const char *signature,
return error;
}
-bool ScriptInterpreterPython::GenerateTypeScriptFunction(
+bool ScriptInterpreterPythonImpl::GenerateTypeScriptFunction(
StringList &user_input, std::string &output, const void *name_token) {
static uint32_t num_created_functions = 0;
user_input.RemoveBlankLines();
@@ -1438,7 +1447,7 @@ bool ScriptInterpreterPython::GenerateTypeScriptFunction(
return true;
}
-bool ScriptInterpreterPython::GenerateScriptAliasFunction(
+bool ScriptInterpreterPythonImpl::GenerateScriptAliasFunction(
StringList &user_input, std::string &output) {
static uint32_t num_created_functions = 0;
user_input.RemoveBlankLines();
@@ -1462,9 +1471,8 @@ bool ScriptInterpreterPython::GenerateScriptAliasFunction(
return true;
}
-bool ScriptInterpreterPython::GenerateTypeSynthClass(StringList &user_input,
- std::string &output,
- const void *name_token) {
+bool ScriptInterpreterPythonImpl::GenerateTypeSynthClass(
+ StringList &user_input, std::string &output, const void *name_token) {
static uint32_t num_created_classes = 0;
user_input.RemoveBlankLines();
int num_lines = user_input.GetSize();
@@ -1507,8 +1515,8 @@ bool ScriptInterpreterPython::GenerateTypeSynthClass(StringList &user_input,
return true;
}
-StructuredData::GenericSP ScriptInterpreterPython::CreateFrameRecognizer(
- const char *class_name) {
+StructuredData::GenericSP
+ScriptInterpreterPythonImpl::CreateFrameRecognizer(const char *class_name) {
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::GenericSP();
@@ -1517,31 +1525,34 @@ StructuredData::GenericSP ScriptInterpreterPython::CreateFrameRecognizer(
{
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);
- ret_val =
- g_swig_create_frame_recognizer(class_name, m_dictionary_name.c_str());
+ ret_val = LLDBSWIGPython_CreateFrameRecognizer(class_name,
+ m_dictionary_name.c_str());
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
}
-lldb::ValueObjectListSP ScriptInterpreterPython::GetRecognizedArguments(
+lldb::ValueObjectListSP ScriptInterpreterPythonImpl::GetRecognizedArguments(
const StructuredData::ObjectSP &os_plugin_object_sp,
lldb::StackFrameSP frame_sp) {
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
- if (!os_plugin_object_sp) return ValueObjectListSP();
+ if (!os_plugin_object_sp)
+ return ValueObjectListSP();
StructuredData::Generic *generic = os_plugin_object_sp->GetAsGeneric();
- if (!generic) return nullptr;
+ if (!generic)
+ return nullptr;
PythonObject implementor(PyRefType::Borrowed,
(PyObject *)generic->GetValue());
- if (!implementor.IsAllocated()) return ValueObjectListSP();
+ if (!implementor.IsAllocated())
+ return ValueObjectListSP();
- PythonObject py_return(
- PyRefType::Owned,
- (PyObject *)g_swig_get_recognized_arguments(implementor.get(), frame_sp));
+ PythonObject py_return(PyRefType::Owned,
+ (PyObject *)LLDBSwigPython_GetRecognizedArguments(
+ implementor.get(), frame_sp));
// if it fails, print the error but otherwise go on
if (PyErr_Occurred()) {
@@ -1554,16 +1565,18 @@ lldb::ValueObjectListSP ScriptInterpreterPython::GetRecognizedArguments(
for (size_t i = 0; i < result_list.GetSize(); i++) {
PyObject *item = result_list.GetItemAtIndex(i).get();
lldb::SBValue *sb_value_ptr =
- (lldb::SBValue *)g_swig_cast_to_sbvalue(item);
- auto valobj_sp = g_swig_get_valobj_sp_from_sbvalue(sb_value_ptr);
- if (valobj_sp) result->Append(valobj_sp);
+ (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(item);
+ auto valobj_sp = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr);
+ if (valobj_sp)
+ result->Append(valobj_sp);
}
return result;
}
return ValueObjectListSP();
}
-StructuredData::GenericSP ScriptInterpreterPython::OSPlugin_CreatePluginObject(
+StructuredData::GenericSP
+ScriptInterpreterPythonImpl::OSPlugin_CreatePluginObject(
const char *class_name, lldb::ProcessSP process_sp) {
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::GenericSP();
@@ -1576,14 +1589,14 @@ StructuredData::GenericSP ScriptInterpreterPython::OSPlugin_CreatePluginObject(
{
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN,
Locker::FreeLock);
- ret_val = g_swig_create_os_plugin(class_name, m_dictionary_name.c_str(),
- process_sp);
+ ret_val = LLDBSWIGPythonCreateOSPlugin(
+ class_name, m_dictionary_name.c_str(), process_sp);
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
}
-StructuredData::DictionarySP ScriptInterpreterPython::OSPlugin_RegisterInfo(
+StructuredData::DictionarySP ScriptInterpreterPythonImpl::OSPlugin_RegisterInfo(
StructuredData::ObjectSP os_plugin_object_sp) {
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
@@ -1638,7 +1651,7 @@ StructuredData::DictionarySP ScriptInterpreterPython::OSPlugin_RegisterInfo(
return StructuredData::DictionarySP();
}
-StructuredData::ArraySP ScriptInterpreterPython::OSPlugin_ThreadsInfo(
+StructuredData::ArraySP ScriptInterpreterPythonImpl::OSPlugin_ThreadsInfo(
StructuredData::ObjectSP os_plugin_object_sp) {
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
@@ -1723,7 +1736,8 @@ template <> const char *GetPythonValueFormatString(unsigned long long) {
template <> const char *GetPythonValueFormatString(float t) { return "f"; }
template <> const char *GetPythonValueFormatString(double t) { return "d"; }
-StructuredData::StringSP ScriptInterpreterPython::OSPlugin_RegisterContextData(
+StructuredData::StringSP
+ScriptInterpreterPythonImpl::OSPlugin_RegisterContextData(
StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid) {
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
@@ -1779,7 +1793,7 @@ StructuredData::StringSP ScriptInterpreterPython::OSPlugin_RegisterContextData(
return StructuredData::StringSP();
}
-StructuredData::DictionarySP ScriptInterpreterPython::OSPlugin_CreateThread(
+StructuredData::DictionarySP ScriptInterpreterPythonImpl::OSPlugin_CreateThread(
StructuredData::ObjectSP os_plugin_object_sp, lldb::tid_t tid,
lldb::addr_t context) {
Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
@@ -1838,7 +1852,7 @@ StructuredData::DictionarySP ScriptInterpreterPython::OSPlugin_CreateThread(
return StructuredData::DictionarySP();
}
-StructuredData::ObjectSP ScriptInterpreterPython::CreateScriptedThreadPlan(
+StructuredData::ObjectSP ScriptInterpreterPythonImpl::CreateScriptedThreadPlan(
const char *class_name, lldb::ThreadPlanSP thread_plan_sp) {
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::ObjectSP();
@@ -1847,10 +1861,9 @@ StructuredData::ObjectSP ScriptInterpreterPython::CreateScriptedThreadPlan(
return StructuredData::ObjectSP();
Debugger &debugger = thread_plan_sp->GetTarget().GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
- ScriptInterpreterPython *python_interpreter =
- static_cast<ScriptInterpreterPython *>(script_interpreter);
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
+ ScriptInterpreterPythonImpl *python_interpreter =
+ static_cast<ScriptInterpreterPythonImpl *>(script_interpreter);
if (!script_interpreter)
return StructuredData::ObjectSP();
@@ -1861,7 +1874,7 @@ StructuredData::ObjectSP ScriptInterpreterPython::CreateScriptedThreadPlan(
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_thread_plan_script(
+ ret_val = LLDBSwigPythonCreateScriptedThreadPlan(
class_name, python_interpreter->m_dictionary_name.c_str(),
thread_plan_sp);
}
@@ -1869,7 +1882,7 @@ StructuredData::ObjectSP ScriptInterpreterPython::CreateScriptedThreadPlan(
return StructuredData::ObjectSP(new StructuredPythonObject(ret_val));
}
-bool ScriptInterpreterPython::ScriptedThreadPlanExplainsStop(
+bool ScriptInterpreterPythonImpl::ScriptedThreadPlanExplainsStop(
StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) {
bool explains_stop = true;
StructuredData::Generic *generic = nullptr;
@@ -1878,7 +1891,7 @@ bool ScriptInterpreterPython::ScriptedThreadPlanExplainsStop(
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- explains_stop = g_swig_call_thread_plan(
+ explains_stop = LLDBSWIGPythonCallThreadPlan(
generic->GetValue(), "explains_stop", event, script_error);
if (script_error)
return true;
@@ -1886,7 +1899,7 @@ bool ScriptInterpreterPython::ScriptedThreadPlanExplainsStop(
return explains_stop;
}
-bool ScriptInterpreterPython::ScriptedThreadPlanShouldStop(
+bool ScriptInterpreterPythonImpl::ScriptedThreadPlanShouldStop(
StructuredData::ObjectSP implementor_sp, Event *event, bool &script_error) {
bool should_stop = true;
StructuredData::Generic *generic = nullptr;
@@ -1895,15 +1908,15 @@ bool ScriptInterpreterPython::ScriptedThreadPlanShouldStop(
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_stop = g_swig_call_thread_plan(generic->GetValue(), "should_stop",
- event, script_error);
+ should_stop = LLDBSWIGPythonCallThreadPlan(
+ generic->GetValue(), "should_stop", event, script_error);
if (script_error)
return true;
}
return should_stop;
}
-bool ScriptInterpreterPython::ScriptedThreadPlanIsStale(
+bool ScriptInterpreterPythonImpl::ScriptedThreadPlanIsStale(
StructuredData::ObjectSP implementor_sp, bool &script_error) {
bool is_stale = true;
StructuredData::Generic *generic = nullptr;
@@ -1912,15 +1925,15 @@ bool ScriptInterpreterPython::ScriptedThreadPlanIsStale(
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- is_stale = g_swig_call_thread_plan(generic->GetValue(), "is_stale", nullptr,
- script_error);
+ is_stale = LLDBSWIGPythonCallThreadPlan(generic->GetValue(), "is_stale",
+ nullptr, script_error);
if (script_error)
return true;
}
return is_stale;
}
-lldb::StateType ScriptInterpreterPython::ScriptedThreadPlanGetRunState(
+lldb::StateType ScriptInterpreterPythonImpl::ScriptedThreadPlanGetRunState(
StructuredData::ObjectSP implementor_sp, bool &script_error) {
bool should_step = false;
StructuredData::Generic *generic = nullptr;
@@ -1929,8 +1942,8 @@ lldb::StateType ScriptInterpreterPython::ScriptedThreadPlanGetRunState(
if (generic) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_step = g_swig_call_thread_plan(generic->GetValue(), "should_step",
- NULL, script_error);
+ should_step = LLDBSWIGPythonCallThreadPlan(
+ generic->GetValue(), "should_step", nullptr, script_error);
if (script_error)
should_step = true;
}
@@ -1941,11 +1954,10 @@ lldb::StateType ScriptInterpreterPython::ScriptedThreadPlanGetRunState(
}
StructuredData::GenericSP
-ScriptInterpreterPython::CreateScriptedBreakpointResolver(
- const char *class_name,
- StructuredDataImpl *args_data,
+ScriptInterpreterPythonImpl::CreateScriptedBreakpointResolver(
+ const char *class_name, StructuredDataImpl *args_data,
lldb::BreakpointSP &bkpt_sp) {
-
+
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::GenericSP();
@@ -1953,10 +1965,9 @@ ScriptInterpreterPython::CreateScriptedBreakpointResolver(
return StructuredData::GenericSP();
Debugger &debugger = bkpt_sp->GetTarget().GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
- ScriptInterpreterPython *python_interpreter =
- static_cast<ScriptInterpreterPython *>(script_interpreter);
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
+ ScriptInterpreterPythonImpl *python_interpreter =
+ static_cast<ScriptInterpreterPythonImpl *>(script_interpreter);
if (!script_interpreter)
return StructuredData::GenericSP();
@@ -1967,26 +1978,23 @@ ScriptInterpreterPython::CreateScriptedBreakpointResolver(
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_bkpt_resolver_script(
- class_name, python_interpreter->m_dictionary_name.c_str(),
- args_data, bkpt_sp);
+ ret_val = LLDBSwigPythonCreateScriptedBreakpointResolver(
+ class_name, python_interpreter->m_dictionary_name.c_str(), args_data,
+ bkpt_sp);
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
}
-bool
-ScriptInterpreterPython::ScriptedBreakpointResolverSearchCallback(
- StructuredData::GenericSP implementor_sp,
- SymbolContext *sym_ctx) {
+bool ScriptInterpreterPythonImpl::ScriptedBreakpointResolverSearchCallback(
+ StructuredData::GenericSP implementor_sp, SymbolContext *sym_ctx) {
bool should_continue = false;
-
+
if (implementor_sp) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- should_continue
- = g_swig_call_bkpt_resolver(implementor_sp->GetValue(), "__callback__",
- sym_ctx);
+ should_continue = LLDBSwigPythonCallBreakpointResolver(
+ implementor_sp->GetValue(), "__callback__", sym_ctx);
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
@@ -1996,14 +2004,14 @@ ScriptInterpreterPython::ScriptedBreakpointResolverSearchCallback(
}
lldb::SearchDepth
-ScriptInterpreterPython::ScriptedBreakpointResolverSearchDepth(
+ScriptInterpreterPythonImpl::ScriptedBreakpointResolverSearchDepth(
StructuredData::GenericSP implementor_sp) {
int depth_as_int = lldb::eSearchDepthModule;
if (implementor_sp) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- depth_as_int
- = g_swig_call_bkpt_resolver(implementor_sp->GetValue(), "__get_depth__", nullptr);
+ depth_as_int = LLDBSwigPythonCallBreakpointResolver(
+ implementor_sp->GetValue(), "__get_depth__", nullptr);
if (PyErr_Occurred()) {
PyErr_Print();
PyErr_Clear();
@@ -2013,14 +2021,14 @@ ScriptInterpreterPython::ScriptedBreakpointResolverSearchDepth(
return lldb::eSearchDepthModule;
if (depth_as_int <= lldb::kLastSearchDepthKind)
- return (lldb::SearchDepth) depth_as_int;
+ return (lldb::SearchDepth)depth_as_int;
else
return lldb::eSearchDepthModule;
}
StructuredData::ObjectSP
-ScriptInterpreterPython::LoadPluginModule(const FileSpec &file_spec,
- lldb_private::Status &error) {
+ScriptInterpreterPythonImpl::LoadPluginModule(const FileSpec &file_spec,
+ lldb_private::Status &error) {
if (!FileSystem::Instance().Exists(file_spec)) {
error.SetErrorString("no such file");
return StructuredData::ObjectSP();
@@ -2035,11 +2043,10 @@ ScriptInterpreterPython::LoadPluginModule(const FileSpec &file_spec,
return StructuredData::ObjectSP();
}
-StructuredData::DictionarySP ScriptInterpreterPython::GetDynamicSettings(
+StructuredData::DictionarySP ScriptInterpreterPythonImpl::GetDynamicSettings(
StructuredData::ObjectSP plugin_module_sp, Target *target,
const char *setting_name, lldb_private::Status &error) {
- if (!plugin_module_sp || !target || !setting_name || !setting_name[0] ||
- !g_swig_plugin_get)
+ if (!plugin_module_sp || !target || !setting_name || !setting_name[0])
return StructuredData::DictionarySP();
StructuredData::Generic *generic = plugin_module_sp->GetAsGeneric();
if (!generic)
@@ -2050,15 +2057,15 @@ StructuredData::DictionarySP ScriptInterpreterPython::GetDynamicSettings(
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
TargetSP target_sp(target->shared_from_this());
reply_pyobj.Reset(PyRefType::Owned,
- (PyObject *)g_swig_plugin_get(generic->GetValue(),
- setting_name, target_sp));
+ (PyObject *)LLDBSWIGPython_GetDynamicSetting(
+ generic->GetValue(), setting_name, target_sp));
PythonDictionary py_dict(PyRefType::Borrowed, reply_pyobj.get());
return py_dict.CreateStructuredDictionary();
}
StructuredData::ObjectSP
-ScriptInterpreterPython::CreateSyntheticScriptedProvider(
+ScriptInterpreterPythonImpl::CreateSyntheticScriptedProvider(
const char *class_name, lldb::ValueObjectSP valobj) {
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::ObjectSP();
@@ -2073,10 +2080,9 @@ ScriptInterpreterPython::CreateSyntheticScriptedProvider(
return StructuredData::ObjectSP();
Debugger &debugger = target->GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
- ScriptInterpreterPython *python_interpreter =
- (ScriptInterpreterPython *)script_interpreter;
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
+ ScriptInterpreterPythonImpl *python_interpreter =
+ (ScriptInterpreterPythonImpl *)script_interpreter;
if (!script_interpreter)
return StructuredData::ObjectSP();
@@ -2086,7 +2092,7 @@ ScriptInterpreterPython::CreateSyntheticScriptedProvider(
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_synthetic_script(
+ ret_val = LLDBSwigPythonCreateSyntheticProvider(
class_name, python_interpreter->m_dictionary_name.c_str(), valobj);
}
@@ -2094,9 +2100,8 @@ ScriptInterpreterPython::CreateSyntheticScriptedProvider(
}
StructuredData::GenericSP
-ScriptInterpreterPython::CreateScriptCommandObject(const char *class_name) {
- DebuggerSP debugger_sp(
- GetCommandInterpreter().GetDebugger().shared_from_this());
+ScriptInterpreterPythonImpl::CreateScriptCommandObject(const char *class_name) {
+ DebuggerSP debugger_sp(m_debugger.shared_from_this());
if (class_name == nullptr || class_name[0] == '\0')
return StructuredData::GenericSP();
@@ -2109,29 +2114,28 @@ ScriptInterpreterPython::CreateScriptCommandObject(const char *class_name) {
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val =
- g_swig_create_cmd(class_name, m_dictionary_name.c_str(), debugger_sp);
+ ret_val = LLDBSwigPythonCreateCommandObject(
+ class_name, m_dictionary_name.c_str(), debugger_sp);
}
return StructuredData::GenericSP(new StructuredPythonObject(ret_val));
}
-bool ScriptInterpreterPython::GenerateTypeScriptFunction(
+bool ScriptInterpreterPythonImpl::GenerateTypeScriptFunction(
const char *oneliner, std::string &output, const void *name_token) {
StringList input;
input.SplitIntoLines(oneliner, strlen(oneliner));
return GenerateTypeScriptFunction(input, output, name_token);
}
-bool ScriptInterpreterPython::GenerateTypeSynthClass(const char *oneliner,
- std::string &output,
- const void *name_token) {
+bool ScriptInterpreterPythonImpl::GenerateTypeSynthClass(
+ const char *oneliner, std::string &output, const void *name_token) {
StringList input;
input.SplitIntoLines(oneliner, strlen(oneliner));
return GenerateTypeSynthClass(input, output, name_token);
}
-Status ScriptInterpreterPython::GenerateBreakpointCommandCallbackData(
+Status ScriptInterpreterPythonImpl::GenerateBreakpointCommandCallbackData(
StringList &user_input, std::string &output) {
static uint32_t num_created_functions = 0;
user_input.RemoveBlankLines();
@@ -2156,7 +2160,7 @@ Status ScriptInterpreterPython::GenerateBreakpointCommandCallbackData(
return error;
}
-bool ScriptInterpreterPython::GenerateWatchpointCommandCallbackData(
+bool ScriptInterpreterPythonImpl::GenerateWatchpointCommandCallbackData(
StringList &user_input, std::string &output) {
static uint32_t num_created_functions = 0;
user_input.RemoveBlankLines();
@@ -2178,7 +2182,7 @@ bool ScriptInterpreterPython::GenerateWatchpointCommandCallbackData(
return true;
}
-bool ScriptInterpreterPython::GetScriptedSummary(
+bool ScriptInterpreterPythonImpl::GetScriptedSummary(
const char *python_function_name, lldb::ValueObjectSP valobj,
StructuredData::ObjectSP &callee_wrapper_sp,
const TypeSummaryOptions &options, std::string &retval) {
@@ -2208,9 +2212,9 @@ bool ScriptInterpreterPython::GetScriptedSummary(
{
TypeSummaryOptionsSP options_sp(new TypeSummaryOptions(options));
- static Timer::Category func_cat("g_swig_typescript_callback");
- Timer scoped_timer(func_cat, "g_swig_typescript_callback");
- ret_val = g_swig_typescript_callback(
+ static Timer::Category func_cat("LLDBSwigPythonCallTypeScript");
+ Timer scoped_timer(func_cat, "LLDBSwigPythonCallTypeScript");
+ ret_val = LLDBSwigPythonCallTypeScript(
python_function_name, GetSessionDictionary().get(), valobj,
&new_callee, options_sp, retval);
}
@@ -2221,16 +2225,15 @@ bool ScriptInterpreterPython::GetScriptedSummary(
}
if (new_callee && old_callee != new_callee)
- callee_wrapper_sp.reset(new StructuredPythonObject(new_callee));
+ callee_wrapper_sp = std::make_shared<StructuredPythonObject>(new_callee);
return ret_val;
}
-void ScriptInterpreterPython::Clear() {
+void ScriptInterpreterPythonImpl::Clear() {
// Release any global variables that might have strong references to
// LLDB objects when clearing the python script interpreter.
- Locker locker(this, ScriptInterpreterPython::Locker::AcquireLock,
- ScriptInterpreterPython::Locker::FreeAcquiredLock);
+ Locker locker(this, Locker::AcquireLock, Locker::FreeAcquiredLock);
// This may be called as part of Py_Finalize. In that case the modules are
// destroyed in random order and we can't guarantee that we can access these.
@@ -2239,7 +2242,7 @@ void ScriptInterpreterPython::Clear() {
"= None; lldb.thread = None; lldb.frame = None");
}
-bool ScriptInterpreterPython::BreakpointCallbackFunction(
+bool ScriptInterpreterPythonImpl::BreakpointCallbackFunction(
void *baton, StoppointCallbackContext *context, user_id_t break_id,
user_id_t break_loc_id) {
CommandDataPython *bp_option_data = (CommandDataPython *)baton;
@@ -2255,10 +2258,9 @@ bool ScriptInterpreterPython::BreakpointCallbackFunction(
return true;
Debugger &debugger = target->GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
- ScriptInterpreterPython *python_interpreter =
- (ScriptInterpreterPython *)script_interpreter;
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
+ ScriptInterpreterPythonImpl *python_interpreter =
+ (ScriptInterpreterPythonImpl *)script_interpreter;
if (!script_interpreter)
return true;
@@ -2276,7 +2278,7 @@ bool ScriptInterpreterPython::BreakpointCallbackFunction(
Locker py_lock(python_interpreter, Locker::AcquireLock |
Locker::InitSession |
Locker::NoSTDIN);
- ret_val = g_swig_breakpoint_callback(
+ ret_val = LLDBSwigPythonBreakpointCallbackFunction(
python_function_name,
python_interpreter->m_dictionary_name.c_str(), stop_frame_sp,
bp_loc_sp);
@@ -2290,7 +2292,7 @@ bool ScriptInterpreterPython::BreakpointCallbackFunction(
return true;
}
-bool ScriptInterpreterPython::WatchpointCallbackFunction(
+bool ScriptInterpreterPythonImpl::WatchpointCallbackFunction(
void *baton, StoppointCallbackContext *context, user_id_t watch_id) {
WatchpointOptions::CommandData *wp_option_data =
(WatchpointOptions::CommandData *)baton;
@@ -2306,10 +2308,9 @@ bool ScriptInterpreterPython::WatchpointCallbackFunction(
return true;
Debugger &debugger = target->GetDebugger();
- ScriptInterpreter *script_interpreter =
- debugger.GetCommandInterpreter().GetScriptInterpreter();
- ScriptInterpreterPython *python_interpreter =
- (ScriptInterpreterPython *)script_interpreter;
+ ScriptInterpreter *script_interpreter = debugger.GetScriptInterpreter();
+ ScriptInterpreterPythonImpl *python_interpreter =
+ (ScriptInterpreterPythonImpl *)script_interpreter;
if (!script_interpreter)
return true;
@@ -2324,7 +2325,7 @@ bool ScriptInterpreterPython::WatchpointCallbackFunction(
Locker py_lock(python_interpreter, Locker::AcquireLock |
Locker::InitSession |
Locker::NoSTDIN);
- ret_val = g_swig_watchpoint_callback(
+ ret_val = LLDBSwigPythonWatchpointCallbackFunction(
python_function_name,
python_interpreter->m_dictionary_name.c_str(), stop_frame_sp,
wp_sp);
@@ -2338,7 +2339,7 @@ bool ScriptInterpreterPython::WatchpointCallbackFunction(
return true;
}
-size_t ScriptInterpreterPython::CalculateNumChildren(
+size_t ScriptInterpreterPythonImpl::CalculateNumChildren(
const StructuredData::ObjectSP &implementor_sp, uint32_t max) {
if (!implementor_sp)
return 0;
@@ -2349,21 +2350,18 @@ size_t ScriptInterpreterPython::CalculateNumChildren(
if (!implementor)
return 0;
- if (!g_swig_calc_children)
- return 0;
-
size_t ret_val = 0;
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_calc_children(implementor, max);
+ ret_val = LLDBSwigPython_CalculateNumChildren(implementor, max);
}
return ret_val;
}
-lldb::ValueObjectSP ScriptInterpreterPython::GetChildAtIndex(
+lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(
const StructuredData::ObjectSP &implementor_sp, uint32_t idx) {
if (!implementor_sp)
return lldb::ValueObjectSP();
@@ -2375,22 +2373,18 @@ lldb::ValueObjectSP ScriptInterpreterPython::GetChildAtIndex(
if (!implementor)
return lldb::ValueObjectSP();
- if (!g_swig_get_child_index || !g_swig_cast_to_sbvalue)
- return lldb::ValueObjectSP();
-
lldb::ValueObjectSP ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- void *child_ptr = g_swig_get_child_index(implementor, idx);
+ void *child_ptr = LLDBSwigPython_GetChildAtIndex(implementor, idx);
if (child_ptr != nullptr && child_ptr != Py_None) {
lldb::SBValue *sb_value_ptr =
- (lldb::SBValue *)g_swig_cast_to_sbvalue(child_ptr);
+ (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr);
if (sb_value_ptr == nullptr)
Py_XDECREF(child_ptr);
else
- ret_val = g_swig_get_valobj_sp_from_sbvalue(sb_value_ptr);
+ ret_val = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr);
} else {
Py_XDECREF(child_ptr);
}
@@ -2399,7 +2393,7 @@ lldb::ValueObjectSP ScriptInterpreterPython::GetChildAtIndex(
return ret_val;
}
-int ScriptInterpreterPython::GetIndexOfChildWithName(
+int ScriptInterpreterPythonImpl::GetIndexOfChildWithName(
const StructuredData::ObjectSP &implementor_sp, const char *child_name) {
if (!implementor_sp)
return UINT32_MAX;
@@ -2411,21 +2405,18 @@ int ScriptInterpreterPython::GetIndexOfChildWithName(
if (!implementor)
return UINT32_MAX;
- if (!g_swig_get_index_child)
- return UINT32_MAX;
-
int ret_val = UINT32_MAX;
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_get_index_child(implementor, child_name);
+ ret_val = LLDBSwigPython_GetIndexOfChildWithName(implementor, child_name);
}
return ret_val;
}
-bool ScriptInterpreterPython::UpdateSynthProviderInstance(
+bool ScriptInterpreterPythonImpl::UpdateSynthProviderInstance(
const StructuredData::ObjectSP &implementor_sp) {
bool ret_val = false;
@@ -2439,19 +2430,16 @@ bool ScriptInterpreterPython::UpdateSynthProviderInstance(
if (!implementor)
return ret_val;
- if (!g_swig_update_provider)
- return ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_update_provider(implementor);
+ ret_val = LLDBSwigPython_UpdateSynthProviderInstance(implementor);
}
return ret_val;
}
-bool ScriptInterpreterPython::MightHaveChildrenSynthProviderInstance(
+bool ScriptInterpreterPythonImpl::MightHaveChildrenSynthProviderInstance(
const StructuredData::ObjectSP &implementor_sp) {
bool ret_val = false;
@@ -2465,19 +2453,17 @@ bool ScriptInterpreterPython::MightHaveChildrenSynthProviderInstance(
if (!implementor)
return ret_val;
- if (!g_swig_mighthavechildren_provider)
- return ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_mighthavechildren_provider(implementor);
+ ret_val =
+ LLDBSwigPython_MightHaveChildrenSynthProviderInstance(implementor);
}
return ret_val;
}
-lldb::ValueObjectSP ScriptInterpreterPython::GetSyntheticValue(
+lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetSyntheticValue(
const StructuredData::ObjectSP &implementor_sp) {
lldb::ValueObjectSP ret_val(nullptr);
@@ -2491,21 +2477,17 @@ lldb::ValueObjectSP ScriptInterpreterPython::GetSyntheticValue(
if (!implementor)
return ret_val;
- if (!g_swig_getvalue_provider || !g_swig_cast_to_sbvalue ||
- !g_swig_get_valobj_sp_from_sbvalue)
- return ret_val;
-
{
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- void *child_ptr = g_swig_getvalue_provider(implementor);
+ void *child_ptr = LLDBSwigPython_GetValueSynthProviderInstance(implementor);
if (child_ptr != nullptr && child_ptr != Py_None) {
lldb::SBValue *sb_value_ptr =
- (lldb::SBValue *)g_swig_cast_to_sbvalue(child_ptr);
+ (lldb::SBValue *)LLDBSWIGPython_CastPyObjectToSBValue(child_ptr);
if (sb_value_ptr == nullptr)
Py_XDECREF(child_ptr);
else
- ret_val = g_swig_get_valobj_sp_from_sbvalue(sb_value_ptr);
+ ret_val = LLDBSWIGPython_GetValueObjectSPFromSBValue(sb_value_ptr);
} else {
Py_XDECREF(child_ptr);
}
@@ -2514,7 +2496,7 @@ lldb::ValueObjectSP ScriptInterpreterPython::GetSyntheticValue(
return ret_val;
}
-ConstString ScriptInterpreterPython::GetSyntheticTypeName(
+ConstString ScriptInterpreterPythonImpl::GetSyntheticTypeName(
const StructuredData::ObjectSP &implementor_sp) {
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
@@ -2580,10 +2562,9 @@ ConstString ScriptInterpreterPython::GetSyntheticTypeName(
return ret_val;
}
-bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
- Process *process,
- std::string &output,
- Status &error) {
+bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
+ const char *impl_function, Process *process, std::string &output,
+ Status &error) {
bool ret_val;
if (!process) {
error.SetErrorString("no process");
@@ -2593,15 +2574,12 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_process) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
ProcessSP process_sp(process->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_process(
+ ret_val = LLDBSWIGPythonRunScriptKeywordProcess(
impl_function, m_dictionary_name.c_str(), process_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2609,10 +2587,9 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
return ret_val;
}
-bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
- Thread *thread,
- std::string &output,
- Status &error) {
+bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
+ const char *impl_function, Thread *thread, std::string &output,
+ Status &error) {
bool ret_val;
if (!thread) {
error.SetErrorString("no thread");
@@ -2622,15 +2599,12 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_thread) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
ThreadSP thread_sp(thread->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_thread(
+ ret_val = LLDBSWIGPythonRunScriptKeywordThread(
impl_function, m_dictionary_name.c_str(), thread_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2638,10 +2612,9 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
return ret_val;
}
-bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
- Target *target,
- std::string &output,
- Status &error) {
+bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
+ const char *impl_function, Target *target, std::string &output,
+ Status &error) {
bool ret_val;
if (!target) {
error.SetErrorString("no thread");
@@ -2651,15 +2624,12 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_target) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
TargetSP target_sp(target->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_target(
+ ret_val = LLDBSWIGPythonRunScriptKeywordTarget(
impl_function, m_dictionary_name.c_str(), target_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2667,10 +2637,9 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
return ret_val;
}
-bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
- StackFrame *frame,
- std::string &output,
- Status &error) {
+bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
+ const char *impl_function, StackFrame *frame, std::string &output,
+ Status &error) {
bool ret_val;
if (!frame) {
error.SetErrorString("no frame");
@@ -2680,15 +2649,12 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_frame) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
StackFrameSP frame_sp(frame->shared_from_this());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_frame(
+ ret_val = LLDBSWIGPythonRunScriptKeywordFrame(
impl_function, m_dictionary_name.c_str(), frame_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2696,10 +2662,9 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
return ret_val;
}
-bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
- ValueObject *value,
- std::string &output,
- Status &error) {
+bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword(
+ const char *impl_function, ValueObject *value, std::string &output,
+ Status &error) {
bool ret_val;
if (!value) {
error.SetErrorString("no value");
@@ -2709,15 +2674,12 @@ bool ScriptInterpreterPython::RunScriptFormatKeyword(const char *impl_function,
error.SetErrorString("no function to execute");
return false;
}
- if (!g_swig_run_script_keyword_value) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
+
{
ValueObjectSP value_sp(value->GetSP());
Locker py_lock(this,
Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN);
- ret_val = g_swig_run_script_keyword_value(
+ ret_val = LLDBSWIGPythonRunScriptKeywordValue(
impl_function, m_dictionary_name.c_str(), value_sp, output);
if (!ret_val)
error.SetErrorString("python script evaluation failed");
@@ -2737,7 +2699,7 @@ uint64_t replace_all(std::string &str, const std::string &oldStr,
return matches;
}
-bool ScriptInterpreterPython::LoadScriptingModule(
+bool ScriptInterpreterPythonImpl::LoadScriptingModule(
const char *pathname, bool can_reload, bool init_session,
lldb_private::Status &error, StructuredData::ObjectSP *module_sp) {
if (!pathname || !pathname[0]) {
@@ -2745,12 +2707,7 @@ bool ScriptInterpreterPython::LoadScriptingModule(
return false;
}
- if (!g_swig_call_module_init) {
- error.SetErrorString("internal helper function missing");
- return false;
- }
-
- lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
+ lldb::DebuggerSP debugger_sp = m_debugger.shared_from_this();
{
FileSpec target_file(pathname);
@@ -2760,9 +2717,10 @@ bool ScriptInterpreterPython::LoadScriptingModule(
StreamString command_stream;
// Before executing Python code, lock the GIL.
- Locker py_lock(this, Locker::AcquireLock |
- (init_session ? Locker::InitSession : 0) |
- Locker::NoSTDIN,
+ Locker py_lock(this,
+ Locker::AcquireLock |
+ (init_session ? Locker::InitSession : 0) |
+ Locker::NoSTDIN,
Locker::FreeAcquiredLock |
(init_session ? Locker::TearDownSession : 0));
namespace fs = llvm::sys::fs;
@@ -2781,6 +2739,11 @@ bool ScriptInterpreterPython::LoadScriptingModule(
basename = pathname; // not a filename, probably a package of some sort,
// let it go through
} else if (is_directory(st) || is_regular_file(st)) {
+ if (target_file.GetDirectory().IsEmpty()) {
+ error.SetErrorString("invalid directory name");
+ return false;
+ }
+
std::string directory = target_file.GetDirectory().GetCString();
replace_all(directory, "\\", "\\\\");
replace_all(directory, "'", "\\'");
@@ -2823,7 +2786,7 @@ bool ScriptInterpreterPython::LoadScriptingModule(
bool was_imported_globally =
(ExecuteOneLineWithReturn(
command_stream.GetData(),
- ScriptInterpreterPython::eScriptReturnTypeBool, &does_contain,
+ ScriptInterpreterPythonImpl::eScriptReturnTypeBool, &does_contain,
ScriptInterpreter::ExecuteScriptOptions()
.SetEnableIO(false)
.SetSetLLDBGlobals(false)) &&
@@ -2864,8 +2827,8 @@ bool ScriptInterpreterPython::LoadScriptingModule(
// if we are here, everything worked
// call __lldb_init_module(debugger,dict)
- if (!g_swig_call_module_init(basename.c_str(), m_dictionary_name.c_str(),
- debugger_sp)) {
+ if (!LLDBSwigPythonCallModuleInit(basename.c_str(),
+ m_dictionary_name.c_str(), debugger_sp)) {
error.SetErrorString("calling __lldb_init_module failed");
return false;
}
@@ -2880,14 +2843,14 @@ bool ScriptInterpreterPython::LoadScriptingModule(
ScriptInterpreter::eScriptReturnTypeOpaqueObject,
&module_pyobj) &&
module_pyobj)
- module_sp->reset(new StructuredPythonObject(module_pyobj));
+ *module_sp = std::make_shared<StructuredPythonObject>(module_pyobj);
}
return true;
}
}
-bool ScriptInterpreterPython::IsReservedWord(const char *word) {
+bool ScriptInterpreterPythonImpl::IsReservedWord(const char *word) {
if (!word || !word[0])
return false;
@@ -2895,7 +2858,8 @@ bool ScriptInterpreterPython::IsReservedWord(const char *word) {
// filter out a few characters that would just confuse us and that are
// clearly not keyword material anyway
- if (word_sr.find_first_of("'\"") != llvm::StringRef::npos)
+ if (word_sr.find('"') != llvm::StringRef::npos ||
+ word_sr.find('\'') != llvm::StringRef::npos)
return false;
StreamString command_stream;
@@ -2912,7 +2876,7 @@ bool ScriptInterpreterPython::IsReservedWord(const char *word) {
return false;
}
-ScriptInterpreterPython::SynchronicityHandler::SynchronicityHandler(
+ScriptInterpreterPythonImpl::SynchronicityHandler::SynchronicityHandler(
lldb::DebuggerSP debugger_sp, ScriptedCommandSynchronicity synchro)
: m_debugger_sp(debugger_sp), m_synch_wanted(synchro),
m_old_asynch(debugger_sp->GetAsyncExecution()) {
@@ -2922,12 +2886,12 @@ ScriptInterpreterPython::SynchronicityHandler::SynchronicityHandler(
m_debugger_sp->SetAsyncExecution(true);
}
-ScriptInterpreterPython::SynchronicityHandler::~SynchronicityHandler() {
+ScriptInterpreterPythonImpl::SynchronicityHandler::~SynchronicityHandler() {
if (m_synch_wanted != eScriptedCommandSynchronicityCurrentValue)
m_debugger_sp->SetAsyncExecution(m_old_asynch);
}
-bool ScriptInterpreterPython::RunScriptBasedCommand(
+bool ScriptInterpreterPythonImpl::RunScriptBasedCommand(
const char *impl_function, llvm::StringRef args,
ScriptedCommandSynchronicity synchronicity,
lldb_private::CommandReturnObject &cmd_retobj, Status &error,
@@ -2937,12 +2901,7 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(
return false;
}
- if (!g_swig_call_command) {
- error.SetErrorString("no helper function to run scripted commands");
- return false;
- }
-
- lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
+ lldb::DebuggerSP debugger_sp = m_debugger.shared_from_this();
lldb::ExecutionContextRefSP exe_ctx_ref_sp(new ExecutionContextRef(exe_ctx));
if (!debugger_sp.get()) {
@@ -2963,9 +2922,9 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(
SynchronicityHandler synch_handler(debugger_sp, synchronicity);
std::string args_str = args.str();
- ret_val = g_swig_call_command(impl_function, m_dictionary_name.c_str(),
- debugger_sp, args_str.c_str(), cmd_retobj,
- exe_ctx_ref_sp);
+ ret_val = LLDBSwigPythonCallCommand(
+ impl_function, m_dictionary_name.c_str(), debugger_sp, args_str.c_str(),
+ cmd_retobj, exe_ctx_ref_sp);
}
if (!ret_val)
@@ -2976,7 +2935,7 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(
return ret_val;
}
-bool ScriptInterpreterPython::RunScriptBasedCommand(
+bool ScriptInterpreterPythonImpl::RunScriptBasedCommand(
StructuredData::GenericSP impl_obj_sp, llvm::StringRef args,
ScriptedCommandSynchronicity synchronicity,
lldb_private::CommandReturnObject &cmd_retobj, Status &error,
@@ -2986,12 +2945,7 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(
return false;
}
- if (!g_swig_call_command_object) {
- error.SetErrorString("no helper function to run scripted commands");
- return false;
- }
-
- lldb::DebuggerSP debugger_sp = m_interpreter.GetDebugger().shared_from_this();
+ lldb::DebuggerSP debugger_sp = m_debugger.shared_from_this();
lldb::ExecutionContextRefSP exe_ctx_ref_sp(new ExecutionContextRef(exe_ctx));
if (!debugger_sp.get()) {
@@ -3012,9 +2966,9 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(
SynchronicityHandler synch_handler(debugger_sp, synchronicity);
std::string args_str = args.str();
- ret_val = g_swig_call_command_object(impl_obj_sp->GetValue(), debugger_sp,
- args_str.c_str(), cmd_retobj,
- exe_ctx_ref_sp);
+ ret_val = LLDBSwigPythonCallCommandObject(impl_obj_sp->GetValue(),
+ debugger_sp, args_str.c_str(),
+ cmd_retobj, exe_ctx_ref_sp);
}
if (!ret_val)
@@ -3028,8 +2982,8 @@ bool ScriptInterpreterPython::RunScriptBasedCommand(
// in Python, a special attribute __doc__ contains the docstring for an object
// (function, method, class, ...) if any is defined Otherwise, the attribute's
// value is None
-bool ScriptInterpreterPython::GetDocumentationForItem(const char *item,
- std::string &dest) {
+bool ScriptInterpreterPythonImpl::GetDocumentationForItem(const char *item,
+ std::string &dest) {
dest.clear();
if (!item || !*item)
return false;
@@ -3055,7 +3009,7 @@ bool ScriptInterpreterPython::GetDocumentationForItem(const char *item,
}
}
-bool ScriptInterpreterPython::GetShortHelpForCommandObject(
+bool ScriptInterpreterPythonImpl::GetShortHelpForCommandObject(
StructuredData::GenericSP cmd_obj_sp, std::string &dest) {
bool got_string = false;
dest.clear();
@@ -3111,7 +3065,7 @@ bool ScriptInterpreterPython::GetShortHelpForCommandObject(
return got_string;
}
-uint32_t ScriptInterpreterPython::GetFlagsForCommandObject(
+uint32_t ScriptInterpreterPythonImpl::GetFlagsForCommandObject(
StructuredData::GenericSP cmd_obj_sp) {
uint32_t result = 0;
@@ -3165,7 +3119,7 @@ uint32_t ScriptInterpreterPython::GetFlagsForCommandObject(
return result;
}
-bool ScriptInterpreterPython::GetLongHelpForCommandObject(
+bool ScriptInterpreterPythonImpl::GetLongHelpForCommandObject(
StructuredData::GenericSP cmd_obj_sp, std::string &dest) {
bool got_string = false;
dest.clear();
@@ -3224,78 +3178,14 @@ bool ScriptInterpreterPython::GetLongHelpForCommandObject(
}
std::unique_ptr<ScriptInterpreterLocker>
-ScriptInterpreterPython::AcquireInterpreterLock() {
+ScriptInterpreterPythonImpl::AcquireInterpreterLock() {
std::unique_ptr<ScriptInterpreterLocker> py_lock(new Locker(
this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN,
Locker::FreeLock | Locker::TearDownSession));
return py_lock;
}
-void ScriptInterpreterPython::InitializeInterpreter(
- SWIGInitCallback swig_init_callback,
- SWIGBreakpointCallbackFunction swig_breakpoint_callback,
- SWIGWatchpointCallbackFunction swig_watchpoint_callback,
- SWIGPythonTypeScriptCallbackFunction swig_typescript_callback,
- SWIGPythonCreateSyntheticProvider swig_synthetic_script,
- SWIGPythonCreateCommandObject swig_create_cmd,
- SWIGPythonCalculateNumChildren swig_calc_children,
- SWIGPythonGetChildAtIndex swig_get_child_index,
- SWIGPythonGetIndexOfChildWithName swig_get_index_child,
- SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue,
- SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue,
- SWIGPythonUpdateSynthProviderInstance swig_update_provider,
- SWIGPythonMightHaveChildrenSynthProviderInstance
- swig_mighthavechildren_provider,
- SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider,
- SWIGPythonCallCommand swig_call_command,
- SWIGPythonCallCommandObject swig_call_command_object,
- SWIGPythonCallModuleInit swig_call_module_init,
- SWIGPythonCreateOSPlugin swig_create_os_plugin,
- SWIGPythonCreateFrameRecognizer swig_create_frame_recognizer,
- SWIGPythonGetRecognizedArguments swig_get_recognized_arguments,
- SWIGPythonScriptKeyword_Process swig_run_script_keyword_process,
- SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread,
- SWIGPythonScriptKeyword_Target swig_run_script_keyword_target,
- SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame,
- SWIGPythonScriptKeyword_Value swig_run_script_keyword_value,
- SWIGPython_GetDynamicSetting swig_plugin_get,
- SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script,
- SWIGPythonCallThreadPlan swig_call_thread_plan,
- SWIGPythonCreateScriptedBreakpointResolver swig_bkpt_resolver_script,
- SWIGPythonCallBreakpointResolver swig_call_bkpt_resolver) {
- g_swig_init_callback = swig_init_callback;
- g_swig_breakpoint_callback = swig_breakpoint_callback;
- g_swig_watchpoint_callback = swig_watchpoint_callback;
- g_swig_typescript_callback = swig_typescript_callback;
- g_swig_synthetic_script = swig_synthetic_script;
- g_swig_create_cmd = swig_create_cmd;
- g_swig_calc_children = swig_calc_children;
- g_swig_get_child_index = swig_get_child_index;
- g_swig_get_index_child = swig_get_index_child;
- g_swig_cast_to_sbvalue = swig_cast_to_sbvalue;
- g_swig_get_valobj_sp_from_sbvalue = swig_get_valobj_sp_from_sbvalue;
- g_swig_update_provider = swig_update_provider;
- g_swig_mighthavechildren_provider = swig_mighthavechildren_provider;
- g_swig_getvalue_provider = swig_getvalue_provider;
- g_swig_call_command = swig_call_command;
- g_swig_call_command_object = swig_call_command_object;
- g_swig_call_module_init = swig_call_module_init;
- g_swig_create_os_plugin = swig_create_os_plugin;
- g_swig_create_frame_recognizer = swig_create_frame_recognizer;
- g_swig_get_recognized_arguments = swig_get_recognized_arguments;
- g_swig_run_script_keyword_process = swig_run_script_keyword_process;
- g_swig_run_script_keyword_thread = swig_run_script_keyword_thread;
- g_swig_run_script_keyword_target = swig_run_script_keyword_target;
- g_swig_run_script_keyword_frame = swig_run_script_keyword_frame;
- g_swig_run_script_keyword_value = swig_run_script_keyword_value;
- g_swig_plugin_get = swig_plugin_get;
- g_swig_thread_plan_script = swig_thread_plan_script;
- g_swig_call_thread_plan = swig_call_thread_plan;
- g_swig_bkpt_resolver_script = swig_bkpt_resolver_script;
- g_swig_call_bkpt_resolver = swig_call_bkpt_resolver;
-}
-
-void ScriptInterpreterPython::InitializePrivate() {
+void ScriptInterpreterPythonImpl::InitializePrivate() {
if (g_initialized)
return;
@@ -3310,8 +3200,7 @@ void ScriptInterpreterPython::InitializePrivate() {
// initialization.
InitializePythonRAII initialize_guard;
- if (g_swig_init_callback)
- g_swig_init_callback();
+ LLDBSwigPyInit();
// Update the path python uses to search for modules to include the current
// directory.
@@ -3334,8 +3223,8 @@ void ScriptInterpreterPython::InitializePrivate() {
"from lldb.embedded_interpreter import run_one_line");
}
-void ScriptInterpreterPython::AddToSysPath(AddLocation location,
- std::string path) {
+void ScriptInterpreterPythonImpl::AddToSysPath(AddLocation location,
+ std::string path) {
std::string path_copy;
std::string statement;
@@ -3358,13 +3247,13 @@ void ScriptInterpreterPython::AddToSysPath(AddLocation location,
// calls Py_Finalize, which calls all the 'at_exit' registered functions.
// SBDebugger::Terminate calls Debugger::Terminate, which calls lldb::Terminate,
// which calls ScriptInterpreter::Terminate, which calls
-// ScriptInterpreterPython::Terminate. So if we call Py_Finalize here, we end
-// up with Py_Finalize being called from within Py_Finalize, which results in a
-// seg fault. Since this function only gets called when lldb is shutting down
-// and going away anyway, the fact that we don't actually call Py_Finalize
+// ScriptInterpreterPythonImpl::Terminate. So if we call Py_Finalize here, we
+// end up with Py_Finalize being called from within Py_Finalize, which results
+// in a seg fault. Since this function only gets called when lldb is shutting
+// down and going away anyway, the fact that we don't actually call Py_Finalize
// should not cause any problems (everything should shut down/go away anyway
// when the process exits).
//
-// void ScriptInterpreterPython::Terminate() { Py_Finalize (); }
+// void ScriptInterpreterPythonImpl::Terminate() { Py_Finalize (); }
#endif // LLDB_DISABLE_PYTHON
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
index a047359883ce5..24941ec774521 100644
--- a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -1,9 +1,8 @@
//===-- ScriptInterpreterPython.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,21 +15,17 @@
#else
-#include <memory>
-#include <string>
-#include <vector>
-
-#include "PythonDataObjects.h"
#include "lldb/Breakpoint/BreakpointOptions.h"
#include "lldb/Core/IOHandler.h"
-#include "lldb/Host/Terminal.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/lldb-private.h"
-class IOHandlerPythonInterpreter;
+#include <memory>
+#include <string>
+#include <vector>
namespace lldb_private {
-
+/// Abstract interface for the Python script interpreter.
class ScriptInterpreterPython : public ScriptInterpreter,
public IOHandlerDelegateMultiline {
public:
@@ -41,570 +36,22 @@ public:
}
};
-#if PY_MAJOR_VERSION >= 3
- typedef PyObject *(*SWIGInitCallback)(void);
-#else
- typedef void (*SWIGInitCallback)(void);
-#endif
-
- typedef bool (*SWIGBreakpointCallbackFunction)(
- const char *python_function_name, const char *session_dictionary_name,
- const lldb::StackFrameSP &frame_sp,
- const lldb::BreakpointLocationSP &bp_loc_sp);
-
- typedef bool (*SWIGWatchpointCallbackFunction)(
- const char *python_function_name, const char *session_dictionary_name,
- const lldb::StackFrameSP &frame_sp, const lldb::WatchpointSP &wp_sp);
-
- typedef bool (*SWIGPythonTypeScriptCallbackFunction)(
- const char *python_function_name, void *session_dictionary,
- const lldb::ValueObjectSP &valobj_sp, void **pyfunct_wrapper,
- const lldb::TypeSummaryOptionsSP &options, std::string &retval);
-
- typedef void *(*SWIGPythonCreateSyntheticProvider)(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::ValueObjectSP &valobj_sp);
-
- typedef void *(*SWIGPythonCreateCommandObject)(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::DebuggerSP debugger_sp);
-
- typedef void *(*SWIGPythonCreateScriptedThreadPlan)(
- const char *python_class_name, const char *session_dictionary_name,
- const lldb::ThreadPlanSP &thread_plan_sp);
-
- typedef bool (*SWIGPythonCallThreadPlan)(void *implementor,
- const char *method_name,
- Event *event_sp, bool &got_error);
-
- typedef void *(*SWIGPythonCreateScriptedBreakpointResolver)(
- const char *python_class_name, const char *session_dictionary_name,
- lldb_private::StructuredDataImpl *args_impl,
- lldb::BreakpointSP &bkpt_sp);
-
- typedef unsigned int (*SWIGPythonCallBreakpointResolver)(void *implementor,
- const char *method_name,
- lldb_private::SymbolContext *sym_ctx);
-
- typedef void *(*SWIGPythonCreateOSPlugin)(const char *python_class_name,
- const char *session_dictionary_name,
- const lldb::ProcessSP &process_sp);
-
- typedef void *(*SWIGPythonCreateFrameRecognizer)(
- const char *python_class_name, const char *session_dictionary_name);
-
- typedef void *(*SWIGPythonGetRecognizedArguments)(
- void *implementor, const lldb::StackFrameSP &frame_sp);
-
- typedef size_t (*SWIGPythonCalculateNumChildren)(void *implementor,
- uint32_t max);
-
- typedef void *(*SWIGPythonGetChildAtIndex)(void *implementor, uint32_t idx);
-
- typedef int (*SWIGPythonGetIndexOfChildWithName)(void *implementor,
- const char *child_name);
-
- typedef void *(*SWIGPythonCastPyObjectToSBValue)(void *data);
-
- typedef lldb::ValueObjectSP (*SWIGPythonGetValueObjectSPFromSBValue)(
- void *data);
-
- typedef bool (*SWIGPythonUpdateSynthProviderInstance)(void *data);
-
- typedef bool (*SWIGPythonMightHaveChildrenSynthProviderInstance)(void *data);
-
- typedef void *(*SWIGPythonGetValueSynthProviderInstance)(void *implementor);
-
- typedef bool (*SWIGPythonCallCommand)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::DebuggerSP &debugger, const char *args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
- typedef bool (*SWIGPythonCallCommandObject)(
- void *implementor, lldb::DebuggerSP &debugger, const char *args,
- lldb_private::CommandReturnObject &cmd_retobj,
- lldb::ExecutionContextRefSP exe_ctx_ref_sp);
-
- typedef bool (*SWIGPythonCallModuleInit)(const char *python_module_name,
- const char *session_dictionary_name,
- lldb::DebuggerSP &debugger);
-
- typedef bool (*SWIGPythonScriptKeyword_Process)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ProcessSP &process, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Thread)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ThreadSP &thread, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Target)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::TargetSP &target, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Frame)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::StackFrameSP &frame, std::string &output);
-
- typedef bool (*SWIGPythonScriptKeyword_Value)(
- const char *python_function_name, const char *session_dictionary_name,
- lldb::ValueObjectSP &value, std::string &output);
-
- typedef void *(*SWIGPython_GetDynamicSetting)(
- void *module, const char *setting, const lldb::TargetSP &target_sp);
-
- friend class ::IOHandlerPythonInterpreter;
-
- ScriptInterpreterPython(CommandInterpreter &interpreter);
-
- ~ScriptInterpreterPython() override;
-
- bool Interrupt() override;
-
- bool ExecuteOneLine(
- llvm::StringRef command, CommandReturnObject *result,
- const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
-
- void ExecuteInterpreterLoop() override;
-
- bool ExecuteOneLineWithReturn(
- llvm::StringRef in_string,
- ScriptInterpreter::ScriptReturnType return_type, void *ret_value,
- const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
-
- lldb_private::Status ExecuteMultipleLines(
- const char *in_string,
- const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
-
- Status
- ExportFunctionDefinitionToInterpreter(StringList &function_def) override;
-
- bool GenerateTypeScriptFunction(StringList &input, std::string &output,
- const void *name_token = nullptr) override;
-
- bool GenerateTypeSynthClass(StringList &input, std::string &output,
- const void *name_token = nullptr) override;
-
- bool GenerateTypeSynthClass(const char *oneliner, std::string &output,
- const void *name_token = nullptr) override;
-
- // use this if the function code is just a one-liner script
- bool GenerateTypeScriptFunction(const char *oneliner, std::string &output,
- const void *name_token = nullptr) override;
-
- bool GenerateScriptAliasFunction(StringList &input,
- std::string &output) override;
-
- StructuredData::ObjectSP
- CreateSyntheticScriptedProvider(const char *class_name,
- lldb::ValueObjectSP valobj) override;
-
- StructuredData::GenericSP
- CreateScriptCommandObject(const char *class_name) override;
-
- StructuredData::ObjectSP
- CreateScriptedThreadPlan(const char *class_name,
- lldb::ThreadPlanSP thread_plan) override;
-
- bool ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp,
- Event *event,
- bool &script_error) override;
-
- bool ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp,
- Event *event, bool &script_error) override;
-
- bool ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp,
- bool &script_error) override;
-
- lldb::StateType
- ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp,
- bool &script_error) override;
-
- StructuredData::GenericSP
- CreateScriptedBreakpointResolver(const char *class_name,
- StructuredDataImpl *args_data,
- lldb::BreakpointSP &bkpt_sp) override;
- bool
- ScriptedBreakpointResolverSearchCallback(StructuredData::GenericSP
- implementor_sp,
- SymbolContext *sym_ctx) override;
-
- lldb::SearchDepth
- ScriptedBreakpointResolverSearchDepth(StructuredData::GenericSP
- implementor_sp) override;
-
- StructuredData::GenericSP
- CreateFrameRecognizer(const char *class_name) override;
-
- lldb::ValueObjectListSP
- GetRecognizedArguments(const StructuredData::ObjectSP &implementor,
- lldb::StackFrameSP frame_sp) override;
-
- StructuredData::GenericSP
- OSPlugin_CreatePluginObject(const char *class_name,
- lldb::ProcessSP process_sp) override;
-
- StructuredData::DictionarySP
- OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
-
- StructuredData::ArraySP
- OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
-
- StructuredData::StringSP
- OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp,
- lldb::tid_t thread_id) override;
-
- StructuredData::DictionarySP
- OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp,
- lldb::tid_t tid, lldb::addr_t context) override;
-
- StructuredData::ObjectSP
- LoadPluginModule(const FileSpec &file_spec,
- lldb_private::Status &error) override;
-
- StructuredData::DictionarySP
- GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target,
- const char *setting_name,
- lldb_private::Status &error) override;
-
- size_t CalculateNumChildren(const StructuredData::ObjectSP &implementor,
- uint32_t max) override;
-
- lldb::ValueObjectSP
- GetChildAtIndex(const StructuredData::ObjectSP &implementor,
- uint32_t idx) override;
-
- int GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor,
- const char *child_name) override;
-
- bool UpdateSynthProviderInstance(
- const StructuredData::ObjectSP &implementor) override;
-
- bool MightHaveChildrenSynthProviderInstance(
- const StructuredData::ObjectSP &implementor) override;
-
- lldb::ValueObjectSP
- GetSyntheticValue(const StructuredData::ObjectSP &implementor) override;
-
- ConstString
- GetSyntheticTypeName(const StructuredData::ObjectSP &implementor) override;
-
- bool
- RunScriptBasedCommand(const char *impl_function, llvm::StringRef args,
- ScriptedCommandSynchronicity synchronicity,
- lldb_private::CommandReturnObject &cmd_retobj,
- Status &error,
- const lldb_private::ExecutionContext &exe_ctx) override;
-
- bool RunScriptBasedCommand(
- StructuredData::GenericSP impl_obj_sp, llvm::StringRef args,
- ScriptedCommandSynchronicity synchronicity,
- lldb_private::CommandReturnObject &cmd_retobj, Status &error,
- const lldb_private::ExecutionContext &exe_ctx) override;
+ ScriptInterpreterPython(Debugger &debugger)
+ : ScriptInterpreter(debugger, lldb::eScriptLanguagePython),
+ IOHandlerDelegateMultiline("DONE") {}
- Status GenerateFunction(const char *signature,
- const StringList &input) override;
-
- Status GenerateBreakpointCommandCallbackData(StringList &input,
- std::string &output) override;
-
- bool GenerateWatchpointCommandCallbackData(StringList &input,
- std::string &output) override;
-
- // static size_t
- // GenerateBreakpointOptionsCommandCallback (void *baton,
- // InputReader &reader,
- // lldb::InputReaderAction
- // notification,
- // const char *bytes,
- // size_t bytes_len);
- //
- // static size_t
- // GenerateWatchpointOptionsCommandCallback (void *baton,
- // InputReader &reader,
- // lldb::InputReaderAction
- // notification,
- // const char *bytes,
- // size_t bytes_len);
-
- static bool BreakpointCallbackFunction(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t break_id,
- lldb::user_id_t break_loc_id);
-
- static bool WatchpointCallbackFunction(void *baton,
- StoppointCallbackContext *context,
- lldb::user_id_t watch_id);
-
- bool GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj,
- StructuredData::ObjectSP &callee_wrapper_sp,
- const TypeSummaryOptions &options,
- std::string &retval) override;
-
- void Clear() override;
-
- bool GetDocumentationForItem(const char *item, std::string &dest) override;
-
- bool GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,
- std::string &dest) override;
-
- uint32_t
- GetFlagsForCommandObject(StructuredData::GenericSP cmd_obj_sp) override;
-
- bool GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,
- std::string &dest) override;
-
- bool CheckObjectExists(const char *name) override {
- if (!name || !name[0])
- return false;
- std::string temp;
- return GetDocumentationForItem(name, temp);
- }
-
- bool RunScriptFormatKeyword(const char *impl_function, Process *process,
- std::string &output, Status &error) override;
-
- bool RunScriptFormatKeyword(const char *impl_function, Thread *thread,
- std::string &output, Status &error) override;
-
- bool RunScriptFormatKeyword(const char *impl_function, Target *target,
- std::string &output, Status &error) override;
-
- bool RunScriptFormatKeyword(const char *impl_function, StackFrame *frame,
- std::string &output, Status &error) override;
-
- bool RunScriptFormatKeyword(const char *impl_function, ValueObject *value,
- std::string &output, Status &error) override;
-
- bool
- LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
- lldb_private::Status &error,
- StructuredData::ObjectSP *module_sp = nullptr) override;
-
- bool IsReservedWord(const char *word) override;
-
- std::unique_ptr<ScriptInterpreterLocker> AcquireInterpreterLock() override;
-
- void CollectDataForBreakpointCommandCallback(
- std::vector<BreakpointOptions *> &bp_options_vec,
- CommandReturnObject &result) override;
-
- void
- CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options,
- CommandReturnObject &result) override;
-
- /// Set the callback body text into the callback for the breakpoint.
- Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
- const char *callback_body) override;
-
- void SetBreakpointCommandCallbackFunction(BreakpointOptions *bp_options,
- const char *function_name) override;
-
- /// This one is for deserialization:
- Status SetBreakpointCommandCallback(
- BreakpointOptions *bp_options,
- std::unique_ptr<BreakpointOptions::CommandData> &data_up) override;
-
- /// Set a one-liner as the callback for the watchpoint.
- void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
- const char *oneliner) override;
-
- StringList ReadCommandInputFromUser(FILE *in_file);
-
- void ResetOutputFileHandle(FILE *new_fh) override;
-
- static void InitializePrivate();
-
- static void InitializeInterpreter(
- SWIGInitCallback python_swig_init_callback,
- SWIGBreakpointCallbackFunction swig_breakpoint_callback,
- SWIGWatchpointCallbackFunction swig_watchpoint_callback,
- SWIGPythonTypeScriptCallbackFunction swig_typescript_callback,
- SWIGPythonCreateSyntheticProvider swig_synthetic_script,
- SWIGPythonCreateCommandObject swig_create_cmd,
- SWIGPythonCalculateNumChildren swig_calc_children,
- SWIGPythonGetChildAtIndex swig_get_child_index,
- SWIGPythonGetIndexOfChildWithName swig_get_index_child,
- SWIGPythonCastPyObjectToSBValue swig_cast_to_sbvalue,
- SWIGPythonGetValueObjectSPFromSBValue swig_get_valobj_sp_from_sbvalue,
- SWIGPythonUpdateSynthProviderInstance swig_update_provider,
- SWIGPythonMightHaveChildrenSynthProviderInstance
- swig_mighthavechildren_provider,
- SWIGPythonGetValueSynthProviderInstance swig_getvalue_provider,
- SWIGPythonCallCommand swig_call_command,
- SWIGPythonCallCommandObject swig_call_command_object,
- SWIGPythonCallModuleInit swig_call_module_init,
- SWIGPythonCreateOSPlugin swig_create_os_plugin,
- SWIGPythonCreateFrameRecognizer swig_create_frame_recognizer,
- SWIGPythonGetRecognizedArguments swig_get_recognized_arguments,
- SWIGPythonScriptKeyword_Process swig_run_script_keyword_process,
- SWIGPythonScriptKeyword_Thread swig_run_script_keyword_thread,
- SWIGPythonScriptKeyword_Target swig_run_script_keyword_target,
- SWIGPythonScriptKeyword_Frame swig_run_script_keyword_frame,
- SWIGPythonScriptKeyword_Value swig_run_script_keyword_value,
- SWIGPython_GetDynamicSetting swig_plugin_get,
- SWIGPythonCreateScriptedThreadPlan swig_thread_plan_script,
- SWIGPythonCallThreadPlan swig_call_thread_plan,
- SWIGPythonCreateScriptedBreakpointResolver swig_bkpt_resolver_script,
- SWIGPythonCallBreakpointResolver swig_call_breakpoint_resolver);
-
- const char *GetDictionaryName() { return m_dictionary_name.c_str(); }
-
- PyThreadState *GetThreadState() { return m_command_thread_state; }
-
- void SetThreadState(PyThreadState *s) {
- if (s)
- m_command_thread_state = s;
- }
-
- //----------------------------------------------------------------------
- // IOHandlerDelegate
- //----------------------------------------------------------------------
- void IOHandlerActivated(IOHandler &io_handler) override;
-
- void IOHandlerInputComplete(IOHandler &io_handler,
- std::string &data) override;
-
- //------------------------------------------------------------------
- // Static Functions
- //------------------------------------------------------------------
static void Initialize();
-
static void Terminate();
-
- static lldb::ScriptInterpreterSP
- CreateInstance(CommandInterpreter &interpreter);
-
static lldb_private::ConstString GetPluginNameStatic();
-
static const char *GetPluginDescriptionStatic();
-
static FileSpec GetPythonDir();
- //------------------------------------------------------------------
- // PluginInterface protocol
- //------------------------------------------------------------------
- lldb_private::ConstString GetPluginName() override;
-
- uint32_t GetPluginVersion() override;
-
- class Locker : public ScriptInterpreterLocker {
- public:
- enum OnEntry {
- AcquireLock = 0x0001,
- InitSession = 0x0002,
- InitGlobals = 0x0004,
- NoSTDIN = 0x0008
- };
-
- enum OnLeave {
- FreeLock = 0x0001,
- FreeAcquiredLock = 0x0002, // do not free the lock if we already held it
- // when calling constructor
- TearDownSession = 0x0004
- };
-
- Locker(ScriptInterpreterPython *py_interpreter = nullptr,
- uint16_t on_entry = AcquireLock | InitSession,
- uint16_t on_leave = FreeLock | TearDownSession, FILE *in = nullptr,
- FILE *out = nullptr, FILE *err = nullptr);
-
- ~Locker() override;
-
- private:
- bool DoAcquireLock();
-
- bool DoInitSession(uint16_t on_entry_flags, FILE *in, FILE *out, FILE *err);
-
- bool DoFreeLock();
-
- bool DoTearDownSession();
-
- static void ReleasePythonLock();
-
- bool m_teardown_session;
- ScriptInterpreterPython *m_python_interpreter;
- // FILE* m_tmp_fh;
- PyGILState_STATE m_GILState;
- };
-
protected:
- class SynchronicityHandler {
- private:
- lldb::DebuggerSP m_debugger_sp;
- ScriptedCommandSynchronicity m_synch_wanted;
- bool m_old_asynch;
-
- public:
- SynchronicityHandler(lldb::DebuggerSP, ScriptedCommandSynchronicity);
-
- ~SynchronicityHandler();
- };
-
- enum class AddLocation { Beginning, End };
-
- static void AddToSysPath(AddLocation location, std::string path);
-
static void ComputePythonDirForApple(llvm::SmallVectorImpl<char> &path);
static void ComputePythonDirForPosix(llvm::SmallVectorImpl<char> &path);
static void ComputePythonDirForWindows(llvm::SmallVectorImpl<char> &path);
-
- bool EnterSession(uint16_t on_entry_flags, FILE *in, FILE *out, FILE *err);
-
- void LeaveSession();
-
- void SaveTerminalState(int fd);
-
- void RestoreTerminalState();
-
- uint32_t IsExecutingPython() const { return m_lock_count > 0; }
-
- uint32_t IncrementLockCount() { return ++m_lock_count; }
-
- uint32_t DecrementLockCount() {
- if (m_lock_count > 0)
- --m_lock_count;
- return m_lock_count;
- }
-
- enum ActiveIOHandler {
- eIOHandlerNone,
- eIOHandlerBreakpoint,
- eIOHandlerWatchpoint
- };
-
- PythonObject &GetMainModule();
-
- PythonDictionary &GetSessionDictionary();
-
- PythonDictionary &GetSysModuleDictionary();
-
- bool GetEmbeddedInterpreterModuleObjects();
-
- bool SetStdHandle(File &file, const char *py_name, PythonFile &save_file,
- const char *mode);
-
- PythonFile m_saved_stdin;
- PythonFile m_saved_stdout;
- PythonFile m_saved_stderr;
- PythonObject m_main_module;
- PythonObject m_lldb_module;
- PythonDictionary m_session_dict;
- PythonDictionary m_sys_module_dict;
- PythonObject m_run_one_line_function;
- PythonObject m_run_one_line_str_global;
- std::string m_dictionary_name;
- TerminalState m_terminal_state;
- ActiveIOHandler m_active_io_handler;
- bool m_session_is_active;
- bool m_pty_slave_is_open;
- bool m_valid_session;
- uint32_t m_lock_count;
- PyThreadState *m_command_thread_state;
};
-
} // namespace lldb_private
#endif // LLDB_DISABLE_PYTHON
-
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTINTERPRETERPYTHON_H
diff --git a/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
new file mode 100644
index 0000000000000..a9993c4068a2b
--- /dev/null
+++ b/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -0,0 +1,473 @@
+//===-- ScriptInterpreterPythonImpl.h ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifdef LLDB_DISABLE_PYTHON
+
+// Python is disabled in this build
+
+#else
+
+#include "lldb-python.h"
+
+#include "PythonDataObjects.h"
+#include "ScriptInterpreterPython.h"
+
+#include "lldb/Host/Terminal.h"
+#include "lldb/Utility/StreamString.h"
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace lldb_private {
+class IOHandlerPythonInterpreter;
+class ScriptInterpreterPythonImpl : public ScriptInterpreterPython {
+public:
+ friend class IOHandlerPythonInterpreter;
+
+ ScriptInterpreterPythonImpl(Debugger &debugger);
+
+ ~ScriptInterpreterPythonImpl() override;
+
+ bool Interrupt() override;
+
+ bool ExecuteOneLine(
+ llvm::StringRef command, CommandReturnObject *result,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
+
+ void ExecuteInterpreterLoop() override;
+
+ bool ExecuteOneLineWithReturn(
+ llvm::StringRef in_string,
+ ScriptInterpreter::ScriptReturnType return_type, void *ret_value,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
+
+ lldb_private::Status ExecuteMultipleLines(
+ const char *in_string,
+ const ExecuteScriptOptions &options = ExecuteScriptOptions()) override;
+
+ Status
+ ExportFunctionDefinitionToInterpreter(StringList &function_def) override;
+
+ bool GenerateTypeScriptFunction(StringList &input, std::string &output,
+ const void *name_token = nullptr) override;
+
+ bool GenerateTypeSynthClass(StringList &input, std::string &output,
+ const void *name_token = nullptr) override;
+
+ bool GenerateTypeSynthClass(const char *oneliner, std::string &output,
+ const void *name_token = nullptr) override;
+
+ // use this if the function code is just a one-liner script
+ bool GenerateTypeScriptFunction(const char *oneliner, std::string &output,
+ const void *name_token = nullptr) override;
+
+ bool GenerateScriptAliasFunction(StringList &input,
+ std::string &output) override;
+
+ StructuredData::ObjectSP
+ CreateSyntheticScriptedProvider(const char *class_name,
+ lldb::ValueObjectSP valobj) override;
+
+ StructuredData::GenericSP
+ CreateScriptCommandObject(const char *class_name) override;
+
+ StructuredData::ObjectSP
+ CreateScriptedThreadPlan(const char *class_name,
+ lldb::ThreadPlanSP thread_plan) override;
+
+ bool ScriptedThreadPlanExplainsStop(StructuredData::ObjectSP implementor_sp,
+ Event *event,
+ bool &script_error) override;
+
+ bool ScriptedThreadPlanShouldStop(StructuredData::ObjectSP implementor_sp,
+ Event *event, bool &script_error) override;
+
+ bool ScriptedThreadPlanIsStale(StructuredData::ObjectSP implementor_sp,
+ bool &script_error) override;
+
+ lldb::StateType
+ ScriptedThreadPlanGetRunState(StructuredData::ObjectSP implementor_sp,
+ bool &script_error) override;
+
+ StructuredData::GenericSP
+ CreateScriptedBreakpointResolver(const char *class_name,
+ StructuredDataImpl *args_data,
+ lldb::BreakpointSP &bkpt_sp) override;
+ bool ScriptedBreakpointResolverSearchCallback(
+ StructuredData::GenericSP implementor_sp,
+ SymbolContext *sym_ctx) override;
+
+ lldb::SearchDepth ScriptedBreakpointResolverSearchDepth(
+ StructuredData::GenericSP implementor_sp) override;
+
+ StructuredData::GenericSP
+ CreateFrameRecognizer(const char *class_name) override;
+
+ lldb::ValueObjectListSP
+ GetRecognizedArguments(const StructuredData::ObjectSP &implementor,
+ lldb::StackFrameSP frame_sp) override;
+
+ StructuredData::GenericSP
+ OSPlugin_CreatePluginObject(const char *class_name,
+ lldb::ProcessSP process_sp) override;
+
+ StructuredData::DictionarySP
+ OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
+
+ StructuredData::ArraySP
+ OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
+
+ StructuredData::StringSP
+ OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp,
+ lldb::tid_t thread_id) override;
+
+ StructuredData::DictionarySP
+ OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp,
+ lldb::tid_t tid, lldb::addr_t context) override;
+
+ StructuredData::ObjectSP
+ LoadPluginModule(const FileSpec &file_spec,
+ lldb_private::Status &error) override;
+
+ StructuredData::DictionarySP
+ GetDynamicSettings(StructuredData::ObjectSP plugin_module_sp, Target *target,
+ const char *setting_name,
+ lldb_private::Status &error) override;
+
+ size_t CalculateNumChildren(const StructuredData::ObjectSP &implementor,
+ uint32_t max) override;
+
+ lldb::ValueObjectSP
+ GetChildAtIndex(const StructuredData::ObjectSP &implementor,
+ uint32_t idx) override;
+
+ int GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor,
+ const char *child_name) override;
+
+ bool UpdateSynthProviderInstance(
+ const StructuredData::ObjectSP &implementor) override;
+
+ bool MightHaveChildrenSynthProviderInstance(
+ const StructuredData::ObjectSP &implementor) override;
+
+ lldb::ValueObjectSP
+ GetSyntheticValue(const StructuredData::ObjectSP &implementor) override;
+
+ ConstString
+ GetSyntheticTypeName(const StructuredData::ObjectSP &implementor) override;
+
+ bool
+ RunScriptBasedCommand(const char *impl_function, llvm::StringRef args,
+ ScriptedCommandSynchronicity synchronicity,
+ lldb_private::CommandReturnObject &cmd_retobj,
+ Status &error,
+ const lldb_private::ExecutionContext &exe_ctx) override;
+
+ bool RunScriptBasedCommand(
+ StructuredData::GenericSP impl_obj_sp, llvm::StringRef args,
+ ScriptedCommandSynchronicity synchronicity,
+ lldb_private::CommandReturnObject &cmd_retobj, Status &error,
+ const lldb_private::ExecutionContext &exe_ctx) override;
+
+ Status GenerateFunction(const char *signature,
+ const StringList &input) override;
+
+ Status GenerateBreakpointCommandCallbackData(StringList &input,
+ std::string &output) override;
+
+ bool GenerateWatchpointCommandCallbackData(StringList &input,
+ std::string &output) override;
+
+ bool GetScriptedSummary(const char *function_name, lldb::ValueObjectSP valobj,
+ StructuredData::ObjectSP &callee_wrapper_sp,
+ const TypeSummaryOptions &options,
+ std::string &retval) override;
+
+ void Clear() override;
+
+ bool GetDocumentationForItem(const char *item, std::string &dest) override;
+
+ bool GetShortHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,
+ std::string &dest) override;
+
+ uint32_t
+ GetFlagsForCommandObject(StructuredData::GenericSP cmd_obj_sp) override;
+
+ bool GetLongHelpForCommandObject(StructuredData::GenericSP cmd_obj_sp,
+ std::string &dest) override;
+
+ bool CheckObjectExists(const char *name) override {
+ if (!name || !name[0])
+ return false;
+ std::string temp;
+ return GetDocumentationForItem(name, temp);
+ }
+
+ bool RunScriptFormatKeyword(const char *impl_function, Process *process,
+ std::string &output, Status &error) override;
+
+ bool RunScriptFormatKeyword(const char *impl_function, Thread *thread,
+ std::string &output, Status &error) override;
+
+ bool RunScriptFormatKeyword(const char *impl_function, Target *target,
+ std::string &output, Status &error) override;
+
+ bool RunScriptFormatKeyword(const char *impl_function, StackFrame *frame,
+ std::string &output, Status &error) override;
+
+ bool RunScriptFormatKeyword(const char *impl_function, ValueObject *value,
+ std::string &output, Status &error) override;
+
+ bool
+ LoadScriptingModule(const char *filename, bool can_reload, bool init_session,
+ lldb_private::Status &error,
+ StructuredData::ObjectSP *module_sp = nullptr) override;
+
+ bool IsReservedWord(const char *word) override;
+
+ std::unique_ptr<ScriptInterpreterLocker> AcquireInterpreterLock() override;
+
+ void CollectDataForBreakpointCommandCallback(
+ std::vector<BreakpointOptions *> &bp_options_vec,
+ CommandReturnObject &result) override;
+
+ void
+ CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options,
+ CommandReturnObject &result) override;
+
+ /// Set the callback body text into the callback for the breakpoint.
+ Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
+ const char *callback_body) override;
+
+ void SetBreakpointCommandCallbackFunction(BreakpointOptions *bp_options,
+ const char *function_name) override;
+
+ /// This one is for deserialization:
+ Status SetBreakpointCommandCallback(
+ BreakpointOptions *bp_options,
+ std::unique_ptr<BreakpointOptions::CommandData> &data_up) override;
+
+ /// Set a one-liner as the callback for the watchpoint.
+ void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
+ const char *oneliner) override;
+
+ void ResetOutputFileHandle(FILE *new_fh) override;
+
+ const char *GetDictionaryName() { return m_dictionary_name.c_str(); }
+
+ PyThreadState *GetThreadState() { return m_command_thread_state; }
+
+ void SetThreadState(PyThreadState *s) {
+ if (s)
+ m_command_thread_state = s;
+ }
+
+ // IOHandlerDelegate
+ void IOHandlerActivated(IOHandler &io_handler, bool interactive) override;
+
+ void IOHandlerInputComplete(IOHandler &io_handler,
+ std::string &data) override;
+
+ static lldb::ScriptInterpreterSP CreateInstance(Debugger &debugger);
+
+ // PluginInterface protocol
+ lldb_private::ConstString GetPluginName() override;
+
+ uint32_t GetPluginVersion() override;
+
+ class Locker : public ScriptInterpreterLocker {
+ public:
+ enum OnEntry {
+ AcquireLock = 0x0001,
+ InitSession = 0x0002,
+ InitGlobals = 0x0004,
+ NoSTDIN = 0x0008
+ };
+
+ enum OnLeave {
+ FreeLock = 0x0001,
+ FreeAcquiredLock = 0x0002, // do not free the lock if we already held it
+ // when calling constructor
+ TearDownSession = 0x0004
+ };
+
+ Locker(ScriptInterpreterPythonImpl *py_interpreter = nullptr,
+ uint16_t on_entry = AcquireLock | InitSession,
+ uint16_t on_leave = FreeLock | TearDownSession, FILE *in = nullptr,
+ FILE *out = nullptr, FILE *err = nullptr);
+
+ ~Locker() override;
+
+ private:
+ bool DoAcquireLock();
+
+ bool DoInitSession(uint16_t on_entry_flags, FILE *in, FILE *out, FILE *err);
+
+ bool DoFreeLock();
+
+ bool DoTearDownSession();
+
+ bool m_teardown_session;
+ ScriptInterpreterPythonImpl *m_python_interpreter;
+ // FILE* m_tmp_fh;
+ PyGILState_STATE m_GILState;
+ };
+
+ static bool BreakpointCallbackFunction(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t break_id,
+ lldb::user_id_t break_loc_id);
+ static bool WatchpointCallbackFunction(void *baton,
+ StoppointCallbackContext *context,
+ lldb::user_id_t watch_id);
+ static void InitializePrivate();
+
+ class SynchronicityHandler {
+ private:
+ lldb::DebuggerSP m_debugger_sp;
+ ScriptedCommandSynchronicity m_synch_wanted;
+ bool m_old_asynch;
+
+ public:
+ SynchronicityHandler(lldb::DebuggerSP, ScriptedCommandSynchronicity);
+
+ ~SynchronicityHandler();
+ };
+
+ enum class AddLocation { Beginning, End };
+
+ static void AddToSysPath(AddLocation location, std::string path);
+
+ bool EnterSession(uint16_t on_entry_flags, FILE *in, FILE *out, FILE *err);
+
+ void LeaveSession();
+
+ void SaveTerminalState(int fd);
+
+ void RestoreTerminalState();
+
+ uint32_t IsExecutingPython() const { return m_lock_count > 0; }
+
+ uint32_t IncrementLockCount() { return ++m_lock_count; }
+
+ uint32_t DecrementLockCount() {
+ if (m_lock_count > 0)
+ --m_lock_count;
+ return m_lock_count;
+ }
+
+ enum ActiveIOHandler {
+ eIOHandlerNone,
+ eIOHandlerBreakpoint,
+ eIOHandlerWatchpoint
+ };
+
+ PythonObject &GetMainModule();
+
+ PythonDictionary &GetSessionDictionary();
+
+ PythonDictionary &GetSysModuleDictionary();
+
+ bool GetEmbeddedInterpreterModuleObjects();
+
+ bool SetStdHandle(File &file, const char *py_name, PythonFile &save_file,
+ const char *mode);
+
+ PythonFile m_saved_stdin;
+ PythonFile m_saved_stdout;
+ PythonFile m_saved_stderr;
+ PythonObject m_main_module;
+ PythonDictionary m_session_dict;
+ PythonDictionary m_sys_module_dict;
+ PythonObject m_run_one_line_function;
+ PythonObject m_run_one_line_str_global;
+ std::string m_dictionary_name;
+ TerminalState m_terminal_state;
+ ActiveIOHandler m_active_io_handler;
+ bool m_session_is_active;
+ bool m_pty_slave_is_open;
+ bool m_valid_session;
+ uint32_t m_lock_count;
+ PyThreadState *m_command_thread_state;
+};
+
+class IOHandlerPythonInterpreter : public IOHandler {
+public:
+ IOHandlerPythonInterpreter(Debugger &debugger,
+ ScriptInterpreterPythonImpl *python)
+ : IOHandler(debugger, IOHandler::Type::PythonInterpreter),
+ m_python(python) {}
+
+ ~IOHandlerPythonInterpreter() override {}
+
+ ConstString GetControlSequence(char ch) override {
+ if (ch == 'd')
+ return ConstString("quit()\n");
+ return ConstString();
+ }
+
+ void Run() override {
+ if (m_python) {
+ int stdin_fd = GetInputFD();
+ if (stdin_fd >= 0) {
+ Terminal terminal(stdin_fd);
+ TerminalState terminal_state;
+ const bool is_a_tty = terminal.IsATerminal();
+
+ if (is_a_tty) {
+ terminal_state.Save(stdin_fd, false);
+ terminal.SetCanonical(false);
+ terminal.SetEcho(true);
+ }
+
+ ScriptInterpreterPythonImpl::Locker locker(
+ m_python,
+ ScriptInterpreterPythonImpl::Locker::AcquireLock |
+ ScriptInterpreterPythonImpl::Locker::InitSession |
+ ScriptInterpreterPythonImpl::Locker::InitGlobals,
+ ScriptInterpreterPythonImpl::Locker::FreeAcquiredLock |
+ ScriptInterpreterPythonImpl::Locker::TearDownSession);
+
+ // The following call drops into the embedded interpreter loop and
+ // stays there until the user chooses to exit from the Python
+ // interpreter. This embedded interpreter will, as any Python code that
+ // performs I/O, unlock the GIL before a system call that can hang, and
+ // lock it when the syscall has returned.
+
+ // We need to surround the call to the embedded interpreter with calls
+ // to PyGILState_Ensure and PyGILState_Release (using the Locker
+ // above). This is because Python has a global lock which must be held
+ // whenever we want to touch any Python objects. Otherwise, if the user
+ // calls Python code, the interpreter state will be off, and things
+ // could hang (it's happened before).
+
+ StreamString run_string;
+ run_string.Printf("run_python_interpreter (%s)",
+ m_python->GetDictionaryName());
+ PyRun_SimpleString(run_string.GetData());
+
+ if (is_a_tty)
+ terminal_state.Restore();
+ }
+ }
+ SetIsDone(true);
+ }
+
+ void Cancel() override {}
+
+ bool Interrupt() override { return m_python->Interrupt(); }
+
+ void GotEOF() override {}
+
+protected:
+ ScriptInterpreterPythonImpl *m_python;
+};
+
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/ScriptInterpreter/Python/lldb-python.h b/source/Plugins/ScriptInterpreter/Python/lldb-python.h
index f929baade2e44..884514da99241 100644
--- a/source/Plugins/ScriptInterpreter/Python/lldb-python.h
+++ b/source/Plugins/ScriptInterpreter/Python/lldb-python.h
@@ -1,9 +1,8 @@
//===-- lldb-python.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,6 +32,12 @@
#undef _XOPEN_SOURCE
#endif
+// Include locale before Python so _PY_PORT_CTYPE_UTF8_ISSUE doesn't cause
+// macro redefinitions.
+#if defined(__APPLE__)
+#include <locale>
+#endif
+
// Include python for non windows machines
#include <Python.h>
#endif // LLDB_DISABLE_PYTHON
diff --git a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 6e3792bff9c49..81a27125c036a 100644
--- a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -1,18 +1,16 @@
//===-- StructuredDataDarwinLog.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "StructuredDataDarwinLog.h"
-// C includes
#include <string.h>
-// C++ includes
+#include <memory>
#include <sstream>
#include "lldb/Breakpoint/StoppointCallbackContext.h"
@@ -41,9 +39,7 @@ using namespace lldb_private;
#pragma mark -
#pragma mark Anonymous Namespace
-// -----------------------------------------------------------------------------
// Anonymous namespace
-// -----------------------------------------------------------------------------
namespace sddarwinlog_private {
const uint64_t NANOS_PER_MICRO = 1000;
@@ -54,13 +50,11 @@ const uint64_t NANOS_PER_HOUR = NANOS_PER_MINUTE * 60;
static bool DEFAULT_FILTER_FALLTHROUGH_ACCEPTS = true;
-//------------------------------------------------------------------
/// Global, sticky enable switch. If true, the user has explicitly
/// run the enable command. When a process launches or is attached to,
/// we will enable DarwinLog if either the settings for auto-enable is
/// on, or if the user had explicitly run enable at some point prior
/// to the launch/attach.
-//------------------------------------------------------------------
static bool s_is_explicitly_enabled;
class EnableOptions;
@@ -108,9 +102,7 @@ void SetGlobalEnableOptions(const DebuggerSP &debugger_sp,
#pragma mark -
#pragma mark Settings Handling
-//------------------------------------------------------------------
/// Code to handle the StructuredDataDarwinLog settings
-//------------------------------------------------------------------
static constexpr PropertyDefinition g_properties[] = {
{
@@ -145,11 +137,11 @@ public:
}
StructuredDataDarwinLogProperties() : Properties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
m_collection_sp->Initialize(g_properties);
}
- virtual ~StructuredDataDarwinLogProperties() {}
+ ~StructuredDataDarwinLogProperties() override {}
bool GetEnableOnStartup() const {
const uint32_t idx = ePropertyEnableOnStartup;
@@ -172,7 +164,7 @@ using StructuredDataDarwinLogPropertiesSP =
static const StructuredDataDarwinLogPropertiesSP &GetGlobalProperties() {
static StructuredDataDarwinLogPropertiesSP g_settings_sp;
if (!g_settings_sp)
- g_settings_sp.reset(new StructuredDataDarwinLogProperties());
+ g_settings_sp = std::make_shared<StructuredDataDarwinLogProperties>();
return g_settings_sp;
}
@@ -189,12 +181,12 @@ const char *const s_filter_attributes[] = {
// used to format message text
};
-static const ConstString &GetDarwinLogTypeName() {
+static ConstString GetDarwinLogTypeName() {
static const ConstString s_key_name("DarwinLog");
return s_key_name;
}
-static const ConstString &GetLogEventType() {
+static ConstString GetLogEventType() {
static const ConstString s_event_type("log");
return s_event_type;
}
@@ -210,13 +202,13 @@ public:
std::function<FilterRuleSP(bool accept, size_t attribute_index,
const std::string &op_arg, Status &error)>;
- static void RegisterOperation(const ConstString &operation,
+ static void RegisterOperation(ConstString operation,
const OperationCreationFunc &creation_func) {
GetCreationFuncMap().insert(std::make_pair(operation, creation_func));
}
static FilterRuleSP CreateRule(bool match_accepts, size_t attribute,
- const ConstString &operation,
+ ConstString operation,
const std::string &op_arg, Status &error) {
// Find the creation func for this type of filter rule.
auto map = GetCreationFuncMap();
@@ -254,10 +246,10 @@ public:
virtual void Dump(Stream &stream) const = 0;
- const ConstString &GetOperationType() const { return m_operation; }
+ ConstString GetOperationType() const { return m_operation; }
protected:
- FilterRule(bool accept, size_t attribute_index, const ConstString &operation)
+ FilterRule(bool accept, size_t attribute_index, ConstString operation)
: m_accept(accept), m_attribute_index(attribute_index),
m_operation(operation) {}
@@ -326,7 +318,7 @@ private:
return FilterRuleSP(new RegexFilterRule(accept, attribute_index, op_arg));
}
- static const ConstString &StaticGetOperation() {
+ static ConstString StaticGetOperation() {
static ConstString s_operation("regex");
return s_operation;
}
@@ -371,7 +363,7 @@ private:
new ExactMatchFilterRule(accept, attribute_index, op_arg));
}
- static const ConstString &StaticGetOperation() {
+ static ConstString StaticGetOperation() {
static ConstString s_operation("match");
return s_operation;
}
@@ -393,12 +385,10 @@ static void RegisterFilterOperations() {
// Commands
// =========================================================================
-// -------------------------------------------------------------------------
/// Provides the main on-off switch for enabling darwin logging.
///
/// It is valid to run the enable command when logging is already enabled.
/// This resets the logging with whatever settings are currently set.
-// -------------------------------------------------------------------------
static constexpr OptionDefinition g_enable_option_table[] = {
// Source stream include/exclude options (the first-level filter). This one
@@ -858,7 +848,7 @@ protected:
// that logging be enabled for a process before libtrace is initialized
// results in a scenario where no errors occur, but no logging is
// captured, either. This step is to eliminate that possibility.
- plugin.AddInitCompletionHook(*process_sp.get());
+ plugin.AddInitCompletionHook(*process_sp);
}
// Send configuration to the feature by way of the process. Construct the
@@ -892,9 +882,7 @@ private:
EnableOptionsSP m_options_sp;
};
-// -------------------------------------------------------------------------
/// Provides the status command.
-// -------------------------------------------------------------------------
class StatusCommand : public CommandObjectParsed {
public:
StatusCommand(CommandInterpreter &interpreter)
@@ -920,7 +908,7 @@ protected:
process_sp->GetStructuredDataPlugin(GetDarwinLogTypeName());
stream.Printf("Availability: %s\n",
plugin_sp ? "available" : "unavailable");
- auto &plugin_name = StructuredDataDarwinLog::GetStaticPluginName();
+ ConstString plugin_name = StructuredDataDarwinLog::GetStaticPluginName();
const bool enabled =
plugin_sp ? plugin_sp->GetEnabled(plugin_name) : false;
stream.Printf("Enabled: %s\n", enabled ? "true" : "false");
@@ -970,9 +958,7 @@ protected:
}
};
-// -------------------------------------------------------------------------
/// Provides the darwin-log base command
-// -------------------------------------------------------------------------
class BaseCommand : public CommandObjectMultiword {
public:
BaseCommand(CommandInterpreter &interpreter)
@@ -1084,9 +1070,7 @@ using namespace sddarwinlog_private;
#pragma mark -
#pragma mark Public static API
-// -----------------------------------------------------------------------------
// Public static API
-// -----------------------------------------------------------------------------
void StructuredDataDarwinLog::Initialize() {
RegisterFilterOperations();
@@ -1099,7 +1083,7 @@ void StructuredDataDarwinLog::Terminate() {
PluginManager::UnregisterPlugin(&CreateInstance);
}
-const ConstString &StructuredDataDarwinLog::GetStaticPluginName() {
+ConstString StructuredDataDarwinLog::GetStaticPluginName() {
static ConstString s_plugin_name("darwin-log");
return s_plugin_name;
}
@@ -1107,9 +1091,7 @@ const ConstString &StructuredDataDarwinLog::GetStaticPluginName() {
#pragma mark -
#pragma mark PluginInterface API
-// -----------------------------------------------------------------------------
// PluginInterface API
-// -----------------------------------------------------------------------------
ConstString StructuredDataDarwinLog::GetPluginName() {
return GetStaticPluginName();
@@ -1120,17 +1102,15 @@ uint32_t StructuredDataDarwinLog::GetPluginVersion() { return 1; }
#pragma mark -
#pragma mark StructuredDataPlugin API
-// -----------------------------------------------------------------------------
// StructuredDataPlugin API
-// -----------------------------------------------------------------------------
bool StructuredDataDarwinLog::SupportsStructuredDataType(
- const ConstString &type_name) {
+ ConstString type_name) {
return type_name == GetDarwinLogTypeName();
}
void StructuredDataDarwinLog::HandleArrivalOfStructuredData(
- Process &process, const ConstString &type_name,
+ Process &process, ConstString type_name,
const StructuredData::ObjectSP &object_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
if (log) {
@@ -1269,7 +1249,7 @@ Status StructuredDataDarwinLog::GetDescription(
return error;
}
-bool StructuredDataDarwinLog::GetEnabled(const ConstString &type_name) const {
+bool StructuredDataDarwinLog::GetEnabled(ConstString type_name) const {
if (type_name == GetStaticPluginName())
return m_is_enabled;
else
@@ -1372,9 +1352,7 @@ void StructuredDataDarwinLog::ModulesDidLoad(Process &process,
EnableNow();
}
-// -----------------------------------------------------------------------------
// public destructor
-// -----------------------------------------------------------------------------
StructuredDataDarwinLog::~StructuredDataDarwinLog() {
if (m_breakpoint_id != LLDB_INVALID_BREAK_ID) {
@@ -1389,9 +1367,7 @@ StructuredDataDarwinLog::~StructuredDataDarwinLog() {
#pragma mark -
#pragma mark Private instance methods
-// -----------------------------------------------------------------------------
// Private constructors
-// -----------------------------------------------------------------------------
StructuredDataDarwinLog::StructuredDataDarwinLog(const ProcessWP &process_wp)
: StructuredDataPlugin(process_wp), m_recorded_first_timestamp(false),
@@ -1399,9 +1375,7 @@ StructuredDataDarwinLog::StructuredDataDarwinLog(const ProcessWP &process_wp)
m_added_breakpoint_mutex(), m_added_breakpoint(),
m_breakpoint_id(LLDB_INVALID_BREAK_ID) {}
-// -----------------------------------------------------------------------------
// Private static methods
-// -----------------------------------------------------------------------------
StructuredDataPluginSP
StructuredDataDarwinLog::CreateInstance(Process &process) {
@@ -1636,8 +1610,8 @@ bool StructuredDataDarwinLog::InitCompletionHookCallback(
}
// Queue the thread plan.
- auto thread_plan_sp = ThreadPlanSP(
- new ThreadPlanCallOnFunctionExit(*thread_sp.get(), callback));
+ auto thread_plan_sp =
+ ThreadPlanSP(new ThreadPlanCallOnFunctionExit(*thread_sp, callback));
const bool abort_other_plans = false;
thread_sp->QueueThreadPlan(thread_plan_sp, abort_other_plans);
if (log)
diff --git a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
index 77b6e7be71c7a..8fa1eed66efbc 100644
--- a/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
+++ b/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h
@@ -1,9 +1,8 @@
//===-- StructuredDataDarwinLog.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,17 +24,14 @@ class StructuredDataDarwinLog : public StructuredDataPlugin {
friend sddarwinlog_private::EnableCommand;
public:
- // -------------------------------------------------------------------------
// Public static API
- // -------------------------------------------------------------------------
static void Initialize();
static void Terminate();
- static const ConstString &GetStaticPluginName();
+ static ConstString GetStaticPluginName();
- // -------------------------------------------------------------------------
/// Return whether the DarwinLog functionality is enabled.
///
/// The DarwinLog functionality is enabled if the user expicitly enabled
@@ -43,49 +39,40 @@ public:
/// that controls if we always enable it for newly created/attached
/// processes.
///
- /// @return
+ /// \return
/// True if DarwinLog support is/will be enabled for existing or
/// newly launched/attached processes.
- // -------------------------------------------------------------------------
static bool IsEnabled();
- // -------------------------------------------------------------------------
// PluginInterface API
- // -------------------------------------------------------------------------
ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- // -------------------------------------------------------------------------
// StructuredDataPlugin API
- // -------------------------------------------------------------------------
- bool SupportsStructuredDataType(const ConstString &type_name) override;
+ bool SupportsStructuredDataType(ConstString type_name) override;
void HandleArrivalOfStructuredData(
- Process &process, const ConstString &type_name,
+ Process &process, ConstString type_name,
const StructuredData::ObjectSP &object_sp) override;
Status GetDescription(const StructuredData::ObjectSP &object_sp,
lldb_private::Stream &stream) override;
- bool GetEnabled(const ConstString &type_name) const override;
+ bool GetEnabled(ConstString type_name) const override;
void ModulesDidLoad(Process &process, ModuleList &module_list) override;
- ~StructuredDataDarwinLog();
+ ~StructuredDataDarwinLog() override;
private:
- // -------------------------------------------------------------------------
// Private constructors
- // -------------------------------------------------------------------------
StructuredDataDarwinLog(const lldb::ProcessWP &process_wp);
- // -------------------------------------------------------------------------
// Private static methods
- // -------------------------------------------------------------------------
static lldb::StructuredDataPluginSP CreateInstance(Process &process);
@@ -99,16 +86,12 @@ private:
static Status FilterLaunchInfo(ProcessLaunchInfo &launch_info,
Target *target);
- // -------------------------------------------------------------------------
// Internal helper methods used by friend classes
- // -------------------------------------------------------------------------
void SetEnabled(bool enabled);
void AddInitCompletionHook(Process &process);
- // -------------------------------------------------------------------------
// Private methods
- // -------------------------------------------------------------------------
void DumpTimestamp(Stream &stream, uint64_t timestamp);
@@ -117,16 +100,12 @@ private:
size_t HandleDisplayOfEvent(const StructuredData::Dictionary &event,
Stream &stream);
- // -------------------------------------------------------------------------
/// Call the enable command again, using whatever settings were initially
/// made.
- // -------------------------------------------------------------------------
void EnableNow();
- // -------------------------------------------------------------------------
// Private data
- // -------------------------------------------------------------------------
bool m_recorded_first_timestamp;
uint64_t m_first_timestamp_seen;
bool m_is_enabled;
diff --git a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
index 2cca7a66b014c..d4258274a38c1 100644
--- a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
+++ b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
@@ -1,84 +1,166 @@
//===-- SymbolFileBreakpad.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h"
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/FileSystem.h"
+#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/PostfixExpression.h"
+#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/TypeMap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
#include "llvm/ADT/StringExtras.h"
using namespace lldb;
using namespace lldb_private;
using namespace lldb_private::breakpad;
-namespace {
-class LineIterator {
+class SymbolFileBreakpad::LineIterator {
public:
// begin iterator for sections of given type
- LineIterator(ObjectFile &obj, ConstString section_type)
- : m_obj(&obj), m_section_type(section_type), m_next_section_idx(0) {
+ LineIterator(ObjectFile &obj, Record::Kind section_type)
+ : m_obj(&obj), m_section_type(toString(section_type)),
+ m_next_section_idx(0), m_next_line(llvm::StringRef::npos) {
++*this;
}
+ // An iterator starting at the position given by the bookmark.
+ LineIterator(ObjectFile &obj, Record::Kind section_type, Bookmark bookmark);
+
// end iterator
explicit LineIterator(ObjectFile &obj)
: m_obj(&obj),
- m_next_section_idx(m_obj->GetSectionList()->GetNumSections(0)) {}
+ m_next_section_idx(m_obj->GetSectionList()->GetNumSections(0)),
+ m_current_line(llvm::StringRef::npos),
+ m_next_line(llvm::StringRef::npos) {}
friend bool operator!=(const LineIterator &lhs, const LineIterator &rhs) {
assert(lhs.m_obj == rhs.m_obj);
if (lhs.m_next_section_idx != rhs.m_next_section_idx)
return true;
- if (lhs.m_next_text.data() != rhs.m_next_text.data())
+ if (lhs.m_current_line != rhs.m_current_line)
return true;
- assert(lhs.m_current_text == rhs.m_current_text);
- assert(rhs.m_next_text == rhs.m_next_text);
+ assert(lhs.m_next_line == rhs.m_next_line);
return false;
}
const LineIterator &operator++();
- llvm::StringRef operator*() const { return m_current_text; }
+ llvm::StringRef operator*() const {
+ return m_section_text.slice(m_current_line, m_next_line);
+ }
+
+ Bookmark GetBookmark() const {
+ return Bookmark{m_next_section_idx, m_current_line};
+ }
private:
ObjectFile *m_obj;
ConstString m_section_type;
uint32_t m_next_section_idx;
- llvm::StringRef m_current_text;
- llvm::StringRef m_next_text;
+ llvm::StringRef m_section_text;
+ size_t m_current_line;
+ size_t m_next_line;
+
+ void FindNextLine() {
+ m_next_line = m_section_text.find('\n', m_current_line);
+ if (m_next_line != llvm::StringRef::npos) {
+ ++m_next_line;
+ if (m_next_line >= m_section_text.size())
+ m_next_line = llvm::StringRef::npos;
+ }
+ }
};
-} // namespace
-const LineIterator &LineIterator::operator++() {
+SymbolFileBreakpad::LineIterator::LineIterator(ObjectFile &obj,
+ Record::Kind section_type,
+ Bookmark bookmark)
+ : m_obj(&obj), m_section_type(toString(section_type)),
+ m_next_section_idx(bookmark.section), m_current_line(bookmark.offset) {
+ Section &sect =
+ *obj.GetSectionList()->GetSectionAtIndex(m_next_section_idx - 1);
+ assert(sect.GetName() == m_section_type);
+
+ DataExtractor data;
+ obj.ReadSectionData(&sect, data);
+ m_section_text = toStringRef(data.GetData());
+
+ assert(m_current_line < m_section_text.size());
+ FindNextLine();
+}
+
+const SymbolFileBreakpad::LineIterator &
+SymbolFileBreakpad::LineIterator::operator++() {
const SectionList &list = *m_obj->GetSectionList();
size_t num_sections = list.GetNumSections(0);
- while (m_next_text.empty() && m_next_section_idx < num_sections) {
+ while (m_next_line != llvm::StringRef::npos ||
+ m_next_section_idx < num_sections) {
+ if (m_next_line != llvm::StringRef::npos) {
+ m_current_line = m_next_line;
+ FindNextLine();
+ return *this;
+ }
+
Section &sect = *list.GetSectionAtIndex(m_next_section_idx++);
if (sect.GetName() != m_section_type)
continue;
DataExtractor data;
m_obj->ReadSectionData(&sect, data);
- m_next_text =
- llvm::StringRef(reinterpret_cast<const char *>(data.GetDataStart()),
- data.GetByteSize());
+ m_section_text = toStringRef(data.GetData());
+ m_next_line = 0;
}
- std::tie(m_current_text, m_next_text) = m_next_text.split('\n');
+ // We've reached the end.
+ m_current_line = m_next_line;
return *this;
}
-static llvm::iterator_range<LineIterator> lines(ObjectFile &obj,
- ConstString section_type) {
- return llvm::make_range(LineIterator(obj, section_type), LineIterator(obj));
+llvm::iterator_range<SymbolFileBreakpad::LineIterator>
+SymbolFileBreakpad::lines(Record::Kind section_type) {
+ return llvm::make_range(LineIterator(*m_obj_file, section_type),
+ LineIterator(*m_obj_file));
+}
+
+namespace {
+// A helper class for constructing the list of support files for a given compile
+// unit.
+class SupportFileMap {
+public:
+ // Given a breakpad file ID, return a file ID to be used in the support files
+ // for this compile unit.
+ size_t operator[](size_t file) {
+ return m_map.try_emplace(file, m_map.size() + 1).first->second;
+ }
+
+ // Construct a FileSpecList containing only the support files relevant for
+ // this compile unit (in the correct order).
+ FileSpecList translate(const FileSpec &cu_spec,
+ llvm::ArrayRef<FileSpec> all_files);
+
+private:
+ llvm::DenseMap<size_t, size_t> m_map;
+};
+} // namespace
+
+FileSpecList SupportFileMap::translate(const FileSpec &cu_spec,
+ llvm::ArrayRef<FileSpec> all_files) {
+ std::vector<FileSpec> result;
+ result.resize(m_map.size() + 1);
+ result[0] = cu_spec;
+ for (const auto &KV : m_map) {
+ if (KV.first < all_files.size())
+ result[KV.second] = all_files[KV.first];
+ }
+ return FileSpecList(std::move(result));
}
void SymbolFileBreakpad::Initialize() {
@@ -102,17 +184,42 @@ uint32_t SymbolFileBreakpad::CalculateAbilities() {
if (m_obj_file->GetPluginName() != ObjectFileBreakpad::GetPluginNameStatic())
return 0;
- return CompileUnits | Functions;
+ return CompileUnits | Functions | LineTables;
}
uint32_t SymbolFileBreakpad::GetNumCompileUnits() {
- // TODO
- return 0;
+ ParseCUData();
+ return m_cu_data->GetSize();
}
CompUnitSP SymbolFileBreakpad::ParseCompileUnitAtIndex(uint32_t index) {
- // TODO
- return nullptr;
+ if (index >= m_cu_data->GetSize())
+ return nullptr;
+
+ CompUnitData &data = m_cu_data->GetEntryRef(index).data;
+
+ ParseFileRecords();
+
+ FileSpec spec;
+
+ // The FileSpec of the compile unit will be the file corresponding to the
+ // first LINE record.
+ LineIterator It(*m_obj_file, Record::Func, data.bookmark), End(*m_obj_file);
+ assert(Record::classify(*It) == Record::Func);
+ ++It; // Skip FUNC record.
+ if (It != End) {
+ auto record = LineRecord::parse(*It);
+ if (record && record->FileNum < m_files->size())
+ spec = (*m_files)[record->FileNum];
+ }
+
+ auto cu_sp = std::make_shared<CompileUnit>(m_obj_file->GetModule(),
+ /*user_data*/ nullptr, spec, index,
+ eLanguageTypeUnknown,
+ /*is_optimized*/ eLazyBoolNo);
+
+ GetSymbolVendor().SetCompileUnitAtIndex(index, cu_sp);
+ return cu_sp;
}
size_t SymbolFileBreakpad::ParseFunctions(CompileUnit &comp_unit) {
@@ -121,20 +228,67 @@ size_t SymbolFileBreakpad::ParseFunctions(CompileUnit &comp_unit) {
}
bool SymbolFileBreakpad::ParseLineTable(CompileUnit &comp_unit) {
- // TODO
- return 0;
+ CompUnitData &data = m_cu_data->GetEntryRef(comp_unit.GetID()).data;
+
+ if (!data.line_table_up)
+ ParseLineTableAndSupportFiles(comp_unit, data);
+
+ comp_unit.SetLineTable(data.line_table_up.release());
+ return true;
+}
+
+bool SymbolFileBreakpad::ParseSupportFiles(CompileUnit &comp_unit,
+ FileSpecList &support_files) {
+ CompUnitData &data = m_cu_data->GetEntryRef(comp_unit.GetID()).data;
+ if (!data.support_files)
+ ParseLineTableAndSupportFiles(comp_unit, data);
+
+ support_files = std::move(*data.support_files);
+ return true;
}
uint32_t
SymbolFileBreakpad::ResolveSymbolContext(const Address &so_addr,
SymbolContextItem resolve_scope,
SymbolContext &sc) {
- // TODO
- return 0;
+ if (!(resolve_scope & (eSymbolContextCompUnit | eSymbolContextLineEntry)))
+ return 0;
+
+ ParseCUData();
+ uint32_t idx =
+ m_cu_data->FindEntryIndexThatContains(so_addr.GetFileAddress());
+ if (idx == UINT32_MAX)
+ return 0;
+
+ sc.comp_unit = GetSymbolVendor().GetCompileUnitAtIndex(idx).get();
+ SymbolContextItem result = eSymbolContextCompUnit;
+ if (resolve_scope & eSymbolContextLineEntry) {
+ if (sc.comp_unit->GetLineTable()->FindLineEntryByAddress(so_addr,
+ sc.line_entry)) {
+ result |= eSymbolContextLineEntry;
+ }
+ }
+
+ return result;
+}
+
+uint32_t SymbolFileBreakpad::ResolveSymbolContext(
+ const FileSpec &file_spec, uint32_t line, bool check_inlines,
+ lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
+ if (!(resolve_scope & eSymbolContextCompUnit))
+ return 0;
+
+ uint32_t old_size = sc_list.GetSize();
+ for (size_t i = 0, size = GetNumCompileUnits(); i < size; ++i) {
+ CompileUnit &cu = *GetSymbolVendor().GetCompileUnitAtIndex(i);
+ cu.ResolveSymbolContext(file_spec, line, check_inlines,
+ /*exact*/ false, resolve_scope, sc_list);
+ }
+ return sc_list.GetSize() - old_size;
}
uint32_t SymbolFileBreakpad::FindFunctions(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
SymbolContextList &sc_list) {
// TODO
@@ -153,7 +307,7 @@ uint32_t SymbolFileBreakpad::FindFunctions(const RegularExpression &regex,
}
uint32_t SymbolFileBreakpad::FindTypes(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
if (!append)
@@ -172,7 +326,7 @@ SymbolFileBreakpad::FindTypes(const std::vector<CompilerContext> &context,
void SymbolFileBreakpad::AddSymbols(Symtab &symtab) {
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
Module &module = *m_obj_file->GetModule();
- addr_t base = module.GetObjectFile()->GetBaseAddress().GetFileAddress();
+ addr_t base = GetBaseFileAddress();
if (base == LLDB_INVALID_ADDRESS) {
LLDB_LOG(log, "Unable to fetch the base address of object file. Skipping "
"symtab population.");
@@ -180,44 +334,320 @@ void SymbolFileBreakpad::AddSymbols(Symtab &symtab) {
}
const SectionList &list = *module.GetSectionList();
- for (llvm::StringRef line : lines(*m_obj_file, ConstString("PUBLIC"))) {
- // PUBLIC [m] address param_size name
- // skip PUBLIC keyword
- line = getToken(line).second;
- llvm::StringRef token;
- std::tie(token, line) = getToken(line);
- if (token == "m")
- std::tie(token, line) = getToken(line);
-
- addr_t address;
- if (!to_integer(token, address, 16))
- continue;
+ llvm::DenseMap<addr_t, Symbol> symbols;
+ auto add_symbol = [&](addr_t address, llvm::Optional<addr_t> size,
+ llvm::StringRef name) {
address += base;
-
- // skip param_size
- line = getToken(line).second;
-
- llvm::StringRef name = line.trim();
-
SectionSP section_sp = list.FindSectionContainingFileAddress(address);
if (!section_sp) {
LLDB_LOG(log,
"Ignoring symbol {0}, whose address ({1}) is outside of the "
"object file. Mismatched symbol file?",
name, address);
+ return;
+ }
+ symbols.try_emplace(
+ address, /*symID*/ 0, Mangled(name, /*is_mangled*/ false),
+ eSymbolTypeCode, /*is_global*/ true, /*is_debug*/ false,
+ /*is_trampoline*/ false, /*is_artificial*/ false,
+ AddressRange(section_sp, address - section_sp->GetFileAddress(),
+ size.getValueOr(0)),
+ size.hasValue(), /*contains_linker_annotations*/ false, /*flags*/ 0);
+ };
+
+ for (llvm::StringRef line : lines(Record::Func)) {
+ if (auto record = FuncRecord::parse(line))
+ add_symbol(record->Address, record->Size, record->Name);
+ }
+
+ for (llvm::StringRef line : lines(Record::Public)) {
+ if (auto record = PublicRecord::parse(line))
+ add_symbol(record->Address, llvm::None, record->Name);
+ else
+ LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line);
+ }
+
+ for (auto &KV : symbols)
+ symtab.AddSymbol(std::move(KV.second));
+ symtab.CalculateSymbolSizes();
+}
+
+static llvm::Optional<std::pair<llvm::StringRef, llvm::StringRef>>
+GetRule(llvm::StringRef &unwind_rules) {
+ // Unwind rules are of the form
+ // register1: expression1 register2: expression2 ...
+ // We assume none of the tokens in expression<n> end with a colon.
+
+ llvm::StringRef lhs, rest;
+ std::tie(lhs, rest) = getToken(unwind_rules);
+ if (!lhs.consume_back(":"))
+ return llvm::None;
+
+ // Seek forward to the next register: expression pair
+ llvm::StringRef::size_type pos = rest.find(": ");
+ if (pos == llvm::StringRef::npos) {
+ // No pair found, this means the rest of the string is a single expression.
+ unwind_rules = llvm::StringRef();
+ return std::make_pair(lhs, rest);
+ }
+
+ // Go back one token to find the end of the current rule.
+ pos = rest.rfind(' ', pos);
+ if (pos == llvm::StringRef::npos)
+ return llvm::None;
+
+ llvm::StringRef rhs = rest.take_front(pos);
+ unwind_rules = rest.drop_front(pos);
+ return std::make_pair(lhs, rhs);
+}
+
+static const RegisterInfo *
+ResolveRegister(const SymbolFile::RegisterInfoResolver &resolver,
+ llvm::StringRef name) {
+ if (name.consume_front("$"))
+ return resolver.ResolveName(name);
+
+ return nullptr;
+}
+
+static const RegisterInfo *
+ResolveRegisterOrRA(const SymbolFile::RegisterInfoResolver &resolver,
+ llvm::StringRef name) {
+ if (name == ".ra")
+ return resolver.ResolveNumber(eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+ return ResolveRegister(resolver, name);
+}
+
+bool SymbolFileBreakpad::ParseUnwindRow(llvm::StringRef unwind_rules,
+ const RegisterInfoResolver &resolver,
+ UnwindPlan::Row &row) {
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
+
+ llvm::BumpPtrAllocator node_alloc;
+ while (auto rule = GetRule(unwind_rules)) {
+ node_alloc.Reset();
+ llvm::StringRef lhs = rule->first;
+ postfix::Node *rhs = postfix::Parse(rule->second, node_alloc);
+ if (!rhs) {
+ LLDB_LOG(log, "Could not parse `{0}` as unwind rhs.", rule->second);
+ return false;
+ }
+
+ bool success = postfix::ResolveSymbols(
+ rhs, [&](postfix::SymbolNode &symbol) -> postfix::Node * {
+ llvm::StringRef name = symbol.GetName();
+ if (name == ".cfa" && lhs != ".cfa")
+ return postfix::MakeNode<postfix::InitialValueNode>(node_alloc);
+
+ if (const RegisterInfo *info = ResolveRegister(resolver, name)) {
+ return postfix::MakeNode<postfix::RegisterNode>(
+ node_alloc, info->kinds[eRegisterKindLLDB]);
+ }
+ return nullptr;
+ });
+
+ if (!success) {
+ LLDB_LOG(log, "Resolving symbols in `{0}` failed.", rule->second);
+ return false;
+ }
+
+ ArchSpec arch = m_obj_file->GetArchitecture();
+ StreamString dwarf(Stream::eBinary, arch.GetAddressByteSize(),
+ arch.GetByteOrder());
+ ToDWARF(*rhs, dwarf);
+ uint8_t *saved = m_allocator.Allocate<uint8_t>(dwarf.GetSize());
+ std::memcpy(saved, dwarf.GetData(), dwarf.GetSize());
+
+ if (lhs == ".cfa") {
+ row.GetCFAValue().SetIsDWARFExpression(saved, dwarf.GetSize());
+ } else if (const RegisterInfo *info = ResolveRegisterOrRA(resolver, lhs)) {
+ UnwindPlan::Row::RegisterLocation loc;
+ loc.SetIsDWARFExpression(saved, dwarf.GetSize());
+ row.SetRegisterInfo(info->kinds[eRegisterKindLLDB], loc);
+ } else
+ LLDB_LOG(log, "Invalid register `{0}` in unwind rule.", lhs);
+ }
+ if (unwind_rules.empty())
+ return true;
+
+ LLDB_LOG(log, "Could not parse `{0}` as an unwind rule.", unwind_rules);
+ return false;
+}
+
+UnwindPlanSP
+SymbolFileBreakpad::GetUnwindPlan(const Address &address,
+ const RegisterInfoResolver &resolver) {
+ ParseUnwindData();
+ const UnwindMap::Entry *entry =
+ m_unwind_data->FindEntryThatContains(address.GetFileAddress());
+ if (!entry)
+ return nullptr;
+
+ addr_t base = GetBaseFileAddress();
+ if (base == LLDB_INVALID_ADDRESS)
+ return nullptr;
+
+ LineIterator It(*m_obj_file, Record::StackCFI, entry->data), End(*m_obj_file);
+ llvm::Optional<StackCFIRecord> init_record = StackCFIRecord::parse(*It);
+ assert(init_record.hasValue());
+ assert(init_record->Size.hasValue());
+
+ auto plan_sp = std::make_shared<UnwindPlan>(lldb::eRegisterKindLLDB);
+ plan_sp->SetSourceName("breakpad STACK CFI");
+ plan_sp->SetUnwindPlanValidAtAllInstructions(eLazyBoolNo);
+ plan_sp->SetSourcedFromCompiler(eLazyBoolYes);
+ plan_sp->SetPlanValidAddressRange(
+ AddressRange(base + init_record->Address, *init_record->Size,
+ m_obj_file->GetModule()->GetSectionList()));
+
+ auto row_sp = std::make_shared<UnwindPlan::Row>();
+ row_sp->SetOffset(0);
+ if (!ParseUnwindRow(init_record->UnwindRules, resolver, *row_sp))
+ return nullptr;
+ plan_sp->AppendRow(row_sp);
+ for (++It; It != End; ++It) {
+ llvm::Optional<StackCFIRecord> record = StackCFIRecord::parse(*It);
+ if (!record.hasValue())
+ return nullptr;
+ if (record->Size.hasValue())
+ break;
+
+ row_sp = std::make_shared<UnwindPlan::Row>(*row_sp);
+ row_sp->SetOffset(record->Address - init_record->Address);
+ if (!ParseUnwindRow(record->UnwindRules, resolver, *row_sp))
+ return nullptr;
+ plan_sp->AppendRow(row_sp);
+ }
+ return plan_sp;
+}
+
+SymbolVendor &SymbolFileBreakpad::GetSymbolVendor() {
+ return *m_obj_file->GetModule()->GetSymbolVendor();
+}
+
+addr_t SymbolFileBreakpad::GetBaseFileAddress() {
+ return m_obj_file->GetModule()
+ ->GetObjectFile()
+ ->GetBaseAddress()
+ .GetFileAddress();
+}
+
+// Parse out all the FILE records from the breakpad file. These will be needed
+// when constructing the support file lists for individual compile units.
+void SymbolFileBreakpad::ParseFileRecords() {
+ if (m_files)
+ return;
+ m_files.emplace();
+
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
+ for (llvm::StringRef line : lines(Record::File)) {
+ auto record = FileRecord::parse(line);
+ if (!record) {
+ LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", line);
continue;
}
- symtab.AddSymbol(Symbol(
- /*symID*/ 0, Mangled(name, /*is_mangled*/ false), eSymbolTypeCode,
- /*is_global*/ true, /*is_debug*/ false, /*is_trampoline*/ false,
- /*is_artificial*/ false,
- AddressRange(section_sp, address - section_sp->GetFileAddress(), 0),
- /*size_is_valid*/ 0, /*contains_linker_annotations*/ false,
- /*flags*/ 0));
+ if (record->Number >= m_files->size())
+ m_files->resize(record->Number + 1);
+ FileSpec::Style style = FileSpec::GuessPathStyle(record->Name)
+ .getValueOr(FileSpec::Style::native);
+ (*m_files)[record->Number] = FileSpec(record->Name, style);
}
+}
- // TODO: Process FUNC records as well.
+void SymbolFileBreakpad::ParseCUData() {
+ if (m_cu_data)
+ return;
- symtab.CalculateSymbolSizes();
+ m_cu_data.emplace();
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
+ addr_t base = GetBaseFileAddress();
+ if (base == LLDB_INVALID_ADDRESS) {
+ LLDB_LOG(log, "SymbolFile parsing failed: Unable to fetch the base address "
+ "of object file.");
+ }
+
+ // We shall create one compile unit for each FUNC record. So, count the number
+ // of FUNC records, and store them in m_cu_data, together with their ranges.
+ for (LineIterator It(*m_obj_file, Record::Func), End(*m_obj_file); It != End;
+ ++It) {
+ if (auto record = FuncRecord::parse(*It)) {
+ m_cu_data->Append(CompUnitMap::Entry(base + record->Address, record->Size,
+ CompUnitData(It.GetBookmark())));
+ } else
+ LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", *It);
+ }
+ m_cu_data->Sort();
+}
+
+// Construct the list of support files and line table entries for the given
+// compile unit.
+void SymbolFileBreakpad::ParseLineTableAndSupportFiles(CompileUnit &cu,
+ CompUnitData &data) {
+ addr_t base = GetBaseFileAddress();
+ assert(base != LLDB_INVALID_ADDRESS &&
+ "How did we create compile units without a base address?");
+
+ SupportFileMap map;
+ data.line_table_up = llvm::make_unique<LineTable>(&cu);
+ std::unique_ptr<LineSequence> line_seq_up(
+ data.line_table_up->CreateLineSequenceContainer());
+ llvm::Optional<addr_t> next_addr;
+ auto finish_sequence = [&]() {
+ data.line_table_up->AppendLineEntryToSequence(
+ line_seq_up.get(), *next_addr, /*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*/ true);
+ data.line_table_up->InsertSequence(line_seq_up.get());
+ line_seq_up->Clear();
+ };
+
+ LineIterator It(*m_obj_file, Record::Func, data.bookmark), End(*m_obj_file);
+ assert(Record::classify(*It) == Record::Func);
+ for (++It; It != End; ++It) {
+ auto record = LineRecord::parse(*It);
+ if (!record)
+ break;
+
+ record->Address += base;
+
+ if (next_addr && *next_addr != record->Address) {
+ // Discontiguous entries. Finish off the previous sequence and reset.
+ finish_sequence();
+ }
+ data.line_table_up->AppendLineEntryToSequence(
+ line_seq_up.get(), record->Address, record->LineNum, /*column*/ 0,
+ map[record->FileNum], /*is_start_of_statement*/ true,
+ /*is_start_of_basic_block*/ false, /*is_prologue_end*/ false,
+ /*is_epilogue_begin*/ false, /*is_terminal_entry*/ false);
+ next_addr = record->Address + record->Size;
+ }
+ if (next_addr)
+ finish_sequence();
+ data.support_files = map.translate(cu, *m_files);
+}
+
+void SymbolFileBreakpad::ParseUnwindData() {
+ if (m_unwind_data)
+ return;
+
+ m_unwind_data.emplace();
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
+ addr_t base = GetBaseFileAddress();
+ if (base == LLDB_INVALID_ADDRESS) {
+ LLDB_LOG(log, "SymbolFile parsing failed: Unable to fetch the base address "
+ "of object file.");
+ }
+
+ for (LineIterator It(*m_obj_file, Record::StackCFI), End(*m_obj_file);
+ It != End; ++It) {
+ if (auto record = StackCFIRecord::parse(*It)) {
+ if (record->Size)
+ m_unwind_data->Append(UnwindMap::Entry(
+ base + record->Address, *record->Size, It.GetBookmark()));
+ } else
+ LLDB_LOG(log, "Failed to parse: {0}. Skipping record.", *It);
+ }
+ m_unwind_data->Sort();
}
diff --git a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
index 68e8d11c7dd79..8a0b7645fd0a1 100644
--- a/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
+++ b/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
@@ -1,16 +1,19 @@
//===-- SymbolFileBreakpad.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
#define LLDB_PLUGINS_SYMBOLFILE_BREAKPAD_SYMBOLFILEBREAKPAD_H
+#include "Plugins/ObjectFile/Breakpad/BreakpadRecords.h"
+#include "lldb/Core/FileSpecList.h"
+#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Symbol/UnwindPlan.h"
namespace lldb_private {
@@ -18,9 +21,7 @@ namespace breakpad {
class SymbolFileBreakpad : public SymbolFile {
public:
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
static void DebuggerInitialize(Debugger &debugger) {}
@@ -34,9 +35,7 @@ public:
return new SymbolFileBreakpad(obj_file);
}
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolFileBreakpad(ObjectFile *object_file) : SymbolFile(object_file) {}
~SymbolFileBreakpad() override {}
@@ -45,9 +44,7 @@ public:
void InitializeObject() override {}
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
@@ -64,20 +61,18 @@ public:
bool ParseDebugMacros(CompileUnit &comp_unit) override { return false; }
bool ParseSupportFiles(CompileUnit &comp_unit,
- FileSpecList &support_files) override {
- return false;
- }
+ FileSpecList &support_files) override;
size_t ParseTypes(CompileUnit &cu) override { return 0; }
- bool
- ParseImportedModules(const SymbolContext &sc,
- std::vector<ConstString> &imported_modules) override {
+ bool ParseImportedModules(
+ const SymbolContext &sc,
+ std::vector<lldb_private::SourceModule> &imported_modules) override {
return false;
}
size_t ParseBlocksRecursive(Function &func) override { return 0; }
- uint32_t FindGlobalVariables(const ConstString &name,
+ uint32_t FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override {
@@ -99,12 +94,17 @@ public:
lldb::SymbolContextItem resolve_scope,
SymbolContext &sc) override;
+ uint32_t ResolveSymbolContext(const FileSpec &file_spec, uint32_t line,
+ bool check_inlines,
+ lldb::SymbolContextItem resolve_scope,
+ SymbolContextList &sc_list) override;
+
size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
TypeList &type_list) override {
return 0;
}
- uint32_t FindFunctions(const ConstString &name,
+ uint32_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -113,7 +113,7 @@ public:
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
- uint32_t FindTypes(const ConstString &name,
+ uint32_t FindTypes(ConstString name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
@@ -127,17 +127,93 @@ public:
}
CompilerDeclContext
- FindNamespace(const ConstString &name,
+ FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) override {
return CompilerDeclContext();
}
void AddSymbols(Symtab &symtab) override;
+ lldb::UnwindPlanSP
+ GetUnwindPlan(const Address &address,
+ const RegisterInfoResolver &resolver) override;
+
ConstString GetPluginName() override { return GetPluginNameStatic(); }
uint32_t GetPluginVersion() override { return 1; }
private:
+ // A class representing a position in the breakpad file. Useful for
+ // remembering the position so we can go back to it later and parse more data.
+ // Can be converted to/from a LineIterator, but it has a much smaller memory
+ // footprint.
+ struct Bookmark {
+ uint32_t section;
+ size_t offset;
+
+ friend bool operator<(const Bookmark &lhs, const Bookmark &rhs) {
+ return std::tie(lhs.section, lhs.offset) <
+ std::tie(rhs.section, rhs.offset);
+ }
+ };
+
+ // At iterator class for simplifying algorithms reading data from the breakpad
+ // file. It iterates over all records (lines) in the sections of a given type.
+ // It also supports saving a specific position (via the GetBookmark() method)
+ // and then resuming from it afterwards.
+ class LineIterator;
+
+ // Return an iterator range for all records in the given object file of the
+ // given type.
+ llvm::iterator_range<LineIterator> lines(Record::Kind section_type);
+
+ // Breakpad files do not contain sufficient information to correctly
+ // reconstruct compile units. The approach chosen here is to treat each
+ // function as a compile unit. The compile unit name is the name if the first
+ // line entry belonging to this function.
+ // This class is our internal representation of a compile unit. It stores the
+ // CompileUnit object and a bookmark pointing to the FUNC record of the
+ // compile unit function. It also lazily construct the list of support files
+ // and line table entries for the compile unit, when these are needed.
+ class CompUnitData {
+ public:
+ CompUnitData(Bookmark bookmark) : bookmark(bookmark) {}
+
+ CompUnitData() = default;
+ CompUnitData(const CompUnitData &rhs) : bookmark(rhs.bookmark) {}
+ CompUnitData &operator=(const CompUnitData &rhs) {
+ bookmark = rhs.bookmark;
+ support_files.reset();
+ line_table_up.reset();
+ return *this;
+ }
+ friend bool operator<(const CompUnitData &lhs, const CompUnitData &rhs) {
+ return lhs.bookmark < rhs.bookmark;
+ }
+
+ Bookmark bookmark;
+ llvm::Optional<FileSpecList> support_files;
+ std::unique_ptr<LineTable> line_table_up;
+
+ };
+
+ SymbolVendor &GetSymbolVendor();
+ lldb::addr_t GetBaseFileAddress();
+ void ParseFileRecords();
+ void ParseCUData();
+ void ParseLineTableAndSupportFiles(CompileUnit &cu, CompUnitData &data);
+ void ParseUnwindData();
+ bool ParseUnwindRow(llvm::StringRef unwind_rules,
+ const RegisterInfoResolver &resolver,
+ UnwindPlan::Row &row);
+
+ using CompUnitMap = RangeDataVector<lldb::addr_t, lldb::addr_t, CompUnitData>;
+
+ llvm::Optional<std::vector<FileSpec>> m_files;
+ llvm::Optional<CompUnitMap> m_cu_data;
+
+ using UnwindMap = RangeDataVector<lldb::addr_t, lldb::addr_t, Bookmark>;
+ llvm::Optional<UnwindMap> m_unwind_data;
+ llvm::BumpPtrAllocator m_allocator;
};
} // namespace breakpad
diff --git a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index db75cf9c3bb3f..9ae047da13258 100644
--- a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -1,14 +1,12 @@
//===-- AppleDWARFIndex.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Plugins/SymbolFile/DWARF/AppleDWARFIndex.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
#include "Plugins/SymbolFile/DWARF/DWARFDeclContext.h"
#include "Plugins/SymbolFile/DWARF/DWARFUnit.h"
#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h"
@@ -75,8 +73,8 @@ void AppleDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
return;
DWARFMappedHash::DIEInfoArray hash_data;
- if (m_apple_names_up->AppendAllDIEsInRange(
- cu.GetOffset(), cu.GetNextCompileUnitOffset(), hash_data))
+ if (m_apple_names_up->AppendAllDIEsInRange(cu.GetOffset(),
+ cu.GetNextUnitOffset(), hash_data))
DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
}
@@ -134,14 +132,14 @@ void AppleDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
m_apple_namespaces_up->FindByName(name.GetStringRef(), offsets);
}
-void AppleDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
+void AppleDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) {
DIEArray offsets;
m_apple_names_up->FindByName(name.GetStringRef(), offsets);
for (const DIERef &die_ref : offsets) {
- ProcessFunctionDIE(name.GetStringRef(), die_ref, info, parent_decl_ctx,
+ ProcessFunctionDIE(name.GetStringRef(), die_ref, dwarf, parent_decl_ctx,
name_type_mask, dies);
}
}
@@ -156,12 +154,12 @@ void AppleDWARFIndex::GetFunctions(const RegularExpression &regex,
DWARFMappedHash::ExtractDIEArray(hash_data, offsets);
}
-void AppleDWARFIndex::ReportInvalidDIEOffset(dw_offset_t offset,
- llvm::StringRef name) {
+void AppleDWARFIndex::ReportInvalidDIERef(const DIERef &ref,
+ llvm::StringRef name) {
m_module.ReportErrorIfModifyDetected(
"the DWARF debug information has been modified (accelerator table had "
"bad die 0x%8.8x for '%s')\n",
- offset, name.str().c_str());
+ ref.die_offset(), name.str().c_str());
}
void AppleDWARFIndex::Dump(Stream &s) {
diff --git a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
index ea133d0e73cf5..d15d61e270b30 100644
--- a/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -1,9 +1,8 @@
//===-- AppleDWARFIndex.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -43,14 +42,13 @@ public:
void GetTypes(ConstString name, DIEArray &offsets) override;
void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
void GetNamespaces(ConstString name, DIEArray &offsets) override;
- void GetFunctions(ConstString name, DWARFDebugInfo &info,
+ void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) override;
void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
- void ReportInvalidDIEOffset(dw_offset_t offset,
- llvm::StringRef name) override;
+ void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override;
void Dump(Stream &s) override;
private:
diff --git a/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/source/Plugins/SymbolFile/DWARF/DIERef.cpp
index 0cd0f0c0272a2..f7f2a5bf006b3 100644
--- a/source/Plugins/SymbolFile/DWARF/DIERef.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DIERef.cpp
@@ -1,67 +1,18 @@
//===-- DIERef.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DIERef.h"
-#include "DWARFUnit.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFFormValue.h"
-#include "SymbolFileDWARF.h"
-#include "SymbolFileDWARFDebugMap.h"
-
-DIERef::DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf)
- : cu_offset(DW_INVALID_OFFSET), die_offset(uid & 0xffffffff) {
- SymbolFileDWARFDebugMap *debug_map = dwarf->GetDebugMapSymfile();
- if (debug_map) {
- const uint32_t oso_idx = debug_map->GetOSOIndexFromUserID(uid);
- SymbolFileDWARF *actual_dwarf = debug_map->GetSymbolFileByOSOIndex(oso_idx);
- if (actual_dwarf) {
- DWARFDebugInfo *debug_info = actual_dwarf->DebugInfo();
- if (debug_info) {
- DWARFUnit *dwarf_cu =
- debug_info->GetCompileUnitContainingDIEOffset(die_offset);
- if (dwarf_cu) {
- cu_offset = dwarf_cu->GetOffset();
- return;
- }
- }
- }
- die_offset = DW_INVALID_OFFSET;
- } else {
- cu_offset = uid >> 32;
- }
-}
-
-DIERef::DIERef(const DWARFFormValue &form_value)
- : cu_offset(DW_INVALID_OFFSET), die_offset(DW_INVALID_OFFSET) {
- if (form_value.IsValid()) {
- const DWARFUnit *dwarf_cu = form_value.GetCompileUnit();
- if (dwarf_cu) {
- if (dwarf_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
- cu_offset = dwarf_cu->GetBaseObjOffset();
- else
- cu_offset = dwarf_cu->GetOffset();
- }
- die_offset = form_value.Reference();
- }
-}
+#include "llvm/Support/Format.h"
-lldb::user_id_t DIERef::GetUID(SymbolFileDWARF *dwarf) const {
- //----------------------------------------------------------------------
- // Each SymbolFileDWARF will set its ID to what is expected.
- //
- // SymbolFileDWARF, when used for DWARF with .o files on MacOSX, has the
- // ID set to the compile unit index.
- //
- // SymbolFileDWARFDwo sets the ID to the compile unit offset.
- //----------------------------------------------------------------------
- if (dwarf && die_offset != DW_INVALID_OFFSET)
- return dwarf->GetID() | die_offset;
- else
- return LLDB_INVALID_UID;
+void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS,
+ StringRef Style) {
+ if (ref.dwo_num())
+ OS << format_hex_no_prefix(*ref.dwo_num(), 8) << "/";
+ OS << (ref.section() == DIERef::DebugInfo ? "INFO" : "TYPE");
+ OS << "/" << format_hex_no_prefix(ref.die_offset(), 8);
}
diff --git a/source/Plugins/SymbolFile/DWARF/DIERef.h b/source/Plugins/SymbolFile/DWARF/DIERef.h
index cb28c890c25a1..5546bb7e8b86a 100644
--- a/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ b/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -1,9 +1,8 @@
//===-- DIERef.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,48 +10,54 @@
#define SymbolFileDWARF_DIERef_h_
#include "lldb/Core/dwarf.h"
-#include "lldb/lldb-defines.h"
-
-class DWARFFormValue;
-class SymbolFileDWARF;
-
-struct DIERef {
- DIERef() = default;
-
- DIERef(dw_offset_t c, dw_offset_t d) : cu_offset(c), die_offset(d) {}
-
- //----------------------------------------------------------------------
- // In order to properly decode a lldb::user_id_t back into a DIERef we
- // need the DWARF file since it knows if DWARF in .o files is being used
- // (MacOSX) or if DWO files are being used. The encoding of the user ID
- // differs between the two types of DWARF.
- //----------------------------------------------------------------------
- explicit DIERef(lldb::user_id_t uid, SymbolFileDWARF *dwarf);
-
- explicit DIERef(const DWARFFormValue &form_value);
-
- //----------------------------------------------------------------------
- // In order to properly encode a DIERef unto a lldb::user_id_t we need
- // the DWARF file since it knows if DWARF in .o files is being used
- // (MacOSX) or if DWO files are being used. The encoding of the user ID
- // differs between the two types of DWARF.
- //----------------------------------------------------------------------
- lldb::user_id_t GetUID(SymbolFileDWARF *dwarf) const;
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/FormatProviders.h"
+#include <cassert>
+#include <vector>
+
+/// Identifies a DWARF debug info entry within a given Module. It contains three
+/// "coordinates":
+/// - dwo_num: identifies the dwo file in the Module. If this field is not set,
+/// the DIERef references the main file.
+/// - section: identifies the section of the debug info entry in the given file:
+/// debug_info or debug_types.
+/// - die_offset: The offset of the debug info entry as an absolute offset from
+/// the beginning of the section specified in the section field.
+class DIERef {
+public:
+ enum Section : uint8_t { DebugInfo, DebugTypes };
+
+ DIERef(llvm::Optional<uint32_t> dwo_num, Section section,
+ dw_offset_t die_offset)
+ : m_dwo_num(dwo_num.getValueOr(0)), m_dwo_num_valid(bool(dwo_num)),
+ m_section(section), m_die_offset(die_offset) {
+ assert(this->dwo_num() == dwo_num && "Dwo number out of range?");
+ }
- bool operator<(const DIERef &ref) const {
- return die_offset < ref.die_offset;
+ llvm::Optional<uint32_t> dwo_num() const {
+ if (m_dwo_num_valid)
+ return m_dwo_num;
+ return llvm::None;
}
- bool operator<(const DIERef &ref) { return die_offset < ref.die_offset; }
+ Section section() const { return static_cast<Section>(m_section); }
- explicit operator bool() const {
- return cu_offset != DW_INVALID_OFFSET || die_offset != DW_INVALID_OFFSET;
- }
+ dw_offset_t die_offset() const { return m_die_offset; }
- dw_offset_t cu_offset = DW_INVALID_OFFSET;
- dw_offset_t die_offset = DW_INVALID_OFFSET;
+private:
+ uint32_t m_dwo_num : 30;
+ uint32_t m_dwo_num_valid : 1;
+ uint32_t m_section : 1;
+ dw_offset_t m_die_offset;
};
+static_assert(sizeof(DIERef) == 8, "");
typedef std::vector<DIERef> DIEArray;
+namespace llvm {
+template<> struct format_provider<DIERef> {
+ static void format(const DIERef &ref, raw_ostream &OS, StringRef Style);
+};
+} // namespace llvm
+
#endif // SymbolFileDWARF_DIERef_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 24d5f26745dc5..e7927b31b9c31 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -1,9 +1,8 @@
//===-- DWARFASTParser.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 70d48e5f1dfa1..b85ab54a10d3a 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1,9 +1,8 @@
//===-- DWARFASTParserClang.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "DWARFASTParserClang.h"
#include "DWARFDIE.h"
-#include "DWARFDIECollection.h"
#include "DWARFDebugInfo.h"
#include "DWARFDeclContext.h"
#include "DWARFDefines.h"
@@ -44,6 +42,7 @@
#include "clang/AST/DeclTemplate.h"
#include <map>
+#include <memory>
#include <vector>
//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
@@ -118,10 +117,10 @@ struct BitfieldInfo {
};
ClangASTImporter &DWARFASTParserClang::GetClangASTImporter() {
- if (!m_clang_ast_importer_ap) {
- m_clang_ast_importer_ap.reset(new ClangASTImporter);
+ if (!m_clang_ast_importer_up) {
+ m_clang_ast_importer_up.reset(new ClangASTImporter);
}
- return *m_clang_ast_importer_ap;
+ return *m_clang_ast_importer_up;
}
/// Detect a forward declaration that is nested in a DW_TAG_module.
@@ -156,8 +155,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
// Since this this type is defined in one of the Clang modules imported by
// this symbol file, search all of them.
- auto *sym_file = die.GetCU()->GetSymbolFileDWARF();
- for (const auto &name_module : sym_file->getExternalTypeModules()) {
+ auto &sym_file = die.GetCU()->GetSymbolFileDWARF();
+ for (const auto &name_module : sym_file.getExternalTypeModules()) {
if (!name_module.second)
continue;
SymbolVendor *sym_vendor = name_module.second->GetSymbolVendor();
@@ -186,7 +185,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
SymbolFileDWARF *dwarf = die.GetDWARF();
TypeSP type_sp(new Type(
die.GetID(), dwarf, dwo_type_sp->GetName(), dwo_type_sp->GetByteSize(),
- NULL, LLDB_INVALID_UID, Type::eEncodingInvalid,
+ nullptr, LLDB_INVALID_UID, Type::eEncodingInvalid,
&dwo_type_sp->GetDeclaration(), type, Type::eResolveStateForward));
dwarf->GetTypeList()->Insert(type_sp);
@@ -229,1676 +228,1454 @@ static void CompleteExternalTagDeclType(ClangASTImporter &ast_importer,
}
}
+namespace {
+/// Parsed form of all attributes that are relevant for type reconstruction.
+/// Some attributes are relevant for all kinds of types (declaration), while
+/// others are only meaningful to a specific type (is_virtual)
+struct ParsedTypeAttributes {
+ explicit ParsedTypeAttributes(const DWARFDIE &die);
+
+ AccessType accessibility = eAccessNone;
+ bool is_artificial = false;
+ bool is_complete_objc_class = false;
+ bool is_explicit = false;
+ bool is_forward_declaration = false;
+ bool is_inline = false;
+ bool is_scoped_enum = false;
+ bool is_vector = false;
+ bool is_virtual = false;
+ clang::StorageClass storage = clang::SC_None;
+ const char *mangled_name = nullptr;
+ ConstString name;
+ Declaration decl;
+ DWARFDIE object_pointer;
+ DWARFFormValue abstract_origin;
+ DWARFFormValue containing_type;
+ DWARFFormValue signature;
+ DWARFFormValue specification;
+ DWARFFormValue type;
+ LanguageType class_language = eLanguageTypeUnknown;
+ llvm::Optional<uint64_t> byte_size;
+ size_t calling_convention = llvm::dwarf::DW_CC_normal;
+ uint32_t bit_stride = 0;
+ uint32_t byte_stride = 0;
+ uint32_t encoding = 0;
+};
+} // namespace
+
+ParsedTypeAttributes::ParsedTypeAttributes(const DWARFDIE &die) {
+ DWARFAttributes attributes;
+ size_t num_attributes = die.GetAttributes(attributes);
+ for (size_t i = 0; i < num_attributes; ++i) {
+ dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (!attributes.ExtractFormValueAtIndex(i, form_value))
+ continue;
+ switch (attr) {
+ case DW_AT_abstract_origin:
+ abstract_origin = form_value;
+ break;
+
+ case DW_AT_accessibility:
+ accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
+ break;
+
+ case DW_AT_artificial:
+ is_artificial = form_value.Boolean();
+ break;
+
+ case DW_AT_bit_stride:
+ bit_stride = form_value.Unsigned();
+ break;
+
+ case DW_AT_byte_size:
+ byte_size = form_value.Unsigned();
+ break;
+
+ case DW_AT_byte_stride:
+ byte_stride = form_value.Unsigned();
+ break;
+
+ case DW_AT_calling_convention:
+ calling_convention = form_value.Unsigned();
+ break;
+
+ case DW_AT_containing_type:
+ containing_type = form_value;
+ break;
+
+ case DW_AT_decl_file:
+ decl.SetFile(die.GetCU()->GetFile(form_value.Unsigned()));
+ break;
+ case DW_AT_decl_line:
+ decl.SetLine(form_value.Unsigned());
+ break;
+ case DW_AT_decl_column:
+ decl.SetColumn(form_value.Unsigned());
+ break;
+
+ case DW_AT_declaration:
+ is_forward_declaration = form_value.Boolean();
+ break;
+
+ case DW_AT_encoding:
+ encoding = form_value.Unsigned();
+ break;
+
+ case DW_AT_enum_class:
+ is_scoped_enum = form_value.Boolean();
+ break;
+
+ case DW_AT_explicit:
+ is_explicit = form_value.Boolean();
+ break;
+
+ case DW_AT_external:
+ if (form_value.Unsigned())
+ storage = clang::SC_Extern;
+ break;
+
+ case DW_AT_inline:
+ is_inline = form_value.Boolean();
+ break;
+
+ case DW_AT_linkage_name:
+ case DW_AT_MIPS_linkage_name:
+ mangled_name = form_value.AsCString();
+ break;
+
+ case DW_AT_name:
+ name.SetCString(form_value.AsCString());
+ break;
+
+ case DW_AT_object_pointer:
+ object_pointer = form_value.Reference();
+ break;
+
+ case DW_AT_signature:
+ signature = form_value;
+ break;
+
+ case DW_AT_specification:
+ specification = form_value;
+ break;
+
+ case DW_AT_type:
+ type = form_value;
+ break;
+
+ case DW_AT_virtuality:
+ is_virtual = form_value.Boolean();
+ break;
+
+ case DW_AT_APPLE_objc_complete_type:
+ is_complete_objc_class = form_value.Signed();
+ break;
+
+ case DW_AT_APPLE_runtime_class:
+ class_language = (LanguageType)form_value.Signed();
+ break;
+
+ case DW_AT_GNU_vector:
+ is_vector = form_value.Boolean();
+ break;
+ }
+ }
+}
+
+static std::string GetUnitName(const DWARFDIE &die) {
+ if (DWARFUnit *unit = die.GetCU())
+ return unit->GetAbsolutePath().GetPath();
+ return "<missing DWARF unit path>";
+}
+
TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
const DWARFDIE &die, Log *log,
bool *type_is_new_ptr) {
- TypeSP type_sp;
-
if (type_is_new_ptr)
*type_is_new_ptr = false;
- AccessType accessibility = eAccessNone;
- if (die) {
- SymbolFileDWARF *dwarf = die.GetDWARF();
- if (log) {
- DWARFDIE context_die;
- clang::DeclContext *context =
- GetClangDeclContextContainingDIE(die, &context_die);
-
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ParseType (die = 0x%8.8x, decl_ctx = %p (die "
- "0x%8.8x)) %s name = '%s')",
- die.GetOffset(), static_cast<void *>(context),
- context_die.GetOffset(), die.GetTagAsCString(), die.GetName());
+ if (!die)
+ return nullptr;
+ SymbolFileDWARF *dwarf = die.GetDWARF();
+ if (log) {
+ DWARFDIE context_die;
+ clang::DeclContext *context =
+ GetClangDeclContextContainingDIE(die, &context_die);
+
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF::ParseType (die = 0x%8.8x, decl_ctx = %p (die "
+ "0x%8.8x)) %s name = '%s')",
+ die.GetOffset(), static_cast<void *>(context), context_die.GetOffset(),
+ die.GetTagAsCString(), die.GetName());
+ }
+
+
+ Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
+ if (type_ptr == DIE_IS_BEING_PARSED)
+ return nullptr;
+ if (type_ptr)
+ return type_ptr->shared_from_this();
+ // Set a bit that lets us know that we are currently parsing this
+ dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+
+ ParsedTypeAttributes attrs(die);
+
+ if (DWARFDIE signature_die = attrs.signature.Reference()) {
+ if (TypeSP type_sp =
+ ParseTypeFromDWARF(sc, signature_die, log, type_is_new_ptr)) {
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ if (clang::DeclContext *decl_ctx =
+ GetCachedClangDeclContextForDIE(signature_die))
+ LinkDeclContextToDIE(decl_ctx, die);
+ return type_sp;
}
- Type *type_ptr = dwarf->GetDIEToType().lookup(die.GetDIE());
- TypeList *type_list = dwarf->GetTypeList();
- if (type_ptr == NULL) {
- if (type_is_new_ptr)
- *type_is_new_ptr = true;
+ return nullptr;
+ }
- const dw_tag_t tag = die.Tag();
+ TypeList *type_list = dwarf->GetTypeList();
+ if (type_is_new_ptr)
+ *type_is_new_ptr = true;
- bool is_forward_declaration = false;
- DWARFAttributes attributes;
- const char *type_name_cstr = NULL;
- const char *mangled_name_cstr = NULL;
- ConstString type_name_const_str;
- Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
- uint64_t byte_size = 0;
- Declaration decl;
-
- Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
- CompilerType clang_type;
- DWARFFormValue form_value;
+ const dw_tag_t tag = die.Tag();
- dw_attr_t attr;
-
- switch (tag) {
- case DW_TAG_typedef:
- case DW_TAG_base_type:
- case DW_TAG_pointer_type:
- case DW_TAG_reference_type:
- case DW_TAG_rvalue_reference_type:
- case DW_TAG_const_type:
- case DW_TAG_restrict_type:
- case DW_TAG_volatile_type:
- case DW_TAG_unspecified_type: {
- // Set a bit that lets us know that we are currently parsing this
- dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
- const size_t num_attributes = die.GetAttributes(attributes);
- uint32_t encoding = 0;
- DWARFFormValue encoding_uid;
-
- if (num_attributes > 0) {
- uint32_t i;
- for (i = 0; i < num_attributes; ++i) {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
- case DW_AT_name:
- type_name_cstr = form_value.AsCString();
- if (type_name_cstr)
- type_name_const_str.SetCString(type_name_cstr);
- break;
- case DW_AT_byte_size:
- byte_size = form_value.Unsigned();
- break;
- case DW_AT_encoding:
- encoding = form_value.Unsigned();
- break;
- case DW_AT_type:
- encoding_uid = form_value;
- break;
- default:
- case DW_AT_sibling:
- break;
- }
- }
- }
- }
+ Type::ResolveState resolve_state = Type::eResolveStateUnresolved;
- if (tag == DW_TAG_typedef && encoding_uid.IsValid()) {
- // Try to parse a typedef from the DWO file first as modules can
- // contain typedef'ed structures that have no names like:
- //
- // typedef struct { int a; } Foo;
- //
- // In this case we will have a structure with no name and a typedef
- // named "Foo" that points to this unnamed structure. The name in the
- // typedef is the only identifier for the struct, so always try to
- // get typedefs from DWO files if possible.
- //
- // The type_sp returned will be empty if the typedef doesn't exist in
- // a DWO file, so it is cheap to call this function just to check.
- //
- // If we don't do this we end up creating a TypeSP that says this is
- // a typedef to type 0x123 (the DW_AT_type value would be 0x123 in
- // the DW_TAG_typedef), and this is the unnamed structure type. We
- // will have a hard time tracking down an unnammed structure type in
- // the module DWO file, so we make sure we don't get into this
- // situation by always resolving typedefs from the DWO file.
- const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
-
- // First make sure that the die that this is typedef'ed to _is_ just
- // a declaration (DW_AT_declaration == 1), not a full definition
- // since template types can't be represented in modules since only
- // concrete instances of templates are ever emitted and modules won't
- // contain those
- if (encoding_die &&
- encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) ==
- 1) {
- type_sp = ParseTypeFromDWO(die, log);
- if (type_sp)
- return type_sp;
- }
- }
+ Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID;
+ CompilerType clang_type;
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n",
- die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr,
- encoding_uid.Reference());
+ TypeSP type_sp;
+ LanguageType cu_language = die.GetLanguage();
+ switch (tag) {
+ case DW_TAG_typedef:
+ case DW_TAG_base_type:
+ case DW_TAG_pointer_type:
+ case DW_TAG_reference_type:
+ case DW_TAG_rvalue_reference_type:
+ case DW_TAG_const_type:
+ case DW_TAG_restrict_type:
+ case DW_TAG_volatile_type:
+ case DW_TAG_unspecified_type: {
+ if (tag == DW_TAG_typedef && attrs.type.IsValid()) {
+ // Try to parse a typedef from the DWO file first as modules can
+ // contain typedef'ed structures that have no names like:
+ //
+ // typedef struct { int a; } Foo;
+ //
+ // In this case we will have a structure with no name and a typedef
+ // named "Foo" that points to this unnamed structure. The name in the
+ // typedef is the only identifier for the struct, so always try to
+ // get typedefs from DWO files if possible.
+ //
+ // The type_sp returned will be empty if the typedef doesn't exist in
+ // a DWO file, so it is cheap to call this function just to check.
+ //
+ // If we don't do this we end up creating a TypeSP that says this is
+ // a typedef to type 0x123 (the DW_AT_type value would be 0x123 in
+ // the DW_TAG_typedef), and this is the unnamed structure type. We
+ // will have a hard time tracking down an unnammed structure type in
+ // the module DWO file, so we make sure we don't get into this
+ // situation by always resolving typedefs from the DWO file.
+ const DWARFDIE encoding_die = attrs.type.Reference();
+
+ // First make sure that the die that this is typedef'ed to _is_ just
+ // a declaration (DW_AT_declaration == 1), not a full definition
+ // since template types can't be represented in modules since only
+ // concrete instances of templates are ever emitted and modules won't
+ // contain those
+ if (encoding_die &&
+ encoding_die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0) == 1) {
+ type_sp = ParseTypeFromDWO(die, log);
+ if (type_sp)
+ return type_sp;
+ }
+ }
- switch (tag) {
- default:
- break;
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\") type => 0x%8.8lx\n",
+ die.GetID(), DW_TAG_value_to_name(tag), type_name_cstr,
+ encoding_uid.Reference());
- case DW_TAG_unspecified_type:
- if (strcmp(type_name_cstr, "nullptr_t") == 0 ||
- strcmp(type_name_cstr, "decltype(nullptr)") == 0) {
- resolve_state = Type::eResolveStateFull;
- clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
- break;
- }
- // Fall through to base type below in case we can handle the type
- // there...
- LLVM_FALLTHROUGH;
-
- case DW_TAG_base_type:
- resolve_state = Type::eResolveStateFull;
- clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
- type_name_cstr, encoding, byte_size * 8);
- break;
+ switch (tag) {
+ default:
+ break;
- case DW_TAG_pointer_type:
- encoding_data_type = Type::eEncodingIsPointerUID;
- break;
- case DW_TAG_reference_type:
- encoding_data_type = Type::eEncodingIsLValueReferenceUID;
- break;
- case DW_TAG_rvalue_reference_type:
- encoding_data_type = Type::eEncodingIsRValueReferenceUID;
- break;
- case DW_TAG_typedef:
- encoding_data_type = Type::eEncodingIsTypedefUID;
- break;
- case DW_TAG_const_type:
- encoding_data_type = Type::eEncodingIsConstUID;
- break;
- case DW_TAG_restrict_type:
- encoding_data_type = Type::eEncodingIsRestrictUID;
- break;
- case DW_TAG_volatile_type:
- encoding_data_type = Type::eEncodingIsVolatileUID;
- break;
- }
+ case DW_TAG_unspecified_type:
+ if (attrs.name == "nullptr_t" || attrs.name == "decltype(nullptr)") {
+ resolve_state = Type::eResolveStateFull;
+ clang_type = m_ast.GetBasicType(eBasicTypeNullPtr);
+ break;
+ }
+ // Fall through to base type below in case we can handle the type
+ // there...
+ LLVM_FALLTHROUGH;
+
+ case DW_TAG_base_type:
+ resolve_state = Type::eResolveStateFull;
+ clang_type = m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
+ attrs.name.GetCString(), attrs.encoding,
+ attrs.byte_size.getValueOr(0) * 8);
+ break;
- if (!clang_type &&
- (encoding_data_type == Type::eEncodingIsPointerUID ||
- encoding_data_type == Type::eEncodingIsTypedefUID)) {
- if (tag == DW_TAG_pointer_type) {
- DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type);
-
- if (target_die.GetAttributeValueAsUnsigned(DW_AT_APPLE_block, 0)) {
- // Blocks have a __FuncPtr inside them which is a pointer to a
- // function of the proper type.
-
- for (DWARFDIE child_die = target_die.GetFirstChild();
- child_die.IsValid(); child_die = child_die.GetSibling()) {
- if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name, ""),
- "__FuncPtr")) {
- DWARFDIE function_pointer_type =
- child_die.GetReferencedDIE(DW_AT_type);
-
- if (function_pointer_type) {
- DWARFDIE function_type =
- function_pointer_type.GetReferencedDIE(DW_AT_type);
-
- bool function_type_is_new_pointer;
- TypeSP lldb_function_type_sp = ParseTypeFromDWARF(
- sc, function_type, log, &function_type_is_new_pointer);
-
- if (lldb_function_type_sp) {
- clang_type = m_ast.CreateBlockPointerType(
- lldb_function_type_sp->GetForwardCompilerType());
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid.Clear();
- resolve_state = Type::eResolveStateFull;
- }
- }
+ case DW_TAG_pointer_type:
+ encoding_data_type = Type::eEncodingIsPointerUID;
+ break;
+ case DW_TAG_reference_type:
+ encoding_data_type = Type::eEncodingIsLValueReferenceUID;
+ break;
+ case DW_TAG_rvalue_reference_type:
+ encoding_data_type = Type::eEncodingIsRValueReferenceUID;
+ break;
+ case DW_TAG_typedef:
+ encoding_data_type = Type::eEncodingIsTypedefUID;
+ break;
+ case DW_TAG_const_type:
+ encoding_data_type = Type::eEncodingIsConstUID;
+ break;
+ case DW_TAG_restrict_type:
+ encoding_data_type = Type::eEncodingIsRestrictUID;
+ break;
+ case DW_TAG_volatile_type:
+ encoding_data_type = Type::eEncodingIsVolatileUID;
+ break;
+ }
- break;
+ if (!clang_type && (encoding_data_type == Type::eEncodingIsPointerUID ||
+ encoding_data_type == Type::eEncodingIsTypedefUID)) {
+ if (tag == DW_TAG_pointer_type) {
+ DWARFDIE target_die = die.GetReferencedDIE(DW_AT_type);
+
+ if (target_die.GetAttributeValueAsUnsigned(DW_AT_APPLE_block, 0)) {
+ // Blocks have a __FuncPtr inside them which is a pointer to a
+ // function of the proper type.
+
+ for (DWARFDIE child_die = target_die.GetFirstChild();
+ child_die.IsValid(); child_die = child_die.GetSibling()) {
+ if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name, ""),
+ "__FuncPtr")) {
+ DWARFDIE function_pointer_type =
+ child_die.GetReferencedDIE(DW_AT_type);
+
+ if (function_pointer_type) {
+ DWARFDIE function_type =
+ function_pointer_type.GetReferencedDIE(DW_AT_type);
+
+ bool function_type_is_new_pointer;
+ TypeSP lldb_function_type_sp = ParseTypeFromDWARF(
+ sc, function_type, log, &function_type_is_new_pointer);
+
+ if (lldb_function_type_sp) {
+ clang_type = m_ast.CreateBlockPointerType(
+ lldb_function_type_sp->GetForwardCompilerType());
+ encoding_data_type = Type::eEncodingIsUID;
+ attrs.type.Clear();
+ resolve_state = Type::eResolveStateFull;
}
}
+
+ break;
}
}
+ }
+ }
- bool translation_unit_is_objc =
- (sc.comp_unit->GetLanguage() == eLanguageTypeObjC ||
- sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
+ if (cu_language == eLanguageTypeObjC ||
+ cu_language == eLanguageTypeObjC_plus_plus) {
+ if (attrs.name) {
+ static ConstString g_objc_type_name_id("id");
+ static ConstString g_objc_type_name_Class("Class");
+ static ConstString g_objc_type_name_selector("SEL");
- if (translation_unit_is_objc) {
- if (type_name_cstr != NULL) {
- static ConstString g_objc_type_name_id("id");
- static ConstString g_objc_type_name_Class("Class");
- static ConstString g_objc_type_name_selector("SEL");
+ if (attrs.name == g_objc_type_name_id) {
+ if (log)
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "is Objective-C 'id' built-in type.",
+ die.GetOffset(), die.GetTagAsCString(), die.GetName());
+ clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
+ encoding_data_type = Type::eEncodingIsUID;
+ attrs.type.Clear();
+ resolve_state = Type::eResolveStateFull;
- if (type_name_const_str == g_objc_type_name_id) {
- if (log)
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
- "is Objective-C 'id' built-in type.",
- die.GetOffset(), die.GetTagAsCString(), die.GetName());
- clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid.Clear();
- resolve_state = Type::eResolveStateFull;
+ } else if (attrs.name == g_objc_type_name_Class) {
+ if (log)
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "is Objective-C 'Class' built-in type.",
+ die.GetOffset(), die.GetTagAsCString(), die.GetName());
+ clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
+ encoding_data_type = Type::eEncodingIsUID;
+ attrs.type.Clear();
+ resolve_state = Type::eResolveStateFull;
+ } else if (attrs.name == g_objc_type_name_selector) {
+ if (log)
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
+ "is Objective-C 'selector' built-in type.",
+ die.GetOffset(), die.GetTagAsCString(), die.GetName());
+ clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
+ encoding_data_type = Type::eEncodingIsUID;
+ attrs.type.Clear();
+ resolve_state = Type::eResolveStateFull;
+ }
+ } else if (encoding_data_type == Type::eEncodingIsPointerUID &&
+ attrs.type.IsValid()) {
+ // Clang sometimes erroneously emits id as objc_object*. In that
+ // case we fix up the type to "id".
- } else if (type_name_const_str == g_objc_type_name_Class) {
- if (log)
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
- "is Objective-C 'Class' built-in type.",
- die.GetOffset(), die.GetTagAsCString(), die.GetName());
- clang_type = m_ast.GetBasicType(eBasicTypeObjCClass);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid.Clear();
- resolve_state = Type::eResolveStateFull;
- } else if (type_name_const_str == g_objc_type_name_selector) {
+ const DWARFDIE encoding_die = attrs.type.Reference();
+
+ if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) {
+ if (const char *struct_name = encoding_die.GetName()) {
+ if (!strcmp(struct_name, "objc_object")) {
if (log)
dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s '%s' "
- "is Objective-C 'selector' built-in type.",
+ log,
+ "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
+ "'%s' is 'objc_object*', which we overrode to "
+ "'id'.",
die.GetOffset(), die.GetTagAsCString(), die.GetName());
- clang_type = m_ast.GetBasicType(eBasicTypeObjCSel);
+ clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
encoding_data_type = Type::eEncodingIsUID;
- encoding_uid.Clear();
+ attrs.type.Clear();
resolve_state = Type::eResolveStateFull;
}
- } else if (encoding_data_type == Type::eEncodingIsPointerUID &&
- encoding_uid.IsValid()) {
- // Clang sometimes erroneously emits id as objc_object*. In that
- // case we fix up the type to "id".
-
- const DWARFDIE encoding_die = dwarf->GetDIE(DIERef(encoding_uid));
-
- if (encoding_die && encoding_die.Tag() == DW_TAG_structure_type) {
- if (const char *struct_name = encoding_die.GetName()) {
- if (!strcmp(struct_name, "objc_object")) {
- if (log)
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF::ParseType (die = 0x%8.8x) %s "
- "'%s' is 'objc_object*', which we overrode to "
- "'id'.",
- die.GetOffset(), die.GetTagAsCString(),
- die.GetName());
- clang_type = m_ast.GetBasicType(eBasicTypeObjCID);
- encoding_data_type = Type::eEncodingIsUID;
- encoding_uid.Clear();
- resolve_state = Type::eResolveStateFull;
- }
- }
- }
}
}
}
+ }
+ }
- type_sp.reset(
- new Type(die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
- DIERef(encoding_uid).GetUID(dwarf), encoding_data_type,
- &decl, clang_type, resolve_state));
+ type_sp = std::make_shared<Type>(
+ die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
+ dwarf->GetUID(attrs.type.Reference()), encoding_data_type, &attrs.decl,
+ clang_type, resolve_state);
- dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- } break;
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ } break;
- case DW_TAG_structure_type:
- case DW_TAG_union_type:
- case DW_TAG_class_type: {
- // Set a bit that lets us know that we are currently parsing this
- dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
- bool byte_size_valid = false;
+ case DW_TAG_structure_type:
+ case DW_TAG_union_type:
+ case DW_TAG_class_type: {
+ // UniqueDWARFASTType is large, so don't create a local variables on
+ // the stack, put it on the heap. This function is often called
+ // recursively and clang isn't good and sharing the stack space for
+ // variables in different blocks.
+ std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_up(
+ new UniqueDWARFASTType());
+
+ ConstString unique_typename(attrs.name);
+ Declaration unique_decl(attrs.decl);
+
+ if (attrs.name) {
+ if (Language::LanguageIsCPlusPlus(cu_language)) {
+ // For C++, we rely solely upon the one definition rule that says
+ // only one thing can exist at a given decl context. We ignore the
+ // file and line that things are declared on.
+ std::string qualified_name;
+ if (die.GetQualifiedName(qualified_name))
+ unique_typename = ConstString(qualified_name);
+ unique_decl.Clear();
+ }
- LanguageType class_language = eLanguageTypeUnknown;
- bool is_complete_objc_class = false;
- size_t calling_convention
- = llvm::dwarf::CallingConvention::DW_CC_normal;
-
- const size_t num_attributes = die.GetAttributes(attributes);
- if (num_attributes > 0) {
- uint32_t i;
- for (i = 0; i < num_attributes; ++i) {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
-
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
-
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
-
- case DW_AT_name:
- type_name_cstr = form_value.AsCString();
- type_name_const_str.SetCString(type_name_cstr);
- break;
-
- case DW_AT_byte_size:
- byte_size = form_value.Unsigned();
- byte_size_valid = true;
- break;
-
- case DW_AT_accessibility:
- accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
- break;
-
- case DW_AT_declaration:
- is_forward_declaration = form_value.Boolean();
- break;
-
- case DW_AT_APPLE_runtime_class:
- class_language = (LanguageType)form_value.Signed();
- break;
-
- case DW_AT_APPLE_objc_complete_type:
- is_complete_objc_class = form_value.Signed();
- break;
- case DW_AT_calling_convention:
- calling_convention = form_value.Unsigned();
- break;
-
- case DW_AT_allocated:
- case DW_AT_associated:
- case DW_AT_data_location:
- case DW_AT_description:
- case DW_AT_start_scope:
- case DW_AT_visibility:
- default:
- case DW_AT_sibling:
- break;
- }
- }
- }
+ if (dwarf->GetUniqueDWARFASTTypeMap().Find(
+ unique_typename, die, unique_decl, attrs.byte_size.getValueOr(-1),
+ *unique_ast_entry_up)) {
+ type_sp = unique_ast_entry_up->m_type_sp;
+ if (type_sp) {
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ return type_sp;
}
+ }
+ }
- // UniqueDWARFASTType is large, so don't create a local variables on
- // the stack, put it on the heap. This function is often called
- // recursively and clang isn't good and sharing the stack space for
- // variables in different blocks.
- std::unique_ptr<UniqueDWARFASTType> unique_ast_entry_ap(
- new UniqueDWARFASTType());
-
- ConstString unique_typename(type_name_const_str);
- Declaration unique_decl(decl);
-
- if (type_name_const_str) {
- LanguageType die_language = die.GetLanguage();
- if (Language::LanguageIsCPlusPlus(die_language)) {
- // For C++, we rely solely upon the one definition rule that says
- // only one thing can exist at a given decl context. We ignore the
- // file and line that things are declared on.
- std::string qualified_name;
- if (die.GetQualifiedName(qualified_name))
- unique_typename = ConstString(qualified_name);
- unique_decl.Clear();
- }
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+ DW_TAG_value_to_name(tag), type_name_cstr);
+
+ int tag_decl_kind = -1;
+ AccessType default_accessibility = eAccessNone;
+ if (tag == DW_TAG_structure_type) {
+ tag_decl_kind = clang::TTK_Struct;
+ default_accessibility = eAccessPublic;
+ } else if (tag == DW_TAG_union_type) {
+ tag_decl_kind = clang::TTK_Union;
+ default_accessibility = eAccessPublic;
+ } else if (tag == DW_TAG_class_type) {
+ tag_decl_kind = clang::TTK_Class;
+ default_accessibility = eAccessPrivate;
+ }
- if (dwarf->GetUniqueDWARFASTTypeMap().Find(
- unique_typename, die, unique_decl,
- byte_size_valid ? byte_size : -1, *unique_ast_entry_ap)) {
- type_sp = unique_ast_entry_ap->m_type_sp;
- if (type_sp) {
- dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- return type_sp;
- }
+ if (attrs.byte_size && *attrs.byte_size == 0 && attrs.name &&
+ !die.HasChildren() && cu_language == eLanguageTypeObjC) {
+ // Work around an issue with clang at the moment where forward
+ // declarations for objective C classes are emitted as:
+ // DW_TAG_structure_type [2]
+ // DW_AT_name( "ForwardObjcClass" )
+ // DW_AT_byte_size( 0x00 )
+ // DW_AT_decl_file( "..." )
+ // DW_AT_decl_line( 1 )
+ //
+ // Note that there is no DW_AT_declaration and there are no children,
+ // and the byte size is zero.
+ attrs.is_forward_declaration = true;
+ }
+
+ if (attrs.class_language == eLanguageTypeObjC ||
+ attrs.class_language == eLanguageTypeObjC_plus_plus) {
+ if (!attrs.is_complete_objc_class &&
+ die.Supports_DW_AT_APPLE_objc_complete_type()) {
+ // We have a valid eSymbolTypeObjCClass class symbol whose name
+ // matches the current objective C class that we are trying to find
+ // and this DIE isn't the complete definition (we checked
+ // is_complete_objc_class above and know it is false), so the real
+ // definition is in here somewhere
+ type_sp =
+ dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.name, true);
+
+ if (!type_sp) {
+ SymbolFileDWARFDebugMap *debug_map_symfile =
+ dwarf->GetDebugMapSymfile();
+ if (debug_map_symfile) {
+ // We weren't able to find a full declaration in this DWARF,
+ // see if we have a declaration anywhere else...
+ type_sp = debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE(
+ die, attrs.name, true);
}
}
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
-
- int tag_decl_kind = -1;
- AccessType default_accessibility = eAccessNone;
- if (tag == DW_TAG_structure_type) {
- tag_decl_kind = clang::TTK_Struct;
- default_accessibility = eAccessPublic;
- } else if (tag == DW_TAG_union_type) {
- tag_decl_kind = clang::TTK_Union;
- default_accessibility = eAccessPublic;
- } else if (tag == DW_TAG_class_type) {
- tag_decl_kind = clang::TTK_Class;
- default_accessibility = eAccessPrivate;
- }
+ if (type_sp) {
+ if (log) {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an "
+ "incomplete objc type, complete type is 0x%8.8" PRIx64,
+ static_cast<void *>(this), die.GetOffset(),
+ DW_TAG_value_to_name(tag), attrs.name.GetCString(),
+ type_sp->GetID());
+ }
- if (byte_size_valid && byte_size == 0 && type_name_cstr &&
- !die.HasChildren() &&
- sc.comp_unit->GetLanguage() == eLanguageTypeObjC) {
- // Work around an issue with clang at the moment where forward
- // declarations for objective C classes are emitted as:
- // DW_TAG_structure_type [2]
- // DW_AT_name( "ForwardObjcClass" )
- // DW_AT_byte_size( 0x00 )
- // DW_AT_decl_file( "..." )
- // DW_AT_decl_line( 1 )
- //
- // Note that there is no DW_AT_declaration and there are no children,
- // and the byte size is zero.
- is_forward_declaration = true;
+ // We found a real definition for this type elsewhere so lets use
+ // it and cache the fact that we found a complete type for this
+ // die
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ return type_sp;
}
+ }
+ }
- if (class_language == eLanguageTypeObjC ||
- class_language == eLanguageTypeObjC_plus_plus) {
- if (!is_complete_objc_class &&
- die.Supports_DW_AT_APPLE_objc_complete_type()) {
- // We have a valid eSymbolTypeObjCClass class symbol whose name
- // matches the current objective C class that we are trying to find
- // and this DIE isn't the complete definition (we checked
- // is_complete_objc_class above and know it is false), so the real
- // definition is in here somewhere
- type_sp = dwarf->FindCompleteObjCDefinitionTypeForDIE(
- die, type_name_const_str, true);
-
- if (!type_sp) {
- SymbolFileDWARFDebugMap *debug_map_symfile =
- dwarf->GetDebugMapSymfile();
- if (debug_map_symfile) {
- // We weren't able to find a full declaration in this DWARF,
- // see if we have a declaration anywhere else...
- type_sp =
- debug_map_symfile->FindCompleteObjCDefinitionTypeForDIE(
- die, type_name_const_str, true);
- }
- }
+ if (attrs.is_forward_declaration) {
+ // We have a forward declaration to a type and we need to try and
+ // find a full declaration. We look in the current type index just in
+ // case we have a forward declaration followed by an actual
+ // declarations in the DWARF. If this fails, we need to look
+ // elsewhere...
+ if (log) {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "forward declaration, trying to find complete type",
+ static_cast<void *>(this), die.GetOffset(),
+ DW_TAG_value_to_name(tag), attrs.name.GetCString());
+ }
- if (type_sp) {
- if (log) {
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is an "
- "incomplete objc type, complete type is 0x%8.8" PRIx64,
- static_cast<void *>(this), die.GetOffset(),
- DW_TAG_value_to_name(tag), type_name_cstr,
- type_sp->GetID());
- }
+ // See if the type comes from a DWO module and if so, track down that
+ // type.
+ type_sp = ParseTypeFromDWO(die, log);
+ if (type_sp)
+ return type_sp;
+
+ DWARFDeclContext die_decl_ctx;
+ die.GetDWARFDeclContext(die_decl_ctx);
+
+ // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
+ // type_name_const_str);
+ type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+
+ if (!type_sp) {
+ SymbolFileDWARFDebugMap *debug_map_symfile =
+ dwarf->GetDebugMapSymfile();
+ if (debug_map_symfile) {
+ // We weren't able to find a full declaration in this DWARF, see
+ // if we have a declaration anywhere else...
+ type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
+ die_decl_ctx);
+ }
+ }
- // We found a real definition for this type elsewhere so lets use
- // it and cache the fact that we found a complete type for this
- // die
- dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- return type_sp;
- }
- }
+ if (type_sp) {
+ if (log) {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "forward declaration, complete type is 0x%8.8" PRIx64,
+ static_cast<void *>(this), die.GetOffset(),
+ DW_TAG_value_to_name(tag), attrs.name.GetCString(),
+ type_sp->GetID());
}
- if (is_forward_declaration) {
- // We have a forward declaration to a type and we need to try and
- // find a full declaration. We look in the current type index just in
- // case we have a forward declaration followed by an actual
- // declarations in the DWARF. If this fails, we need to look
- // elsewhere...
- if (log) {
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
- "forward declaration, trying to find complete type",
- static_cast<void *>(this), die.GetOffset(),
- DW_TAG_value_to_name(tag), type_name_cstr);
- }
+ // We found a real definition for this type elsewhere so lets use
+ // it and cache the fact that we found a complete type for this die
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ clang::DeclContext *defn_decl_ctx =
+ GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID()));
+ if (defn_decl_ctx)
+ LinkDeclContextToDIE(defn_decl_ctx, die);
+ return type_sp;
+ }
+ }
+ assert(tag_decl_kind != -1);
+ bool clang_type_was_created = false;
+ clang_type.SetCompilerType(
+ &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+ if (!clang_type) {
+ clang::DeclContext *decl_ctx =
+ GetClangDeclContextContainingDIE(die, nullptr);
- // See if the type comes from a DWO module and if so, track down that
- // type.
- type_sp = ParseTypeFromDWO(die, log);
- if (type_sp)
- return type_sp;
-
- DWARFDeclContext die_decl_ctx;
- die.GetDWARFDeclContext(die_decl_ctx);
-
- // type_sp = FindDefinitionTypeForDIE (dwarf_cu, die,
- // type_name_const_str);
- type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
-
- if (!type_sp) {
- SymbolFileDWARFDebugMap *debug_map_symfile =
- dwarf->GetDebugMapSymfile();
- if (debug_map_symfile) {
- // We weren't able to find a full declaration in this DWARF, see
- // if we have a declaration anywhere else...
- type_sp =
- debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
- die_decl_ctx);
- }
- }
+ // If your decl context is a record that was imported from another
+ // AST context (in the gmodules case), we need to make sure the type
+ // backing the Decl is complete before adding children to it. This is
+ // not an issue in the non-gmodules case because the debug info will
+ // always contain a full definition of parent types in that case.
+ CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die,
+ attrs.name.GetCString());
+
+ if (attrs.accessibility == eAccessNone && decl_ctx) {
+ // Check the decl context that contains this class/struct/union. If
+ // it is a class we must give it an accessibility.
+ const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
+ if (DeclKindIsCXXClass(containing_decl_kind))
+ attrs.accessibility = default_accessibility;
+ }
- if (type_sp) {
+ ClangASTMetadata metadata;
+ metadata.SetUserID(die.GetID());
+ metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
+
+ if (attrs.name.GetStringRef().contains('<')) {
+ ClangASTContext::TemplateParameterInfos template_param_infos;
+ if (ParseTemplateParameterInfos(die, template_param_infos)) {
+ clang::ClassTemplateDecl *class_template_decl =
+ m_ast.ParseClassTemplateDecl(decl_ctx, attrs.accessibility,
+ attrs.name.GetCString(),
+ tag_decl_kind, template_param_infos);
+ if (!class_template_decl) {
if (log) {
dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
- "forward declaration, complete type is 0x%8.8" PRIx64,
+ log,
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" "
+ "clang::ClassTemplateDecl failed to return a decl.",
static_cast<void *>(this), die.GetOffset(),
- DW_TAG_value_to_name(tag), type_name_cstr, type_sp->GetID());
+ DW_TAG_value_to_name(tag), attrs.name.GetCString());
}
-
- // We found a real definition for this type elsewhere so lets use
- // it and cache the fact that we found a complete type for this die
- dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- clang::DeclContext *defn_decl_ctx = GetCachedClangDeclContextForDIE(
- dwarf->DebugInfo()->GetDIE(DIERef(type_sp->GetID(), dwarf)));
- if (defn_decl_ctx)
- LinkDeclContextToDIE(defn_decl_ctx, die);
- return type_sp;
- }
- }
- assert(tag_decl_kind != -1);
- bool clang_type_was_created = false;
- clang_type.SetCompilerType(
- &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
- if (!clang_type) {
- clang::DeclContext *decl_ctx =
- GetClangDeclContextContainingDIE(die, nullptr);
-
- // If your decl context is a record that was imported from another
- // AST context (in the gmodules case), we need to make sure the type
- // backing the Decl is complete before adding children to it. This is
- // not an issue in the non-gmodules case because the debug info will
- // always contain a full definition of parent types in that case.
- CompleteExternalTagDeclType(GetClangASTImporter(), decl_ctx, die,
- type_name_cstr);
-
- if (accessibility == eAccessNone && decl_ctx) {
- // Check the decl context that contains this class/struct/union. If
- // it is a class we must give it an accessibility.
- const clang::Decl::Kind containing_decl_kind =
- decl_ctx->getDeclKind();
- if (DeclKindIsCXXClass(containing_decl_kind))
- accessibility = default_accessibility;
+ return TypeSP();
}
- ClangASTMetadata metadata;
- metadata.SetUserID(die.GetID());
- metadata.SetIsDynamicCXXType(dwarf->ClassOrStructIsVirtual(die));
-
- if (type_name_cstr && strchr(type_name_cstr, '<')) {
- ClangASTContext::TemplateParameterInfos template_param_infos;
- if (ParseTemplateParameterInfos(die, template_param_infos)) {
- clang::ClassTemplateDecl *class_template_decl =
- m_ast.ParseClassTemplateDecl(decl_ctx, accessibility,
- type_name_cstr, tag_decl_kind,
- template_param_infos);
- if (!class_template_decl) {
- if (log) {
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" "
- "clang::ClassTemplateDecl failed to return a decl.",
- static_cast<void *>(this), die.GetOffset(),
- DW_TAG_value_to_name(tag), type_name_cstr);
- }
- return TypeSP();
- }
-
- clang::ClassTemplateSpecializationDecl
- *class_specialization_decl =
- m_ast.CreateClassTemplateSpecializationDecl(
- decl_ctx, class_template_decl, tag_decl_kind,
- template_param_infos);
- clang_type = m_ast.CreateClassTemplateSpecializationType(
- class_specialization_decl);
- clang_type_was_created = true;
-
- m_ast.SetMetadata(class_template_decl, metadata);
- m_ast.SetMetadata(class_specialization_decl, metadata);
- }
- }
+ clang::ClassTemplateSpecializationDecl *class_specialization_decl =
+ m_ast.CreateClassTemplateSpecializationDecl(
+ decl_ctx, class_template_decl, tag_decl_kind,
+ template_param_infos);
+ clang_type = m_ast.CreateClassTemplateSpecializationType(
+ class_specialization_decl);
+ clang_type_was_created = true;
- if (!clang_type_was_created) {
- clang_type_was_created = true;
- clang_type = m_ast.CreateRecordType(decl_ctx, accessibility,
- type_name_cstr, tag_decl_kind,
- class_language, &metadata);
- }
- }
-
- // Store a forward declaration to this class type in case any
- // parameters in any class methods need it for the clang types for
- // function prototypes.
- LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
- type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
- byte_size, NULL, LLDB_INVALID_UID,
- Type::eEncodingIsUID, &decl, clang_type,
- Type::eResolveStateForward));
-
- type_sp->SetIsCompleteObjCClass(is_complete_objc_class);
-
- // Add our type to the unique type map so we don't end up creating many
- // copies of the same type over and over in the ASTContext for our
- // module
- unique_ast_entry_ap->m_type_sp = type_sp;
- unique_ast_entry_ap->m_die = die;
- unique_ast_entry_ap->m_declaration = unique_decl;
- unique_ast_entry_ap->m_byte_size = byte_size;
- dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
- *unique_ast_entry_ap);
-
- if (is_forward_declaration && die.HasChildren()) {
- // Check to see if the DIE actually has a definition, some version of
- // GCC will
- // emit DIEs with DW_AT_declaration set to true, but yet still have
- // subprogram, members, or inheritance, so we can't trust it
- DWARFDIE child_die = die.GetFirstChild();
- while (child_die) {
- switch (child_die.Tag()) {
- case DW_TAG_inheritance:
- case DW_TAG_subprogram:
- case DW_TAG_member:
- case DW_TAG_APPLE_property:
- case DW_TAG_class_type:
- case DW_TAG_structure_type:
- case DW_TAG_enumeration_type:
- case DW_TAG_typedef:
- case DW_TAG_union_type:
- child_die.Clear();
- is_forward_declaration = false;
- break;
- default:
- child_die = child_die.GetSibling();
- break;
- }
- }
+ m_ast.SetMetadata(class_template_decl, metadata);
+ m_ast.SetMetadata(class_specialization_decl, metadata);
}
+ }
- if (!is_forward_declaration) {
- // Always start the definition for a class type so that if the class
- // has child classes or types that require the class to be created
- // for use as their decl contexts the class will be ready to accept
- // these child definitions.
- if (!die.HasChildren()) {
- // No children for this struct/union/class, lets finish it
- if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
- } else {
- dwarf->GetObjectFile()->GetModule()->ReportError(
- "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
- "definition.\nPlease file a bug and attach the file at the "
- "start of this error message",
- die.GetOffset(), type_name_cstr);
- }
+ if (!clang_type_was_created) {
+ clang_type_was_created = true;
+ clang_type = m_ast.CreateRecordType(
+ decl_ctx, attrs.accessibility, attrs.name.GetCString(),
+ tag_decl_kind, attrs.class_language, &metadata);
+ }
+ }
- if (tag == DW_TAG_structure_type) // this only applies in C
- {
- clang::RecordDecl *record_decl =
- ClangASTContext::GetAsRecordDecl(clang_type);
+ // Store a forward declaration to this class type in case any
+ // parameters in any class methods need it for the clang types for
+ // function prototypes.
+ LinkDeclContextToDIE(m_ast.GetDeclContextForType(clang_type), die);
+ type_sp = std::make_shared<Type>(die.GetID(), dwarf, attrs.name,
+ attrs.byte_size, nullptr, LLDB_INVALID_UID,
+ Type::eEncodingIsUID, &attrs.decl, clang_type,
+ Type::eResolveStateForward);
+
+ type_sp->SetIsCompleteObjCClass(attrs.is_complete_objc_class);
+
+ // Add our type to the unique type map so we don't end up creating many
+ // copies of the same type over and over in the ASTContext for our
+ // module
+ unique_ast_entry_up->m_type_sp = type_sp;
+ unique_ast_entry_up->m_die = die;
+ unique_ast_entry_up->m_declaration = unique_decl;
+ unique_ast_entry_up->m_byte_size = attrs.byte_size.getValueOr(0);
+ dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
+ *unique_ast_entry_up);
+
+ if (attrs.is_forward_declaration && die.HasChildren()) {
+ // Check to see if the DIE actually has a definition, some version of
+ // GCC will
+ // emit DIEs with DW_AT_declaration set to true, but yet still have
+ // subprogram, members, or inheritance, so we can't trust it
+ DWARFDIE child_die = die.GetFirstChild();
+ while (child_die) {
+ switch (child_die.Tag()) {
+ case DW_TAG_inheritance:
+ case DW_TAG_subprogram:
+ case DW_TAG_member:
+ case DW_TAG_APPLE_property:
+ case DW_TAG_class_type:
+ case DW_TAG_structure_type:
+ case DW_TAG_enumeration_type:
+ case DW_TAG_typedef:
+ case DW_TAG_union_type:
+ child_die.Clear();
+ attrs.is_forward_declaration = false;
+ break;
+ default:
+ child_die = child_die.GetSibling();
+ break;
+ }
+ }
+ }
- if (record_decl) {
- GetClangASTImporter().InsertRecordDecl(
- record_decl, ClangASTImporter::LayoutInfo());
- }
- }
- } else if (clang_type_was_created) {
- // Start the definition if the class is not objective C since the
- // underlying decls respond to isCompleteDefinition(). Objective
- // C decls don't respond to isCompleteDefinition() so we can't
- // start the declaration definition right away. For C++
- // class/union/structs we want to start the definition in case the
- // class is needed as the declaration context for a contained class
- // or type without the need to complete that type..
-
- if (class_language != eLanguageTypeObjC &&
- class_language != eLanguageTypeObjC_plus_plus)
- ClangASTContext::StartTagDeclarationDefinition(clang_type);
-
- // Leave this as a forward declaration until we need to know the
- // details of the type. lldb_private::Type will automatically call
- // the SymbolFile virtual function
- // "SymbolFileDWARF::CompleteType(Type *)" When the definition
- // needs to be defined.
- assert(!dwarf->GetForwardDeclClangTypeToDie().count(
- ClangUtil::RemoveFastQualifiers(clang_type)
- .GetOpaqueQualType()) &&
- "Type already in the forward declaration map!");
- // Can't assume m_ast.GetSymbolFile() is actually a
- // SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
- // binaries.
- dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
- clang_type.GetOpaqueQualType();
- dwarf->GetForwardDeclClangTypeToDie()
- [ClangUtil::RemoveFastQualifiers(clang_type)
- .GetOpaqueQualType()] = die.GetDIERef();
- m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
- }
+ if (!attrs.is_forward_declaration) {
+ // Always start the definition for a class type so that if the class
+ // has child classes or types that require the class to be created
+ // for use as their decl contexts the class will be ready to accept
+ // these child definitions.
+ if (!die.HasChildren()) {
+ // No children for this struct/union/class, lets finish it
+ if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+ ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ } else {
+ dwarf->GetObjectFile()->GetModule()->ReportError(
+ "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+ "definition.\nPlease file a bug and attach the file at the "
+ "start of this error message",
+ die.GetOffset(), attrs.name.GetCString());
}
-
- // If we made a clang type, set the trivial abi if applicable: We only
- // do this for pass by value - which implies the Trivial ABI. There
- // isn't a way to assert that something that would normally be pass by
- // value is pass by reference, so we ignore that attribute if set.
- if (calling_convention == llvm::dwarf::DW_CC_pass_by_value) {
- clang::CXXRecordDecl *record_decl =
- m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+
+ if (tag == DW_TAG_structure_type) // this only applies in C
+ {
+ clang::RecordDecl *record_decl =
+ ClangASTContext::GetAsRecordDecl(clang_type);
+
if (record_decl) {
- record_decl->setHasTrivialSpecialMemberForCall();
+ GetClangASTImporter().InsertRecordDecl(
+ record_decl, ClangASTImporter::LayoutInfo());
}
}
+ } else if (clang_type_was_created) {
+ // Start the definition if the class is not objective C since the
+ // underlying decls respond to isCompleteDefinition(). Objective
+ // C decls don't respond to isCompleteDefinition() so we can't
+ // start the declaration definition right away. For C++
+ // class/union/structs we want to start the definition in case the
+ // class is needed as the declaration context for a contained class
+ // or type without the need to complete that type..
+
+ if (attrs.class_language != eLanguageTypeObjC &&
+ attrs.class_language != eLanguageTypeObjC_plus_plus)
+ ClangASTContext::StartTagDeclarationDefinition(clang_type);
- } break;
+ // Leave this as a forward declaration until we need to know the
+ // details of the type. lldb_private::Type will automatically call
+ // the SymbolFile virtual function
+ // "SymbolFileDWARF::CompleteType(Type *)" When the definition
+ // needs to be defined.
+ assert(!dwarf->GetForwardDeclClangTypeToDie().count(
+ ClangUtil::RemoveFastQualifiers(clang_type)
+ .GetOpaqueQualType()) &&
+ "Type already in the forward declaration map!");
+ // Can't assume m_ast.GetSymbolFile() is actually a
+ // SymbolFileDWARF, it can be a SymbolFileDWARFDebugMap for Apple
+ // binaries.
+ dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
+ clang_type.GetOpaqueQualType();
+ dwarf->GetForwardDeclClangTypeToDie()
+ [ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] =
+ die.GetID();
+ m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
+ }
+ }
- case DW_TAG_enumeration_type: {
- // Set a bit that lets us know that we are currently parsing this
- dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+ // If we made a clang type, set the trivial abi if applicable: We only
+ // do this for pass by value - which implies the Trivial ABI. There
+ // isn't a way to assert that something that would normally be pass by
+ // value is pass by reference, so we ignore that attribute if set.
+ if (attrs.calling_convention == llvm::dwarf::DW_CC_pass_by_value) {
+ clang::CXXRecordDecl *record_decl =
+ m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+ if (record_decl) {
+ record_decl->setHasTrivialSpecialMemberForCall();
+ }
+ }
- bool is_scoped = false;
- DWARFFormValue encoding_form;
+ if (attrs.calling_convention == llvm::dwarf::DW_CC_pass_by_reference) {
+ clang::CXXRecordDecl *record_decl =
+ m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+ if (record_decl)
+ record_decl->setArgPassingRestrictions(
+ clang::RecordDecl::APK_CannotPassInRegs);
+ }
- const size_t num_attributes = die.GetAttributes(attributes);
- if (num_attributes > 0) {
- uint32_t i;
-
- for (i = 0; i < num_attributes; ++i) {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
- case DW_AT_name:
- type_name_cstr = form_value.AsCString();
- type_name_const_str.SetCString(type_name_cstr);
- break;
- case DW_AT_type:
- encoding_form = form_value;
- break;
- case DW_AT_byte_size:
- byte_size = form_value.Unsigned();
- break;
- case DW_AT_accessibility:
- break; // accessibility =
- // DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
- case DW_AT_declaration:
- is_forward_declaration = form_value.Boolean();
- break;
- case DW_AT_enum_class:
- is_scoped = form_value.Boolean();
- break;
- case DW_AT_allocated:
- case DW_AT_associated:
- case DW_AT_bit_stride:
- case DW_AT_byte_stride:
- case DW_AT_data_location:
- case DW_AT_description:
- case DW_AT_start_scope:
- case DW_AT_visibility:
- case DW_AT_specification:
- case DW_AT_abstract_origin:
- case DW_AT_sibling:
- break;
- }
- }
- }
+ } break;
- if (is_forward_declaration) {
- type_sp = ParseTypeFromDWO(die, log);
- if (type_sp)
- return type_sp;
-
- DWARFDeclContext die_decl_ctx;
- die.GetDWARFDeclContext(die_decl_ctx);
-
- type_sp =
- dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
-
- if (!type_sp) {
- SymbolFileDWARFDebugMap *debug_map_symfile =
- dwarf->GetDebugMapSymfile();
- if (debug_map_symfile) {
- // We weren't able to find a full declaration in this DWARF,
- // see if we have a declaration anywhere else...
- type_sp =
- debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
- die_decl_ctx);
- }
- }
+ case DW_TAG_enumeration_type: {
+ if (attrs.is_forward_declaration) {
+ type_sp = ParseTypeFromDWO(die, log);
+ if (type_sp)
+ return type_sp;
- if (type_sp) {
- if (log) {
- dwarf->GetObjectFile()->GetModule()->LogMessage(
- log, "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
- "forward declaration, complete type is 0x%8.8" PRIx64,
- static_cast<void *>(this), die.GetOffset(),
- DW_TAG_value_to_name(tag), type_name_cstr,
- type_sp->GetID());
- }
+ DWARFDeclContext die_decl_ctx;
+ die.GetDWARFDeclContext(die_decl_ctx);
- // We found a real definition for this type elsewhere so lets use
- // it and cache the fact that we found a complete type for this
- // die
- dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- clang::DeclContext *defn_decl_ctx =
- GetCachedClangDeclContextForDIE(dwarf->DebugInfo()->GetDIE(
- DIERef(type_sp->GetID(), dwarf)));
- if (defn_decl_ctx)
- LinkDeclContextToDIE(defn_decl_ctx, die);
- return type_sp;
- }
- }
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
-
- CompilerType enumerator_clang_type;
- clang_type.SetCompilerType(
- &m_ast,
- dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
- if (!clang_type) {
- if (encoding_form.IsValid()) {
- Type *enumerator_type =
- dwarf->ResolveTypeUID(DIERef(encoding_form));
- if (enumerator_type)
- enumerator_clang_type = enumerator_type->GetFullCompilerType();
- }
+ type_sp = dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
- if (!enumerator_clang_type) {
- if (byte_size > 0) {
- enumerator_clang_type =
- m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
- NULL, DW_ATE_signed, byte_size * 8);
- } else {
- enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
- }
- }
+ if (!type_sp) {
+ SymbolFileDWARFDebugMap *debug_map_symfile =
+ dwarf->GetDebugMapSymfile();
+ if (debug_map_symfile) {
+ // We weren't able to find a full declaration in this DWARF,
+ // see if we have a declaration anywhere else...
+ type_sp = debug_map_symfile->FindDefinitionTypeForDWARFDeclContext(
+ die_decl_ctx);
+ }
+ }
- clang_type = m_ast.CreateEnumerationType(
- type_name_cstr, GetClangDeclContextContainingDIE(die, nullptr),
- decl, enumerator_clang_type, is_scoped);
- } else {
- enumerator_clang_type =
- m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());
- }
+ if (type_sp) {
+ if (log) {
+ dwarf->GetObjectFile()->GetModule()->LogMessage(
+ log,
+ "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is a "
+ "forward declaration, complete type is 0x%8.8" PRIx64,
+ static_cast<void *>(this), die.GetOffset(),
+ DW_TAG_value_to_name(tag), attrs.name.GetCString(),
+ type_sp->GetID());
+ }
- LinkDeclContextToDIE(
- ClangASTContext::GetDeclContextForType(clang_type), die);
-
- type_sp.reset(new Type(
- die.GetID(), dwarf, type_name_const_str, byte_size, NULL,
- DIERef(encoding_form).GetUID(dwarf), Type::eEncodingIsUID, &decl,
- clang_type, Type::eResolveStateForward));
-
- if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
- if (die.HasChildren()) {
- SymbolContext cu_sc(die.GetLLDBCompileUnit());
- bool is_signed = false;
- enumerator_clang_type.IsIntegerType(is_signed);
- ParseChildEnumerators(cu_sc, clang_type, is_signed,
- type_sp->GetByteSize(), die);
- }
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
- } else {
- dwarf->GetObjectFile()->GetModule()->ReportError(
- "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
- "definition.\nPlease file a bug and attach the file at the "
- "start of this error message",
- die.GetOffset(), type_name_cstr);
- }
+ // We found a real definition for this type elsewhere so lets use
+ // it and cache the fact that we found a complete type for this
+ // die
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
+ clang::DeclContext *defn_decl_ctx =
+ GetCachedClangDeclContextForDIE(dwarf->GetDIE(type_sp->GetID()));
+ if (defn_decl_ctx)
+ LinkDeclContextToDIE(defn_decl_ctx, die);
+ return type_sp;
+ }
+ }
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+ DW_TAG_value_to_name(tag), type_name_cstr);
+
+ CompilerType enumerator_clang_type;
+ clang_type.SetCompilerType(
+ &m_ast, dwarf->GetForwardDeclDieToClangType().lookup(die.GetDIE()));
+ if (!clang_type) {
+ if (attrs.type.IsValid()) {
+ Type *enumerator_type =
+ dwarf->ResolveTypeUID(attrs.type.Reference(), true);
+ if (enumerator_type)
+ enumerator_clang_type = enumerator_type->GetFullCompilerType();
+ }
+
+ if (!enumerator_clang_type) {
+ if (attrs.byte_size) {
+ enumerator_clang_type =
+ m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
+ NULL, DW_ATE_signed, *attrs.byte_size * 8);
+ } else {
+ enumerator_clang_type = m_ast.GetBasicType(eBasicTypeInt);
}
- } break;
+ }
- case DW_TAG_inlined_subroutine:
- case DW_TAG_subprogram:
- case DW_TAG_subroutine_type: {
- // Set a bit that lets us know that we are currently parsing this
- dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
+ clang_type = m_ast.CreateEnumerationType(
+ attrs.name.GetCString(),
+ GetClangDeclContextContainingDIE(die, nullptr), attrs.decl,
+ enumerator_clang_type, attrs.is_scoped_enum);
+ } else {
+ enumerator_clang_type =
+ m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());
+ }
- DWARFFormValue type_die_form;
- bool is_variadic = false;
- bool is_inline = false;
- bool is_static = false;
- bool is_virtual = false;
- bool is_explicit = false;
- bool is_artificial = false;
- bool has_template_params = false;
- DWARFFormValue specification_die_form;
- DWARFFormValue abstract_origin_die_form;
- dw_offset_t object_pointer_die_offset = DW_INVALID_OFFSET;
+ LinkDeclContextToDIE(ClangASTContext::GetDeclContextForType(clang_type),
+ die);
- unsigned type_quals = 0;
- clang::StorageClass storage =
- clang::SC_None; //, Extern, Static, PrivateExtern
-
- const size_t num_attributes = die.GetAttributes(attributes);
- if (num_attributes > 0) {
- uint32_t i;
- for (i = 0; i < num_attributes; ++i) {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
- case DW_AT_name:
- type_name_cstr = form_value.AsCString();
- type_name_const_str.SetCString(type_name_cstr);
- break;
-
- case DW_AT_linkage_name:
- case DW_AT_MIPS_linkage_name:
- mangled_name_cstr = form_value.AsCString();
- break;
- case DW_AT_type:
- type_die_form = form_value;
- break;
- case DW_AT_accessibility:
- accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned());
- break;
- case DW_AT_declaration:
- break; // is_forward_declaration = form_value.Boolean(); break;
- case DW_AT_inline:
- is_inline = form_value.Boolean();
- break;
- case DW_AT_virtuality:
- is_virtual = form_value.Boolean();
- break;
- case DW_AT_explicit:
- is_explicit = form_value.Boolean();
- break;
- case DW_AT_artificial:
- is_artificial = form_value.Boolean();
- break;
-
- case DW_AT_external:
- if (form_value.Unsigned()) {
- if (storage == clang::SC_None)
- storage = clang::SC_Extern;
- else
- storage = clang::SC_PrivateExtern;
- }
- break;
-
- case DW_AT_specification:
- specification_die_form = form_value;
- break;
-
- case DW_AT_abstract_origin:
- abstract_origin_die_form = form_value;
- break;
-
- case DW_AT_object_pointer:
- object_pointer_die_offset = form_value.Reference();
- break;
-
- case DW_AT_allocated:
- case DW_AT_associated:
- case DW_AT_address_class:
- case DW_AT_calling_convention:
- case DW_AT_data_location:
- case DW_AT_elemental:
- case DW_AT_entry_pc:
- case DW_AT_frame_base:
- case DW_AT_high_pc:
- case DW_AT_low_pc:
- case DW_AT_prototyped:
- case DW_AT_pure:
- case DW_AT_ranges:
- case DW_AT_recursive:
- case DW_AT_return_addr:
- case DW_AT_segment:
- case DW_AT_start_scope:
- case DW_AT_static_link:
- case DW_AT_trampoline:
- case DW_AT_visibility:
- case DW_AT_vtable_elem_location:
- case DW_AT_description:
- case DW_AT_sibling:
- break;
- }
- }
- }
- }
+ type_sp = std::make_shared<Type>(
+ die.GetID(), dwarf, attrs.name, attrs.byte_size, nullptr,
+ dwarf->GetUID(attrs.type.Reference()), Type::eEncodingIsUID,
+ &attrs.decl, clang_type, Type::eResolveStateForward);
- std::string object_pointer_name;
- if (object_pointer_die_offset != DW_INVALID_OFFSET) {
- DWARFDIE object_pointer_die = die.GetDIE(object_pointer_die_offset);
- if (object_pointer_die) {
- const char *object_pointer_name_cstr = object_pointer_die.GetName();
- if (object_pointer_name_cstr)
- object_pointer_name = object_pointer_name_cstr;
- }
- }
+ if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
+ if (die.HasChildren()) {
+ bool is_signed = false;
+ enumerator_clang_type.IsIntegerType(is_signed);
+ ParseChildEnumerators(clang_type, is_signed,
+ type_sp->GetByteSize().getValueOr(0), die);
+ }
+ ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ } else {
+ dwarf->GetObjectFile()->GetModule()->ReportError(
+ "DWARF DIE at 0x%8.8x named \"%s\" was not able to start its "
+ "definition.\nPlease file a bug and attach the file at the "
+ "start of this error message",
+ die.GetOffset(), attrs.name.GetCString());
+ }
+ } break;
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
+ case DW_TAG_inlined_subroutine:
+ case DW_TAG_subprogram:
+ case DW_TAG_subroutine_type: {
+ bool is_variadic = false;
+ bool is_static = false;
+ bool has_template_params = false;
+
+ unsigned type_quals = 0;
+
+ std::string object_pointer_name;
+ if (attrs.object_pointer) {
+ const char *object_pointer_name_cstr = attrs.object_pointer.GetName();
+ if (object_pointer_name_cstr)
+ object_pointer_name = object_pointer_name_cstr;
+ }
- CompilerType return_clang_type;
- Type *func_type = NULL;
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+ DW_TAG_value_to_name(tag), type_name_cstr);
- if (type_die_form.IsValid())
- func_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
+ CompilerType return_clang_type;
+ Type *func_type = NULL;
- if (func_type)
- return_clang_type = func_type->GetForwardCompilerType();
- else
- return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
+ if (attrs.type.IsValid())
+ func_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
- std::vector<CompilerType> function_param_types;
- std::vector<clang::ParmVarDecl *> function_param_decls;
+ if (func_type)
+ return_clang_type = func_type->GetForwardCompilerType();
+ else
+ return_clang_type = m_ast.GetBasicType(eBasicTypeVoid);
- // Parse the function children for the parameters
+ std::vector<CompilerType> function_param_types;
+ std::vector<clang::ParmVarDecl *> function_param_decls;
- DWARFDIE decl_ctx_die;
- clang::DeclContext *containing_decl_ctx =
- GetClangDeclContextContainingDIE(die, &decl_ctx_die);
- const clang::Decl::Kind containing_decl_kind =
- containing_decl_ctx->getDeclKind();
-
- bool is_cxx_method = DeclKindIsCXXClass(containing_decl_kind);
- // Start off static. This will be set to false in
- // ParseChildParameters(...) if we find a "this" parameters as the
- // first parameter
- if (is_cxx_method) {
- is_static = true;
- }
+ // Parse the function children for the parameters
- if (die.HasChildren()) {
- bool skip_artificial = true;
- ParseChildParameters(*sc.comp_unit, containing_decl_ctx, die,
- skip_artificial, is_static, is_variadic,
- has_template_params, function_param_types,
- function_param_decls, type_quals);
- }
+ DWARFDIE decl_ctx_die;
+ clang::DeclContext *containing_decl_ctx =
+ GetClangDeclContextContainingDIE(die, &decl_ctx_die);
+ const clang::Decl::Kind containing_decl_kind =
+ containing_decl_ctx->getDeclKind();
- bool ignore_containing_context = false;
- // Check for templatized class member functions. If we had any
- // DW_TAG_template_type_parameter or DW_TAG_template_value_parameter
- // the DW_TAG_subprogram DIE, then we can't let this become a method in
- // a class. Why? Because templatized functions are only emitted if one
- // of the templatized methods is used in the current compile unit and
- // we will end up with classes that may or may not include these member
- // functions and this means one class won't match another class
- // definition and it affects our ability to use a class in the clang
- // expression parser. So for the greater good, we currently must not
- // allow any template member functions in a class definition.
- if (is_cxx_method && has_template_params) {
- ignore_containing_context = true;
- is_cxx_method = false;
- }
+ bool is_cxx_method = DeclKindIsCXXClass(containing_decl_kind);
+ // Start off static. This will be set to false in
+ // ParseChildParameters(...) if we find a "this" parameters as the
+ // first parameter
+ if (is_cxx_method) {
+ is_static = true;
+ }
- // clang_type will get the function prototype clang type after this
- // call
- clang_type = m_ast.CreateFunctionType(
- return_clang_type, function_param_types.data(),
- function_param_types.size(), is_variadic, type_quals);
-
- if (type_name_cstr) {
- bool type_handled = false;
- if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
- ObjCLanguage::MethodName objc_method(type_name_cstr, true);
- if (objc_method.IsValid(true)) {
- CompilerType class_opaque_type;
- ConstString class_name(objc_method.GetClassName());
- if (class_name) {
- TypeSP complete_objc_class_type_sp(
- dwarf->FindCompleteObjCDefinitionTypeForDIE(
- DWARFDIE(), class_name, false));
-
- if (complete_objc_class_type_sp) {
- CompilerType type_clang_forward_type =
- complete_objc_class_type_sp->GetForwardCompilerType();
- if (ClangASTContext::IsObjCObjectOrInterfaceType(
- type_clang_forward_type))
- class_opaque_type = type_clang_forward_type;
- }
- }
+ if (die.HasChildren()) {
+ bool skip_artificial = true;
+ ParseChildParameters(containing_decl_ctx, die, skip_artificial, is_static,
+ is_variadic, has_template_params,
+ function_param_types, function_param_decls,
+ type_quals);
+ }
- if (class_opaque_type) {
- // If accessibility isn't set to anything valid, assume public
- // for now...
- if (accessibility == eAccessNone)
- accessibility = eAccessPublic;
-
- clang::ObjCMethodDecl *objc_method_decl =
- m_ast.AddMethodToObjCObjectType(
- class_opaque_type, type_name_cstr, clang_type,
- accessibility, is_artificial, is_variadic);
- type_handled = objc_method_decl != NULL;
- if (type_handled) {
- LinkDeclContextToDIE(
- ClangASTContext::GetAsDeclContext(objc_method_decl), die);
- m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
- } else {
- dwarf->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
- "please file a bug and attach the file at the start of "
- "this error message",
- die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+ bool ignore_containing_context = false;
+ // Check for templatized class member functions. If we had any
+ // DW_TAG_template_type_parameter or DW_TAG_template_value_parameter
+ // the DW_TAG_subprogram DIE, then we can't let this become a method in
+ // a class. Why? Because templatized functions are only emitted if one
+ // of the templatized methods is used in the current compile unit and
+ // we will end up with classes that may or may not include these member
+ // functions and this means one class won't match another class
+ // definition and it affects our ability to use a class in the clang
+ // expression parser. So for the greater good, we currently must not
+ // allow any template member functions in a class definition.
+ if (is_cxx_method && has_template_params) {
+ ignore_containing_context = true;
+ is_cxx_method = false;
+ }
+
+ // clang_type will get the function prototype clang type after this
+ // call
+ clang_type = m_ast.CreateFunctionType(
+ return_clang_type, function_param_types.data(),
+ function_param_types.size(), is_variadic, type_quals);
+
+ if (attrs.name) {
+ bool type_handled = false;
+ if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
+ ObjCLanguage::MethodName objc_method(attrs.name.GetStringRef(), true);
+ if (objc_method.IsValid(true)) {
+ CompilerType class_opaque_type;
+ ConstString class_name(objc_method.GetClassName());
+ if (class_name) {
+ TypeSP complete_objc_class_type_sp(
+ dwarf->FindCompleteObjCDefinitionTypeForDIE(DWARFDIE(),
+ class_name, false));
+
+ if (complete_objc_class_type_sp) {
+ CompilerType type_clang_forward_type =
+ complete_objc_class_type_sp->GetForwardCompilerType();
+ if (ClangASTContext::IsObjCObjectOrInterfaceType(
+ type_clang_forward_type))
+ class_opaque_type = type_clang_forward_type;
+ }
+ }
+
+ if (class_opaque_type) {
+ // If accessibility isn't set to anything valid, assume public
+ // for now...
+ if (attrs.accessibility == eAccessNone)
+ attrs.accessibility = eAccessPublic;
+
+ clang::ObjCMethodDecl *objc_method_decl =
+ m_ast.AddMethodToObjCObjectType(
+ class_opaque_type, attrs.name.GetCString(), clang_type,
+ attrs.accessibility, attrs.is_artificial, is_variadic);
+ type_handled = objc_method_decl != NULL;
+ if (type_handled) {
+ LinkDeclContextToDIE(
+ ClangASTContext::GetAsDeclContext(objc_method_decl), die);
+ m_ast.SetMetadataAsUserID(objc_method_decl, die.GetID());
+ } else {
+ dwarf->GetObjectFile()->GetModule()->ReportError(
+ "{0x%8.8x}: invalid Objective-C method 0x%4.4x (%s), "
+ "please file a bug and attach the file at the start of "
+ "this error message",
+ die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+ }
+ }
+ } else if (is_cxx_method) {
+ // Look at the parent of this DIE and see if is is a class or
+ // struct and see if this is actually a C++ method
+ Type *class_type = dwarf->ResolveType(decl_ctx_die);
+ if (class_type) {
+ bool alternate_defn = false;
+ if (class_type->GetID() != decl_ctx_die.GetID() ||
+ decl_ctx_die.GetContainingDWOModuleDIE()) {
+ alternate_defn = true;
+
+ // We uniqued the parent class of this function to another
+ // class so we now need to associate all dies under
+ // "decl_ctx_die" to DIEs in the DIE for "class_type"...
+ DWARFDIE class_type_die = dwarf->GetDIE(class_type->GetID());
+
+ if (class_type_die) {
+ std::vector<DWARFDIE> failures;
+
+ CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
+ class_type, failures);
+
+ // FIXME do something with these failures that's smarter
+ // than
+ // just dropping them on the ground. Unfortunately classes
+ // don't like having stuff added to them after their
+ // definitions are complete...
+
+ type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
+ if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
+ type_sp = type_ptr->shared_from_this();
+ break;
}
}
- } else if (is_cxx_method) {
- // Look at the parent of this DIE and see if is is a class or
- // struct and see if this is actually a C++ method
- Type *class_type = dwarf->ResolveType(decl_ctx_die);
- if (class_type) {
- bool alternate_defn = false;
- if (class_type->GetID() != decl_ctx_die.GetID() ||
- decl_ctx_die.GetContainingDWOModuleDIE()) {
- alternate_defn = true;
-
- // We uniqued the parent class of this function to another
- // class so we now need to associate all dies under
- // "decl_ctx_die" to DIEs in the DIE for "class_type"...
- SymbolFileDWARF *class_symfile = NULL;
- DWARFDIE class_type_die;
-
- SymbolFileDWARFDebugMap *debug_map_symfile =
- dwarf->GetDebugMapSymfile();
- if (debug_map_symfile) {
- class_symfile = debug_map_symfile->GetSymbolFileByOSOIndex(
- SymbolFileDWARFDebugMap::GetOSOIndexFromUserID(
- class_type->GetID()));
- class_type_die = class_symfile->DebugInfo()->GetDIE(
- DIERef(class_type->GetID(), dwarf));
- } else {
- class_symfile = dwarf;
- class_type_die = dwarf->DebugInfo()->GetDIE(
- DIERef(class_type->GetID(), dwarf));
- }
- if (class_type_die) {
- DWARFDIECollection failures;
-
- CopyUniqueClassMethodTypes(decl_ctx_die, class_type_die,
- class_type, failures);
-
- // FIXME do something with these failures that's smarter
- // than
- // just dropping them on the ground. Unfortunately classes
- // don't like having stuff added to them after their
- // definitions are complete...
-
- type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
- if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
- type_sp = type_ptr->shared_from_this();
- break;
- }
- }
- }
+ }
- if (specification_die_form.IsValid()) {
- // We have a specification which we are going to base our
- // function prototype off of, so we need this type to be
- // completed so that the m_die_to_decl_ctx for the method in
- // the specification has a valid clang decl context.
- class_type->GetForwardCompilerType();
- // If we have a specification, then the function type should
- // have been made with the specification and not with this
- // die.
- DWARFDIE spec_die = dwarf->DebugInfo()->GetDIE(
- DIERef(specification_die_form));
- clang::DeclContext *spec_clang_decl_ctx =
- GetClangDeclContextForDIE(spec_die);
- if (spec_clang_decl_ctx) {
- LinkDeclContextToDIE(spec_clang_decl_ctx, die);
- } else {
- dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8" PRIx64
- ") has no decl\n",
- die.GetID(), specification_die_form.Reference());
- }
- type_handled = true;
- } else if (abstract_origin_die_form.IsValid()) {
- // We have a specification which we are going to base our
- // function prototype off of, so we need this type to be
- // completed so that the m_die_to_decl_ctx for the method in
- // the abstract origin has a valid clang decl context.
+ if (attrs.specification.IsValid()) {
+ // We have a specification which we are going to base our
+ // function prototype off of, so we need this type to be
+ // completed so that the m_die_to_decl_ctx for the method in
+ // the specification has a valid clang decl context.
+ class_type->GetForwardCompilerType();
+ // If we have a specification, then the function type should
+ // have been made with the specification and not with this
+ // die.
+ DWARFDIE spec_die = attrs.specification.Reference();
+ clang::DeclContext *spec_clang_decl_ctx =
+ GetClangDeclContextForDIE(spec_die);
+ if (spec_clang_decl_ctx) {
+ LinkDeclContextToDIE(spec_clang_decl_ctx, die);
+ } else {
+ dwarf->GetObjectFile()->GetModule()->ReportWarning(
+ "0x%8.8" PRIx64 ": DW_AT_specification(0x%8.8x"
+ ") has no decl\n",
+ die.GetID(), spec_die.GetOffset());
+ }
+ type_handled = true;
+ } else if (attrs.abstract_origin.IsValid()) {
+ // We have a specification which we are going to base our
+ // function prototype off of, so we need this type to be
+ // completed so that the m_die_to_decl_ctx for the method in
+ // the abstract origin has a valid clang decl context.
+ class_type->GetForwardCompilerType();
+
+ DWARFDIE abs_die = attrs.abstract_origin.Reference();
+ clang::DeclContext *abs_clang_decl_ctx =
+ GetClangDeclContextForDIE(abs_die);
+ if (abs_clang_decl_ctx) {
+ LinkDeclContextToDIE(abs_clang_decl_ctx, die);
+ } else {
+ dwarf->GetObjectFile()->GetModule()->ReportWarning(
+ "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8x"
+ ") has no decl\n",
+ die.GetID(), abs_die.GetOffset());
+ }
+ type_handled = true;
+ } else {
+ CompilerType class_opaque_type =
class_type->GetForwardCompilerType();
-
- DWARFDIE abs_die = dwarf->DebugInfo()->GetDIE(
- DIERef(abstract_origin_die_form));
- clang::DeclContext *abs_clang_decl_ctx =
- GetClangDeclContextForDIE(abs_die);
- if (abs_clang_decl_ctx) {
- LinkDeclContextToDIE(abs_clang_decl_ctx, die);
+ if (ClangASTContext::IsCXXClassType(class_opaque_type)) {
+ if (class_opaque_type.IsBeingDefined() || alternate_defn) {
+ if (!is_static && !die.HasChildren()) {
+ // We have a C++ member function with no children (this
+ // pointer!) and clang will get mad if we try and make
+ // a function that isn't well formed in the DWARF, so
+ // we will just skip it...
+ type_handled = true;
} else {
- dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64 ": DW_AT_abstract_origin(0x%8.8" PRIx64
- ") has no decl\n",
- die.GetID(), abstract_origin_die_form.Reference());
- }
- type_handled = true;
- } else {
- CompilerType class_opaque_type =
- class_type->GetForwardCompilerType();
- if (ClangASTContext::IsCXXClassType(class_opaque_type)) {
- if (class_opaque_type.IsBeingDefined() || alternate_defn) {
- if (!is_static && !die.HasChildren()) {
- // We have a C++ member function with no children (this
- // pointer!) and clang will get mad if we try and make
- // a function that isn't well formed in the DWARF, so
- // we will just skip it...
- type_handled = true;
- } else {
- bool add_method = true;
- if (alternate_defn) {
- // If an alternate definition for the class exists,
- // then add the method only if an equivalent is not
- // already present.
- clang::CXXRecordDecl *record_decl =
- m_ast.GetAsCXXRecordDecl(
- class_opaque_type.GetOpaqueQualType());
- if (record_decl) {
- for (auto method_iter = record_decl->method_begin();
- method_iter != record_decl->method_end();
- method_iter++) {
- clang::CXXMethodDecl *method_decl = *method_iter;
- if (method_decl->getNameInfo().getAsString() ==
- std::string(type_name_cstr)) {
- if (method_decl->getType() ==
- ClangUtil::GetQualType(clang_type)) {
- add_method = false;
- LinkDeclContextToDIE(
- ClangASTContext::GetAsDeclContext(
- method_decl),
- die);
- type_handled = true;
-
- break;
- }
- }
+ bool add_method = true;
+ if (alternate_defn) {
+ // If an alternate definition for the class exists,
+ // then add the method only if an equivalent is not
+ // already present.
+ clang::CXXRecordDecl *record_decl =
+ m_ast.GetAsCXXRecordDecl(
+ class_opaque_type.GetOpaqueQualType());
+ if (record_decl) {
+ for (auto method_iter = record_decl->method_begin();
+ method_iter != record_decl->method_end();
+ method_iter++) {
+ clang::CXXMethodDecl *method_decl = *method_iter;
+ if (method_decl->getNameInfo().getAsString() ==
+ attrs.name.GetStringRef()) {
+ if (method_decl->getType() ==
+ ClangUtil::GetQualType(clang_type)) {
+ add_method = false;
+ LinkDeclContextToDIE(
+ ClangASTContext::GetAsDeclContext(
+ method_decl),
+ die);
+ type_handled = true;
+
+ break;
}
}
}
+ }
+ }
- if (add_method) {
- llvm::PrettyStackTraceFormat stack_trace(
- "SymbolFileDWARF::ParseType() is adding a method "
- "%s to class %s in DIE 0x%8.8" PRIx64 " from %s",
- type_name_cstr,
- class_type->GetName().GetCString(), die.GetID(),
- dwarf->GetObjectFile()
- ->GetFileSpec()
- .GetPath()
- .c_str());
-
- const bool is_attr_used = false;
- // Neither GCC 4.2 nor clang++ currently set a valid
- // accessibility in the DWARF for C++ methods...
- // Default to public for now...
- if (accessibility == eAccessNone)
- accessibility = eAccessPublic;
-
- clang::CXXMethodDecl *cxx_method_decl =
- m_ast.AddMethodToCXXRecordType(
- class_opaque_type.GetOpaqueQualType(),
- type_name_cstr, mangled_name_cstr, clang_type,
- accessibility, is_virtual, is_static,
- is_inline, is_explicit, is_attr_used,
- is_artificial);
-
- type_handled = cxx_method_decl != NULL;
-
- if (type_handled) {
- LinkDeclContextToDIE(
- ClangASTContext::GetAsDeclContext(
- cxx_method_decl),
- die);
-
- ClangASTMetadata metadata;
- metadata.SetUserID(die.GetID());
-
- if (!object_pointer_name.empty()) {
- metadata.SetObjectPtrName(
- object_pointer_name.c_str());
- if (log)
- log->Printf(
- "Setting object pointer name: %s on method "
- "object %p.\n",
- object_pointer_name.c_str(),
- static_cast<void *>(cxx_method_decl));
- }
- m_ast.SetMetadata(cxx_method_decl, metadata);
- } else {
- ignore_containing_context = true;
- }
+ if (add_method) {
+ llvm::PrettyStackTraceFormat stack_trace(
+ "SymbolFileDWARF::ParseType() is adding a method "
+ "%s to class %s in DIE 0x%8.8" PRIx64 " from %s",
+ attrs.name.GetCString(),
+ class_type->GetName().GetCString(), die.GetID(),
+ dwarf->GetObjectFile()
+ ->GetFileSpec()
+ .GetPath()
+ .c_str());
+
+ const bool is_attr_used = false;
+ // Neither GCC 4.2 nor clang++ currently set a valid
+ // accessibility in the DWARF for C++ methods...
+ // Default to public for now...
+ if (attrs.accessibility == eAccessNone)
+ attrs.accessibility = eAccessPublic;
+
+ clang::CXXMethodDecl *cxx_method_decl =
+ m_ast.AddMethodToCXXRecordType(
+ class_opaque_type.GetOpaqueQualType(),
+ attrs.name.GetCString(), attrs.mangled_name,
+ clang_type, attrs.accessibility, attrs.is_virtual,
+ is_static, attrs.is_inline, attrs.is_explicit,
+ is_attr_used, attrs.is_artificial);
+
+ type_handled = cxx_method_decl != NULL;
+
+ if (type_handled) {
+ LinkDeclContextToDIE(
+ ClangASTContext::GetAsDeclContext(cxx_method_decl),
+ die);
+
+ ClangASTMetadata metadata;
+ metadata.SetUserID(die.GetID());
+
+ if (!object_pointer_name.empty()) {
+ metadata.SetObjectPtrName(
+ object_pointer_name.c_str());
+ if (log)
+ log->Printf(
+ "Setting object pointer name: %s on method "
+ "object %p.\n",
+ object_pointer_name.c_str(),
+ static_cast<void *>(cxx_method_decl));
}
+ m_ast.SetMetadata(cxx_method_decl, metadata);
+ } else {
+ ignore_containing_context = true;
}
- } else {
- // We were asked to parse the type for a method in a
- // class, yet the class hasn't been asked to complete
- // itself through the clang::ExternalASTSource protocol,
- // so we need to just have the class complete itself and
- // do things the right way, then our
- // DIE should then have an entry in the
- // dwarf->GetDIEToType() map. First
- // we need to modify the dwarf->GetDIEToType() so it
- // doesn't think we are trying to parse this DIE
- // anymore...
- dwarf->GetDIEToType()[die.GetDIE()] = NULL;
-
- // Now we get the full type to force our class type to
- // complete itself using the clang::ExternalASTSource
- // protocol which will parse all base classes and all
- // methods (including the method for this DIE).
- class_type->GetFullCompilerType();
-
- // The type for this DIE should have been filled in the
- // function call above
- type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
- if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
- type_sp = type_ptr->shared_from_this();
- break;
- }
-
- // FIXME This is fixing some even uglier behavior but we
- // really need to
- // uniq the methods of each class as well as the class
- // itself. <rdar://problem/11240464>
- type_handled = true;
}
}
- }
- }
- }
- }
-
- if (!type_handled) {
- clang::FunctionDecl *function_decl = nullptr;
-
- if (abstract_origin_die_form.IsValid()) {
- DWARFDIE abs_die =
- dwarf->DebugInfo()->GetDIE(DIERef(abstract_origin_die_form));
-
- SymbolContext sc;
-
- if (dwarf->ResolveType(abs_die)) {
- function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
- GetCachedClangDeclContextForDIE(abs_die));
+ } else {
+ // We were asked to parse the type for a method in a
+ // class, yet the class hasn't been asked to complete
+ // itself through the clang::ExternalASTSource protocol,
+ // so we need to just have the class complete itself and
+ // do things the right way, then our
+ // DIE should then have an entry in the
+ // dwarf->GetDIEToType() map. First
+ // we need to modify the dwarf->GetDIEToType() so it
+ // doesn't think we are trying to parse this DIE
+ // anymore...
+ dwarf->GetDIEToType()[die.GetDIE()] = NULL;
+
+ // Now we get the full type to force our class type to
+ // complete itself using the clang::ExternalASTSource
+ // protocol which will parse all base classes and all
+ // methods (including the method for this DIE).
+ class_type->GetFullCompilerType();
+
+ // The type for this DIE should have been filled in the
+ // function call above
+ type_ptr = dwarf->GetDIEToType()[die.GetDIE()];
+ if (type_ptr && type_ptr != DIE_IS_BEING_PARSED) {
+ type_sp = type_ptr->shared_from_this();
+ break;
+ }
- if (function_decl) {
- LinkDeclContextToDIE(function_decl, die);
+ // FIXME This is fixing some even uglier behavior but we
+ // really need to
+ // uniq the methods of each class as well as the class
+ // itself. <rdar://problem/11240464>
+ type_handled = true;
}
}
}
+ }
+ }
+ }
- if (!function_decl) {
- // We just have a function that isn't part of a class
- function_decl = m_ast.CreateFunctionDeclaration(
- ignore_containing_context ? m_ast.GetTranslationUnitDecl()
- : containing_decl_ctx,
- type_name_cstr, clang_type, storage, is_inline);
-
- if (has_template_params) {
- ClangASTContext::TemplateParameterInfos template_param_infos;
- ParseTemplateParameterInfos(die, template_param_infos);
- clang::FunctionTemplateDecl *func_template_decl =
- m_ast.CreateFunctionTemplateDecl(
- containing_decl_ctx, function_decl, type_name_cstr,
- template_param_infos);
- m_ast.CreateFunctionTemplateSpecializationInfo(
- function_decl, func_template_decl, template_param_infos);
- }
-
- lldbassert(function_decl);
-
- if (function_decl) {
- LinkDeclContextToDIE(function_decl, die);
+ if (!type_handled) {
+ clang::FunctionDecl *function_decl = nullptr;
+ clang::FunctionDecl *template_function_decl = nullptr;
- if (!function_param_decls.empty())
- m_ast.SetFunctionParameters(function_decl,
- &function_param_decls.front(),
- function_param_decls.size());
+ if (attrs.abstract_origin.IsValid()) {
+ DWARFDIE abs_die = attrs.abstract_origin.Reference();
- ClangASTMetadata metadata;
- metadata.SetUserID(die.GetID());
+ if (dwarf->ResolveType(abs_die)) {
+ function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
+ GetCachedClangDeclContextForDIE(abs_die));
- if (!object_pointer_name.empty()) {
- metadata.SetObjectPtrName(object_pointer_name.c_str());
- if (log)
- log->Printf("Setting object pointer name: %s on function "
- "object %p.",
- object_pointer_name.c_str(),
- static_cast<void *>(function_decl));
- }
- m_ast.SetMetadata(function_decl, metadata);
- }
+ if (function_decl) {
+ LinkDeclContextToDIE(function_decl, die);
}
}
}
- type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str, 0, NULL,
- LLDB_INVALID_UID, Type::eEncodingIsUID, &decl,
- clang_type, Type::eResolveStateFull));
- assert(type_sp.get());
- } break;
-
- case DW_TAG_array_type: {
- // Set a bit that lets us know that we are currently parsing this
- dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
-
- DWARFFormValue type_die_form;
- int64_t first_index = 0;
- uint32_t byte_stride = 0;
- uint32_t bit_stride = 0;
- bool is_vector = false;
- const size_t num_attributes = die.GetAttributes(attributes);
-
- if (num_attributes > 0) {
- uint32_t i;
- for (i = 0; i < num_attributes; ++i) {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
- case DW_AT_name:
- type_name_cstr = form_value.AsCString();
- type_name_const_str.SetCString(type_name_cstr);
- break;
-
- case DW_AT_type:
- type_die_form = form_value;
- break;
- case DW_AT_byte_size:
- break; // byte_size = form_value.Unsigned(); break;
- case DW_AT_byte_stride:
- byte_stride = form_value.Unsigned();
- break;
- case DW_AT_bit_stride:
- bit_stride = form_value.Unsigned();
- break;
- case DW_AT_GNU_vector:
- is_vector = form_value.Boolean();
- break;
- case DW_AT_accessibility:
- break; // accessibility =
- // DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
- case DW_AT_declaration:
- break; // is_forward_declaration = form_value.Boolean(); break;
- case DW_AT_allocated:
- case DW_AT_associated:
- case DW_AT_data_location:
- case DW_AT_description:
- case DW_AT_ordering:
- case DW_AT_start_scope:
- case DW_AT_visibility:
- case DW_AT_specification:
- case DW_AT_abstract_origin:
- case DW_AT_sibling:
- break;
- }
- }
- }
- DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
- DW_TAG_value_to_name(tag), type_name_cstr);
+ if (!function_decl) {
+ // We just have a function that isn't part of a class
+ function_decl = m_ast.CreateFunctionDeclaration(
+ ignore_containing_context ? m_ast.GetTranslationUnitDecl()
+ : containing_decl_ctx,
+ attrs.name.GetCString(), clang_type, attrs.storage,
+ attrs.is_inline);
- DIERef type_die_ref(type_die_form);
- Type *element_type = dwarf->ResolveTypeUID(type_die_ref);
+ if (has_template_params) {
+ ClangASTContext::TemplateParameterInfos template_param_infos;
+ ParseTemplateParameterInfos(die, template_param_infos);
+ template_function_decl = m_ast.CreateFunctionDeclaration(
+ ignore_containing_context ? m_ast.GetTranslationUnitDecl()
+ : containing_decl_ctx,
+ attrs.name.GetCString(), clang_type, attrs.storage,
+ attrs.is_inline);
+ clang::FunctionTemplateDecl *func_template_decl =
+ m_ast.CreateFunctionTemplateDecl(
+ containing_decl_ctx, template_function_decl,
+ attrs.name.GetCString(), template_param_infos);
+ m_ast.CreateFunctionTemplateSpecializationInfo(
+ function_decl, func_template_decl, template_param_infos);
+ }
- if (element_type) {
- auto array_info = ParseChildArrayInfo(die);
- if (array_info) {
- first_index = array_info->first_index;
- byte_stride = array_info->byte_stride;
- bit_stride = array_info->bit_stride;
- }
- if (byte_stride == 0 && bit_stride == 0)
- byte_stride = element_type->GetByteSize();
- CompilerType array_element_type =
- element_type->GetForwardCompilerType();
-
- if (ClangASTContext::IsCXXClassType(array_element_type) &&
- !array_element_type.GetCompleteType()) {
- ModuleSP module_sp = die.GetModule();
- if (module_sp) {
- if (die.GetCU()->GetProducer() == eProducerClang)
- module_sp->ReportError(
- "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
- "class/union/struct element type DIE 0x%8.8x that is a "
- "forward declaration, not a complete definition.\nTry "
- "compiling the source file with -fstandalone-debug or "
- "disable -gmodules",
- die.GetOffset(), type_die_ref.die_offset);
- else
- module_sp->ReportError(
- "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
- "class/union/struct element type DIE 0x%8.8x that is a "
- "forward declaration, not a complete definition.\nPlease "
- "file a bug against the compiler and include the "
- "preprocessed output for %s",
- die.GetOffset(), type_die_ref.die_offset,
- die.GetLLDBCompileUnit()
- ? die.GetLLDBCompileUnit()->GetPath().c_str()
- : "the source file");
- }
+ lldbassert(function_decl);
- // We have no choice other than to pretend that the element class
- // type is complete. If we don't do this, clang will crash when
- // trying to layout the class. Since we provide layout
- // assistance, all ivars in this class and other classes will be
- // fine, this is the best we can do short of crashing.
- if (ClangASTContext::StartTagDeclarationDefinition(
- array_element_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(
- array_element_type);
- } else {
- module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to "
- "start its definition.\nPlease file a "
- "bug and attach the file at the start "
- "of this error message",
- type_die_ref.die_offset);
- }
- }
+ if (function_decl) {
+ LinkDeclContextToDIE(function_decl, die);
- uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
- if (array_info && array_info->element_orders.size() > 0) {
- uint64_t num_elements = 0;
- auto end = array_info->element_orders.rend();
- for (auto pos = array_info->element_orders.rbegin(); pos != end;
- ++pos) {
- num_elements = *pos;
- clang_type = m_ast.CreateArrayType(array_element_type,
- num_elements, is_vector);
- array_element_type = clang_type;
- array_element_bit_stride =
- num_elements ? array_element_bit_stride * num_elements
- : array_element_bit_stride;
- }
- } else {
- clang_type =
- m_ast.CreateArrayType(array_element_type, 0, is_vector);
+ if (!function_param_decls.empty()) {
+ m_ast.SetFunctionParameters(function_decl,
+ &function_param_decls.front(),
+ function_param_decls.size());
+ if (template_function_decl)
+ m_ast.SetFunctionParameters(template_function_decl,
+ &function_param_decls.front(),
+ function_param_decls.size());
}
- ConstString empty_name;
- type_sp.reset(new Type(
- die.GetID(), dwarf, empty_name, array_element_bit_stride / 8,
- NULL, DIERef(type_die_form).GetUID(dwarf), Type::eEncodingIsUID,
- &decl, clang_type, Type::eResolveStateFull));
- type_sp->SetEncodingType(element_type);
- m_ast.SetMetadataAsUserID(clang_type.GetOpaqueQualType(),
- die.GetID());
- }
- }
- } break;
-
- case DW_TAG_ptr_to_member_type: {
- DWARFFormValue type_die_form;
- DWARFFormValue containing_type_die_form;
-
- const size_t num_attributes = die.GetAttributes(attributes);
-
- if (num_attributes > 0) {
- uint32_t i;
- for (i = 0; i < num_attributes; ++i) {
- attr = attributes.AttributeAtIndex(i);
- if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- switch (attr) {
- case DW_AT_type:
- type_die_form = form_value;
- break;
- case DW_AT_containing_type:
- containing_type_die_form = form_value;
- break;
- }
- }
- }
-
- Type *pointee_type = dwarf->ResolveTypeUID(DIERef(type_die_form));
- Type *class_type =
- dwarf->ResolveTypeUID(DIERef(containing_type_die_form));
-
- CompilerType pointee_clang_type =
- pointee_type->GetForwardCompilerType();
- CompilerType class_clang_type = class_type->GetLayoutCompilerType();
- clang_type = ClangASTContext::CreateMemberPointerType(
- class_clang_type, pointee_clang_type);
+ ClangASTMetadata metadata;
+ metadata.SetUserID(die.GetID());
- if (llvm::Optional<uint64_t> clang_type_size =
- clang_type.GetByteSize(nullptr)) {
- byte_size = *clang_type_size;
- type_sp.reset(new Type(die.GetID(), dwarf, type_name_const_str,
- byte_size, NULL, LLDB_INVALID_UID,
- Type::eEncodingIsUID, NULL, clang_type,
- Type::eResolveStateForward));
+ if (!object_pointer_name.empty()) {
+ metadata.SetObjectPtrName(object_pointer_name.c_str());
+ if (log)
+ log->Printf("Setting object pointer name: %s on function "
+ "object %p.",
+ object_pointer_name.c_str(),
+ static_cast<void *>(function_decl));
+ }
+ m_ast.SetMetadata(function_decl, metadata);
}
}
-
- break;
}
- default:
- dwarf->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
- "attach the file at the start of this error message",
- die.GetOffset(), tag, DW_TAG_value_to_name(tag));
- break;
+ }
+ type_sp = std::make_shared<Type>(
+ die.GetID(), dwarf, attrs.name, llvm::None, nullptr, LLDB_INVALID_UID,
+ Type::eEncodingIsUID, &attrs.decl, clang_type, Type::eResolveStateFull);
+ assert(type_sp.get());
+ } break;
+
+ case DW_TAG_array_type: {
+ DEBUG_PRINTF("0x%8.8" PRIx64 ": %s (\"%s\")\n", die.GetID(),
+ DW_TAG_value_to_name(tag), type_name_cstr);
+
+ DWARFDIE type_die = attrs.type.Reference();
+ Type *element_type = dwarf->ResolveTypeUID(type_die, true);
+
+ if (element_type) {
+ auto array_info = ParseChildArrayInfo(die);
+ if (array_info) {
+ attrs.byte_stride = array_info->byte_stride;
+ attrs.bit_stride = array_info->bit_stride;
}
+ if (attrs.byte_stride == 0 && attrs.bit_stride == 0)
+ attrs.byte_stride = element_type->GetByteSize().getValueOr(0);
+ CompilerType array_element_type = element_type->GetForwardCompilerType();
+
+ if (ClangASTContext::IsCXXClassType(array_element_type) &&
+ !array_element_type.GetCompleteType()) {
+ ModuleSP module_sp = die.GetModule();
+ if (module_sp) {
+ if (die.GetCU()->GetProducer() == eProducerClang)
+ module_sp->ReportError(
+ "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
+ "class/union/struct element type DIE 0x%8.8x that is a "
+ "forward declaration, not a complete definition.\nTry "
+ "compiling the source file with -fstandalone-debug or "
+ "disable -gmodules",
+ die.GetOffset(), type_die.GetOffset());
+ else
+ module_sp->ReportError(
+ "DWARF DW_TAG_array_type DIE at 0x%8.8x has a "
+ "class/union/struct element type DIE 0x%8.8x that is a "
+ "forward declaration, not a complete definition.\nPlease "
+ "file a bug against the compiler and include the "
+ "preprocessed output for %s",
+ die.GetOffset(), type_die.GetOffset(),
+ GetUnitName(die).c_str());
+ }
- if (type_sp.get()) {
- DWARFDIE sc_parent_die =
- SymbolFileDWARF::GetParentSymbolContextDIE(die);
- dw_tag_t sc_parent_tag = sc_parent_die.Tag();
-
- SymbolContextScope *symbol_context_scope = NULL;
- if (sc_parent_tag == DW_TAG_compile_unit ||
- sc_parent_tag == DW_TAG_partial_unit) {
- symbol_context_scope = sc.comp_unit;
- } else if (sc.function != NULL && sc_parent_die) {
- symbol_context_scope =
- sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
- if (symbol_context_scope == NULL)
- symbol_context_scope = sc.function;
+ // We have no choice other than to pretend that the element class
+ // type is complete. If we don't do this, clang will crash when
+ // trying to layout the class. Since we provide layout
+ // assistance, all ivars in this class and other classes will be
+ // fine, this is the best we can do short of crashing.
+ if (ClangASTContext::StartTagDeclarationDefinition(
+ array_element_type)) {
+ ClangASTContext::CompleteTagDeclarationDefinition(array_element_type);
+ } else {
+ module_sp->ReportError("DWARF DIE at 0x%8.8x was not able to "
+ "start its definition.\nPlease file a "
+ "bug and attach the file at the start "
+ "of this error message",
+ type_die.GetOffset());
}
+ }
- if (symbol_context_scope != NULL) {
- type_sp->SetSymbolContextScope(symbol_context_scope);
+ uint64_t array_element_bit_stride =
+ attrs.byte_stride * 8 + attrs.bit_stride;
+ if (array_info && array_info->element_orders.size() > 0) {
+ uint64_t num_elements = 0;
+ auto end = array_info->element_orders.rend();
+ for (auto pos = array_info->element_orders.rbegin(); pos != end;
+ ++pos) {
+ num_elements = *pos;
+ clang_type = m_ast.CreateArrayType(array_element_type, num_elements,
+ attrs.is_vector);
+ array_element_type = clang_type;
+ array_element_bit_stride =
+ num_elements ? array_element_bit_stride * num_elements
+ : array_element_bit_stride;
}
+ } else {
+ clang_type = m_ast.CreateArrayType(array_element_type, 0, attrs.is_vector);
+ }
+ ConstString empty_name;
+ type_sp = std::make_shared<Type>(
+ die.GetID(), dwarf, empty_name, array_element_bit_stride / 8, nullptr,
+ dwarf->GetUID(type_die), Type::eEncodingIsUID, &attrs.decl,
+ clang_type, Type::eResolveStateFull);
+ type_sp->SetEncodingType(element_type);
+ m_ast.SetMetadataAsUserID(clang_type.GetOpaqueQualType(), die.GetID());
+ }
+ } break;
- // We are ready to put this type into the uniqued list up at the module
- // level
- type_list->Insert(type_sp);
+ case DW_TAG_ptr_to_member_type: {
+ Type *pointee_type = dwarf->ResolveTypeUID(attrs.type.Reference(), true);
+ Type *class_type =
+ dwarf->ResolveTypeUID(attrs.containing_type.Reference(), true);
- dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
- }
- } else if (type_ptr != DIE_IS_BEING_PARSED) {
- type_sp = type_ptr->shared_from_this();
+ CompilerType pointee_clang_type = pointee_type->GetForwardCompilerType();
+ CompilerType class_clang_type = class_type->GetLayoutCompilerType();
+
+ clang_type = ClangASTContext::CreateMemberPointerType(class_clang_type,
+ pointee_clang_type);
+
+ if (llvm::Optional<uint64_t> clang_type_size =
+ clang_type.GetByteSize(nullptr)) {
+ type_sp = std::make_shared<Type>(
+ die.GetID(), dwarf, attrs.name, *clang_type_size, nullptr,
+ LLDB_INVALID_UID, Type::eEncodingIsUID, nullptr, clang_type,
+ Type::eResolveStateForward);
+ }
+
+ break;
+ }
+ default:
+ dwarf->GetObjectFile()->GetModule()->ReportError(
+ "{0x%8.8x}: unhandled type tag 0x%4.4x (%s), please file a bug and "
+ "attach the file at the start of this error message",
+ die.GetOffset(), tag, DW_TAG_value_to_name(tag));
+ break;
+ }
+
+ if (type_sp.get()) {
+ DWARFDIE sc_parent_die = SymbolFileDWARF::GetParentSymbolContextDIE(die);
+ dw_tag_t sc_parent_tag = sc_parent_die.Tag();
+
+ SymbolContextScope *symbol_context_scope = NULL;
+ if (sc_parent_tag == DW_TAG_compile_unit ||
+ sc_parent_tag == DW_TAG_partial_unit) {
+ symbol_context_scope = sc.comp_unit;
+ } else if (sc.function != NULL && sc_parent_die) {
+ symbol_context_scope =
+ sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
+ if (symbol_context_scope == NULL)
+ symbol_context_scope = sc.function;
+ } else
+ symbol_context_scope = sc.module_sp.get();
+
+ if (symbol_context_scope != NULL) {
+ type_sp->SetSymbolContextScope(symbol_context_scope);
}
+
+ // We are ready to put this type into the uniqued list up at the module
+ // level
+ type_list->Insert(type_sp);
+
+ dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
}
return type_sp;
}
@@ -1920,9 +1697,9 @@ public:
m_property_setter_name(property_setter_name),
m_property_getter_name(property_getter_name),
m_property_attributes(property_attributes) {
- if (metadata != NULL) {
- m_metadata_ap.reset(new ClangASTMetadata());
- *m_metadata_ap = *metadata;
+ if (metadata != nullptr) {
+ m_metadata_up.reset(new ClangASTMetadata());
+ *m_metadata_up = *metadata;
}
}
@@ -1940,9 +1717,9 @@ public:
m_property_getter_name = rhs.m_property_getter_name;
m_property_attributes = rhs.m_property_attributes;
- if (rhs.m_metadata_ap.get()) {
- m_metadata_ap.reset(new ClangASTMetadata());
- *m_metadata_ap = *rhs.m_metadata_ap;
+ if (rhs.m_metadata_up) {
+ m_metadata_up.reset(new ClangASTMetadata());
+ *m_metadata_up = *rhs.m_metadata_up;
}
return *this;
}
@@ -1951,7 +1728,7 @@ public:
return ClangASTContext::AddObjCClassProperty(
m_class_opaque_type, m_property_name, m_property_opaque_type,
m_ivar_decl, m_property_setter_name, m_property_getter_name,
- m_property_attributes, m_metadata_ap.get());
+ m_property_attributes, m_metadata_up.get());
}
private:
@@ -1962,7 +1739,7 @@ private:
const char *m_property_setter_name;
const char *m_property_getter_name;
uint32_t m_property_attributes;
- std::unique_ptr<ClangASTMetadata> m_metadata_ap;
+ std::unique_ptr<ClangASTMetadata> m_metadata_up;
};
bool DWARFASTParserClang::ParseTemplateDIE(
@@ -2015,7 +1792,7 @@ bool DWARFASTParserClang::ParseTemplateDIE(
case DW_AT_type:
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
- Type *lldb_type = die.ResolveTypeUID(DIERef(form_value));
+ Type *lldb_type = die.ResolveTypeUID(form_value.Reference());
if (lldb_type)
clang_type = lldb_type->GetForwardCompilerType();
}
@@ -2118,7 +1895,6 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
return false;
#if defined LLDB_CONFIGURATION_DEBUG
- //----------------------------------------------------------------------
// For debugging purposes, the LLDB_DWARF_DONT_COMPLETE_TYPENAMES environment
// variable can be set with one or more typenames separated by ';'
// characters. This will cause this function to not complete any types whose
@@ -2128,7 +1904,6 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
//
// LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo
// LLDB_DWARF_DONT_COMPLETE_TYPENAMES=Foo;Bar;Baz
- //----------------------------------------------------------------------
const char *dont_complete_typenames_cstr =
getenv("LLDB_DWARF_DONT_COMPLETE_TYPENAMES");
if (dont_complete_typenames_cstr && dont_complete_typenames_cstr[0]) {
@@ -2191,26 +1966,21 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
default_accessibility = eAccessPrivate;
}
- SymbolContext sc(die.GetLLDBCompileUnit());
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
std::vector<int> member_accessibilities;
bool is_a_class = false;
// Parse members and base classes first
- DWARFDIECollection member_function_dies;
+ std::vector<DWARFDIE> member_function_dies;
DelayedPropertyList delayed_properties;
- ParseChildMembers(sc, die, clang_type, class_language, bases,
+ ParseChildMembers(die, clang_type, class_language, bases,
member_accessibilities, member_function_dies,
delayed_properties, default_accessibility, is_a_class,
layout_info);
// Now parse any methods if there were any...
- size_t num_functions = member_function_dies.Size();
- if (num_functions > 0) {
- for (size_t i = 0; i < num_functions; ++i) {
- dwarf->ResolveType(member_function_dies.GetDIEAtIndex(i));
- }
- }
+ for (const DWARFDIE &die : member_function_dies)
+ dwarf->ResolveType(die);
if (class_language == eLanguageTypeObjC) {
ConstString class_name(clang_type.GetTypeName());
@@ -2313,7 +2083,7 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
!layout_info.base_offsets.empty() ||
!layout_info.vbase_offsets.empty()) {
if (type)
- layout_info.bit_size = type->GetByteSize() * 8;
+ layout_info.bit_size = type->GetByteSize().getValueOr(0) * 8;
if (layout_info.bit_size == 0)
layout_info.bit_size =
die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
@@ -2394,11 +2164,10 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
case DW_TAG_enumeration_type:
if (ClangASTContext::StartTagDeclarationDefinition(clang_type)) {
if (die.HasChildren()) {
- SymbolContext sc(die.GetLLDBCompileUnit());
bool is_signed = false;
clang_type.IsIntegerType(is_signed);
- ParseChildEnumerators(sc, clang_type, is_signed, type->GetByteSize(),
- die);
+ ParseChildEnumerators(clang_type, is_signed,
+ type->GetByteSize().getValueOr(0), die);
}
ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
}
@@ -2447,8 +2216,8 @@ DWARFASTParserClang::GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) {
}
size_t DWARFASTParserClang::ParseChildEnumerators(
- const SymbolContext &sc, lldb_private::CompilerType &clang_type,
- bool is_signed, uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
+ lldb_private::CompilerType &clang_type, bool is_signed,
+ uint32_t enumerator_byte_size, const DWARFDIE &parent_die) {
if (!parent_die)
return 0;
@@ -2461,7 +2230,7 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
DWARFAttributes attributes;
const size_t num_child_attributes = die.GetAttributes(attributes);
if (num_child_attributes > 0) {
- const char *name = NULL;
+ const char *name = nullptr;
bool got_value = false;
int64_t enum_value = 0;
Declaration decl;
@@ -2487,8 +2256,7 @@ size_t DWARFASTParserClang::ParseChildEnumerators(
case DW_AT_description:
default:
case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
+ decl.SetFile(die.GetCU()->GetFile(form_value.Unsigned()));
break;
case DW_AT_decl_line:
decl.SetLine(form_value.Unsigned());
@@ -2564,20 +2332,20 @@ protected:
Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
const DWARFDIE &die) {
DWARFRangeList func_ranges;
- const char *name = NULL;
- const char *mangled = NULL;
+ const char *name = nullptr;
+ const char *mangled = nullptr;
int decl_file = 0;
int decl_line = 0;
int decl_column = 0;
int call_file = 0;
int call_line = 0;
int call_column = 0;
- DWARFExpression frame_base(die.GetCU());
+ DWARFExpression frame_base;
const dw_tag_t tag = die.Tag();
if (tag != DW_TAG_subprogram)
- return NULL;
+ return nullptr;
if (die.GetDIENamesAndRanges(name, mangled, func_ranges, decl_file, decl_line,
decl_column, call_file, call_line, call_column,
@@ -2603,7 +2371,8 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
func_name.SetValue(ConstString(mangled), true);
else if ((die.GetParent().Tag() == DW_TAG_compile_unit ||
die.GetParent().Tag() == DW_TAG_partial_unit) &&
- Language::LanguageIsCPlusPlus(die.GetLanguage()) && name &&
+ Language::LanguageIsCPlusPlus(die.GetLanguage()) &&
+ !Language::LanguageIsObjC(die.GetLanguage()) && name &&
strcmp(name, "main") != 0) {
// If the mangled name is not present in the DWARF, generate the
// demangled name using the decl context. We skip if the function is
@@ -2622,9 +2391,9 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
clang::DeclContext *containing_decl_ctx =
GetClangDeclContextContainingDIE(die, nullptr);
- ParseChildParameters(comp_unit, containing_decl_ctx, die, true,
- is_static, is_variadic, has_template_params,
- param_types, param_decls, type_quals);
+ ParseChildParameters(containing_decl_ctx, die, true, is_static,
+ is_variadic, has_template_params, param_types,
+ param_decls, type_quals);
sstr << "(";
for (size_t i = 0; i < param_types.size(); i++) {
if (i > 0)
@@ -2642,26 +2411,26 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
func_name.SetValue(ConstString(name), false);
FunctionSP func_sp;
- std::unique_ptr<Declaration> decl_ap;
+ std::unique_ptr<Declaration> decl_up;
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
- decl_ap.reset(new Declaration(
- comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file),
- decl_line, decl_column));
+ decl_up.reset(new Declaration(die.GetCU()->GetFile(decl_file),
+ decl_line, decl_column));
SymbolFileDWARF *dwarf = die.GetDWARF();
// Supply the type _only_ if it has already been parsed
Type *func_type = dwarf->GetDIEToType().lookup(die.GetDIE());
- assert(func_type == NULL || func_type != DIE_IS_BEING_PARSED);
+ assert(func_type == nullptr || func_type != DIE_IS_BEING_PARSED);
if (dwarf->FixupAddress(func_range.GetBaseAddress())) {
const user_id_t func_user_id = die.GetID();
- func_sp.reset(new Function(&comp_unit,
+ func_sp =
+ std::make_shared<Function>(&comp_unit,
func_user_id, // UserID is the DIE offset
func_user_id, func_name, func_type,
- func_range)); // first address range
+ func_range); // first address range
- if (func_sp.get() != NULL) {
+ if (func_sp.get() != nullptr) {
if (frame_base.IsValid())
func_sp->GetFrameBaseExpression() = frame_base;
comp_unit.AddFunction(func_sp);
@@ -2670,19 +2439,19 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(CompileUnit &comp_unit,
}
}
}
- return NULL;
+ return nullptr;
}
bool DWARFASTParserClang::ParseChildMembers(
- const SymbolContext &sc, const DWARFDIE &parent_die,
- CompilerType &class_clang_type, const LanguageType class_language,
+ const DWARFDIE &parent_die, CompilerType &class_clang_type,
+ const LanguageType class_language,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<int> &member_accessibilities,
- DWARFDIECollection &member_function_dies,
+ std::vector<DWARFDIE> &member_function_dies,
DelayedPropertyList &delayed_properties, AccessType &default_accessibility,
bool &is_a_class, ClangASTImporter::LayoutInfo &layout_info) {
if (!parent_die)
- return 0;
+ return false;
// Get the parent byte size so we can verify any members will fit
const uint64_t parent_byte_size =
@@ -2697,7 +2466,7 @@ bool DWARFASTParserClang::ParseChildMembers(
ClangASTContext *ast =
llvm::dyn_cast_or_null<ClangASTContext>(class_clang_type.GetTypeSystem());
if (ast == nullptr)
- return 0;
+ return false;
for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
die = die.GetSibling()) {
@@ -2709,12 +2478,10 @@ bool DWARFASTParserClang::ParseChildMembers(
DWARFAttributes attributes;
const size_t num_attributes = die.GetAttributes(attributes);
if (num_attributes > 0) {
- Declaration decl;
- // DWARFExpression location;
- const char *name = NULL;
- const char *prop_name = NULL;
- const char *prop_getter_name = NULL;
- const char *prop_setter_name = NULL;
+ const char *name = nullptr;
+ const char *prop_name = nullptr;
+ const char *prop_getter_name = nullptr;
+ const char *prop_setter_name = nullptr;
uint32_t prop_attributes = 0;
bool is_artificial = false;
@@ -2722,7 +2489,7 @@ bool DWARFASTParserClang::ParseChildMembers(
AccessType accessibility = eAccessNone;
uint32_t member_byte_offset =
(parent_die.Tag() == DW_TAG_union_type) ? 0 : UINT32_MAX;
- size_t byte_size = 0;
+ llvm::Optional<uint64_t> byte_size;
int64_t bit_offset = 0;
uint64_t data_bit_offset = UINT64_MAX;
size_t bit_size = 0;
@@ -2734,16 +2501,6 @@ bool DWARFASTParserClang::ParseChildMembers(
DWARFFormValue form_value;
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
case DW_AT_name:
name = form_value.AsCString();
break;
@@ -2776,7 +2533,8 @@ bool DWARFASTParserClang::ParseChildMembers(
module_sp, debug_info_data, die.GetCU(), block_offset,
block_length, eRegisterKindDWARF, &initialValue,
nullptr, memberOffset, nullptr)) {
- member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+ member_byte_offset =
+ memberOffset.ResolveValue(nullptr).UInt();
}
} else {
// With DWARF 3 and later, if the value is an integer constant,
@@ -2865,7 +2623,7 @@ bool DWARFASTParserClang::ParseChildMembers(
// with a crash if we try to use this type in an expression when clang
// becomes unhappy with its recycled debug info.
- if (byte_size == 0 && bit_offset < 0) {
+ if (byte_size.getValueOr(0) == 0 && bit_offset < 0) {
bit_size = 0;
bit_offset = 0;
}
@@ -2877,7 +2635,7 @@ bool DWARFASTParserClang::ParseChildMembers(
// Handle static members
if (is_external && member_byte_offset == UINT32_MAX) {
- Type *var_type = die.ResolveTypeUID(DIERef(encoding_form));
+ Type *var_type = die.ResolveTypeUID(encoding_form.Reference());
if (var_type) {
if (accessibility == eAccessNone)
@@ -2890,9 +2648,9 @@ bool DWARFASTParserClang::ParseChildMembers(
}
if (!is_artificial) {
- Type *member_type = die.ResolveTypeUID(DIERef(encoding_form));
+ Type *member_type = die.ResolveTypeUID(encoding_form.Reference());
- clang::FieldDecl *field_decl = NULL;
+ clang::FieldDecl *field_decl = nullptr;
if (tag == DW_TAG_member) {
if (member_type) {
if (accessibility == eAccessNone)
@@ -2927,12 +2685,12 @@ bool DWARFASTParserClang::ParseChildMembers(
if (data_bit_offset != UINT64_MAX) {
this_field_info.bit_offset = data_bit_offset;
} else {
- if (byte_size == 0)
+ if (!byte_size)
byte_size = member_type->GetByteSize();
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
if (objfile->GetByteOrder() == eByteOrderLittle) {
- this_field_info.bit_offset += byte_size * 8;
+ this_field_info.bit_offset += byte_size.getValueOr(0) * 8;
this_field_info.bit_offset -= (bit_offset + bit_size);
} else {
this_field_info.bit_offset += bit_offset;
@@ -2945,13 +2703,12 @@ bool DWARFASTParserClang::ParseChildMembers(
ObjectFile *objfile = die.GetDWARF()->GetObjectFile();
objfile->GetModule()->ReportWarning(
"0x%8.8" PRIx64 ": %s bitfield named \"%s\" has invalid "
- "bit offset (0x%8.8" PRIx64
+ "bit offset (0x%8.8" PRIx64
") member will be ignored. Please file a bug against the "
"compiler and include the preprocessed output for %s\n",
die.GetID(), DW_TAG_value_to_name(tag), name,
this_field_info.bit_offset,
- sc.comp_unit ? sc.comp_unit->GetPath().c_str()
- : "the source file");
+ GetUnitName(parent_die).c_str());
this_field_info.Clear();
continue;
}
@@ -3074,9 +2831,10 @@ bool DWARFASTParserClang::ParseChildMembers(
member_byte_offset > parent_byte_size)) {
module_sp->ReportError(
"0x%8.8" PRIx64
- ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64
+ ": DW_TAG_member '%s' refers to type 0x%8.8x"
" which extends beyond the bounds of 0x%8.8" PRIx64,
- die.GetID(), name, encoding_form.Reference(),
+ die.GetID(), name,
+ encoding_form.Reference().GetOffset(),
parent_die.GetID());
}
@@ -3103,9 +2861,7 @@ bool DWARFASTParserClang::ParseChildMembers(
"complete definition.\nPlease file a bug against the "
"compiler and include the preprocessed output for %s",
parent_die.GetOffset(), parent_die.GetName(),
- die.GetOffset(), name,
- sc.comp_unit ? sc.comp_unit->GetPath().c_str()
- : "the source file");
+ die.GetOffset(), name, GetUnitName(parent_die).c_str());
// We have no choice other than to pretend that the member
// class is complete. If we don't do this, clang will crash
// when trying to layout the class. Since we provide layout
@@ -3139,24 +2895,23 @@ bool DWARFASTParserClang::ParseChildMembers(
if (name)
module_sp->ReportError(
"0x%8.8" PRIx64
- ": DW_TAG_member '%s' refers to type 0x%8.8" PRIx64
+ ": DW_TAG_member '%s' refers to type 0x%8.8x"
" which was unable to be parsed",
- die.GetID(), name, encoding_form.Reference());
+ die.GetID(), name, encoding_form.Reference().GetOffset());
else
module_sp->ReportError(
- "0x%8.8" PRIx64
- ": DW_TAG_member refers to type 0x%8.8" PRIx64
+ "0x%8.8" PRIx64 ": DW_TAG_member refers to type 0x%8.8x"
" which was unable to be parsed",
- die.GetID(), encoding_form.Reference());
+ die.GetID(), encoding_form.Reference().GetOffset());
}
}
- if (prop_name != NULL && member_type) {
- clang::ObjCIvarDecl *ivar_decl = NULL;
+ if (prop_name != nullptr && member_type) {
+ clang::ObjCIvarDecl *ivar_decl = nullptr;
if (field_decl) {
ivar_decl = clang::dyn_cast<clang::ObjCIvarDecl>(field_decl);
- assert(ivar_decl != NULL);
+ assert(ivar_decl != nullptr);
}
ClangASTMetadata metadata;
@@ -3177,7 +2932,7 @@ bool DWARFASTParserClang::ParseChildMembers(
case DW_TAG_subprogram:
// Let the type parsing code handle this one for us.
- member_function_dies.Append(die);
+ member_function_dies.push_back(die);
break;
case DW_TAG_inheritance: {
@@ -3188,8 +2943,6 @@ bool DWARFASTParserClang::ParseChildMembers(
DWARFAttributes attributes;
const size_t num_attributes = die.GetAttributes(attributes);
if (num_attributes > 0) {
- Declaration decl;
- DWARFExpression location(die.GetCU());
DWARFFormValue encoding_form;
AccessType accessibility = default_accessibility;
bool is_virtual = false;
@@ -3201,16 +2954,6 @@ bool DWARFASTParserClang::ParseChildMembers(
DWARFFormValue form_value;
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
case DW_AT_type:
encoding_form = form_value;
break;
@@ -3227,7 +2970,8 @@ bool DWARFASTParserClang::ParseChildMembers(
block_offset, block_length,
eRegisterKindDWARF, &initialValue,
nullptr, memberOffset, nullptr)) {
- member_byte_offset = memberOffset.ResolveValue(NULL).UInt();
+ member_byte_offset =
+ memberOffset.ResolveValue(nullptr).UInt();
}
} else {
// With DWARF 3 and later, if the value is an integer constant,
@@ -3254,14 +2998,15 @@ bool DWARFASTParserClang::ParseChildMembers(
}
}
- Type *base_class_type = die.ResolveTypeUID(DIERef(encoding_form));
- if (base_class_type == NULL) {
+ Type *base_class_type = die.ResolveTypeUID(encoding_form.Reference());
+ if (base_class_type == nullptr) {
module_sp->ReportError("0x%8.8x: DW_TAG_inheritance failed to "
- "resolve the base class at 0x%8.8" PRIx64
+ "resolve the base class at 0x%8.8x"
" from enclosing type 0x%8.8x. \nPlease file "
"a bug and attach the file at the start of "
"this error message",
- die.GetOffset(), encoding_form.Reference(),
+ die.GetOffset(),
+ encoding_form.Reference().GetOffset(),
parent_die.GetOffset());
break;
}
@@ -3313,10 +3058,9 @@ bool DWARFASTParserClang::ParseChildMembers(
}
size_t DWARFASTParserClang::ParseChildParameters(
- CompileUnit &comp_unit, clang::DeclContext *containing_decl_ctx,
- const DWARFDIE &parent_die, bool skip_artificial, bool &is_static,
- bool &is_variadic, bool &has_template_params,
- std::vector<CompilerType> &function_param_types,
+ clang::DeclContext *containing_decl_ctx, const DWARFDIE &parent_die,
+ bool skip_artificial, bool &is_static, bool &is_variadic,
+ bool &has_template_params, std::vector<CompilerType> &function_param_types,
std::vector<clang::ParmVarDecl *> &function_param_decls,
unsigned &type_quals) {
if (!parent_die)
@@ -3331,8 +3075,7 @@ size_t DWARFASTParserClang::ParseChildParameters(
DWARFAttributes attributes;
const size_t num_attributes = die.GetAttributes(attributes);
if (num_attributes > 0) {
- const char *name = NULL;
- Declaration decl;
+ const char *name = nullptr;
DWARFFormValue param_type_die_form;
bool is_artificial = false;
// one of None, Auto, Register, Extern, Static, PrivateExtern
@@ -3344,16 +3087,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
DWARFFormValue form_value;
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
switch (attr) {
- case DW_AT_decl_file:
- decl.SetFile(comp_unit.GetSupportFiles().GetFileSpecAtIndex(
- form_value.Unsigned()));
- break;
- case DW_AT_decl_line:
- decl.SetLine(form_value.Unsigned());
- break;
- case DW_AT_decl_column:
- decl.SetColumn(form_value.Unsigned());
- break;
case DW_AT_name:
name = form_value.AsCString();
break;
@@ -3388,8 +3121,9 @@ size_t DWARFASTParserClang::ParseChildParameters(
// Often times compilers omit the "this" name for the
// specification DIEs, so we can't rely upon the name being in
// the formal parameter DIE...
- (name == NULL || ::strcmp(name, "this") == 0)) {
- Type *this_type = die.ResolveTypeUID(DIERef(param_type_die_form));
+ (name == nullptr || ::strcmp(name, "this") == 0)) {
+ Type *this_type =
+ die.ResolveTypeUID(param_type_die_form.Reference());
if (this_type) {
uint32_t encoding_mask = this_type->GetEncodingMask();
if (encoding_mask & Type::eEncodingIsPointerUID) {
@@ -3406,7 +3140,7 @@ size_t DWARFASTParserClang::ParseChildParameters(
}
if (!skip) {
- Type *type = die.ResolveTypeUID(DIERef(param_type_die_form));
+ Type *type = die.ResolveTypeUID(param_type_die_form.Reference());
if (type) {
function_param_types.push_back(type->GetForwardCompilerType());
@@ -3554,7 +3288,7 @@ Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
if (attr == DW_AT_type &&
attributes.ExtractFormValueAtIndex(i, form_value))
- return dwarf->ResolveTypeUID(dwarf->GetDIE(DIERef(form_value)), true);
+ return dwarf->ResolveTypeUID(form_value.Reference(), true);
}
}
}
@@ -3799,8 +3533,11 @@ DWARFASTParserClang::ResolveNamespaceDIE(const DWARFDIE &die) {
const char *namespace_name = die.GetName();
clang::DeclContext *containing_decl_ctx =
GetClangDeclContextContainingDIE(die, nullptr);
- namespace_decl = m_ast.GetUniqueNamespaceDeclaration(namespace_name,
- containing_decl_ctx);
+ bool is_inline =
+ die.GetAttributeValueAsUnsigned(DW_AT_export_symbols, 0) != 0;
+
+ namespace_decl = m_ast.GetUniqueNamespaceDeclaration(
+ namespace_name, containing_decl_ctx, is_inline);
Log *log =
nullptr; // (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
if (log) {
@@ -3870,7 +3607,7 @@ void DWARFASTParserClang::LinkDeclContextToDIE(clang::DeclContext *decl_ctx,
bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
const DWARFDIE &src_class_die, const DWARFDIE &dst_class_die,
- lldb_private::Type *class_type, DWARFDIECollection &failures) {
+ lldb_private::Type *class_type, std::vector<DWARFDIE> &failures) {
if (!class_type || !src_class_die || !dst_class_die)
return false;
if (src_class_die.Tag() != dst_class_die.Tag())
@@ -4075,7 +3812,7 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
log->Printf("warning: couldn't find a match for 0x%8.8x",
dst_die.GetOffset());
- failures.Append(dst_die);
+ failures.push_back(dst_die);
}
}
}
@@ -4140,9 +3877,9 @@ bool DWARFASTParserClang::CopyUniqueClassMethodTypes(
"method '%s'",
dst_die.GetOffset(), dst_name_artificial.GetCString());
- failures.Append(dst_die);
+ failures.push_back(dst_die);
}
}
- return (failures.Size() != 0);
+ return !failures.empty();
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 63e058d7bf217..5b5d83d659325 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -1,9 +1,8 @@
//===-- DWARFASTParserClang.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,11 +21,12 @@
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/ClangASTImporter.h"
+#include <vector>
+
namespace lldb_private {
class CompileUnit;
}
class DWARFDebugInfoEntry;
-class DWARFDIECollection;
class SymbolFileDWARF;
class DWARFASTParserClang : public DWARFASTParser {
@@ -81,19 +81,17 @@ protected:
&template_param_infos);
bool ParseChildMembers(
- const lldb_private::SymbolContext &sc, const DWARFDIE &die,
- lldb_private::CompilerType &class_compiler_type,
+ const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type,
const lldb::LanguageType class_language,
std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
std::vector<int> &member_accessibilities,
- DWARFDIECollection &member_function_dies,
+ std::vector<DWARFDIE> &member_function_dies,
DelayedPropertyList &delayed_properties,
lldb::AccessType &default_accessibility, bool &is_a_class,
lldb_private::ClangASTImporter::LayoutInfo &layout_info);
size_t
- ParseChildParameters(lldb_private::CompileUnit &comp_unit,
- clang::DeclContext *containing_decl_ctx,
+ ParseChildParameters(clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die, bool skip_artificial,
bool &is_static, bool &is_variadic,
bool &has_template_params,
@@ -101,8 +99,7 @@ protected:
std::vector<clang::ParmVarDecl *> &function_param_decls,
unsigned &type_quals);
- size_t ParseChildEnumerators(const lldb_private::SymbolContext &sc,
- lldb_private::CompilerType &compiler_type,
+ size_t ParseChildEnumerators(lldb_private::CompilerType &compiler_type,
bool is_signed, uint32_t enumerator_byte_size,
const DWARFDIE &parent_die);
@@ -118,7 +115,7 @@ protected:
bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die,
const DWARFDIE &dst_class_die,
lldb_private::Type *class_type,
- DWARFDIECollection &failures);
+ std::vector<DWARFDIE> &failures);
clang::DeclContext *GetCachedClangDeclContextForDIE(const DWARFDIE &die);
@@ -128,10 +125,8 @@ protected:
lldb::TypeSP ParseTypeFromDWO(const DWARFDIE &die, lldb_private::Log *log);
- //----------------------------------------------------------------------
// Return true if this type is a declaration to a type in an external
// module.
- //----------------------------------------------------------------------
lldb::ModuleSP GetModuleForType(const DWARFDIE &die);
typedef llvm::SmallPtrSet<const DWARFDebugInfoEntry *, 4> DIEPointerSet;
@@ -150,7 +145,7 @@ protected:
DeclToDIEMap m_decl_to_die;
DIEToDeclContextMap m_die_to_decl_ctx;
DeclContextToDIEMap m_decl_ctx_to_die;
- std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_ap;
+ std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_up;
};
#endif // SymbolFileDWARF_DWARFASTParserClang_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
index d78b9ab10f5a9..6128163a29269 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.cpp
@@ -1,9 +1,8 @@
//===-- DWARFAbbreviationDeclaration.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,8 @@
#include "lldb/Core/dwarf.h"
#include "lldb/Utility/Stream.h"
+#include "llvm/Object/Error.h"
+
#include "DWARFFormValue.h"
using namespace lldb_private;
@@ -24,57 +25,46 @@ DWARFAbbreviationDeclaration::DWARFAbbreviationDeclaration(dw_tag_t tag,
: m_code(InvalidCode), m_tag(tag), m_has_children(has_children),
m_attributes() {}
-bool DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr) {
- return Extract(data, offset_ptr, data.GetULEB128(offset_ptr));
-}
+llvm::Expected<DWARFEnumState>
+DWARFAbbreviationDeclaration::extract(const DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr) {
+ m_code = data.GetULEB128(offset_ptr);
+ if (m_code == 0)
+ return DWARFEnumState::Complete;
-bool DWARFAbbreviationDeclaration::Extract(const DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr,
- dw_uleb128_t code) {
- m_code = code;
m_attributes.clear();
- if (m_code) {
- m_tag = data.GetULEB128(offset_ptr);
- m_has_children = data.GetU8(offset_ptr);
-
- while (data.ValidOffset(*offset_ptr)) {
- dw_attr_t attr = data.GetULEB128(offset_ptr);
- dw_form_t form = data.GetULEB128(offset_ptr);
- DWARFFormValue::ValueType val;
-
- if (form == DW_FORM_implicit_const)
- val.value.sval = data.GetULEB128(offset_ptr);
-
- if (attr && form)
- m_attributes.push_back(DWARFAttribute(attr, form, val));
- else
- break;
- }
-
- return m_tag != 0;
- } else {
- m_tag = 0;
- m_has_children = 0;
- }
+ m_tag = data.GetULEB128(offset_ptr);
+ if (m_tag == DW_TAG_null)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "abbrev decl requires non-null tag.");
- return false;
-}
+ m_has_children = data.GetU8(offset_ptr);
-void DWARFAbbreviationDeclaration::Dump(Stream *s) const {
- s->Printf("Debug Abbreviation Declaration: code = 0x%4.4x, tag = %s, "
- "has_children = %s\n",
- m_code, DW_TAG_value_to_name(m_tag),
- DW_CHILDREN_value_to_name(m_has_children));
+ while (data.ValidOffset(*offset_ptr)) {
+ dw_attr_t attr = data.GetULEB128(offset_ptr);
+ dw_form_t form = data.GetULEB128(offset_ptr);
- DWARFAttribute::const_iterator pos;
+ // This is the last attribute for this abbrev decl, but there may still be
+ // more abbrev decls, so return MoreItems to indicate to the caller that
+ // they should call this function again.
+ if (!attr && !form)
+ return DWARFEnumState::MoreItems;
- for (pos = m_attributes.begin(); pos != m_attributes.end(); ++pos)
- s->Printf(" attr = %s, form = %s\n",
- DW_AT_value_to_name(pos->get_attr()),
- DW_FORM_value_to_name(pos->get_form()));
+ if (!attr || !form)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "malformed abbreviation declaration attribute");
+
+ DWARFFormValue::ValueType val;
+
+ if (form == DW_FORM_implicit_const)
+ val.value.sval = data.GetULEB128(offset_ptr);
+
+ m_attributes.push_back(DWARFAttribute(attr, form, val));
+ }
- s->Printf("\n");
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "abbreviation declaration attribute list not terminated with a null "
+ "entry");
}
bool DWARFAbbreviationDeclaration::IsValid() {
@@ -95,5 +85,5 @@ DWARFAbbreviationDeclaration::FindAttributeIndex(dw_attr_t attr) const {
bool DWARFAbbreviationDeclaration::
operator==(const DWARFAbbreviationDeclaration &rhs) const {
return Tag() == rhs.Tag() && HasChildren() == rhs.HasChildren() &&
- Attributes() == rhs.Attributes();
+ m_attributes == rhs.m_attributes;
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
index afce52558f457..c0cf8823a3685 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h
@@ -1,9 +1,8 @@
//===-- DWARFAbbreviationDeclaration.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,9 @@
#define liblldb_DWARFAbbreviationDeclaration_h_
#include "DWARFAttribute.h"
+#include "DWARFDefines.h"
#include "SymbolFileDWARF.h"
+#include "llvm/Support/Error.h"
class DWARFAbbreviationDeclaration {
public:
@@ -20,18 +21,12 @@ public:
// For hand crafting an abbreviation declaration
DWARFAbbreviationDeclaration(dw_tag_t tag, uint8_t has_children);
- void AddAttribute(const DWARFAttribute &attr) {
- m_attributes.push_back(attr);
- }
dw_uleb128_t Code() const { return m_code; }
void SetCode(dw_uleb128_t code) { m_code = code; }
dw_tag_t Tag() const { return m_tag; }
bool HasChildren() const { return m_has_children; }
size_t NumAttributes() const { return m_attributes.size(); }
- dw_attr_t GetAttrByIndex(uint32_t idx) const {
- return m_attributes.size() > idx ? m_attributes[idx].get_attr() : 0;
- }
dw_form_t GetFormByIndex(uint32_t idx) const {
return m_attributes.size() > idx ? m_attributes[idx].get_form() : 0;
}
@@ -45,14 +40,20 @@ public:
return m_attributes[idx].get_form();
}
uint32_t FindAttributeIndex(dw_attr_t attr) const;
- bool Extract(const lldb_private::DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr);
- bool Extract(const lldb_private::DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr, dw_uleb128_t code);
+
+ /// Extract one abbreviation declaration and all of its associated attributes.
+ /// Possible return values:
+ /// DWARFEnumState::Complete - the extraction completed successfully. This
+ /// was the last abbrev decl in a sequence, and the user should not call
+ /// this function again.
+ /// DWARFEnumState::MoreItems - the extraction completed successfully. The
+ /// user should call this function again to retrieve the next decl.
+ /// llvm::Error - A parsing error occurred. The debug info is malformed.
+ llvm::Expected<lldb_private::DWARFEnumState>
+ extract(const lldb_private::DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr);
bool IsValid();
- void Dump(lldb_private::Stream *s) const;
bool operator==(const DWARFAbbreviationDeclaration &rhs) const;
- const DWARFAttribute::collection &Attributes() const { return m_attributes; }
protected:
dw_uleb128_t m_code;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
index dd830eb7b9dd6..b3594a455680e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
@@ -1,9 +1,8 @@
//===-- DWARFAttribute.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,41 +32,27 @@ void DWARFAttributes::Append(const DWARFUnit *cu, dw_offset_t attr_die_offset,
m_infos.push_back(attr_value);
}
-bool DWARFAttributes::ContainsAttribute(dw_attr_t attr) const {
- return FindAttributeIndex(attr) != UINT32_MAX;
-}
-
-bool DWARFAttributes::RemoveAttribute(dw_attr_t attr) {
- uint32_t attr_index = FindAttributeIndex(attr);
- if (attr_index != UINT32_MAX) {
- m_infos.erase(m_infos.begin() + attr_index);
- return true;
- }
- return false;
-}
-
bool DWARFAttributes::ExtractFormValueAtIndex(
uint32_t i, DWARFFormValue &form_value) const {
const DWARFUnit *cu = CompileUnitAtIndex(i);
- form_value.SetCompileUnit(cu);
+ form_value.SetUnit(cu);
form_value.SetForm(FormAtIndex(i));
lldb::offset_t offset = DIEOffsetAtIndex(i);
return form_value.ExtractValue(cu->GetData(), &offset);
}
-uint64_t DWARFAttributes::FormValueAsUnsigned(dw_attr_t attr,
- uint64_t fail_value) const {
+DWARFDIE
+DWARFAttributes::FormValueAsReference(dw_attr_t attr) const {
const uint32_t attr_idx = FindAttributeIndex(attr);
if (attr_idx != UINT32_MAX)
- return FormValueAsUnsignedAtIndex(attr_idx, fail_value);
- return fail_value;
+ return FormValueAsReferenceAtIndex(attr_idx);
+ return {};
}
-uint64_t
-DWARFAttributes::FormValueAsUnsignedAtIndex(uint32_t i,
- uint64_t fail_value) const {
+DWARFDIE
+DWARFAttributes::FormValueAsReferenceAtIndex(uint32_t i) const {
DWARFFormValue form_value;
if (ExtractFormValueAtIndex(i, form_value))
return form_value.Reference();
- return fail_value;
+ return {};
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
index 2399861d7fc3f..58427b19100a5 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
@@ -1,9 +1,8 @@
//===-- DWARFAttribute.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,8 +26,6 @@ public:
m_attr = attr;
m_form = form;
}
- void set_attr(dw_attr_t attr) { m_attr = attr; }
- void set_form(dw_form_t form) { m_form = form; }
dw_attr_t get_attr() const { return m_attr; }
dw_form_t get_form() const { return m_form; }
void get(dw_attr_t &attr, dw_form_t &form,
@@ -68,11 +65,9 @@ public:
}
dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].attr.get_form(); }
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const;
- uint64_t FormValueAsUnsignedAtIndex(uint32_t i, uint64_t fail_value) const;
- uint64_t FormValueAsUnsigned(dw_attr_t attr, uint64_t fail_value) const;
+ DWARFDIE FormValueAsReferenceAtIndex(uint32_t i) const;
+ DWARFDIE FormValueAsReference(dw_attr_t attr) const;
uint32_t FindAttributeIndex(dw_attr_t attr) const;
- bool ContainsAttribute(dw_attr_t attr) const;
- bool RemoveAttribute(dw_attr_t attr);
void Clear() { m_infos.clear(); }
size_t Size() const { return m_infos.size(); }
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
index 077de9604f1d5..96adb72c95322 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
@@ -1,9 +1,8 @@
//===-- DWARFBaseDIE.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,14 +17,12 @@
using namespace lldb_private;
-DIERef DWARFBaseDIE::GetDIERef() const {
+llvm::Optional<DIERef> DWARFBaseDIE::GetDIERef() const {
if (!IsValid())
- return DIERef();
+ return llvm::None;
- dw_offset_t cu_offset = m_cu->GetOffset();
- if (m_cu->GetBaseObjOffset() != DW_INVALID_OFFSET)
- cu_offset = m_cu->GetBaseObjOffset();
- return DIERef(cu_offset, m_die->GetOffset());
+ return DIERef(m_cu->GetSymbolFileDWARF().GetDwoNum(), m_cu->GetDebugSection(),
+ m_die->GetOffset());
}
dw_tag_t DWARFBaseDIE::Tag() const {
@@ -42,8 +39,7 @@ const char *DWARFBaseDIE::GetTagAsCString() const {
const char *DWARFBaseDIE::GetAttributeValueAsString(const dw_attr_t attr,
const char *fail_value) const {
if (IsValid())
- return m_die->GetAttributeValueAsString(GetDWARF(), GetCU(), attr,
- fail_value);
+ return m_die->GetAttributeValueAsString(GetCU(), attr, fail_value);
else
return fail_value;
}
@@ -51,26 +47,7 @@ const char *DWARFBaseDIE::GetAttributeValueAsString(const dw_attr_t attr,
uint64_t DWARFBaseDIE::GetAttributeValueAsUnsigned(const dw_attr_t attr,
uint64_t fail_value) const {
if (IsValid())
- return m_die->GetAttributeValueAsUnsigned(GetDWARF(), GetCU(), attr,
- fail_value);
- else
- return fail_value;
-}
-
-int64_t DWARFBaseDIE::GetAttributeValueAsSigned(const dw_attr_t attr,
- int64_t fail_value) const {
- if (IsValid())
- return m_die->GetAttributeValueAsSigned(GetDWARF(), GetCU(), attr,
- fail_value);
- else
- return fail_value;
-}
-
-uint64_t DWARFBaseDIE::GetAttributeValueAsReference(const dw_attr_t attr,
- uint64_t fail_value) const {
- if (IsValid())
- return m_die->GetAttributeValueAsReference(GetDWARF(), GetCU(), attr,
- fail_value);
+ return m_die->GetAttributeValueAsUnsigned(GetCU(), attr, fail_value);
else
return fail_value;
}
@@ -78,19 +55,20 @@ uint64_t DWARFBaseDIE::GetAttributeValueAsReference(const dw_attr_t attr,
uint64_t DWARFBaseDIE::GetAttributeValueAsAddress(const dw_attr_t attr,
uint64_t fail_value) const {
if (IsValid())
- return m_die->GetAttributeValueAsAddress(GetDWARF(), GetCU(), attr,
- fail_value);
+ return m_die->GetAttributeValueAsAddress(GetCU(), attr, fail_value);
else
return fail_value;
}
lldb::user_id_t DWARFBaseDIE::GetID() const {
- return GetDIERef().GetUID(GetDWARF());
+ if (IsValid())
+ return GetDWARF()->GetUID(*this);
+ return LLDB_INVALID_UID;
}
const char *DWARFBaseDIE::GetName() const {
if (IsValid())
- return m_die->GetName(GetDWARF(), m_cu);
+ return m_die->GetName(m_cu);
else
return nullptr;
}
@@ -110,13 +88,6 @@ lldb::ModuleSP DWARFBaseDIE::GetModule() const {
return lldb::ModuleSP();
}
-lldb_private::CompileUnit *DWARFBaseDIE::GetLLDBCompileUnit() const {
- if (IsValid())
- return GetDWARF()->GetCompUnitForDWARFCompUnit(GetCU());
- else
- return nullptr;
-}
-
dw_offset_t DWARFBaseDIE::GetOffset() const {
if (IsValid())
return m_die->GetOffset();
@@ -124,16 +95,9 @@ dw_offset_t DWARFBaseDIE::GetOffset() const {
return DW_INVALID_OFFSET;
}
-dw_offset_t DWARFBaseDIE::GetCompileUnitRelativeOffset() const {
- if (IsValid())
- return m_die->GetOffset() - m_cu->GetOffset();
- else
- return DW_INVALID_OFFSET;
-}
-
SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const {
if (m_cu)
- return m_cu->GetSymbolFileDWARF();
+ return &m_cu->GetSymbolFileDWARF();
else
return nullptr;
}
@@ -163,21 +127,13 @@ bool DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type() const {
size_t DWARFBaseDIE::GetAttributes(DWARFAttributes &attributes,
uint32_t depth) const {
- if (IsValid()) {
- return m_die->GetAttributes(m_cu, m_cu->GetFixedFormSizes(), attributes,
- depth);
- }
+ if (IsValid())
+ return m_die->GetAttributes(m_cu, attributes, depth);
if (depth == 0)
attributes.Clear();
return 0;
}
-void DWARFBaseDIE::Dump(lldb_private::Stream *s,
- const uint32_t recurse_depth) const {
- if (s && IsValid())
- m_die->Dump(GetDWARF(), GetCU(), *s, recurse_depth);
-}
-
bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) {
return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU();
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
index 2163a027ffbcc..0058043017cdb 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
@@ -1,9 +1,8 @@
//===-- DWARFBaseDIE.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,13 +12,12 @@
#include "lldb/Core/dwarf.h"
#include "lldb/lldb-types.h"
-struct DIERef;
+class DIERef;
class DWARFASTParser;
class DWARFAttributes;
class DWARFUnit;
class DWARFDebugInfoEntry;
class DWARFDeclContext;
-class DWARFDIECollection;
class SymbolFileDWARF;
class DWARFBaseDIE {
@@ -39,9 +37,7 @@ public:
: m_cu(const_cast<DWARFUnit *>(cu)),
m_die(const_cast<DWARFDebugInfoEntry *>(die)) {}
- //----------------------------------------------------------------------
// Tests
- //----------------------------------------------------------------------
explicit operator bool() const { return IsValid(); }
bool IsValid() const { return m_cu && m_die; }
@@ -50,16 +46,14 @@ public:
bool Supports_DW_AT_APPLE_objc_complete_type() const;
- //----------------------------------------------------------------------
// Accessors
- //----------------------------------------------------------------------
SymbolFileDWARF *GetDWARF() const;
DWARFUnit *GetCU() const { return m_cu; }
DWARFDebugInfoEntry *GetDIE() const { return m_die; }
- DIERef GetDIERef() const;
+ llvm::Optional<DIERef> GetDIERef() const;
lldb_private::TypeSystem *GetTypeSystem() const;
@@ -79,33 +73,25 @@ public:
m_die = nullptr;
}
- //----------------------------------------------------------------------
// Get the data that contains the attribute values for this DIE. Support
// for .debug_types means that any DIE can have its data either in the
// .debug_info or the .debug_types section; this method will return the
// correct section data.
//
// Clients must validate that this object is valid before calling this.
- //----------------------------------------------------------------------
const lldb_private::DWARFDataExtractor &GetData() const;
- //----------------------------------------------------------------------
// Accessing information about a DIE
- //----------------------------------------------------------------------
dw_tag_t Tag() const;
const char *GetTagAsCString() const;
dw_offset_t GetOffset() const;
- dw_offset_t GetCompileUnitRelativeOffset() const;
-
- //----------------------------------------------------------------------
// Get the LLDB user ID for this DIE. This is often just the DIE offset,
// but it might have a SymbolFileDWARF::GetID() in the high 32 bits if
// we are doing Darwin DWARF in .o file, or DWARF stand alone debug
// info.
- //----------------------------------------------------------------------
lldb::user_id_t GetID() const;
const char *GetName() const;
@@ -114,38 +100,22 @@ public:
lldb::ModuleSP GetModule() const;
- lldb_private::CompileUnit *GetLLDBCompileUnit() const;
-
- //----------------------------------------------------------------------
// Getting attribute values from the DIE.
//
// GetAttributeValueAsXXX() functions should only be used if you are
// looking for one or two attributes on a DIE. If you are trying to
// parse all attributes, use GetAttributes (...) instead
- //----------------------------------------------------------------------
const char *GetAttributeValueAsString(const dw_attr_t attr,
const char *fail_value) const;
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr,
uint64_t fail_value) const;
- int64_t GetAttributeValueAsSigned(const dw_attr_t attr,
- int64_t fail_value) const;
-
- uint64_t GetAttributeValueAsReference(const dw_attr_t attr,
- uint64_t fail_value) const;
-
uint64_t GetAttributeValueAsAddress(const dw_attr_t attr,
uint64_t fail_value) const;
size_t GetAttributes(DWARFAttributes &attributes, uint32_t depth = 0) const;
- //----------------------------------------------------------------------
- // Pretty printing
- //----------------------------------------------------------------------
-
- void Dump(lldb_private::Stream *s, const uint32_t recurse_depth) const;
-
protected:
DWARFUnit *m_cu;
DWARFDebugInfoEntry *m_die;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index b9a7231286e3c..718f0537d6edd 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -1,98 +1,115 @@
//===-- DWARFCompileUnit.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFCompileUnit.h"
+#include "DWARFDebugAranges.h"
+#include "SymbolFileDWARFDebugMap.h"
-#include "SymbolFileDWARF.h"
+#include "lldb/Symbol/CompileUnit.h"
+#include "lldb/Symbol/LineTable.h"
#include "lldb/Utility/Stream.h"
using namespace lldb;
using namespace lldb_private;
-extern int g_verbose;
-
-DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF *dwarf2Data)
- : DWARFUnit(dwarf2Data) {}
-
-DWARFUnitSP DWARFCompileUnit::Extract(SymbolFileDWARF *dwarf2Data,
- const DWARFDataExtractor &debug_info,
- lldb::offset_t *offset_ptr) {
- // std::make_shared would require the ctor to be public.
- std::shared_ptr<DWARFCompileUnit> cu_sp(new DWARFCompileUnit(dwarf2Data));
-
- cu_sp->m_offset = *offset_ptr;
-
- if (debug_info.ValidOffset(*offset_ptr)) {
- dw_offset_t abbr_offset;
- const DWARFDebugAbbrev *abbr = dwarf2Data->DebugAbbrev();
- cu_sp->m_length = debug_info.GetDWARFInitialLength(offset_ptr);
- cu_sp->m_is_dwarf64 = debug_info.IsDWARF64();
- cu_sp->m_version = debug_info.GetU16(offset_ptr);
-
- if (cu_sp->m_version == 5) {
- cu_sp->m_unit_type = debug_info.GetU8(offset_ptr);
- cu_sp->m_addr_size = debug_info.GetU8(offset_ptr);
- abbr_offset = debug_info.GetDWARFOffset(offset_ptr);
-
- if (cu_sp->m_unit_type == llvm::dwarf::DW_UT_skeleton)
- cu_sp->m_dwo_id = debug_info.GetU64(offset_ptr);
- } else {
- abbr_offset = debug_info.GetDWARFOffset(offset_ptr);
- cu_sp->m_addr_size = debug_info.GetU8(offset_ptr);
- }
-
- bool length_OK =
- debug_info.ValidOffset(cu_sp->GetNextCompileUnitOffset() - 1);
- bool version_OK = SymbolFileDWARF::SupportedVersion(cu_sp->m_version);
- bool abbr_offset_OK =
- dwarf2Data->get_debug_abbrev_data().ValidOffset(abbr_offset);
- bool addr_size_OK = (cu_sp->m_addr_size == 4) || (cu_sp->m_addr_size == 8);
-
- if (length_OK && version_OK && addr_size_OK && abbr_offset_OK &&
- abbr != NULL) {
- cu_sp->m_abbrevs = abbr->GetAbbreviationDeclarationSet(abbr_offset);
- return cu_sp;
- }
-
- // reset the offset to where we tried to parse from if anything went wrong
- *offset_ptr = cu_sp->m_offset;
- }
-
- return nullptr;
-}
-
void DWARFCompileUnit::Dump(Stream *s) const {
s->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, "
"abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
"{0x%8.8x})\n",
- m_offset, m_length, m_version, GetAbbrevOffset(), m_addr_size,
- GetNextCompileUnitOffset());
+ GetOffset(), GetLength(), GetVersion(), GetAbbrevOffset(),
+ GetAddressByteSize(), GetNextUnitOffset());
}
-uint32_t DWARFCompileUnit::GetHeaderByteSize() const {
- if (m_version < 5)
- return m_is_dwarf64 ? 23 : 11;
-
- switch (m_unit_type) {
- case llvm::dwarf::DW_UT_compile:
- case llvm::dwarf::DW_UT_partial:
- return 12;
- case llvm::dwarf::DW_UT_skeleton:
- case llvm::dwarf::DW_UT_split_compile:
- return 20;
- case llvm::dwarf::DW_UT_type:
- case llvm::dwarf::DW_UT_split_type:
- return 24;
+void DWARFCompileUnit::BuildAddressRangeTable(
+ DWARFDebugAranges *debug_aranges) {
+ // This function is usually called if there in no .debug_aranges section in
+ // order to produce a compile unit level set of address ranges that is
+ // accurate.
+
+ size_t num_debug_aranges = debug_aranges->GetNumRanges();
+
+ // First get the compile unit DIE only and check if it has a DW_AT_ranges
+ const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
+
+ const dw_offset_t cu_offset = GetOffset();
+ if (die) {
+ DWARFRangeList ranges;
+ const size_t num_ranges =
+ die->GetAttributeAddressRanges(this, ranges, false);
+ if (num_ranges > 0) {
+ // This compile unit has DW_AT_ranges, assume this is correct if it is
+ // present since clang no longer makes .debug_aranges by default and it
+ // emits DW_AT_ranges for DW_TAG_compile_units. GCC also does this with
+ // recent GCC builds.
+ for (size_t i = 0; i < num_ranges; ++i) {
+ const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
+ debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
+ range.GetRangeEnd());
+ }
+
+ return; // We got all of our ranges from the DW_AT_ranges attribute
+ }
+ }
+ // We don't have a DW_AT_ranges attribute, so we need to parse the DWARF
+
+ // If the DIEs weren't parsed, then we don't want all dies for all compile
+ // units to stay loaded when they weren't needed. So we can end up parsing
+ // the DWARF and then throwing them all away to keep memory usage down.
+ ScopedExtractDIEs clear_dies(ExtractDIEsScoped());
+
+ die = DIEPtr();
+ if (die)
+ die->BuildAddressRangeTable(this, debug_aranges);
+
+ if (debug_aranges->GetNumRanges() == num_debug_aranges) {
+ // We got nothing from the functions, maybe we have a line tables only
+ // situation. Check the line tables and build the arange table from this.
+ SymbolContext sc;
+ sc.comp_unit = m_dwarf.GetCompUnitForDWARFCompUnit(*this);
+ if (sc.comp_unit) {
+ SymbolFileDWARFDebugMap *debug_map_sym_file =
+ m_dwarf.GetDebugMapSymfile();
+ if (debug_map_sym_file == nullptr) {
+ if (LineTable *line_table = sc.comp_unit->GetLineTable()) {
+ LineTable::FileAddressRanges file_ranges;
+ const bool append = true;
+ const size_t num_ranges =
+ line_table->GetContiguousFileAddressRanges(file_ranges, append);
+ for (uint32_t idx = 0; idx < num_ranges; ++idx) {
+ const LineTable::FileAddressRanges::Entry &range =
+ file_ranges.GetEntryRef(idx);
+ debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
+ range.GetRangeEnd());
+ }
+ }
+ } else
+ debug_map_sym_file->AddOSOARanges(&m_dwarf, debug_aranges);
+ }
}
- llvm_unreachable("invalid UnitType.");
-}
-const lldb_private::DWARFDataExtractor &DWARFCompileUnit::GetData() const {
- return m_dwarf->get_debug_info_data();
+ if (debug_aranges->GetNumRanges() == num_debug_aranges) {
+ // We got nothing from the functions, maybe we have a line tables only
+ // situation. Check the line tables and build the arange table from this.
+ SymbolContext sc;
+ sc.comp_unit = m_dwarf.GetCompUnitForDWARFCompUnit(*this);
+ if (sc.comp_unit) {
+ if (LineTable *line_table = sc.comp_unit->GetLineTable()) {
+ LineTable::FileAddressRanges file_ranges;
+ const bool append = true;
+ const size_t num_ranges =
+ line_table->GetContiguousFileAddressRanges(file_ranges, append);
+ for (uint32_t idx = 0; idx < num_ranges; ++idx) {
+ const LineTable::FileAddressRanges::Entry &range =
+ file_ranges.GetEntryRef(idx);
+ debug_aranges->AppendRange(GetOffset(), range.GetRangeBase(),
+ range.GetRangeEnd());
+ }
+ }
+ }
+ }
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index b92a155e0335e..75647dbb082f2 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -1,9 +1,8 @@
//===-- DWARFCompileUnit.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,35 +10,26 @@
#define SymbolFileDWARF_DWARFCompileUnit_h_
#include "DWARFUnit.h"
+#include "llvm/Support/Error.h"
class DWARFCompileUnit : public DWARFUnit {
public:
- static DWARFUnitSP Extract(SymbolFileDWARF *dwarf2Data,
- const lldb_private::DWARFDataExtractor &debug_info,
- lldb::offset_t *offset_ptr);
+ void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) override;
+
void Dump(lldb_private::Stream *s) const override;
- //------------------------------------------------------------------
- /// Get the data that contains the DIE information for this unit.
- ///
- /// @return
- /// The correct data (.debug_types for DWARF 4 and earlier, and
- /// .debug_info for DWARF 5 and later) for the DIE information in
- /// this unit.
- //------------------------------------------------------------------
- const lldb_private::DWARFDataExtractor &GetData() const override;
-
- //------------------------------------------------------------------
- /// Get the size in bytes of the header.
- ///
- /// @return
- /// Byte size of the compile unit header
- //------------------------------------------------------------------
- uint32_t GetHeaderByteSize() const override;
+ static bool classof(const DWARFUnit *unit) { return !unit->IsTypeUnit(); }
private:
- DWARFCompileUnit(SymbolFileDWARF *dwarf2Data);
+ DWARFCompileUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
+ const DWARFUnitHeader &header,
+ const DWARFAbbreviationDeclarationSet &abbrevs,
+ DIERef::Section section)
+ : DWARFUnit(dwarf, uid, header, abbrevs, section) {}
+
DISALLOW_COPY_AND_ASSIGN(DWARFCompileUnit);
+
+ friend class DWARFUnit;
};
#endif // SymbolFileDWARF_DWARFCompileUnit_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
new file mode 100644
index 0000000000000..eb307ce1cce1b
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -0,0 +1,138 @@
+//===-- DWARFContext.cpp ----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFContext.h"
+
+#include "lldb/Core/Section.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static DWARFDataExtractor LoadSection(SectionList *section_list,
+ SectionType section_type) {
+ if (!section_list)
+ return DWARFDataExtractor();
+
+ auto section_sp = section_list->FindSectionByType(section_type, true);
+ if (!section_sp)
+ return DWARFDataExtractor();
+
+ DWARFDataExtractor data;
+ section_sp->GetSectionData(data);
+ return data;
+}
+
+const DWARFDataExtractor &
+DWARFContext::LoadOrGetSection(SectionType main_section_type,
+ llvm::Optional<SectionType> dwo_section_type,
+ SectionData &data) {
+ llvm::call_once(data.flag, [&] {
+ if (dwo_section_type && isDwo())
+ data.data = LoadSection(m_dwo_section_list, *dwo_section_type);
+ else
+ data.data = LoadSection(m_main_section_list, main_section_type);
+ });
+ return data.data;
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadAbbrevData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugAbbrev,
+ eSectionTypeDWARFDebugAbbrevDwo, m_data_debug_abbrev);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadArangesData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugAranges, llvm::None,
+ m_data_debug_aranges);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadAddrData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugAddr, llvm::None,
+ m_data_debug_addr);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadDebugInfoData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugInfo,
+ eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadLineData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugLine, llvm::None,
+ m_data_debug_line);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadLineStrData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugLineStr, llvm::None,
+ m_data_debug_line_str);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadMacroData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugMacro, llvm::None,
+ m_data_debug_macro);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadRangesData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugRanges, llvm::None,
+ m_data_debug_ranges);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadRngListsData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugRngLists, llvm::None,
+ m_data_debug_rnglists);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadStrData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugStr,
+ eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadStrOffsetsData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugStrOffsets,
+ eSectionTypeDWARFDebugStrOffsetsDwo,
+ m_data_debug_str_offsets);
+}
+
+const DWARFDataExtractor &DWARFContext::getOrLoadDebugTypesData() {
+ return LoadOrGetSection(eSectionTypeDWARFDebugTypes,
+ eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
+}
+
+llvm::DWARFContext &DWARFContext::GetAsLLVM() {
+ if (!m_llvm_context) {
+ llvm::StringMap<std::unique_ptr<llvm::MemoryBuffer>> section_map;
+ uint8_t addr_size = 0;
+
+ auto AddSection = [&](Section &section) {
+ DataExtractor section_data;
+ section.GetSectionData(section_data);
+
+ // Set the address size the first time we see it.
+ if (addr_size == 0)
+ addr_size = section_data.GetByteSize();
+
+ llvm::StringRef data = llvm::toStringRef(section_data.GetData());
+ llvm::StringRef name = section.GetName().GetStringRef();
+ if (name.startswith("."))
+ name = name.drop_front();
+ section_map.try_emplace(
+ name, llvm::MemoryBuffer::getMemBuffer(data, name, false));
+ };
+
+ if (m_main_section_list) {
+ for (auto &section : *m_main_section_list)
+ AddSection(*section);
+ }
+
+ if (m_dwo_section_list) {
+ for (auto &section : *m_dwo_section_list)
+ AddSection(*section);
+ }
+
+ m_llvm_context = llvm::DWARFContext::create(section_map, addr_size);
+ }
+ return *m_llvm_context;
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFContext.h b/source/Plugins/SymbolFile/DWARF/DWARFContext.h
new file mode 100644
index 0000000000000..add0423840397
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -0,0 +1,74 @@
+//===-- DWARFContext.h ------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
+#define LLDB_PLUGINS_SYMBOLFILE_DWARF_DWARFCONTEXT_H
+
+#include "DWARFDataExtractor.h"
+#include "lldb/Core/Section.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/Support/Threading.h"
+#include <memory>
+
+namespace lldb_private {
+class DWARFContext {
+private:
+ SectionList *m_main_section_list;
+ SectionList *m_dwo_section_list;
+ mutable std::unique_ptr<llvm::DWARFContext> m_llvm_context;
+
+ struct SectionData {
+ llvm::once_flag flag;
+ DWARFDataExtractor data;
+ };
+
+ SectionData m_data_debug_abbrev;
+ SectionData m_data_debug_addr;
+ SectionData m_data_debug_aranges;
+ SectionData m_data_debug_info;
+ SectionData m_data_debug_line;
+ SectionData m_data_debug_line_str;
+ SectionData m_data_debug_macro;
+ SectionData m_data_debug_ranges;
+ SectionData m_data_debug_rnglists;
+ SectionData m_data_debug_str;
+ SectionData m_data_debug_str_offsets;
+ SectionData m_data_debug_types;
+
+ bool isDwo() { return m_dwo_section_list != nullptr; }
+
+ const DWARFDataExtractor &
+ LoadOrGetSection(lldb::SectionType main_section_type,
+ llvm::Optional<lldb::SectionType> dwo_section_type,
+ SectionData &data);
+
+public:
+ explicit DWARFContext(SectionList *main_section_list,
+ SectionList *dwo_section_list)
+ : m_main_section_list(main_section_list),
+ m_dwo_section_list(dwo_section_list) {}
+
+ const DWARFDataExtractor &getOrLoadAbbrevData();
+ const DWARFDataExtractor &getOrLoadAddrData();
+ const DWARFDataExtractor &getOrLoadArangesData();
+ const DWARFDataExtractor &getOrLoadDebugInfoData();
+ const DWARFDataExtractor &getOrLoadLineData();
+ const DWARFDataExtractor &getOrLoadLineStrData();
+ const DWARFDataExtractor &getOrLoadMacroData();
+ const DWARFDataExtractor &getOrLoadRangesData();
+ const DWARFDataExtractor &getOrLoadRngListsData();
+ const DWARFDataExtractor &getOrLoadStrData();
+ const DWARFDataExtractor &getOrLoadStrOffsetsData();
+ const DWARFDataExtractor &getOrLoadDebugTypesData();
+
+ llvm::DWARFContext &GetAsLLVM();
+};
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 22b70b2d6852b..9d97ca15a2529 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -1,16 +1,14 @@
//===-- DWARFDIE.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFDIE.h"
#include "DWARFASTParser.h"
-#include "DWARFDIECollection.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugInfoEntry.h"
#include "DWARFDeclContext.h"
@@ -18,20 +16,75 @@
using namespace lldb_private;
-void DWARFDIE::ElaboratingDIEIterator::Next() {
- assert(!m_worklist.empty() && "Incrementing end iterator?");
+namespace {
+
+/// Iterate through all DIEs elaborating (i.e. reachable by a chain of
+/// DW_AT_specification and DW_AT_abstract_origin attributes) a given DIE. For
+/// convenience, the starting die is included in the sequence as the first
+/// item.
+class ElaboratingDIEIterator
+ : public std::iterator<std::input_iterator_tag, DWARFDIE> {
+
+ // The operating invariant is: top of m_worklist contains the "current" item
+ // and the rest of the list are items yet to be visited. An empty worklist
+ // means we've reached the end.
+ // Infinite recursion is prevented by maintaining a list of seen DIEs.
+ // Container sizes are optimized for the case of following DW_AT_specification
+ // and DW_AT_abstract_origin just once.
+ llvm::SmallVector<DWARFDIE, 2> m_worklist;
+ llvm::SmallSet<lldb::user_id_t, 3> m_seen;
+
+ void Next() {
+ assert(!m_worklist.empty() && "Incrementing end iterator?");
+
+ // Pop the current item from the list.
+ DWARFDIE die = m_worklist.back();
+ m_worklist.pop_back();
+
+ // And add back any items that elaborate it.
+ for (dw_attr_t attr : {DW_AT_specification, DW_AT_abstract_origin}) {
+ if (DWARFDIE d = die.GetReferencedDIE(attr))
+ if (m_seen.insert(die.GetID()).second)
+ m_worklist.push_back(d);
+ }
+ }
- // Pop the current item from the list.
- DWARFDIE die = m_worklist.back();
- m_worklist.pop_back();
+public:
+ /// An iterator starting at die d.
+ explicit ElaboratingDIEIterator(DWARFDIE d) : m_worklist(1, d) {}
- // And add back any items that elaborate it.
- for (dw_attr_t attr : {DW_AT_specification, DW_AT_abstract_origin}) {
- if (DWARFDIE d = die.GetReferencedDIE(attr))
- if (m_seen.insert(die.GetID()).second)
- m_worklist.push_back(d);
+ /// End marker
+ ElaboratingDIEIterator() {}
+
+ const DWARFDIE &operator*() const { return m_worklist.back(); }
+ ElaboratingDIEIterator &operator++() {
+ Next();
+ return *this;
+ }
+ ElaboratingDIEIterator operator++(int) {
+ ElaboratingDIEIterator I = *this;
+ Next();
+ return I;
}
+
+ friend bool operator==(const ElaboratingDIEIterator &a,
+ const ElaboratingDIEIterator &b) {
+ if (a.m_worklist.empty() || b.m_worklist.empty())
+ return a.m_worklist.empty() == b.m_worklist.empty();
+ return a.m_worklist.back() == b.m_worklist.back();
+ }
+ friend bool operator!=(const ElaboratingDIEIterator &a,
+ const ElaboratingDIEIterator &b) {
+ return !(a == b);
+ }
+};
+
+llvm::iterator_range<ElaboratingDIEIterator>
+elaborating_dies(const DWARFDIE &die) {
+ return llvm::make_range(ElaboratingDIEIterator(die),
+ ElaboratingDIEIterator());
}
+} // namespace
DWARFDIE
DWARFDIE::GetParent() const {
@@ -59,12 +112,10 @@ DWARFDIE::GetSibling() const {
DWARFDIE
DWARFDIE::GetReferencedDIE(const dw_attr_t attr) const {
- const dw_offset_t die_offset =
- GetAttributeValueAsReference(attr, DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET)
- return GetDIE(die_offset);
+ if (IsValid())
+ return m_die->GetAttributeValueAsReference(GetCU(), attr);
else
- return DWARFDIE();
+ return {};
}
DWARFDIE
@@ -79,12 +130,11 @@ DWARFDIE
DWARFDIE::GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const {
if (IsValid()) {
DWARFUnit *cu = GetCU();
- SymbolFileDWARF *dwarf = cu->GetSymbolFileDWARF();
const bool check_specification_or_abstract_origin = true;
DWARFFormValue form_value;
- if (m_die->GetAttributeValue(dwarf, cu, attr, form_value, nullptr,
+ if (m_die->GetAttributeValue(cu, attr, form_value, nullptr,
check_specification_or_abstract_origin))
- return dwarf->GetDIE(DIERef(form_value));
+ return form_value.Reference();
}
return DWARFDIE();
}
@@ -96,13 +146,14 @@ DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const {
DWARFUnit *cu = GetCU();
DWARFDebugInfoEntry *function_die = nullptr;
DWARFDebugInfoEntry *block_die = nullptr;
- if (m_die->LookupAddress(file_addr, dwarf, cu, &function_die, &block_die)) {
+ if (m_die->LookupAddress(file_addr, cu, &function_die, &block_die)) {
if (block_die && block_die != function_die) {
if (cu->ContainsDIEOffset(block_die->GetOffset()))
return DWARFDIE(cu, block_die);
else
- return DWARFDIE(dwarf->DebugInfo()->GetCompileUnit(
- DIERef(cu->GetOffset(), block_die->GetOffset())),
+ return DWARFDIE(dwarf->DebugInfo()->GetUnit(DIERef(
+ cu->GetSymbolFileDWARF().GetDwoNum(),
+ cu->GetDebugSection(), block_die->GetOffset())),
block_die);
}
}
@@ -112,25 +163,149 @@ DWARFDIE::LookupDeepestBlock(lldb::addr_t file_addr) const {
const char *DWARFDIE::GetMangledName() const {
if (IsValid())
- return m_die->GetMangledName(GetDWARF(), m_cu);
+ return m_die->GetMangledName(m_cu);
else
return nullptr;
}
const char *DWARFDIE::GetPubname() const {
if (IsValid())
- return m_die->GetPubname(GetDWARF(), m_cu);
+ return m_die->GetPubname(m_cu);
else
return nullptr;
}
const char *DWARFDIE::GetQualifiedName(std::string &storage) const {
if (IsValid())
- return m_die->GetQualifiedName(GetDWARF(), m_cu, storage);
+ return m_die->GetQualifiedName(m_cu, storage);
else
return nullptr;
}
+// GetName
+//
+// Get value of the DW_AT_name attribute and place that value into the supplied
+// stream object. If the DIE is a NULL object "NULL" is placed into the stream,
+// and if no DW_AT_name attribute exists for the DIE then nothing is printed.
+void DWARFDIE::GetName(Stream &s) const {
+ if (!IsValid())
+ return;
+ if (GetDIE()->IsNULL()) {
+ s.PutCString("NULL");
+ return;
+ }
+ const char *name = GetDIE()->GetAttributeValueAsString(GetCU(), DW_AT_name, nullptr, true);
+ if (!name)
+ return;
+ s.PutCString(name);
+}
+
+// AppendTypeName
+//
+// Follows the type name definition down through all needed tags to end up with
+// a fully qualified type name and dump the results to the supplied stream.
+// This is used to show the name of types given a type identifier.
+void DWARFDIE::AppendTypeName(Stream &s) const {
+ if (!IsValid())
+ return;
+ if (GetDIE()->IsNULL()) {
+ s.PutCString("NULL");
+ return;
+ }
+ if (const char *name = GetPubname()) {
+ s.PutCString(name);
+ return;
+ }
+ switch (Tag()) {
+ case DW_TAG_array_type:
+ break; // print out a "[]" after printing the full type of the element
+ // below
+ case DW_TAG_base_type:
+ s.PutCString("base ");
+ break;
+ case DW_TAG_class_type:
+ s.PutCString("class ");
+ break;
+ case DW_TAG_const_type:
+ s.PutCString("const ");
+ break;
+ case DW_TAG_enumeration_type:
+ s.PutCString("enum ");
+ break;
+ case DW_TAG_file_type:
+ s.PutCString("file ");
+ break;
+ case DW_TAG_interface_type:
+ s.PutCString("interface ");
+ break;
+ case DW_TAG_packed_type:
+ s.PutCString("packed ");
+ break;
+ case DW_TAG_pointer_type:
+ break; // print out a '*' after printing the full type below
+ case DW_TAG_ptr_to_member_type:
+ break; // print out a '*' after printing the full type below
+ case DW_TAG_reference_type:
+ break; // print out a '&' after printing the full type below
+ case DW_TAG_restrict_type:
+ s.PutCString("restrict ");
+ break;
+ case DW_TAG_set_type:
+ s.PutCString("set ");
+ break;
+ case DW_TAG_shared_type:
+ s.PutCString("shared ");
+ break;
+ case DW_TAG_string_type:
+ s.PutCString("string ");
+ break;
+ case DW_TAG_structure_type:
+ s.PutCString("struct ");
+ break;
+ case DW_TAG_subrange_type:
+ s.PutCString("subrange ");
+ break;
+ case DW_TAG_subroutine_type:
+ s.PutCString("function ");
+ break;
+ case DW_TAG_thrown_type:
+ s.PutCString("thrown ");
+ break;
+ case DW_TAG_union_type:
+ s.PutCString("union ");
+ break;
+ case DW_TAG_unspecified_type:
+ s.PutCString("unspecified ");
+ break;
+ case DW_TAG_volatile_type:
+ s.PutCString("volatile ");
+ break;
+ default:
+ return;
+ }
+
+ // Follow the DW_AT_type if possible
+ if (DWARFDIE next_die = GetAttributeValueAsReferenceDIE(DW_AT_type))
+ next_die.AppendTypeName(s);
+
+ switch (Tag()) {
+ case DW_TAG_array_type:
+ s.PutCString("[]");
+ break;
+ case DW_TAG_pointer_type:
+ s.PutChar('*');
+ break;
+ case DW_TAG_ptr_to_member_type:
+ s.PutChar('*');
+ break;
+ case DW_TAG_reference_type:
+ s.PutChar('&');
+ break;
+ default:
+ break;
+ }
+}
+
lldb_private::Type *DWARFDIE::ResolveType() const {
if (IsValid())
return GetDWARF()->ResolveType(*this, true);
@@ -138,29 +313,30 @@ lldb_private::Type *DWARFDIE::ResolveType() const {
return nullptr;
}
-lldb_private::Type *DWARFDIE::ResolveTypeUID(const DIERef &die_ref) const {
- SymbolFileDWARF *dwarf = GetDWARF();
- if (dwarf)
- return dwarf->ResolveTypeUID(dwarf->GetDIE(die_ref), true);
- else
- return nullptr;
+lldb_private::Type *DWARFDIE::ResolveTypeUID(const DWARFDIE &die) const {
+ if (SymbolFileDWARF *dwarf = GetDWARF())
+ return dwarf->ResolveTypeUID(die, true);
+ return nullptr;
}
-void DWARFDIE::GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const {
- if (IsValid()) {
- DWARFDIE parent_decl_ctx_die =
- m_die->GetParentDeclContextDIE(GetDWARF(), GetCU());
- if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != GetDIE()) {
- decl_context_dies.Append(parent_decl_ctx_die);
- parent_decl_ctx_die.GetDeclContextDIEs(decl_context_dies);
- }
+std::vector<DWARFDIE> DWARFDIE::GetDeclContextDIEs() const {
+ if (!IsValid())
+ return {};
+
+ std::vector<DWARFDIE> result;
+ DWARFDIE parent = GetParentDeclContextDIE();
+ while (parent.IsValid() && parent.GetDIE() != GetDIE()) {
+ result.push_back(std::move(parent));
+ parent = parent.GetParentDeclContextDIE();
}
+
+ return result;
}
void DWARFDIE::GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const {
if (IsValid()) {
dwarf_decl_ctx.SetLanguage(GetLanguage());
- m_die->GetDWARFDeclContext(GetDWARF(), GetCU(), dwarf_decl_ctx);
+ m_die->GetDWARFDeclContext(GetCU(), dwarf_decl_ctx);
} else {
dwarf_decl_ctx.Clear();
}
@@ -218,7 +394,7 @@ void DWARFDIE::GetDeclContext(std::vector<CompilerContext> &context) const {
DWARFDIE
DWARFDIE::GetParentDeclContextDIE() const {
if (IsValid())
- return m_die->GetParentDeclContextDIE(GetDWARF(), m_cu);
+ return m_die->GetParentDeclContextDIE(m_cu);
else
return DWARFDIE();
}
@@ -230,7 +406,7 @@ bool DWARFDIE::IsStructUnionOrClass() const {
}
bool DWARFDIE::IsMethod() const {
- for (DWARFDIE d: elaborating_dies())
+ for (DWARFDIE d : elaborating_dies(*this))
if (d.GetParent().IsStructUnionOrClass())
return true;
return false;
@@ -276,8 +452,8 @@ bool DWARFDIE::GetDIENamesAndRanges(
lldb_private::DWARFExpression *frame_base) const {
if (IsValid()) {
return m_die->GetDIENamesAndRanges(
- GetDWARF(), GetCU(), name, mangled, ranges, decl_file, decl_line,
- decl_column, call_file, call_line, call_column, frame_base);
+ GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column,
+ call_file, call_line, call_column, frame_base);
} else
return false;
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
index b0d06a886ac16..7753ec9008cb5 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -1,9 +1,8 @@
//===-- DWARFDIE.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,46 +14,37 @@
class DWARFDIE : public DWARFBaseDIE {
public:
- class ElaboratingDIEIterator;
-
using DWARFBaseDIE::DWARFBaseDIE;
- //----------------------------------------------------------------------
// Tests
- //----------------------------------------------------------------------
bool IsStructUnionOrClass() const;
bool IsMethod() const;
- //----------------------------------------------------------------------
// Accessors
- //----------------------------------------------------------------------
lldb::ModuleSP GetContainingDWOModule() const;
DWARFDIE
GetContainingDWOModuleDIE() const;
- inline llvm::iterator_range<ElaboratingDIEIterator> elaborating_dies() const;
-
- //----------------------------------------------------------------------
// Accessing information about a DIE
- //----------------------------------------------------------------------
const char *GetMangledName() const;
const char *GetPubname() const;
const char *GetQualifiedName(std::string &storage) const;
+ using DWARFBaseDIE::GetName;
+ void GetName(lldb_private::Stream &s) const;
+
+ void AppendTypeName(lldb_private::Stream &s) const;
+
lldb_private::Type *ResolveType() const;
- //----------------------------------------------------------------------
// Resolve a type by UID using this DIE's DWARF file
- //----------------------------------------------------------------------
- lldb_private::Type *ResolveTypeUID(const DIERef &die_ref) const;
+ lldb_private::Type *ResolveTypeUID(const DWARFDIE &die) const;
- //----------------------------------------------------------------------
// Functions for obtaining DIE relations and references
- //----------------------------------------------------------------------
DWARFDIE
GetParent() const;
@@ -68,11 +58,9 @@ public:
DWARFDIE
GetReferencedDIE(const dw_attr_t attr) const;
- //----------------------------------------------------------------------
// Get a another DIE from the same DWARF file as this DIE. This will
// check the current DIE's compile unit first to see if "die_offset" is
// in the same compile unit, and fall back to checking the DWARF file.
- //----------------------------------------------------------------------
DWARFDIE
GetDIE(dw_offset_t die_offset) const;
using DWARFBaseDIE::GetDIE;
@@ -83,10 +71,8 @@ public:
DWARFDIE
GetParentDeclContextDIE() const;
- //----------------------------------------------------------------------
// DeclContext related functions
- //----------------------------------------------------------------------
- void GetDeclContextDIEs(DWARFDIECollection &decl_context_dies) const;
+ std::vector<DWARFDIE> GetDeclContextDIEs() const;
void GetDWARFDeclContext(DWARFDeclContext &dwarf_decl_ctx) const;
@@ -95,13 +81,11 @@ public:
void
GetDeclContext(std::vector<lldb_private::CompilerContext> &context) const;
- //----------------------------------------------------------------------
// Getting attribute values from the DIE.
//
// GetAttributeValueAsXXX() functions should only be used if you are
// looking for one or two attributes on a DIE. If you are trying to
// parse all attributes, use GetAttributes (...) instead
- //----------------------------------------------------------------------
DWARFDIE
GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const;
@@ -111,9 +95,7 @@ public:
int &call_line, int &call_column,
lldb_private::DWARFExpression *frame_base) const;
- //----------------------------------------------------------------------
// CompilerDecl related functions
- //----------------------------------------------------------------------
lldb_private::CompilerDecl GetDecl() const;
@@ -122,58 +104,4 @@ public:
lldb_private::CompilerDeclContext GetContainingDeclContext() const;
};
-/// Iterate through all DIEs elaborating (i.e. reachable by a chain of
-/// DW_AT_specification and DW_AT_abstract_origin attributes) a given DIE. For
-/// convenience, the starting die is included in the sequence as the first
-/// item.
-class DWARFDIE::ElaboratingDIEIterator
- : public std::iterator<std::input_iterator_tag, DWARFDIE> {
-
- // The operating invariant is: top of m_worklist contains the "current" item
- // and the rest of the list are items yet to be visited. An empty worklist
- // means we've reached the end.
- // Infinite recursion is prevented by maintaining a list of seen DIEs.
- // Container sizes are optimized for the case of following DW_AT_specification
- // and DW_AT_abstract_origin just once.
- llvm::SmallVector<DWARFDIE, 2> m_worklist;
- llvm::SmallSet<lldb::user_id_t, 3> m_seen;
-
- void Next();
-
-public:
- /// An iterator starting at die d.
- explicit ElaboratingDIEIterator(DWARFDIE d) : m_worklist(1, d) {}
-
- /// End marker
- ElaboratingDIEIterator() {}
-
- const DWARFDIE &operator*() const { return m_worklist.back(); }
- ElaboratingDIEIterator &operator++() {
- Next();
- return *this;
- }
- ElaboratingDIEIterator operator++(int) {
- ElaboratingDIEIterator I = *this;
- Next();
- return I;
- }
-
- friend bool operator==(const ElaboratingDIEIterator &a,
- const ElaboratingDIEIterator &b) {
- if (a.m_worklist.empty() || b.m_worklist.empty())
- return a.m_worklist.empty() == b.m_worklist.empty();
- return a.m_worklist.back() == b.m_worklist.back();
- }
- friend bool operator!=(const ElaboratingDIEIterator &a,
- const ElaboratingDIEIterator &b) {
- return !(a == b);
- }
-};
-
-llvm::iterator_range<DWARFDIE::ElaboratingDIEIterator>
-DWARFDIE::elaborating_dies() const {
- return llvm::make_range(ElaboratingDIEIterator(*this),
- ElaboratingDIEIterator());
-}
-
#endif // SymbolFileDWARF_DWARFDIE_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
deleted file mode 100644
index 1e5bf619f7986..0000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//===-- DWARFDIECollection.cpp ----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFDIECollection.h"
-
-#include <algorithm>
-
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb_private;
-using namespace std;
-
-void DWARFDIECollection::Append(const DWARFDIE &die) { m_dies.push_back(die); }
-
-DWARFDIE
-DWARFDIECollection::GetDIEAtIndex(uint32_t idx) const {
- if (idx < m_dies.size())
- return m_dies[idx];
- return DWARFDIE();
-}
-
-size_t DWARFDIECollection::Size() const { return m_dies.size(); }
-
-void DWARFDIECollection::Dump(Stream *s, const char *title) const {
- if (title && title[0] != '\0')
- s->Printf("%s\n", title);
- for (const auto &die : m_dies)
- s->Printf("0x%8.8x\n", die.GetOffset());
-}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h b/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
deleted file mode 100644
index e1e73e71ae7f3..0000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
+++ /dev/null
@@ -1,38 +0,0 @@
-//===-- DWARFDIECollection.h ------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARF_DWARFDIECollection_h_
-#define SymbolFileDWARF_DWARFDIECollection_h_
-
-#include "DWARFDIE.h"
-#include <vector>
-
-class DWARFDIECollection {
-public:
- DWARFDIECollection() : m_dies() {}
- ~DWARFDIECollection() {}
-
- void Append(const DWARFDIE &die);
-
- void Dump(lldb_private::Stream *s, const char *title) const;
-
- DWARFDIE
- GetDIEAtIndex(uint32_t idx) const;
-
- size_t Size() const;
-
-protected:
- typedef std::vector<DWARFDIE> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
-
- collection m_dies; // Ordered list of die offsets
-};
-
-#endif // SymbolFileDWARF_DWARFDIECollection_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
index 2fcdd34d532f0..1678b228137f6 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.cpp
@@ -1,27 +1,30 @@
//===-- DWARFDataExtractor.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFDataExtractor.h"
+#include "llvm/ADT/StringRef.h"
namespace lldb_private {
uint64_t
DWARFDataExtractor::GetDWARFInitialLength(lldb::offset_t *offset_ptr) const {
- uint64_t length = GetU32(offset_ptr);
- m_is_dwarf64 = (length == UINT32_MAX);
- if (m_is_dwarf64)
- length = GetU64(offset_ptr);
- return length;
+ return GetU32(offset_ptr);
}
dw_offset_t
DWARFDataExtractor::GetDWARFOffset(lldb::offset_t *offset_ptr) const {
return GetMaxU64(offset_ptr, GetDWARFSizeOfOffset());
}
+
+llvm::DWARFDataExtractor DWARFDataExtractor::GetAsLLVM() const {
+ return llvm::DWARFDataExtractor(
+ llvm::StringRef(reinterpret_cast<const char *>(GetDataStart()),
+ GetByteSize()),
+ GetByteOrder() == lldb::eByteOrderLittle, GetAddressByteSize());
}
+} // namespace lldb_private
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
index 1f342035f1354..22db5e8c0b79c 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h
@@ -1,9 +1,8 @@
//===-- DWARFDataExtractor.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,27 +11,26 @@
#include "lldb/Core/dwarf.h"
#include "lldb/Utility/DataExtractor.h"
+#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
namespace lldb_private {
class DWARFDataExtractor : public DataExtractor {
public:
- DWARFDataExtractor() : DataExtractor(), m_is_dwarf64(false) {}
+ DWARFDataExtractor() = default;
DWARFDataExtractor(const DWARFDataExtractor &data, lldb::offset_t offset,
lldb::offset_t length)
- : DataExtractor(data, offset, length), m_is_dwarf64(false) {}
+ : DataExtractor(data, offset, length) {}
uint64_t GetDWARFInitialLength(lldb::offset_t *offset_ptr) const;
dw_offset_t GetDWARFOffset(lldb::offset_t *offset_ptr) const;
- size_t GetDWARFSizeofInitialLength() const { return m_is_dwarf64 ? 12 : 4; }
- size_t GetDWARFSizeOfOffset() const { return m_is_dwarf64 ? 8 : 4; }
- bool IsDWARF64() const { return m_is_dwarf64; }
+ size_t GetDWARFSizeofInitialLength() const { return 4; }
+ size_t GetDWARFSizeOfOffset() const { return 4; }
-protected:
- mutable bool m_is_dwarf64;
+ llvm::DWARFDataExtractor GetAsLLVM() const;
};
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
index affe4b85bdabd..26301566a8e14 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDebugAbbrev.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,50 +14,41 @@ using namespace lldb;
using namespace lldb_private;
using namespace std;
-//----------------------------------------------------------------------
// DWARFAbbreviationDeclarationSet::Clear()
-//----------------------------------------------------------------------
void DWARFAbbreviationDeclarationSet::Clear() {
m_idx_offset = 0;
m_decls.clear();
}
-//----------------------------------------------------------------------
// DWARFAbbreviationDeclarationSet::Extract()
-//----------------------------------------------------------------------
-bool DWARFAbbreviationDeclarationSet::Extract(const DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr) {
+llvm::Error
+DWARFAbbreviationDeclarationSet::extract(const DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr) {
const lldb::offset_t begin_offset = *offset_ptr;
m_offset = begin_offset;
Clear();
DWARFAbbreviationDeclaration abbrevDeclaration;
dw_uleb128_t prev_abbr_code = 0;
- while (abbrevDeclaration.Extract(data, offset_ptr)) {
+ while (true) {
+ llvm::Expected<DWARFEnumState> es =
+ abbrevDeclaration.extract(data, offset_ptr);
+ if (!es)
+ return es.takeError();
+ if (*es == DWARFEnumState::Complete)
+ break;
m_decls.push_back(abbrevDeclaration);
if (m_idx_offset == 0)
m_idx_offset = abbrevDeclaration.Code();
- else {
- if (prev_abbr_code + 1 != abbrevDeclaration.Code())
- m_idx_offset =
- UINT32_MAX; // Out of order indexes, we can't do O(1) lookups...
+ else if (prev_abbr_code + 1 != abbrevDeclaration.Code()) {
+ // Out of order indexes, we can't do O(1) lookups...
+ m_idx_offset = UINT32_MAX;
}
prev_abbr_code = abbrevDeclaration.Code();
}
- return begin_offset != *offset_ptr;
+ return llvm::ErrorSuccess();
}
-//----------------------------------------------------------------------
-// DWARFAbbreviationDeclarationSet::Dump()
-//----------------------------------------------------------------------
-void DWARFAbbreviationDeclarationSet::Dump(Stream *s) const {
- std::for_each(
- m_decls.begin(), m_decls.end(),
- bind2nd(std::mem_fun_ref(&DWARFAbbreviationDeclaration::Dump), s));
-}
-
-//----------------------------------------------------------------------
// DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration()
-//----------------------------------------------------------------------
const DWARFAbbreviationDeclaration *
DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration(
dw_uleb128_t abbrCode) const {
@@ -74,32 +64,11 @@ DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration(
if (idx < m_decls.size())
return &m_decls[idx];
}
- return NULL;
+ return nullptr;
}
-//----------------------------------------------------------------------
-// DWARFAbbreviationDeclarationSet::AppendAbbrevDeclSequential()
-//
-// Append an abbreviation declaration with a sequential code for O(n) lookups.
-// Handy when creating an DWARFAbbreviationDeclarationSet.
-//----------------------------------------------------------------------
-dw_uleb128_t DWARFAbbreviationDeclarationSet::AppendAbbrevDeclSequential(
- const DWARFAbbreviationDeclaration &abbrevDecl) {
- // Get the next abbreviation code based on our current array size
- dw_uleb128_t code = m_decls.size() + 1;
-
- // Push the new declaration on the back
- m_decls.push_back(abbrevDecl);
-
- // Update the code for this new declaration
- m_decls.back().SetCode(code);
-
- return code; // return the new abbreviation code!
-}
-//----------------------------------------------------------------------
// DWARFAbbreviationDeclarationSet::GetUnsupportedForms()
-//----------------------------------------------------------------------
void DWARFAbbreviationDeclarationSet::GetUnsupportedForms(
std::set<dw_form_t> &invalid_forms) const {
for (const auto &abbr_decl : m_decls) {
@@ -112,13 +81,11 @@ void DWARFAbbreviationDeclarationSet::GetUnsupportedForms(
}
}
-//----------------------------------------------------------------------
// Encode
//
// Encode the abbreviation table onto the end of the buffer provided into a
// byte representation as would be found in a ".debug_abbrev" debug information
// section.
-//----------------------------------------------------------------------
// void
// DWARFAbbreviationDeclarationSet::Encode(BinaryStreamBuf& debug_abbrev_buf)
// const
@@ -130,49 +97,29 @@ void DWARFAbbreviationDeclarationSet::GetUnsupportedForms(
// debug_abbrev_buf.Append8(0);
//}
-//----------------------------------------------------------------------
// DWARFDebugAbbrev constructor
-//----------------------------------------------------------------------
DWARFDebugAbbrev::DWARFDebugAbbrev()
: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()) {}
-//----------------------------------------------------------------------
// DWARFDebugAbbrev::Parse()
-//----------------------------------------------------------------------
-void DWARFDebugAbbrev::Parse(const DWARFDataExtractor &data) {
+llvm::Error DWARFDebugAbbrev::parse(const DWARFDataExtractor &data) {
lldb::offset_t offset = 0;
while (data.ValidOffset(offset)) {
uint32_t initial_cu_offset = offset;
DWARFAbbreviationDeclarationSet abbrevDeclSet;
- if (abbrevDeclSet.Extract(data, &offset))
- m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
- else
- break;
- }
- m_prev_abbr_offset_pos = m_abbrevCollMap.end();
-}
+ llvm::Error error = abbrevDeclSet.extract(data, &offset);
+ if (error)
+ return error;
-//----------------------------------------------------------------------
-// DWARFDebugAbbrev::Dump()
-//----------------------------------------------------------------------
-void DWARFDebugAbbrev::Dump(Stream *s) const {
- if (m_abbrevCollMap.empty()) {
- s->PutCString("< EMPTY >\n");
- return;
- }
-
- DWARFAbbreviationDeclarationCollMapConstIter pos;
- for (pos = m_abbrevCollMap.begin(); pos != m_abbrevCollMap.end(); ++pos) {
- s->Printf("Abbrev table for offset: 0x%8.8x\n", pos->first);
- pos->second.Dump(s);
+ m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
}
+ m_prev_abbr_offset_pos = m_abbrevCollMap.end();
+ return llvm::ErrorSuccess();
}
-//----------------------------------------------------------------------
// DWARFDebugAbbrev::GetAbbreviationDeclarationSet()
-//----------------------------------------------------------------------
const DWARFAbbreviationDeclarationSet *
DWARFDebugAbbrev::GetAbbreviationDeclarationSet(
dw_offset_t cu_abbr_offset) const {
@@ -188,12 +135,10 @@ DWARFDebugAbbrev::GetAbbreviationDeclarationSet(
if (pos != m_abbrevCollMap.end())
return &(pos->second);
- return NULL;
+ return nullptr;
}
-//----------------------------------------------------------------------
// DWARFDebugAbbrev::GetUnsupportedForms()
-//----------------------------------------------------------------------
void DWARFDebugAbbrev::GetUnsupportedForms(
std::set<dw_form_t> &invalid_forms) const {
for (const auto &pair : m_abbrevCollMap)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
index 2bacb6349b6fc..9c4729326081c 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
@@ -1,9 +1,8 @@
//===-- DWARFDebugAbbrev.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,17 +34,21 @@ public:
void Clear();
dw_offset_t GetOffset() const { return m_offset; }
- void Dump(lldb_private::Stream *s) const;
- bool Extract(const lldb_private::DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr);
+
+ /// Extract all abbrev decls in a set. Returns llvm::ErrorSuccess() on
+ /// success, and an appropriate llvm::Error object otherwise.
+ llvm::Error extract(const lldb_private::DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr);
// void Encode(BinaryStreamBuf& debug_abbrev_buf) const;
- dw_uleb128_t
- AppendAbbrevDeclSequential(const DWARFAbbreviationDeclaration &abbrevDecl);
void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const;
const DWARFAbbreviationDeclaration *
GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const;
+ /// Unit test accessor functions.
+ /// @{
+ uint32_t GetIndexOffset() const { return m_idx_offset; }
+ /// @}
private:
dw_offset_t m_offset;
uint32_t m_idx_offset;
@@ -64,8 +67,10 @@ public:
DWARFDebugAbbrev();
const DWARFAbbreviationDeclarationSet *
GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
- void Dump(lldb_private::Stream *s) const;
- void Parse(const lldb_private::DWARFDataExtractor &data);
+ /// Extract all abbreviations for a particular compile unit. Returns
+ /// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object
+ /// otherwise.
+ llvm::Error parse(const lldb_private::DWARFDataExtractor &data);
void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const;
protected:
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
index 00265361f8655..86ce3b329b25b 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
@@ -1,17 +1,15 @@
//===-- DWARFDebugArangeSet.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFDebugArangeSet.h"
-
-#include "SymbolFileDWARF.h"
-#include "lldb/Utility/Stream.h"
-#include <assert.h>
+#include "DWARFDataExtractor.h"
+#include "llvm/Object/Error.h"
+#include <cassert>
using namespace lldb_private;
@@ -34,213 +32,88 @@ void DWARFDebugArangeSet::Clear() {
m_arange_descriptors.clear();
}
-void DWARFDebugArangeSet::SetHeader(uint16_t version, uint32_t cu_offset,
- uint8_t addr_size, uint8_t seg_size) {
- m_header.version = version;
- m_header.cu_offset = cu_offset;
- m_header.addr_size = addr_size;
- m_header.seg_size = seg_size;
-}
-
-void DWARFDebugArangeSet::Compact() {
- if (m_arange_descriptors.empty())
- return;
-
- // Iterate through all arange descriptors and combine any ranges that overlap
- // or have matching boundaries. The m_arange_descriptors are assumed to be in
- // ascending order after being built by adding descriptors using the
- // AddDescriptor method.
- uint32_t i = 0;
- while (i + 1 < m_arange_descriptors.size()) {
- if (m_arange_descriptors[i].end_address() >=
- m_arange_descriptors[i + 1].address) {
- // The current range ends at or exceeds the start of the next address
- // range. Compute the max end address between the two and use that to
- // make the new length.
- const dw_addr_t max_end_addr =
- std::max(m_arange_descriptors[i].end_address(),
- m_arange_descriptors[i + 1].end_address());
- m_arange_descriptors[i].length =
- max_end_addr - m_arange_descriptors[i].address;
- // Now remove the next entry as it was just combined with the previous
- // one.
- m_arange_descriptors.erase(m_arange_descriptors.begin() + i + 1);
- } else {
- // Discontiguous address range, just proceed to the next one.
- ++i;
- }
- }
-}
-//----------------------------------------------------------------------
-// Compare function DWARFDebugArangeSet::Descriptor structures
-//----------------------------------------------------------------------
-static bool DescriptorLessThan(const DWARFDebugArangeSet::Descriptor &range1,
- const DWARFDebugArangeSet::Descriptor &range2) {
- return range1.address < range2.address;
-}
-
-//----------------------------------------------------------------------
-// Add a range descriptor and keep things sorted so we can easily compact the
-// ranges before being saved or used.
-//----------------------------------------------------------------------
-void DWARFDebugArangeSet::AddDescriptor(
- const DWARFDebugArangeSet::Descriptor &range) {
- if (m_arange_descriptors.empty()) {
- m_arange_descriptors.push_back(range);
- return;
- }
-
- DescriptorIter end = m_arange_descriptors.end();
- DescriptorIter pos =
- lower_bound(m_arange_descriptors.begin(), end, range, DescriptorLessThan);
- const dw_addr_t range_end_addr = range.end_address();
- if (pos != end) {
- const dw_addr_t found_end_addr = pos->end_address();
- if (range.address < pos->address) {
- if (range_end_addr < pos->address) {
- // Non-contiguous entries, add this one before the found entry
- m_arange_descriptors.insert(pos, range);
- } else if (range_end_addr == pos->address) {
- // The top end of 'range' is the lower end of the entry pointed to by
- // 'pos'. We can combine range with the entry we found by setting the
- // starting address and increasing the length since they don't overlap.
- pos->address = range.address;
- pos->length += range.length;
- } else {
- // We can combine these two and make sure the largest end address is
- // used to make end address.
- pos->address = range.address;
- pos->length = std::max(found_end_addr, range_end_addr) - pos->address;
- }
- } else if (range.address == pos->address) {
- pos->length = std::max(pos->length, range.length);
- }
- } else {
- // NOTE: 'pos' points to entry past the end which is ok for insert,
- // don't use otherwise!!!
- const dw_addr_t max_addr = m_arange_descriptors.back().end_address();
- if (max_addr < range.address) {
- // Non-contiguous entries, add this one before the found entry
- m_arange_descriptors.insert(pos, range);
- } else if (max_addr == range.address) {
- m_arange_descriptors.back().length += range.length;
- } else {
- m_arange_descriptors.back().length = std::max(max_addr, range_end_addr) -
- m_arange_descriptors.back().address;
- }
- }
-}
-
-bool DWARFDebugArangeSet::Extract(const DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr) {
- if (data.ValidOffset(*offset_ptr)) {
- m_arange_descriptors.clear();
- m_offset = *offset_ptr;
+llvm::Error DWARFDebugArangeSet::extract(const DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr) {
+ assert(data.ValidOffset(*offset_ptr));
- // 7.20 Address Range Table
- //
- // Each set of entries in the table of address ranges contained in the
- // .debug_aranges section begins with a header consisting of: a 4-byte
- // length containing the length of the set of entries for this compilation
- // unit, not including the length field itself; a 2-byte version identifier
- // containing the value 2 for DWARF Version 2; a 4-byte offset into
- // the.debug_infosection; a 1-byte unsigned integer containing the size in
- // bytes of an address (or the offset portion of an address for segmented
- // addressing) on the target system; and a 1-byte unsigned integer
- // containing the size in bytes of a segment descriptor on the target
- // system. This header is followed by a series of tuples. Each tuple
- // consists of an address and a length, each in the size appropriate for an
- // address on the target architecture.
- m_header.length = data.GetDWARFInitialLength(offset_ptr);
- m_header.version = data.GetU16(offset_ptr);
- m_header.cu_offset = data.GetDWARFOffset(offset_ptr);
- m_header.addr_size = data.GetU8(offset_ptr);
- m_header.seg_size = data.GetU8(offset_ptr);
-
- // Try to avoid reading invalid arange sets by making sure:
- // 1 - the version looks good
- // 2 - the address byte size looks plausible
- // 3 - the length seems to make sense
- // size looks plausible
- if ((m_header.version >= 2 && m_header.version <= 5) &&
- (m_header.addr_size == 4 || m_header.addr_size == 8) &&
- (m_header.length > 0)) {
- if (data.ValidOffset(m_offset + sizeof(m_header.length) +
- m_header.length - 1)) {
- // The first tuple following the header in each set begins at an offset
- // that is a multiple of the size of a single tuple (that is, twice the
- // size of an address). The header is padded, if necessary, to the
- // appropriate boundary.
- const uint32_t header_size = *offset_ptr - m_offset;
- const uint32_t tuple_size = m_header.addr_size << 1;
- uint32_t first_tuple_offset = 0;
- while (first_tuple_offset < header_size)
- first_tuple_offset += tuple_size;
-
- *offset_ptr = m_offset + first_tuple_offset;
-
- Descriptor arangeDescriptor;
-
- static_assert(
- sizeof(arangeDescriptor.address) == sizeof(arangeDescriptor.length),
- "DWARFDebugArangeSet::Descriptor.address and "
- "DWARFDebugArangeSet::Descriptor.length must have same size");
-
- while (data.ValidOffset(*offset_ptr)) {
- arangeDescriptor.address =
- data.GetMaxU64(offset_ptr, m_header.addr_size);
- arangeDescriptor.length =
- data.GetMaxU64(offset_ptr, m_header.addr_size);
-
- // Each set of tuples is terminated by a 0 for the address and 0 for
- // the length.
- if (arangeDescriptor.address || arangeDescriptor.length)
- m_arange_descriptors.push_back(arangeDescriptor);
- else
- break; // We are done if we get a zero address and length
- }
- }
-#if defined(LLDB_CONFIGURATION_DEBUG)
- else {
- printf("warning: .debug_arange set length is too large arange data at "
- "0x%8.8x: length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, "
- "addr_size=%u, seg_size=%u\n",
- m_offset, m_header.length, m_header.version, m_header.cu_offset,
- m_header.addr_size, m_header.seg_size);
- }
-#endif
- }
-#if defined(LLDB_CONFIGURATION_DEBUG)
- else {
- printf("warning: .debug_arange set has bad header at 0x%8.8x: "
- "length=0x%8.8x, version=0x%4.4x, cu_offset=0x%8.8x, "
- "addr_size=%u, seg_size=%u\n",
- m_offset, m_header.length, m_header.version, m_header.cu_offset,
- m_header.addr_size, m_header.seg_size);
- }
-#endif
-
- return !m_arange_descriptors.empty();
+ m_arange_descriptors.clear();
+ m_offset = *offset_ptr;
+
+ // 7.20 Address Range Table
+ //
+ // Each set of entries in the table of address ranges contained in the
+ // .debug_aranges section begins with a header consisting of: a 4-byte
+ // length containing the length of the set of entries for this compilation
+ // unit, not including the length field itself; a 2-byte version identifier
+ // containing the value 2 for DWARF Version 2; a 4-byte offset into
+ // the.debug_infosection; a 1-byte unsigned integer containing the size in
+ // bytes of an address (or the offset portion of an address for segmented
+ // addressing) on the target system; and a 1-byte unsigned integer
+ // containing the size in bytes of a segment descriptor on the target
+ // system. This header is followed by a series of tuples. Each tuple
+ // consists of an address and a length, each in the size appropriate for an
+ // address on the target architecture.
+ m_header.length = data.GetDWARFInitialLength(offset_ptr);
+ m_header.version = data.GetU16(offset_ptr);
+ m_header.cu_offset = data.GetDWARFOffset(offset_ptr);
+ m_header.addr_size = data.GetU8(offset_ptr);
+ m_header.seg_size = data.GetU8(offset_ptr);
+
+ // Try to avoid reading invalid arange sets by making sure:
+ // 1 - the version looks good
+ // 2 - the address byte size looks plausible
+ // 3 - the length seems to make sense
+ // size looks plausible
+ if (m_header.version < 2 || m_header.version > 5)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Invalid arange header version");
+
+ if (m_header.addr_size != 4 && m_header.addr_size != 8)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Invalid arange header address size");
+
+ if (m_header.length == 0)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Invalid arange header length");
+
+ if (!data.ValidOffset(m_offset + sizeof(m_header.length) + m_header.length -
+ 1))
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Invalid arange header length");
+
+ // The first tuple following the header in each set begins at an offset
+ // that is a multiple of the size of a single tuple (that is, twice the
+ // size of an address). The header is padded, if necessary, to the
+ // appropriate boundary.
+ const uint32_t header_size = *offset_ptr - m_offset;
+ const uint32_t tuple_size = m_header.addr_size << 1;
+ uint32_t first_tuple_offset = 0;
+ while (first_tuple_offset < header_size)
+ first_tuple_offset += tuple_size;
+
+ *offset_ptr = m_offset + first_tuple_offset;
+
+ Descriptor arangeDescriptor;
+
+ static_assert(sizeof(arangeDescriptor.address) ==
+ sizeof(arangeDescriptor.length),
+ "DWARFDebugArangeSet::Descriptor.address and "
+ "DWARFDebugArangeSet::Descriptor.length must have same size");
+
+ while (data.ValidOffset(*offset_ptr)) {
+ arangeDescriptor.address = data.GetMaxU64(offset_ptr, m_header.addr_size);
+ arangeDescriptor.length = data.GetMaxU64(offset_ptr, m_header.addr_size);
+
+ // Each set of tuples is terminated by a 0 for the address and 0 for
+ // the length.
+ if (!arangeDescriptor.address && !arangeDescriptor.length)
+ return llvm::ErrorSuccess();
+
+ m_arange_descriptors.push_back(arangeDescriptor);
}
- return false;
-}
-
-dw_offset_t DWARFDebugArangeSet::GetOffsetOfNextEntry() const {
- return m_offset + m_header.length + 4;
-}
-
-void DWARFDebugArangeSet::Dump(Stream *s) const {
- s->Printf("Address Range Header: length = 0x%8.8x, version = 0x%4.4x, "
- "cu_offset = 0x%8.8x, addr_size = 0x%2.2x, seg_size = 0x%2.2x\n",
- m_header.length, m_header.version, m_header.cu_offset,
- m_header.addr_size, m_header.seg_size);
- const uint32_t hex_width = m_header.addr_size * 2;
- DescriptorConstIter pos;
- DescriptorConstIter end = m_arange_descriptors.end();
- for (pos = m_arange_descriptors.begin(); pos != end; ++pos)
- s->Printf("[0x%*.*" PRIx64 " - 0x%*.*" PRIx64 ")\n", hex_width, hex_width,
- pos->address, hex_width, hex_width, pos->end_address());
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "arange descriptors not terminated by null entry");
}
class DescriptorContainsAddress {
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
index ae6319a13d0ed..db0cf22a3f45e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
@@ -1,20 +1,18 @@
//===-- DWARFDebugArangeSet.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef SymbolFileDWARF_DWARFDebugArangeSet_h_
#define SymbolFileDWARF_DWARFDebugArangeSet_h_
-#include "SymbolFileDWARF.h"
+#include "lldb/Core/dwarf.h"
+#include <cstdint>
#include <vector>
-class SymbolFileDWARF;
-
class DWARFDebugArangeSet {
public:
struct Header {
@@ -41,23 +39,11 @@ public:
DWARFDebugArangeSet();
void Clear();
void SetOffset(uint32_t offset) { m_offset = offset; }
- void SetHeader(uint16_t version, uint32_t cu_offset, uint8_t addr_size,
- uint8_t seg_size);
- void AddDescriptor(const DWARFDebugArangeSet::Descriptor &range);
- void Compact();
- bool Extract(const lldb_private::DWARFDataExtractor &data,
- lldb::offset_t *offset_ptr);
- void Dump(lldb_private::Stream *s) const;
- dw_offset_t GetCompileUnitDIEOffset() const { return m_header.cu_offset; }
- dw_offset_t GetOffsetOfNextEntry() const;
+ llvm::Error extract(const lldb_private::DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr);
dw_offset_t FindAddress(dw_addr_t address) const;
size_t NumDescriptors() const { return m_arange_descriptors.size(); }
const Header &GetHeader() const { return m_header; }
- const Descriptor *GetDescriptor(uint32_t i) const {
- if (i < m_arange_descriptors.size())
- return &m_arange_descriptors[i];
- return NULL;
- }
const Descriptor &GetDescriptorRef(uint32_t i) const {
return m_arange_descriptors[i];
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
index 02f528d571b07..ccf33e6dc3414 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -1,39 +1,24 @@
//===-- DWARFDebugAranges.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFDebugAranges.h"
-
-#include <assert.h>
-#include <stdio.h>
-
-#include <algorithm>
-
+#include "DWARFDebugArangeSet.h"
+#include "DWARFUnit.h"
#include "lldb/Utility/Log.h"
-#include "lldb/Utility/Stream.h"
#include "lldb/Utility/Timer.h"
-#include "DWARFUnit.h"
-#include "DWARFDebugInfo.h"
-#include "LogChannelDWARF.h"
-#include "SymbolFileDWARF.h"
-
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Constructor
-//----------------------------------------------------------------------
DWARFDebugAranges::DWARFDebugAranges() : m_aranges() {}
-//----------------------------------------------------------------------
// CountArangeDescriptors
-//----------------------------------------------------------------------
class CountArangeDescriptors {
public:
CountArangeDescriptors(uint32_t &count_ref) : count(count_ref) {
@@ -45,53 +30,36 @@ public:
uint32_t &count;
};
-//----------------------------------------------------------------------
// Extract
-//----------------------------------------------------------------------
-bool DWARFDebugAranges::Extract(const DWARFDataExtractor &debug_aranges_data) {
- if (debug_aranges_data.ValidOffset(0)) {
- lldb::offset_t offset = 0;
-
- DWARFDebugArangeSet set;
- Range range;
- while (set.Extract(debug_aranges_data, &offset)) {
- const uint32_t num_descriptors = set.NumDescriptors();
- if (num_descriptors > 0) {
- const dw_offset_t cu_offset = set.GetCompileUnitDIEOffset();
-
- for (uint32_t i = 0; i < num_descriptors; ++i) {
- const DWARFDebugArangeSet::Descriptor &descriptor =
- set.GetDescriptorRef(i);
- m_aranges.Append(RangeToDIE::Entry(descriptor.address,
- descriptor.length, cu_offset));
- }
+llvm::Error
+DWARFDebugAranges::extract(const DWARFDataExtractor &debug_aranges_data) {
+ lldb::offset_t offset = 0;
+
+ DWARFDebugArangeSet set;
+ Range range;
+ while (debug_aranges_data.ValidOffset(offset)) {
+ llvm::Error error = set.extract(debug_aranges_data, &offset);
+ if (!error)
+ return error;
+
+ const uint32_t num_descriptors = set.NumDescriptors();
+ if (num_descriptors > 0) {
+ const dw_offset_t cu_offset = set.GetHeader().cu_offset;
+
+ for (uint32_t i = 0; i < num_descriptors; ++i) {
+ const DWARFDebugArangeSet::Descriptor &descriptor =
+ set.GetDescriptorRef(i);
+ m_aranges.Append(RangeToDIE::Entry(descriptor.address,
+ descriptor.length, cu_offset));
}
- set.Clear();
}
+ set.Clear();
}
- return false;
-}
-
-//----------------------------------------------------------------------
-// Generate
-//----------------------------------------------------------------------
-bool DWARFDebugAranges::Generate(SymbolFileDWARF *dwarf2Data) {
- Clear();
- DWARFDebugInfo *debug_info = dwarf2Data->DebugInfo();
- if (debug_info) {
- uint32_t cu_idx = 0;
- const uint32_t num_compile_units = dwarf2Data->GetNumCompileUnits();
- for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
- DWARFUnit *cu = debug_info->GetCompileUnitAtIndex(cu_idx);
- if (cu)
- cu->BuildAddressRangeTable(dwarf2Data, this);
- }
- }
- return !IsEmpty();
+ return llvm::ErrorSuccess();
}
void DWARFDebugAranges::Dump(Log *log) const {
- if (log == NULL)
+ if (log == nullptr)
return;
const size_t num_entries = m_aranges.GetSize();
@@ -114,35 +82,11 @@ void DWARFDebugAranges::Sort(bool minimize) {
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast<void *>(this));
- Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
- size_t orig_arange_size = 0;
- if (log) {
- orig_arange_size = m_aranges.GetSize();
- log->Printf("DWARFDebugAranges::Sort(minimize = %u) with %" PRIu64
- " entries",
- minimize, (uint64_t)orig_arange_size);
- }
-
m_aranges.Sort();
m_aranges.CombineConsecutiveEntriesWithEqualData();
-
- if (log) {
- if (minimize) {
- const size_t new_arange_size = m_aranges.GetSize();
- const size_t delta = orig_arange_size - new_arange_size;
- log->Printf("DWARFDebugAranges::Sort() %" PRIu64
- " entries after minimizing (%" PRIu64
- " entries combined for %" PRIu64 " bytes saved)",
- (uint64_t)new_arange_size, (uint64_t)delta,
- (uint64_t)delta * sizeof(Range));
- }
- Dump(log);
- }
}
-//----------------------------------------------------------------------
// FindAddress
-//----------------------------------------------------------------------
dw_offset_t DWARFDebugAranges::FindAddress(dw_addr_t address) const {
const RangeToDIE::Entry *entry = m_aranges.FindEntryThatContains(address);
if (entry)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
index e7a8635f05321..74ba011b27af0 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
@@ -1,21 +1,17 @@
//===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef SymbolFileDWARF_DWARFDebugAranges_h_
#define SymbolFileDWARF_DWARFDebugAranges_h_
-#include "DWARFDebugArangeSet.h"
-#include <list>
-
-#include "lldb/Core/RangeMap.h"
-
-class SymbolFileDWARF;
+#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/RangeMap.h"
+#include "llvm/Support/Error.h"
class DWARFDebugAranges {
protected:
@@ -30,19 +26,14 @@ public:
void Clear() { m_aranges.Clear(); }
- bool Extract(const lldb_private::DWARFDataExtractor &debug_aranges_data);
-
- bool Generate(SymbolFileDWARF *dwarf2Data);
+ llvm::Error
+ extract(const lldb_private::DWARFDataExtractor &debug_aranges_data);
// Use append range multiple times and then call sort
void AppendRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc);
void Sort(bool minimize);
- const Range *RangeAtIndex(uint32_t idx) const {
- return m_aranges.GetEntryAtIndex(idx);
- }
-
void Dump(lldb_private::Log *log) const;
dw_offset_t FindAddress(dw_addr_t address) const;
@@ -57,8 +48,6 @@ public:
return DW_INVALID_OFFSET;
}
- static void Dump(SymbolFileDWARF *dwarf2Data, lldb_private::Stream *s);
-
protected:
RangeToDIE m_aranges;
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index dadc30dc918ac..100f35f8c6b02 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDebugInfo.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,213 +15,183 @@
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
+#include "llvm/Support/Casting.h"
#include "DWARFCompileUnit.h"
-#include "DWARFDebugAranges.h"
+#include "DWARFContext.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugInfoEntry.h"
#include "DWARFFormValue.h"
-#include "LogChannelDWARF.h"
+#include "DWARFTypeUnit.h"
using namespace lldb;
using namespace lldb_private;
using namespace std;
-//----------------------------------------------------------------------
// Constructor
-//----------------------------------------------------------------------
-DWARFDebugInfo::DWARFDebugInfo()
- : m_dwarf2Data(NULL), m_compile_units(), m_cu_aranges_ap() {}
-
-//----------------------------------------------------------------------
-// SetDwarfData
-//----------------------------------------------------------------------
-void DWARFDebugInfo::SetDwarfData(SymbolFileDWARF *dwarf2Data) {
- m_dwarf2Data = dwarf2Data;
- m_compile_units.clear();
-}
+DWARFDebugInfo::DWARFDebugInfo(SymbolFileDWARF &dwarf,
+ lldb_private::DWARFContext &context)
+ : m_dwarf(dwarf), m_context(context), m_units(), m_cu_aranges_up() {}
+
+llvm::Expected<DWARFDebugAranges &> DWARFDebugInfo::GetCompileUnitAranges() {
+ if (m_cu_aranges_up)
+ return *m_cu_aranges_up;
+
+ m_cu_aranges_up = llvm::make_unique<DWARFDebugAranges>();
+ const DWARFDataExtractor &debug_aranges_data =
+ m_context.getOrLoadArangesData();
+ if (llvm::Error error = m_cu_aranges_up->extract(debug_aranges_data))
+ return std::move(error);
+
+ // Make a list of all CUs represented by the arange data in the file.
+ std::set<dw_offset_t> cus_with_data;
+ for (size_t n = 0; n < m_cu_aranges_up->GetNumRanges(); n++) {
+ dw_offset_t offset = m_cu_aranges_up->OffsetAtIndex(n);
+ if (offset != DW_INVALID_OFFSET)
+ cus_with_data.insert(offset);
+ }
-DWARFDebugAranges &DWARFDebugInfo::GetCompileUnitAranges() {
- if (m_cu_aranges_ap.get() == NULL && m_dwarf2Data) {
- Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
-
- m_cu_aranges_ap.reset(new DWARFDebugAranges());
- const DWARFDataExtractor &debug_aranges_data =
- m_dwarf2Data->get_debug_aranges_data();
- if (debug_aranges_data.GetByteSize() > 0) {
- if (log)
- log->Printf(
- "DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" from "
- ".debug_aranges",
- m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
- m_cu_aranges_ap->Extract(debug_aranges_data);
- }
+ // Manually build arange data for everything that wasn't in the
+ // .debug_aranges table.
+ const size_t num_units = GetNumUnits();
+ for (size_t idx = 0; idx < num_units; ++idx) {
+ DWARFUnit *cu = GetUnitAtIndex(idx);
- // Make a list of all CUs represented by the arange data in the file.
- std::set<dw_offset_t> cus_with_data;
- for (size_t n = 0; n < m_cu_aranges_ap.get()->GetNumRanges(); n++) {
- dw_offset_t offset = m_cu_aranges_ap.get()->OffsetAtIndex(n);
- if (offset != DW_INVALID_OFFSET)
- cus_with_data.insert(offset);
- }
+ dw_offset_t offset = cu->GetOffset();
+ if (cus_with_data.find(offset) == cus_with_data.end())
+ cu->BuildAddressRangeTable(m_cu_aranges_up.get());
+ }
+
+ const bool minimize = true;
+ m_cu_aranges_up->Sort(minimize);
+ return *m_cu_aranges_up;
+}
- // Manually build arange data for everything that wasn't in the
- // .debug_aranges table.
- bool printed = false;
- const size_t num_compile_units = GetNumCompileUnits();
- for (size_t idx = 0; idx < num_compile_units; ++idx) {
- DWARFUnit *cu = GetCompileUnitAtIndex(idx);
-
- dw_offset_t offset = cu->GetOffset();
- if (cus_with_data.find(offset) == cus_with_data.end()) {
- if (log) {
- if (!printed)
- log->Printf(
- "DWARFDebugInfo::GetCompileUnitAranges() for \"%s\" by parsing",
- m_dwarf2Data->GetObjectFile()->GetFileSpec().GetPath().c_str());
- printed = true;
- }
- cu->BuildAddressRangeTable(m_dwarf2Data, m_cu_aranges_ap.get());
- }
+void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) {
+ DWARFDataExtractor data = section == DIERef::Section::DebugTypes
+ ? m_context.getOrLoadDebugTypesData()
+ : m_context.getOrLoadDebugInfoData();
+ lldb::offset_t offset = 0;
+ while (data.ValidOffset(offset)) {
+ llvm::Expected<DWARFUnitSP> unit_sp =
+ DWARFUnit::extract(m_dwarf, m_units.size(), data, section, &offset);
+
+ if (!unit_sp) {
+ // FIXME: Propagate this error up.
+ llvm::consumeError(unit_sp.takeError());
+ return;
}
- const bool minimize = true;
- m_cu_aranges_ap->Sort(minimize);
- }
- return *m_cu_aranges_ap.get();
-}
+ // If it didn't return an error, then it should be returning a valid Unit.
+ assert(*unit_sp);
+ m_units.push_back(*unit_sp);
+ offset = (*unit_sp)->GetNextUnitOffset();
-void DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() {
- if (m_compile_units.empty()) {
- if (m_dwarf2Data != NULL) {
- lldb::offset_t offset = 0;
- DWARFUnitSP cu_sp;
- const auto &debug_info_data = m_dwarf2Data->get_debug_info_data();
- while ((cu_sp = DWARFCompileUnit::Extract(m_dwarf2Data, debug_info_data,
- &offset))) {
- m_compile_units.push_back(cu_sp);
-
- offset = cu_sp->GetNextCompileUnitOffset();
- }
+ if (auto *type_unit = llvm::dyn_cast<DWARFTypeUnit>(unit_sp->get())) {
+ m_type_hash_to_unit_index.emplace_back(type_unit->GetTypeHash(),
+ unit_sp.get()->GetID());
}
}
}
-size_t DWARFDebugInfo::GetNumCompileUnits() {
- ParseCompileUnitHeadersIfNeeded();
- return m_compile_units.size();
-}
+void DWARFDebugInfo::ParseUnitHeadersIfNeeded() {
+ if (!m_units.empty())
+ return;
-DWARFUnit *DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx) {
- DWARFUnit *cu = NULL;
- if (idx < GetNumCompileUnits())
- cu = m_compile_units[idx].get();
- return cu;
+ ParseUnitsFor(DIERef::Section::DebugInfo);
+ ParseUnitsFor(DIERef::Section::DebugTypes);
+ llvm::sort(m_type_hash_to_unit_index, llvm::less_first());
}
-bool DWARFDebugInfo::ContainsCompileUnit(const DWARFUnit *cu) const {
- // Not a verify efficient function, but it is handy for use in assertions to
- // make sure that a compile unit comes from a debug information file.
- CompileUnitColl::const_iterator end_pos = m_compile_units.end();
- CompileUnitColl::const_iterator pos;
+size_t DWARFDebugInfo::GetNumUnits() {
+ ParseUnitHeadersIfNeeded();
+ return m_units.size();
+}
- for (pos = m_compile_units.begin(); pos != end_pos; ++pos) {
- if (pos->get() == cu)
- return true;
- }
- return false;
+DWARFUnit *DWARFDebugInfo::GetUnitAtIndex(user_id_t idx) {
+ DWARFUnit *cu = nullptr;
+ if (idx < GetNumUnits())
+ cu = m_units[idx].get();
+ return cu;
}
-bool DWARFDebugInfo::OffsetLessThanCompileUnitOffset(
- dw_offset_t offset, const DWARFUnitSP &cu_sp) {
- return offset < cu_sp->GetOffset();
+uint32_t DWARFDebugInfo::FindUnitIndex(DIERef::Section section,
+ dw_offset_t offset) {
+ ParseUnitHeadersIfNeeded();
+
+ // llvm::lower_bound is not used as for DIE offsets it would still return
+ // index +1 and GetOffset() returning index itself would be a special case.
+ auto pos = llvm::upper_bound(
+ m_units, std::make_pair(section, offset),
+ [](const std::pair<DIERef::Section, dw_offset_t> &lhs,
+ const DWARFUnitSP &rhs) {
+ return lhs < std::make_pair(rhs->GetDebugSection(), rhs->GetOffset());
+ });
+ uint32_t idx = std::distance(m_units.begin(), pos);
+ if (idx == 0)
+ return DW_INVALID_OFFSET;
+ return idx - 1;
}
-DWARFUnit *DWARFDebugInfo::GetCompileUnit(dw_offset_t cu_offset,
- uint32_t *idx_ptr) {
- DWARFUnitSP cu_sp;
- uint32_t cu_idx = DW_INVALID_INDEX;
- if (cu_offset != DW_INVALID_OFFSET) {
- ParseCompileUnitHeadersIfNeeded();
-
- // Watch out for single compile unit executable as they are pretty common
- const size_t num_cus = m_compile_units.size();
- if (num_cus == 1) {
- if (m_compile_units[0]->GetOffset() == cu_offset) {
- cu_sp = m_compile_units[0];
- cu_idx = 0;
- }
- } else if (num_cus) {
- CompileUnitColl::const_iterator end_pos = m_compile_units.end();
- CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
- CompileUnitColl::const_iterator pos = std::upper_bound(
- begin_pos, end_pos, cu_offset, OffsetLessThanCompileUnitOffset);
- if (pos != begin_pos) {
- --pos;
- if ((*pos)->GetOffset() == cu_offset) {
- cu_sp = *pos;
- cu_idx = std::distance(begin_pos, pos);
- }
- }
- }
+DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section section,
+ dw_offset_t cu_offset,
+ uint32_t *idx_ptr) {
+ uint32_t idx = FindUnitIndex(section, cu_offset);
+ DWARFUnit *result = GetUnitAtIndex(idx);
+ if (result && result->GetOffset() != cu_offset) {
+ result = nullptr;
+ idx = DW_INVALID_INDEX;
}
if (idx_ptr)
- *idx_ptr = cu_idx;
- return cu_sp.get();
+ *idx_ptr = idx;
+ return result;
}
-DWARFUnit *DWARFDebugInfo::GetCompileUnit(const DIERef &die_ref) {
- if (die_ref.cu_offset == DW_INVALID_OFFSET)
- return GetCompileUnitContainingDIEOffset(die_ref.die_offset);
- else
- return GetCompileUnit(die_ref.cu_offset);
+DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef &die_ref) {
+ return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
}
DWARFUnit *
-DWARFDebugInfo::GetCompileUnitContainingDIEOffset(dw_offset_t die_offset) {
- ParseCompileUnitHeadersIfNeeded();
-
- DWARFUnitSP cu_sp;
-
- // Watch out for single compile unit executable as they are pretty common
- const size_t num_cus = m_compile_units.size();
- if (num_cus == 1) {
- if (m_compile_units[0]->ContainsDIEOffset(die_offset))
- return m_compile_units[0].get();
- } else if (num_cus) {
- CompileUnitColl::const_iterator end_pos = m_compile_units.end();
- CompileUnitColl::const_iterator begin_pos = m_compile_units.begin();
- CompileUnitColl::const_iterator pos = std::upper_bound(
- begin_pos, end_pos, die_offset, OffsetLessThanCompileUnitOffset);
- if (pos != begin_pos) {
- --pos;
- if ((*pos)->ContainsDIEOffset(die_offset))
- return (*pos).get();
- }
- }
+DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section,
+ dw_offset_t die_offset) {
+ uint32_t idx = FindUnitIndex(section, die_offset);
+ DWARFUnit *result = GetUnitAtIndex(idx);
+ if (result && !result->ContainsDIEOffset(die_offset))
+ return nullptr;
+ return result;
+}
+
+DWARFTypeUnit *DWARFDebugInfo::GetTypeUnitForHash(uint64_t hash) {
+ auto pos = llvm::lower_bound(m_type_hash_to_unit_index,
+ std::make_pair(hash, 0u), llvm::less_first());
+ if (pos == m_type_hash_to_unit_index.end() || pos->first != hash)
+ return nullptr;
+ return llvm::cast<DWARFTypeUnit>(GetUnitAtIndex(pos->second));
+}
- return nullptr;
+bool DWARFDebugInfo::ContainsTypeUnits() {
+ ParseUnitHeadersIfNeeded();
+ return !m_type_hash_to_unit_index.empty();
}
DWARFDIE
-DWARFDebugInfo::GetDIEForDIEOffset(dw_offset_t die_offset) {
- DWARFUnit *cu = GetCompileUnitContainingDIEOffset(die_offset);
+DWARFDebugInfo::GetDIEForDIEOffset(DIERef::Section section,
+ dw_offset_t die_offset) {
+ DWARFUnit *cu = GetUnitContainingDIEOffset(section, die_offset);
if (cu)
return cu->GetDIE(die_offset);
return DWARFDIE();
}
-//----------------------------------------------------------------------
// GetDIE()
//
// Get the DIE (Debug Information Entry) with the specified offset.
-//----------------------------------------------------------------------
DWARFDIE
DWARFDebugInfo::GetDIE(const DIERef &die_ref) {
- DWARFUnit *cu = GetCompileUnit(die_ref);
+ DWARFUnit *cu = GetUnit(die_ref);
if (cu)
- return cu->GetDIE(die_ref.die_offset);
+ return cu->GetDIE(die_ref.die_offset());
return DWARFDIE(); // Not found
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index fc6085f99a218..d1b066ffe80cb 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -1,9 +1,8 @@
//===-- DWARFDebugInfo.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,11 +12,17 @@
#include <map>
#include <vector>
-#include "DWARFUnit.h"
#include "DWARFDIE.h"
+#include "DWARFTypeUnit.h"
+#include "DWARFUnit.h"
#include "SymbolFileDWARF.h"
#include "lldb/Core/STLUtils.h"
#include "lldb/lldb-private.h"
+#include "llvm/Support/Error.h"
+
+namespace lldb_private {
+class DWARFContext;
+}
typedef std::multimap<const char *, dw_offset_t, CStringCompareFunctionObject>
CStringToDIEMap;
@@ -32,16 +37,20 @@ public:
const dw_offset_t next_offset,
const uint32_t depth, void *userData);
- DWARFDebugInfo();
- void SetDwarfData(SymbolFileDWARF *dwarf2Data);
+ explicit DWARFDebugInfo(SymbolFileDWARF &dwarf,
+ lldb_private::DWARFContext &context);
- size_t GetNumCompileUnits();
- bool ContainsCompileUnit(const DWARFUnit *cu) const;
- DWARFUnit *GetCompileUnitAtIndex(uint32_t idx);
- DWARFUnit *GetCompileUnit(dw_offset_t cu_offset, uint32_t *idx_ptr = NULL);
- DWARFUnit *GetCompileUnitContainingDIEOffset(dw_offset_t die_offset);
- DWARFUnit *GetCompileUnit(const DIERef &die_ref);
- DWARFDIE GetDIEForDIEOffset(dw_offset_t die_offset);
+ size_t GetNumUnits();
+ DWARFUnit *GetUnitAtIndex(lldb::user_id_t idx);
+ DWARFUnit *GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset,
+ uint32_t *idx_ptr = nullptr);
+ DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section,
+ dw_offset_t die_offset);
+ DWARFUnit *GetUnit(const DIERef &die_ref);
+ DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash);
+ bool ContainsTypeUnits();
+ DWARFDIE GetDIEForDIEOffset(DIERef::Section section,
+ dw_offset_t die_offset);
DWARFDIE GetDIE(const DIERef &die_ref);
enum {
@@ -51,26 +60,27 @@ public:
(1 << 2) // Show all parent DIEs when dumping single DIEs
};
- DWARFDebugAranges &GetCompileUnitAranges();
+ llvm::Expected<DWARFDebugAranges &> GetCompileUnitAranges();
protected:
- static bool OffsetLessThanCompileUnitOffset(dw_offset_t offset,
- const DWARFUnitSP &cu_sp);
+ typedef std::vector<DWARFUnitSP> UnitColl;
- typedef std::vector<DWARFUnitSP> CompileUnitColl;
-
- //----------------------------------------------------------------------
- // Member variables
- //----------------------------------------------------------------------
- SymbolFileDWARF *m_dwarf2Data;
- CompileUnitColl m_compile_units;
+ SymbolFileDWARF &m_dwarf;
+ lldb_private::DWARFContext &m_context;
+ UnitColl m_units;
std::unique_ptr<DWARFDebugAranges>
- m_cu_aranges_ap; // A quick address to compile unit table
+ m_cu_aranges_up; // A quick address to compile unit table
+
+ std::vector<std::pair<uint64_t, uint32_t>> m_type_hash_to_unit_index;
private:
// All parsing needs to be done partially any managed by this class as
// accessors are called.
- void ParseCompileUnitHeadersIfNeeded();
+ void ParseUnitHeadersIfNeeded();
+
+ void ParseUnitsFor(DIERef::Section section);
+
+ uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset);
DISALLOW_COPY_AND_ASSIGN(DWARFDebugInfo);
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 7531aeac709a2..2f55b7d40ed9e 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDebugInfoEntry.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,19 +12,21 @@
#include <algorithm>
+#include "llvm/Support/LEB128.h"
+
#include "lldb/Core/Module.h"
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/Stream.h"
-#include "DWARFUnit.h"
-#include "DWARFDIECollection.h"
+#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
#include "DWARFDebugRanges.h"
#include "DWARFDeclContext.h"
#include "DWARFFormValue.h"
+#include "DWARFUnit.h"
#include "SymbolFileDWARF.h"
#include "SymbolFileDWARFDwo.h"
@@ -33,14 +34,15 @@ using namespace lldb_private;
using namespace std;
extern int g_verbose;
-bool DWARFDebugInfoEntry::FastExtract(
- const DWARFDataExtractor &debug_info_data, const DWARFUnit *cu,
- const DWARFFormValue::FixedFormSizes &fixed_form_sizes,
- lldb::offset_t *offset_ptr) {
+// Extract a debug info entry for a given DWARFUnit from the data
+// starting at the offset in offset_ptr
+bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor &data,
+ const DWARFUnit *cu,
+ lldb::offset_t *offset_ptr) {
m_offset = *offset_ptr;
m_parent_idx = 0;
m_sibling_idx = 0;
- const uint64_t abbr_idx = debug_info_data.GetULEB128(offset_ptr);
+ const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
lldbassert(abbr_idx <= UINT16_MAX);
m_abbr_idx = abbr_idx;
@@ -49,12 +51,9 @@ bool DWARFDebugInfoEntry::FastExtract(
if (m_abbr_idx) {
lldb::offset_t offset = *offset_ptr;
-
- const DWARFAbbreviationDeclaration *abbrevDecl =
- cu->GetAbbreviations()->GetAbbreviationDeclaration(m_abbr_idx);
-
- if (abbrevDecl == NULL) {
- cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
+ const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
+ if (abbrevDecl == nullptr) {
+ cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
"{0x%8.8x}: invalid abbreviation code %u, please file a bug and "
"attach the file at the start of this error message",
m_offset, (unsigned)abbr_idx);
@@ -64,16 +63,16 @@ bool DWARFDebugInfoEntry::FastExtract(
}
m_tag = abbrevDecl->Tag();
m_has_children = abbrevDecl->HasChildren();
- // Skip all data in the .debug_info for the attributes
+ // Skip all data in the .debug_info or .debug_types for the attributes
const uint32_t numAttributes = abbrevDecl->NumAttributes();
uint32_t i;
dw_form_t form;
for (i = 0; i < numAttributes; ++i) {
form = abbrevDecl->GetFormByIndexUnchecked(i);
-
- const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
+ llvm::Optional<uint8_t> fixed_skip_size =
+ DWARFFormValue::GetFixedSize(form, cu);
if (fixed_skip_size)
- offset += fixed_skip_size;
+ offset += *fixed_skip_size;
else {
bool form_is_indirect = false;
do {
@@ -81,24 +80,24 @@ bool DWARFDebugInfoEntry::FastExtract(
uint32_t form_size = 0;
switch (form) {
// Blocks if inlined data that have a length field and the data bytes
- // inlined in the .debug_info
+ // inlined in the .debug_info/.debug_types
case DW_FORM_exprloc:
case DW_FORM_block:
- form_size = debug_info_data.GetULEB128(&offset);
+ form_size = data.GetULEB128(&offset);
break;
case DW_FORM_block1:
- form_size = debug_info_data.GetU8_unchecked(&offset);
+ form_size = data.GetU8_unchecked(&offset);
break;
case DW_FORM_block2:
- form_size = debug_info_data.GetU16_unchecked(&offset);
+ form_size = data.GetU16_unchecked(&offset);
break;
case DW_FORM_block4:
- form_size = debug_info_data.GetU32_unchecked(&offset);
+ form_size = data.GetU32_unchecked(&offset);
break;
// Inlined NULL terminated C-strings
case DW_FORM_string:
- debug_info_data.GetCStr(&offset);
+ data.GetCStr(&offset);
break;
// Compile unit address sized values
@@ -109,7 +108,7 @@ bool DWARFDebugInfoEntry::FastExtract(
if (cu->GetVersion() <= 2)
form_size = cu->GetAddressByteSize();
else
- form_size = cu->IsDWARF64() ? 8 : 4;
+ form_size = 4;
break;
// 0 sized form
@@ -164,20 +163,17 @@ bool DWARFDebugInfoEntry::FastExtract(
case DW_FORM_GNU_addr_index:
case DW_FORM_GNU_str_index:
case DW_FORM_strx:
- debug_info_data.Skip_LEB128(&offset);
+ data.Skip_LEB128(&offset);
break;
case DW_FORM_indirect:
form_is_indirect = true;
- form = debug_info_data.GetULEB128(&offset);
+ form = data.GetULEB128(&offset);
break;
case DW_FORM_strp:
case DW_FORM_sec_offset:
- if (cu->IsDWARF64())
- debug_info_data.GetU64(&offset);
- else
- debug_info_data.GetU32(&offset);
+ data.GetU32(&offset);
break;
case DW_FORM_implicit_const:
@@ -204,233 +200,48 @@ bool DWARFDebugInfoEntry::FastExtract(
return false;
}
-//----------------------------------------------------------------------
-// Extract
-//
-// Extract a debug info entry for a given compile unit from the .debug_info and
-// .debug_abbrev data within the SymbolFileDWARF class starting at the given
-// offset
-//----------------------------------------------------------------------
-bool DWARFDebugInfoEntry::Extract(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
- lldb::offset_t *offset_ptr) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
- // const DWARFDataExtractor& debug_str_data =
- // dwarf2Data->get_debug_str_data();
- const uint32_t cu_end_offset = cu->GetNextCompileUnitOffset();
- lldb::offset_t offset = *offset_ptr;
- // if (offset >= cu_end_offset)
- // Log::Status("DIE at offset 0x%8.8x is beyond the end of the current
- // compile unit (0x%8.8x)", m_offset, cu_end_offset);
- if ((offset < cu_end_offset) && debug_info_data.ValidOffset(offset)) {
- m_offset = offset;
-
- const uint64_t abbr_idx = debug_info_data.GetULEB128(&offset);
- lldbassert(abbr_idx <= UINT16_MAX);
- m_abbr_idx = abbr_idx;
- if (abbr_idx) {
- const DWARFAbbreviationDeclaration *abbrevDecl =
- cu->GetAbbreviations()->GetAbbreviationDeclaration(abbr_idx);
-
- if (abbrevDecl) {
- m_tag = abbrevDecl->Tag();
- m_has_children = abbrevDecl->HasChildren();
-
- bool isCompileUnitTag = (m_tag == DW_TAG_compile_unit ||
- m_tag == DW_TAG_partial_unit);
- if (cu && isCompileUnitTag)
- const_cast<DWARFUnit *>(cu)->SetBaseAddress(0);
-
- // Skip all data in the .debug_info for the attributes
- const uint32_t numAttributes = abbrevDecl->NumAttributes();
- for (uint32_t i = 0; i < numAttributes; ++i) {
- DWARFFormValue form_value(cu);
- dw_attr_t attr;
- abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
- dw_form_t form = form_value.Form();
-
- if (isCompileUnitTag &&
- ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) {
- if (form_value.ExtractValue(debug_info_data, &offset)) {
- if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
- const_cast<DWARFUnit *>(cu)->SetBaseAddress(
- form_value.Address());
- }
- } else {
- bool form_is_indirect = false;
- do {
- form_is_indirect = false;
- uint32_t form_size = 0;
- switch (form) {
- // Blocks if inlined data that have a length field and the data
- // bytes inlined in the .debug_info
- case DW_FORM_exprloc:
- case DW_FORM_block:
- form_size = debug_info_data.GetULEB128(&offset);
- break;
- case DW_FORM_block1:
- form_size = debug_info_data.GetU8(&offset);
- break;
- case DW_FORM_block2:
- form_size = debug_info_data.GetU16(&offset);
- break;
- case DW_FORM_block4:
- form_size = debug_info_data.GetU32(&offset);
- break;
-
- // Inlined NULL terminated C-strings
- case DW_FORM_string:
- debug_info_data.GetCStr(&offset);
- break;
-
- // Compile unit address sized values
- case DW_FORM_addr:
- form_size = cu->GetAddressByteSize();
- break;
- case DW_FORM_ref_addr:
- if (cu->GetVersion() <= 2)
- form_size = cu->GetAddressByteSize();
- else
- form_size = cu->IsDWARF64() ? 8 : 4;
- break;
-
- // 0 sized form
- case DW_FORM_flag_present:
- case DW_FORM_implicit_const:
- form_size = 0;
- break;
-
- // 1 byte values
- case DW_FORM_data1:
- case DW_FORM_flag:
- case DW_FORM_ref1:
- form_size = 1;
- break;
-
- // 2 byte values
- case DW_FORM_data2:
- case DW_FORM_ref2:
- form_size = 2;
- break;
-
- // 4 byte values
- case DW_FORM_data4:
- case DW_FORM_ref4:
- form_size = 4;
- break;
-
- // 8 byte values
- case DW_FORM_data8:
- case DW_FORM_ref8:
- case DW_FORM_ref_sig8:
- form_size = 8;
- break;
-
- // signed or unsigned LEB 128 values
- case DW_FORM_sdata:
- case DW_FORM_udata:
- case DW_FORM_ref_udata:
- case DW_FORM_GNU_addr_index:
- case DW_FORM_GNU_str_index:
- debug_info_data.Skip_LEB128(&offset);
- break;
-
- case DW_FORM_indirect:
- form = debug_info_data.GetULEB128(&offset);
- form_is_indirect = true;
- break;
-
- case DW_FORM_strp:
- case DW_FORM_sec_offset:
- if (cu->IsDWARF64())
- debug_info_data.GetU64(&offset);
- else
- debug_info_data.GetU32(&offset);
- break;
-
- default:
- *offset_ptr = offset;
- return false;
- }
-
- offset += form_size;
- } while (form_is_indirect);
- }
- }
- *offset_ptr = offset;
- return true;
- }
- } else {
- m_tag = 0;
- m_has_children = false;
- *offset_ptr = offset;
- return true; // NULL debug tag entry
- }
- }
-
- return false;
-}
-
-//----------------------------------------------------------------------
-// DumpAncestry
-//
-// Dumps all of a debug information entries parents up until oldest and all of
-// it's attributes to the specified stream.
-//----------------------------------------------------------------------
-void DWARFDebugInfoEntry::DumpAncestry(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
- const DWARFDebugInfoEntry *oldest,
- Stream &s,
- uint32_t recurse_depth) const {
- const DWARFDebugInfoEntry *parent = GetParent();
- if (parent && parent != oldest)
- parent->DumpAncestry(dwarf2Data, cu, oldest, s, 0);
- Dump(dwarf2Data, cu, s, recurse_depth);
+static DWARFRangeList GetRangesOrReportError(const DWARFUnit &unit,
+ const DWARFDebugInfoEntry &die,
+ const DWARFFormValue &value) {
+ llvm::Expected<DWARFRangeList> expected_ranges =
+ (value.Form() == DW_FORM_rnglistx)
+ ? unit.FindRnglistFromIndex(value.Unsigned())
+ : unit.FindRnglistFromOffset(value.Unsigned());
+ if (expected_ranges)
+ return std::move(*expected_ranges);
+ unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+ "{0x%8.8x}: DIE has DW_AT_ranges(0x%" PRIx64 ") attribute, but "
+ "range extraction failed (%s), please file a bug "
+ "and attach the file at the start of this error message",
+ die.GetOffset(), value.Unsigned(),
+ toString(expected_ranges.takeError()).c_str());
+ return DWARFRangeList();
}
-static dw_offset_t GetRangesOffset(const DWARFDebugRangesBase *debug_ranges,
- DWARFFormValue &form_value) {
- if (form_value.Form() == DW_FORM_rnglistx)
- return debug_ranges->GetOffset(form_value.Unsigned());
- return form_value.Unsigned();
-}
-
-//----------------------------------------------------------------------
// GetDIENamesAndRanges
//
// Gets the valid address ranges for a given DIE by looking for a
// DW_AT_low_pc/DW_AT_high_pc pair, DW_AT_entry_pc, or DW_AT_ranges attributes.
-//----------------------------------------------------------------------
bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, const char *&name,
- const char *&mangled, DWARFRangeList &ranges, int &decl_file,
- int &decl_line, int &decl_column, int &call_file, int &call_line,
- int &call_column, DWARFExpression *frame_base) const {
- if (dwarf2Data == nullptr)
- return false;
-
- SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
- if (dwo_symbol_file)
- return GetDIENamesAndRanges(
- dwo_symbol_file, dwo_symbol_file->GetCompileUnit(), name, mangled,
- ranges, decl_file, decl_line, decl_column, call_file, call_line,
- call_column, frame_base);
-
+ const DWARFUnit *cu, const char *&name, const char *&mangled,
+ DWARFRangeList &ranges, int &decl_file, int &decl_line, int &decl_column,
+ int &call_file, int &call_line, int &call_column,
+ DWARFExpression *frame_base) const {
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- std::vector<DIERef> die_refs;
+ std::vector<DWARFDIE> dies;
bool set_frame_base_loclist_addr = false;
- lldb::offset_t offset;
- const DWARFAbbreviationDeclaration *abbrevDecl =
- GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
+ const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
- lldb::ModuleSP module = dwarf2Data->GetObjectFile()->GetModule();
+ SymbolFileDWARF &dwarf = cu->GetSymbolFileDWARF();
+ lldb::ModuleSP module = dwarf.GetObjectFile()->GetModule();
if (abbrevDecl) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
+ lldb::offset_t offset = GetFirstAttributeOffset();
- if (!debug_info_data.ValidOffset(offset))
+ if (!data.ValidOffset(offset))
return false;
const uint32_t numAttributes = abbrevDecl->NumAttributes();
@@ -441,7 +252,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
dw_attr_t attr;
abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
- if (form_value.ExtractValue(debug_info_data, &offset)) {
+ if (form_value.ExtractValue(data, &offset)) {
switch (attr) {
case DW_AT_low_pc:
lo_pc = form_value.Address();
@@ -457,6 +268,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
case DW_AT_high_pc:
if (form_value.Form() == DW_FORM_addr ||
+ form_value.Form() == DW_FORM_addrx ||
form_value.Form() == DW_FORM_GNU_addr_index) {
hi_pc = form_value.Address();
} else {
@@ -469,35 +281,27 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
}
break;
- case DW_AT_ranges: {
- const DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges();
- if (debug_ranges)
- debug_ranges->FindRanges(cu, GetRangesOffset(debug_ranges, form_value), ranges);
- else
- cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
- "{0x%8.8x}: DIE has DW_AT_ranges(0x%" PRIx64
- ") attribute yet DWARF has no .debug_ranges, please file a bug "
- "and attach the file at the start of this error message",
- m_offset, form_value.Unsigned());
- } break;
+ case DW_AT_ranges:
+ ranges = GetRangesOrReportError(*cu, *this, form_value);
+ break;
case DW_AT_name:
- if (name == NULL)
+ if (name == nullptr)
name = form_value.AsCString();
break;
case DW_AT_MIPS_linkage_name:
case DW_AT_linkage_name:
- if (mangled == NULL)
+ if (mangled == nullptr)
mangled = form_value.AsCString();
break;
case DW_AT_abstract_origin:
- die_refs.emplace_back(form_value);
+ dies.push_back(form_value.Reference());
break;
case DW_AT_specification:
- die_refs.emplace_back(form_value);
+ dies.push_back(form_value.Reference());
break;
case DW_AT_decl_file:
@@ -534,20 +338,20 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
if (frame_base) {
if (form_value.BlockData()) {
uint32_t block_offset =
- form_value.BlockData() - debug_info_data.GetDataStart();
+ form_value.BlockData() - data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- frame_base->SetOpcodeData(module, debug_info_data, block_offset,
- block_length);
+ *frame_base = DWARFExpression(module, data, cu,
+ block_offset, block_length);
} else {
- const DWARFDataExtractor &debug_loc_data =
- dwarf2Data->DebugLocData();
+ const DWARFDataExtractor &debug_loc_data = dwarf.DebugLocData();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
size_t loc_list_length = DWARFExpression::LocationListSize(
cu, debug_loc_data, debug_loc_offset);
if (loc_list_length > 0) {
- frame_base->SetOpcodeData(module, debug_loc_data,
- debug_loc_offset, loc_list_length);
+ *frame_base =
+ DWARFExpression(module, debug_loc_data, cu,
+ debug_loc_offset, loc_list_length);
if (lo_pc != LLDB_INVALID_ADDRESS) {
assert(lo_pc >= cu->GetBaseAddress());
frame_base->SetLocationListSlide(lo_pc -
@@ -582,56 +386,48 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
frame_base->SetLocationListSlide(lowest_range_pc - cu->GetBaseAddress());
}
- if (ranges.IsEmpty() || name == NULL || mangled == NULL) {
- for (const DIERef &die_ref : die_refs) {
- if (die_ref.die_offset != DW_INVALID_OFFSET) {
- DWARFDIE die = dwarf2Data->GetDIE(die_ref);
- if (die)
- die.GetDIE()->GetDIENamesAndRanges(
- die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file,
- decl_line, decl_column, call_file, call_line, call_column);
+ if (ranges.IsEmpty() || name == nullptr || mangled == nullptr) {
+ for (const DWARFDIE &die : dies) {
+ if (die) {
+ die.GetDIE()->GetDIENamesAndRanges(die.GetCU(), name, mangled, ranges,
+ decl_file, decl_line, decl_column,
+ call_file, call_line, call_column);
}
}
}
return !ranges.IsEmpty();
}
-//----------------------------------------------------------------------
// Dump
//
// Dumps a debug information entry and all of it's attributes to the specified
// stream.
-//----------------------------------------------------------------------
-void DWARFDebugInfoEntry::Dump(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu, Stream &s,
+void DWARFDebugInfoEntry::Dump(const DWARFUnit *cu, Stream &s,
uint32_t recurse_depth) const {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
lldb::offset_t offset = m_offset;
- if (debug_info_data.ValidOffset(offset)) {
- dw_uleb128_t abbrCode = debug_info_data.GetULEB128(&offset);
+ if (data.ValidOffset(offset)) {
+ dw_uleb128_t abbrCode = data.GetULEB128(&offset);
s.Printf("\n0x%8.8x: ", m_offset);
s.Indent();
if (abbrCode != m_abbr_idx) {
s.Printf("error: DWARF has been modified\n");
} else if (abbrCode) {
- const DWARFAbbreviationDeclaration *abbrevDecl =
- cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode);
-
+ const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl) {
s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag()));
s.Printf(" [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*' : ' ');
- // Dump all data in the .debug_info for the attributes
+ // Dump all data in the .debug_info/.debug_types for the attributes
const uint32_t numAttributes = abbrevDecl->NumAttributes();
for (uint32_t i = 0; i < numAttributes; ++i) {
DWARFFormValue form_value(cu);
dw_attr_t attr;
abbrevDecl->GetAttrAndFormValueByIndex(i, attr, form_value);
- DumpAttribute(dwarf2Data, cu, debug_info_data, &offset, s, attr,
- form_value);
+ DumpAttribute(cu, data, &offset, s, attr, form_value);
}
const DWARFDebugInfoEntry *child = GetFirstChild();
@@ -639,7 +435,7 @@ void DWARFDebugInfoEntry::Dump(SymbolFileDWARF *dwarf2Data,
s.IndentMore();
while (child) {
- child->Dump(dwarf2Data, cu, s, recurse_depth - 1);
+ child->Dump(cu, s, recurse_depth - 1);
child = child->GetSibling();
}
s.IndentLess();
@@ -654,34 +450,15 @@ void DWARFDebugInfoEntry::Dump(SymbolFileDWARF *dwarf2Data,
}
}
-void DWARFDebugInfoEntry::DumpLocation(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu, Stream &s) const {
- const DWARFBaseDIE cu_die = cu->GetUnitDIEOnly();
- const char *cu_name = NULL;
- if (cu_die)
- cu_name = cu_die.GetName();
- const char *obj_file_name = NULL;
- ObjectFile *obj_file = dwarf2Data->GetObjectFile();
- if (obj_file)
- obj_file_name =
- obj_file->GetFileSpec().GetFilename().AsCString("<Unknown>");
- const char *die_name = GetName(dwarf2Data, cu);
- s.Printf("0x%8.8x/0x%8.8x: %-30s (from %s in %s)", cu->GetOffset(),
- GetOffset(), die_name ? die_name : "", cu_name ? cu_name : "<NULL>",
- obj_file_name ? obj_file_name : "<NULL>");
-}
-
-//----------------------------------------------------------------------
// DumpAttribute
//
// Dumps a debug information entry attribute along with it's form. Any special
// display of attributes is done (disassemble location lists, show enumeration
// values for attributes, etc).
-//----------------------------------------------------------------------
void DWARFDebugInfoEntry::DumpAttribute(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr,
- Stream &s, dw_attr_t attr, DWARFFormValue &form_value) {
+ const DWARFUnit *cu, const DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr, Stream &s, dw_attr_t attr,
+ DWARFFormValue &form_value) {
bool show_form = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
s.Printf(" ");
@@ -691,7 +468,7 @@ void DWARFDebugInfoEntry::DumpAttribute(
s.Printf("[%s", DW_FORM_value_to_name(form_value.Form()));
}
- if (!form_value.ExtractValue(debug_info_data, offset_ptr))
+ if (!form_value.ExtractValue(data, offset_ptr))
return;
if (show_form) {
@@ -704,6 +481,8 @@ void DWARFDebugInfoEntry::DumpAttribute(
s.PutCString("( ");
+ SymbolFileDWARF &dwarf = cu->GetSymbolFileDWARF();
+
// Check to see if we have any special attribute formatters
switch (attr) {
case DW_AT_stmt_list:
@@ -724,7 +503,7 @@ void DWARFDebugInfoEntry::DumpAttribute(
const uint8_t *blockData = form_value.BlockData();
if (blockData) {
// Location description is inlined in data in the form value
- DWARFDataExtractor locationData(debug_info_data,
+ DWARFDataExtractor locationData(data,
(*offset_ptr) - form_value.Unsigned(),
form_value.Unsigned());
DWARFExpression::PrintDWARFExpression(
@@ -733,38 +512,26 @@ void DWARFDebugInfoEntry::DumpAttribute(
// We have a location list offset as the value that is the offset into
// the .debug_loc section that describes the value over it's lifetime
uint64_t debug_loc_offset = form_value.Unsigned();
- if (dwarf2Data) {
- DWARFExpression::PrintDWARFLocationList(
- s, cu, dwarf2Data->DebugLocData(), debug_loc_offset);
- }
+ DWARFExpression::PrintDWARFLocationList(s, cu, dwarf.DebugLocData(),
+ debug_loc_offset);
}
} break;
case DW_AT_abstract_origin:
case DW_AT_specification: {
- uint64_t abstract_die_offset = form_value.Reference();
+ DWARFDIE abstract_die = form_value.Reference();
form_value.Dump(s);
- // *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
- GetName(dwarf2Data, cu, abstract_die_offset, s);
+ // *ostrm_ptr << HEX32 << abstract_die.GetOffset() << " ( ";
+ abstract_die.GetName(s);
} break;
case DW_AT_type: {
- uint64_t type_die_offset = form_value.Reference();
+ DWARFDIE type_die = form_value.Reference();
s.PutCString(" ( ");
- AppendTypeName(dwarf2Data, cu, type_die_offset, s);
+ type_die.AppendTypeName(s);
s.PutCString(" )");
} break;
- case DW_AT_ranges: {
- if (!dwarf2Data)
- break;
- lldb::offset_t ranges_offset =
- GetRangesOffset(dwarf2Data->DebugRanges(), form_value);
- dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
- DWARFDebugRanges::Dump(s, dwarf2Data->get_debug_ranges_data(),
- &ranges_offset, base_addr);
- } break;
-
default:
break;
}
@@ -772,36 +539,17 @@ void DWARFDebugInfoEntry::DumpAttribute(
s.PutCString(" )\n");
}
-//----------------------------------------------------------------------
// Get all attribute values for a given DIE, including following any
// specification or abstract origin attributes and including those in the
// results. Any duplicate attributes will have the first instance take
// precedence (this can happen for declaration attributes).
-//----------------------------------------------------------------------
size_t DWARFDebugInfoEntry::GetAttributes(
- const DWARFUnit *cu, DWARFFormValue::FixedFormSizes fixed_form_sizes,
- DWARFAttributes &attributes, uint32_t curr_depth) const {
- SymbolFileDWARF *dwarf2Data = nullptr;
- const DWARFAbbreviationDeclaration *abbrevDecl = nullptr;
- lldb::offset_t offset = 0;
- if (cu) {
- if (m_tag != DW_TAG_compile_unit && m_tag != DW_TAG_partial_unit) {
- SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
- if (dwo_symbol_file)
- return GetAttributes(dwo_symbol_file->GetCompileUnit(),
- fixed_form_sizes, attributes, curr_depth);
- }
-
- dwarf2Data = cu->GetSymbolFileDWARF();
- abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
- }
-
+ const DWARFUnit *cu, DWARFAttributes &attributes,
+ uint32_t curr_depth) const {
+ const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
if (abbrevDecl) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
-
- if (fixed_form_sizes.Empty())
- fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(
- cu->GetAddressByteSize(), cu->IsDWARF64());
+ const DWARFDataExtractor &data = cu->GetData();
+ lldb::offset_t offset = GetFirstAttributeOffset();
const uint32_t num_attributes = abbrevDecl->NumAttributes();
for (uint32_t i = 0; i < num_attributes; ++i) {
@@ -829,19 +577,17 @@ size_t DWARFDebugInfoEntry::GetAttributes(
}
if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin)) {
- if (form_value.ExtractValue(debug_info_data, &offset)) {
- dw_offset_t die_offset = form_value.Reference();
- DWARFDIE spec_die =
- const_cast<DWARFUnit *>(cu)->GetDIE(die_offset);
+ if (form_value.ExtractValue(data, &offset)) {
+ DWARFDIE spec_die = form_value.Reference();
if (spec_die)
spec_die.GetAttributes(attributes, curr_depth + 1);
}
} else {
- const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
+ llvm::Optional<uint8_t> fixed_skip_size = DWARFFormValue::GetFixedSize(form, cu);
if (fixed_skip_size)
- offset += fixed_skip_size;
+ offset += *fixed_skip_size;
else
- DWARFFormValue::SkipValue(form, debug_info_data, &offset, cu);
+ DWARFFormValue::SkipValue(form, data, &offset, cu);
}
}
} else {
@@ -850,45 +596,32 @@ size_t DWARFDebugInfoEntry::GetAttributes(
return attributes.Size();
}
-//----------------------------------------------------------------------
// GetAttributeValue
//
-// Get the value of an attribute and return the .debug_info offset of the
-// attribute if it was properly extracted into form_value, or zero if we fail
-// since an offset of zero is invalid for an attribute (it would be a compile
-// unit header).
-//----------------------------------------------------------------------
+// Get the value of an attribute and return the .debug_info or .debug_types
+// offset of the attribute if it was properly extracted into form_value,
+// or zero if we fail since an offset of zero is invalid for an attribute (it
+// would be a compile unit header).
dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, DWARFFormValue &form_value,
+ const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &form_value,
dw_offset_t *end_attr_offset_ptr,
bool check_specification_or_abstract_origin) const {
- SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
- if (dwo_symbol_file && m_tag != DW_TAG_compile_unit &&
- m_tag != DW_TAG_partial_unit)
- return GetAttributeValue(dwo_symbol_file, dwo_symbol_file->GetCompileUnit(),
- attr, form_value, end_attr_offset_ptr,
- check_specification_or_abstract_origin);
-
- lldb::offset_t offset;
- const DWARFAbbreviationDeclaration *abbrevDecl =
- GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
-
- if (abbrevDecl) {
+ if (const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) {
uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr);
if (attr_idx != DW_INVALID_INDEX) {
- const DWARFDataExtractor &debug_info_data = cu->GetData();
+ const DWARFDataExtractor &data = cu->GetData();
+ lldb::offset_t offset = GetFirstAttributeOffset();
uint32_t idx = 0;
while (idx < attr_idx)
DWARFFormValue::SkipValue(abbrevDecl->GetFormByIndex(idx++),
- debug_info_data, &offset, cu);
+ data, &offset, cu);
const dw_offset_t attr_offset = offset;
- form_value.SetCompileUnit(cu);
+ form_value.SetUnit(cu);
form_value.SetForm(abbrevDecl->GetFormByIndex(idx));
- if (form_value.ExtractValue(debug_info_data, &offset)) {
+ if (form_value.ExtractValue(data, &offset)) {
if (end_attr_offset_ptr)
*end_attr_offset_ptr = offset;
return attr_offset;
@@ -897,35 +630,35 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
}
if (check_specification_or_abstract_origin) {
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value)) {
- DWARFDIE die =
- const_cast<DWARFUnit *>(cu)->GetDIE(form_value.Reference());
+ if (GetAttributeValue(cu, DW_AT_specification, form_value)) {
+ DWARFDIE die = form_value.Reference();
if (die) {
dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(
- die.GetDWARF(), die.GetCU(), attr, form_value, end_attr_offset_ptr,
- false);
+ die.GetCU(), attr, form_value, end_attr_offset_ptr, false);
if (die_offset)
return die_offset;
}
}
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value)) {
- DWARFDIE die =
- const_cast<DWARFUnit *>(cu)->GetDIE(form_value.Reference());
+ if (GetAttributeValue(cu, DW_AT_abstract_origin, form_value)) {
+ DWARFDIE die = form_value.Reference();
if (die) {
dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(
- die.GetDWARF(), die.GetCU(), attr, form_value, end_attr_offset_ptr,
- false);
+ die.GetCU(), attr, form_value, end_attr_offset_ptr, false);
if (die_offset)
return die_offset;
}
}
}
+ // If we're a unit DIE, also check the attributes of the dwo unit (if any).
+ if (GetParent())
+ return 0;
+ SymbolFileDWARFDwo *dwo_symbol_file = cu->GetDwoSymbolFile();
if (!dwo_symbol_file)
return 0;
- DWARFUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
+ DWARFCompileUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
if (!dwo_cu)
return 0;
@@ -934,105 +667,78 @@ dw_offset_t DWARFDebugInfoEntry::GetAttributeValue(
return 0;
return dwo_cu_die.GetDIE()->GetAttributeValue(
- dwo_symbol_file, dwo_cu, attr, form_value, end_attr_offset_ptr,
+ dwo_cu, attr, form_value, end_attr_offset_ptr,
check_specification_or_abstract_origin);
}
-//----------------------------------------------------------------------
// GetAttributeValueAsString
//
// Get the value of an attribute as a string return it. The resulting pointer
// to the string data exists within the supplied SymbolFileDWARF and will only
// be available as long as the SymbolFileDWARF is still around and it's content
// doesn't change.
-//----------------------------------------------------------------------
const char *DWARFDebugInfoEntry::GetAttributeValueAsString(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, const char *fail_value,
+ const DWARFUnit *cu, const dw_attr_t attr, const char *fail_value,
bool check_specification_or_abstract_origin) const {
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
+ if (GetAttributeValue(cu, attr, form_value, nullptr,
check_specification_or_abstract_origin))
return form_value.AsCString();
return fail_value;
}
-//----------------------------------------------------------------------
// GetAttributeValueAsUnsigned
//
// Get the value of an attribute as unsigned and return it.
-//----------------------------------------------------------------------
uint64_t DWARFDebugInfoEntry::GetAttributeValueAsUnsigned(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, uint64_t fail_value,
+ const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value,
bool check_specification_or_abstract_origin) const {
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
+ if (GetAttributeValue(cu, attr, form_value, nullptr,
check_specification_or_abstract_origin))
return form_value.Unsigned();
return fail_value;
}
-//----------------------------------------------------------------------
-// GetAttributeValueAsSigned
-//
-// Get the value of an attribute a signed value and return it.
-//----------------------------------------------------------------------
-int64_t DWARFDebugInfoEntry::GetAttributeValueAsSigned(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, int64_t fail_value,
- bool check_specification_or_abstract_origin) const {
- DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
- check_specification_or_abstract_origin))
- return form_value.Signed();
- return fail_value;
-}
-
-//----------------------------------------------------------------------
// GetAttributeValueAsReference
//
// Get the value of an attribute as reference and fix up and compile unit
// relative offsets as needed.
-//----------------------------------------------------------------------
-uint64_t DWARFDebugInfoEntry::GetAttributeValueAsReference(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, uint64_t fail_value,
+DWARFDIE DWARFDebugInfoEntry::GetAttributeValueAsReference(
+ const DWARFUnit *cu, const dw_attr_t attr,
bool check_specification_or_abstract_origin) const {
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
+ if (GetAttributeValue(cu, attr, form_value, nullptr,
check_specification_or_abstract_origin))
return form_value.Reference();
- return fail_value;
+ return {};
}
uint64_t DWARFDebugInfoEntry::GetAttributeValueAsAddress(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, uint64_t fail_value,
+ const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value,
bool check_specification_or_abstract_origin) const {
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr,
+ if (GetAttributeValue(cu, attr, form_value, nullptr,
check_specification_or_abstract_origin))
return form_value.Address();
return fail_value;
}
-//----------------------------------------------------------------------
// GetAttributeHighPC
//
// Get the hi_pc, adding hi_pc to lo_pc when specified as an <offset-from-low-
// pc>.
//
// Returns the hi_pc or fail_value.
-//----------------------------------------------------------------------
dw_addr_t DWARFDebugInfoEntry::GetAttributeHighPC(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, dw_addr_t lo_pc,
- uint64_t fail_value, bool check_specification_or_abstract_origin) const {
+ const DWARFUnit *cu, dw_addr_t lo_pc, uint64_t fail_value,
+ bool check_specification_or_abstract_origin) const {
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr,
+ if (GetAttributeValue(cu, DW_AT_high_pc, form_value, nullptr,
check_specification_or_abstract_origin)) {
dw_form_t form = form_value.Form();
- if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
+ if (form == DW_FORM_addr || form == DW_FORM_addrx ||
+ form == DW_FORM_GNU_addr_index)
return form_value.Address();
// DWARF4 can specify the hi_pc as an <offset-from-lowpc>
@@ -1041,22 +747,19 @@ dw_addr_t DWARFDebugInfoEntry::GetAttributeHighPC(
return fail_value;
}
-//----------------------------------------------------------------------
// GetAttributeAddressRange
//
// Get the lo_pc and hi_pc, adding hi_pc to lo_pc when specified as an <offset-
// from-low-pc>.
//
// Returns true or sets lo_pc and hi_pc to fail_value.
-//----------------------------------------------------------------------
bool DWARFDebugInfoEntry::GetAttributeAddressRange(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, dw_addr_t &lo_pc,
- dw_addr_t &hi_pc, uint64_t fail_value,
- bool check_specification_or_abstract_origin) const {
- lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, fail_value,
+ const DWARFUnit *cu, dw_addr_t &lo_pc, dw_addr_t &hi_pc,
+ uint64_t fail_value, bool check_specification_or_abstract_origin) const {
+ lo_pc = GetAttributeValueAsAddress(cu, DW_AT_low_pc, fail_value,
check_specification_or_abstract_origin);
if (lo_pc != fail_value) {
- hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, fail_value,
+ hi_pc = GetAttributeHighPC(cu, lo_pc, fail_value,
check_specification_or_abstract_origin);
if (hi_pc != fail_value)
return true;
@@ -1067,21 +770,17 @@ bool DWARFDebugInfoEntry::GetAttributeAddressRange(
}
size_t DWARFDebugInfoEntry::GetAttributeAddressRanges(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- DWARFRangeList &ranges, bool check_hi_lo_pc,
+ const DWARFUnit *cu, DWARFRangeList &ranges, bool check_hi_lo_pc,
bool check_specification_or_abstract_origin) const {
ranges.Clear();
DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_ranges, form_value)) {
- if (DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges())
- debug_ranges->FindRanges(cu, GetRangesOffset(debug_ranges, form_value),
- ranges);
+ if (GetAttributeValue(cu, DW_AT_ranges, form_value)) {
+ ranges = GetRangesOrReportError(*cu, *this, form_value);
} else if (check_hi_lo_pc) {
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- if (GetAttributeAddressRange(dwarf2Data, cu, lo_pc, hi_pc,
- LLDB_INVALID_ADDRESS,
+ if (GetAttributeAddressRange(cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS,
check_specification_or_abstract_origin)) {
if (lo_pc < hi_pc)
ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
@@ -1090,250 +789,67 @@ size_t DWARFDebugInfoEntry::GetAttributeAddressRanges(
return ranges.GetSize();
}
-//----------------------------------------------------------------------
// GetName
//
// Get value of the DW_AT_name attribute and return it if one exists, else
// return NULL.
-//----------------------------------------------------------------------
-const char *DWARFDebugInfoEntry::GetName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu) const {
- return GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
+const char *DWARFDebugInfoEntry::GetName(const DWARFUnit *cu) const {
+ return GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
}
-//----------------------------------------------------------------------
// GetMangledName
//
// Get value of the DW_AT_MIPS_linkage_name attribute and return it if one
// exists, else return the value of the DW_AT_name attribute
-//----------------------------------------------------------------------
const char *
-DWARFDebugInfoEntry::GetMangledName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
+DWARFDebugInfoEntry::GetMangledName(const DWARFUnit *cu,
bool substitute_name_allowed) const {
const char *name = nullptr;
- name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name,
- nullptr, true);
+ name = GetAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, nullptr, true);
if (name)
return name;
- name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr,
- true);
+ name = GetAttributeValueAsString(cu, DW_AT_linkage_name, nullptr, true);
if (name)
return name;
if (!substitute_name_allowed)
return nullptr;
- name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
+ name = GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
return name;
}
-//----------------------------------------------------------------------
// GetPubname
//
// Get value the name for a DIE as it should appear for a .debug_pubnames or
// .debug_pubtypes section.
-//----------------------------------------------------------------------
-const char *DWARFDebugInfoEntry::GetPubname(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu) const {
+const char *DWARFDebugInfoEntry::GetPubname(const DWARFUnit *cu) const {
const char *name = nullptr;
- if (!dwarf2Data)
+ if (!cu)
return name;
- name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name,
- nullptr, true);
+ name = GetAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, nullptr, true);
if (name)
return name;
- name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr,
- true);
+ name = GetAttributeValueAsString(cu, DW_AT_linkage_name, nullptr, true);
if (name)
return name;
- name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
+ name = GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
return name;
}
-//----------------------------------------------------------------------
-// GetName
-//
-// Get value of the DW_AT_name attribute for a debug information entry that
-// exists at offset "die_offset" and place that value into the supplied stream
-// object. If the DIE is a NULL object "NULL" is placed into the stream, and if
-// no DW_AT_name attribute exists for the DIE then nothing is printed.
-//----------------------------------------------------------------------
-bool DWARFDebugInfoEntry::GetName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
- const dw_offset_t die_offset, Stream &s) {
- if (dwarf2Data == NULL) {
- s.PutCString("NULL");
- return false;
- }
-
- DWARFDebugInfoEntry die;
- lldb::offset_t offset = die_offset;
- if (die.Extract(dwarf2Data, cu, &offset)) {
- if (die.IsNULL()) {
- s.PutCString("NULL");
- return true;
- } else {
- const char *name = die.GetAttributeValueAsString(
- dwarf2Data, cu, DW_AT_name, nullptr, true);
- if (name) {
- s.PutCString(name);
- return true;
- }
- }
- }
- return false;
-}
-
-//----------------------------------------------------------------------
-// AppendTypeName
-//
-// Follows the type name definition down through all needed tags to end up with
-// a fully qualified type name and dump the results to the supplied stream.
-// This is used to show the name of types given a type identifier.
-//----------------------------------------------------------------------
-bool DWARFDebugInfoEntry::AppendTypeName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
- const dw_offset_t die_offset,
- Stream &s) {
- if (dwarf2Data == NULL) {
- s.PutCString("NULL");
- return false;
- }
-
- DWARFDebugInfoEntry die;
- lldb::offset_t offset = die_offset;
- if (die.Extract(dwarf2Data, cu, &offset)) {
- if (die.IsNULL()) {
- s.PutCString("NULL");
- return true;
- } else {
- const char *name = die.GetPubname(dwarf2Data, cu);
- if (name)
- s.PutCString(name);
- else {
- bool result = true;
- const DWARFAbbreviationDeclaration *abbrevDecl =
- die.GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
-
- if (abbrevDecl == NULL)
- return false;
-
- switch (abbrevDecl->Tag()) {
- case DW_TAG_array_type:
- break; // print out a "[]" after printing the full type of the element
- // below
- case DW_TAG_base_type:
- s.PutCString("base ");
- break;
- case DW_TAG_class_type:
- s.PutCString("class ");
- break;
- case DW_TAG_const_type:
- s.PutCString("const ");
- break;
- case DW_TAG_enumeration_type:
- s.PutCString("enum ");
- break;
- case DW_TAG_file_type:
- s.PutCString("file ");
- break;
- case DW_TAG_interface_type:
- s.PutCString("interface ");
- break;
- case DW_TAG_packed_type:
- s.PutCString("packed ");
- break;
- case DW_TAG_pointer_type:
- break; // print out a '*' after printing the full type below
- case DW_TAG_ptr_to_member_type:
- break; // print out a '*' after printing the full type below
- case DW_TAG_reference_type:
- break; // print out a '&' after printing the full type below
- case DW_TAG_restrict_type:
- s.PutCString("restrict ");
- break;
- case DW_TAG_set_type:
- s.PutCString("set ");
- break;
- case DW_TAG_shared_type:
- s.PutCString("shared ");
- break;
- case DW_TAG_string_type:
- s.PutCString("string ");
- break;
- case DW_TAG_structure_type:
- s.PutCString("struct ");
- break;
- case DW_TAG_subrange_type:
- s.PutCString("subrange ");
- break;
- case DW_TAG_subroutine_type:
- s.PutCString("function ");
- break;
- case DW_TAG_thrown_type:
- s.PutCString("thrown ");
- break;
- case DW_TAG_union_type:
- s.PutCString("union ");
- break;
- case DW_TAG_unspecified_type:
- s.PutCString("unspecified ");
- break;
- case DW_TAG_volatile_type:
- s.PutCString("volatile ");
- break;
- default:
- return false;
- }
-
- // Follow the DW_AT_type if possible
- DWARFFormValue form_value;
- if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_type, form_value)) {
- uint64_t next_die_offset = form_value.Reference();
- result = AppendTypeName(dwarf2Data, cu, next_die_offset, s);
- }
-
- switch (abbrevDecl->Tag()) {
- case DW_TAG_array_type:
- s.PutCString("[]");
- break;
- case DW_TAG_pointer_type:
- s.PutChar('*');
- break;
- case DW_TAG_ptr_to_member_type:
- s.PutChar('*');
- break;
- case DW_TAG_reference_type:
- s.PutChar('&');
- break;
- default:
- break;
- }
- return result;
- }
- }
- }
- return false;
-}
-
-//----------------------------------------------------------------------
// BuildAddressRangeTable
-//----------------------------------------------------------------------
void DWARFDebugInfoEntry::BuildAddressRangeTable(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- DWARFDebugAranges *debug_aranges) const {
+ const DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
if (m_tag) {
if (m_tag == DW_TAG_subprogram) {
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- if (GetAttributeAddressRange(dwarf2Data, cu, lo_pc, hi_pc,
- LLDB_INVALID_ADDRESS)) {
+ if (GetAttributeAddressRange(cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) {
/// printf("BuildAddressRangeTable() 0x%8.8x: %30s: [0x%8.8x -
/// 0x%8.8x)\n", m_offset, DW_TAG_value_to_name(tag), lo_pc, hi_pc);
debug_aranges->AppendRange(cu->GetOffset(), lo_pc, hi_pc);
@@ -1342,29 +858,25 @@ void DWARFDebugInfoEntry::BuildAddressRangeTable(
const DWARFDebugInfoEntry *child = GetFirstChild();
while (child) {
- child->BuildAddressRangeTable(dwarf2Data, cu, debug_aranges);
+ child->BuildAddressRangeTable(cu, debug_aranges);
child = child->GetSibling();
}
}
}
-//----------------------------------------------------------------------
// BuildFunctionAddressRangeTable
//
// This function is very similar to the BuildAddressRangeTable function except
// that the actual DIE offset for the function is placed in the table instead
// of the compile unit offset (which is the way the standard .debug_aranges
// section does it).
-//----------------------------------------------------------------------
void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- DWARFDebugAranges *debug_aranges) const {
+ const DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
if (m_tag) {
if (m_tag == DW_TAG_subprogram) {
dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
- if (GetAttributeAddressRange(dwarf2Data, cu, lo_pc, hi_pc,
- LLDB_INVALID_ADDRESS)) {
+ if (GetAttributeAddressRange(cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS)) {
// printf("BuildAddressRangeTable() 0x%8.8x: [0x%16.16" PRIx64 " -
// 0x%16.16" PRIx64 ")\n", m_offset, lo_pc, hi_pc); // DEBUG ONLY
debug_aranges->AppendRange(GetOffset(), lo_pc, hi_pc);
@@ -1373,57 +885,37 @@ void DWARFDebugInfoEntry::BuildFunctionAddressRangeTable(
const DWARFDebugInfoEntry *child = GetFirstChild();
while (child) {
- child->BuildFunctionAddressRangeTable(dwarf2Data, cu, debug_aranges);
+ child->BuildFunctionAddressRangeTable(cu, debug_aranges);
child = child->GetSibling();
}
}
}
-void DWARFDebugInfoEntry::GetDeclContextDIEs(
- DWARFUnit *cu, DWARFDIECollection &decl_context_dies) const {
-
- DWARFDIE die(cu, const_cast<DWARFDebugInfoEntry *>(this));
- die.GetDeclContextDIEs(decl_context_dies);
-}
-
void DWARFDebugInfoEntry::GetDWARFDeclContext(
- SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
- DWARFDeclContext &dwarf_decl_ctx) const {
+ DWARFUnit *cu, DWARFDeclContext &dwarf_decl_ctx) const {
const dw_tag_t tag = Tag();
if (tag != DW_TAG_compile_unit && tag != DW_TAG_partial_unit) {
- dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu));
- DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(dwarf2Data, cu);
+ dwarf_decl_ctx.AppendDeclContext(tag, GetName(cu));
+ DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this) {
if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit &&
parent_decl_ctx_die.Tag() != DW_TAG_partial_unit)
parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext(
- parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(),
- dwarf_decl_ctx);
+ parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
}
}
}
-bool DWARFDebugInfoEntry::MatchesDWARFDeclContext(
- SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
- const DWARFDeclContext &dwarf_decl_ctx) const {
-
- DWARFDeclContext this_dwarf_decl_ctx;
- GetDWARFDeclContext(dwarf2Data, cu, this_dwarf_decl_ctx);
- return this_dwarf_decl_ctx == dwarf_decl_ctx;
-}
-
DWARFDIE
-DWARFDebugInfoEntry::GetParentDeclContextDIE(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu) const {
+DWARFDebugInfoEntry::GetParentDeclContextDIE(DWARFUnit *cu) const {
DWARFAttributes attributes;
- GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
- return GetParentDeclContextDIE(dwarf2Data, cu, attributes);
+ GetAttributes(cu, attributes);
+ return GetParentDeclContextDIE(cu, attributes);
}
DWARFDIE
DWARFDebugInfoEntry::GetParentDeclContextDIE(
- SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
- const DWARFAttributes &attributes) const {
+ DWARFUnit *cu, const DWARFAttributes &attributes) const {
DWARFDIE die(cu, const_cast<DWARFDebugInfoEntry *>(this));
while (die) {
@@ -1445,28 +937,18 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE(
}
}
- dw_offset_t die_offset;
-
- die_offset =
- attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET) {
- DWARFDIE spec_die = cu->GetDIE(die_offset);
- if (spec_die) {
- DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE();
- if (decl_ctx_die)
- return decl_ctx_die;
- }
+ DWARFDIE spec_die = attributes.FormValueAsReference(DW_AT_specification);
+ if (spec_die) {
+ DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE();
+ if (decl_ctx_die)
+ return decl_ctx_die;
}
- die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin,
- DW_INVALID_OFFSET);
- if (die_offset != DW_INVALID_OFFSET) {
- DWARFDIE abs_die = cu->GetDIE(die_offset);
- if (abs_die) {
- DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE();
- if (decl_ctx_die)
- return decl_ctx_die;
- }
+ DWARFDIE abs_die = attributes.FormValueAsReference(DW_AT_abstract_origin);
+ if (abs_die) {
+ DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE();
+ if (decl_ctx_die)
+ return decl_ctx_die;
}
die = die.GetParent();
@@ -1474,22 +956,22 @@ DWARFDebugInfoEntry::GetParentDeclContextDIE(
return DWARFDIE();
}
-const char *DWARFDebugInfoEntry::GetQualifiedName(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu,
+const char *DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
std::string &storage) const {
DWARFAttributes attributes;
- GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
- return GetQualifiedName(dwarf2Data, cu, attributes, storage);
+ GetAttributes(cu, attributes);
+ return GetQualifiedName(cu, attributes, storage);
}
-const char *DWARFDebugInfoEntry::GetQualifiedName(
- SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
- const DWARFAttributes &attributes, std::string &storage) const {
+const char *
+DWARFDebugInfoEntry::GetQualifiedName(DWARFUnit *cu,
+ const DWARFAttributes &attributes,
+ std::string &storage) const {
- const char *name = GetName(dwarf2Data, cu);
+ const char *name = GetName(cu);
if (name) {
- DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(dwarf2Data, cu);
+ DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE(cu);
storage.clear();
// TODO: change this to get the correct decl context parent....
while (parent_decl_ctx_die) {
@@ -1530,15 +1012,11 @@ const char *DWARFDebugInfoEntry::GetQualifiedName(
storage.append(name);
}
if (storage.empty())
- return NULL;
+ return nullptr;
return storage.c_str();
}
-//----------------------------------------------------------------------
-// LookupAddress
-//----------------------------------------------------------------------
bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
- SymbolFileDWARF *dwarf2Data,
const DWARFUnit *cu,
DWARFDebugInfoEntry **function_die,
DWARFDebugInfoEntry **block_die) {
@@ -1555,13 +1033,9 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
check_children = true;
break;
case DW_TAG_entry_point:
- break;
case DW_TAG_enumeration_type:
- break;
case DW_TAG_formal_parameter:
- break;
case DW_TAG_imported_declaration:
- break;
case DW_TAG_label:
break;
case DW_TAG_lexical_block:
@@ -1569,9 +1043,7 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
match_addr_range = true;
break;
case DW_TAG_member:
- break;
case DW_TAG_pointer_type:
- break;
case DW_TAG_reference_type:
break;
case DW_TAG_compile_unit:
@@ -1583,20 +1055,15 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
check_children = true;
break;
case DW_TAG_subroutine_type:
- break;
case DW_TAG_typedef:
- break;
case DW_TAG_union_type:
- break;
case DW_TAG_unspecified_parameters:
- break;
case DW_TAG_variant:
break;
case DW_TAG_common_block:
check_children = true;
break;
case DW_TAG_common_inclusion:
- break;
case DW_TAG_inheritance:
break;
case DW_TAG_inlined_subroutine:
@@ -1607,86 +1074,62 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
match_addr_range = true;
break;
case DW_TAG_ptr_to_member_type:
- break;
case DW_TAG_set_type:
- break;
case DW_TAG_subrange_type:
- break;
case DW_TAG_with_stmt:
- break;
case DW_TAG_access_declaration:
- break;
case DW_TAG_base_type:
break;
case DW_TAG_catch_block:
match_addr_range = true;
break;
case DW_TAG_const_type:
- break;
case DW_TAG_constant:
- break;
case DW_TAG_enumerator:
- break;
case DW_TAG_file_type:
- break;
case DW_TAG_friend:
- break;
case DW_TAG_namelist:
- break;
case DW_TAG_namelist_item:
- break;
case DW_TAG_packed_type:
break;
case DW_TAG_subprogram:
match_addr_range = true;
break;
case DW_TAG_template_type_parameter:
- break;
case DW_TAG_template_value_parameter:
- break;
case DW_TAG_GNU_template_parameter_pack:
- break;
case DW_TAG_thrown_type:
break;
case DW_TAG_try_block:
match_addr_range = true;
break;
case DW_TAG_variant_part:
- break;
case DW_TAG_variable:
- break;
case DW_TAG_volatile_type:
- break;
case DW_TAG_dwarf_procedure:
- break;
case DW_TAG_restrict_type:
- break;
case DW_TAG_interface_type:
break;
case DW_TAG_namespace:
check_children = true;
break;
case DW_TAG_imported_module:
- break;
case DW_TAG_unspecified_type:
break;
case DW_TAG_partial_unit:
match_addr_range = true;
break;
case DW_TAG_imported_unit:
- break;
case DW_TAG_shared_type:
- break;
default:
break;
}
if (match_addr_range) {
- dw_addr_t lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc,
- LLDB_INVALID_ADDRESS);
+ dw_addr_t lo_pc =
+ GetAttributeValueAsAddress(cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
if (lo_pc != LLDB_INVALID_ADDRESS) {
- dw_addr_t hi_pc =
- GetAttributeHighPC(dwarf2Data, cu, lo_pc, LLDB_INVALID_ADDRESS);
+ dw_addr_t hi_pc = GetAttributeHighPC(cu, lo_pc, LLDB_INVALID_ADDRESS);
if (hi_pc != LLDB_INVALID_ADDRESS) {
// printf("\n0x%8.8x: %30s: address = 0x%8.8x [0x%8.8x - 0x%8.8x) ",
// m_offset, DW_TAG_value_to_name(tag), address, lo_pc, hi_pc);
@@ -1696,13 +1139,14 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
switch (m_tag) {
case DW_TAG_compile_unit: // File
case DW_TAG_partial_unit: // File
- check_children = ((function_die != NULL) || (block_die != NULL));
+ check_children =
+ ((function_die != nullptr) || (block_die != nullptr));
break;
case DW_TAG_subprogram: // Function
if (function_die)
*function_die = this;
- check_children = (block_die != NULL);
+ check_children = (block_die != nullptr);
break;
case DW_TAG_inlined_subroutine: // Inlined Function
@@ -1722,48 +1166,43 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
// Compile units may not have a valid high/low pc when there
// are address gaps in subroutines so we must always search
// if there is no valid high and low PC.
- check_children = (m_tag == DW_TAG_compile_unit ||
- m_tag == DW_TAG_partial_unit) &&
- ((function_die != NULL) || (block_die != NULL));
+ check_children =
+ (m_tag == DW_TAG_compile_unit || m_tag == DW_TAG_partial_unit) &&
+ ((function_die != nullptr) || (block_die != nullptr));
}
} else {
- DWARFFormValue form_value;
- if (GetAttributeValue(dwarf2Data, cu, DW_AT_ranges, form_value)) {
- DWARFRangeList ranges;
- DWARFDebugRangesBase *debug_ranges = dwarf2Data->DebugRanges();
- debug_ranges->FindRanges(
- cu, GetRangesOffset(debug_ranges, form_value), ranges);
-
- if (ranges.FindEntryThatContains(address)) {
- found_address = true;
- // puts("***MATCH***");
- switch (m_tag) {
- case DW_TAG_compile_unit: // File
- case DW_TAG_partial_unit: // File
- check_children = ((function_die != NULL) || (block_die != NULL));
+ DWARFRangeList ranges;
+ if (GetAttributeAddressRanges(cu, ranges, /*check_hi_lo_pc*/ false) &&
+ ranges.FindEntryThatContains(address)) {
+ found_address = true;
+ // puts("***MATCH***");
+ switch (m_tag) {
+ case DW_TAG_compile_unit: // File
+ case DW_TAG_partial_unit: // File
+ check_children =
+ ((function_die != nullptr) || (block_die != nullptr));
break;
- case DW_TAG_subprogram: // Function
- if (function_die)
- *function_die = this;
- check_children = (block_die != NULL);
- break;
-
- case DW_TAG_inlined_subroutine: // Inlined Function
- case DW_TAG_lexical_block: // Block { } in code
- if (block_die) {
- *block_die = this;
- check_children = true;
- }
- break;
+ case DW_TAG_subprogram: // Function
+ if (function_die)
+ *function_die = this;
+ check_children = (block_die != nullptr);
+ break;
- default:
+ case DW_TAG_inlined_subroutine: // Inlined Function
+ case DW_TAG_lexical_block: // Block { } in code
+ if (block_die) {
+ *block_die = this;
check_children = true;
- break;
}
- } else {
- check_children = false;
+ break;
+
+ default:
+ check_children = true;
+ break;
}
+ } else {
+ check_children = false;
}
}
}
@@ -1772,8 +1211,7 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
// printf("checking children\n");
DWARFDebugInfoEntry *child = GetFirstChild();
while (child) {
- if (child->LookupAddress(address, dwarf2Data, cu, function_die,
- block_die))
+ if (child->LookupAddress(address, cu, function_die, block_die))
return true;
child = child->GetSibling();
}
@@ -1782,59 +1220,18 @@ bool DWARFDebugInfoEntry::LookupAddress(const dw_addr_t address,
return found_address;
}
-const DWARFAbbreviationDeclaration *
-DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- lldb::offset_t &offset) const {
- if (dwarf2Data) {
- offset = GetOffset();
-
- const DWARFAbbreviationDeclarationSet *abbrev_set = cu->GetAbbreviations();
- if (abbrev_set) {
- const DWARFAbbreviationDeclaration *abbrev_decl =
- abbrev_set->GetAbbreviationDeclaration(m_abbr_idx);
- if (abbrev_decl) {
- // Make sure the abbreviation code still matches. If it doesn't and the
- // DWARF data was mmap'ed, the backing file might have been modified
- // which is bad news.
- const uint64_t abbrev_code = cu->GetData().GetULEB128(&offset);
-
- if (abbrev_decl->Code() == abbrev_code)
- return abbrev_decl;
-
- dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected(
- "0x%8.8x: the DWARF debug information has been modified (abbrev "
- "code was %u, and is now %u)",
- GetOffset(), (uint32_t)abbrev_decl->Code(), (uint32_t)abbrev_code);
- }
- }
- }
- offset = DW_INVALID_OFFSET;
- return NULL;
-}
-
-bool DWARFDebugInfoEntry::OffsetLessThan(const DWARFDebugInfoEntry &a,
- const DWARFDebugInfoEntry &b) {
- return a.GetOffset() < b.GetOffset();
+lldb::offset_t DWARFDebugInfoEntry::GetFirstAttributeOffset() const {
+ return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
}
-void DWARFDebugInfoEntry::DumpDIECollection(
- Stream &strm, DWARFDebugInfoEntry::collection &die_collection) {
- DWARFDebugInfoEntry::const_iterator pos;
- DWARFDebugInfoEntry::const_iterator end = die_collection.end();
- strm.PutCString("\noffset parent sibling child\n");
- strm.PutCString("-------- -------- -------- --------\n");
- for (pos = die_collection.begin(); pos != end; ++pos) {
- const DWARFDebugInfoEntry &die_ref = *pos;
- const DWARFDebugInfoEntry *p = die_ref.GetParent();
- const DWARFDebugInfoEntry *s = die_ref.GetSibling();
- const DWARFDebugInfoEntry *c = die_ref.GetFirstChild();
- strm.Printf("%.8x: %.8x %.8x %.8x 0x%4.4x %s%s\n", die_ref.GetOffset(),
- p ? p->GetOffset() : 0, s ? s->GetOffset() : 0,
- c ? c->GetOffset() : 0, die_ref.Tag(),
- DW_TAG_value_to_name(die_ref.Tag()),
- die_ref.HasChildren() ? " *" : "");
+const DWARFAbbreviationDeclaration *
+DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr(const DWARFUnit *cu) const {
+ if (cu) {
+ const DWARFAbbreviationDeclarationSet *abbrev_set = cu->GetAbbreviations();
+ if (abbrev_set)
+ return abbrev_set->GetAbbreviationDeclaration(m_abbr_idx);
}
+ return nullptr;
}
bool DWARFDebugInfoEntry::operator==(const DWARFDebugInfoEntry &rhs) const {
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index ec19fc814fbaf..1e7b5f27642d3 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -1,9 +1,8 @@
//===-- DWARFDebugInfoEntry.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,26 +19,6 @@
#include <set>
#include <vector>
-typedef std::map<const DWARFDebugInfoEntry *, dw_addr_t> DIEToAddressMap;
-typedef DIEToAddressMap::iterator DIEToAddressMapIter;
-typedef DIEToAddressMap::const_iterator DIEToAddressMapConstIter;
-
-typedef std::map<dw_addr_t, const DWARFDebugInfoEntry *> AddressToDIEMap;
-typedef AddressToDIEMap::iterator AddressToDIEMapIter;
-typedef AddressToDIEMap::const_iterator AddressToDIEMapConstIter;
-
-typedef std::map<dw_offset_t, dw_offset_t> DIEToDIEMap;
-typedef DIEToDIEMap::iterator DIEToDIEMapIter;
-typedef DIEToDIEMap::const_iterator DIEToDIEMapConstIter;
-
-typedef std::map<uint32_t, const DWARFDebugInfoEntry *> UInt32ToDIEMap;
-typedef UInt32ToDIEMap::iterator UInt32ToDIEMapIter;
-typedef UInt32ToDIEMap::const_iterator UInt32ToDIEMapConstIter;
-
-typedef std::multimap<uint32_t, const DWARFDebugInfoEntry *> UInt32ToDIEMMap;
-typedef UInt32ToDIEMMap::iterator UInt32ToDIEMMapIter;
-typedef UInt32ToDIEMMap::const_iterator UInt32ToDIEMMapConstIter;
-
class DWARFDeclContext;
#define DIE_SIBLING_IDX_BITSIZE 31
@@ -50,10 +29,6 @@ public:
typedef collection::iterator iterator;
typedef collection::const_iterator const_iterator;
- typedef std::vector<dw_offset_t> offset_collection;
- typedef offset_collection::iterator offset_collection_iterator;
- typedef offset_collection::const_iterator offset_collection_const_iterator;
-
DWARFDebugInfoEntry()
: m_offset(DW_INVALID_OFFSET), m_parent_idx(0), m_sibling_idx(0),
m_has_children(false), m_abbr_idx(0), m_tag(0) {}
@@ -62,138 +37,90 @@ public:
bool operator==(const DWARFDebugInfoEntry &rhs) const;
bool operator!=(const DWARFDebugInfoEntry &rhs) const;
- void BuildAddressRangeTable(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
+ void BuildAddressRangeTable(const DWARFUnit *cu,
DWARFDebugAranges *debug_aranges) const;
- void BuildFunctionAddressRangeTable(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
+ void BuildFunctionAddressRangeTable(const DWARFUnit *cu,
DWARFDebugAranges *debug_aranges) const;
- bool FastExtract(const lldb_private::DWARFDataExtractor &debug_info_data,
- const DWARFUnit *cu,
- const DWARFFormValue::FixedFormSizes &fixed_form_sizes,
- lldb::offset_t *offset_ptr);
+ bool Extract(const lldb_private::DWARFDataExtractor &data,
+ const DWARFUnit *cu, lldb::offset_t *offset_ptr);
- bool Extract(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- lldb::offset_t *offset_ptr);
-
- bool LookupAddress(const dw_addr_t address, SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
+ bool LookupAddress(const dw_addr_t address, const DWARFUnit *cu,
DWARFDebugInfoEntry **function_die,
DWARFDebugInfoEntry **block_die);
size_t GetAttributes(const DWARFUnit *cu,
- DWARFFormValue::FixedFormSizes fixed_form_sizes,
DWARFAttributes &attrs,
uint32_t curr_depth = 0)
const; // "curr_depth" for internal use only, don't set this yourself!!!
dw_offset_t
- GetAttributeValue(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, DWARFFormValue &formValue,
+ GetAttributeValue(const DWARFUnit *cu, const dw_attr_t attr,
+ DWARFFormValue &formValue,
dw_offset_t *end_attr_offset_ptr = nullptr,
bool check_specification_or_abstract_origin = false) const;
const char *GetAttributeValueAsString(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, const char *fail_value,
+ const DWARFUnit *cu, const dw_attr_t attr, const char *fail_value,
bool check_specification_or_abstract_origin = false) const;
uint64_t GetAttributeValueAsUnsigned(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, uint64_t fail_value,
- bool check_specification_or_abstract_origin = false) const;
-
- uint64_t GetAttributeValueAsReference(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, uint64_t fail_value,
+ const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value,
bool check_specification_or_abstract_origin = false) const;
- int64_t GetAttributeValueAsSigned(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, int64_t fail_value,
+ DWARFDIE GetAttributeValueAsReference(
+ const DWARFUnit *cu, const dw_attr_t attr,
bool check_specification_or_abstract_origin = false) const;
uint64_t GetAttributeValueAsAddress(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_attr_t attr, uint64_t fail_value,
+ const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value,
bool check_specification_or_abstract_origin = false) const;
dw_addr_t
- GetAttributeHighPC(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- dw_addr_t lo_pc, uint64_t fail_value,
+ GetAttributeHighPC(const DWARFUnit *cu, dw_addr_t lo_pc, uint64_t fail_value,
bool check_specification_or_abstract_origin = false) const;
bool GetAttributeAddressRange(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu, dw_addr_t &lo_pc,
- dw_addr_t &hi_pc, uint64_t fail_value,
+ const DWARFUnit *cu, dw_addr_t &lo_pc, dw_addr_t &hi_pc,
+ uint64_t fail_value,
bool check_specification_or_abstract_origin = false) const;
size_t GetAttributeAddressRanges(
- SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- DWARFRangeList &ranges, bool check_hi_lo_pc,
+ const DWARFUnit *cu, DWARFRangeList &ranges, bool check_hi_lo_pc,
bool check_specification_or_abstract_origin = false) const;
- const char *GetName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu) const;
+ const char *GetName(const DWARFUnit *cu) const;
- const char *GetMangledName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
+ const char *GetMangledName(const DWARFUnit *cu,
bool substitute_name_allowed = true) const;
- const char *GetPubname(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu) const;
+ const char *GetPubname(const DWARFUnit *cu) const;
- static bool GetName(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const dw_offset_t die_offset, lldb_private::Stream &s);
-
- static bool AppendTypeName(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
- const dw_offset_t die_offset,
- lldb_private::Stream &s);
-
- const char *GetQualifiedName(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu,
- std::string &storage) const;
+ const char *GetQualifiedName(DWARFUnit *cu, std::string &storage) const;
- const char *GetQualifiedName(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu,
- const DWARFAttributes &attributes,
+ const char *GetQualifiedName(DWARFUnit *cu, const DWARFAttributes &attributes,
std::string &storage) const;
- static bool OffsetLessThan(const DWARFDebugInfoEntry &a,
- const DWARFDebugInfoEntry &b);
-
- void Dump(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- lldb_private::Stream &s, uint32_t recurse_depth) const;
-
- void DumpAncestry(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const DWARFDebugInfoEntry *oldest, lldb_private::Stream &s,
- uint32_t recurse_depth) const;
+ void Dump(const DWARFUnit *cu, lldb_private::Stream &s,
+ uint32_t recurse_depth) const;
static void
- DumpAttribute(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const lldb_private::DWARFDataExtractor &debug_info_data,
+ DumpAttribute(const DWARFUnit *cu,
+ const lldb_private::DWARFDataExtractor &data,
lldb::offset_t *offset_ptr, lldb_private::Stream &s,
dw_attr_t attr, DWARFFormValue &form_value);
- // This one dumps the comp unit name, objfile name and die offset for this die
- // so the stream S.
- void DumpLocation(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
- lldb_private::Stream &s) const;
-
- bool
- GetDIENamesAndRanges(SymbolFileDWARF *dwarf2Data, const DWARFUnit *cu,
- const char *&name, const char *&mangled,
- DWARFRangeList &rangeList, int &decl_file,
- int &decl_line, int &decl_column, int &call_file,
- int &call_line, int &call_column,
- lldb_private::DWARFExpression *frame_base = NULL) const;
+
+ bool GetDIENamesAndRanges(
+ const DWARFUnit *cu, const char *&name, const char *&mangled,
+ DWARFRangeList &rangeList, int &decl_file, int &decl_line,
+ int &decl_column, int &call_file, int &call_line, int &call_column,
+ lldb_private::DWARFExpression *frame_base = nullptr) const;
const DWARFAbbreviationDeclaration *
- GetAbbreviationDeclarationPtr(SymbolFileDWARF *dwarf2Data,
- const DWARFUnit *cu,
- lldb::offset_t &offset) const;
+ GetAbbreviationDeclarationPtr(const DWARFUnit *cu) const;
+
+ lldb::offset_t GetFirstAttributeOffset() const;
dw_tag_t Tag() const { return m_tag; }
@@ -208,74 +135,41 @@ public:
// We know we are kept in a vector of contiguous entries, so we know
// our parent will be some index behind "this".
DWARFDebugInfoEntry *GetParent() {
- return m_parent_idx > 0 ? this - m_parent_idx : NULL;
+ return m_parent_idx > 0 ? this - m_parent_idx : nullptr;
}
const DWARFDebugInfoEntry *GetParent() const {
- return m_parent_idx > 0 ? this - m_parent_idx : NULL;
+ return m_parent_idx > 0 ? this - m_parent_idx : nullptr;
}
// We know we are kept in a vector of contiguous entries, so we know
// our sibling will be some index after "this".
DWARFDebugInfoEntry *GetSibling() {
- return m_sibling_idx > 0 ? this + m_sibling_idx : NULL;
+ return m_sibling_idx > 0 ? this + m_sibling_idx : nullptr;
}
const DWARFDebugInfoEntry *GetSibling() const {
- return m_sibling_idx > 0 ? this + m_sibling_idx : NULL;
+ return m_sibling_idx > 0 ? this + m_sibling_idx : nullptr;
}
// We know we are kept in a vector of contiguous entries, so we know
// we don't need to store our child pointer, if we have a child it will
// be the next entry in the list...
DWARFDebugInfoEntry *GetFirstChild() {
- return HasChildren() ? this + 1 : NULL;
+ return HasChildren() ? this + 1 : nullptr;
}
const DWARFDebugInfoEntry *GetFirstChild() const {
- return HasChildren() ? this + 1 : NULL;
+ return HasChildren() ? this + 1 : nullptr;
}
- void GetDeclContextDIEs(DWARFUnit *cu,
- DWARFDIECollection &decl_context_dies) const;
-
- void GetDWARFDeclContext(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu,
+ void GetDWARFDeclContext(DWARFUnit *cu,
DWARFDeclContext &dwarf_decl_ctx) const;
- bool MatchesDWARFDeclContext(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu,
- const DWARFDeclContext &dwarf_decl_ctx) const;
-
- DWARFDIE GetParentDeclContextDIE(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu) const;
- DWARFDIE GetParentDeclContextDIE(SymbolFileDWARF *dwarf2Data,
- DWARFUnit *cu,
+ DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu) const;
+ DWARFDIE GetParentDeclContextDIE(DWARFUnit *cu,
const DWARFAttributes &attributes) const;
- void SetParent(DWARFDebugInfoEntry *parent) {
- if (parent) {
- // We know we are kept in a vector of contiguous entries, so we know
- // our parent will be some index behind "this".
- m_parent_idx = this - parent;
- } else
- m_parent_idx = 0;
- }
- void SetSibling(DWARFDebugInfoEntry *sibling) {
- if (sibling) {
- // We know we are kept in a vector of contiguous entries, so we know
- // our sibling will be some index after "this".
- m_sibling_idx = sibling - this;
- sibling->SetParent(GetParent());
- } else
- m_sibling_idx = 0;
- }
-
void SetSiblingIndex(uint32_t idx) { m_sibling_idx = idx; }
-
void SetParentIndex(uint32_t idx) { m_parent_idx = idx; }
- static void
- DumpDIECollection(lldb_private::Stream &strm,
- DWARFDebugInfoEntry::collection &die_collection);
-
protected:
- dw_offset_t
- m_offset; // Offset within the .debug_info of the start of this entry
+ dw_offset_t m_offset; // Offset within the .debug_info/.debug_types
uint32_t m_parent_idx; // How many to subtract from "this" to get the parent.
// If zero this die has no parent
uint32_t m_sibling_idx : 31, // How many to add to "this" to get the sibling.
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
index d9f50122bd6f2..953089fee22b5 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDebugLine.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,12 +11,15 @@
//#define ENABLE_DEBUG_PRINTF // DO NOT LEAVE THIS DEFINED: DEBUG ONLY!!!
#include <assert.h>
+#include <memory>
+
#include "lldb/Core/FileSpecList.h"
#include "lldb/Core/Module.h"
#include "lldb/Host/Host.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Timer.h"
+#include "DWARFUnit.h"
#include "LogChannelDWARF.h"
#include "SymbolFileDWARF.h"
@@ -25,12 +27,10 @@ using namespace lldb;
using namespace lldb_private;
using namespace std;
-//----------------------------------------------------------------------
// Parse
//
// Parse all information in the debug_line_data into an internal
// representation.
-//----------------------------------------------------------------------
void DWARFDebugLine::Parse(const DWARFDataExtractor &debug_line_data) {
m_lineTableMap.clear();
lldb::offset_t offset = 0;
@@ -38,7 +38,7 @@ void DWARFDebugLine::Parse(const DWARFDataExtractor &debug_line_data) {
while (debug_line_data.ValidOffset(offset)) {
const lldb::offset_t debug_line_offset = offset;
- if (line_table_sp.get() == NULL)
+ if (line_table_sp.get() == nullptr)
break;
if (ParseStatementTable(debug_line_data, &offset, line_table_sp.get(), nullptr)) {
@@ -48,7 +48,7 @@ void DWARFDebugLine::Parse(const DWARFDataExtractor &debug_line_data) {
// DEBUG_PRINTF("m_lineTableMap[0x%8.8x] = line_table_sp\n",
// debug_line_offset);
m_lineTableMap[debug_line_offset] = line_table_sp;
- line_table_sp.reset(new LineTable);
+ line_table_sp = std::make_shared<LineTable>();
} else
++offset; // Try next byte in line table
}
@@ -59,9 +59,7 @@ void DWARFDebugLine::ParseIfNeeded(const DWARFDataExtractor &debug_line_data) {
Parse(debug_line_data);
}
-//----------------------------------------------------------------------
// DWARFDebugLine::GetLineTable
-//----------------------------------------------------------------------
DWARFDebugLine::LineTable::shared_ptr
DWARFDebugLine::GetLineTable(const dw_offset_t offset) const {
DWARFDebugLine::LineTable::shared_ptr line_table_shared_ptr;
@@ -71,296 +69,11 @@ DWARFDebugLine::GetLineTable(const dw_offset_t offset) const {
return line_table_shared_ptr;
}
-//----------------------------------------------------------------------
-// DumpStateToFile
-//----------------------------------------------------------------------
-static void DumpStateToFile(dw_offset_t offset,
- const DWARFDebugLine::State &state,
- void *userData) {
- Log *log = (Log *)userData;
- if (state.row == DWARFDebugLine::State::StartParsingLineTable) {
- // If the row is zero we are being called with the prologue only
- state.prologue->Dump(log);
- log->PutCString("Address Line Column File");
- log->PutCString("------------------ ------ ------ ------");
- } else if (state.row == DWARFDebugLine::State::DoneParsingLineTable) {
- // Done parsing line table
- } else {
- log->Printf("0x%16.16" PRIx64 " %6u %6u %6u%s\n", state.address, state.line,
- state.column, state.file, state.end_sequence ? " END" : "");
- }
-}
-
-//----------------------------------------------------------------------
-// DWARFDebugLine::DumpLineTableRows
-//----------------------------------------------------------------------
-bool DWARFDebugLine::DumpLineTableRows(Log *log, SymbolFileDWARF *dwarf2Data,
- dw_offset_t debug_line_offset) {
- const DWARFDataExtractor &debug_line_data = dwarf2Data->get_debug_line_data();
-
- if (debug_line_offset == DW_INVALID_OFFSET) {
- // Dump line table to a single file only
- debug_line_offset = 0;
- while (debug_line_data.ValidOffset(debug_line_offset))
- debug_line_offset =
- DumpStatementTable(log, debug_line_data, debug_line_offset);
- } else {
- // Dump line table to a single file only
- DumpStatementTable(log, debug_line_data, debug_line_offset);
- }
- return false;
-}
-
-//----------------------------------------------------------------------
-// DWARFDebugLine::DumpStatementTable
-//----------------------------------------------------------------------
-dw_offset_t
-DWARFDebugLine::DumpStatementTable(Log *log,
- const DWARFDataExtractor &debug_line_data,
- const dw_offset_t debug_line_offset) {
- if (debug_line_data.ValidOffset(debug_line_offset)) {
- lldb::offset_t offset = debug_line_offset;
- log->Printf("--------------------------------------------------------------"
- "--------\n"
- "debug_line[0x%8.8x]\n"
- "--------------------------------------------------------------"
- "--------\n",
- debug_line_offset);
-
- if (ParseStatementTable(debug_line_data, &offset, DumpStateToFile, log, nullptr))
- return offset;
- else
- return debug_line_offset + 1; // Skip to next byte in .debug_line section
- }
-
- return DW_INVALID_OFFSET;
-}
-
-//----------------------------------------------------------------------
-// DumpOpcodes
-//----------------------------------------------------------------------
-bool DWARFDebugLine::DumpOpcodes(Log *log, SymbolFileDWARF *dwarf2Data,
- dw_offset_t debug_line_offset,
- uint32_t dump_flags) {
- const DWARFDataExtractor &debug_line_data = dwarf2Data->get_debug_line_data();
-
- if (debug_line_data.GetByteSize() == 0) {
- log->Printf("< EMPTY >\n");
- return false;
- }
-
- if (debug_line_offset == DW_INVALID_OFFSET) {
- // Dump line table to a single file only
- debug_line_offset = 0;
- while (debug_line_data.ValidOffset(debug_line_offset))
- debug_line_offset = DumpStatementOpcodes(log, debug_line_data,
- debug_line_offset, dump_flags);
- } else {
- // Dump line table to a single file only
- DumpStatementOpcodes(log, debug_line_data, debug_line_offset, dump_flags);
- }
- return false;
-}
-
-//----------------------------------------------------------------------
-// DumpStatementOpcodes
-//----------------------------------------------------------------------
-dw_offset_t DWARFDebugLine::DumpStatementOpcodes(
- Log *log, const DWARFDataExtractor &debug_line_data,
- const dw_offset_t debug_line_offset, uint32_t flags) {
- lldb::offset_t offset = debug_line_offset;
- if (debug_line_data.ValidOffset(offset)) {
- Prologue prologue;
-
- if (ParsePrologue(debug_line_data, &offset, &prologue)) {
- log->PutCString("--------------------------------------------------------"
- "--------------");
- log->Printf("debug_line[0x%8.8x]", debug_line_offset);
- log->PutCString("--------------------------------------------------------"
- "--------------\n");
- prologue.Dump(log);
- } else {
- offset = debug_line_offset;
- log->Printf("0x%8.8" PRIx64 ": skipping pad byte %2.2x", offset,
- debug_line_data.GetU8(&offset));
- return offset;
- }
-
- Row row(prologue.default_is_stmt);
- const dw_offset_t end_offset = debug_line_offset + prologue.total_length +
- sizeof(prologue.total_length);
-
- assert(debug_line_data.ValidOffset(end_offset - 1));
-
- while (offset < end_offset) {
- const uint32_t op_offset = offset;
- uint8_t opcode = debug_line_data.GetU8(&offset);
- switch (opcode) {
- case 0: // Extended Opcodes always start with a zero opcode followed by
- { // a uleb128 length so you can skip ones you don't know about
-
- dw_offset_t ext_offset = offset;
- dw_uleb128_t len = debug_line_data.GetULEB128(&offset);
- dw_offset_t arg_size = len - (offset - ext_offset);
- uint8_t sub_opcode = debug_line_data.GetU8(&offset);
- // if (verbose)
- // log->Printf( "Extended: <%u> %2.2x ", len,
- // sub_opcode);
-
- switch (sub_opcode) {
- case DW_LNE_end_sequence:
- log->Printf("0x%8.8x: DW_LNE_end_sequence", op_offset);
- row.Dump(log);
- row.Reset(prologue.default_is_stmt);
- break;
-
- case DW_LNE_set_address: {
- row.address = debug_line_data.GetMaxU64(&offset, arg_size);
- log->Printf("0x%8.8x: DW_LNE_set_address (0x%" PRIx64 ")", op_offset,
- row.address);
- } break;
-
- case DW_LNE_define_file: {
- FileNameEntry fileEntry;
- fileEntry.name = debug_line_data.GetCStr(&offset);
- fileEntry.dir_idx = debug_line_data.GetULEB128(&offset);
- fileEntry.mod_time = debug_line_data.GetULEB128(&offset);
- fileEntry.length = debug_line_data.GetULEB128(&offset);
- log->Printf("0x%8.8x: DW_LNE_define_file('%s', dir=%i, "
- "mod_time=0x%8.8x, length=%i )",
- op_offset, fileEntry.name, fileEntry.dir_idx,
- fileEntry.mod_time, fileEntry.length);
- prologue.file_names.push_back(fileEntry);
- } break;
-
- case DW_LNE_set_discriminator: {
- uint64_t discriminator = debug_line_data.GetULEB128(&offset);
- log->Printf("0x%8.8x: DW_LNE_set_discriminator (0x%" PRIx64 ")",
- op_offset, discriminator);
- } break;
- default:
- log->Printf("0x%8.8x: DW_LNE_??? (%2.2x) - Skipping unknown upcode",
- op_offset, opcode);
- // Length doesn't include the zero opcode byte or the length itself,
- // but it does include the sub_opcode, so we have to adjust for that
- // below
- offset += arg_size;
- break;
- }
- } break;
-
- // Standard Opcodes
- case DW_LNS_copy:
- log->Printf("0x%8.8x: DW_LNS_copy", op_offset);
- row.Dump(log);
- break;
-
- case DW_LNS_advance_pc: {
- dw_uleb128_t addr_offset_n = debug_line_data.GetULEB128(&offset);
- dw_uleb128_t addr_offset = addr_offset_n * prologue.min_inst_length;
- log->Printf("0x%8.8x: DW_LNS_advance_pc (0x%x)", op_offset,
- addr_offset);
- row.address += addr_offset;
- } break;
-
- case DW_LNS_advance_line: {
- dw_sleb128_t line_offset = debug_line_data.GetSLEB128(&offset);
- log->Printf("0x%8.8x: DW_LNS_advance_line (%i)", op_offset,
- line_offset);
- row.line += line_offset;
- } break;
-
- case DW_LNS_set_file:
- row.file = debug_line_data.GetULEB128(&offset);
- log->Printf("0x%8.8x: DW_LNS_set_file (%u)", op_offset, row.file);
- break;
-
- case DW_LNS_set_column:
- row.column = debug_line_data.GetULEB128(&offset);
- log->Printf("0x%8.8x: DW_LNS_set_column (%u)", op_offset, row.column);
- break;
-
- case DW_LNS_negate_stmt:
- row.is_stmt = !row.is_stmt;
- log->Printf("0x%8.8x: DW_LNS_negate_stmt", op_offset);
- break;
-
- case DW_LNS_set_basic_block:
- row.basic_block = true;
- log->Printf("0x%8.8x: DW_LNS_set_basic_block", op_offset);
- break;
-
- case DW_LNS_const_add_pc: {
- uint8_t adjust_opcode = 255 - prologue.opcode_base;
- dw_addr_t addr_offset =
- (adjust_opcode / prologue.line_range) * prologue.min_inst_length;
- log->Printf("0x%8.8x: DW_LNS_const_add_pc (0x%8.8" PRIx64 ")",
- op_offset, addr_offset);
- row.address += addr_offset;
- } break;
-
- case DW_LNS_fixed_advance_pc: {
- uint16_t pc_offset = debug_line_data.GetU16(&offset);
- log->Printf("0x%8.8x: DW_LNS_fixed_advance_pc (0x%4.4x)", op_offset,
- pc_offset);
- row.address += pc_offset;
- } break;
-
- case DW_LNS_set_prologue_end:
- row.prologue_end = true;
- log->Printf("0x%8.8x: DW_LNS_set_prologue_end", op_offset);
- break;
-
- case DW_LNS_set_epilogue_begin:
- row.epilogue_begin = true;
- log->Printf("0x%8.8x: DW_LNS_set_epilogue_begin", op_offset);
- break;
-
- case DW_LNS_set_isa:
- row.isa = debug_line_data.GetULEB128(&offset);
- log->Printf("0x%8.8x: DW_LNS_set_isa (%u)", op_offset, row.isa);
- break;
-
- // Special Opcodes
- default:
- if (opcode < prologue.opcode_base) {
- // We have an opcode that this parser doesn't know about, skip the
- // number of ULEB128 numbers that is says to skip in the prologue's
- // standard_opcode_lengths array
- uint8_t n = prologue.standard_opcode_lengths[opcode - 1];
- log->Printf("0x%8.8x: Special : Unknown skipping %u ULEB128 values.",
- op_offset, n);
- while (n > 0) {
- debug_line_data.GetULEB128(&offset);
- --n;
- }
- } else {
- uint8_t adjust_opcode = opcode - prologue.opcode_base;
- dw_addr_t addr_offset =
- (adjust_opcode / prologue.line_range) * prologue.min_inst_length;
- int32_t line_offset =
- prologue.line_base + (adjust_opcode % prologue.line_range);
- log->Printf("0x%8.8x: address += 0x%" PRIx64 ", line += %i\n",
- op_offset, (uint64_t)addr_offset, line_offset);
- row.address += addr_offset;
- row.line += line_offset;
- row.Dump(log);
- }
- break;
- }
- }
- return end_offset;
- }
- return DW_INVALID_OFFSET;
-}
-
-//----------------------------------------------------------------------
// Parse
//
// Parse the entire line table contents calling callback each time a new
// prologue is parsed and every time a new row is to be added to the line
// table.
-//----------------------------------------------------------------------
void DWARFDebugLine::Parse(const DWARFDataExtractor &debug_line_data,
DWARFDebugLine::State::Callback callback,
void *userData) {
@@ -392,9 +105,7 @@ ReadDescriptors(const DWARFDataExtractor &debug_line_data,
}
} // namespace
-//----------------------------------------------------------------------
// DWARFDebugLine::ParsePrologue
-//----------------------------------------------------------------------
bool DWARFDebugLine::ParsePrologue(const DWARFDataExtractor &debug_line_data,
lldb::offset_t *offset_ptr,
Prologue *prologue, DWARFUnit *dwarf_cu) {
@@ -528,8 +239,7 @@ bool DWARFDebugLine::ParsePrologue(const DWARFDataExtractor &debug_line_data,
bool DWARFDebugLine::ParseSupportFiles(
const lldb::ModuleSP &module_sp, const DWARFDataExtractor &debug_line_data,
- const lldb_private::FileSpec &cu_comp_dir, dw_offset_t stmt_list,
- FileSpecList &support_files, DWARFUnit *dwarf_cu) {
+ dw_offset_t stmt_list, FileSpecList &support_files, DWARFUnit *dwarf_cu) {
lldb::offset_t offset = stmt_list;
Prologue prologue;
@@ -545,7 +255,9 @@ bool DWARFDebugLine::ParseSupportFiles(
std::string remapped_file;
for (uint32_t file_idx = 1;
- prologue.GetFile(file_idx, cu_comp_dir, file_spec); ++file_idx) {
+ prologue.GetFile(file_idx, dwarf_cu->GetCompilationDirectory(),
+ dwarf_cu->GetPathStyle(), file_spec);
+ ++file_idx) {
if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file))
file_spec.SetFile(remapped_file, FileSpec::Style::native);
support_files.Append(file_spec);
@@ -553,13 +265,11 @@ bool DWARFDebugLine::ParseSupportFiles(
return true;
}
-//----------------------------------------------------------------------
// ParseStatementTable
//
// Parse a single line table (prologue and all rows) and call the callback
// function once for the prologue (row in state will be zero) and each time a
// row is to be added to the line table.
-//----------------------------------------------------------------------
bool DWARFDebugLine::ParseStatementTable(
const DWARFDataExtractor &debug_line_data, lldb::offset_t *offset_ptr,
DWARFDebugLine::State::Callback callback, void *userData, DWARFUnit *dwarf_cu) {
@@ -832,9 +542,7 @@ bool DWARFDebugLine::ParseStatementTable(
return end_offset;
}
-//----------------------------------------------------------------------
// ParseStatementTableCallback
-//----------------------------------------------------------------------
static void ParseStatementTableCallback(dw_offset_t offset,
const DWARFDebugLine::State &state,
void *userData) {
@@ -851,12 +559,10 @@ static void ParseStatementTableCallback(dw_offset_t offset,
}
}
-//----------------------------------------------------------------------
// ParseStatementTable
//
// Parse a line table at offset and populate the LineTable class with the
// prologue and all rows.
-//----------------------------------------------------------------------
bool DWARFDebugLine::ParseStatementTable(
const DWARFDataExtractor &debug_line_data, lldb::offset_t *offset_ptr,
LineTable *line_table, DWARFUnit *dwarf_cu) {
@@ -868,9 +574,7 @@ inline bool DWARFDebugLine::Prologue::IsValid() const {
return SymbolFileDWARF::SupportedVersion(version);
}
-//----------------------------------------------------------------------
// DWARFDebugLine::Prologue::Dump
-//----------------------------------------------------------------------
void DWARFDebugLine::Prologue::Dump(Log *log) {
uint32_t i;
@@ -909,11 +613,9 @@ void DWARFDebugLine::Prologue::Dump(Log *log) {
}
}
-//----------------------------------------------------------------------
// DWARFDebugLine::ParsePrologue::Append
//
// Append the contents of the prologue to the binary stream buffer
-//----------------------------------------------------------------------
// void
// DWARFDebugLine::Prologue::Append(BinaryStreamBuf& buff) const
//{
@@ -947,10 +649,12 @@ void DWARFDebugLine::Prologue::Dump(Log *log) {
//}
bool DWARFDebugLine::Prologue::GetFile(uint32_t file_idx,
- const lldb_private::FileSpec &comp_dir, FileSpec &file) const {
+ const FileSpec &comp_dir,
+ FileSpec::Style style,
+ FileSpec &file) const {
uint32_t idx = file_idx - 1; // File indexes are 1 based...
if (idx < file_names.size()) {
- file.SetFile(file_names[idx].name, FileSpec::Style::native);
+ file.SetFile(file_names[idx].name, style);
if (file.IsRelative()) {
if (file_names[idx].dir_idx > 0) {
const uint32_t dir_idx = file_names[idx].dir_idx - 1;
@@ -969,42 +673,18 @@ bool DWARFDebugLine::Prologue::GetFile(uint32_t file_idx,
return false;
}
-//----------------------------------------------------------------------
-// DWARFDebugLine::LineTable::Dump
-//----------------------------------------------------------------------
-void DWARFDebugLine::LineTable::Dump(Log *log) const {
- if (prologue.get())
- prologue->Dump(log);
-
- if (!rows.empty()) {
- log->PutCString("Address Line Column File ISA Flags");
- log->PutCString(
- "------------------ ------ ------ ------ --- -------------");
- Row::const_iterator pos = rows.begin();
- Row::const_iterator end = rows.end();
- while (pos != end) {
- (*pos).Dump(log);
- ++pos;
- }
- }
-}
-
void DWARFDebugLine::LineTable::AppendRow(const DWARFDebugLine::Row &state) {
rows.push_back(state);
}
-//----------------------------------------------------------------------
// Compare function for the binary search in
// DWARFDebugLine::LineTable::LookupAddress()
-//----------------------------------------------------------------------
static bool FindMatchingAddress(const DWARFDebugLine::Row &row1,
const DWARFDebugLine::Row &row2) {
return row1.address < row2.address;
}
-//----------------------------------------------------------------------
// DWARFDebugLine::LineTable::LookupAddress
-//----------------------------------------------------------------------
uint32_t DWARFDebugLine::LineTable::LookupAddress(dw_addr_t address,
dw_addr_t cu_high_pc) const {
uint32_t index = UINT32_MAX;
@@ -1037,26 +717,20 @@ uint32_t DWARFDebugLine::LineTable::LookupAddress(dw_addr_t address,
return index; // Failed to find address
}
-//----------------------------------------------------------------------
// DWARFDebugLine::Row::Row
-//----------------------------------------------------------------------
DWARFDebugLine::Row::Row(bool default_is_stmt)
: address(0), line(1), column(0), file(1), is_stmt(default_is_stmt),
basic_block(false), end_sequence(false), prologue_end(false),
epilogue_begin(false), isa(0) {}
-//----------------------------------------------------------------------
// Called after a row is appended to the matrix
-//----------------------------------------------------------------------
void DWARFDebugLine::Row::PostAppend() {
basic_block = false;
prologue_end = false;
epilogue_begin = false;
}
-//----------------------------------------------------------------------
// DWARFDebugLine::Row::Reset
-//----------------------------------------------------------------------
void DWARFDebugLine::Row::Reset(bool default_is_stmt) {
address = 0;
line = 1;
@@ -1069,9 +743,7 @@ void DWARFDebugLine::Row::Reset(bool default_is_stmt) {
epilogue_begin = false;
isa = 0;
}
-//----------------------------------------------------------------------
// DWARFDebugLine::Row::Dump
-//----------------------------------------------------------------------
void DWARFDebugLine::Row::Dump(Log *log) const {
log->Printf("0x%16.16" PRIx64 " %6u %6u %6u %3u %s%s%s%s%s", address, line,
column, file, isa, is_stmt ? " is_stmt" : "",
@@ -1081,9 +753,7 @@ void DWARFDebugLine::Row::Dump(Log *log) const {
end_sequence ? " end_sequence" : "");
}
-//----------------------------------------------------------------------
// Compare function LineTable structures
-//----------------------------------------------------------------------
static bool AddressLessThan(const DWARFDebugLine::Row &a,
const DWARFDebugLine::Row &b) {
return a.address < b.address;
@@ -1123,14 +793,7 @@ void DWARFDebugLine::Row::Insert(Row::collection &state_coll,
}
}
-void DWARFDebugLine::Row::Dump(Log *log, const Row::collection &state_coll) {
- std::for_each(state_coll.begin(), state_coll.end(),
- bind2nd(std::mem_fun_ref(&Row::Dump), log));
-}
-
-//----------------------------------------------------------------------
// DWARFDebugLine::State::State
-//----------------------------------------------------------------------
DWARFDebugLine::State::State(Prologue::shared_ptr &p, Log *l,
DWARFDebugLine::State::Callback cb, void *userData)
: Row(p->default_is_stmt), prologue(p), log(l), callback(cb),
@@ -1140,14 +803,10 @@ DWARFDebugLine::State::State(Prologue::shared_ptr &p, Log *l,
callback(0, *this, callbackUserData);
}
-//----------------------------------------------------------------------
// DWARFDebugLine::State::Reset
-//----------------------------------------------------------------------
void DWARFDebugLine::State::Reset() { Row::Reset(prologue->default_is_stmt); }
-//----------------------------------------------------------------------
// DWARFDebugLine::State::AppendRowToMatrix
-//----------------------------------------------------------------------
void DWARFDebugLine::State::AppendRowToMatrix(dw_offset_t offset) {
// Each time we are to add an entry into the line table matrix call the
// callback function so that someone can do something with the current state
@@ -1167,9 +826,7 @@ void DWARFDebugLine::State::AppendRowToMatrix(dw_offset_t offset) {
PostAppend();
}
-//----------------------------------------------------------------------
// DWARFDebugLine::State::Finalize
-//----------------------------------------------------------------------
void DWARFDebugLine::State::Finalize(dw_offset_t offset) {
// Call the callback with a special row state when we are done parsing a line
// table
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
index 04f72e03a2db5..0d236ca686b50 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.h
@@ -1,9 +1,8 @@
//===-- DWARFDebugLine.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include <string>
#include <vector>
+#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-private.h"
#include "DWARFDataExtractor.h"
@@ -24,16 +24,13 @@
class DWARFUnit;
class SymbolFileDWARF;
-//----------------------------------------------------------------------
// DWARFDebugLine
-//----------------------------------------------------------------------
class DWARFDebugLine {
public:
- //------------------------------------------------------------------
// FileNameEntry
- //------------------------------------------------------------------
struct FileNameEntry {
- FileNameEntry() : name(nullptr), dir_idx(0), mod_time(0), length(0) {}
+ FileNameEntry()
+ : name(nullptr), dir_idx(0), mod_time(0), length(0), checksum() {}
const char *name;
dw_sleb128_t dir_idx;
@@ -42,9 +39,7 @@ public:
llvm::MD5::MD5Result checksum;
};
- //------------------------------------------------------------------
// Prologue
- //------------------------------------------------------------------
struct Prologue {
Prologue()
@@ -99,6 +94,7 @@ public:
file_names.clear();
}
bool GetFile(uint32_t file_idx, const lldb_private::FileSpec &cu_comp_dir,
+ lldb_private::FileSpec::Style style,
lldb_private::FileSpec &file) const;
};
@@ -114,7 +110,6 @@ public:
void Reset(bool default_is_stmt);
void Dump(lldb_private::Log *log) const;
static void Insert(Row::collection &state_coll, const Row &state);
- static void Dump(lldb_private::Log *log, const Row::collection &state_coll);
dw_addr_t address; // The program-counter value corresponding to a machine
// instruction generated by the compiler.
@@ -145,9 +140,7 @@ public:
// instruction set architecture for the current instruction.
};
- //------------------------------------------------------------------
// LineTable
- //------------------------------------------------------------------
struct LineTable {
typedef std::shared_ptr<LineTable> shared_ptr;
@@ -160,15 +153,12 @@ public:
}
uint32_t LookupAddress(dw_addr_t address, dw_addr_t cu_high_pc) const;
- void Dump(lldb_private::Log *log) const;
Prologue::shared_ptr prologue;
Row::collection rows;
};
- //------------------------------------------------------------------
// State
- //------------------------------------------------------------------
struct State : public Row {
typedef void (*Callback)(dw_offset_t offset, const State &state,
void *userData);
@@ -196,20 +186,12 @@ public:
DISALLOW_COPY_AND_ASSIGN(State);
};
- static bool DumpOpcodes(
- lldb_private::Log *log, SymbolFileDWARF *dwarf2Data,
- dw_offset_t line_offset = DW_INVALID_OFFSET,
- uint32_t dump_flags = 0); // If line_offset is invalid, dump everything
- static bool DumpLineTableRows(
- lldb_private::Log *log, SymbolFileDWARF *dwarf2Data,
- dw_offset_t line_offset =
- DW_INVALID_OFFSET); // If line_offset is invalid, dump everything
static bool
ParseSupportFiles(const lldb::ModuleSP &module_sp,
const lldb_private::DWARFDataExtractor &debug_line_data,
- const lldb_private::FileSpec &cu_comp_dir,
dw_offset_t stmt_list,
- lldb_private::FileSpecList &support_files, DWARFUnit *dwarf_cu);
+ lldb_private::FileSpecList &support_files,
+ DWARFUnit *dwarf_cu);
static bool
ParsePrologue(const lldb_private::DWARFDataExtractor &debug_line_data,
lldb::offset_t *offset_ptr, Prologue *prologue,
@@ -218,14 +200,6 @@ public:
ParseStatementTable(const lldb_private::DWARFDataExtractor &debug_line_data,
lldb::offset_t *offset_ptr, State::Callback callback,
void *userData, DWARFUnit *dwarf_cu);
- static dw_offset_t
- DumpStatementTable(lldb_private::Log *log,
- const lldb_private::DWARFDataExtractor &debug_line_data,
- const dw_offset_t line_offset);
- static dw_offset_t
- DumpStatementOpcodes(lldb_private::Log *log,
- const lldb_private::DWARFDataExtractor &debug_line_data,
- const dw_offset_t line_offset, uint32_t flags);
static bool
ParseStatementTable(const lldb_private::DWARFDataExtractor &debug_line_data,
lldb::offset_t *offset_ptr, LineTable *line_table,
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp
deleted file mode 100644
index 19074b8865ff3..0000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//===-- DWARFDebugMacinfo.cpp -----------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFDebugMacinfo.h"
-
-#include "DWARFDebugMacinfoEntry.h"
-#include "SymbolFileDWARF.h"
-
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb_private;
-using namespace std;
-
-DWARFDebugMacinfo::DWARFDebugMacinfo() {}
-
-DWARFDebugMacinfo::~DWARFDebugMacinfo() {}
-
-void DWARFDebugMacinfo::Dump(Stream *s, const DWARFDataExtractor &macinfo_data,
- lldb::offset_t offset) {
- DWARFDebugMacinfoEntry maninfo_entry;
- if (macinfo_data.GetByteSize() == 0) {
- s->PutCString("< EMPTY >\n");
- return;
- }
- if (offset == LLDB_INVALID_OFFSET) {
- offset = 0;
- while (maninfo_entry.Extract(macinfo_data, &offset))
- maninfo_entry.Dump(s);
- } else {
- if (maninfo_entry.Extract(macinfo_data, &offset))
- maninfo_entry.Dump(s);
- }
-}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h
deleted file mode 100644
index ec9dc85669c47..0000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfo.h
+++ /dev/null
@@ -1,26 +0,0 @@
-//===-- DWARFDebugMacinfo.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARF_DWARFDebugMacinfo_h_
-#define SymbolFileDWARF_DWARFDebugMacinfo_h_
-
-#include "SymbolFileDWARF.h"
-
-class DWARFDebugMacinfo {
-public:
- DWARFDebugMacinfo();
-
- ~DWARFDebugMacinfo();
-
- static void Dump(lldb_private::Stream *s,
- const lldb_private::DWARFDataExtractor &macinfo_data,
- lldb::offset_t offset = LLDB_INVALID_OFFSET);
-};
-
-#endif // SymbolFileDWARF_DWARFDebugMacinfo_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp
deleted file mode 100644
index f078fbd44f2fe..0000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-//===-- DWARFDebugMacinfoEntry.cpp ------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "DWARFDebugMacinfoEntry.h"
-
-#include "lldb/Utility/Stream.h"
-
-using namespace lldb_private;
-using namespace std;
-
-DWARFDebugMacinfoEntry::DWARFDebugMacinfoEntry()
- : m_type_code(0), m_line(0), m_op2() {
- m_op2.cstr = NULL;
-}
-
-DWARFDebugMacinfoEntry::~DWARFDebugMacinfoEntry() {}
-
-const char *DWARFDebugMacinfoEntry::GetCString() const {
- switch (m_type_code) {
- case 0:
- case DW_MACINFO_start_file:
- case DW_MACINFO_end_file:
- return NULL;
- default:
- break;
- }
- return m_op2.cstr;
-}
-
-void DWARFDebugMacinfoEntry::Dump(Stream *s) const {
- if (m_type_code) {
- s->PutCString(DW_MACINFO_value_to_name(m_type_code));
-
- switch (m_type_code) {
- case DW_MACINFO_define:
- s->Printf(" line:%u #define %s\n", (uint32_t)m_line, m_op2.cstr);
- break;
-
- case DW_MACINFO_undef:
- s->Printf(" line:%u #undef %s\n", (uint32_t)m_line, m_op2.cstr);
- break;
-
- default:
- s->Printf(" line:%u str: '%s'\n", (uint32_t)m_line, m_op2.cstr);
- break;
-
- case DW_MACINFO_start_file:
- s->Printf(" line:%u file index: '%u'\n", (uint32_t)m_line,
- (uint32_t)m_op2.file_idx);
- break;
-
- case DW_MACINFO_end_file:
- break;
- }
- } else {
- s->PutCString(" END\n");
- }
-}
-
-bool DWARFDebugMacinfoEntry::Extract(const DWARFDataExtractor &mac_info_data,
- lldb::offset_t *offset_ptr) {
- if (mac_info_data.ValidOffset(*offset_ptr)) {
- m_type_code = mac_info_data.GetU8(offset_ptr);
-
- switch (m_type_code) {
-
- case DW_MACINFO_define:
- case DW_MACINFO_undef:
- // 2 operands:
- // Arg 1: operand encodes the line number of the source line on which
- // the relevant defining or undefining pre-processor directives
- // appeared.
- m_line = mac_info_data.GetULEB128(offset_ptr);
- // Arg 2: define string
- m_op2.cstr = mac_info_data.GetCStr(offset_ptr);
- break;
-
- case DW_MACINFO_start_file:
- // 2 operands:
- // Op 1: line number of the source line on which the inclusion
- // pre-processor directive occurred.
- m_line = mac_info_data.GetULEB128(offset_ptr);
- // Op 2: a source file name index to a file number in the statement
- // information table for the relevant compilation unit.
- m_op2.file_idx = mac_info_data.GetULEB128(offset_ptr);
- break;
-
- case 0: // End of list
- case DW_MACINFO_end_file:
- // No operands
- m_line = DW_INVALID_OFFSET;
- m_op2.cstr = NULL;
- break;
- default:
- // Vendor specific entries always have a ULEB128 and a string
- m_line = mac_info_data.GetULEB128(offset_ptr);
- m_op2.cstr = mac_info_data.GetCStr(offset_ptr);
- break;
- }
- return true;
- } else
- m_type_code = 0;
-
- return false;
-}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h
deleted file mode 100644
index 96829c2fc09be..0000000000000
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacinfoEntry.h
+++ /dev/null
@@ -1,42 +0,0 @@
-//===-- DWARFDebugMacinfoEntry.h --------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef SymbolFileDWARF_DWARFDebugMacinfoEntry_h_
-#define SymbolFileDWARF_DWARFDebugMacinfoEntry_h_
-
-#include "SymbolFileDWARF.h"
-
-class DWARFDebugMacinfoEntry {
-public:
- DWARFDebugMacinfoEntry();
-
- ~DWARFDebugMacinfoEntry();
-
- uint8_t TypeCode() const { return m_type_code; }
-
- uint8_t GetLineNumber() const { return m_line; }
-
- void Dump(lldb_private::Stream *s) const;
-
- const char *GetCString() const;
-
- bool Extract(const lldb_private::DWARFDataExtractor &mac_info_data,
- lldb::offset_t *offset_ptr);
-
-protected:
-private:
- uint8_t m_type_code;
- dw_uleb128_t m_line;
- union {
- dw_uleb128_t file_idx;
- const char *cstr;
- } m_op2;
-};
-
-#endif // SymbolFileDWARF_DWARFDebugMacinfoEntry_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
index d79acdc5cfc47..4238be7ec1c39 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDebugMacro.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
index 021b434cd4573..c3a93a9f4d14a 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h
@@ -1,10 +1,9 @@
//===-- DWARFDebugMacro.h ----------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
index a0436dd7ffad4..207c71211c9a5 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp
@@ -1,20 +1,16 @@
//===-- DWARFDebugRanges.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFDebugRanges.h"
#include "DWARFUnit.h"
-#include "SymbolFileDWARF.h"
#include "lldb/Utility/Stream.h"
-#include <assert.h>
using namespace lldb_private;
-using namespace std;
static dw_addr_t GetBaseAddressMarker(uint32_t addr_size) {
switch(addr_size) {
@@ -30,25 +26,24 @@ static dw_addr_t GetBaseAddressMarker(uint32_t addr_size) {
DWARFDebugRanges::DWARFDebugRanges() : m_range_map() {}
-void DWARFDebugRanges::Extract(SymbolFileDWARF *dwarf2Data) {
+void DWARFDebugRanges::Extract(DWARFContext &context) {
DWARFRangeList range_list;
lldb::offset_t offset = 0;
dw_offset_t debug_ranges_offset = offset;
- while (Extract(dwarf2Data, &offset, range_list)) {
+ while (Extract(context, &offset, range_list)) {
range_list.Sort();
m_range_map[debug_ranges_offset] = range_list;
debug_ranges_offset = offset;
}
}
-bool DWARFDebugRanges::Extract(SymbolFileDWARF *dwarf2Data,
+bool DWARFDebugRanges::Extract(DWARFContext &context,
lldb::offset_t *offset_ptr,
DWARFRangeList &range_list) {
range_list.Clear();
lldb::offset_t range_offset = *offset_ptr;
- const DWARFDataExtractor &debug_ranges_data =
- dwarf2Data->get_debug_ranges_data();
+ const DWARFDataExtractor &debug_ranges_data = context.getOrLoadRangesData();
uint32_t addr_size = debug_ranges_data.GetAddressByteSize();
dw_addr_t base_addr = 0;
dw_addr_t base_addr_marker = GetBaseAddressMarker(addr_size);
@@ -106,7 +101,7 @@ void DWARFDebugRanges::Dump(Stream &s,
dw_addr_t begin_addr = begin + base_addr;
dw_addr_t end_addr = end + base_addr;
- s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t), NULL);
+ s.AddressRange(begin_addr, end_addr, sizeof(dw_addr_t), nullptr);
}
}
}
@@ -205,8 +200,10 @@ static uint64_t ReadAddressFromDebugAddrSection(const DWARFUnit *cu,
uint32_t index_size = cu->GetAddressByteSize();
dw_offset_t addr_base = cu->GetAddrBase();
lldb::offset_t offset = addr_base + index * index_size;
- return cu->GetSymbolFileDWARF()->get_debug_addr_data().GetMaxU64(&offset,
- index_size);
+ return cu->GetSymbolFileDWARF()
+ .GetDWARFContext()
+ .getOrLoadAddrData()
+ .GetMaxU64(&offset, index_size);
}
bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu,
@@ -256,14 +253,12 @@ bool DWARFDebugRngLists::FindRanges(const DWARFUnit *cu,
return false;
}
-void DWARFDebugRngLists::Extract(SymbolFileDWARF *dwarf2Data) {
- const DWARFDataExtractor &data = dwarf2Data->get_debug_rnglists_data();
+void DWARFDebugRngLists::Extract(DWARFContext &context) {
+ const DWARFDataExtractor &data = context.getOrLoadRngListsData();
lldb::offset_t offset = 0;
uint64_t length = data.GetU32(&offset);
- bool isDwarf64 = (length == 0xffffffff);
- if (isDwarf64)
- length = data.GetU64(&offset);
+ // FIXME: Handle DWARF64.
lldb::offset_t end = offset + length;
// Check version.
@@ -280,7 +275,7 @@ void DWARFDebugRngLists::Extract(SymbolFileDWARF *dwarf2Data) {
uint32_t offsetsAmount = data.GetU32(&offset);
for (uint32_t i = 0; i < offsetsAmount; ++i)
- Offsets.push_back(data.GetMaxU64(&offset, isDwarf64 ? 8 : 4));
+ Offsets.push_back(data.GetMaxU64(&offset, 4));
lldb::offset_t listOffset = offset;
std::vector<RngListEntry> rangeList;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
index 5790f448ba851..baf2667f0afea 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
@@ -1,25 +1,27 @@
//===-- DWARFDebugRanges.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef SymbolFileDWARF_DWARFDebugRanges_h_
#define SymbolFileDWARF_DWARFDebugRanges_h_
-#include "DWARFDIE.h"
-#include "SymbolFileDWARF.h"
-
+#include "lldb/Core/dwarf.h"
#include <map>
+class DWARFUnit;
+namespace lldb_private {
+class DWARFContext;
+}
+
class DWARFDebugRangesBase {
public:
virtual ~DWARFDebugRangesBase(){};
- virtual void Extract(SymbolFileDWARF *dwarf2Data) = 0;
+ virtual void Extract(lldb_private::DWARFContext &context) = 0;
virtual bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
DWARFRangeList &range_list) const = 0;
virtual uint64_t GetOffset(size_t Index) const = 0;
@@ -29,7 +31,7 @@ class DWARFDebugRanges final : public DWARFDebugRangesBase {
public:
DWARFDebugRanges();
- void Extract(SymbolFileDWARF *dwarf2Data) override;
+ void Extract(lldb_private::DWARFContext &context) override;
bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
DWARFRangeList &range_list) const override;
uint64_t GetOffset(size_t Index) const override;
@@ -39,7 +41,7 @@ public:
lldb::offset_t *offset_ptr, dw_addr_t cu_base_addr);
protected:
- bool Extract(SymbolFileDWARF *dwarf2Data, lldb::offset_t *offset_ptr,
+ bool Extract(lldb_private::DWARFContext &context, lldb::offset_t *offset_ptr,
DWARFRangeList &range_list);
typedef std::map<dw_offset_t, DWARFRangeList> range_map;
@@ -57,7 +59,7 @@ class DWARFDebugRngLists final : public DWARFDebugRangesBase {
};
public:
- void Extract(SymbolFileDWARF *dwarf2Data) override;
+ void Extract(lldb_private::DWARFContext &context) override;
bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset,
DWARFRangeList &range_list) const override;
uint64_t GetOffset(size_t Index) const override;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
index dbaf0b0ed1273..a664314035e4d 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDeclContext.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,7 +29,7 @@ const char *DWARFDeclContext::GetQualifiedName() const {
for (pos = begin; pos != end; ++pos) {
if (pos != begin)
m_qualified_name.append("::");
- if (pos->name == NULL) {
+ if (pos->name == nullptr) {
if (pos->tag == DW_TAG_namespace)
m_qualified_name.append("(anonymous namespace)");
else if (pos->tag == DW_TAG_class_type)
@@ -48,7 +47,7 @@ const char *DWARFDeclContext::GetQualifiedName() const {
}
}
if (m_qualified_name.empty())
- return NULL;
+ return nullptr;
return m_qualified_name.c_str();
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
index aff5ea64e9ce4..d0d70dd5123e1 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
@@ -1,9 +1,8 @@
//===-- DWARFDeclContext.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,18 +14,16 @@
#include "lldb/Utility/ConstString.h"
#include "DWARFDefines.h"
-//----------------------------------------------------------------------
// DWARFDeclContext
//
// A class that represents a declaration context all the way down to a
// DIE. This is useful when trying to find a DIE in one DWARF to a DIE
// in another DWARF file.
-//----------------------------------------------------------------------
class DWARFDeclContext {
public:
struct Entry {
- Entry() : tag(0), name(NULL) {}
+ Entry() : tag(0), name(nullptr) {}
Entry(dw_tag_t t, const char *n) : tag(t), name(n) {}
bool NameMatches(const Entry &rhs) const {
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
index 99becdbb2bc12..3bf0bb0882273 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
@@ -1,9 +1,8 @@
//===-- DWARFDefines.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,17 +28,6 @@ const char *DW_TAG_value_to_name(uint32_t val) {
return llvmstr.data();
}
-const char *DW_CHILDREN_value_to_name(uint8_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::ChildrenString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_CHILDREN constant: 0x%x",
- val);
- return invalid;
- }
- return llvmstr.data();
-}
-
const char *DW_AT_value_to_name(uint32_t val) {
static char invalid[100];
llvm::StringRef llvmstr = llvm::dwarf::AttributeString(val);
@@ -391,38 +379,6 @@ const char *DW_ATE_value_to_name(uint32_t val) {
return llvmstr.data();
}
-const char *DW_ACCESS_value_to_name(uint32_t val) {
- static char invalid[100];
-
- llvm::StringRef llvmstr = llvm::dwarf::AccessibilityString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_ACCESS constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_VIS_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::VisibilityString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_VIS constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_VIRTUALITY_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::VirtualityString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_VIRTUALITY constant: 0x%x",
- val);
- return invalid;
- }
- return llvmstr.data();
-}
-
const char *DW_LANG_value_to_name(uint32_t val) {
static char invalid[100];
llvm::StringRef llvmstr = llvm::dwarf::LanguageString(val);
@@ -433,46 +389,6 @@ const char *DW_LANG_value_to_name(uint32_t val) {
return llvmstr.data();
}
-const char *DW_ID_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::CaseString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_ID constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_CC_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::ConventionString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_CC constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_INL_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::InlineCodeString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_INL constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_ORD_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::ArrayOrderString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_ORD constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
const char *DW_LNS_value_to_name(uint32_t val) {
static char invalid[100];
llvm::StringRef llvmstr = llvm::dwarf::LNStandardString(val);
@@ -483,157 +399,4 @@ const char *DW_LNS_value_to_name(uint32_t val) {
return llvmstr.data();
}
-const char *DW_LNE_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::LNExtendedString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_LNE constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_MACINFO_value_to_name(uint32_t val) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::MacinfoString(val);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_MACINFO constant: 0x%x",
- val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-const char *DW_CFA_value_to_name(uint32_t val, llvm::Triple::ArchType Arch) {
- static char invalid[100];
- llvm::StringRef llvmstr = llvm::dwarf::CallFrameString(val, Arch);
- if (llvmstr.empty()) {
- snprintf(invalid, sizeof(invalid), "Unknown DW_CFA constant: 0x%x", val);
- return invalid;
- }
- return llvmstr.data();
-}
-
-DW_TAG_CategoryEnum get_tag_category(uint16_t tag) {
- switch (tag) {
- case DW_TAG_array_type:
- return TagCategoryType;
- case DW_TAG_class_type:
- return TagCategoryType;
- case DW_TAG_entry_point:
- return TagCategoryProgram;
- case DW_TAG_enumeration_type:
- return TagCategoryType;
- case DW_TAG_formal_parameter:
- return TagCategoryVariable;
- case DW_TAG_imported_declaration:
- return TagCategoryProgram;
- case DW_TAG_label:
- return TagCategoryProgram;
- case DW_TAG_lexical_block:
- return TagCategoryProgram;
- case DW_TAG_member:
- return TagCategoryType;
- case DW_TAG_pointer_type:
- return TagCategoryType;
- case DW_TAG_reference_type:
- return TagCategoryType;
- case DW_TAG_compile_unit:
- return TagCategoryProgram;
- case DW_TAG_string_type:
- return TagCategoryType;
- case DW_TAG_structure_type:
- return TagCategoryType;
- case DW_TAG_subroutine_type:
- return TagCategoryType;
- case DW_TAG_typedef:
- return TagCategoryType;
- case DW_TAG_union_type:
- return TagCategoryType;
- case DW_TAG_unspecified_parameters:
- return TagCategoryVariable;
- case DW_TAG_variant:
- return TagCategoryType;
- case DW_TAG_common_block:
- return TagCategoryProgram;
- case DW_TAG_common_inclusion:
- return TagCategoryProgram;
- case DW_TAG_inheritance:
- return TagCategoryType;
- case DW_TAG_inlined_subroutine:
- return TagCategoryProgram;
- case DW_TAG_module:
- return TagCategoryProgram;
- case DW_TAG_ptr_to_member_type:
- return TagCategoryType;
- case DW_TAG_set_type:
- return TagCategoryType;
- case DW_TAG_subrange_type:
- return TagCategoryType;
- case DW_TAG_with_stmt:
- return TagCategoryProgram;
- case DW_TAG_access_declaration:
- return TagCategoryProgram;
- case DW_TAG_base_type:
- return TagCategoryType;
- case DW_TAG_catch_block:
- return TagCategoryProgram;
- case DW_TAG_const_type:
- return TagCategoryType;
- case DW_TAG_constant:
- return TagCategoryVariable;
- case DW_TAG_enumerator:
- return TagCategoryType;
- case DW_TAG_file_type:
- return TagCategoryType;
- case DW_TAG_friend:
- return TagCategoryType;
- case DW_TAG_namelist:
- return TagCategoryVariable;
- case DW_TAG_namelist_item:
- return TagCategoryVariable;
- case DW_TAG_packed_type:
- return TagCategoryType;
- case DW_TAG_subprogram:
- return TagCategoryProgram;
- case DW_TAG_template_type_parameter:
- return TagCategoryType;
- case DW_TAG_template_value_parameter:
- return TagCategoryType;
- case DW_TAG_GNU_template_parameter_pack:
- return TagCategoryType;
- case DW_TAG_thrown_type:
- return TagCategoryType;
- case DW_TAG_try_block:
- return TagCategoryProgram;
- case DW_TAG_variant_part:
- return TagCategoryType;
- case DW_TAG_variable:
- return TagCategoryVariable;
- case DW_TAG_volatile_type:
- return TagCategoryType;
- case DW_TAG_dwarf_procedure:
- return TagCategoryProgram;
- case DW_TAG_restrict_type:
- return TagCategoryType;
- case DW_TAG_interface_type:
- return TagCategoryType;
- case DW_TAG_namespace:
- return TagCategoryProgram;
- case DW_TAG_imported_module:
- return TagCategoryProgram;
- case DW_TAG_unspecified_type:
- return TagCategoryType;
- case DW_TAG_partial_unit:
- return TagCategoryProgram;
- case DW_TAG_imported_unit:
- return TagCategoryProgram;
- case DW_TAG_shared_type:
- return TagCategoryType;
- default:
- break;
- }
- return TagCategoryProgram;
-}
-
} // namespace lldb_private
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDefines.h b/source/Plugins/SymbolFile/DWARF/DWARFDefines.h
index 0f5a885efb867..d16cb07baf884 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFDefines.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFDefines.h
@@ -1,9 +1,8 @@
//===-- DWARFDefines.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,23 +14,12 @@
namespace lldb_private {
-typedef uint32_t DRC_class; // Holds DRC_* class bitfields
-
-enum DW_TAG_Category {
- TagCategoryVariable,
- TagCategoryType,
- TagCategoryProgram,
- kNumTagCategories
-};
+enum class DWARFEnumState { MoreItems, Complete };
-typedef enum DW_TAG_Category DW_TAG_CategoryEnum;
+typedef uint32_t DRC_class; // Holds DRC_* class bitfields
const char *DW_TAG_value_to_name(uint32_t val);
-DW_TAG_CategoryEnum get_tag_category(uint16_t tag);
-
-const char *DW_CHILDREN_value_to_name(uint8_t val);
-
const char *DW_AT_value_to_name(uint32_t val);
const char *DW_FORM_value_to_name(uint32_t val);
@@ -42,32 +30,10 @@ DRC_class DW_OP_value_to_class(uint32_t val);
const char *DW_ATE_value_to_name(uint32_t val);
-const char *DW_ACCESS_value_to_name(uint32_t val);
-
-const char *DW_VIS_value_to_name(uint32_t val);
-
-const char *DW_VIRTUALITY_value_to_name(uint32_t val);
-
const char *DW_LANG_value_to_name(uint32_t val);
-const char *DW_ID_value_to_name(uint32_t val);
-
-const char *DW_CC_value_to_name(uint32_t val);
-
-const char *DW_INL_value_to_name(uint32_t val);
-
-const char *DW_ORD_value_to_name(uint32_t val);
-
const char *DW_LNS_value_to_name(uint32_t val);
-const char *DW_LNE_value_to_name(uint32_t val);
-
-const char *DW_MACINFO_value_to_name(uint32_t val);
-
-const char *DW_CFA_value_to_name(uint32_t val, llvm::Triple::ArchType Arch);
-
-const char *DW_GNU_EH_PE_value_to_name(uint32_t val);
-
/* These DRC are entirely our own construction,
although they are derived from various comments in the DWARF standard.
Most of these are not useful to the parser, but the DW_AT and DW_FORM
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index 5d2a8ffdb85b3..046ae67446af4 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -1,169 +1,30 @@
//===-- DWARFFormValue.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <assert.h>
+#include "lldb/Core/Module.h"
#include "lldb/Core/dwarf.h"
+#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/Stream.h"
-#include "DWARFUnit.h"
+#include "DWARFDebugInfo.h"
#include "DWARFFormValue.h"
+#include "DWARFUnit.h"
class DWARFUnit;
using namespace lldb_private;
-static uint8_t g_form_sizes_addr4[] = {
- 0, // 0x00 unused
- 4, // 0x01 DW_FORM_addr
- 0, // 0x02 unused
- 0, // 0x03 DW_FORM_block2
- 0, // 0x04 DW_FORM_block4
- 2, // 0x05 DW_FORM_data2
- 4, // 0x06 DW_FORM_data4
- 8, // 0x07 DW_FORM_data8
- 0, // 0x08 DW_FORM_string
- 0, // 0x09 DW_FORM_block
- 0, // 0x0a DW_FORM_block1
- 1, // 0x0b DW_FORM_data1
- 1, // 0x0c DW_FORM_flag
- 0, // 0x0d DW_FORM_sdata
- 4, // 0x0e DW_FORM_strp
- 0, // 0x0f DW_FORM_udata
- 0, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes for
- // DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
- 1, // 0x11 DW_FORM_ref1
- 2, // 0x12 DW_FORM_ref2
- 4, // 0x13 DW_FORM_ref4
- 8, // 0x14 DW_FORM_ref8
- 0, // 0x15 DW_FORM_ref_udata
- 0, // 0x16 DW_FORM_indirect
- 4, // 0x17 DW_FORM_sec_offset
- 0, // 0x18 DW_FORM_exprloc
- 0, // 0x19 DW_FORM_flag_present
- 0, // 0x1a
- 0, // 0x1b
- 0, // 0x1c
- 0, // 0x1d
- 0, // 0x1e
- 0, // 0x1f
- 8, // 0x20 DW_FORM_ref_sig8
-
-};
-
-static uint8_t g_form_sizes_addr8[] = {
- 0, // 0x00 unused
- 8, // 0x01 DW_FORM_addr
- 0, // 0x02 unused
- 0, // 0x03 DW_FORM_block2
- 0, // 0x04 DW_FORM_block4
- 2, // 0x05 DW_FORM_data2
- 4, // 0x06 DW_FORM_data4
- 8, // 0x07 DW_FORM_data8
- 0, // 0x08 DW_FORM_string
- 0, // 0x09 DW_FORM_block
- 0, // 0x0a DW_FORM_block1
- 1, // 0x0b DW_FORM_data1
- 1, // 0x0c DW_FORM_flag
- 0, // 0x0d DW_FORM_sdata
- 4, // 0x0e DW_FORM_strp
- 0, // 0x0f DW_FORM_udata
- 0, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes for
- // DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
- 1, // 0x11 DW_FORM_ref1
- 2, // 0x12 DW_FORM_ref2
- 4, // 0x13 DW_FORM_ref4
- 8, // 0x14 DW_FORM_ref8
- 0, // 0x15 DW_FORM_ref_udata
- 0, // 0x16 DW_FORM_indirect
- 4, // 0x17 DW_FORM_sec_offset
- 0, // 0x18 DW_FORM_exprloc
- 0, // 0x19 DW_FORM_flag_present
- 0, // 0x1a
- 0, // 0x1b
- 0, // 0x1c
- 0, // 0x1d
- 0, // 0x1e
- 0, // 0x1f
- 8, // 0x20 DW_FORM_ref_sig8
-};
-
-// Difference with g_form_sizes_addr8:
-// DW_FORM_strp and DW_FORM_sec_offset are 8 instead of 4
-static uint8_t g_form_sizes_addr8_dwarf64[] = {
- 0, // 0x00 unused
- 8, // 0x01 DW_FORM_addr
- 0, // 0x02 unused
- 0, // 0x03 DW_FORM_block2
- 0, // 0x04 DW_FORM_block4
- 2, // 0x05 DW_FORM_data2
- 4, // 0x06 DW_FORM_data4
- 8, // 0x07 DW_FORM_data8
- 0, // 0x08 DW_FORM_string
- 0, // 0x09 DW_FORM_block
- 0, // 0x0a DW_FORM_block1
- 1, // 0x0b DW_FORM_data1
- 1, // 0x0c DW_FORM_flag
- 0, // 0x0d DW_FORM_sdata
- 8, // 0x0e DW_FORM_strp
- 0, // 0x0f DW_FORM_udata
- 0, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes for
- // DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
- 1, // 0x11 DW_FORM_ref1
- 2, // 0x12 DW_FORM_ref2
- 4, // 0x13 DW_FORM_ref4
- 8, // 0x14 DW_FORM_ref8
- 0, // 0x15 DW_FORM_ref_udata
- 0, // 0x16 DW_FORM_indirect
- 8, // 0x17 DW_FORM_sec_offset
- 0, // 0x18 DW_FORM_exprloc
- 0, // 0x19 DW_FORM_flag_present
- 0, // 0x1a
- 0, // 0x1b
- 0, // 0x1c
- 0, // 0x1d
- 0, // 0x1e
- 0, // 0x1f
- 8, // 0x20 DW_FORM_ref_sig8
-};
-
-DWARFFormValue::FixedFormSizes
-DWARFFormValue::GetFixedFormSizesForAddressSize(uint8_t addr_size,
- bool is_dwarf64) {
- if (!is_dwarf64) {
- switch (addr_size) {
- case 4:
- return FixedFormSizes(g_form_sizes_addr4, sizeof(g_form_sizes_addr4));
- case 8:
- return FixedFormSizes(g_form_sizes_addr8, sizeof(g_form_sizes_addr8));
- }
- } else {
- if (addr_size == 8)
- return FixedFormSizes(g_form_sizes_addr8_dwarf64,
- sizeof(g_form_sizes_addr8_dwarf64));
- // is_dwarf64 && addr_size == 4 : no provider does this.
- }
- return FixedFormSizes();
-}
-
-DWARFFormValue::DWARFFormValue() : m_cu(NULL), m_form(0), m_value() {}
-
-DWARFFormValue::DWARFFormValue(const DWARFUnit *cu)
- : m_cu(cu), m_form(0), m_value() {}
-
-DWARFFormValue::DWARFFormValue(const DWARFUnit *cu, dw_form_t form)
- : m_cu(cu), m_form(form), m_value() {}
-
void DWARFFormValue::Clear() {
- m_cu = nullptr;
+ m_unit = nullptr;
m_form = 0;
- memset(&m_value, 0, sizeof(m_value));
+ m_value = ValueTypeTag();
}
bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
@@ -173,7 +34,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
bool indirect = false;
bool is_block = false;
- m_value.data = NULL;
+ m_value.data = nullptr;
uint8_t ref_addr_size;
// Read the value for the form into value and follow and DW_FORM_indirect
// instances we run into
@@ -181,9 +42,9 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
indirect = false;
switch (m_form) {
case DW_FORM_addr:
- assert(m_cu);
+ assert(m_unit);
m_value.value.uval =
- data.GetMaxU64(offset_ptr, DWARFUnit::GetAddressByteSize(m_cu));
+ data.GetMaxU64(offset_ptr, DWARFUnit::GetAddressByteSize(m_unit));
break;
case DW_FORM_block1:
m_value.value.uval = data.GetU8(offset_ptr);
@@ -215,9 +76,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
case DW_FORM_strp:
case DW_FORM_line_strp:
case DW_FORM_sec_offset:
- assert(m_cu);
- m_value.value.uval =
- data.GetMaxU64(offset_ptr, DWARFUnit::IsDWARF64(m_cu) ? 8 : 4);
+ m_value.value.uval = data.GetMaxU64(offset_ptr, 4);
break;
case DW_FORM_addrx1:
case DW_FORM_strx1:
@@ -257,11 +116,11 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
m_value.value.uval = data.GetULEB128(offset_ptr);
break;
case DW_FORM_ref_addr:
- assert(m_cu);
- if (m_cu->GetVersion() <= 2)
- ref_addr_size = m_cu->GetAddressByteSize();
+ assert(m_unit);
+ if (m_unit->GetVersion() <= 2)
+ ref_addr_size = m_unit->GetAddressByteSize();
else
- ref_addr_size = m_cu->IsDWARF64() ? 8 : 4;
+ ref_addr_size = 4;
m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
break;
case DW_FORM_indirect:
@@ -278,7 +137,7 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
if (is_block) {
m_value.data = data.PeekData(*offset_ptr, m_value.value.uval);
- if (m_value.data != NULL) {
+ if (m_value.data != nullptr) {
*offset_ptr += m_value.value.uval;
}
}
@@ -286,15 +145,68 @@ bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
return true;
}
+struct FormSize {
+ uint8_t valid:1, size:7;
+};
+static FormSize g_form_sizes[] = {
+ {0,0}, // 0x00 unused
+ {0,0}, // 0x01 DW_FORM_addr
+ {0,0}, // 0x02 unused
+ {0,0}, // 0x03 DW_FORM_block2
+ {0,0}, // 0x04 DW_FORM_block4
+ {1,2}, // 0x05 DW_FORM_data2
+ {1,4}, // 0x06 DW_FORM_data4
+ {1,8}, // 0x07 DW_FORM_data8
+ {0,0}, // 0x08 DW_FORM_string
+ {0,0}, // 0x09 DW_FORM_block
+ {0,0}, // 0x0a DW_FORM_block1
+ {1,1}, // 0x0b DW_FORM_data1
+ {1,1}, // 0x0c DW_FORM_flag
+ {0,0}, // 0x0d DW_FORM_sdata
+ {1,4}, // 0x0e DW_FORM_strp
+ {0,0}, // 0x0f DW_FORM_udata
+ {0,0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes for
+ // DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
+ {1,1}, // 0x11 DW_FORM_ref1
+ {1,2}, // 0x12 DW_FORM_ref2
+ {1,4}, // 0x13 DW_FORM_ref4
+ {1,8}, // 0x14 DW_FORM_ref8
+ {0,0}, // 0x15 DW_FORM_ref_udata
+ {0,0}, // 0x16 DW_FORM_indirect
+ {1,4}, // 0x17 DW_FORM_sec_offset
+ {0,0}, // 0x18 DW_FORM_exprloc
+ {1,0}, // 0x19 DW_FORM_flag_present
+ {0,0}, // 0x1a
+ {0,0}, // 0x1b
+ {0,0}, // 0x1c
+ {0,0}, // 0x1d
+ {0,0}, // 0x1e
+ {0,0}, // 0x1f
+ {1,8}, // 0x20 DW_FORM_ref_sig8
+};
+
+llvm::Optional<uint8_t>
+DWARFFormValue::GetFixedSize(dw_form_t form, const DWARFUnit *u) {
+ if (form <= DW_FORM_ref_sig8 && g_form_sizes[form].valid)
+ return g_form_sizes[form].size;
+ if (form == DW_FORM_addr && u)
+ return u->GetAddressByteSize();
+ return llvm::None;
+}
+
+llvm::Optional<uint8_t> DWARFFormValue::GetFixedSize() const {
+ return GetFixedSize(m_form, m_unit);
+}
+
bool DWARFFormValue::SkipValue(const DWARFDataExtractor &debug_info_data,
lldb::offset_t *offset_ptr) const {
- return DWARFFormValue::SkipValue(m_form, debug_info_data, offset_ptr, m_cu);
+ return DWARFFormValue::SkipValue(m_form, debug_info_data, offset_ptr, m_unit);
}
bool DWARFFormValue::SkipValue(dw_form_t form,
const DWARFDataExtractor &debug_info_data,
lldb::offset_t *offset_ptr,
- const DWARFUnit *cu) {
+ const DWARFUnit *unit) {
uint8_t ref_addr_size;
switch (form) {
// Blocks if inlined data that have a length field and the data bytes inlined
@@ -328,17 +240,17 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
// Compile unit address sized values
case DW_FORM_addr:
- *offset_ptr += DWARFUnit::GetAddressByteSize(cu);
+ *offset_ptr += DWARFUnit::GetAddressByteSize(unit);
return true;
case DW_FORM_ref_addr:
ref_addr_size = 4;
- assert(cu); // CU must be valid for DW_FORM_ref_addr objects or we will get
- // this wrong
- if (cu->GetVersion() <= 2)
- ref_addr_size = cu->GetAddressByteSize();
+ assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
+ // get this wrong
+ if (unit->GetVersion() <= 2)
+ ref_addr_size = unit->GetAddressByteSize();
else
- ref_addr_size = cu->IsDWARF64() ? 8 : 4;
+ ref_addr_size = 4;
*offset_ptr += ref_addr_size;
return true;
@@ -373,8 +285,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
// 32 bit for DWARF 32, 64 for DWARF 64
case DW_FORM_sec_offset:
case DW_FORM_strp:
- assert(cu);
- *offset_ptr += (cu->IsDWARF64() ? 8 : 4);
+ *offset_ptr += 4;
return true;
// 4 byte values
@@ -407,7 +318,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
case DW_FORM_indirect: {
dw_form_t indirect_form = debug_info_data.GetULEB128(offset_ptr);
return DWARFFormValue::SkipValue(indirect_form, debug_info_data, offset_ptr,
- cu);
+ unit);
}
default:
@@ -418,7 +329,7 @@ bool DWARFFormValue::SkipValue(dw_form_t form,
void DWARFFormValue::Dump(Stream &s) const {
uint64_t uvalue = Unsigned();
- bool cu_relative_offset = false;
+ bool unit_relative_offset = false;
switch (m_form) {
case DW_FORM_addr:
@@ -495,9 +406,9 @@ void DWARFFormValue::Dump(Stream &s) const {
} break;
case DW_FORM_ref_addr: {
- assert(m_cu); // CU must be valid for DW_FORM_ref_addr objects or we will
- // get this wrong
- if (m_cu->GetVersion() <= 2)
+ assert(m_unit); // Unit must be valid for DW_FORM_ref_addr objects or we
+ // will get this wrong
+ if (m_unit->GetVersion() <= 2)
s.Address(uvalue, sizeof(uint64_t) * 2);
else
s.Address(uvalue, 4 * 2); // 4 for DWARF32, 8 for DWARF64, but we don't
@@ -505,19 +416,19 @@ void DWARFFormValue::Dump(Stream &s) const {
break;
}
case DW_FORM_ref1:
- cu_relative_offset = true;
+ unit_relative_offset = true;
break;
case DW_FORM_ref2:
- cu_relative_offset = true;
+ unit_relative_offset = true;
break;
case DW_FORM_ref4:
- cu_relative_offset = true;
+ unit_relative_offset = true;
break;
case DW_FORM_ref8:
- cu_relative_offset = true;
+ unit_relative_offset = true;
break;
case DW_FORM_ref_udata:
- cu_relative_offset = true;
+ unit_relative_offset = true;
break;
// All DW_FORM_indirect attributes should be resolved prior to calling this
@@ -532,33 +443,29 @@ void DWARFFormValue::Dump(Stream &s) const {
break;
}
- if (cu_relative_offset) {
- assert(m_cu); // CU must be valid for DW_FORM_ref forms that are compile
- // unit relative or we will get this wrong
- s.Printf("{0x%8.8" PRIx64 "}", uvalue + m_cu->GetOffset());
+ if (unit_relative_offset) {
+ assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
+ // unit relative or we will get this wrong
+ s.Printf("{0x%8.8" PRIx64 "}", uvalue + m_unit->GetOffset());
}
}
const char *DWARFFormValue::AsCString() const {
- SymbolFileDWARF *symbol_file = m_cu->GetSymbolFileDWARF();
+ SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
if (m_form == DW_FORM_string) {
return m_value.value.cstr;
} else if (m_form == DW_FORM_strp) {
- if (!symbol_file)
- return nullptr;
-
- return symbol_file->get_debug_str_data().PeekCStr(m_value.value.uval);
+ return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
+ m_value.value.uval);
} else if (m_form == DW_FORM_GNU_str_index) {
- if (!symbol_file)
- return nullptr;
-
- uint32_t index_size = m_cu->IsDWARF64() ? 8 : 4;
+ uint32_t index_size = 4;
lldb::offset_t offset = m_value.value.uval * index_size;
dw_offset_t str_offset =
- symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset,
- index_size);
- return symbol_file->get_debug_str_data().PeekCStr(str_offset);
+ symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
+ &offset, index_size);
+ return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
+ str_offset);
}
if (m_form == DW_FORM_strx || m_form == DW_FORM_strx1 ||
@@ -566,44 +473,41 @@ const char *DWARFFormValue::AsCString() const {
m_form == DW_FORM_strx4) {
// The same code as above.
- if (!symbol_file)
- return nullptr;
-
- uint32_t indexSize = m_cu->IsDWARF64() ? 8 : 4;
+ uint32_t indexSize = 4;
lldb::offset_t offset =
- m_cu->GetStrOffsetsBase() + m_value.value.uval * indexSize;
+ m_unit->GetStrOffsetsBase() + m_value.value.uval * indexSize;
dw_offset_t strOffset =
- symbol_file->get_debug_str_offsets_data().GetMaxU64(&offset, indexSize);
- return symbol_file->get_debug_str_data().PeekCStr(strOffset);
+ symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
+ &offset, indexSize);
+ return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(strOffset);
}
if (m_form == DW_FORM_line_strp)
- return symbol_file->get_debug_line_str_data().PeekCStr(m_value.value.uval);
+ return symbol_file.GetDWARFContext().getOrLoadLineStrData().PeekCStr(
+ m_value.value.uval);
return nullptr;
}
dw_addr_t DWARFFormValue::Address() const {
- SymbolFileDWARF *symbol_file = m_cu->GetSymbolFileDWARF();
+ SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
if (m_form == DW_FORM_addr)
return Unsigned();
- assert(m_cu);
+ assert(m_unit);
assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx ||
m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 ||
m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4);
- if (!symbol_file)
- return 0;
-
- uint32_t index_size = m_cu->GetAddressByteSize();
- dw_offset_t addr_base = m_cu->GetAddrBase();
+ uint32_t index_size = m_unit->GetAddressByteSize();
+ dw_offset_t addr_base = m_unit->GetAddrBase();
lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
- return symbol_file->get_debug_addr_data().GetMaxU64(&offset, index_size);
+ return symbol_file.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
+ &offset, index_size);
}
-uint64_t DWARFFormValue::Reference() const {
+DWARFDIE DWARFFormValue::Reference() const {
uint64_t value = m_value.value.uval;
switch (m_form) {
case DW_FORM_ref1:
@@ -611,17 +515,40 @@ uint64_t DWARFFormValue::Reference() const {
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata:
- assert(m_cu); // CU must be valid for DW_FORM_ref forms that are compile
- // unit relative or we will get this wrong
- return value + m_cu->GetOffset();
+ assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
+ // unit relative or we will get this wrong
+ value += m_unit->GetOffset();
+ if (!m_unit->ContainsDIEOffset(value)) {
+ m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+ "DW_FORM_ref* DIE reference 0x%" PRIx64 " is outside of its CU",
+ value);
+ return {};
+ }
+ return const_cast<DWARFUnit *>(m_unit)->GetDIE(value);
- case DW_FORM_ref_addr:
- case DW_FORM_ref_sig8:
- case DW_FORM_GNU_ref_alt:
- return value;
+ case DW_FORM_ref_addr: {
+ DWARFUnit *ref_cu =
+ m_unit->GetSymbolFileDWARF().DebugInfo()->GetUnitContainingDIEOffset(
+ DIERef::Section::DebugInfo, value);
+ if (!ref_cu) {
+ m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+ "DW_FORM_ref_addr DIE reference 0x%" PRIx64 " has no matching CU",
+ value);
+ return {};
+ }
+ return ref_cu->GetDIE(value);
+ }
+
+ case DW_FORM_ref_sig8: {
+ DWARFTypeUnit *tu =
+ m_unit->GetSymbolFileDWARF().DebugInfo()->GetTypeUnitForHash(value);
+ if (!tu)
+ return {};
+ return tu->GetDIE(tu->GetTypeOffset());
+ }
default:
- return DW_INVALID_OFFSET;
+ return {};
}
}
@@ -682,6 +609,7 @@ int DWARFFormValue::Compare(const DWARFFormValue &a_value,
return 1;
switch (a_form) {
case DW_FORM_addr:
+ case DW_FORM_addrx:
case DW_FORM_flag:
case DW_FORM_data1:
case DW_FORM_data2:
@@ -721,7 +649,7 @@ int DWARFFormValue::Compare(const DWARFFormValue &a_value,
return 0;
else if (a_string && b_string)
return strcmp(a_string, b_string);
- else if (a_string == NULL)
+ else if (a_string == nullptr)
return -1; // A string is NULL, and B is valid
else
return 1; // A string valid, and B is NULL
@@ -747,8 +675,8 @@ int DWARFFormValue::Compare(const DWARFFormValue &a_value,
case DW_FORM_ref4:
case DW_FORM_ref8:
case DW_FORM_ref_udata: {
- uint64_t a = a_value.Reference();
- uint64_t b = b_value.Reference();
+ uint64_t a = a_value.m_value.value.uval;
+ uint64_t b = b_value.m_value.value.uval;
if (a < b)
return -1;
if (a > b)
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
index 0890f0c1bfc55..848db2990ded7 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
@@ -1,9 +1,8 @@
//===-- DWARFFormValue.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,14 +11,16 @@
#include "DWARFDataExtractor.h"
#include <stddef.h>
+#include "llvm/ADT/Optional.h"
class DWARFUnit;
class SymbolFileDWARF;
+class DWARFDIE;
class DWARFFormValue {
public:
typedef struct ValueTypeTag {
- ValueTypeTag() : value(), data(NULL) { value.uval = 0; }
+ ValueTypeTag() : value(), data(nullptr) { value.uval = 0; }
union {
uint64_t uval;
@@ -29,24 +30,6 @@ public:
const uint8_t *data;
} ValueType;
- class FixedFormSizes {
- public:
- FixedFormSizes() : m_fix_sizes(nullptr), m_size(0) {}
-
- FixedFormSizes(const uint8_t *fix_sizes, size_t size)
- : m_fix_sizes(fix_sizes), m_size(size) {}
-
- uint8_t GetSize(uint32_t index) const {
- return index < m_size ? m_fix_sizes[index] : 0;
- }
-
- bool Empty() const { return m_size == 0; }
-
- private:
- const uint8_t *m_fix_sizes;
- size_t m_size;
- };
-
enum {
eValueTypeInvalid = 0,
eValueTypeUnsigned,
@@ -55,11 +38,11 @@ public:
eValueTypeBlock
};
- DWARFFormValue();
- DWARFFormValue(const DWARFUnit *cu);
- DWARFFormValue(const DWARFUnit *cu, dw_form_t form);
- const DWARFUnit *GetCompileUnit() const { return m_cu; }
- void SetCompileUnit(const DWARFUnit *cu) { m_cu = cu; }
+ DWARFFormValue() = default;
+ DWARFFormValue(const DWARFUnit *unit) : m_unit(unit) {}
+ DWARFFormValue(const DWARFUnit *unit, dw_form_t form)
+ : m_unit(unit), m_form(form) {}
+ void SetUnit(const DWARFUnit *unit) { m_unit = unit; }
dw_form_t Form() const { return m_form; }
dw_form_t& FormRef() { return m_form; }
void SetForm(dw_form_t form) { m_form = form; }
@@ -71,7 +54,10 @@ public:
bool ExtractValue(const lldb_private::DWARFDataExtractor &data,
lldb::offset_t *offset_ptr);
const uint8_t *BlockData() const;
- uint64_t Reference() const;
+ static llvm::Optional<uint8_t> GetFixedSize(dw_form_t form,
+ const DWARFUnit *u);
+ llvm::Optional<uint8_t> GetFixedSize() const;
+ DWARFDIE Reference() const;
uint64_t Reference(dw_offset_t offset) const;
bool Boolean() const { return m_value.value.uval != 0; }
uint64_t Unsigned() const { return m_value.value.uval; }
@@ -85,18 +71,18 @@ public:
lldb::offset_t *offset_ptr) const;
static bool SkipValue(const dw_form_t form,
const lldb_private::DWARFDataExtractor &debug_info_data,
- lldb::offset_t *offset_ptr, const DWARFUnit *cu);
+ lldb::offset_t *offset_ptr, const DWARFUnit *unit);
static bool IsBlockForm(const dw_form_t form);
static bool IsDataForm(const dw_form_t form);
- static FixedFormSizes GetFixedFormSizesForAddressSize(uint8_t addr_size,
- bool is_dwarf64);
static int Compare(const DWARFFormValue &a, const DWARFFormValue &b);
void Clear();
static bool FormIsSupported(dw_form_t form);
protected:
- const DWARFUnit *m_cu; // Compile unit for this form
- dw_form_t m_form; // Form for this value
+ // Compile unit where m_value was located.
+ // It may be different from compile unit where m_value refers to.
+ const DWARFUnit *m_unit = nullptr; // Unit for this form
+ dw_form_t m_form = 0; // Form for this value
ValueType m_value; // Contains all data for the form
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index 4577f0557a1de..c122f756e81aa 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -1,17 +1,15 @@
//===-- DWARFIndex.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
-#include "Plugins/SymbolFile/DWARF/DWARFDebugInfo.h"
-
#include "Plugins/Language/ObjC/ObjCLanguage.h"
+#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
using namespace lldb_private;
using namespace lldb;
@@ -19,13 +17,13 @@ using namespace lldb;
DWARFIndex::~DWARFIndex() = default;
void DWARFIndex::ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
- DWARFDebugInfo &info,
+ SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) {
- DWARFDIE die = info.GetDIE(ref);
+ DWARFDIE die = dwarf.GetDIE(ref);
if (!die) {
- ReportInvalidDIEOffset(ref.die_offset, name);
+ ReportInvalidDIERef(ref, name);
return;
}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 77af67b8e60f6..e3c7c5e63ac89 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -1,9 +1,8 @@
//===-- DWARFIndex.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,6 @@
#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"
#include "Plugins/SymbolFile/DWARF/DWARFFormValue.h"
-class DWARFDebugInfo;
class DWARFDeclContext;
class DWARFDIE;
@@ -41,15 +39,14 @@ public:
virtual void GetTypes(ConstString name, DIEArray &offsets) = 0;
virtual void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) = 0;
virtual void GetNamespaces(ConstString name, DIEArray &offsets) = 0;
- virtual void GetFunctions(ConstString name, DWARFDebugInfo &info,
+ virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) = 0;
virtual void GetFunctions(const RegularExpression &regex,
DIEArray &offsets) = 0;
- virtual void ReportInvalidDIEOffset(dw_offset_t offset,
- llvm::StringRef name) = 0;
+ virtual void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) = 0;
virtual void Dump(Stream &s) = 0;
protected:
@@ -60,7 +57,7 @@ protected:
/// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
/// vector.
void ProcessFunctionDIE(llvm::StringRef name, DIERef ref,
- DWARFDebugInfo &info,
+ SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask, std::vector<DWARFDIE> &dies);
};
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
new file mode 100644
index 0000000000000..fcc031bf1ea0f
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
@@ -0,0 +1,23 @@
+//===-- DWARFTypeUnit.cpp ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DWARFTypeUnit.h"
+
+#include "SymbolFileDWARF.h"
+#include "lldb/Utility/Stream.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+void DWARFTypeUnit::Dump(Stream *s) const {
+ s->Printf("0x%8.8x: Type Unit: length = 0x%8.8x, version = 0x%4.4x, "
+ "abbr_offset = 0x%8.8x, addr_size = 0x%2.2x (next CU at "
+ "{0x%8.8x})\n",
+ GetOffset(), GetLength(), GetVersion(), GetAbbrevOffset(),
+ GetAddressByteSize(), GetNextUnitOffset());
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
new file mode 100644
index 0000000000000..6ff73ecd8efa3
--- /dev/null
+++ b/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
@@ -0,0 +1,37 @@
+//===-- DWARFTypeUnit.h -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SymbolFileDWARF_DWARFTypeUnit_h_
+#define SymbolFileDWARF_DWARFTypeUnit_h_
+
+#include "DWARFUnit.h"
+#include "llvm/Support/Error.h"
+
+class DWARFTypeUnit : public DWARFUnit {
+public:
+ void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) override {}
+
+ void Dump(lldb_private::Stream *s) const override;
+
+ uint64_t GetTypeHash() { return m_header.GetTypeHash(); }
+
+ dw_offset_t GetTypeOffset() { return GetOffset() + m_header.GetTypeOffset(); }
+
+ static bool classof(const DWARFUnit *unit) { return unit->IsTypeUnit(); }
+
+private:
+ DWARFTypeUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
+ const DWARFUnitHeader &header,
+ const DWARFAbbreviationDeclarationSet &abbrevs,
+ DIERef::Section section)
+ : DWARFUnit(dwarf, uid, header, abbrevs, section) {}
+
+ friend class DWARFUnit;
+};
+
+#endif // SymbolFileDWARF_DWARFTypeUnit_h_
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 7afc71bc24f0b..33e83d1fe57f6 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -1,9 +1,8 @@
//===-- DWARFUnit.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,18 +10,17 @@
#include "lldb/Core/Module.h"
#include "lldb/Host/StringConvert.h"
-#include "lldb/Symbol/CompileUnit.h"
-#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+#include "llvm/Object/Error.h"
-#include "DWARFDIECollection.h"
+#include "DWARFCompileUnit.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
+#include "DWARFTypeUnit.h"
#include "LogChannelDWARF.h"
-#include "SymbolFileDWARFDebugMap.h"
#include "SymbolFileDWARFDwo.h"
using namespace lldb;
@@ -31,14 +29,16 @@ using namespace std;
extern int g_verbose;
-DWARFUnit::DWARFUnit(SymbolFileDWARF *dwarf)
- : m_dwarf(dwarf), m_cancel_scopes(false) {}
+DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
+ const DWARFUnitHeader &header,
+ const DWARFAbbreviationDeclarationSet &abbrevs,
+ DIERef::Section section)
+ : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
+ m_cancel_scopes(false), m_section(section) {}
-DWARFUnit::~DWARFUnit() {}
+DWARFUnit::~DWARFUnit() = default;
-//----------------------------------------------------------------------
// Parses first DIE of a compile unit.
-//----------------------------------------------------------------------
void DWARFUnit::ExtractUnitDIEIfNeeded() {
{
llvm::sys::ScopedReader lock(m_first_die_mutex);
@@ -50,8 +50,8 @@ void DWARFUnit::ExtractUnitDIEIfNeeded() {
return; // Already parsed
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
- Timer scoped_timer(
- func_cat, "%8.8x: DWARFUnit::ExtractUnitDIEIfNeeded()", m_offset);
+ Timer scoped_timer(func_cat, "%8.8x: DWARFUnit::ExtractUnitDIEIfNeeded()",
+ GetOffset());
// Set the offset to that of the first DIE and calculate the start of the
// next compilation unit header.
@@ -60,22 +60,15 @@ void DWARFUnit::ExtractUnitDIEIfNeeded() {
// We are in our compile unit, parse starting at the offset we were told to
// parse
const DWARFDataExtractor &data = GetData();
- DWARFFormValue::FixedFormSizes fixed_form_sizes =
- DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
- IsDWARF64());
- if (offset < GetNextCompileUnitOffset() &&
- m_first_die.FastExtract(data, this, fixed_form_sizes, &offset)) {
+ if (offset < GetNextUnitOffset() &&
+ m_first_die.Extract(data, this, &offset)) {
AddUnitDIE(m_first_die);
return;
}
-
- ExtractDIEsEndCheck(offset);
}
-//----------------------------------------------------------------------
// Parses a compile unit and indexes its DIEs if it hasn't already been done.
// It will leave this compile unit extracted forever.
-//----------------------------------------------------------------------
void DWARFUnit::ExtractDIEsIfNeeded() {
m_cancel_scopes = true;
@@ -91,15 +84,13 @@ void DWARFUnit::ExtractDIEsIfNeeded() {
ExtractDIEsRWLocked();
}
-//----------------------------------------------------------------------
// Parses a compile unit and indexes its DIEs if it hasn't already been done.
// It will clear this compile unit after returned instance gets out of scope,
// no other ScopedExtractDIEs instance is running for this compile unit
// and no ExtractDIEsIfNeeded() has been executed during this ScopedExtractDIEs
// lifetime.
-//----------------------------------------------------------------------
DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
- ScopedExtractDIEs scoped(this);
+ ScopedExtractDIEs scoped(*this);
{
llvm::sys::ScopedReader lock(m_die_array_mutex);
@@ -118,8 +109,7 @@ DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
return scoped;
}
-DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit *cu) : m_cu(cu) {
- lldbassert(m_cu);
+DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
m_cu->m_die_array_scoped_mutex.lock_shared();
}
@@ -150,33 +140,21 @@ DWARFUnit::ScopedExtractDIEs &DWARFUnit::ScopedExtractDIEs::operator=(
return *this;
}
-//----------------------------------------------------------------------
// Parses a compile unit and indexes its DIEs, m_die_array_mutex must be
// held R/W and m_die_array must be empty.
-//----------------------------------------------------------------------
void DWARFUnit::ExtractDIEsRWLocked() {
llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
- Timer scoped_timer(
- func_cat, "%8.8x: DWARFUnit::ExtractDIEsIfNeeded()", m_offset);
+ Timer scoped_timer(func_cat, "%8.8x: DWARFUnit::ExtractDIEsIfNeeded()",
+ GetOffset());
// Set the offset to that of the first DIE and calculate the start of the
// next compilation unit header.
lldb::offset_t offset = GetFirstDIEOffset();
- lldb::offset_t next_cu_offset = GetNextCompileUnitOffset();
+ lldb::offset_t next_cu_offset = GetNextUnitOffset();
DWARFDebugInfoEntry die;
- // Keep a flat array of the DIE for binary lookup by DIE offset
- Log *log(
- LogChannelDWARF::GetLogIfAny(DWARF_LOG_DEBUG_INFO | DWARF_LOG_LOOKUPS));
- if (log) {
- m_dwarf->GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
- log,
- "DWARFUnit::ExtractDIEsIfNeeded () for compile unit at "
- ".debug_info[0x%8.8x]",
- GetOffset());
- }
uint32_t depth = 0;
// We are in our compile unit, parse starting at the offset we were told to
@@ -186,11 +164,7 @@ void DWARFUnit::ExtractDIEsRWLocked() {
die_index_stack.reserve(32);
die_index_stack.push_back(0);
bool prev_die_had_children = false;
- DWARFFormValue::FixedFormSizes fixed_form_sizes =
- DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
- IsDWARF64());
- while (offset < next_cu_offset &&
- die.FastExtract(data, this, fixed_form_sizes, &offset)) {
+ while (offset < next_cu_offset && die.Extract(data, this, &offset)) {
const bool null_die = die.IsNULL();
if (depth == 0) {
assert(m_die_array.empty() && "Compile unit DIE already added");
@@ -208,6 +182,17 @@ void DWARFUnit::ExtractDIEsRWLocked() {
if (!m_first_die)
AddUnitDIE(m_die_array.front());
+
+ // With -fsplit-dwarf-inlining, clang will emit non-empty skeleton compile
+ // units. We are not able to access these DIE *and* the dwo file
+ // simultaneously. We also don't need to do that as the dwo file will
+ // contain a superset of information. So, we don't even attempt to parse
+ // any remaining DIEs.
+ if (m_dwo_symbol_file) {
+ m_die_array.front().SetHasChildren(false);
+ break;
+ }
+
} else {
if (null_die) {
if (prev_die_had_children) {
@@ -264,40 +249,12 @@ void DWARFUnit::ExtractDIEsRWLocked() {
m_die_array.shrink_to_fit();
- ExtractDIEsEndCheck(offset);
-
if (m_dwo_symbol_file) {
DWARFUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
dwo_cu->ExtractDIEsIfNeeded();
}
}
-//--------------------------------------------------------------------------
-// Final checks for both ExtractUnitDIEIfNeeded() and ExtractDIEsIfNeeded().
-//--------------------------------------------------------------------------
-void DWARFUnit::ExtractDIEsEndCheck(lldb::offset_t offset) const {
- // Give a little bit of info if we encounter corrupt DWARF (our offset should
- // always terminate at or before the start of the next compilation unit
- // header).
- if (offset > GetNextCompileUnitOffset()) {
- m_dwarf->GetObjectFile()->GetModule()->ReportWarning(
- "DWARF compile unit extends beyond its bounds cu 0x%8.8x at "
- "0x%8.8" PRIx64 "\n",
- GetOffset(), offset);
- }
-
- Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO));
- if (log && log->GetVerbose()) {
- StreamString strm;
- Dump(&strm);
- if (m_die_array.empty())
- strm.Printf("error: no DIE for compile unit");
- else
- m_die_array[0].Dump(m_dwarf, this, strm, UINT32_MAX);
- log->PutString(strm.GetString());
- }
-}
-
// This is used when a split dwarf is enabled.
// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
// that points to the first string offset of the CU contribution to the
@@ -308,7 +265,7 @@ static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
lldb::offset_t baseOffset = 0;
const DWARFDataExtractor &strOffsets =
- dwo_cu->GetSymbolFileDWARF()->get_debug_str_offsets_data();
+ dwo_cu->GetSymbolFileDWARF().GetDWARFContext().getOrLoadStrOffsetsData();
uint64_t length = strOffsets.GetU32(&baseOffset);
if (length == 0xffffffff)
length = strOffsets.GetU64(&baseOffset);
@@ -325,28 +282,50 @@ static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
// m_die_array_mutex must be already held as read/write.
void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
- dw_addr_t addr_base = cu_die.GetAttributeValueAsUnsigned(
- m_dwarf, this, DW_AT_addr_base, LLDB_INVALID_ADDRESS);
- if (addr_base != LLDB_INVALID_ADDRESS)
- SetAddrBase(addr_base);
-
- dw_addr_t ranges_base = cu_die.GetAttributeValueAsUnsigned(
- m_dwarf, this, DW_AT_rnglists_base, LLDB_INVALID_ADDRESS);
- if (ranges_base != LLDB_INVALID_ADDRESS)
- SetRangesBase(ranges_base);
-
- SetStrOffsetsBase(cu_die.GetAttributeValueAsUnsigned(
- m_dwarf, this, DW_AT_str_offsets_base, 0));
-
- uint64_t base_addr = cu_die.GetAttributeValueAsAddress(
- m_dwarf, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
- if (base_addr == LLDB_INVALID_ADDRESS)
- base_addr = cu_die.GetAttributeValueAsAddress(
- m_dwarf, this, DW_AT_entry_pc, 0);
- SetBaseAddress(base_addr);
+ llvm::Optional<uint64_t> addr_base, gnu_addr_base, ranges_base,
+ gnu_ranges_base;
+
+ DWARFAttributes attributes;
+ size_t num_attributes = cu_die.GetAttributes(this, attributes);
+ for (size_t i = 0; i < num_attributes; ++i) {
+ dw_attr_t attr = attributes.AttributeAtIndex(i);
+ DWARFFormValue form_value;
+ if (!attributes.ExtractFormValueAtIndex(i, form_value))
+ continue;
+ switch (attr) {
+ case DW_AT_addr_base:
+ addr_base = form_value.Unsigned();
+ SetAddrBase(*addr_base);
+ break;
+ case DW_AT_rnglists_base:
+ ranges_base = form_value.Unsigned();
+ SetRangesBase(*ranges_base);
+ break;
+ case DW_AT_str_offsets_base:
+ SetStrOffsetsBase(form_value.Unsigned());
+ break;
+ case DW_AT_low_pc:
+ SetBaseAddress(form_value.Address());
+ break;
+ case DW_AT_entry_pc:
+ // If the value was already set by DW_AT_low_pc, don't update it.
+ if (m_base_addr == LLDB_INVALID_ADDRESS)
+ SetBaseAddress(form_value.Address());
+ break;
+ case DW_AT_stmt_list:
+ m_line_table_offset = form_value.Unsigned();
+ break;
+ case DW_AT_GNU_addr_base:
+ gnu_addr_base = form_value.Unsigned();
+ break;
+ case DW_AT_GNU_ranges_base:
+ gnu_ranges_base = form_value.Unsigned();
+ break;
+ }
+ }
std::unique_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
- m_dwarf->GetDwoSymbolFileForCompileUnit(*this, cu_die);
+ m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
if (!dwo_symbol_file)
return;
@@ -359,7 +338,7 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
return; // Can't fetch the compile unit DIE from the dwo file.
uint64_t main_dwo_id =
- cu_die.GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_GNU_dwo_id, 0);
+ cu_die.GetAttributeValueAsUnsigned(this, DW_AT_GNU_dwo_id, 0);
uint64_t sub_dwo_id =
dwo_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0);
if (main_dwo_id != sub_dwo_id)
@@ -374,19 +353,20 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
// attributes which were applicable to the DWO units. The corresponding
// DW_AT_* attributes standardized in DWARF v5 are also applicable to the main
// unit in contrast.
- if (addr_base == LLDB_INVALID_ADDRESS)
- addr_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
- DW_AT_GNU_addr_base, 0);
- dwo_cu->SetAddrBase(addr_base);
-
- if (ranges_base == LLDB_INVALID_ADDRESS)
- ranges_base = cu_die.GetAttributeValueAsUnsigned(m_dwarf, this,
- DW_AT_GNU_ranges_base, 0);
- dwo_cu->SetRangesBase(ranges_base);
-
- dwo_cu->SetBaseObjOffset(m_offset);
-
- SetDwoStrOffsetsBase(dwo_cu);
+ if (addr_base)
+ dwo_cu->SetAddrBase(*addr_base);
+ else if (gnu_addr_base)
+ dwo_cu->SetAddrBase(*gnu_addr_base);
+
+ if (ranges_base)
+ dwo_cu->SetRangesBase(*ranges_base);
+ else if (gnu_ranges_base)
+ dwo_cu->SetRangesBase(*gnu_ranges_base);
+
+ for (size_t i = 0; i < m_dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) {
+ DWARFUnit *unit = m_dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i);
+ SetDwoStrOffsetsBase(unit);
+ }
}
DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
@@ -401,35 +381,21 @@ DWARFDIE DWARFUnit::LookupAddress(const dw_addr_t address) {
}
size_t DWARFUnit::AppendDIEsWithTag(const dw_tag_t tag,
- DWARFDIECollection &dies,
- uint32_t depth) const {
- size_t old_size = dies.Size();
+ std::vector<DWARFDIE> &dies,
+ uint32_t depth) const {
+ size_t old_size = dies.size();
{
llvm::sys::ScopedReader lock(m_die_array_mutex);
DWARFDebugInfoEntry::const_iterator pos;
DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
for (pos = m_die_array.begin(); pos != end; ++pos) {
if (pos->Tag() == tag)
- dies.Append(DWARFDIE(this, &(*pos)));
+ dies.emplace_back(this, &(*pos));
}
}
// Return the number of DIEs added to the collection
- return dies.Size() - old_size;
-}
-
-
-lldb::user_id_t DWARFUnit::GetID() const {
- dw_offset_t local_id =
- m_base_obj_offset != DW_INVALID_OFFSET ? m_base_obj_offset : m_offset;
- if (m_dwarf)
- return DIERef(local_id, local_id).GetUID(m_dwarf);
- else
- return local_id;
-}
-
-dw_offset_t DWARFUnit::GetNextCompileUnitOffset() const {
- return m_offset + GetLengthByteSize() + GetLength();
+ return dies.size() - old_size;
}
size_t DWARFUnit::GetDebugInfoSize() const {
@@ -444,16 +410,17 @@ dw_offset_t DWARFUnit::GetAbbrevOffset() const {
return m_abbrevs ? m_abbrevs->GetOffset() : DW_INVALID_OFFSET;
}
+dw_offset_t DWARFUnit::GetLineTableOffset() {
+ ExtractUnitDIEIfNeeded();
+ return m_line_table_offset;
+}
+
void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
void DWARFUnit::SetRangesBase(dw_addr_t ranges_base) {
m_ranges_base = ranges_base;
}
-void DWARFUnit::SetBaseObjOffset(dw_offset_t base_obj_offset) {
- m_base_obj_offset = base_obj_offset;
-}
-
void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) {
m_str_offsets_base = str_offsets_base;
}
@@ -467,132 +434,27 @@ void DWARFUnit::ClearDIEsRWLocked() {
m_dwo_symbol_file->GetCompileUnit()->ClearDIEsRWLocked();
}
-void DWARFUnit::BuildAddressRangeTable(SymbolFileDWARF *dwarf,
- DWARFDebugAranges *debug_aranges) {
- // This function is usually called if there in no .debug_aranges section in
- // order to produce a compile unit level set of address ranges that is
- // accurate.
-
- size_t num_debug_aranges = debug_aranges->GetNumRanges();
-
- // First get the compile unit DIE only and check if it has a DW_AT_ranges
- const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
-
- const dw_offset_t cu_offset = GetOffset();
- if (die) {
- DWARFRangeList ranges;
- const size_t num_ranges =
- die->GetAttributeAddressRanges(dwarf, this, ranges, false);
- if (num_ranges > 0) {
- // This compile unit has DW_AT_ranges, assume this is correct if it is
- // present since clang no longer makes .debug_aranges by default and it
- // emits DW_AT_ranges for DW_TAG_compile_units. GCC also does this with
- // recent GCC builds.
- for (size_t i = 0; i < num_ranges; ++i) {
- const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
- debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
- range.GetRangeEnd());
- }
-
- return; // We got all of our ranges from the DW_AT_ranges attribute
- }
- }
- // We don't have a DW_AT_ranges attribute, so we need to parse the DWARF
-
- // If the DIEs weren't parsed, then we don't want all dies for all compile
- // units to stay loaded when they weren't needed. So we can end up parsing
- // the DWARF and then throwing them all away to keep memory usage down.
- ScopedExtractDIEs clear_dies(ExtractDIEsScoped());
-
- die = DIEPtr();
- if (die)
- die->BuildAddressRangeTable(dwarf, this, debug_aranges);
-
- if (debug_aranges->GetNumRanges() == num_debug_aranges) {
- // We got nothing from the functions, maybe we have a line tables only
- // situation. Check the line tables and build the arange table from this.
- SymbolContext sc;
- sc.comp_unit = dwarf->GetCompUnitForDWARFCompUnit(this);
- if (sc.comp_unit) {
- SymbolFileDWARFDebugMap *debug_map_sym_file =
- m_dwarf->GetDebugMapSymfile();
- if (debug_map_sym_file == NULL) {
- LineTable *line_table = sc.comp_unit->GetLineTable();
-
- if (line_table) {
- LineTable::FileAddressRanges file_ranges;
- const bool append = true;
- const size_t num_ranges =
- line_table->GetContiguousFileAddressRanges(file_ranges, append);
- for (uint32_t idx = 0; idx < num_ranges; ++idx) {
- const LineTable::FileAddressRanges::Entry &range =
- file_ranges.GetEntryRef(idx);
- debug_aranges->AppendRange(cu_offset, range.GetRangeBase(),
- range.GetRangeEnd());
- }
- }
- } else
- debug_map_sym_file->AddOSOARanges(dwarf, debug_aranges);
- }
- }
-
- if (debug_aranges->GetNumRanges() == num_debug_aranges) {
- // We got nothing from the functions, maybe we have a line tables only
- // situation. Check the line tables and build the arange table from this.
- SymbolContext sc;
- sc.comp_unit = dwarf->GetCompUnitForDWARFCompUnit(this);
- if (sc.comp_unit) {
- LineTable *line_table = sc.comp_unit->GetLineTable();
-
- if (line_table) {
- LineTable::FileAddressRanges file_ranges;
- const bool append = true;
- const size_t num_ranges =
- line_table->GetContiguousFileAddressRanges(file_ranges, append);
- for (uint32_t idx = 0; idx < num_ranges; ++idx) {
- const LineTable::FileAddressRanges::Entry &range =
- file_ranges.GetEntryRef(idx);
- debug_aranges->AppendRange(GetOffset(), range.GetRangeBase(),
- range.GetRangeEnd());
- }
- }
- }
- }
-}
-
lldb::ByteOrder DWARFUnit::GetByteOrder() const {
- return m_dwarf->GetObjectFile()->GetByteOrder();
+ return m_dwarf.GetObjectFile()->GetByteOrder();
}
TypeSystem *DWARFUnit::GetTypeSystem() {
- if (m_dwarf)
- return m_dwarf->GetTypeSystemForLanguage(GetLanguageType());
- else
- return nullptr;
-}
-
-DWARFFormValue::FixedFormSizes DWARFUnit::GetFixedFormSizes() {
- return DWARFFormValue::GetFixedFormSizesForAddressSize(GetAddressByteSize(),
- IsDWARF64());
+ return m_dwarf.GetTypeSystemForLanguage(GetLanguageType());
}
void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
-//----------------------------------------------------------------------
// Compare function DWARFDebugAranges::Range structures
-//----------------------------------------------------------------------
static bool CompareDIEOffset(const DWARFDebugInfoEntry &die,
const dw_offset_t die_offset) {
return die.GetOffset() < die_offset;
}
-//----------------------------------------------------------------------
// GetDIE()
//
// Get the DIE (Debug Information Entry) with the specified offset by first
// checking if the DIE is contained within this compile unit and grabbing the
// DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
-//----------------------------------------------------------------------
DWARFDIE
DWARFUnit::GetDIE(dw_offset_t die_offset) {
if (die_offset != DW_INVALID_OFFSET) {
@@ -608,28 +470,26 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
if (die_offset == (*pos).GetOffset())
return DWARFDIE(this, &(*pos));
}
- } else {
- // Don't specify the compile unit offset as we don't know it because the
- // DIE belongs to
- // a different compile unit in the same symbol file.
- return m_dwarf->DebugInfo()->GetDIEForDIEOffset(die_offset);
- }
+ } else
+ GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+ "GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
+ die_offset, GetOffset());
}
return DWARFDIE(); // Not found
}
+DWARFUnit &DWARFUnit::GetNonSkeletonUnit() {
+ if (SymbolFileDWARFDwo *dwo = GetDwoSymbolFile())
+ return *dwo->GetCompileUnit();
+ return *this;
+}
+
uint8_t DWARFUnit::GetAddressByteSize(const DWARFUnit *cu) {
if (cu)
return cu->GetAddressByteSize();
return DWARFUnit::GetDefaultAddressSize();
}
-bool DWARFUnit::IsDWARF64(const DWARFUnit *cu) {
- if (cu)
- return cu->IsDWARF64();
- return false;
-}
-
uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
void *DWARFUnit::GetUserData() const { return m_user_data; }
@@ -660,8 +520,6 @@ bool DWARFUnit::Supports_unnamed_objc_bitfields() {
// info
}
-SymbolFileDWARF *DWARFUnit::GetSymbolFileDWARF() const { return m_dwarf; }
-
void DWARFUnit::ParseProducerInfo() {
m_producer_version_major = UINT32_MAX;
m_producer_version_minor = UINT32_MAX;
@@ -671,7 +529,7 @@ void DWARFUnit::ParseProducerInfo() {
if (die) {
const char *producer_cstr =
- die->GetAttributeValueAsString(m_dwarf, this, DW_AT_producer, NULL);
+ die->GetAttributeValueAsString(this, DW_AT_producer, nullptr);
if (producer_cstr) {
RegularExpression llvm_gcc_regex(
llvm::StringRef("^4\\.[012]\\.[01] \\(Based on Apple "
@@ -748,7 +606,7 @@ LanguageType DWARFUnit::GetLanguageType() {
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
if (die)
m_language_type = LanguageTypeFromDWARF(
- die->GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_language, 0));
+ die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0));
return m_language_type;
}
@@ -757,8 +615,8 @@ bool DWARFUnit::GetIsOptimized() {
const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
if (die) {
m_is_optimized = eLazyBoolNo;
- if (die->GetAttributeValueAsUnsigned(m_dwarf, this, DW_AT_APPLE_optimized,
- 0) == 1) {
+ if (die->GetAttributeValueAsUnsigned(this, DW_AT_APPLE_optimized, 0) ==
+ 1) {
m_is_optimized = eLazyBoolYes;
}
}
@@ -766,40 +624,255 @@ bool DWARFUnit::GetIsOptimized() {
return m_is_optimized == eLazyBoolYes;
}
+FileSpec::Style DWARFUnit::GetPathStyle() {
+ if (!m_comp_dir)
+ ComputeCompDirAndGuessPathStyle();
+ return m_comp_dir->GetPathStyle();
+}
+
+const FileSpec &DWARFUnit::GetCompilationDirectory() {
+ if (!m_comp_dir)
+ ComputeCompDirAndGuessPathStyle();
+ return *m_comp_dir;
+}
+
+const FileSpec &DWARFUnit::GetAbsolutePath() {
+ if (!m_file_spec)
+ ComputeAbsolutePath();
+ return *m_file_spec;
+}
+
+FileSpec DWARFUnit::GetFile(size_t file_idx) {
+ return m_dwarf.GetFile(*this, file_idx);
+}
+
+// DWARF2/3 suggests the form hostname:pathname for compilation directory.
+// Remove the host part if present.
+static llvm::StringRef
+removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
+ llvm::StringRef host, path;
+ std::tie(host, path) = path_from_dwarf.split(':');
+
+ if (host.contains('/'))
+ return path_from_dwarf;
+
+ // check whether we have a windows path, and so the first character is a
+ // drive-letter not a hostname.
+ if (host.size() == 1 && llvm::isAlpha(host[0]) && path.startswith("\\"))
+ return path_from_dwarf;
+
+ return path;
+}
+
+static FileSpec resolveCompDir(const FileSpec &path) {
+ bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
+ 0, path, /*full*/ true) != UINT32_MAX;
+
+ if (!is_symlink)
+ return path;
+
+ namespace fs = llvm::sys::fs;
+ if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file)
+ return path;
+
+ FileSpec resolved_symlink;
+ const auto error = FileSystem::Instance().Readlink(path, resolved_symlink);
+ if (error.Success())
+ return resolved_symlink;
+
+ return path;
+}
+
+void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
+ m_comp_dir = FileSpec();
+ const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
+ if (!die)
+ return;
+
+ llvm::StringRef comp_dir = removeHostnameFromPathname(
+ die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
+ if (!comp_dir.empty()) {
+ FileSpec::Style comp_dir_style =
+ FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
+ m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
+ } else {
+ // Try to detect the style based on the DW_AT_name attribute, but just store
+ // the detected style in the m_comp_dir field.
+ const char *name =
+ die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
+ m_comp_dir = FileSpec(
+ "", FileSpec::GuessPathStyle(name).getValueOr(FileSpec::Style::native));
+ }
+}
+
+void DWARFUnit::ComputeAbsolutePath() {
+ m_file_spec = FileSpec();
+ const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
+ if (!die)
+ return;
+
+ m_file_spec =
+ FileSpec(die->GetAttributeValueAsString(this, DW_AT_name, nullptr),
+ GetPathStyle());
+
+ if (m_file_spec->IsRelative())
+ m_file_spec->MakeAbsolute(GetCompilationDirectory());
+}
+
SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() const {
return m_dwo_symbol_file.get();
}
-dw_offset_t DWARFUnit::GetBaseObjOffset() const { return m_base_obj_offset; }
-
const DWARFDebugAranges &DWARFUnit::GetFunctionAranges() {
- if (m_func_aranges_ap.get() == NULL) {
- m_func_aranges_ap.reset(new DWARFDebugAranges());
- Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES));
-
- if (log) {
- m_dwarf->GetObjectFile()->GetModule()->LogMessage(
- log,
- "DWARFUnit::GetFunctionAranges() for compile unit at "
- ".debug_info[0x%8.8x]",
- GetOffset());
- }
+ if (m_func_aranges_up == nullptr) {
+ m_func_aranges_up.reset(new DWARFDebugAranges());
const DWARFDebugInfoEntry *die = DIEPtr();
if (die)
- die->BuildFunctionAddressRangeTable(m_dwarf, this,
- m_func_aranges_ap.get());
+ die->BuildFunctionAddressRangeTable(this, m_func_aranges_up.get());
if (m_dwo_symbol_file) {
DWARFUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
const DWARFDebugInfoEntry *dwo_die = dwo_cu->DIEPtr();
if (dwo_die)
- dwo_die->BuildFunctionAddressRangeTable(m_dwo_symbol_file.get(), dwo_cu,
- m_func_aranges_ap.get());
+ dwo_die->BuildFunctionAddressRangeTable(dwo_cu,
+ m_func_aranges_up.get());
}
const bool minimize = false;
- m_func_aranges_ap->Sort(minimize);
+ m_func_aranges_up->Sort(minimize);
+ }
+ return *m_func_aranges_up;
+}
+
+llvm::Expected<DWARFUnitHeader>
+DWARFUnitHeader::extract(const DWARFDataExtractor &data, DIERef::Section section,
+ lldb::offset_t *offset_ptr) {
+ DWARFUnitHeader header;
+ header.m_offset = *offset_ptr;
+ header.m_length = data.GetDWARFInitialLength(offset_ptr);
+ header.m_version = data.GetU16(offset_ptr);
+ if (header.m_version == 5) {
+ header.m_unit_type = data.GetU8(offset_ptr);
+ header.m_addr_size = data.GetU8(offset_ptr);
+ header.m_abbr_offset = data.GetDWARFOffset(offset_ptr);
+ if (header.m_unit_type == llvm::dwarf::DW_UT_skeleton)
+ header.m_dwo_id = data.GetU64(offset_ptr);
+ } else {
+ header.m_abbr_offset = data.GetDWARFOffset(offset_ptr);
+ header.m_addr_size = data.GetU8(offset_ptr);
+ header.m_unit_type =
+ section == DIERef::Section::DebugTypes ? DW_UT_type : DW_UT_compile;
+ }
+
+ if (header.IsTypeUnit()) {
+ header.m_type_hash = data.GetU64(offset_ptr);
+ header.m_type_offset = data.GetDWARFOffset(offset_ptr);
+ }
+
+ bool length_OK = data.ValidOffset(header.GetNextUnitOffset() - 1);
+ bool version_OK = SymbolFileDWARF::SupportedVersion(header.m_version);
+ bool addr_size_OK = (header.m_addr_size == 4) || (header.m_addr_size == 8);
+ bool type_offset_OK =
+ !header.IsTypeUnit() || (header.m_type_offset <= header.GetLength());
+
+ if (!length_OK)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Invalid unit length");
+ if (!version_OK)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Unsupported unit version");
+ if (!addr_size_OK)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Invalid unit address size");
+ if (!type_offset_OK)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Type offset out of range");
+
+ return header;
+}
+
+llvm::Expected<DWARFUnitSP>
+DWARFUnit::extract(SymbolFileDWARF &dwarf, user_id_t uid,
+ const DWARFDataExtractor &debug_info,
+ DIERef::Section section, lldb::offset_t *offset_ptr) {
+ assert(debug_info.ValidOffset(*offset_ptr));
+
+ auto expected_header =
+ DWARFUnitHeader::extract(debug_info, section, offset_ptr);
+ if (!expected_header)
+ return expected_header.takeError();
+
+ const DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();
+ if (!abbr)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "No debug_abbrev data");
+
+ bool abbr_offset_OK =
+ dwarf.GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
+ expected_header->GetAbbrOffset());
+ if (!abbr_offset_OK)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "Abbreviation offset for unit is not valid");
+
+ const DWARFAbbreviationDeclarationSet *abbrevs =
+ abbr->GetAbbreviationDeclarationSet(expected_header->GetAbbrOffset());
+ if (!abbrevs)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "No abbrev exists at the specified offset.");
+
+ if (expected_header->IsTypeUnit())
+ return DWARFUnitSP(
+ new DWARFTypeUnit(dwarf, uid, *expected_header, *abbrevs, section));
+ return DWARFUnitSP(
+ new DWARFCompileUnit(dwarf, uid, *expected_header, *abbrevs, section));
+}
+
+const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
+ return m_section == DIERef::Section::DebugTypes
+ ? m_dwarf.GetDWARFContext().getOrLoadDebugTypesData()
+ : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
+}
+
+uint32_t DWARFUnit::GetHeaderByteSize() const {
+ switch (m_header.GetUnitType()) {
+ case llvm::dwarf::DW_UT_compile:
+ case llvm::dwarf::DW_UT_partial:
+ return GetVersion() < 5 ? 11 : 12;
+ case llvm::dwarf::DW_UT_skeleton:
+ case llvm::dwarf::DW_UT_split_compile:
+ return 20;
+ case llvm::dwarf::DW_UT_type:
+ case llvm::dwarf::DW_UT_split_type:
+ return GetVersion() < 5 ? 23 : 24;
}
- return *m_func_aranges_ap.get();
+ llvm_unreachable("invalid UnitType.");
+}
+
+llvm::Expected<DWARFRangeList>
+DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) const {
+ const DWARFDebugRangesBase *debug_ranges;
+ llvm::StringRef section;
+ if (GetVersion() <= 4) {
+ debug_ranges = m_dwarf.GetDebugRanges();
+ section = "debug_ranges";
+ } else {
+ debug_ranges = m_dwarf.GetDebugRngLists();
+ section = "debug_rnglists";
+ }
+ if (!debug_ranges)
+ return llvm::make_error<llvm::object::GenericBinaryError>("No " + section +
+ " section");
+
+ DWARFRangeList ranges;
+ debug_ranges->FindRanges(this, offset, ranges);
+ return ranges;
}
+llvm::Expected<DWARFRangeList>
+DWARFUnit::FindRnglistFromIndex(uint32_t index) const {
+ const DWARFDebugRangesBase *debug_rnglists = m_dwarf.GetDebugRngLists();
+ if (!debug_rnglists)
+ return llvm::make_error<llvm::object::GenericBinaryError>(
+ "No debug_rnglists section");
+ return FindRnglistFromOffset(debug_rnglists->GetOffset(index));
+}
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 178c894686ee2..8aa1e449f3ed5 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -1,9 +1,8 @@
//===-- DWARFUnit.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,11 +31,52 @@ enum DWARFProducer {
eProcucerOther
};
-class DWARFUnit {
+/// Base class describing the header of any kind of "unit." Some information
+/// is specific to certain unit types. We separate this class out so we can
+/// parse the header before deciding what specific kind of unit to construct.
+class DWARFUnitHeader {
+ dw_offset_t m_offset = 0;
+ dw_offset_t m_length = 0;
+ uint16_t m_version = 0;
+ dw_offset_t m_abbr_offset = 0;
+ uint8_t m_unit_type = 0;
+ uint8_t m_addr_size = 0;
+
+ uint64_t m_type_hash = 0;
+ uint32_t m_type_offset = 0;
+
+ uint64_t m_dwo_id = 0;
+
+ DWARFUnitHeader() = default;
+
+public:
+ dw_offset_t GetOffset() const { return m_offset; }
+ uint16_t GetVersion() const { return m_version; }
+ uint16_t GetAddressByteSize() const { return m_addr_size; }
+ dw_offset_t GetLength() const { return m_length; }
+ dw_offset_t GetAbbrOffset() const { return m_abbr_offset; }
+ uint8_t GetUnitType() const { return m_unit_type; }
+ uint64_t GetTypeHash() const { return m_type_hash; }
+ dw_offset_t GetTypeOffset() const { return m_type_offset; }
+ bool IsTypeUnit() const {
+ return m_unit_type == DW_UT_type || m_unit_type == DW_UT_split_type;
+ }
+ uint32_t GetNextUnitOffset() const { return m_offset + m_length + 4; }
+
+ static llvm::Expected<DWARFUnitHeader>
+ extract(const lldb_private::DWARFDataExtractor &data, DIERef::Section section,
+ lldb::offset_t *offset_ptr);
+};
+
+class DWARFUnit : public lldb_private::UserID {
using die_iterator_range =
llvm::iterator_range<DWARFDebugInfoEntry::collection::iterator>;
public:
+ static llvm::Expected<DWARFUnitSP>
+ extract(SymbolFileDWARF &dwarf2Data, lldb::user_id_t uid,
+ const lldb_private::DWARFDataExtractor &debug_info,
+ DIERef::Section section, lldb::offset_t *offset_ptr);
virtual ~DWARFUnit();
void ExtractUnitDIEIfNeeded();
@@ -46,7 +86,7 @@ public:
DWARFUnit *m_cu;
public:
bool m_clear_dies = false;
- ScopedExtractDIEs(DWARFUnit *cu);
+ ScopedExtractDIEs(DWARFUnit &cu);
~ScopedExtractDIEs();
DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
@@ -55,69 +95,61 @@ public:
ScopedExtractDIEs ExtractDIEsScoped();
DWARFDIE LookupAddress(const dw_addr_t address);
- size_t AppendDIEsWithTag(const dw_tag_t tag,
- DWARFDIECollection &matching_dies,
+ size_t AppendDIEsWithTag(const dw_tag_t tag, std::vector<DWARFDIE> &dies,
uint32_t depth = UINT32_MAX) const;
bool Verify(lldb_private::Stream *s) const;
virtual void Dump(lldb_private::Stream *s) const = 0;
- //------------------------------------------------------------------
/// Get the data that contains the DIE information for this unit.
///
/// This will return the correct bytes that contain the data for
/// this DWARFUnit. It could be .debug_info or .debug_types
/// depending on where the data for this unit originates.
///
- /// @return
+ /// \return
/// The correct data for the DIE information in this unit.
- //------------------------------------------------------------------
- virtual const lldb_private::DWARFDataExtractor &GetData() const = 0;
- //------------------------------------------------------------------
- /// Get the size in bytes of the compile unit header.
+ const lldb_private::DWARFDataExtractor &GetData() const;
+
+ /// Get the size in bytes of the unit header.
///
- /// @return
- /// Byte size of the compile unit header
- //------------------------------------------------------------------
- virtual uint32_t GetHeaderByteSize() const = 0;
+ /// \return
+ /// Byte size of the unit header
+ uint32_t GetHeaderByteSize() const;
+
// Offset of the initial length field.
- dw_offset_t GetOffset() const { return m_offset; }
- lldb::user_id_t GetID() const;
- //------------------------------------------------------------------
+ dw_offset_t GetOffset() const { return m_header.GetOffset(); }
/// Get the size in bytes of the length field in the header.
///
- /// In DWARF32 this is just 4 bytes, and DWARF64 it is 12 where 4
- /// are 0xFFFFFFFF followed by the actual 64 bit length.
+ /// In DWARF32 this is just 4 bytes
///
- /// @return
+ /// \return
/// Byte size of the compile unit header length field
- //------------------------------------------------------------------
- size_t GetLengthByteSize() const { return IsDWARF64() ? 12 : 4; }
-
+ size_t GetLengthByteSize() const { return 4; }
+
bool ContainsDIEOffset(dw_offset_t die_offset) const {
return die_offset >= GetFirstDIEOffset() &&
- die_offset < GetNextCompileUnitOffset();
+ die_offset < GetNextUnitOffset();
}
dw_offset_t GetFirstDIEOffset() const {
- return m_offset + GetHeaderByteSize();
+ return GetOffset() + GetHeaderByteSize();
}
- dw_offset_t GetNextCompileUnitOffset() const;
+ dw_offset_t GetNextUnitOffset() const { return m_header.GetNextUnitOffset(); }
// Size of the CU data (without initial length and without header).
size_t GetDebugInfoSize() const;
// Size of the CU data incl. header but without initial length.
- uint32_t GetLength() const { return m_length; }
- uint16_t GetVersion() const { return m_version; }
+ uint32_t GetLength() const { return m_header.GetLength(); }
+ uint16_t GetVersion() const { return m_header.GetVersion(); }
const DWARFAbbreviationDeclarationSet *GetAbbreviations() const;
dw_offset_t GetAbbrevOffset() const;
- uint8_t GetAddressByteSize() const { return m_addr_size; }
- dw_addr_t GetBaseAddress() const { return m_base_addr; }
+ uint8_t GetAddressByteSize() const { return m_header.GetAddressByteSize(); }
dw_addr_t GetAddrBase() const { return m_addr_base; }
+ dw_addr_t GetBaseAddress() const { return m_base_addr; }
+ dw_offset_t GetLineTableOffset();
dw_addr_t GetRangesBase() const { return m_ranges_base; }
dw_addr_t GetStrOffsetsBase() const { return m_str_offsets_base; }
void SetAddrBase(dw_addr_t addr_base);
void SetRangesBase(dw_addr_t ranges_base);
- void SetBaseObjOffset(dw_offset_t base_obj_offset);
void SetStrOffsetsBase(dw_offset_t str_offsets_base);
- void BuildAddressRangeTable(SymbolFileDWARF *dwarf,
- DWARFDebugAranges *debug_aranges);
+ virtual void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) = 0;
lldb::ByteOrder GetByteOrder() const;
@@ -125,8 +157,6 @@ public:
const DWARFDebugAranges &GetFunctionAranges();
- DWARFFormValue::FixedFormSizes GetFixedFormSizes();
-
void SetBaseAddress(dw_addr_t base_addr);
DWARFBaseDIE GetUnitDIEOnly() { return DWARFDIE(this, GetUnitDIEPtrOnly()); }
@@ -135,9 +165,9 @@ public:
DWARFDIE GetDIE(dw_offset_t die_offset);
- static uint8_t GetAddressByteSize(const DWARFUnit *cu);
+ DWARFUnit &GetNonSkeletonUnit();
- static bool IsDWARF64(const DWARFUnit *cu);
+ static uint8_t GetAddressByteSize(const DWARFUnit *cu);
static uint8_t GetDefaultAddressSize();
@@ -151,7 +181,7 @@ public:
bool Supports_unnamed_objc_bitfields();
- SymbolFileDWARF *GetSymbolFileDWARF() const;
+ SymbolFileDWARF &GetSymbolFileDWARF() const { return m_dwarf; }
DWARFProducer GetProducer();
@@ -165,24 +195,65 @@ public:
lldb::LanguageType GetLanguageType();
- bool IsDWARF64() const { return m_is_dwarf64; }
-
bool GetIsOptimized();
- SymbolFileDWARFDwo *GetDwoSymbolFile() const;
+ const lldb_private::FileSpec &GetCompilationDirectory();
+ const lldb_private::FileSpec &GetAbsolutePath();
+ lldb_private::FileSpec GetFile(size_t file_idx);
+ lldb_private::FileSpec::Style GetPathStyle();
- dw_offset_t GetBaseObjOffset() const;
+ SymbolFileDWARFDwo *GetDwoSymbolFile() const;
die_iterator_range dies() {
ExtractDIEsIfNeeded();
return die_iterator_range(m_die_array.begin(), m_die_array.end());
}
+ DIERef::Section GetDebugSection() const { return m_section; }
+
+ uint8_t GetUnitType() const { return m_header.GetUnitType(); }
+ bool IsTypeUnit() const { return m_header.IsTypeUnit(); }
+
+ /// Return a list of address ranges resulting from a (possibly encoded)
+ /// range list starting at a given offset in the appropriate ranges section.
+ llvm::Expected<DWARFRangeList> FindRnglistFromOffset(dw_offset_t offset) const;
+
+ /// Return a list of address ranges retrieved from an encoded range
+ /// list whose offset is found via a table lookup given an index (DWARF v5
+ /// and later).
+ llvm::Expected<DWARFRangeList> FindRnglistFromIndex(uint32_t index) const;
+
protected:
- DWARFUnit(SymbolFileDWARF *dwarf);
+ DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
+ const DWARFUnitHeader &header,
+ const DWARFAbbreviationDeclarationSet &abbrevs,
+ DIERef::Section section);
+
+ llvm::Error ExtractHeader(SymbolFileDWARF &dwarf,
+ const lldb_private::DWARFDataExtractor &data,
+ lldb::offset_t *offset_ptr);
+
+ // Get the DWARF unit DWARF debug information entry. Parse the single DIE
+ // if needed.
+ const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
+ ExtractUnitDIEIfNeeded();
+ // m_first_die_mutex is not required as m_first_die is never cleared.
+ if (!m_first_die)
+ return NULL;
+ return &m_first_die;
+ }
+
+ // Get all DWARF debug informration entries. Parse all DIEs if needed.
+ const DWARFDebugInfoEntry *DIEPtr() {
+ ExtractDIEsIfNeeded();
+ if (m_die_array.empty())
+ return NULL;
+ return &m_die_array[0];
+ }
- SymbolFileDWARF *m_dwarf = nullptr;
+ SymbolFileDWARF &m_dwarf;
std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file;
+ DWARFUnitHeader m_header;
const DWARFAbbreviationDeclarationSet *m_abbrevs = nullptr;
void *m_user_data = nullptr;
// The compile unit debug information entry item
@@ -200,54 +271,34 @@ protected:
llvm::sys::RWMutex m_first_die_mutex;
// A table similar to the .debug_aranges table, but this one points to the
// exact DW_TAG_subprogram DIEs
- std::unique_ptr<DWARFDebugAranges> m_func_aranges_ap;
+ std::unique_ptr<DWARFDebugAranges> m_func_aranges_up;
dw_addr_t m_base_addr = 0;
- dw_offset_t m_length = 0;
- uint16_t m_version = 0;
- uint8_t m_addr_size = 0;
- uint8_t m_unit_type = 0;
- uint64_t m_dwo_id = 0;
DWARFProducer m_producer = eProducerInvalid;
uint32_t m_producer_version_major = 0;
uint32_t m_producer_version_minor = 0;
uint32_t m_producer_version_update = 0;
lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
- bool m_is_dwarf64 = false;
lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate;
+ llvm::Optional<lldb_private::FileSpec> m_comp_dir;
+ llvm::Optional<lldb_private::FileSpec> m_file_spec;
dw_addr_t m_addr_base = 0; // Value of DW_AT_addr_base
dw_addr_t m_ranges_base = 0; // Value of DW_AT_ranges_base
- // If this is a dwo compile unit this is the offset of the base compile unit
- // in the main object file
- dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET;
+
+ /// Value of DW_AT_stmt_list.
+ dw_offset_t m_line_table_offset = DW_INVALID_OFFSET;
+
dw_offset_t m_str_offsets_base = 0; // Value of DW_AT_str_offsets_base.
- // Offset of the initial length field.
- dw_offset_t m_offset;
+ const DIERef::Section m_section;
private:
void ParseProducerInfo();
void ExtractDIEsRWLocked();
void ClearDIEsRWLocked();
- // Get the DWARF unit DWARF debug informration entry. Parse the single DIE
- // if needed.
- const DWARFDebugInfoEntry *GetUnitDIEPtrOnly() {
- ExtractUnitDIEIfNeeded();
- // m_first_die_mutex is not required as m_first_die is never cleared.
- if (!m_first_die)
- return NULL;
- return &m_first_die;
- }
-
- // Get all DWARF debug informration entries. Parse all DIEs if needed.
- const DWARFDebugInfoEntry *DIEPtr() {
- ExtractDIEsIfNeeded();
- if (m_die_array.empty())
- return NULL;
- return &m_die_array[0];
- }
-
void AddUnitDIE(const DWARFDebugInfoEntry &cu_die);
- void ExtractDIEsEndCheck(lldb::offset_t offset) const;
+
+ void ComputeCompDirAndGuessPathStyle();
+ void ComputeAbsolutePath();
DISALLOW_COPY_AND_ASSIGN(DWARFUnit);
};
diff --git a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index c043272f8a3e5..9746ad76c9300 100644
--- a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -1,9 +1,8 @@
//===-- DebugNamesDWARFIndex.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,13 +16,6 @@
using namespace lldb_private;
using namespace lldb;
-static llvm::DWARFDataExtractor ToLLVM(const DWARFDataExtractor &data) {
- return llvm::DWARFDataExtractor(
- llvm::StringRef(reinterpret_cast<const char *>(data.GetDataStart()),
- data.GetByteSize()),
- data.GetByteOrder() == eByteOrderLittle, data.GetAddressByteSize());
-}
-
llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>>
DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
DWARFDataExtractor debug_str,
@@ -32,8 +24,8 @@ DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names,
return llvm::make_error<llvm::StringError>("debug info null",
llvm::inconvertibleErrorCode());
}
- auto index_up =
- llvm::make_unique<DebugNames>(ToLLVM(debug_names), ToLLVM(debug_str));
+ auto index_up = llvm::make_unique<DebugNames>(debug_names.GetAsLLVM(),
+ debug_str.GetAsLLVM());
if (llvm::Error E = index_up->extract())
return std::move(E);
@@ -51,31 +43,33 @@ DebugNamesDWARFIndex::GetUnits(const DebugNames &debug_names) {
return result;
}
-DIERef DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
+llvm::Optional<DIERef>
+DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry &entry) {
llvm::Optional<uint64_t> cu_offset = entry.getCUOffset();
if (!cu_offset)
- return DIERef();
+ return llvm::None;
- DWARFUnit *cu = m_debug_info.GetCompileUnit(*cu_offset);
+ DWARFUnit *cu = m_debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, *cu_offset);
if (!cu)
- return DIERef();
+ return llvm::None;
// This initializes the DWO symbol file. It's not possible for
// GetDwoSymbolFile to call this automatically because of mutual recursion
// between this and DWARFDebugInfoEntry::GetAttributeValue.
cu->ExtractUnitDIEIfNeeded();
- uint64_t die_bias = cu->GetDwoSymbolFile() ? 0 : *cu_offset;
+ cu = &cu->GetNonSkeletonUnit();
if (llvm::Optional<uint64_t> die_offset = entry.getDIEUnitOffset())
- return DIERef(*cu_offset, die_bias + *die_offset);
+ return DIERef(cu->GetSymbolFileDWARF().GetDwoNum(),
+ DIERef::Section::DebugInfo, cu->GetOffset() + *die_offset);
- return DIERef();
+ return llvm::None;
}
void DebugNamesDWARFIndex::Append(const DebugNames::Entry &entry,
DIEArray &offsets) {
- if (DIERef ref = ToDIERef(entry))
- offsets.push_back(ref);
+ if (llvm::Optional<DIERef> ref = ToDIERef(entry))
+ offsets.push_back(*ref);
}
void DebugNamesDWARFIndex::MaybeLogLookupError(llvm::Error error,
@@ -161,27 +155,27 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(ConstString class_name,
entry.tag() != DW_TAG_class_type)
continue;
- DIERef ref = ToDIERef(entry);
+ llvm::Optional<DIERef> ref = ToDIERef(entry);
if (!ref)
continue;
- DWARFUnit *cu = m_debug_info.GetCompileUnit(ref.cu_offset);
+ DWARFUnit *cu = m_debug_info.GetUnit(*ref);
if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) {
- incomplete_types.push_back(ref);
+ incomplete_types.push_back(*ref);
continue;
}
// FIXME: We should return DWARFDIEs so we don't have to resolve it twice.
- DWARFDIE die = m_debug_info.GetDIE(ref);
+ DWARFDIE die = m_debug_info.GetDIE(*ref);
if (!die)
continue;
if (die.GetAttributeValueAsUnsigned(DW_AT_APPLE_objc_complete_type, 0)) {
// If we find the complete version we're done.
- offsets.push_back(ref);
+ offsets.push_back(*ref);
return;
} else {
- incomplete_types.push_back(ref);
+ incomplete_types.push_back(*ref);
}
}
@@ -221,12 +215,12 @@ void DebugNamesDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
}
void DebugNamesDWARFIndex::GetFunctions(
- ConstString name, DWARFDebugInfo &info,
+ ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) {
std::vector<DWARFDIE> v;
- m_fallback.GetFunctions(name, info, parent_decl_ctx, name_type_mask, v);
+ m_fallback.GetFunctions(name, dwarf, parent_decl_ctx, name_type_mask, v);
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
@@ -234,8 +228,8 @@ void DebugNamesDWARFIndex::GetFunctions(
if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
continue;
- if (DIERef ref = ToDIERef(entry))
- ProcessFunctionDIE(name.GetStringRef(), ref, info, parent_decl_ctx,
+ if (llvm::Optional<DIERef> ref = ToDIERef(entry))
+ ProcessFunctionDIE(name.GetStringRef(), *ref, dwarf, parent_decl_ctx,
name_type_mask, v);
}
diff --git a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index 30423c7ca2a26..dca25496373ff 100644
--- a/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -1,9 +1,8 @@
//===-- DebugNamesDWARFIndex.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,15 +34,14 @@ public:
void GetTypes(ConstString name, DIEArray &offsets) override;
void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
void GetNamespaces(ConstString name, DIEArray &offsets) override;
- void GetFunctions(ConstString name, DWARFDebugInfo &info,
+ void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) override;
void GetFunctions(const RegularExpression &regex,
DIEArray &offsets) override;
- void ReportInvalidDIEOffset(dw_offset_t offset,
- llvm::StringRef name) override {}
+ void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {}
void Dump(Stream &s) override;
private:
@@ -68,7 +66,7 @@ private:
std::unique_ptr<DebugNames> m_debug_names_up;
ManualDWARFIndex m_fallback;
- DIERef ToDIERef(const DebugNames::Entry &entry);
+ llvm::Optional<DIERef> ToDIERef(const DebugNames::Entry &entry);
void Append(const DebugNames::Entry &entry, DIEArray &offsets);
static void MaybeLogLookupError(llvm::Error error,
diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
index f83ba6663dfc6..62b0ad37a9fc0 100644
--- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
+++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
@@ -1,9 +1,8 @@
//===-- HashedNameToDIE.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,8 +13,7 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
DIEArray &die_offsets) {
const size_t count = die_info_array.size();
for (size_t i = 0; i < count; ++i)
- die_offsets.emplace_back(die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace_back(die_info_array[i]);
}
void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
@@ -34,8 +32,7 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
}
if (tag_matches)
- die_offsets.emplace_back(die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace_back(die_info_array[i]);
}
}
}
@@ -59,8 +56,7 @@ void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
tag == DW_TAG_structure_type || tag == DW_TAG_class_type;
}
if (tag_matches)
- die_offsets.emplace_back(die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace_back(die_info_array[i]);
}
}
}
@@ -78,17 +74,14 @@ void DWARFMappedHash::ExtractClassOrStructDIEArray(
// We found the one true definition for this class, so only return
// that
die_offsets.clear();
- die_offsets.emplace_back(die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace_back(die_info_array[i]);
return;
} else {
// Put the one true definition as the first entry so it matches first
- die_offsets.emplace(die_offsets.begin(), die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace(die_offsets.begin(), die_info_array[i]);
}
} else {
- die_offsets.emplace_back(die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace_back(die_info_array[i]);
}
}
}
@@ -100,8 +93,7 @@ void DWARFMappedHash::ExtractTypesFromDIEArray(
const size_t count = die_info_array.size();
for (size_t i = 0; i < count; ++i) {
if ((die_info_array[i].type_flags & type_flag_mask) == type_flag_value)
- die_offsets.emplace_back(die_info_array[i].cu_offset,
- die_info_array[i].offset);
+ die_offsets.emplace_back(die_info_array[i]);
}
}
@@ -125,13 +117,9 @@ const char *DWARFMappedHash::GetAtomTypeName(uint16_t atom) {
return "<invalid>";
}
-DWARFMappedHash::DIEInfo::DIEInfo()
- : cu_offset(DW_INVALID_OFFSET), offset(DW_INVALID_OFFSET), tag(0),
- type_flags(0), qualified_name_hash(0) {}
-
-DWARFMappedHash::DIEInfo::DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t,
- uint32_t f, uint32_t h)
- : cu_offset(c), offset(o), tag(t), type_flags(f), qualified_name_hash(h) {}
+DWARFMappedHash::DIEInfo::DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f,
+ uint32_t h)
+ : die_offset(o), tag(t), type_flags(f), qualified_name_hash(h) {}
DWARFMappedHash::Prologue::Prologue(dw_offset_t _die_base_offset)
: die_base_offset(_die_base_offset), atoms(), atom_mask(0),
@@ -167,6 +155,7 @@ void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) {
case DW_FORM_ref_sig8:
llvm_unreachable("Unhandled atom form");
+ case DW_FORM_addrx:
case DW_FORM_string:
case DW_FORM_block:
case DW_FORM_block1:
@@ -271,14 +260,14 @@ bool DWARFMappedHash::Header::Read(const lldb_private::DWARFDataExtractor &data,
return false;
for (size_t i = 0; i < num_atoms; ++i) {
- DWARFFormValue form_value(NULL, header_data.atoms[i].form);
+ DWARFFormValue form_value(nullptr, header_data.atoms[i].form);
if (!form_value.ExtractValue(data, offset_ptr))
return false;
switch (header_data.atoms[i].type) {
case eAtomTypeDIEOffset: // DIE offset, check form for encoding
- hash_data.offset =
+ hash_data.die_offset =
DWARFFormValue::IsDataForm(form_value.Form())
? form_value.Unsigned()
: form_value.Reference(header_data.die_base_offset);
@@ -301,50 +290,7 @@ bool DWARFMappedHash::Header::Read(const lldb_private::DWARFDataExtractor &data,
break;
}
}
- return true;
-}
-
-void DWARFMappedHash::Header::Dump(lldb_private::Stream &strm,
- const DIEInfo &hash_data) const {
- const size_t num_atoms = header_data.atoms.size();
- for (size_t i = 0; i < num_atoms; ++i) {
- if (i > 0)
- strm.PutCString(", ");
-
- DWARFFormValue form_value(NULL, header_data.atoms[i].form);
- switch (header_data.atoms[i].type) {
- case eAtomTypeDIEOffset: // DIE offset, check form for encoding
- strm.Printf("{0x%8.8x}", hash_data.offset);
- break;
-
- case eAtomTypeTag: // DW_TAG value for the DIE
- {
- const char *tag_cstr = lldb_private::DW_TAG_value_to_name(hash_data.tag);
- if (tag_cstr)
- strm.PutCString(tag_cstr);
- else
- strm.Printf("DW_TAG_(0x%4.4x)", hash_data.tag);
- } break;
-
- case eAtomTypeTypeFlags: // Flags from enum TypeFlags
- strm.Printf("0x%2.2x", hash_data.type_flags);
- if (hash_data.type_flags) {
- strm.PutCString(" (");
- if (hash_data.type_flags & eTypeFlagClassIsImplementation)
- strm.PutCString(" implementation");
- strm.PutCString(" )");
- }
- break;
-
- case eAtomTypeQualNameHash: // Flags from enum TypeFlags
- strm.Printf("0x%8.8x", hash_data.qualified_name_hash);
- break;
-
- default:
- strm.Printf("AtomType(0x%x)", header_data.atoms[i].type);
- break;
- }
- }
+ return hash_data.die_offset != DW_INVALID_OFFSET;
}
DWARFMappedHash::MemoryTable::MemoryTable(
@@ -391,7 +337,7 @@ DWARFMappedHash::MemoryTable::GetHashDataForName(
// There definitely should be a string for this string offset, if there
// isn't, there is something wrong, return and error
const char *strp_cstr = m_string_table.PeekCStr(pair.key);
- if (strp_cstr == NULL) {
+ if (strp_cstr == nullptr) {
*hash_data_offset_ptr = UINT32_MAX;
return eResultError;
}
@@ -458,7 +404,7 @@ DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression(
// There definitely should be a string for this string offset, if there
// isn't, there is something wrong, return and error
const char *strp_cstr = m_string_table.PeekCStr(pair.key);
- if (strp_cstr == NULL)
+ if (strp_cstr == nullptr)
return eResultError;
const uint32_t count = m_data.GetU32(hash_data_offset_ptr);
@@ -556,10 +502,10 @@ size_t DWARFMappedHash::MemoryTable::AppendAllDIEsInRange(
for (uint32_t i = 0; i < count; ++i) {
DIEInfo die_info;
if (m_header.Read(m_data, &hash_data_offset, die_info)) {
- if (die_info.offset == 0)
+ if (die_info.die_offset == 0)
done = true;
- if (die_offset_start <= die_info.offset &&
- die_info.offset < die_offset_end)
+ if (die_offset_start <= die_info.die_offset &&
+ die_info.die_offset < die_offset_end)
die_info_array.push_back(die_info);
}
}
diff --git a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
index 17600df2edd43..a01612b595286 100644
--- a/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -1,9 +1,8 @@
//===-- HashedNameToDIE.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -49,14 +48,21 @@ public:
};
struct DIEInfo {
- dw_offset_t cu_offset;
- dw_offset_t offset; // The DIE offset
- dw_tag_t tag;
- uint32_t type_flags; // Any flags for this DIEInfo
- uint32_t qualified_name_hash; // A 32 bit hash of the fully qualified name
-
- DIEInfo();
- DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
+ dw_offset_t die_offset = DW_INVALID_OFFSET;
+ dw_tag_t tag = 0;
+
+ /// Any flags for this DIEInfo
+ uint32_t type_flags = 0;
+
+ /// A 32 bit hash of the fully qualified name
+ uint32_t qualified_name_hash = 0;
+
+ DIEInfo() = default;
+ DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
+
+ explicit operator DIERef() const {
+ return DIERef(llvm::None, DIERef::Section::DebugInfo, die_offset);
+ }
};
struct Atom {
@@ -105,8 +111,6 @@ public:
bool Read(const lldb_private::DWARFDataExtractor &data,
lldb::offset_t *offset_ptr, DIEInfo &hash_data) const;
-
- void Dump(lldb_private::Stream &strm, const DIEInfo &hash_data) const;
};
// A class for reading and using a saved hash table from a block of data
diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
index 0b06713f9543a..8495016d4280d 100644
--- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp
@@ -1,9 +1,8 @@
//===-- LogChannelDWARF.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,9 +11,6 @@
using namespace lldb_private;
static constexpr Log::Category g_categories[] = {
- {{"aranges"},
- {"log the parsing of .debug_aranges"},
- DWARF_LOG_DEBUG_ARANGES},
{{"comp"},
{"log insertions of object files into DWARF debug maps"},
DWARF_LOG_TYPE_COMPLETION},
@@ -26,12 +22,6 @@ static constexpr Log::Category g_categories[] = {
{{"map"},
{"log struct/unions/class type completions"},
DWARF_LOG_DEBUG_MAP},
- {{"pubnames"},
- {"log the parsing of .debug_pubnames"},
- DWARF_LOG_DEBUG_PUBNAMES},
- {{"pubtypes"},
- {"log the parsing of .debug_pubtypes"},
- DWARF_LOG_DEBUG_PUBTYPES},
};
Log::Channel LogChannelDWARF::g_channel(g_categories, DWARF_LOG_DEFAULT);
diff --git a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
index 038e9b8c2b084..a89c686735d2f 100644
--- a/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.h
@@ -1,9 +1,8 @@
//===-- LogChannelDWARF.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,12 +13,9 @@
#define DWARF_LOG_DEBUG_INFO (1u << 1)
#define DWARF_LOG_DEBUG_LINE (1u << 2)
-#define DWARF_LOG_DEBUG_PUBNAMES (1u << 3)
-#define DWARF_LOG_DEBUG_PUBTYPES (1u << 4)
-#define DWARF_LOG_DEBUG_ARANGES (1u << 5)
-#define DWARF_LOG_LOOKUPS (1u << 6)
-#define DWARF_LOG_TYPE_COMPLETION (1u << 7)
-#define DWARF_LOG_DEBUG_MAP (1u << 8)
+#define DWARF_LOG_LOOKUPS (1u << 3)
+#define DWARF_LOG_TYPE_COMPLETION (1u << 4)
+#define DWARF_LOG_DEBUG_MAP (1u << 5)
#define DWARF_LOG_ALL (UINT32_MAX)
#define DWARF_LOG_DEFAULT (DWARF_LOG_DEBUG_INFO)
diff --git a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 6438f02fe8ecd..aff8b5d8c15fd 100644
--- a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -1,9 +1,8 @@
//===-- ManualDWARFIndex.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,9 +32,9 @@ void ManualDWARFIndex::Index() {
Timer scoped_timer(func_cat, "%p", static_cast<void *>(&debug_info));
std::vector<DWARFUnit *> units_to_index;
- units_to_index.reserve(debug_info.GetNumCompileUnits());
- for (size_t U = 0; U < debug_info.GetNumCompileUnits(); ++U) {
- DWARFUnit *unit = debug_info.GetCompileUnitAtIndex(U);
+ units_to_index.reserve(debug_info.GetNumUnits());
+ for (size_t U = 0; U < debug_info.GetNumUnits(); ++U) {
+ DWARFUnit *unit = debug_info.GetUnitAtIndex(U);
if (unit && m_units_to_avoid.count(unit->GetOffset()) == 0)
units_to_index.push_back(unit);
}
@@ -44,10 +43,8 @@ void ManualDWARFIndex::Index() {
std::vector<IndexSet> sets(units_to_index.size());
- //----------------------------------------------------------------------
- // Keep memory down by clearing DIEs for any compile units if indexing
- // caused us to load the compile unit's DIEs.
- //----------------------------------------------------------------------
+ // Keep memory down by clearing DIEs for any units if indexing
+ // caused us to load the unit's DIEs.
std::vector<llvm::Optional<DWARFUnit::ScopedExtractDIEs>> clear_cu_dies(
units_to_index.size());
auto parser_fn = [&](size_t cu_idx) {
@@ -58,19 +55,17 @@ void ManualDWARFIndex::Index() {
clear_cu_dies[cu_idx] = units_to_index[cu_idx]->ExtractDIEsScoped();
};
- // Create a task runner that extracts dies for each DWARF compile unit in a
+ // Create a task runner that extracts dies for each DWARF unit in a
// separate thread
- //----------------------------------------------------------------------
- // First figure out which compile units didn't have their DIEs already
+ // First figure out which units didn't have their DIEs already
// parsed and remember this. If no DIEs were parsed prior to this index
// function call, we are going to want to clear the CU dies after we are
// done indexing to make sure we don't pull in all DWARF dies, but we need
- // to wait until all compile units have been indexed in case a DIE in one
- // compile unit refers to another and the indexes accesses those DIEs.
- //----------------------------------------------------------------------
+ // to wait until all units have been indexed in case a DIE in one
+ // unit refers to another and the indexes accesses those DIEs.
TaskMapOverInt(0, units_to_index.size(), extract_fn);
- // Now create a task runner that can index each DWARF compile unit in a
+ // Now create a task runner that can index each DWARF unit in a
// separate thread so we can index quickly.
TaskMapOverInt(0, units_to_index.size(), parser_fn);
@@ -93,30 +88,32 @@ void ManualDWARFIndex::Index() {
}
void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
+ assert(
+ !unit.GetSymbolFileDWARF().GetBaseCompileUnit() &&
+ "DWARFUnit associated with .dwo or .dwp should not be indexed directly");
+
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS);
if (log) {
m_module.LogMessage(
- log, "ManualDWARFIndex::IndexUnit for compile unit at .debug_info[0x%8.8x]",
+ log, "ManualDWARFIndex::IndexUnit for unit at .debug_info[0x%8.8x]",
unit.GetOffset());
}
const LanguageType cu_language = unit.GetLanguageType();
- DWARFFormValue::FixedFormSizes fixed_form_sizes = unit.GetFixedFormSizes();
- IndexUnitImpl(unit, cu_language, fixed_form_sizes, unit.GetOffset(), set);
+ IndexUnitImpl(unit, cu_language, set);
- SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile();
- if (dwo_symbol_file && dwo_symbol_file->GetCompileUnit()) {
- IndexUnitImpl(*dwo_symbol_file->GetCompileUnit(), cu_language,
- fixed_form_sizes, unit.GetOffset(), set);
+ if (SymbolFileDWARFDwo *dwo_symbol_file = unit.GetDwoSymbolFile()) {
+ DWARFDebugInfo &dwo_info = *dwo_symbol_file->DebugInfo();
+ for (size_t i = 0; i < dwo_info.GetNumUnits(); ++i)
+ IndexUnitImpl(*dwo_info.GetUnitAtIndex(i), cu_language, set);
}
}
-void ManualDWARFIndex::IndexUnitImpl(
- DWARFUnit &unit, const LanguageType cu_language,
- const DWARFFormValue::FixedFormSizes &fixed_form_sizes,
- const dw_offset_t cu_offset, IndexSet &set) {
+void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
+ const LanguageType cu_language,
+ IndexSet &set) {
for (const DWARFDebugInfoEntry &die : unit.dies()) {
const dw_tag_t tag = die.Tag();
@@ -143,8 +140,8 @@ void ManualDWARFIndex::IndexUnitImpl(
}
DWARFAttributes attributes;
- const char *name = NULL;
- const char *mangled_cstr = NULL;
+ const char *name = nullptr;
+ const char *mangled_cstr = nullptr;
bool is_declaration = false;
// bool is_artificial = false;
bool has_address = false;
@@ -152,8 +149,7 @@ void ManualDWARFIndex::IndexUnitImpl(
bool is_global_or_static_variable = false;
DWARFFormValue specification_die_form;
- const size_t num_attributes =
- die.GetAttributes(&unit, fixed_form_sizes, attributes);
+ const size_t num_attributes = die.GetAttributes(&unit, attributes);
if (num_attributes > 0) {
for (uint32_t i = 0; i < num_attributes; ++i) {
dw_attr_t attr = attributes.AttributeAtIndex(i);
@@ -196,7 +192,7 @@ void ManualDWARFIndex::IndexUnitImpl(
has_location_or_const_value = true;
if (tag == DW_TAG_variable) {
const DWARFDebugInfoEntry *parent_die = die.GetParent();
- while (parent_die != NULL) {
+ while (parent_die != nullptr) {
switch (parent_die->Tag()) {
case DW_TAG_subprogram:
case DW_TAG_lexical_block:
@@ -215,19 +211,19 @@ void ManualDWARFIndex::IndexUnitImpl(
// if (block_data) {
// uint32_t block_length = form_value.Unsigned();
// if (block_length == 1 +
- // attributes.CompileUnitAtIndex(i)->GetAddressByteSize()) {
+ // attributes.UnitAtIndex(i)->GetAddressByteSize()) {
// if (block_data[0] == DW_OP_addr)
// add_die = true;
// }
// }
// }
- parent_die = NULL; // Terminate the while loop.
+ parent_die = nullptr; // Terminate the while loop.
break;
case DW_TAG_compile_unit:
case DW_TAG_partial_unit:
is_global_or_static_variable = true;
- parent_die = NULL; // Terminate the while loop.
+ parent_die = nullptr; // Terminate the while loop.
break;
default:
@@ -247,51 +243,48 @@ void ManualDWARFIndex::IndexUnitImpl(
}
}
+ DIERef ref = *DWARFDIE(&unit, &die).GetDIERef();
switch (tag) {
case DW_TAG_inlined_subroutine:
case DW_TAG_subprogram:
if (has_address) {
if (name) {
- ObjCLanguage::MethodName objc_method(name, true);
- if (objc_method.IsValid(true)) {
- ConstString objc_class_name_with_category(
- objc_method.GetClassNameWithCategory());
- ConstString objc_selector_name(objc_method.GetSelector());
- ConstString objc_fullname_no_category_name(
- objc_method.GetFullNameWithoutCategory(true));
- ConstString objc_class_name_no_category(objc_method.GetClassName());
- set.function_fullnames.Insert(ConstString(name),
- DIERef(cu_offset, die.GetOffset()));
- if (objc_class_name_with_category)
- set.objc_class_selectors.Insert(
- objc_class_name_with_category,
- DIERef(cu_offset, die.GetOffset()));
- if (objc_class_name_no_category &&
- objc_class_name_no_category != objc_class_name_with_category)
- set.objc_class_selectors.Insert(
- objc_class_name_no_category,
- DIERef(cu_offset, die.GetOffset()));
- if (objc_selector_name)
- set.function_selectors.Insert(objc_selector_name,
- DIERef(cu_offset, die.GetOffset()));
- if (objc_fullname_no_category_name)
- set.function_fullnames.Insert(objc_fullname_no_category_name,
- DIERef(cu_offset, die.GetOffset()));
+ bool is_objc_method = false;
+ if (cu_language == eLanguageTypeObjC ||
+ cu_language == eLanguageTypeObjC_plus_plus) {
+ ObjCLanguage::MethodName objc_method(name, true);
+ if (objc_method.IsValid(true)) {
+ is_objc_method = true;
+ ConstString class_name_with_category(
+ objc_method.GetClassNameWithCategory());
+ ConstString objc_selector_name(objc_method.GetSelector());
+ ConstString objc_fullname_no_category_name(
+ objc_method.GetFullNameWithoutCategory(true));
+ ConstString class_name_no_category(objc_method.GetClassName());
+ set.function_fullnames.Insert(ConstString(name), ref);
+ if (class_name_with_category)
+ set.objc_class_selectors.Insert(class_name_with_category, ref);
+ if (class_name_no_category &&
+ class_name_no_category != class_name_with_category)
+ set.objc_class_selectors.Insert(class_name_no_category, ref);
+ if (objc_selector_name)
+ set.function_selectors.Insert(objc_selector_name, ref);
+ if (objc_fullname_no_category_name)
+ set.function_fullnames.Insert(objc_fullname_no_category_name,
+ ref);
+ }
}
// If we have a mangled name, then the DW_AT_name attribute is
// usually the method name without the class or any parameters
bool is_method = DWARFDIE(&unit, &die).IsMethod();
if (is_method)
- set.function_methods.Insert(ConstString(name),
- DIERef(cu_offset, die.GetOffset()));
+ set.function_methods.Insert(ConstString(name), ref);
else
- set.function_basenames.Insert(ConstString(name),
- DIERef(cu_offset, die.GetOffset()));
+ set.function_basenames.Insert(ConstString(name), ref);
- if (!is_method && !mangled_cstr && !objc_method.IsValid(true))
- set.function_fullnames.Insert(ConstString(name),
- DIERef(cu_offset, die.GetOffset()));
+ if (!is_method && !mangled_cstr && !is_objc_method)
+ set.function_fullnames.Insert(ConstString(name), ref);
}
if (mangled_cstr) {
// Make sure our mangled name isn't the same string table entry as
@@ -301,8 +294,7 @@ void ManualDWARFIndex::IndexUnitImpl(
if (name && name != mangled_cstr &&
((mangled_cstr[0] == '_') ||
(::strcmp(name, mangled_cstr) != 0))) {
- set.function_fullnames.Insert(ConstString(mangled_cstr),
- DIERef(cu_offset, die.GetOffset()));
+ set.function_fullnames.Insert(ConstString(mangled_cstr), ref);
}
}
}
@@ -320,22 +312,19 @@ void ManualDWARFIndex::IndexUnitImpl(
case DW_TAG_union_type:
case DW_TAG_unspecified_type:
if (name && !is_declaration)
- set.types.Insert(ConstString(name), DIERef(cu_offset, die.GetOffset()));
+ set.types.Insert(ConstString(name), ref);
if (mangled_cstr && !is_declaration)
- set.types.Insert(ConstString(mangled_cstr),
- DIERef(cu_offset, die.GetOffset()));
+ set.types.Insert(ConstString(mangled_cstr), ref);
break;
case DW_TAG_namespace:
if (name)
- set.namespaces.Insert(ConstString(name),
- DIERef(cu_offset, die.GetOffset()));
+ set.namespaces.Insert(ConstString(name), ref);
break;
case DW_TAG_variable:
if (name && has_location_or_const_value && is_global_or_static_variable) {
- set.globals.Insert(ConstString(name),
- DIERef(cu_offset, die.GetOffset()));
+ set.globals.Insert(ConstString(name), ref);
// Be sure to include variables by their mangled and demangled names if
// they have any since a variable can have a basename "i", a mangled
// named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name
@@ -347,8 +336,7 @@ void ManualDWARFIndex::IndexUnitImpl(
// entries
if (mangled_cstr && name != mangled_cstr &&
((mangled_cstr[0] == '_') || (::strcmp(name, mangled_cstr) != 0))) {
- set.globals.Insert(ConstString(mangled_cstr),
- DIERef(cu_offset, die.GetOffset()));
+ set.globals.Insert(ConstString(mangled_cstr), ref);
}
}
break;
@@ -370,10 +358,10 @@ void ManualDWARFIndex::GetGlobalVariables(const RegularExpression &regex,
m_set.globals.Find(regex, offsets);
}
-void ManualDWARFIndex::GetGlobalVariables(const DWARFUnit &cu,
+void ManualDWARFIndex::GetGlobalVariables(const DWARFUnit &unit,
DIEArray &offsets) {
Index();
- m_set.globals.FindAllEntriesForCompileUnit(cu.GetOffset(), offsets);
+ m_set.globals.FindAllEntriesForUnit(unit, offsets);
}
void ManualDWARFIndex::GetObjCMethods(ConstString class_name,
@@ -405,7 +393,7 @@ void ManualDWARFIndex::GetNamespaces(ConstString name, DIEArray &offsets) {
m_set.namespaces.Find(name, offsets);
}
-void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
+void ManualDWARFIndex::GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) {
@@ -417,7 +405,7 @@ void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
m_set.function_methods.Find(name, offsets);
m_set.function_fullnames.Find(name, offsets);
for (const DIERef &die_ref: offsets) {
- DWARFDIE die = info.GetDIE(die_ref);
+ DWARFDIE die = dwarf.GetDIE(die_ref);
if (!die)
continue;
if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
@@ -428,7 +416,7 @@ void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
DIEArray offsets;
m_set.function_basenames.Find(name, offsets);
for (const DIERef &die_ref: offsets) {
- DWARFDIE die = info.GetDIE(die_ref);
+ DWARFDIE die = dwarf.GetDIE(die_ref);
if (!die)
continue;
if (SymbolFileDWARF::DIEInDeclContext(&parent_decl_ctx, die))
@@ -441,7 +429,7 @@ void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
DIEArray offsets;
m_set.function_methods.Find(name, offsets);
for (const DIERef &die_ref: offsets) {
- if (DWARFDIE die = info.GetDIE(die_ref))
+ if (DWARFDIE die = dwarf.GetDIE(die_ref))
dies.push_back(die);
}
}
@@ -451,7 +439,7 @@ void ManualDWARFIndex::GetFunctions(ConstString name, DWARFDebugInfo &info,
DIEArray offsets;
m_set.function_selectors.Find(name, offsets);
for (const DIERef &die_ref: offsets) {
- if (DWARFDIE die = info.GetDIE(die_ref))
+ if (DWARFDIE die = dwarf.GetDIE(die_ref))
dies.push_back(die);
}
}
diff --git a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index 79ab1d95b380b..dd03b103c936a 100644
--- a/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -1,9 +1,8 @@
-//===-- ManulaDWARFIndex.h -------------------------------------*- C++ -*-===//
+//===-- ManualDWARFIndex.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,8 @@
#include "Plugins/SymbolFile/DWARF/NameToDIE.h"
#include "llvm/ADT/DenseSet.h"
+class DWARFDebugInfo;
+
namespace lldb_private {
class ManualDWARFIndex : public DWARFIndex {
public:
@@ -27,21 +28,20 @@ public:
void GetGlobalVariables(ConstString basename, DIEArray &offsets) override;
void GetGlobalVariables(const RegularExpression &regex,
DIEArray &offsets) override;
- void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override;
+ void GetGlobalVariables(const DWARFUnit &unit, DIEArray &offsets) override;
void GetObjCMethods(ConstString class_name, DIEArray &offsets) override;
void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
DIEArray &offsets) override;
void GetTypes(ConstString name, DIEArray &offsets) override;
void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override;
void GetNamespaces(ConstString name, DIEArray &offsets) override;
- void GetFunctions(ConstString name, DWARFDebugInfo &info,
+ void GetFunctions(ConstString name, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
uint32_t name_type_mask,
std::vector<DWARFDIE> &dies) override;
void GetFunctions(const RegularExpression &regex, DIEArray &offsets) override;
- void ReportInvalidDIEOffset(dw_offset_t offset,
- llvm::StringRef name) override {}
+ void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {}
void Dump(Stream &s) override;
private:
@@ -58,10 +58,9 @@ private:
void Index();
void IndexUnit(DWARFUnit &unit, IndexSet &set);
- static void
- IndexUnitImpl(DWARFUnit &unit, const lldb::LanguageType cu_language,
- const DWARFFormValue::FixedFormSizes &fixed_form_sizes,
- const dw_offset_t cu_offset, IndexSet &set);
+ static void IndexUnitImpl(DWARFUnit &unit,
+ const lldb::LanguageType cu_language,
+ IndexSet &set);
/// Non-null value means we haven't built the index yet.
DWARFDebugInfo *m_debug_info;
diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index c8d6bba16976d..7d81afb1b2262 100644
--- a/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -1,23 +1,19 @@
//===-- NameToDIE.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "NameToDIE.h"
+#include "DWARFUnit.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/StreamString.h"
-#include "DWARFDebugInfo.h"
-#include "DWARFDebugInfoEntry.h"
-#include "SymbolFileDWARF.h"
-
using namespace lldb;
using namespace lldb_private;
@@ -26,11 +22,11 @@ void NameToDIE::Finalize() {
m_map.SizeToFit();
}
-void NameToDIE::Insert(const ConstString &name, const DIERef &die_ref) {
+void NameToDIE::Insert(ConstString name, const DIERef &die_ref) {
m_map.Append(name, die_ref);
}
-size_t NameToDIE::Find(const ConstString &name, DIEArray &info_array) const {
+size_t NameToDIE::Find(ConstString name, DIEArray &info_array) const {
return m_map.GetValues(name, info_array);
}
@@ -39,13 +35,16 @@ size_t NameToDIE::Find(const RegularExpression &regex,
return m_map.GetValues(regex, info_array);
}
-size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
- DIEArray &info_array) const {
+size_t NameToDIE::FindAllEntriesForUnit(const DWARFUnit &unit,
+ DIEArray &info_array) const {
const size_t initial_size = info_array.size();
const uint32_t size = m_map.GetSize();
for (uint32_t i = 0; i < size; ++i) {
const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
- if (cu_offset == die_ref.cu_offset)
+ if (unit.GetSymbolFileDWARF().GetDwoNum() == die_ref.dwo_num() &&
+ unit.GetDebugSection() == die_ref.section() &&
+ unit.GetOffset() <= die_ref.die_offset() &&
+ die_ref.die_offset() < unit.GetNextUnitOffset())
info_array.push_back(die_ref);
}
return info_array.size() - initial_size;
@@ -54,10 +53,8 @@ size_t NameToDIE::FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
void NameToDIE::Dump(Stream *s) {
const uint32_t size = m_map.GetSize();
for (uint32_t i = 0; i < size; ++i) {
- ConstString cstr = m_map.GetCStringAtIndex(i);
- const DIERef &die_ref = m_map.GetValueAtIndexUnchecked(i);
- s->Printf("%p: {0x%8.8x/0x%8.8x} \"%s\"\n", (const void *)cstr.GetCString(),
- die_ref.cu_offset, die_ref.die_offset, cstr.GetCString());
+ s->Format("{0} \"{1}\"\n", m_map.GetValueAtIndexUnchecked(i),
+ m_map.GetCStringAtIndexUnchecked(i));
}
}
diff --git a/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/source/Plugins/SymbolFile/DWARF/NameToDIE.h
index bba44fda3c042..b504f45e81b55 100644
--- a/source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ b/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -1,9 +1,8 @@
//===-- NameToDIE.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,7 +16,7 @@
#include "lldb/Core/dwarf.h"
#include "lldb/lldb-defines.h"
-class SymbolFileDWARF;
+class DWARFUnit;
class NameToDIE {
public:
@@ -27,20 +26,20 @@ public:
void Dump(lldb_private::Stream *s);
- void Insert(const lldb_private::ConstString &name, const DIERef &die_ref);
+ void Insert(lldb_private::ConstString name, const DIERef &die_ref);
void Append(const NameToDIE &other);
void Finalize();
- size_t Find(const lldb_private::ConstString &name,
+ size_t Find(lldb_private::ConstString name,
DIEArray &info_array) const;
size_t Find(const lldb_private::RegularExpression &regex,
DIEArray &info_array) const;
- size_t FindAllEntriesForCompileUnit(dw_offset_t cu_offset,
- DIEArray &info_array) const;
+ size_t FindAllEntriesForUnit(const DWARFUnit &unit,
+ DIEArray &info_array) const;
void
ForEach(std::function<bool(lldb_private::ConstString name,
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 2a0a89f0b25a1..e2ddcfc5d64be 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARF.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,7 +29,6 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
#include "lldb/Interpreter/OptionValueFileSpecList.h"
#include "lldb/Interpreter/OptionValueProperties.h"
@@ -43,6 +41,7 @@
#include "lldb/Symbol/CompilerDeclContext.h"
#include "lldb/Symbol/DebugMacros.h"
#include "lldb/Symbol/LineTable.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/TypeMap.h"
@@ -50,11 +49,12 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Target/Language.h"
+#include "lldb/Target/Target.h"
#include "AppleDWARFIndex.h"
#include "DWARFASTParser.h"
#include "DWARFASTParserClang.h"
-#include "DWARFDIECollection.h"
+#include "DWARFCompileUnit.h"
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
#include "DWARFDebugInfo.h"
@@ -63,6 +63,7 @@
#include "DWARFDebugRanges.h"
#include "DWARFDeclContext.h"
#include "DWARFFormValue.h"
+#include "DWARFTypeUnit.h"
#include "DWARFUnit.h"
#include "DebugNamesDWARFIndex.h"
#include "LogChannelDWARF.h"
@@ -73,7 +74,9 @@
#include "llvm/Support/FileSystem.h"
+#include <algorithm>
#include <map>
+#include <memory>
#include <ctype.h>
#include <string.h>
@@ -131,12 +134,12 @@ public:
}
PluginProperties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
m_collection_sp->Initialize(g_properties);
}
- FileSpecList &GetSymLinkPaths() {
- OptionValueFileSpecList *option_value =
+ FileSpecList GetSymLinkPaths() {
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(
nullptr, true, ePropertySymLinkPaths);
assert(option_value);
@@ -158,68 +161,8 @@ static const SymbolFileDWARFPropertiesSP &GetGlobalPluginProperties() {
} // anonymous namespace end
-static const char *removeHostnameFromPathname(const char *path_from_dwarf) {
- if (!path_from_dwarf || !path_from_dwarf[0]) {
- return path_from_dwarf;
- }
-
- const char *colon_pos = strchr(path_from_dwarf, ':');
- if (nullptr == colon_pos) {
- return path_from_dwarf;
- }
-
- const char *slash_pos = strchr(path_from_dwarf, '/');
- if (slash_pos && (slash_pos < colon_pos)) {
- return path_from_dwarf;
- }
-
- // check whether we have a windows path, and so the first character is a
- // drive-letter not a hostname.
- if (colon_pos == path_from_dwarf + 1 && isalpha(*path_from_dwarf) &&
- strlen(path_from_dwarf) > 2 && '\\' == path_from_dwarf[2]) {
- return path_from_dwarf;
- }
-
- return colon_pos + 1;
-}
-
-static FileSpec resolveCompDir(const char *path_from_dwarf) {
- if (!path_from_dwarf)
- return FileSpec();
-
- // DWARF2/3 suggests the form hostname:pathname for compilation directory.
- // Remove the host part if present.
- const char *local_path = removeHostnameFromPathname(path_from_dwarf);
- if (!local_path)
- return FileSpec();
-
- bool is_symlink = false;
- // Always normalize our compile unit directory to get rid of redundant
- // slashes and other path anomalies before we use it for path prepending
- FileSpec local_spec(local_path);
- const auto &file_specs = GetGlobalPluginProperties()->GetSymLinkPaths();
- for (size_t i = 0; i < file_specs.GetSize() && !is_symlink; ++i)
- is_symlink = FileSpec::Equal(file_specs.GetFileSpecAtIndex(i),
- local_spec, true);
-
- if (!is_symlink)
- return local_spec;
-
- namespace fs = llvm::sys::fs;
- if (fs::get_file_type(local_spec.GetPath(), false) !=
- fs::file_type::symlink_file)
- return local_spec;
-
- FileSpec resolved_symlink;
- const auto error = FileSystem::Instance().Readlink(local_spec, resolved_symlink);
- if (error.Success())
- return resolved_symlink;
-
- return local_spec;
-}
-
-DWARFUnit *SymbolFileDWARF::GetBaseCompileUnit() {
- return nullptr;
+FileSpecList SymbolFileDWARF::GetSymlinkPaths() {
+ return GetGlobalPluginProperties()->GetSymLinkPaths();
}
void SymbolFileDWARF::Initialize() {
@@ -255,7 +198,8 @@ const char *SymbolFileDWARF::GetPluginDescriptionStatic() {
}
SymbolFile *SymbolFileDWARF::CreateInstance(ObjectFile *obj_file) {
- return new SymbolFileDWARF(obj_file);
+ return new SymbolFileDWARF(obj_file,
+ /*dwo_section_list*/ nullptr);
}
TypeList *SymbolFileDWARF::GetTypeList() {
@@ -346,23 +290,23 @@ size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope,
ASSERT_MODULE_LOCK(this);
TypeSet type_set;
- CompileUnit *comp_unit = NULL;
- DWARFUnit *dwarf_cu = NULL;
+ CompileUnit *comp_unit = nullptr;
+ DWARFUnit *dwarf_cu = nullptr;
if (sc_scope)
comp_unit = sc_scope->CalculateSymbolContextCompileUnit();
if (comp_unit) {
dwarf_cu = GetDWARFCompileUnit(comp_unit);
- if (dwarf_cu == 0)
+ if (dwarf_cu == nullptr)
return 0;
GetTypes(dwarf_cu->DIE(), dwarf_cu->GetOffset(),
- dwarf_cu->GetNextCompileUnitOffset(), type_mask, type_set);
+ dwarf_cu->GetNextUnitOffset(), type_mask, type_set);
} else {
DWARFDebugInfo *info = DebugInfo();
if (info) {
- const size_t num_cus = info->GetNumCompileUnits();
+ const size_t num_cus = info->GetNumUnits();
for (size_t cu_idx = 0; cu_idx < num_cus; ++cu_idx) {
- dwarf_cu = info->GetCompileUnitAtIndex(cu_idx);
+ dwarf_cu = info->GetUnitAtIndex(cu_idx);
if (dwarf_cu) {
GetTypes(dwarf_cu->DIE(), 0, UINT32_MAX, type_mask, type_set);
}
@@ -383,10 +327,8 @@ size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope,
return num_types_added;
}
-//----------------------------------------------------------------------
// Gets the first parent that is a lexical block, function or inlined
// subroutine, or compile unit.
-//----------------------------------------------------------------------
DWARFDIE
SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDIE &child_die) {
DWARFDIE die;
@@ -405,23 +347,21 @@ SymbolFileDWARF::GetParentSymbolContextDIE(const DWARFDIE &child_die) {
return DWARFDIE();
}
-SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile)
- : SymbolFile(objfile), UserID(uint64_t(DW_INVALID_OFFSET)
- << 32), // Used by SymbolFileDWARFDebugMap to
- // when this class parses .o files to
- // contain the .o file index/ID
- m_debug_map_module_wp(), m_debug_map_symfile(NULL), m_data_debug_abbrev(),
- m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(),
- m_data_debug_line(), m_data_debug_macro(), m_data_debug_loc(),
- m_data_debug_ranges(), m_data_debug_rnglists(), m_data_debug_str(),
- m_data_apple_names(), m_data_apple_types(), m_data_apple_namespaces(),
- m_abbr(), m_info(), m_line(), m_fetched_external_modules(false),
- m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(),
+SymbolFileDWARF::SymbolFileDWARF(ObjectFile *objfile,
+ SectionList *dwo_section_list)
+ : SymbolFile(objfile),
+ UserID(0x7fffffff00000000), // Used by SymbolFileDWARFDebugMap to
+ // when this class parses .o files to
+ // contain the .o file index/ID
+ m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
+ m_context(objfile->GetModule()->GetSectionList(), dwo_section_list),
+ m_data_debug_loc(), m_abbr(), m_info(), m_fetched_external_modules(false),
+ m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate),
m_unique_ast_type_map() {}
SymbolFileDWARF::~SymbolFileDWARF() {}
-static const ConstString &GetDWARFMachOSegmentName() {
+static ConstString GetDWARFMachOSegmentName() {
static ConstString g_dwarf_section_name("__DWARF");
return g_dwarf_section_name;
}
@@ -449,15 +389,6 @@ TypeSystem *SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) {
void SymbolFileDWARF::InitializeObject() {
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- ModuleSP module_sp(m_obj_file->GetModule());
- if (module_sp) {
- const SectionList *section_list = module_sp->GetSectionList();
- Section *section =
- section_list->FindSectionByName(GetDWARFMachOSegmentName()).get();
-
- if (section)
- m_obj_file->ReadSectionData(section, m_dwarf_data);
- }
if (!GetGlobalPluginProperties()->IgnoreFileIndexes()) {
DWARFDataExtractor apple_names, apple_namespaces, apple_types, apple_objc;
@@ -468,7 +399,7 @@ void SymbolFileDWARF::InitializeObject() {
m_index = AppleDWARFIndex::Create(
*GetObjectFile()->GetModule(), apple_names, apple_namespaces,
- apple_types, apple_objc, get_debug_str_data());
+ apple_types, apple_objc, m_context.getOrLoadStrData());
if (m_index)
return;
@@ -477,9 +408,9 @@ void SymbolFileDWARF::InitializeObject() {
LoadSectionData(eSectionTypeDWARFDebugNames, debug_names);
if (debug_names.GetByteSize() > 0) {
llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> index_or =
- DebugNamesDWARFIndex::Create(*GetObjectFile()->GetModule(),
- debug_names, get_debug_str_data(),
- DebugInfo());
+ DebugNamesDWARFIndex::Create(
+ *GetObjectFile()->GetModule(), debug_names,
+ m_context.getOrLoadStrData(), DebugInfo());
if (index_or) {
m_index = std::move(*index_or);
return;
@@ -499,25 +430,11 @@ bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
uint32_t SymbolFileDWARF::CalculateAbilities() {
uint32_t abilities = 0;
- if (m_obj_file != NULL) {
- const Section *section = NULL;
+ if (m_obj_file != nullptr) {
+ const Section *section = nullptr;
const SectionList *section_list = m_obj_file->GetSectionList();
- if (section_list == NULL)
- return 0;
-
- // On non Apple platforms we might have .debug_types debug info that is
- // created by using "-fdebug-types-section". LLDB currently will try to
- // load this debug info, but it causes crashes during debugging when types
- // are missing since it doesn't know how to parse the info in the
- // .debug_types type units. This causes all complex debug info types to be
- // unresolved. Because this causes LLDB to crash and since it really
- // doesn't provide a solid debuggiung experience, we should disable trying
- // to debug this kind of DWARF until support gets added or deprecated.
- if (section_list->FindSectionByName(ConstString(".debug_types"))) {
- m_obj_file->GetModule()->ReportWarning(
- "lldb doesn’t support .debug_types debug info");
+ if (section_list == nullptr)
return 0;
- }
uint64_t debug_abbrev_file_size = 0;
uint64_t debug_info_file_size = 0;
@@ -530,7 +447,7 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
section =
section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true).get();
- if (section != NULL) {
+ if (section != nullptr) {
debug_info_file_size = section->GetFileSize();
section =
@@ -604,53 +521,15 @@ void SymbolFileDWARF::LoadSectionData(lldb::SectionType sect_type,
DWARFDataExtractor &data) {
ModuleSP module_sp(m_obj_file->GetModule());
const SectionList *section_list = module_sp->GetSectionList();
- if (section_list) {
- SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
- if (section_sp) {
- // See if we memory mapped the DWARF segment?
- if (m_dwarf_data.GetByteSize()) {
- data.SetData(m_dwarf_data, section_sp->GetOffset(),
- section_sp->GetFileSize());
- } else {
- if (m_obj_file->ReadSectionData(section_sp.get(), data) == 0)
- data.Clear();
- }
- }
- }
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_abbrev_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugAbbrev,
- m_data_debug_abbrev);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_addr_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugAddr, m_data_debug_addr);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_aranges_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugAranges,
- m_data_debug_aranges);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_frame_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugFrame, m_data_debug_frame);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_info_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugInfo, m_data_debug_info);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugLine, m_data_debug_line);
-}
+ if (!section_list)
+ return;
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_line_str_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugLineStr, m_data_debug_line_str);
-}
+ SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
+ if (!section_sp)
+ return;
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_macro_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugMacro, m_data_debug_macro);
+ data.Clear();
+ m_obj_file->ReadSectionData(section_sp.get(), data);
}
const DWARFDataExtractor &SymbolFileDWARF::DebugLocData() {
@@ -669,60 +548,24 @@ const DWARFDataExtractor &SymbolFileDWARF::get_debug_loclists_data() {
m_data_debug_loclists);
}
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_ranges_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugRanges,
- m_data_debug_ranges);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_rnglists_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugRngLists,
- m_data_debug_rnglists);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugStr, m_data_debug_str);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_str_offsets_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsets,
- m_data_debug_str_offsets);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_debug_types_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugTypes, m_data_debug_types);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_apple_names_data() {
- return GetCachedSectionData(eSectionTypeDWARFAppleNames, m_data_apple_names);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_apple_types_data() {
- return GetCachedSectionData(eSectionTypeDWARFAppleTypes, m_data_apple_types);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_apple_namespaces_data() {
- return GetCachedSectionData(eSectionTypeDWARFAppleNamespaces,
- m_data_apple_namespaces);
-}
-
-const DWARFDataExtractor &SymbolFileDWARF::get_apple_objc_data() {
- return GetCachedSectionData(eSectionTypeDWARFAppleObjC, m_data_apple_objc);
-}
+DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
+ if (m_abbr)
+ return m_abbr.get();
-const DWARFDataExtractor &SymbolFileDWARF::get_gnu_debugaltlink() {
- return GetCachedSectionData(eSectionTypeDWARFGNUDebugAltLink,
- m_data_gnu_debugaltlink);
-}
+ const DWARFDataExtractor &debug_abbrev_data = m_context.getOrLoadAbbrevData();
+ if (debug_abbrev_data.GetByteSize() == 0)
+ return nullptr;
-DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
- if (m_abbr.get() == NULL) {
- const DWARFDataExtractor &debug_abbrev_data = get_debug_abbrev_data();
- if (debug_abbrev_data.GetByteSize() > 0) {
- m_abbr.reset(new DWARFDebugAbbrev());
- if (m_abbr.get())
- m_abbr->Parse(debug_abbrev_data);
- }
+ auto abbr = llvm::make_unique<DWARFDebugAbbrev>();
+ llvm::Error error = abbr->parse(debug_abbrev_data);
+ if (error) {
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ LLDB_LOG_ERROR(log, std::move(error),
+ "Unable to read .debug_abbrev section: {0}");
+ return nullptr;
}
+
+ m_abbr = std::move(abbr);
return m_abbr.get();
}
@@ -731,16 +574,12 @@ const DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() const {
}
DWARFDebugInfo *SymbolFileDWARF::DebugInfo() {
- if (m_info.get() == NULL) {
+ if (m_info == nullptr) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast<void *>(this));
- if (get_debug_info_data().GetByteSize() > 0) {
- m_info.reset(new DWARFDebugInfo());
- if (m_info.get()) {
- m_info->SetDwarfData(this);
- }
- }
+ if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0)
+ m_info = llvm::make_unique<DWARFDebugInfo>(*this, m_context);
}
return m_info.get();
}
@@ -756,109 +595,90 @@ SymbolFileDWARF::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
DWARFDebugInfo *info = DebugInfo();
if (info) {
- // Just a normal DWARF file whose user ID for the compile unit is the DWARF
- // offset itself
-
- DWARFUnit *dwarf_cu =
- info->GetCompileUnit((dw_offset_t)comp_unit->GetID());
- if (dwarf_cu && dwarf_cu->GetUserData() == NULL)
+ // The compile unit ID is the index of the DWARF unit.
+ DWARFUnit *dwarf_cu = info->GetUnitAtIndex(comp_unit->GetID());
+ if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
dwarf_cu->SetUserData(comp_unit);
return dwarf_cu;
}
- return NULL;
+ return nullptr;
}
-DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() {
- if (m_ranges.get() == NULL) {
+DWARFDebugRangesBase *SymbolFileDWARF::GetDebugRanges() {
+ if (!m_ranges) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
static_cast<void *>(this));
- if (get_debug_ranges_data().GetByteSize() > 0)
+ if (m_context.getOrLoadRangesData().GetByteSize() > 0)
m_ranges.reset(new DWARFDebugRanges());
- else if (get_debug_rnglists_data().GetByteSize() > 0)
- m_ranges.reset(new DWARFDebugRngLists());
- if (m_ranges.get())
- m_ranges->Extract(this);
+ if (m_ranges)
+ m_ranges->Extract(m_context);
}
return m_ranges.get();
}
-const DWARFDebugRangesBase *SymbolFileDWARF::DebugRanges() const {
- return m_ranges.get();
+DWARFDebugRangesBase *SymbolFileDWARF::GetDebugRngLists() {
+ if (!m_rnglists) {
+ static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
+ Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
+ static_cast<void *>(this));
+
+ if (m_context.getOrLoadRngListsData().GetByteSize() > 0)
+ m_rnglists.reset(new DWARFDebugRngLists());
+
+ if (m_rnglists)
+ m_rnglists->Extract(m_context);
+ }
+ return m_rnglists.get();
}
-lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFUnit *dwarf_cu,
- uint32_t cu_idx) {
+lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
CompUnitSP cu_sp;
- if (dwarf_cu) {
- CompileUnit *comp_unit = (CompileUnit *)dwarf_cu->GetUserData();
- if (comp_unit) {
- // We already parsed this compile unit, had out a shared pointer to it
- cu_sp = comp_unit->shared_from_this();
+ CompileUnit *comp_unit = (CompileUnit *)dwarf_cu.GetUserData();
+ if (comp_unit) {
+ // We already parsed this compile unit, had out a shared pointer to it
+ cu_sp = comp_unit->shared_from_this();
+ } else {
+ if (&dwarf_cu.GetSymbolFileDWARF() != this) {
+ return dwarf_cu.GetSymbolFileDWARF().ParseCompileUnit(dwarf_cu);
+ } else if (dwarf_cu.GetOffset() == 0 && GetDebugMapSymfile()) {
+ // Let the debug map create the compile unit
+ cu_sp = m_debug_map_symfile->GetCompileUnit(this);
+ dwarf_cu.SetUserData(cu_sp.get());
} else {
- if (dwarf_cu->GetSymbolFileDWARF() != this) {
- return dwarf_cu->GetSymbolFileDWARF()->ParseCompileUnit(dwarf_cu,
- cu_idx);
- } else if (dwarf_cu->GetOffset() == 0 && GetDebugMapSymfile()) {
- // Let the debug map create the compile unit
- cu_sp = m_debug_map_symfile->GetCompileUnit(this);
- dwarf_cu->SetUserData(cu_sp.get());
- } else {
- ModuleSP module_sp(m_obj_file->GetModule());
- if (module_sp) {
- const DWARFDIE cu_die = dwarf_cu->DIE();
- if (cu_die) {
- FileSpec cu_file_spec(cu_die.GetName());
- if (cu_file_spec) {
- // If we have a full path to the compile unit, we don't need to
- // resolve the file. This can be expensive e.g. when the source
- // files are
- // NFS mounted.
- if (cu_file_spec.IsRelative()) {
- const char *cu_comp_dir{
- cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr)};
- cu_file_spec.PrependPathComponent(resolveCompDir(cu_comp_dir));
- }
-
- std::string remapped_file;
- if (module_sp->RemapSourceFile(cu_file_spec.GetPath(),
- remapped_file))
- cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
- }
+ ModuleSP module_sp(m_obj_file->GetModule());
+ if (module_sp) {
+ const DWARFDIE cu_die = dwarf_cu.DIE();
+ if (cu_die) {
+ FileSpec cu_file_spec(cu_die.GetName(), dwarf_cu.GetPathStyle());
+ if (cu_file_spec) {
+ // If we have a full path to the compile unit, we don't need to
+ // resolve the file. This can be expensive e.g. when the source
+ // files are NFS mounted.
+ cu_file_spec.MakeAbsolute(dwarf_cu.GetCompilationDirectory());
+
+ std::string remapped_file;
+ if (module_sp->RemapSourceFile(cu_file_spec.GetPath(),
+ remapped_file))
+ cu_file_spec.SetFile(remapped_file, FileSpec::Style::native);
+ }
- LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF(
- cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
-
- bool is_optimized = dwarf_cu->GetIsOptimized();
- cu_sp.reset(new CompileUnit(
- module_sp, dwarf_cu, cu_file_spec, dwarf_cu->GetID(),
- cu_language, is_optimized ? eLazyBoolYes : eLazyBoolNo));
- if (cu_sp) {
- // If we just created a compile unit with an invalid file spec,
- // try and get the first entry in the supports files from the
- // line table as that should be the compile unit.
- if (!cu_file_spec) {
- cu_file_spec = cu_sp->GetSupportFiles().GetFileSpecAtIndex(1);
- if (cu_file_spec) {
- (FileSpec &)(*cu_sp) = cu_file_spec;
- // Also fix the invalid file spec which was copied from the
- // compile unit.
- cu_sp->GetSupportFiles().Replace(0, cu_file_spec);
- }
- }
+ LanguageType cu_language = DWARFUnit::LanguageTypeFromDWARF(
+ cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0));
- dwarf_cu->SetUserData(cu_sp.get());
+ bool is_optimized = dwarf_cu.GetIsOptimized();
+ BuildCuTranslationTable();
+ cu_sp = std::make_shared<CompileUnit>(
+ module_sp, &dwarf_cu, cu_file_spec,
+ *GetDWARFUnitIndex(dwarf_cu.GetID()), cu_language,
+ is_optimized ? eLazyBoolYes : eLazyBoolNo);
- // Figure out the compile unit index if we weren't given one
- if (cu_idx == UINT32_MAX)
- DebugInfo()->GetCompileUnit(dwarf_cu->GetOffset(), &cu_idx);
+ dwarf_cu.SetUserData(cu_sp.get());
- m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(
- cu_idx, cu_sp);
- }
- }
+ m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(
+ dwarf_cu.GetID(), cu_sp);
}
}
}
@@ -866,23 +686,56 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFUnit *dwarf_cu,
return cu_sp;
}
+void SymbolFileDWARF::BuildCuTranslationTable() {
+ if (!m_lldb_cu_to_dwarf_unit.empty())
+ return;
+
+ DWARFDebugInfo *info = DebugInfo();
+ if (!info)
+ return;
+
+ if (!info->ContainsTypeUnits()) {
+ // We can use a 1-to-1 mapping. No need to build a translation table.
+ return;
+ }
+ for (uint32_t i = 0, num = info->GetNumUnits(); i < num; ++i) {
+ if (auto *cu = llvm::dyn_cast<DWARFCompileUnit>(info->GetUnitAtIndex(i))) {
+ cu->SetID(m_lldb_cu_to_dwarf_unit.size());
+ m_lldb_cu_to_dwarf_unit.push_back(i);
+ }
+ }
+}
+
+llvm::Optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) {
+ BuildCuTranslationTable();
+ if (m_lldb_cu_to_dwarf_unit.empty())
+ return cu_idx;
+ if (cu_idx >= m_lldb_cu_to_dwarf_unit.size())
+ return llvm::None;
+ return m_lldb_cu_to_dwarf_unit[cu_idx];
+}
+
uint32_t SymbolFileDWARF::GetNumCompileUnits() {
DWARFDebugInfo *info = DebugInfo();
- if (info)
- return info->GetNumCompileUnits();
- return 0;
+ if (!info)
+ return 0;
+ BuildCuTranslationTable();
+ return m_lldb_cu_to_dwarf_unit.empty() ? info->GetNumUnits()
+ : m_lldb_cu_to_dwarf_unit.size();
}
CompUnitSP SymbolFileDWARF::ParseCompileUnitAtIndex(uint32_t cu_idx) {
ASSERT_MODULE_LOCK(this);
- CompUnitSP cu_sp;
DWARFDebugInfo *info = DebugInfo();
- if (info) {
- DWARFUnit *dwarf_cu = info->GetCompileUnitAtIndex(cu_idx);
- if (dwarf_cu)
- cu_sp = ParseCompileUnit(dwarf_cu, cu_idx);
+ if (!info)
+ return {};
+
+ if (llvm::Optional<uint32_t> dwarf_idx = GetDWARFUnitIndex(cu_idx)) {
+ if (auto *dwarf_cu = llvm::cast_or_null<DWARFCompileUnit>(
+ info->GetUnitAtIndex(*dwarf_idx)))
+ return ParseCompileUnit(*dwarf_cu);
}
- return cu_sp;
+ return {};
}
Function *SymbolFileDWARF::ParseFunction(CompileUnit &comp_unit,
@@ -920,50 +773,74 @@ lldb::LanguageType SymbolFileDWARF::ParseLanguage(CompileUnit &comp_unit) {
size_t SymbolFileDWARF::ParseFunctions(CompileUnit &comp_unit) {
ASSERT_MODULE_LOCK(this);
- size_t functions_added = 0;
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
- if (dwarf_cu) {
- DWARFDIECollection function_dies;
- const size_t num_functions =
- dwarf_cu->AppendDIEsWithTag(DW_TAG_subprogram, function_dies);
- size_t func_idx;
- for (func_idx = 0; func_idx < num_functions; ++func_idx) {
- DWARFDIE die = function_dies.GetDIEAtIndex(func_idx);
- if (comp_unit.FindFunctionByUID(die.GetID()).get() == NULL) {
- if (ParseFunction(comp_unit, die))
- ++functions_added;
- }
- }
- // FixupTypes();
+ if (!dwarf_cu)
+ return 0;
+
+ size_t functions_added = 0;
+ std::vector<DWARFDIE> function_dies;
+ dwarf_cu->AppendDIEsWithTag(DW_TAG_subprogram, function_dies);
+ for (const DWARFDIE &die : function_dies) {
+ if (comp_unit.FindFunctionByUID(die.GetID()))
+ continue;
+ if (ParseFunction(comp_unit, die))
+ ++functions_added;
}
+ // FixupTypes();
return functions_added;
}
bool SymbolFileDWARF::ParseSupportFiles(CompileUnit &comp_unit,
FileSpecList &support_files) {
ASSERT_MODULE_LOCK(this);
- DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
- if (dwarf_cu) {
- const DWARFBaseDIE cu_die = dwarf_cu->GetUnitDIEOnly();
-
- if (cu_die) {
- FileSpec cu_comp_dir = resolveCompDir(
- cu_die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr));
- const dw_offset_t stmt_list = cu_die.GetAttributeValueAsUnsigned(
- DW_AT_stmt_list, DW_INVALID_OFFSET);
- if (stmt_list != DW_INVALID_OFFSET) {
- // All file indexes in DWARF are one based and a file of index zero is
- // supposed to be the compile unit itself.
- support_files.Append(comp_unit);
- return DWARFDebugLine::ParseSupportFiles(
- comp_unit.GetModule(), get_debug_line_data(), cu_comp_dir,
- stmt_list, support_files, dwarf_cu);
- }
+ if (DWARFUnit *unit = GetDWARFCompileUnit(&comp_unit)) {
+ const dw_offset_t stmt_list = unit->GetLineTableOffset();
+ if (stmt_list != DW_INVALID_OFFSET) {
+ // All file indexes in DWARF are one based and a file of index zero is
+ // supposed to be the compile unit itself.
+ support_files.Append(comp_unit);
+ return DWARFDebugLine::ParseSupportFiles(comp_unit.GetModule(),
+ m_context.getOrLoadLineData(),
+ stmt_list, support_files, unit);
}
}
return false;
}
+FileSpec SymbolFileDWARF::GetFile(DWARFUnit &unit, size_t file_idx) {
+ if (auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(&unit)) {
+ if (CompileUnit *lldb_cu = GetCompUnitForDWARFCompUnit(*dwarf_cu))
+ return lldb_cu->GetSupportFiles().GetFileSpecAtIndex(file_idx);
+ return FileSpec();
+ }
+
+ auto &tu = llvm::cast<DWARFTypeUnit>(unit);
+ return GetTypeUnitSupportFiles(tu).GetFileSpecAtIndex(file_idx);
+}
+
+const FileSpecList &
+SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
+ static FileSpecList empty_list;
+
+ dw_offset_t offset = tu.GetLineTableOffset();
+ if (offset == DW_INVALID_OFFSET ||
+ offset == llvm::DenseMapInfo<dw_offset_t>::getEmptyKey() ||
+ offset == llvm::DenseMapInfo<dw_offset_t>::getTombstoneKey())
+ return empty_list;
+
+ // Many type units can share a line table, so parse the support file list
+ // once, and cache it based on the offset field.
+ auto iter_bool = m_type_unit_support_files.try_emplace(offset);
+ FileSpecList &list = iter_bool.first->second;
+ if (iter_bool.second) {
+ list.Append(FileSpec());
+ DWARFDebugLine::ParseSupportFiles(GetObjectFile()->GetModule(),
+ m_context.getOrLoadLineData(), offset,
+ list, &tu);
+ }
+ return list;
+}
+
bool SymbolFileDWARF::ParseIsOptimized(CompileUnit &comp_unit) {
ASSERT_MODULE_LOCK(this);
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
@@ -974,54 +851,63 @@ bool SymbolFileDWARF::ParseIsOptimized(CompileUnit &comp_unit) {
bool SymbolFileDWARF::ParseImportedModules(
const lldb_private::SymbolContext &sc,
- std::vector<lldb_private::ConstString> &imported_modules) {
+ std::vector<SourceModule> &imported_modules) {
ASSERT_MODULE_LOCK(this);
assert(sc.comp_unit);
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
- if (dwarf_cu) {
- if (ClangModulesDeclVendor::LanguageSupportsClangModules(
- sc.comp_unit->GetLanguage())) {
- UpdateExternalModuleListIfNeeded();
+ if (!dwarf_cu)
+ return false;
+ if (!ClangModulesDeclVendor::LanguageSupportsClangModules(
+ sc.comp_unit->GetLanguage()))
+ return false;
+ UpdateExternalModuleListIfNeeded();
- if (sc.comp_unit) {
- const DWARFDIE die = dwarf_cu->DIE();
+ const DWARFDIE die = dwarf_cu->DIE();
+ if (!die)
+ return false;
- if (die) {
- for (DWARFDIE child_die = die.GetFirstChild(); child_die;
- child_die = child_die.GetSibling()) {
- if (child_die.Tag() == DW_TAG_imported_declaration) {
- if (DWARFDIE module_die =
- child_die.GetReferencedDIE(DW_AT_import)) {
- if (module_die.Tag() == DW_TAG_module) {
- if (const char *name = module_die.GetAttributeValueAsString(
- DW_AT_name, nullptr)) {
- ConstString const_name(name);
- imported_modules.push_back(const_name);
- }
- }
- }
- }
- }
- }
- } else {
- for (const auto &pair : m_external_type_modules) {
- imported_modules.push_back(pair.first);
- }
+ for (DWARFDIE child_die = die.GetFirstChild(); child_die;
+ child_die = child_die.GetSibling()) {
+ if (child_die.Tag() != DW_TAG_imported_declaration)
+ continue;
+
+ DWARFDIE module_die = child_die.GetReferencedDIE(DW_AT_import);
+ if (module_die.Tag() != DW_TAG_module)
+ continue;
+
+ if (const char *name =
+ module_die.GetAttributeValueAsString(DW_AT_name, nullptr)) {
+ SourceModule module;
+ module.path.push_back(ConstString(name));
+
+ DWARFDIE parent_die = module_die;
+ while ((parent_die = parent_die.GetParent())) {
+ if (parent_die.Tag() != DW_TAG_module)
+ break;
+ if (const char *name =
+ parent_die.GetAttributeValueAsString(DW_AT_name, nullptr))
+ module.path.push_back(ConstString(name));
}
+ std::reverse(module.path.begin(), module.path.end());
+ if (const char *include_path = module_die.GetAttributeValueAsString(
+ DW_AT_LLVM_include_path, nullptr))
+ module.search_path = ConstString(include_path);
+ if (const char *sysroot = module_die.GetAttributeValueAsString(
+ DW_AT_LLVM_isysroot, nullptr))
+ module.sysroot = ConstString(sysroot);
+ imported_modules.push_back(module);
}
}
- return false;
+ return true;
}
struct ParseDWARFLineTableCallbackInfo {
LineTable *line_table;
- std::unique_ptr<LineSequence> sequence_ap;
+ std::unique_ptr<LineSequence> sequence_up;
lldb::addr_t addr_mask;
};
-//----------------------------------------------------------------------
// ParseStatementTableCallback
-//----------------------------------------------------------------------
static void ParseDWARFLineTableCallback(dw_offset_t offset,
const DWARFDebugLine::State &state,
void *userData) {
@@ -1035,26 +921,26 @@ static void ParseDWARFLineTableCallback(dw_offset_t offset,
LineTable *line_table = info->line_table;
// If this is our first time here, we need to create a sequence container.
- if (!info->sequence_ap.get()) {
- info->sequence_ap.reset(line_table->CreateLineSequenceContainer());
- assert(info->sequence_ap.get());
+ if (!info->sequence_up) {
+ info->sequence_up.reset(line_table->CreateLineSequenceContainer());
+ assert(info->sequence_up.get());
}
line_table->AppendLineEntryToSequence(
- info->sequence_ap.get(), state.address & info->addr_mask, state.line,
+ info->sequence_up.get(), state.address & info->addr_mask, state.line,
state.column, state.file, state.is_stmt, state.basic_block,
state.prologue_end, state.epilogue_begin, state.end_sequence);
if (state.end_sequence) {
// First, put the current sequence into the line table.
- line_table->InsertSequence(info->sequence_ap.get());
+ line_table->InsertSequence(info->sequence_up.get());
// Then, empty it to prepare for the next sequence.
- info->sequence_ap->Clear();
+ info->sequence_up->Clear();
}
}
}
bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
ASSERT_MODULE_LOCK(this);
- if (comp_unit.GetLineTable() != NULL)
+ if (comp_unit.GetLineTable() != nullptr)
return true;
DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
@@ -1065,10 +951,10 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_stmt_list,
DW_INVALID_OFFSET);
if (cu_line_offset != DW_INVALID_OFFSET) {
- std::unique_ptr<LineTable> line_table_ap(new LineTable(&comp_unit));
- if (line_table_ap.get()) {
+ std::unique_ptr<LineTable> line_table_up(new LineTable(&comp_unit));
+ if (line_table_up) {
ParseDWARFLineTableCallbackInfo info;
- info.line_table = line_table_ap.get();
+ info.line_table = line_table_up.get();
/*
* MIPS:
@@ -1091,9 +977,9 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
}
lldb::offset_t offset = cu_line_offset;
- DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset,
- ParseDWARFLineTableCallback,
- &info, dwarf_cu);
+ DWARFDebugLine::ParseStatementTable(
+ m_context.getOrLoadLineData(), &offset,
+ ParseDWARFLineTableCallback, &info, dwarf_cu);
SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
if (debug_map_symfile) {
// We have an object file that has a line table with addresses that
@@ -1101,9 +987,9 @@ bool SymbolFileDWARF::ParseLineTable(CompileUnit &comp_unit) {
// addresses that are relative to the .o file into addresses for
// the main executable.
comp_unit.SetLineTable(
- debug_map_symfile->LinkOSOLineTable(this, line_table_ap.get()));
+ debug_map_symfile->LinkOSOLineTable(this, line_table_up.get()));
} else {
- comp_unit.SetLineTable(line_table_ap.release());
+ comp_unit.SetLineTable(line_table_up.release());
return true;
}
}
@@ -1119,7 +1005,7 @@ SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) {
if (iter != m_debug_macros_map.end())
return iter->second;
- const DWARFDataExtractor &debug_macro_data = get_debug_macro_data();
+ const DWARFDataExtractor &debug_macro_data = m_context.getOrLoadMacroData();
if (debug_macro_data.GetByteSize() == 0)
return DebugMacrosSP();
@@ -1128,9 +1014,9 @@ SymbolFileDWARF::ParseDebugMacros(lldb::offset_t *offset) {
const DWARFDebugMacroHeader &header =
DWARFDebugMacroHeader::ParseHeader(debug_macro_data, offset);
- DWARFDebugMacroEntry::ReadMacroEntries(debug_macro_data, get_debug_str_data(),
- header.OffsetIs64Bit(), offset, this,
- debug_macros_sp);
+ DWARFDebugMacroEntry::ReadMacroEntries(
+ debug_macro_data, m_context.getOrLoadStrData(), header.OffsetIs64Bit(),
+ offset, this, debug_macros_sp);
return debug_macros_sp;
}
@@ -1171,7 +1057,7 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(
case DW_TAG_inlined_subroutine:
case DW_TAG_subprogram:
case DW_TAG_lexical_block: {
- Block *block = NULL;
+ Block *block = nullptr;
if (tag == DW_TAG_subprogram) {
// Skip any DW_TAG_subprogram DIEs that are inside of a normal or
// inlined functions. These will be parsed on their own as separate
@@ -1187,8 +1073,8 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(
block = block_sp.get();
}
DWARFRangeList ranges;
- const char *name = NULL;
- const char *mangled_name = NULL;
+ const char *name = nullptr;
+ const char *mangled_name = nullptr;
int decl_file = 0;
int decl_line = 0;
@@ -1236,21 +1122,21 @@ size_t SymbolFileDWARF::ParseBlocksRecursive(
block->FinalizeRanges();
if (tag != DW_TAG_subprogram &&
- (name != NULL || mangled_name != NULL)) {
- std::unique_ptr<Declaration> decl_ap;
+ (name != nullptr || mangled_name != nullptr)) {
+ std::unique_ptr<Declaration> decl_up;
if (decl_file != 0 || decl_line != 0 || decl_column != 0)
- decl_ap.reset(new Declaration(
+ decl_up.reset(new Declaration(
comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file),
decl_line, decl_column));
- std::unique_ptr<Declaration> call_ap;
+ std::unique_ptr<Declaration> call_up;
if (call_file != 0 || call_line != 0 || call_column != 0)
- call_ap.reset(new Declaration(
+ call_up.reset(new Declaration(
comp_unit.GetSupportFiles().GetFileSpecAtIndex(call_file),
call_line, call_column));
- block->SetInlinedFunctionInfo(name, mangled_name, decl_ap.get(),
- call_ap.get());
+ block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(),
+ call_up.get());
}
++blocks_added;
@@ -1313,7 +1199,17 @@ void SymbolFileDWARF::ParseDeclsForContext(CompilerDeclContext decl_ctx) {
ast_parser->GetDeclForUIDFromDWARF(decl);
}
-SymbolFileDWARF *SymbolFileDWARF::GetDWARFForUID(lldb::user_id_t uid) {
+user_id_t SymbolFileDWARF::GetUID(DIERef ref) {
+ if (GetDebugMapSymfile())
+ return GetID() | ref.die_offset();
+
+ return user_id_t(GetDwoNum().getValueOr(0x7fffffff)) << 32 |
+ ref.die_offset() |
+ (lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63);
+}
+
+llvm::Optional<SymbolFileDWARF::DecodedUID>
+SymbolFileDWARF::DecodeUID(lldb::user_id_t uid) {
// This method can be called without going through the symbol vendor so we
// need to lock the module.
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -1324,28 +1220,37 @@ SymbolFileDWARF *SymbolFileDWARF::GetDWARFForUID(lldb::user_id_t uid) {
// references to other DWARF objects and we must be ready to receive a
// "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF
// instance.
- SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile();
- if (debug_map)
- return debug_map->GetSymbolFileByOSOIndex(
+ if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
+ SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex(
debug_map->GetOSOIndexFromUserID(uid));
- return this;
+ return DecodedUID{
+ *dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
+ }
+ dw_offset_t die_offset = uid;
+ if (die_offset == DW_INVALID_OFFSET)
+ return llvm::None;
+
+ DIERef::Section section =
+ uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
+
+ llvm::Optional<uint32_t> dwo_num = uid >> 32 & 0x7fffffff;
+ if (*dwo_num == 0x7fffffff)
+ dwo_num = llvm::None;
+
+ return DecodedUID{*this, {dwo_num, section, die_offset}};
}
DWARFDIE
-SymbolFileDWARF::GetDIEFromUID(lldb::user_id_t uid) {
+SymbolFileDWARF::GetDIE(lldb::user_id_t uid) {
// This method can be called without going through the symbol vendor so we
// need to lock the module.
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
- // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API we
- // must make sure we use the correct DWARF file when resolving things. On
- // MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple
- // SymbolFileDWARF classes, one for each .o file. We can often end up with
- // references to other DWARF objects and we must be ready to receive a
- // "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF
- // instance.
- SymbolFileDWARF *dwarf = GetDWARFForUID(uid);
- if (dwarf)
- return dwarf->GetDIE(DIERef(uid, dwarf));
+
+ llvm::Optional<DecodedUID> decoded = DecodeUID(uid);
+
+ if (decoded)
+ return decoded->dwarf.GetDIE(decoded->ref);
+
return DWARFDIE();
}
@@ -1354,10 +1259,9 @@ CompilerDecl SymbolFileDWARF::GetDeclForUID(lldb::user_id_t type_uid) {
// need to lock the module.
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Anytime we have a lldb::user_id_t, we must get the DIE by calling
- // SymbolFileDWARF::GetDIEFromUID(). See comments inside the
- // SymbolFileDWARF::GetDIEFromUID() for details.
- DWARFDIE die = GetDIEFromUID(type_uid);
- if (die)
+ // SymbolFileDWARF::GetDIE(). See comments inside the
+ // SymbolFileDWARF::GetDIE() for details.
+ if (DWARFDIE die = GetDIE(type_uid))
return die.GetDecl();
return CompilerDecl();
}
@@ -1368,10 +1272,9 @@ SymbolFileDWARF::GetDeclContextForUID(lldb::user_id_t type_uid) {
// need to lock the module.
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Anytime we have a lldb::user_id_t, we must get the DIE by calling
- // SymbolFileDWARF::GetDIEFromUID(). See comments inside the
- // SymbolFileDWARF::GetDIEFromUID() for details.
- DWARFDIE die = GetDIEFromUID(type_uid);
- if (die)
+ // SymbolFileDWARF::GetDIE(). See comments inside the
+ // SymbolFileDWARF::GetDIE() for details.
+ if (DWARFDIE die = GetDIE(type_uid))
return die.GetDeclContext();
return CompilerDeclContext();
}
@@ -1382,10 +1285,9 @@ SymbolFileDWARF::GetDeclContextContainingUID(lldb::user_id_t type_uid) {
// need to lock the module.
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Anytime we have a lldb::user_id_t, we must get the DIE by calling
- // SymbolFileDWARF::GetDIEFromUID(). See comments inside the
- // SymbolFileDWARF::GetDIEFromUID() for details.
- DWARFDIE die = GetDIEFromUID(type_uid);
- if (die)
+ // SymbolFileDWARF::GetDIE(). See comments inside the
+ // SymbolFileDWARF::GetDIE() for details.
+ if (DWARFDIE die = GetDIE(type_uid))
return die.GetContainingDeclContext();
return CompilerDeclContext();
}
@@ -1395,10 +1297,9 @@ Type *SymbolFileDWARF::ResolveTypeUID(lldb::user_id_t type_uid) {
// need to lock the module.
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Anytime we have a lldb::user_id_t, we must get the DIE by calling
- // SymbolFileDWARF::GetDIEFromUID(). See comments inside the
- // SymbolFileDWARF::GetDIEFromUID() for details.
- DWARFDIE type_die = GetDIEFromUID(type_uid);
- if (type_die)
+ // SymbolFileDWARF::GetDIE(). See comments inside the
+ // SymbolFileDWARF::GetDIE() for details.
+ if (DWARFDIE type_die = GetDIE(type_uid))
return type_die.ResolveType();
else
return nullptr;
@@ -1408,8 +1309,7 @@ llvm::Optional<SymbolFile::ArrayInfo>
SymbolFileDWARF::GetDynamicArrayInfoForUID(
lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
- DWARFDIE type_die = GetDIEFromUID(type_uid);
- if (type_die)
+ if (DWARFDIE type_die = GetDIE(type_uid))
return DWARFASTParser::ParseChildArrayInfo(type_die, exe_ctx);
else
return llvm::None;
@@ -1454,7 +1354,7 @@ Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE &die,
}
return ResolveType(die);
}
- return NULL;
+ return nullptr;
}
// This function is used when SymbolFileDWARFDebugMap owns a bunch of
@@ -1548,15 +1448,14 @@ Type *SymbolFileDWARF::ResolveType(const DWARFDIE &die,
}
CompileUnit *
-SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu,
- uint32_t cu_idx) {
+SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu) {
// Check if the symbol vendor already knows about this compile unit?
- if (dwarf_cu->GetUserData() == NULL) {
+ if (dwarf_cu.GetUserData() == nullptr) {
// The symbol vendor doesn't know about this compile unit, we need to parse
// and add it to the symbol vendor object.
- return ParseCompileUnit(dwarf_cu, cu_idx).get();
+ return ParseCompileUnit(dwarf_cu).get();
}
- return (CompileUnit *)dwarf_cu->GetUserData();
+ return (CompileUnit *)dwarf_cu.GetUserData();
}
size_t SymbolFileDWARF::GetObjCMethodDIEOffsets(ConstString class_name,
@@ -1569,12 +1468,13 @@ size_t SymbolFileDWARF::GetObjCMethodDIEOffsets(ConstString class_name,
bool SymbolFileDWARF::GetFunction(const DWARFDIE &die, SymbolContext &sc) {
sc.Clear(false);
- if (die) {
+ if (die && llvm::isa<DWARFCompileUnit>(die.GetCU())) {
// Check if the symbol vendor already knows about this compile unit?
- sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX);
+ sc.comp_unit =
+ GetCompUnitForDWARFCompUnit(llvm::cast<DWARFCompileUnit>(*die.GetCU()));
sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get();
- if (sc.function == NULL)
+ if (sc.function == nullptr)
sc.function = ParseFunction(*sc.comp_unit, die);
if (sc.function) {
@@ -1597,6 +1497,14 @@ lldb::ModuleSP SymbolFileDWARF::GetDWOModule(ConstString name) {
DWARFDIE
SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
+ if (die_ref.dwo_num()) {
+ return DebugInfo()
+ ->GetUnitAtIndex(*die_ref.dwo_num())
+ ->GetDwoSymbolFile()
+ ->GetDIE(die_ref);
+ }
+
+
DWARFDebugInfo *debug_info = DebugInfo();
if (debug_info)
return debug_info->GetDIE(die_ref);
@@ -1606,24 +1514,29 @@ SymbolFileDWARF::GetDIE(const DIERef &die_ref) {
std::unique_ptr<SymbolFileDWARFDwo>
SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
- DWARFUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die) {
+ DWARFUnit &unit, const DWARFDebugInfoEntry &cu_die) {
// If we are using a dSYM file, we never want the standard DWO files since
// the -gmodules support uses the same DWO machanism to specify full debug
// info files for modules.
if (GetDebugMapSymfile())
return nullptr;
- const char *dwo_name = cu_die.GetAttributeValueAsString(
- this, &dwarf_cu, DW_AT_GNU_dwo_name, nullptr);
+ DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(&unit);
+ // Only compile units can be split into two parts.
+ if (!dwarf_cu)
+ return nullptr;
+
+ const char *dwo_name =
+ cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_GNU_dwo_name, nullptr);
if (!dwo_name)
return nullptr;
SymbolFileDWARFDwp *dwp_symfile = GetDwpSymbolFile();
if (dwp_symfile) {
- uint64_t dwo_id = cu_die.GetAttributeValueAsUnsigned(this, &dwarf_cu,
- DW_AT_GNU_dwo_id, 0);
+ uint64_t dwo_id =
+ cu_die.GetAttributeValueAsUnsigned(dwarf_cu, DW_AT_GNU_dwo_id, 0);
std::unique_ptr<SymbolFileDWARFDwo> dwo_symfile =
- dwp_symfile->GetSymbolFileForDwoId(&dwarf_cu, dwo_id);
+ dwp_symfile->GetSymbolFileForDwoId(*dwarf_cu, dwo_id);
if (dwo_symfile)
return dwo_symfile;
}
@@ -1631,8 +1544,8 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
FileSpec dwo_file(dwo_name);
FileSystem::Instance().Resolve(dwo_file);
if (dwo_file.IsRelative()) {
- const char *comp_dir = cu_die.GetAttributeValueAsString(
- this, &dwarf_cu, DW_AT_comp_dir, nullptr);
+ const char *comp_dir =
+ cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir, nullptr);
if (!comp_dir)
return nullptr;
@@ -1654,7 +1567,7 @@ SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
if (dwo_obj_file == nullptr)
return nullptr;
- return llvm::make_unique<SymbolFileDWARFDwo>(dwo_obj_file, &dwarf_cu);
+ return llvm::make_unique<SymbolFileDWARFDwo>(dwo_obj_file, *dwarf_cu);
}
void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
@@ -1666,7 +1579,7 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
- DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+ DWARFUnit *dwarf_cu = debug_info->GetUnitAtIndex(cu_idx);
const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly();
if (die && !die.HasChildren()) {
@@ -1708,16 +1621,14 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
// printed. However, as one can notice in this case we don't
// actually need to try to load the already loaded module
// (corresponding to .dwo) so we simply skip it.
- if (m_obj_file->GetFileSpec()
- .GetFileNameExtension()
- .GetStringRef() == ".dwo" &&
+ if (m_obj_file->GetFileSpec().GetFileNameExtension() == ".dwo" &&
llvm::StringRef(m_obj_file->GetFileSpec().GetPath())
.endswith(dwo_module_spec.GetFileSpec().GetPath())) {
continue;
}
Status error = ModuleList::GetSharedModule(
- dwo_module_spec, module_sp, NULL, NULL, NULL);
+ dwo_module_spec, module_sp, nullptr, nullptr, nullptr);
if (!module_sp) {
GetObjectFile()->GetModule()->ReportWarning(
"0x%8.8x: unable to locate module needed for external types: "
@@ -1737,8 +1648,8 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() {
}
SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
- if (!m_global_aranges_ap) {
- m_global_aranges_ap.reset(new GlobalVariableMap());
+ if (!m_global_aranges_up) {
+ m_global_aranges_up.reset(new GlobalVariableMap());
ModuleSP module_sp = GetObjectFile()->GetModule();
if (module_sp) {
@@ -1763,8 +1674,9 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
location_result.GetScalar().ULongLong();
lldb::addr_t byte_size = 1;
if (var_sp->GetType())
- byte_size = var_sp->GetType()->GetByteSize();
- m_global_aranges_ap->Append(GlobalVariableMap::Entry(
+ byte_size =
+ var_sp->GetType()->GetByteSize().getValueOr(0);
+ m_global_aranges_up->Append(GlobalVariableMap::Entry(
file_addr, byte_size, var_sp.get()));
}
}
@@ -1774,9 +1686,9 @@ SymbolFileDWARF::GlobalVariableMap &SymbolFileDWARF::GetGlobalAranges() {
}
}
}
- m_global_aranges_ap->Sort();
+ m_global_aranges_up->Sort();
}
- return *m_global_aranges_ap;
+ return *m_global_aranges_up;
}
uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
@@ -1798,8 +1710,17 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
DWARFDebugInfo *debug_info = DebugInfo();
if (debug_info) {
- const dw_offset_t cu_offset =
- debug_info->GetCompileUnitAranges().FindAddress(file_vm_addr);
+ llvm::Expected<DWARFDebugAranges &> aranges =
+ debug_info->GetCompileUnitAranges();
+ if (!aranges) {
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ LLDB_LOG_ERROR(log, aranges.takeError(),
+ "SymbolFileDWARF::ResolveSymbolContext failed to get cu "
+ "aranges. {0}");
+ return 0;
+ }
+
+ const dw_offset_t cu_offset = aranges->FindAddress(file_vm_addr);
if (cu_offset == DW_INVALID_OFFSET) {
// Global variables are not in the compile unit address ranges. The
// only way to currently find global variables is to iterate over the
@@ -1822,10 +1743,10 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
}
} else {
uint32_t cu_idx = DW_INVALID_INDEX;
- DWARFUnit *dwarf_cu =
- debug_info->GetCompileUnit(cu_offset, &cu_idx);
- if (dwarf_cu) {
- sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
+ if (auto *dwarf_cu = llvm::dyn_cast_or_null<DWARFCompileUnit>(
+ debug_info->GetUnitAtOffset(DIERef::Section::DebugInfo,
+ cu_offset, &cu_idx))) {
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
if (sc.comp_unit) {
resolved |= eSymbolContextCompUnit;
@@ -1837,7 +1758,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
if (function_die) {
sc.function =
sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
- if (sc.function == NULL)
+ if (sc.function == nullptr)
sc.function = ParseFunction(*sc.comp_unit, function_die);
if (sc.function && (resolve_scope & eSymbolContextBlock))
@@ -1852,7 +1773,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
force_check_line_table = true;
}
- if (sc.function != NULL) {
+ if (sc.function != nullptr) {
resolved |= eSymbolContextFunction;
if (resolve_scope & eSymbolContextBlock) {
@@ -1871,7 +1792,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
if ((resolve_scope & eSymbolContextLineEntry) ||
force_check_line_table) {
LineTable *line_table = sc.comp_unit->GetLineTable();
- if (line_table != NULL) {
+ if (line_table != nullptr) {
// And address that makes it into this function should be in
// terms of this debug file if there is no debug map, or it
// will be an address in the .o file which needs to be fixed up
@@ -1895,7 +1816,7 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const Address &so_addr,
// only happen when there aren't other functions from other
// compile units in these gaps. This helps keep the size of the
// aranges down.
- sc.comp_unit = NULL;
+ sc.comp_unit = nullptr;
resolved &= ~eSymbolContextCompUnit;
}
} else {
@@ -1918,110 +1839,100 @@ uint32_t SymbolFileDWARF::ResolveSymbolContext(const FileSpec &file_spec,
SymbolContextList &sc_list) {
const uint32_t prev_size = sc_list.GetSize();
if (resolve_scope & eSymbolContextCompUnit) {
- DWARFDebugInfo *debug_info = DebugInfo();
- if (debug_info) {
- uint32_t cu_idx;
- DWARFUnit *dwarf_cu = NULL;
-
- for (cu_idx = 0;
- (dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL;
- ++cu_idx) {
- CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
- const bool full_match = (bool)file_spec.GetDirectory();
- bool file_spec_matches_cu_file_spec =
- dc_cu != NULL && FileSpec::Equal(file_spec, *dc_cu, full_match);
- if (check_inlines || file_spec_matches_cu_file_spec) {
- SymbolContext sc(m_obj_file->GetModule());
- sc.comp_unit = GetCompUnitForDWARFCompUnit(dwarf_cu, cu_idx);
- if (sc.comp_unit) {
- uint32_t file_idx = UINT32_MAX;
+ for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus;
+ ++cu_idx) {
+ CompileUnit *dc_cu = ParseCompileUnitAtIndex(cu_idx).get();
+ if (!dc_cu)
+ continue;
+
+ const bool full_match = (bool)file_spec.GetDirectory();
+ bool file_spec_matches_cu_file_spec =
+ FileSpec::Equal(file_spec, *dc_cu, full_match);
+ if (check_inlines || file_spec_matches_cu_file_spec) {
+ SymbolContext sc(m_obj_file->GetModule());
+ sc.comp_unit = dc_cu;
+ uint32_t file_idx = UINT32_MAX;
+
+ // If we are looking for inline functions only and we don't find it
+ // in the support files, we are done.
+ if (check_inlines) {
+ file_idx =
+ sc.comp_unit->GetSupportFiles().FindFileIndex(1, file_spec, true);
+ if (file_idx == UINT32_MAX)
+ continue;
+ }
- // If we are looking for inline functions only and we don't find it
- // in the support files, we are done.
- if (check_inlines) {
+ if (line != 0) {
+ LineTable *line_table = sc.comp_unit->GetLineTable();
+
+ if (line_table != nullptr && line != 0) {
+ // We will have already looked up the file index if we are
+ // searching for inline entries.
+ if (!check_inlines)
file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex(
1, file_spec, true);
- if (file_idx == UINT32_MAX)
- continue;
- }
-
- if (line != 0) {
- LineTable *line_table = sc.comp_unit->GetLineTable();
- if (line_table != NULL && line != 0) {
- // We will have already looked up the file index if we are
- // searching for inline entries.
- if (!check_inlines)
- file_idx = sc.comp_unit->GetSupportFiles().FindFileIndex(
- 1, file_spec, true);
-
- if (file_idx != UINT32_MAX) {
- uint32_t found_line;
- uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex(
- 0, file_idx, line, false, &sc.line_entry);
- found_line = sc.line_entry.line;
-
- while (line_idx != UINT32_MAX) {
- sc.function = NULL;
- sc.block = NULL;
- if (resolve_scope &
- (eSymbolContextFunction | eSymbolContextBlock)) {
- const lldb::addr_t file_vm_addr =
- sc.line_entry.range.GetBaseAddress().GetFileAddress();
- if (file_vm_addr != LLDB_INVALID_ADDRESS) {
- DWARFDIE function_die =
- dwarf_cu->LookupAddress(file_vm_addr);
- DWARFDIE block_die;
- if (function_die) {
- sc.function =
- sc.comp_unit
- ->FindFunctionByUID(function_die.GetID())
- .get();
- if (sc.function == NULL)
- sc.function =
- ParseFunction(*sc.comp_unit, function_die);
-
- if (sc.function &&
- (resolve_scope & eSymbolContextBlock))
- block_die =
- function_die.LookupDeepestBlock(file_vm_addr);
- }
+ if (file_idx != UINT32_MAX) {
+ uint32_t found_line;
+ uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex(
+ 0, file_idx, line, false, &sc.line_entry);
+ found_line = sc.line_entry.line;
+
+ while (line_idx != UINT32_MAX) {
+ sc.function = nullptr;
+ sc.block = nullptr;
+ if (resolve_scope &
+ (eSymbolContextFunction | eSymbolContextBlock)) {
+ const lldb::addr_t file_vm_addr =
+ sc.line_entry.range.GetBaseAddress().GetFileAddress();
+ if (file_vm_addr != LLDB_INVALID_ADDRESS) {
+ DWARFDIE function_die =
+ GetDWARFCompileUnit(dc_cu)->LookupAddress(file_vm_addr);
+ DWARFDIE block_die;
+ if (function_die) {
+ sc.function =
+ sc.comp_unit->FindFunctionByUID(function_die.GetID())
+ .get();
+ if (sc.function == nullptr)
+ sc.function =
+ ParseFunction(*sc.comp_unit, function_die);
+
+ if (sc.function && (resolve_scope & eSymbolContextBlock))
+ block_die =
+ function_die.LookupDeepestBlock(file_vm_addr);
+ }
- if (sc.function != NULL) {
- Block &block = sc.function->GetBlock(true);
+ if (sc.function != nullptr) {
+ Block &block = sc.function->GetBlock(true);
- if (block_die)
- sc.block = block.FindBlockByID(block_die.GetID());
- else if (function_die)
- sc.block =
- block.FindBlockByID(function_die.GetID());
- }
- }
+ if (block_die)
+ sc.block = block.FindBlockByID(block_die.GetID());
+ else if (function_die)
+ sc.block = block.FindBlockByID(function_die.GetID());
}
-
- sc_list.Append(sc);
- line_idx = line_table->FindLineEntryIndexByFileIndex(
- line_idx + 1, file_idx, found_line, true,
- &sc.line_entry);
}
}
- } else if (file_spec_matches_cu_file_spec && !check_inlines) {
- // only append the context if we aren't looking for inline call
- // sites by file and line and if the file spec matches that of
- // the compile unit
+
sc_list.Append(sc);
+ line_idx = line_table->FindLineEntryIndexByFileIndex(
+ line_idx + 1, file_idx, found_line, true, &sc.line_entry);
}
- } else if (file_spec_matches_cu_file_spec && !check_inlines) {
- // only append the context if we aren't looking for inline call
- // sites by file and line and if the file spec matches that of
- // the compile unit
- sc_list.Append(sc);
}
-
- if (!check_inlines)
- break;
+ } else if (file_spec_matches_cu_file_spec && !check_inlines) {
+ // only append the context if we aren't looking for inline call
+ // sites by file and line and if the file spec matches that of
+ // the compile unit
+ sc_list.Append(sc);
}
+ } else if (file_spec_matches_cu_file_spec && !check_inlines) {
+ // only append the context if we aren't looking for inline call
+ // sites by file and line and if the file spec matches that of
+ // the compile unit
+ sc_list.Append(sc);
}
+
+ if (!check_inlines)
+ break;
}
}
}
@@ -2066,7 +1977,7 @@ bool SymbolFileDWARF::DeclContextMatchesThisSymbolFile(
}
uint32_t SymbolFileDWARF::FindGlobalVariables(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -2082,7 +1993,7 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
return 0;
DWARFDebugInfo *info = DebugInfo();
- if (info == NULL)
+ if (info == nullptr)
return 0;
// Remember how many variables are in the list before we search.
@@ -2090,6 +2001,7 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
llvm::StringRef basename;
llvm::StringRef context;
+ bool name_is_mangled = (bool)Mangled(name);
if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(),
context, basename))
@@ -2122,7 +2034,10 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
break;
case DW_TAG_variable: {
- sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX);
+ auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
+ if (!dwarf_cu)
+ continue;
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
if (parent_decl_ctx) {
DWARFASTParser *dwarf_ast = die.GetDWARFParser();
@@ -2139,7 +2054,8 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
&variables);
while (pruned_idx < variables.GetSize()) {
VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
- if (var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
+ if (name_is_mangled ||
+ var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
++pruned_idx;
else
variables.RemoveVariableAtIndex(pruned_idx);
@@ -2150,8 +2066,7 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(
} break;
}
} else {
- m_index->ReportInvalidDIEOffset(die_ref.die_offset,
- name.GetStringRef());
+ m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
}
}
}
@@ -2183,7 +2098,7 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
}
DWARFDebugInfo *info = DebugInfo();
- if (info == NULL)
+ if (info == nullptr)
return 0;
// Remember how many variables are in the list before we search.
@@ -2203,14 +2118,18 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression &regex,
DWARFDIE die = GetDIE(die_ref);
if (die) {
- sc.comp_unit = GetCompUnitForDWARFCompUnit(die.GetCU(), UINT32_MAX);
+ DWARFCompileUnit *dwarf_cu =
+ llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
+ if (!dwarf_cu)
+ continue;
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, &variables);
if (variables.GetSize() - original_size >= max_matches)
break;
} else
- m_index->ReportInvalidDIEOffset(die_ref.die_offset, regex.GetText());
+ m_index->ReportInvalidDIERef(die_ref, regex.GetText());
}
}
@@ -2236,7 +2155,7 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
if (die.Tag() == DW_TAG_inlined_subroutine) {
inlined_die = die;
- while (1) {
+ while (true) {
die = die.GetParent();
if (die) {
@@ -2253,12 +2172,12 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE &orig_die,
if (inlined_die) {
Block &function_block = sc.function->GetBlock(true);
sc.block = function_block.FindBlockByID(inlined_die.GetID());
- if (sc.block == NULL)
+ if (sc.block == nullptr)
sc.block = function_block.FindBlockByID(inlined_die.GetOffset());
- if (sc.block == NULL || !sc.block->GetStartAddress(addr))
+ if (sc.block == nullptr || !sc.block->GetStartAddress(addr))
addr.Clear();
} else {
- sc.block = NULL;
+ sc.block = nullptr;
addr = sc.function->GetAddressRange().GetBaseAddress();
}
@@ -2285,14 +2204,14 @@ bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext *decl_ctx,
CompilerDeclContext actual_decl_ctx =
dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
if (actual_decl_ctx)
- return actual_decl_ctx == *decl_ctx;
+ return decl_ctx->IsContainedInLookup(actual_decl_ctx);
}
}
return false;
}
uint32_t SymbolFileDWARF::FindFunctions(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
SymbolContextList &sc_list) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@@ -2328,10 +2247,6 @@ uint32_t SymbolFileDWARF::FindFunctions(
const uint32_t original_size = sc_list.GetSize();
- DWARFDebugInfo *info = DebugInfo();
- if (info == NULL)
- return 0;
-
llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
DIEArray offsets;
CompilerDeclContext empty_decl_ctx;
@@ -2339,7 +2254,7 @@ uint32_t SymbolFileDWARF::FindFunctions(
parent_decl_ctx = &empty_decl_ctx;
std::vector<DWARFDIE> dies;
- m_index->GetFunctions(name, *info, *parent_decl_ctx, name_type_mask, dies);
+ m_index->GetFunctions(name, *this, *parent_decl_ctx, name_type_mask, dies);
for (const DWARFDIE &die: dies) {
if (resolved_dies.insert(die.GetDIE()).second)
ResolveFunction(die, include_inlines, sc_list);
@@ -2394,7 +2309,7 @@ uint32_t SymbolFileDWARF::FindFunctions(const RegularExpression &regex,
for (DIERef ref : offsets) {
DWARFDIE die = info->GetDIE(ref);
if (!die) {
- m_index->ReportInvalidDIEOffset(ref.die_offset, regex.GetText());
+ m_index->ReportInvalidDIERef(ref, regex.GetText());
continue;
}
if (resolved_dies.insert(die.GetDIE()).second)
@@ -2411,10 +2326,10 @@ void SymbolFileDWARF::GetMangledNamesForFunction(
DWARFDebugInfo *info = DebugInfo();
uint32_t num_comp_units = 0;
if (info)
- num_comp_units = info->GetNumCompileUnits();
+ num_comp_units = info->GetNumUnits();
for (uint32_t i = 0; i < num_comp_units; i++) {
- DWARFUnit *cu = info->GetCompileUnitAtIndex(i);
+ DWARFUnit *cu = info->GetUnitAtIndex(i);
if (cu == nullptr)
continue;
@@ -2423,21 +2338,15 @@ void SymbolFileDWARF::GetMangledNamesForFunction(
dwo->GetMangledNamesForFunction(scope_qualified_name, mangled_names);
}
- NameToOffsetMap::iterator iter =
- m_function_scope_qualified_name_map.find(scope_qualified_name);
- if (iter == m_function_scope_qualified_name_map.end())
- return;
-
- DIERefSetSP set_sp = (*iter).second;
- std::set<DIERef>::iterator set_iter;
- for (set_iter = set_sp->begin(); set_iter != set_sp->end(); set_iter++) {
- DWARFDIE die = DebugInfo()->GetDIE(*set_iter);
+ for (lldb::user_id_t uid :
+ m_function_scope_qualified_name_map.lookup(scope_qualified_name)) {
+ DWARFDIE die = GetDIE(uid);
mangled_names.push_back(ConstString(die.GetMangledName()));
}
}
uint32_t SymbolFileDWARF::FindTypes(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -2452,7 +2361,7 @@ uint32_t SymbolFileDWARF::FindTypes(
searched_symbol_files.insert(this);
DWARFDebugInfo *info = DebugInfo();
- if (info == NULL)
+ if (info == nullptr)
return 0;
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -2497,8 +2406,7 @@ uint32_t SymbolFileDWARF::FindTypes(
break;
}
} else {
- m_index->ReportInvalidDIEOffset(die_ref.die_offset,
- name.GetStringRef());
+ m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
}
}
const uint32_t num_matches = types.GetSize() - initial_types_size;
@@ -2576,8 +2484,7 @@ size_t SymbolFileDWARF::FindTypes(const std::vector<CompilerContext> &context,
++num_matches;
}
} else {
- m_index->ReportInvalidDIEOffset(die_ref.die_offset,
- name.GetStringRef());
+ m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
}
}
return num_matches;
@@ -2586,7 +2493,7 @@ size_t SymbolFileDWARF::FindTypes(const std::vector<CompilerContext> &context,
}
CompilerDeclContext
-SymbolFileDWARF::FindNamespace(const ConstString &name,
+SymbolFileDWARF::FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
@@ -2622,8 +2529,7 @@ SymbolFileDWARF::FindNamespace(const ConstString &name,
break;
}
} else {
- m_index->ReportInvalidDIEOffset(die_ref.die_offset,
- name.GetStringRef());
+ m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
}
}
}
@@ -2646,10 +2552,14 @@ TypeSP SymbolFileDWARF::GetTypeForDIE(const DWARFDIE &die,
TypeSP type_sp;
if (die) {
Type *type_ptr = GetDIEToType().lookup(die.GetDIE());
- if (type_ptr == NULL) {
- CompileUnit *lldb_cu = GetCompUnitForDWARFCompUnit(die.GetCU());
- assert(lldb_cu);
- SymbolContext sc(lldb_cu);
+ if (type_ptr == nullptr) {
+ SymbolContextScope *scope;
+ if (auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU()))
+ scope = GetCompUnitForDWARFCompUnit(*dwarf_cu);
+ else
+ scope = GetObjectFile()->GetModule().get();
+ assert(scope);
+ SymbolContext sc(scope);
const DWARFDebugInfoEntry *parent_die = die.GetParent().GetDIE();
while (parent_die != nullptr) {
if (parent_die->Tag() == DW_TAG_subprogram)
@@ -2661,7 +2571,7 @@ TypeSP SymbolFileDWARF::GetTypeForDIE(const DWARFDIE &die,
!GetFunction(DWARFDIE(die.GetCU(), parent_die), sc))
sc = sc_backup;
- type_sp = ParseType(sc, die, NULL);
+ type_sp = ParseType(sc, die, nullptr);
} else if (type_ptr != DIE_IS_BEING_PARSED) {
// Grab the existing type from the master types lists
type_sp = type_ptr->shared_from_this();
@@ -2723,8 +2633,8 @@ SymbolFileDWARF::GetDeclContextDIEContainingDIE(const DWARFDIE &orig_die) {
}
Symbol *
-SymbolFileDWARF::GetObjCClassSymbol(const ConstString &objc_class_name) {
- Symbol *objc_class_symbol = NULL;
+SymbolFileDWARF::GetObjCClassSymbol(ConstString objc_class_name) {
+ Symbol *objc_class_symbol = nullptr;
if (m_obj_file) {
Symtab *symtab = m_obj_file->GetSymtab();
if (symtab) {
@@ -2753,7 +2663,7 @@ bool SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type(
DWARFDebugInfo *debug_info = DebugInfo();
const uint32_t num_compile_units = GetNumCompileUnits();
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
- DWARFUnit *dwarf_cu = debug_info->GetCompileUnitAtIndex(cu_idx);
+ DWARFUnit *dwarf_cu = debug_info->GetUnitAtIndex(cu_idx);
if (dwarf_cu != cu &&
dwarf_cu->Supports_DW_AT_APPLE_objc_complete_type()) {
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
@@ -2771,7 +2681,7 @@ bool SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type(
// This function can be used when a DIE is found that is a forward declaration
// DIE and we want to try and find a type that has the complete definition.
TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
- const DWARFDIE &die, const ConstString &type_name,
+ const DWARFDIE &die, ConstString type_name,
bool must_be_implementation) {
TypeSP type_sp;
@@ -2829,15 +2739,13 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
}
}
} else {
- m_index->ReportInvalidDIEOffset(die_ref.die_offset,
- type_name.GetStringRef());
+ m_index->ReportInvalidDIERef(die_ref, type_name.GetStringRef());
}
}
}
return type_sp;
}
-//----------------------------------------------------------------------
// This function helps to ensure that the declaration contexts match for two
// different DIEs. Often times debug information will refer to a forward
// declaration of a type (the equivalent of "struct my_struct;". There will
@@ -2847,14 +2755,13 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
// type was in the same declaration context as the original DIE. This function
// can efficiently compare two DIEs and will return true when the declaration
// context matches, and false when they don't.
-//----------------------------------------------------------------------
bool SymbolFileDWARF::DIEDeclContextsMatch(const DWARFDIE &die1,
const DWARFDIE &die2) {
if (die1 == die2)
return true;
- DWARFDIECollection decl_ctx_1;
- DWARFDIECollection decl_ctx_2;
+ std::vector<DWARFDIE> decl_ctx_1;
+ std::vector<DWARFDIE> decl_ctx_2;
// The declaration DIE stack is a stack of the declaration context DIEs all
// the way back to the compile unit. If a type "T" is declared inside a class
// "B", and class "B" is declared inside a class "A" and class "A" is in a
@@ -2870,11 +2777,11 @@ bool SymbolFileDWARF::DIEDeclContextsMatch(const DWARFDIE &die1,
// back to the compiler unit.
// First lets grab the decl contexts for both DIEs
- die1.GetDeclContextDIEs(decl_ctx_1);
- die2.GetDeclContextDIEs(decl_ctx_2);
+ decl_ctx_1 = die1.GetDeclContextDIEs();
+ decl_ctx_2 = die2.GetDeclContextDIEs();
// Make sure the context arrays have the same size, otherwise we are done
- const size_t count1 = decl_ctx_1.Size();
- const size_t count2 = decl_ctx_2.Size();
+ const size_t count1 = decl_ctx_1.size();
+ const size_t count2 = decl_ctx_2.size();
if (count1 != count2)
return false;
@@ -2884,18 +2791,18 @@ bool SymbolFileDWARF::DIEDeclContextsMatch(const DWARFDIE &die1,
DWARFDIE decl_ctx_die2;
size_t i;
for (i = 0; i < count1; i++) {
- decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex(i);
- decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex(i);
+ decl_ctx_die1 = decl_ctx_1[i];
+ decl_ctx_die2 = decl_ctx_2[i];
if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag())
return false;
}
-#if defined LLDB_CONFIGURATION_DEBUG
+#ifndef NDEBUG
// Make sure the top item in the decl context die array is always
// DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then
// something went wrong in the DWARFDIE::GetDeclContextDIEs()
// function.
- dw_tag_t cu_tag = decl_ctx_1.GetDIEAtIndex(count1 - 1).Tag();
+ dw_tag_t cu_tag = decl_ctx_1[count1 - 1].Tag();
UNUSED_IF_ASSERT_DISABLED(cu_tag);
assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit);
@@ -2903,8 +2810,8 @@ bool SymbolFileDWARF::DIEDeclContextsMatch(const DWARFDIE &die1,
// Always skip the compile unit when comparing by only iterating up to "count
// - 1". Here we compare the names as we go.
for (i = 0; i < count1 - 1; i++) {
- decl_ctx_die1 = decl_ctx_1.GetDIEAtIndex(i);
- decl_ctx_die2 = decl_ctx_2.GetDIEAtIndex(i);
+ decl_ctx_die1 = decl_ctx_1[i];
+ decl_ctx_die2 = decl_ctx_2[i];
const char *name1 = decl_ctx_die1.GetName();
const char *name2 = decl_ctx_die2.GetName();
// If the string was from a DW_FORM_strp, then the pointer will often be
@@ -3039,8 +2946,7 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
}
}
} else {
- m_index->ReportInvalidDIEOffset(die_ref.die_offset,
- type_name.GetStringRef());
+ m_index->ReportInvalidDIERef(die_ref, type_name.GetStringRef());
}
}
}
@@ -3051,42 +2957,32 @@ TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
TypeSP SymbolFileDWARF::ParseType(const SymbolContext &sc, const DWARFDIE &die,
bool *type_is_new_ptr) {
- TypeSP type_sp;
+ if (!die)
+ return {};
- if (die) {
- TypeSystem *type_system =
- GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
+ TypeSystem *type_system =
+ GetTypeSystemForLanguage(die.GetCU()->GetLanguageType());
+ if (!type_system)
+ return {};
- if (type_system) {
- DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
- if (dwarf_ast) {
- Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
- type_sp = dwarf_ast->ParseTypeFromDWARF(sc, die, log, type_is_new_ptr);
- if (type_sp) {
- TypeList *type_list = GetTypeList();
- if (type_list)
- type_list->Insert(type_sp);
-
- if (die.Tag() == DW_TAG_subprogram) {
- DIERef die_ref = die.GetDIERef();
- std::string scope_qualified_name(GetDeclContextForUID(die.GetID())
- .GetScopeQualifiedName()
- .AsCString(""));
- if (scope_qualified_name.size()) {
- NameToOffsetMap::iterator iter =
- m_function_scope_qualified_name_map.find(
- scope_qualified_name);
- if (iter != m_function_scope_qualified_name_map.end())
- (*iter).second->insert(die_ref);
- else {
- DIERefSetSP new_set(new std::set<DIERef>);
- new_set->insert(die_ref);
- m_function_scope_qualified_name_map.emplace(
- std::make_pair(scope_qualified_name, new_set));
- }
- }
- }
- }
+ DWARFASTParser *dwarf_ast = type_system->GetDWARFParser();
+ if (!dwarf_ast)
+ return {};
+
+ Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
+ TypeSP type_sp = dwarf_ast->ParseTypeFromDWARF(sc, die, log, type_is_new_ptr);
+ if (type_sp) {
+ TypeList *type_list = GetTypeList();
+ if (type_list)
+ type_list->Insert(type_sp);
+
+ if (die.Tag() == DW_TAG_subprogram) {
+ std::string scope_qualified_name(GetDeclContextForUID(die.GetID())
+ .GetScopeQualifiedName()
+ .AsCString(""));
+ if (scope_qualified_name.size()) {
+ m_function_scope_qualified_name_map[scope_qualified_name].insert(
+ die.GetID());
}
}
}
@@ -3161,13 +3057,13 @@ size_t SymbolFileDWARF::ParseTypes(CompileUnit &comp_unit) {
size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
ASSERT_MODULE_LOCK(this);
- if (sc.comp_unit != NULL) {
+ if (sc.comp_unit != nullptr) {
DWARFDebugInfo *info = DebugInfo();
- if (info == NULL)
+ if (info == nullptr)
return 0;
if (sc.function) {
- DWARFDIE function_die = info->GetDIE(DIERef(sc.function->GetID(), this));
+ DWARFDIE function_die = GetDIE(sc.function->GetID());
const dw_addr_t func_lo_pc = function_die.GetAttributeValueAsAddress(
DW_AT_low_pc, LLDB_INVALID_ADDRESS);
@@ -3180,20 +3076,21 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
return num_variables;
}
} else if (sc.comp_unit) {
- DWARFUnit *dwarf_cu = info->GetCompileUnit(sc.comp_unit->GetID());
+ DWARFUnit *dwarf_cu = info->GetUnitAtIndex(sc.comp_unit->GetID());
- if (dwarf_cu == NULL)
+ if (dwarf_cu == nullptr)
return 0;
uint32_t vars_added = 0;
VariableListSP variables(sc.comp_unit->GetVariableList(false));
- if (variables.get() == NULL) {
- variables.reset(new VariableList());
+ if (variables.get() == nullptr) {
+ variables = std::make_shared<VariableList>();
sc.comp_unit->SetVariableList(variables);
DIEArray die_offsets;
- m_index->GetGlobalVariables(*dwarf_cu, die_offsets);
+ m_index->GetGlobalVariables(dwarf_cu->GetNonSkeletonUnit(),
+ die_offsets);
const size_t num_matches = die_offsets.size();
if (num_matches) {
for (size_t i = 0; i < num_matches; ++i) {
@@ -3207,7 +3104,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
++vars_added;
}
} else
- m_index->ReportInvalidDIEOffset(die_ref.die_offset, "");
+ m_index->ReportInvalidDIERef(die_ref, "");
}
}
}
@@ -3240,12 +3137,12 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
const size_t num_attributes = die.GetAttributes(attributes);
DWARFDIE spec_die;
if (num_attributes > 0) {
- const char *name = NULL;
- const char *mangled = NULL;
+ const char *name = nullptr;
+ const char *mangled = nullptr;
Declaration decl;
uint32_t i;
DWARFFormValue type_die_form;
- DWARFExpression location(die.GetCU());
+ DWARFExpression location;
bool is_external = false;
bool is_artificial = false;
bool location_is_const_value_data = false;
@@ -3296,18 +3193,16 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
uint32_t block_offset =
form_value.BlockData() - debug_info_data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- location.CopyOpcodeData(module, debug_info_data, block_offset,
- block_length);
+ location = DWARFExpression(module, debug_info_data, die.GetCU(),
+ block_offset, block_length);
} else if (DWARFFormValue::IsDataForm(form_value.Form())) {
// Retrieve the value as a data expression.
- DWARFFormValue::FixedFormSizes fixed_form_sizes =
- DWARFFormValue::GetFixedFormSizesForAddressSize(
- attributes.CompileUnitAtIndex(i)->GetAddressByteSize(),
- attributes.CompileUnitAtIndex(i)->IsDWARF64());
uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
- uint32_t data_length =
- fixed_form_sizes.GetSize(form_value.Form());
- if (data_length == 0) {
+ if (auto data_length = form_value.GetFixedSize())
+ location =
+ DWARFExpression(module, debug_info_data, die.GetCU(),
+ data_offset, *data_length);
+ else {
const uint8_t *data_pointer = form_value.BlockData();
if (data_pointer) {
form_value.Unsigned();
@@ -3316,29 +3211,23 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
// create the variable
const_value = form_value;
}
- } else
- location.CopyOpcodeData(module, debug_info_data, data_offset,
- data_length);
+ }
} else {
// Retrieve the value as a string expression.
if (form_value.Form() == DW_FORM_strp) {
- DWARFFormValue::FixedFormSizes fixed_form_sizes =
- DWARFFormValue::GetFixedFormSizesForAddressSize(
- attributes.CompileUnitAtIndex(i)
- ->GetAddressByteSize(),
- attributes.CompileUnitAtIndex(i)->IsDWARF64());
uint32_t data_offset = attributes.DIEOffsetAtIndex(i);
- uint32_t data_length =
- fixed_form_sizes.GetSize(form_value.Form());
- location.CopyOpcodeData(module, debug_info_data, data_offset,
- data_length);
+ if (auto data_length = form_value.GetFixedSize())
+ location =
+ DWARFExpression(module, debug_info_data, die.GetCU(),
+ data_offset, *data_length);
} else {
const char *str = form_value.AsCString();
uint32_t string_offset =
str - (const char *)debug_info_data.GetDataStart();
uint32_t string_length = strlen(str) + 1;
- location.CopyOpcodeData(module, debug_info_data,
- string_offset, string_length);
+ location =
+ DWARFExpression(module, debug_info_data, die.GetCU(),
+ string_offset, string_length);
}
}
}
@@ -3352,7 +3241,8 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
uint32_t block_offset =
form_value.BlockData() - data.GetDataStart();
uint32_t block_length = form_value.Unsigned();
- location.CopyOpcodeData(module, data, block_offset, block_length);
+ location = DWARFExpression(module, data, die.GetCU(),
+ block_offset, block_length);
} else {
const DWARFDataExtractor &debug_loc_data = DebugLocData();
const dw_offset_t debug_loc_offset = form_value.Unsigned();
@@ -3360,8 +3250,8 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
size_t loc_list_length = DWARFExpression::LocationListSize(
die.GetCU(), debug_loc_data, debug_loc_offset);
if (loc_list_length > 0) {
- location.CopyOpcodeData(module, debug_loc_data,
- debug_loc_offset, loc_list_length);
+ location = DWARFExpression(module, debug_loc_data, die.GetCU(),
+ debug_loc_offset, loc_list_length);
assert(func_low_pc != LLDB_INVALID_ADDRESS);
location.SetLocationListSlide(
func_low_pc -
@@ -3370,31 +3260,11 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
}
} break;
case DW_AT_specification:
- spec_die = GetDIE(DIERef(form_value));
+ spec_die = form_value.Reference();
+ break;
+ case DW_AT_start_scope:
+ // TODO: Implement this.
break;
- case DW_AT_start_scope: {
- if (form_value.Form() == DW_FORM_sec_offset) {
- DWARFRangeList dwarf_scope_ranges;
- const DWARFDebugRangesBase *debug_ranges = DebugRanges();
- debug_ranges->FindRanges(die.GetCU(),
- form_value.Unsigned(),
- dwarf_scope_ranges);
- } else {
- // TODO: Handle the case when DW_AT_start_scope have form
- // constant. The
- // dwarf spec is a bit ambiguous about what is the expected
- // behavior in case the enclosing block have a non coninious
- // address range and the DW_AT_start_scope entry have a form
- // constant.
- GetObjectFile()->GetModule()->ReportWarning(
- "0x%8.8" PRIx64
- ": DW_AT_start_scope has unsupported form type (0x%x)\n",
- die.GetID(), form_value.Form());
- }
-
- scope_ranges.Sort();
- scope_ranges.CombineConsecutiveRanges();
- } break;
case DW_AT_artificial:
is_artificial = form_value.Boolean();
break;
@@ -3425,7 +3295,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
ValueType scope = eValueTypeInvalid;
const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die);
- SymbolContextScope *symbol_context_scope = NULL;
+ SymbolContextScope *symbol_context_scope = nullptr;
bool has_explicit_mangled = mangled != nullptr;
if (!mangled) {
@@ -3471,7 +3341,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
if (op_error) {
StreamString strm;
location.DumpLocationForAddress(&strm, eDescriptionLevelFull, 0, 0,
- NULL);
+ nullptr);
GetObjectFile()->GetModule()->ReportError(
"0x%8.8x: %s has an invalid location: %s", die.GetOffset(),
die.GetTagAsCString(), strm.GetData());
@@ -3574,7 +3444,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
}
}
- if (symbol_context_scope == NULL) {
+ if (symbol_context_scope == nullptr) {
switch (parent_tag) {
case DW_TAG_subprogram:
case DW_TAG_inlined_subroutine:
@@ -3582,7 +3452,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
if (sc.function) {
symbol_context_scope = sc.function->GetBlock(true).FindBlockByID(
sc_parent_die.GetID());
- if (symbol_context_scope == NULL)
+ if (symbol_context_scope == nullptr)
symbol_context_scope = sc.function;
}
break;
@@ -3595,17 +3465,17 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
if (symbol_context_scope) {
SymbolFileTypeSP type_sp(
- new SymbolFileType(*this, DIERef(type_die_form).GetUID(this)));
+ new SymbolFileType(*this, GetUID(type_die_form.Reference())));
if (const_value.Form() && type_sp && type_sp->GetType())
- location.CopyOpcodeData(const_value.Unsigned(),
- type_sp->GetType()->GetByteSize(),
- die.GetCU()->GetAddressByteSize());
+ location.UpdateValue(const_value.Unsigned(),
+ type_sp->GetType()->GetByteSize().getValueOr(0),
+ die.GetCU()->GetAddressByteSize());
- var_sp.reset(new Variable(die.GetID(), name, mangled, type_sp, scope,
- symbol_context_scope, scope_ranges, &decl,
- location, is_external, is_artificial,
- is_static_member));
+ var_sp = std::make_shared<Variable>(
+ die.GetID(), name, mangled, type_sp, scope, symbol_context_scope,
+ scope_ranges, &decl, location, is_external, is_artificial,
+ is_static_member);
var_sp->SetLocationIsConstantValueData(location_is_const_value_data);
} else {
@@ -3644,12 +3514,11 @@ SymbolFileDWARF::FindBlockContainingSpecification(
case DW_TAG_subprogram:
case DW_TAG_inlined_subroutine:
case DW_TAG_lexical_block: {
- if (die.GetAttributeValueAsReference(
- DW_AT_specification, DW_INVALID_OFFSET) == spec_block_die_offset)
+ if (die.GetReferencedDIE(DW_AT_specification).GetOffset() ==
+ spec_block_die_offset)
return die;
- if (die.GetAttributeValueAsReference(DW_AT_abstract_origin,
- DW_INVALID_OFFSET) ==
+ if (die.GetReferencedDIE(DW_AT_abstract_origin).GetOffset() ==
spec_block_die_offset)
return die;
} break;
@@ -3694,16 +3563,16 @@ size_t SymbolFileDWARF::ParseVariables(const SymbolContext &sc,
// We haven't already parsed it, lets do that now.
if ((tag == DW_TAG_variable) || (tag == DW_TAG_constant) ||
(tag == DW_TAG_formal_parameter && sc.function)) {
- if (variable_list_sp.get() == NULL) {
+ if (variable_list_sp.get() == nullptr) {
DWARFDIE sc_parent_die = GetParentSymbolContextDIE(orig_die);
dw_tag_t parent_tag = sc_parent_die.Tag();
switch (parent_tag) {
case DW_TAG_compile_unit:
case DW_TAG_partial_unit:
- if (sc.comp_unit != NULL) {
+ if (sc.comp_unit != nullptr) {
variable_list_sp = sc.comp_unit->GetVariableList(false);
- if (variable_list_sp.get() == NULL) {
- variable_list_sp.reset(new VariableList());
+ if (variable_list_sp.get() == nullptr) {
+ variable_list_sp = std::make_shared<VariableList>();
}
} else {
GetObjectFile()->GetModule()->ReportError(
@@ -3718,31 +3587,31 @@ size_t SymbolFileDWARF::ParseVariables(const SymbolContext &sc,
case DW_TAG_subprogram:
case DW_TAG_inlined_subroutine:
case DW_TAG_lexical_block:
- if (sc.function != NULL) {
+ if (sc.function != nullptr) {
// Check to see if we already have parsed the variables for the
// given scope
Block *block = sc.function->GetBlock(true).FindBlockByID(
sc_parent_die.GetID());
- if (block == NULL) {
+ if (block == nullptr) {
// This must be a specification or abstract origin with a
// concrete block counterpart in the current function. We need
// to find the concrete block so we can correctly add the
// variable to it
const DWARFDIE concrete_block_die =
FindBlockContainingSpecification(
- DIERef(sc.function->GetID(), this),
+ GetDIE(sc.function->GetID()),
sc_parent_die.GetOffset());
if (concrete_block_die)
block = sc.function->GetBlock(true).FindBlockByID(
concrete_block_die.GetID());
}
- if (block != NULL) {
+ if (block != nullptr) {
const bool can_create = false;
variable_list_sp = block->GetBlockVariableList(can_create);
- if (variable_list_sp.get() == NULL) {
- variable_list_sp.reset(new VariableList());
+ if (variable_list_sp.get() == nullptr) {
+ variable_list_sp = std::make_shared<VariableList>();
block->SetVariableList(variable_list_sp);
}
}
@@ -3770,7 +3639,7 @@ size_t SymbolFileDWARF::ParseVariables(const SymbolContext &sc,
}
}
- bool skip_children = (sc.function == NULL && tag == DW_TAG_subprogram);
+ bool skip_children = (sc.function == nullptr && tag == DW_TAG_subprogram);
if (!skip_children && parse_children && die.HasChildren()) {
vars_added += ParseVariables(sc, die.GetFirstChild(), func_low_pc, true,
@@ -3833,15 +3702,13 @@ CollectCallEdges(DWARFDIE function_die) {
std::vector<lldb_private::CallEdge>
SymbolFileDWARF::ParseCallEdgesInFunction(UserID func_id) {
- DWARFDIE func_die = GetDIEFromUID(func_id.GetID());
+ DWARFDIE func_die = GetDIE(func_id.GetID());
if (func_die.IsValid())
return CollectCallEdges(func_die);
return {};
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString SymbolFileDWARF::GetPluginName() { return GetPluginNameStatic(); }
uint32_t SymbolFileDWARF::GetPluginVersion() { return 1; }
@@ -3857,7 +3724,7 @@ void SymbolFileDWARF::DumpClangAST(Stream &s) {
}
SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {
- if (m_debug_map_symfile == NULL && !m_debug_map_module_wp.expired()) {
+ if (m_debug_map_symfile == nullptr && !m_debug_map_module_wp.expired()) {
lldb::ModuleSP module_sp(m_debug_map_module_wp.lock());
if (module_sp) {
SymbolVendor *sym_vendor = module_sp->GetSymbolVendor();
@@ -3882,7 +3749,10 @@ SymbolFileDWARFDwp *SymbolFileDWARF::GetDwpSymbolFile() {
module_spec.GetFileSpec() = m_obj_file->GetFileSpec();
module_spec.GetSymbolFileSpec() =
FileSpec(m_obj_file->GetFileSpec().GetPath() + ".dwp");
- FileSpec dwp_filespec = Symbols::LocateExecutableSymbolFile(module_spec);
+
+ FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
+ FileSpec dwp_filespec =
+ Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
if (FileSystem::Instance().Exists(dwp_filespec)) {
m_dwp_symfile = SymbolFileDWARFDwp::Create(GetObjectFile()->GetModule(),
dwp_filespec);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index d351289f8b51b..018af47305f46 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARF.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,9 +19,6 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Threading.h"
-#include "lldb/Utility/Flags.h"
-
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Expression/DWARFExpression.h"
@@ -30,20 +26,21 @@
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/Flags.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/lldb-private.h"
+#include "DWARFContext.h"
#include "DWARFDataExtractor.h"
#include "DWARFDefines.h"
#include "DWARFIndex.h"
#include "UniqueDWARFASTType.h"
-//----------------------------------------------------------------------
// Forward Declarations for this DWARF plugin
-//----------------------------------------------------------------------
class DebugMapModule;
class DWARFAbbreviationDeclaration;
class DWARFAbbreviationDeclarationSet;
-class DWARFileUnit;
+class DWARFCompileUnit;
class DWARFDebugAbbrev;
class DWARFDebugAranges;
class DWARFDebugInfo;
@@ -51,8 +48,8 @@ class DWARFDebugInfoEntry;
class DWARFDebugLine;
class DWARFDebugRangesBase;
class DWARFDeclContext;
-class DWARFDIECollection;
class DWARFFormValue;
+class DWARFTypeUnit;
class SymbolFileDWARFDebugMap;
class SymbolFileDWARFDwo;
class SymbolFileDWARFDwp;
@@ -65,14 +62,11 @@ public:
friend class SymbolFileDWARFDebugMap;
friend class SymbolFileDWARFDwo;
friend class DebugMapModule;
- friend struct DIERef;
- friend class DWARFUnit;
+ friend class DWARFCompileUnit;
friend class DWARFDIE;
friend class DWARFASTParserClang;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -86,11 +80,12 @@ public:
static lldb_private::SymbolFile *
CreateInstance(lldb_private::ObjectFile *obj_file);
- //------------------------------------------------------------------
+ static lldb_private::FileSpecList GetSymlinkPaths();
+
// Constructors and Destructors
- //------------------------------------------------------------------
- SymbolFileDWARF(lldb_private::ObjectFile *ofile);
+ SymbolFileDWARF(lldb_private::ObjectFile *ofile,
+ lldb_private::SectionList *dwo_section_list);
~SymbolFileDWARF() override;
@@ -98,9 +93,7 @@ public:
void InitializeObject() override;
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
@@ -124,7 +117,7 @@ public:
bool ParseImportedModules(
const lldb_private::SymbolContext &sc,
- std::vector<lldb_private::ConstString> &imported_modules) override;
+ std::vector<lldb_private::SourceModule> &imported_modules) override;
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
@@ -142,11 +135,6 @@ public:
bool assert_not_being_parsed = true,
bool resolve_function_context = false);
- SymbolFileDWARF *GetDWARFForUID(lldb::user_id_t uid);
-
- DWARFDIE
- GetDIEFromUID(lldb::user_id_t uid);
-
lldb_private::CompilerDecl GetDeclForUID(lldb::user_id_t uid) override;
lldb_private::CompilerDeclContext
@@ -169,7 +157,7 @@ public:
lldb_private::SymbolContextList &sc_list) override;
uint32_t
- FindGlobalVariables(const lldb_private::ConstString &name,
+ FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@@ -179,7 +167,7 @@ public:
lldb_private::VariableList &variables) override;
uint32_t
- FindFunctions(const lldb_private::ConstString &name,
+ FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool include_inlines,
bool append, lldb_private::SymbolContextList &sc_list) override;
@@ -193,7 +181,7 @@ public:
std::vector<lldb_private::ConstString> &mangled_names) override;
uint32_t
- FindTypes(const lldb_private::ConstString &name,
+ FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
@@ -212,40 +200,20 @@ public:
GetTypeSystemForLanguage(lldb::LanguageType language) override;
lldb_private::CompilerDeclContext FindNamespace(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
void PreloadSymbols() override;
std::recursive_mutex &GetModuleMutex() const override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
- virtual const lldb_private::DWARFDataExtractor &get_debug_abbrev_data();
- virtual const lldb_private::DWARFDataExtractor &get_debug_addr_data();
- const lldb_private::DWARFDataExtractor &get_debug_aranges_data();
- const lldb_private::DWARFDataExtractor &get_debug_frame_data();
- virtual const lldb_private::DWARFDataExtractor &get_debug_info_data();
- const lldb_private::DWARFDataExtractor &get_debug_line_data();
- const lldb_private::DWARFDataExtractor &get_debug_line_str_data();
- const lldb_private::DWARFDataExtractor &get_debug_macro_data();
const lldb_private::DWARFDataExtractor &get_debug_loc_data();
const lldb_private::DWARFDataExtractor &get_debug_loclists_data();
- const lldb_private::DWARFDataExtractor &get_debug_ranges_data();
- const lldb_private::DWARFDataExtractor &get_debug_rnglists_data();
- virtual const lldb_private::DWARFDataExtractor &get_debug_str_data();
- virtual const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data();
- const lldb_private::DWARFDataExtractor &get_debug_types_data();
- const lldb_private::DWARFDataExtractor &get_apple_names_data();
- const lldb_private::DWARFDataExtractor &get_apple_types_data();
- const lldb_private::DWARFDataExtractor &get_apple_namespaces_data();
- const lldb_private::DWARFDataExtractor &get_apple_objc_data();
- const lldb_private::DWARFDataExtractor &get_gnu_debugaltlink();
DWARFDebugAbbrev *DebugAbbrev();
@@ -255,9 +223,8 @@ public:
const DWARFDebugInfo *DebugInfo() const;
- DWARFDebugRangesBase *DebugRanges();
-
- const DWARFDebugRangesBase *DebugRanges() const;
+ DWARFDebugRangesBase *GetDebugRanges();
+ DWARFDebugRangesBase *GetDebugRngLists();
const lldb_private::DWARFDataExtractor &DebugLocData();
@@ -270,8 +237,7 @@ public:
HasForwardDeclForClangType(const lldb_private::CompilerType &compiler_type);
lldb_private::CompileUnit *
- GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu,
- uint32_t cu_idx = UINT32_MAX);
+ GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu);
virtual size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
DIEArray &method_die_offsets);
@@ -282,8 +248,7 @@ public:
static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die);
- virtual lldb::CompUnitSP ParseCompileUnit(DWARFUnit *dwarf_cu,
- uint32_t cu_idx);
+ virtual lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu);
virtual lldb_private::DWARFExpression::LocationListFormat
GetLocationListFormat() const;
@@ -300,6 +265,18 @@ public:
virtual DWARFDIE GetDIE(const DIERef &die_ref);
+ DWARFDIE GetDIE(lldb::user_id_t uid);
+
+ lldb::user_id_t GetUID(const DWARFBaseDIE &die) {
+ return GetUID(die.GetDIERef());
+ }
+
+ lldb::user_id_t GetUID(const llvm::Optional<DIERef> &ref) {
+ return ref ? GetUID(*ref) : LLDB_INVALID_UID;
+ }
+
+ lldb::user_id_t GetUID(DIERef ref);
+
virtual std::unique_ptr<SymbolFileDWARFDwo>
GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
const DWARFDebugInfoEntry &cu_die);
@@ -307,7 +284,9 @@ public:
// For regular SymbolFileDWARF instances the method returns nullptr,
// for the instances of the subclass SymbolFileDWARFDwo
// the method returns a pointer to the base compile unit.
- virtual DWARFUnit *GetBaseCompileUnit();
+ virtual DWARFCompileUnit *GetBaseCompileUnit() { return nullptr; }
+
+ virtual llvm::Optional<uint32_t> GetDwoNum() { return llvm::None; }
static bool
DIEInDeclContext(const lldb_private::CompilerDeclContext *parent_decl_ctx,
@@ -320,6 +299,10 @@ public:
void DumpClangAST(lldb_private::Stream &s) override;
+ lldb_private::DWARFContext &GetDWARFContext() { return m_context; }
+
+ lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx);
+
protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *>
DIEToTypePtr;
@@ -328,7 +311,8 @@ protected:
typedef llvm::DenseMap<const DWARFDebugInfoEntry *,
lldb::opaque_compiler_type_t>
DIEToClangType;
- typedef llvm::DenseMap<lldb::opaque_compiler_type_t, DIERef> ClangTypeToDIE;
+ typedef llvm::DenseMap<lldb::opaque_compiler_type_t, lldb::user_id_t>
+ ClangTypeToDIE;
struct DWARFDataSegment {
llvm::once_flag m_flag;
@@ -381,7 +365,7 @@ protected:
const DWARFDIE &orig_die,
const lldb::addr_t func_low_pc, bool parse_siblings,
bool parse_children,
- lldb_private::VariableList *cc_variable_list = NULL);
+ lldb_private::VariableList *cc_variable_list = nullptr);
bool ClassOrStructIsVirtual(const DWARFDIE &die);
@@ -393,11 +377,11 @@ protected:
FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext &die_decl_ctx);
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
- const DWARFDIE &die, const lldb_private::ConstString &type_name,
+ const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation);
lldb_private::Symbol *
- GetObjCClassSymbol(const lldb_private::ConstString &objc_class_name);
+ GetObjCClassSymbol(lldb_private::ConstString objc_class_name);
lldb::TypeSP GetTypeForDIE(const DWARFDIE &die,
bool resolve_function_context = false);
@@ -421,7 +405,7 @@ protected:
bool DIEDeclContextsMatch(const DWARFDIE &die1, const DWARFDIE &die2);
bool ClassContainsSelector(const DWARFDIE &class_die,
- const lldb_private::ConstString &selector);
+ lldb_private::ConstString selector);
bool FixupAddress(lldb_private::Address &addr);
@@ -451,44 +435,35 @@ protected:
return m_forward_decl_clang_type_to_die;
}
+ void BuildCuTranslationTable();
+ llvm::Optional<uint32_t> GetDWARFUnitIndex(uint32_t cu_idx);
+
+ struct DecodedUID {
+ SymbolFileDWARF &dwarf;
+ DIERef ref;
+ };
+ llvm::Optional<DecodedUID> DecodeUID(lldb::user_id_t uid);
+
SymbolFileDWARFDwp *GetDwpSymbolFile();
+ const lldb_private::FileSpecList &GetTypeUnitSupportFiles(DWARFTypeUnit &tu);
+
lldb::ModuleWP m_debug_map_module_wp;
SymbolFileDWARFDebugMap *m_debug_map_symfile;
llvm::once_flag m_dwp_symfile_once_flag;
std::unique_ptr<SymbolFileDWARFDwp> m_dwp_symfile;
- lldb_private::DWARFDataExtractor m_dwarf_data;
+ lldb_private::DWARFContext m_context;
- DWARFDataSegment m_data_debug_abbrev;
- DWARFDataSegment m_data_debug_addr;
- DWARFDataSegment m_data_debug_aranges;
- DWARFDataSegment m_data_debug_frame;
- DWARFDataSegment m_data_debug_info;
- DWARFDataSegment m_data_debug_line;
- DWARFDataSegment m_data_debug_line_str;
- DWARFDataSegment m_data_debug_macro;
DWARFDataSegment m_data_debug_loc;
DWARFDataSegment m_data_debug_loclists;
- DWARFDataSegment m_data_debug_ranges;
- DWARFDataSegment m_data_debug_rnglists;
- DWARFDataSegment m_data_debug_str;
- DWARFDataSegment m_data_debug_str_offsets;
- DWARFDataSegment m_data_debug_types;
- DWARFDataSegment m_data_apple_names;
- DWARFDataSegment m_data_apple_types;
- DWARFDataSegment m_data_apple_namespaces;
- DWARFDataSegment m_data_apple_objc;
- DWARFDataSegment m_data_gnu_debugaltlink;
// The unique pointer items below are generated on demand if and when someone
- // accesses
- // them through a non const version of this class.
+ // accesses them through a non const version of this class.
std::unique_ptr<DWARFDebugAbbrev> m_abbr;
std::unique_ptr<DWARFDebugInfo> m_info;
- std::unique_ptr<DWARFDebugLine> m_line;
- std::unique_ptr<GlobalVariableMap> m_global_aranges_ap;
+ std::unique_ptr<GlobalVariableMap> m_global_aranges_up;
typedef std::unordered_map<lldb::offset_t, lldb_private::DebugMacrosSP>
DebugMacrosMap;
@@ -499,15 +474,19 @@ protected:
bool m_fetched_external_modules : 1;
lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
- typedef std::shared_ptr<std::set<DIERef>> DIERefSetSP;
- typedef std::unordered_map<std::string, DIERefSetSP> NameToOffsetMap;
+ typedef std::set<lldb::user_id_t> DIERefSet;
+ typedef llvm::StringMap<DIERefSet> NameToOffsetMap;
NameToOffsetMap m_function_scope_qualified_name_map;
std::unique_ptr<DWARFDebugRangesBase> m_ranges;
+ std::unique_ptr<DWARFDebugRangesBase> m_rnglists;
UniqueDWARFASTTypeMap m_unique_ast_type_map;
DIEToTypePtr m_die_to_type;
DIEToVariableSP m_die_to_variable_sp;
DIEToClangType m_forward_decl_die_to_clang_type;
ClangTypeToDIE m_forward_decl_clang_type_to_die;
+ llvm::DenseMap<dw_offset_t, lldb_private::FileSpecList>
+ m_type_unit_support_files;
+ std::vector<uint32_t> m_lldb_cu_to_dwarf_unit;
};
#endif // SymbolFileDWARF_SymbolFileDWARF_h_
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 2c1e6416a9353..8ec64dbaf7641 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1,22 +1,20 @@
//===-- SymbolFileDWARFDebugMap.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "SymbolFileDWARFDebugMap.h"
-
#include "DWARFDebugAranges.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleList.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Core/RangeMap.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Timer.h"
@@ -36,6 +34,8 @@
#include "LogChannelDWARF.h"
#include "SymbolFileDWARF.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -60,13 +60,11 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap(
return file_range_map;
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_MAP));
- if (log) {
- ConstString object_name(oso_module->GetObjectName());
+ if (log)
log->Printf(
"%p: SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap ('%s')",
static_cast<void *>(this),
oso_module->GetSpecificationDescription().c_str());
- }
std::vector<SymbolFileDWARFDebugMap::CompileUnitInfo *> cu_infos;
if (exe_symfile->GetCompUnitInfosForModule(oso_module, cu_infos)) {
@@ -177,10 +175,10 @@ public:
SymbolVendor *
GetSymbolVendor(bool can_create = true,
- lldb_private::Stream *feedback_strm = NULL) override {
+ lldb_private::Stream *feedback_strm = nullptr) override {
// Scope for locker
- if (m_symfile_ap.get() || !can_create)
- return m_symfile_ap.get();
+ if (m_symfile_up.get() || !can_create)
+ return m_symfile_up.get();
ModuleSP exe_module_sp(m_exe_module_wp.lock());
if (exe_module_sp) {
@@ -199,7 +197,7 @@ public:
symbol_vendor->GetSymbolFile());
if (!oso_symfile)
- return NULL;
+ return nullptr;
ObjectFile *exe_objfile = exe_module_sp->GetObjectFile();
SymbolVendor *exe_sym_vendor = exe_module_sp->GetSymbolVendor();
@@ -215,7 +213,7 @@ public:
}
}
}
- return NULL;
+ return nullptr;
}
protected:
@@ -370,12 +368,12 @@ void SymbolFileDWARFDebugMap::InitOSO() {
oso_symbol->GetName().GetCString());
}
} else {
- if (oso_symbol == NULL)
+ if (oso_symbol == nullptr)
m_obj_file->GetModule()->ReportError(
"N_OSO symbol[%u] can't be found, please file a bug and attach "
"the binary listed in this error",
oso_idx);
- else if (so_symbol == NULL)
+ else if (so_symbol == nullptr)
m_obj_file->GetModule()->ReportError(
"N_SO not found for N_OSO symbol[%u], please file a bug and "
"attach the binary listed in this error",
@@ -400,7 +398,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByOSOIndex(uint32_t oso_idx) {
const uint32_t cu_count = GetNumCompileUnits();
if (oso_idx < cu_count)
return GetModuleByCompUnitInfo(&m_compile_unit_infos[oso_idx]);
- return NULL;
+ return nullptr;
}
Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
@@ -412,7 +410,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
comp_unit_info->oso_sp = pos->second;
} else {
ObjectFile *obj_file = GetObjectFile();
- comp_unit_info->oso_sp.reset(new OSOInfo());
+ comp_unit_info->oso_sp = std::make_shared<OSOInfo>();
m_oso_map[{comp_unit_info->oso_path, comp_unit_info->oso_mod_time}] =
comp_unit_info->oso_sp;
const char *oso_path = comp_unit_info->oso_path.GetCString();
@@ -430,7 +428,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
") since this executable was linked, file will be ignored",
oso_file.GetPath().c_str(), llvm::to_string(oso_mod_time).c_str(),
llvm::to_string(comp_unit_info->oso_mod_time).c_str());
- return NULL;
+ return nullptr;
}
} else {
@@ -438,7 +436,7 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
if (!ObjectFile::SplitArchivePathWithObject(oso_path, oso_file,
oso_object, must_exist)) {
- return NULL;
+ return nullptr;
}
}
// Always create a new module for .o files. Why? Because we use the debug
@@ -456,16 +454,15 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo(
.getArchName()
.str()
.c_str());
- comp_unit_info->oso_sp->module_sp.reset(new DebugMapModule(
+ comp_unit_info->oso_sp->module_sp = std::make_shared<DebugMapModule>(
obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), oso_file,
- oso_arch, oso_object ? &oso_object : NULL, 0,
- oso_object ? comp_unit_info->oso_mod_time
- : llvm::sys::TimePoint<>()));
+ oso_arch, oso_object ? &oso_object : nullptr, 0,
+ oso_object ? comp_unit_info->oso_mod_time : llvm::sys::TimePoint<>());
}
}
if (comp_unit_info->oso_sp)
return comp_unit_info->oso_sp->module_sp.get();
- return NULL;
+ return nullptr;
}
bool SymbolFileDWARFDebugMap::GetFileSpecForSO(uint32_t oso_idx,
@@ -483,7 +480,7 @@ ObjectFile *SymbolFileDWARFDebugMap::GetObjectFileByOSOIndex(uint32_t oso_idx) {
Module *oso_module = GetModuleByOSOIndex(oso_idx);
if (oso_module)
return oso_module->GetObjectFile();
- return NULL;
+ return nullptr;
}
SymbolFileDWARF *
@@ -496,7 +493,7 @@ SymbolFileDWARFDebugMap::GetSymbolFile(const CompileUnit &comp_unit) {
CompileUnitInfo *comp_unit_info = GetCompUnitInfo(comp_unit);
if (comp_unit_info)
return GetSymbolFileByCompUnitInfo(comp_unit_info);
- return NULL;
+ return nullptr;
}
ObjectFile *SymbolFileDWARFDebugMap::GetObjectFileByCompUnitInfo(
@@ -504,7 +501,7 @@ ObjectFile *SymbolFileDWARFDebugMap::GetObjectFileByCompUnitInfo(
Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
if (oso_module)
return oso_module->GetObjectFile();
- return NULL;
+ return nullptr;
}
uint32_t SymbolFileDWARFDebugMap::GetCompUnitInfoIndex(
@@ -524,7 +521,7 @@ SymbolFileDWARFDebugMap::GetSymbolFileByOSOIndex(uint32_t oso_idx) {
unsigned size = m_compile_unit_infos.size();
if (oso_idx < size)
return GetSymbolFileByCompUnitInfo(&m_compile_unit_infos[oso_idx]);
- return NULL;
+ return nullptr;
}
SymbolFileDWARF *
@@ -532,7 +529,7 @@ SymbolFileDWARFDebugMap::GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file) {
if (sym_file &&
sym_file->GetPluginName() == SymbolFileDWARF::GetPluginNameStatic())
return (SymbolFileDWARF *)sym_file;
- return NULL;
+ return nullptr;
}
SymbolFileDWARF *SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo(
@@ -543,7 +540,7 @@ SymbolFileDWARF *SymbolFileDWARFDebugMap::GetSymbolFileByCompUnitInfo(
if (sym_vendor)
return GetSymbolFileAsSymbolFileDWARF(sym_vendor->GetSymbolFile());
}
- return NULL;
+ return nullptr;
}
uint32_t SymbolFileDWARFDebugMap::CalculateAbilities() {
@@ -582,9 +579,10 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) {
// User zero as the ID to match the compile unit at offset zero in each
// .o file since each .o file can only have one compile unit for now.
lldb::user_id_t cu_id = 0;
- m_compile_unit_infos[cu_idx].compile_unit_sp.reset(
- new CompileUnit(m_obj_file->GetModule(), NULL, so_file_spec, cu_id,
- eLanguageTypeUnknown, eLazyBoolCalculate));
+ m_compile_unit_infos[cu_idx].compile_unit_sp =
+ std::make_shared<CompileUnit>(
+ m_obj_file->GetModule(), nullptr, so_file_spec, cu_id,
+ eLanguageTypeUnknown, eLazyBoolCalculate);
if (m_compile_unit_infos[cu_idx].compile_unit_sp) {
// Let our symbol vendor know about this compile unit
@@ -611,7 +609,7 @@ SymbolFileDWARFDebugMap::GetCompUnitInfo(const CompileUnit &comp_unit) {
if (comp_unit == m_compile_unit_infos[i].compile_unit_sp.get())
return &m_compile_unit_infos[i];
}
- return NULL;
+ return nullptr;
}
size_t SymbolFileDWARFDebugMap::GetCompUnitInfosForModule(
@@ -670,7 +668,7 @@ bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) {
}
bool SymbolFileDWARFDebugMap::ParseImportedModules(
- const SymbolContext &sc, std::vector<ConstString> &imported_modules) {
+ const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc);
if (oso_dwarf)
return oso_dwarf->ParseImportedModules(sc, imported_modules);
@@ -708,7 +706,7 @@ Type *SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) {
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
if (oso_dwarf)
return oso_dwarf->ResolveTypeUID(type_uid);
- return NULL;
+ return nullptr;
}
llvm::Optional<SymbolFile::ArrayInfo>
@@ -752,7 +750,7 @@ SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr,
sc.symbol =
symtab->SymbolAtIndex(debug_map_entry->data.GetExeSymbolIndex());
- if (sc.symbol != NULL) {
+ if (sc.symbol != nullptr) {
resolved_flags |= eSymbolContextSymbol;
uint32_t oso_idx = 0;
@@ -810,7 +808,7 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext(
}
uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
const std::vector<uint32_t>
&indexes, // Indexes into the symbol table that match "name"
uint32_t max_matches, VariableList &variables) {
@@ -834,7 +832,7 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables(
}
uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
// Remember how many variables are in the list before we search.
@@ -932,7 +930,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo *
SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithIndex(
uint32_t symbol_idx, uint32_t *oso_idx_ptr) {
const uint32_t oso_index_count = m_compile_unit_infos.size();
- CompileUnitInfo *comp_unit_info = NULL;
+ CompileUnitInfo *comp_unit_info = nullptr;
if (oso_index_count) {
comp_unit_info = (CompileUnitInfo *)bsearch(
&symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(),
@@ -941,7 +939,7 @@ SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithIndex(
}
if (oso_idx_ptr) {
- if (comp_unit_info != NULL)
+ if (comp_unit_info != nullptr)
*oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
else
*oso_idx_ptr = UINT32_MAX;
@@ -953,7 +951,7 @@ SymbolFileDWARFDebugMap::CompileUnitInfo *
SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID(
user_id_t symbol_id, uint32_t *oso_idx_ptr) {
const uint32_t oso_index_count = m_compile_unit_infos.size();
- CompileUnitInfo *comp_unit_info = NULL;
+ CompileUnitInfo *comp_unit_info = nullptr;
if (oso_index_count) {
comp_unit_info = (CompileUnitInfo *)::bsearch(
&symbol_id, &m_compile_unit_infos[0], m_compile_unit_infos.size(),
@@ -962,7 +960,7 @@ SymbolFileDWARFDebugMap::GetCompileUnitInfoForSymbolWithID(
}
if (oso_idx_ptr) {
- if (comp_unit_info != NULL)
+ if (comp_unit_info != nullptr)
*oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
else
*oso_idx_ptr = UINT32_MAX;
@@ -996,7 +994,7 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp,
}
uint32_t SymbolFileDWARFDebugMap::FindFunctions(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
SymbolContextList &sc_list) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
@@ -1060,7 +1058,7 @@ size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
type_mask);
uint32_t initial_size = type_list.GetSize();
- SymbolFileDWARF *oso_dwarf = NULL;
+ SymbolFileDWARF *oso_dwarf = nullptr;
if (sc_scope) {
SymbolContext sc;
sc_scope->CalculateSymbolContext(&sc);
@@ -1105,7 +1103,7 @@ bool SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type(
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolNo;
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
if (skip_dwarf_oso != oso_dwarf &&
- oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(NULL)) {
+ oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(nullptr)) {
m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
return true;
}
@@ -1116,7 +1114,7 @@ bool SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type(
}
TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
- const DWARFDIE &die, const ConstString &type_name,
+ const DWARFDIE &die, ConstString type_name,
bool must_be_implementation) {
// If we have a debug map, we will have an Objective-C symbol whose name is
// the type name and whose type is eSymbolTypeObjCClass. If we can find that
@@ -1124,7 +1122,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
// contain the implementation definition since it will be scoped inside the
// N_SO and we can then locate the SymbolFileDWARF that corresponds to that
// N_SO.
- SymbolFileDWARF *oso_dwarf = NULL;
+ SymbolFileDWARF *oso_dwarf = nullptr;
TypeSP type_sp;
ObjectFile *module_objfile = m_obj_file->GetModule()->GetObjectFile();
if (module_objfile) {
@@ -1145,7 +1143,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
if (source_file_symbol_idx != UINT32_MAX) {
CompileUnitInfo *compile_unit_info =
GetCompileUnitInfoForSymbolWithIndex(source_file_symbol_idx,
- NULL);
+ nullptr);
if (compile_unit_info) {
oso_dwarf = GetSymbolFileByCompUnitInfo(compile_unit_info);
if (oso_dwarf) {
@@ -1180,7 +1178,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
}
uint32_t SymbolFileDWARFDebugMap::FindTypes(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -1212,7 +1210,7 @@ uint32_t SymbolFileDWARFDebugMap::FindTypes(
//}
CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
CompilerDeclContext matching_namespace;
@@ -1232,9 +1230,7 @@ void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s) {
});
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString SymbolFileDWARFDebugMap::GetPluginName() {
return GetPluginNameStatic();
}
@@ -1272,7 +1268,7 @@ SymbolFileDWARFDebugMap::GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf) {
}
}
}
- return NULL;
+ return nullptr;
}
void SymbolFileDWARFDebugMap::SetCompileUnit(SymbolFileDWARF *oso_dwarf,
@@ -1418,7 +1414,7 @@ LineTable *SymbolFileDWARFDebugMap::LinkOSOLineTable(SymbolFileDWARF *oso_dwarf,
CompileUnitInfo *cu_info = GetCompileUnitInfo(oso_dwarf);
if (cu_info)
return line_table->LinkLineTable(cu_info->GetFileRangeMap(this));
- return NULL;
+ return nullptr;
}
size_t
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 176eadeeca71c..afc6142e8231c 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -1,23 +1,21 @@
//===-- SymbolFileDWARFDebugMap.h ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef SymbolFileDWARF_SymbolFileDWARFDebugMap_h_
#define SymbolFileDWARF_SymbolFileDWARFDebugMap_h_
+#include "lldb/Symbol/SymbolFile.h"
+#include "lldb/Utility/RangeMap.h"
+#include "llvm/Support/Chrono.h"
#include <bitset>
#include <map>
#include <vector>
-#include "lldb/Core/RangeMap.h"
-#include "lldb/Symbol/SymbolFile.h"
-#include "llvm/Support/Chrono.h"
-
#include "UniqueDWARFASTType.h"
class SymbolFileDWARF;
@@ -26,9 +24,7 @@ class DWARFDeclContext;
class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile {
public:
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -40,18 +36,14 @@ public:
static lldb_private::SymbolFile *
CreateInstance(lldb_private::ObjectFile *obj_file);
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolFileDWARFDebugMap(lldb_private::ObjectFile *ofile);
~SymbolFileDWARFDebugMap() override;
uint32_t CalculateAbilities() override;
void InitializeObject() override;
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
@@ -73,7 +65,7 @@ public:
bool ParseImportedModules(
const lldb_private::SymbolContext &sc,
- std::vector<lldb_private::ConstString> &imported_modules) override;
+ std::vector<lldb_private::SourceModule> &imported_modules) override;
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
size_t
ParseVariablesForContext(const lldb_private::SymbolContext &sc) override;
@@ -100,7 +92,7 @@ public:
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContextList &sc_list) override;
uint32_t
- FindGlobalVariables(const lldb_private::ConstString &name,
+ FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@@ -108,7 +100,7 @@ public:
uint32_t max_matches,
lldb_private::VariableList &variables) override;
uint32_t
- FindFunctions(const lldb_private::ConstString &name,
+ FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool include_inlines,
bool append, lldb_private::SymbolContextList &sc_list) override;
@@ -116,13 +108,13 @@ public:
bool include_inlines, bool append,
lldb_private::SymbolContextList &sc_list) override;
uint32_t
- FindTypes(const lldb_private::ConstString &name,
+ FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
lldb_private::CompilerDeclContext FindNamespace(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
lldb::TypeClass type_mask,
@@ -132,9 +124,7 @@ public:
void DumpClangAST(lldb_private::Stream &s) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
@@ -143,9 +133,8 @@ protected:
enum { kHaveInitializedOSOs = (1 << 0), kNumFlags };
friend class DebugMapModule;
- friend struct DIERef;
friend class DWARFASTParserClang;
- friend class DWARFUnit;
+ friend class DWARFCompileUnit;
friend class SymbolFileDWARF;
struct OSOInfo {
lldb::ModuleSP module_sp;
@@ -159,9 +148,7 @@ protected:
lldb::addr_t>
FileRangeMap;
- //------------------------------------------------------------------
// Class specific types
- //------------------------------------------------------------------
struct CompileUnitInfo {
lldb_private::FileSpec so_file;
lldb_private::ConstString oso_path;
@@ -184,9 +171,7 @@ protected:
const FileRangeMap &GetFileRangeMap(SymbolFileDWARFDebugMap *exe_symfile);
};
- //------------------------------------------------------------------
// Protected Member Functions
- //------------------------------------------------------------------
void InitOSO();
static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid) {
@@ -248,7 +233,7 @@ protected:
const CompileUnitInfo *comp_unit_info);
uint32_t PrivateFindGlobalVariables(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
const std::vector<uint32_t> &name_symbol_indexes, uint32_t max_matches,
lldb_private::VariableList &variables);
@@ -266,16 +251,14 @@ protected:
bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
- const DWARFDIE &die, const lldb_private::ConstString &type_name,
+ const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation);
UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() {
return m_unique_ast_type_map;
}
- //------------------------------------------------------------------
// OSOEntry
- //------------------------------------------------------------------
class OSOEntry {
public:
OSOEntry()
@@ -304,9 +287,7 @@ protected:
typedef lldb_private::RangeDataVector<lldb::addr_t, lldb::addr_t, OSOEntry>
DebugMap;
- //------------------------------------------------------------------
// Member Variables
- //------------------------------------------------------------------
std::bitset<kNumFlags> m_flags;
std::vector<CompileUnitInfo> m_compile_unit_infos;
std::vector<uint32_t> m_func_indexes; // Sorted by address
@@ -318,68 +299,58 @@ protected:
lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
DebugMap m_debug_map;
- //------------------------------------------------------------------
// When an object file from the debug map gets parsed in
// SymbolFileDWARF, it needs to tell the debug map about the object
// files addresses by calling this function once for each N_FUN,
// N_GSYM and N_STSYM and after all entries in the debug map have
// been matched up, FinalizeOSOFileRanges() should be called.
- //------------------------------------------------------------------
bool AddOSOFileRange(CompileUnitInfo *cu_info, lldb::addr_t exe_file_addr,
lldb::addr_t exe_byte_size, lldb::addr_t oso_file_addr,
lldb::addr_t oso_byte_size);
- //------------------------------------------------------------------
// Called after calling AddOSOFileRange() for each object file debug
// map entry to finalize the info for the unlinked compile unit.
- //------------------------------------------------------------------
void FinalizeOSOFileRanges(CompileUnitInfo *cu_info);
- //------------------------------------------------------------------
/// Convert \a addr from a .o file address, to an executable address.
///
- /// @param[in] addr
+ /// \param[in] addr
/// A section offset address from a .o file
///
- /// @return
+ /// \return
/// Returns true if \a addr was converted to be an executable
/// section/offset address, false otherwise.
- //------------------------------------------------------------------
bool LinkOSOAddress(lldb_private::Address &addr);
- //------------------------------------------------------------------
/// Convert a .o file "file address" to an executable "file address".
///
- /// @param[in] oso_symfile
+ /// \param[in] oso_symfile
/// The DWARF symbol file that contains \a oso_file_addr
///
- /// @param[in] oso_file_addr
+ /// \param[in] oso_file_addr
/// A .o file "file address" to convert.
///
- /// @return
+ /// \return
/// LLDB_INVALID_ADDRESS if \a oso_file_addr is not in the
/// linked executable, otherwise a valid "file address" from the
/// linked executable that contains the debug map.
- //------------------------------------------------------------------
lldb::addr_t LinkOSOFileAddress(SymbolFileDWARF *oso_symfile,
lldb::addr_t oso_file_addr);
- //------------------------------------------------------------------
/// Given a line table full of lines with "file addresses" that are
/// for a .o file represented by \a oso_symfile, link a new line table
/// and return it.
///
- /// @param[in] oso_symfile
+ /// \param[in] oso_symfile
/// The DWARF symbol file that produced the \a line_table
///
- /// @param[in] addr
+ /// \param[in] addr
/// A section offset address from a .o file
///
- /// @return
+ /// \return
/// Returns a valid line table full of linked addresses, or NULL
/// if none of the line table addresses exist in the main
/// executable.
- //------------------------------------------------------------------
lldb_private::LineTable *
LinkOSOLineTable(SymbolFileDWARF *oso_symfile,
lldb_private::LineTable *line_table);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
index 7881448535b81..c5b54b65ea29c 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARFDwo.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,18 +12,21 @@
#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Utility/LLDBAssert.h"
+#include "llvm/Support/Casting.h"
-#include "DWARFUnit.h"
+#include "DWARFCompileUnit.h"
#include "DWARFDebugInfo.h"
+#include "DWARFUnit.h"
using namespace lldb;
using namespace lldb_private;
SymbolFileDWARFDwo::SymbolFileDWARFDwo(ObjectFileSP objfile,
- DWARFUnit *dwarf_cu)
- : SymbolFileDWARF(objfile.get()), m_obj_file_sp(objfile),
- m_base_dwarf_cu(dwarf_cu) {
- SetID(((lldb::user_id_t)dwarf_cu->GetOffset()) << 32);
+ DWARFCompileUnit &dwarf_cu)
+ : SymbolFileDWARF(objfile.get(), objfile->GetSectionList(
+ /*update_module_section_list*/ false)),
+ m_obj_file_sp(objfile), m_base_dwarf_cu(dwarf_cu) {
+ SetID(((lldb::user_id_t)dwarf_cu.GetID()) << 32);
}
void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type,
@@ -34,12 +36,6 @@ void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type,
if (section_list) {
SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
if (section_sp) {
- // See if we memory mapped the DWARF segment?
- if (m_dwarf_data.GetByteSize()) {
- data.SetData(m_dwarf_data, section_sp->GetOffset(),
- section_sp->GetFileSize());
- return;
- }
if (m_obj_file->ReadSectionData(section_sp.get(), data) != 0)
return;
@@ -52,20 +48,41 @@ void SymbolFileDWARFDwo::LoadSectionData(lldb::SectionType sect_type,
}
lldb::CompUnitSP
-SymbolFileDWARFDwo::ParseCompileUnit(DWARFUnit *dwarf_cu,
- uint32_t cu_idx) {
- assert(GetCompileUnit() == dwarf_cu && "SymbolFileDWARFDwo::ParseCompileUnit "
- "called with incompatible compile "
- "unit");
- return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu, UINT32_MAX);
-}
-
-DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() {
- // Only dwo files with 1 compile unit is supported
- if (GetNumCompileUnits() == 1)
- return DebugInfo()->GetCompileUnitAtIndex(0);
- else
+SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
+ assert(GetCompileUnit() == &dwarf_cu &&
+ "SymbolFileDWARFDwo::ParseCompileUnit called with incompatible "
+ "compile unit");
+ return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu);
+}
+
+DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
+ if (!m_cu)
+ m_cu = ComputeCompileUnit();
+ return m_cu;
+}
+
+DWARFCompileUnit *SymbolFileDWARFDwo::ComputeCompileUnit() {
+ DWARFDebugInfo *debug_info = DebugInfo();
+ if (!debug_info)
return nullptr;
+
+ // Right now we only support dwo files with one compile unit. If we don't have
+ // type units, we can just check for the unit count.
+ if (!debug_info->ContainsTypeUnits() && debug_info->GetNumUnits() == 1)
+ return llvm::cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(0));
+
+ // Otherwise, we have to run through all units, and find the compile unit that
+ // way.
+ DWARFCompileUnit *cu = nullptr;
+ for (size_t i = 0; i < debug_info->GetNumUnits(); ++i) {
+ if (auto *candidate =
+ llvm::dyn_cast<DWARFCompileUnit>(debug_info->GetUnitAtIndex(i))) {
+ if (cu)
+ return nullptr; // More that one CU found.
+ cu = candidate;
+ }
+ }
+ return cu;
}
DWARFUnit *
@@ -74,83 +91,48 @@ SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
}
SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() {
- return GetBaseSymbolFile()->GetDIEToType();
+ return GetBaseSymbolFile().GetDIEToType();
}
SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
- return GetBaseSymbolFile()->GetDIEToVariable();
+ return GetBaseSymbolFile().GetDIEToVariable();
}
SymbolFileDWARF::DIEToClangType &
SymbolFileDWARFDwo::GetForwardDeclDieToClangType() {
- return GetBaseSymbolFile()->GetForwardDeclDieToClangType();
+ return GetBaseSymbolFile().GetForwardDeclDieToClangType();
}
SymbolFileDWARF::ClangTypeToDIE &
SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() {
- return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie();
+ return GetBaseSymbolFile().GetForwardDeclClangTypeToDie();
}
size_t SymbolFileDWARFDwo::GetObjCMethodDIEOffsets(
lldb_private::ConstString class_name, DIEArray &method_die_offsets) {
- return GetBaseSymbolFile()->GetObjCMethodDIEOffsets(
- class_name, method_die_offsets);
+ return GetBaseSymbolFile().GetObjCMethodDIEOffsets(class_name,
+ method_die_offsets);
}
UniqueDWARFASTTypeMap &SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() {
- return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap();
+ return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
}
lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
const DWARFDeclContext &die_decl_ctx) {
- return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(
+ return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
die_decl_ctx);
}
lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
- const DWARFDIE &die, const lldb_private::ConstString &type_name,
+ const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation) {
- return GetBaseSymbolFile()->FindCompleteObjCDefinitionTypeForDIE(
+ return GetBaseSymbolFile().FindCompleteObjCDefinitionTypeForDIE(
die, type_name, must_be_implementation);
}
-DWARFUnit *SymbolFileDWARFDwo::GetBaseCompileUnit() {
- return m_base_dwarf_cu;
-}
-
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_abbrev_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugAbbrevDwo,
- m_data_debug_abbrev);
-}
-
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_addr_data() {
- // For single file split dwarf case (when we have .dwo sections in a .o),
- // we do not want to use the .debug_addr section from .o file,
- // but want to get one from the final executable.
- // For regular split debug case, .dwo file does not contain the
- // .debug_addr, so we would always fall back to such lookup anyways.
- llvm::call_once(m_data_debug_addr.m_flag, [this] {
- SymbolFileDWARF::LoadSectionData(eSectionTypeDWARFDebugAddr,
- std::ref(m_data_debug_addr.m_data));
- });
- return m_data_debug_addr.m_data;
-}
-
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_info_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugInfoDwo, m_data_debug_info);
-}
-
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugStrDwo, m_data_debug_str);
-}
-
-const DWARFDataExtractor &SymbolFileDWARFDwo::get_debug_str_offsets_data() {
- return GetCachedSectionData(eSectionTypeDWARFDebugStrOffsetsDwo,
- m_data_debug_str_offsets);
-}
-
-SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
- return m_base_dwarf_cu->GetSymbolFileDWARF();
+SymbolFileDWARF &SymbolFileDWARFDwo::GetBaseSymbolFile() {
+ return m_base_dwarf_cu.GetSymbolFileDWARF();
}
DWARFExpression::LocationListFormat
@@ -160,11 +142,12 @@ SymbolFileDWARFDwo::GetLocationListFormat() const {
TypeSystem *
SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
- return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
+ return GetBaseSymbolFile().GetTypeSystemForLanguage(language);
}
DWARFDIE
SymbolFileDWARFDwo::GetDIE(const DIERef &die_ref) {
- lldbassert(m_base_dwarf_cu->GetOffset() == die_ref.cu_offset);
- return DebugInfo()->GetDIEForDIEOffset(die_ref.die_offset);
+ if (*die_ref.dwo_num() == GetDwoNum())
+ return DebugInfo()->GetDIE(die_ref);
+ return GetBaseSymbolFile().GetDIE(die_ref);
}
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
index b9ed37547aca6..9b2f3bb84c4f3 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARFDwo.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,14 +13,13 @@
class SymbolFileDWARFDwo : public SymbolFileDWARF {
public:
- SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu);
+ SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu);
~SymbolFileDWARFDwo() override = default;
- lldb::CompUnitSP ParseCompileUnit(DWARFUnit *dwarf_cu,
- uint32_t cu_idx) override;
+ lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu) override;
- DWARFUnit *GetCompileUnit();
+ DWARFCompileUnit *GetCompileUnit();
DWARFUnit *
GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override;
@@ -44,13 +42,9 @@ public:
return nullptr;
}
- DWARFUnit *GetBaseCompileUnit() override;
+ DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
- const lldb_private::DWARFDataExtractor &get_debug_abbrev_data() override;
- const lldb_private::DWARFDataExtractor &get_debug_addr_data() override;
- const lldb_private::DWARFDataExtractor &get_debug_info_data() override;
- const lldb_private::DWARFDataExtractor &get_debug_str_data() override;
- const lldb_private::DWARFDataExtractor &get_debug_str_offsets_data() override;
+ llvm::Optional<uint32_t> GetDwoNum() override { return GetID() >> 32; }
protected:
void LoadSectionData(lldb::SectionType sect_type,
@@ -70,13 +64,16 @@ protected:
const DWARFDeclContext &die_decl_ctx) override;
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
- const DWARFDIE &die, const lldb_private::ConstString &type_name,
+ const DWARFDIE &die, lldb_private::ConstString type_name,
bool must_be_implementation) override;
- SymbolFileDWARF *GetBaseSymbolFile();
+ SymbolFileDWARF &GetBaseSymbolFile();
+
+ DWARFCompileUnit *ComputeCompileUnit();
lldb::ObjectFileSP m_obj_file_sp;
- DWARFUnit *m_base_dwarf_cu;
+ DWARFCompileUnit &m_base_dwarf_cu;
+ DWARFCompileUnit *m_cu = nullptr;
};
#endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
index 403c10fe65ea3..efea192b17ced 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARFDwoDwp.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,7 @@ using namespace lldb_private;
SymbolFileDWARFDwoDwp::SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
ObjectFileSP objfile,
- DWARFUnit *dwarf_cu,
+ DWARFCompileUnit &dwarf_cu,
uint64_t dwo_id)
: SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile),
m_dwo_id(dwo_id) {}
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
index 905ba0a5c7b87..2105e1a8f6cbd 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARFDwoDwp.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,7 @@
class SymbolFileDWARFDwoDwp : public SymbolFileDWARFDwo {
public:
SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile,
- lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu,
+ lldb::ObjectFileSP objfile, DWARFCompileUnit &dwarf_cu,
uint64_t dwo_id);
protected:
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
index 73226dfc130f7..08e6e1c8c2f33 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARFDwp.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -82,7 +81,7 @@ SymbolFileDWARFDwp::SymbolFileDWARFDwp(lldb::ModuleSP module_sp,
{}
std::unique_ptr<SymbolFileDWARFDwo>
-SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFUnit *dwarf_cu,
+SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu,
uint64_t dwo_id) {
return std::unique_ptr<SymbolFileDWARFDwo>(
new SymbolFileDWARFDwoDwp(this, m_obj_file, dwarf_cu, dwo_id));
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
index 87f4d94023356..ef06b9dca8bb6 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h
@@ -1,9 +1,8 @@
//===-- SymbolFileDWARFDwp.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,7 +24,7 @@ public:
Create(lldb::ModuleSP module_sp, const lldb_private::FileSpec &file_spec);
std::unique_ptr<SymbolFileDWARFDwo>
- GetSymbolFileForDwoId(DWARFUnit *dwarf_cu, uint64_t dwo_id);
+ GetSymbolFileForDwoId(DWARFCompileUnit &dwarf_cu, uint64_t dwo_id);
bool LoadSectionData(uint64_t dwo_id, lldb::SectionType sect_type,
lldb_private::DWARFDataExtractor &data);
diff --git a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
index dd912aecf0d85..8da7e22262664 100644
--- a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
+++ b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp
@@ -1,9 +1,8 @@
//===-- UniqueDWARFASTType.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,12 +39,12 @@ bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die,
case DW_TAG_namespace: {
const char *parent_arg_die_name = parent_arg_die.GetName();
if (parent_arg_die_name ==
- NULL) // Anonymous (i.e. no-name) struct
+ nullptr) // Anonymous (i.e. no-name) struct
{
match = false;
} else {
const char *parent_pos_die_name = parent_pos_die.GetName();
- if (parent_pos_die_name == NULL ||
+ if (parent_pos_die_name == nullptr ||
((parent_arg_die_name != parent_pos_die_name) &&
strcmp(parent_arg_die_name, parent_pos_die_name)))
match = false;
diff --git a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
index 1e6b164e9457c..1269dbac71263 100644
--- a/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
+++ b/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h
@@ -1,9 +1,8 @@
//===-- UniqueDWARFASTType.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
class UniqueDWARFASTType {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
UniqueDWARFASTType()
: m_type_sp(), m_die(), m_declaration(),
m_byte_size(
@@ -81,12 +78,12 @@ public:
~UniqueDWARFASTTypeMap() {}
- void Insert(const lldb_private::ConstString &name,
+ void Insert(lldb_private::ConstString name,
const UniqueDWARFASTType &entry) {
m_collection[name.GetCString()].Append(entry);
}
- bool Find(const lldb_private::ConstString &name, const DWARFDIE &die,
+ bool Find(lldb_private::ConstString name, const DWARFDIE &die,
const lldb_private::Declaration &decl, const int32_t byte_size,
UniqueDWARFASTType &entry) const {
const char *unique_name_cstr = name.GetCString();
diff --git a/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp b/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
new file mode 100644
index 0000000000000..3834165c71c01
--- /dev/null
+++ b/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
@@ -0,0 +1,457 @@
+//===-- CodeViewRegisterMapping.cpp -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "CodeViewRegisterMapping.h"
+
+#include "lldb/lldb-defines.h"
+
+#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
+
+using namespace lldb_private;
+
+static const uint32_t g_code_view_to_lldb_registers_x86[] = {
+ LLDB_INVALID_REGNUM, // NONE
+ lldb_al_i386, // AL
+ lldb_cl_i386, // CL
+ lldb_dl_i386, // DL
+ lldb_bl_i386, // BL
+ lldb_ah_i386, // AH
+ lldb_ch_i386, // CH
+ lldb_dh_i386, // DH
+ lldb_bh_i386, // BH
+ lldb_ax_i386, // AX
+ lldb_cx_i386, // CX
+ lldb_dx_i386, // DX
+ lldb_bx_i386, // BX
+ lldb_sp_i386, // SP
+ lldb_bp_i386, // BP
+ lldb_si_i386, // SI
+ lldb_di_i386, // DI
+ lldb_eax_i386, // EAX
+ lldb_ecx_i386, // ECX
+ lldb_edx_i386, // EDX
+ lldb_ebx_i386, // EBX
+ lldb_esp_i386, // ESP
+ lldb_ebp_i386, // EBP
+ lldb_esi_i386, // ESI
+ lldb_edi_i386, // EDI
+ lldb_es_i386, // ES
+ lldb_cs_i386, // CS
+ lldb_ss_i386, // SS
+ lldb_ds_i386, // DS
+ lldb_fs_i386, // FS
+ lldb_gs_i386, // GS
+ LLDB_INVALID_REGNUM, // IP
+ LLDB_INVALID_REGNUM, // FLAGS
+ lldb_eip_i386, // EIP
+ lldb_eflags_i386, // EFLAGS
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // TEMP
+ LLDB_INVALID_REGNUM, // TEMPH
+ LLDB_INVALID_REGNUM, // QUOTE
+ LLDB_INVALID_REGNUM, // PCDR3
+ LLDB_INVALID_REGNUM, // PCDR4
+ LLDB_INVALID_REGNUM, // PCDR5
+ LLDB_INVALID_REGNUM, // PCDR6
+ LLDB_INVALID_REGNUM, // PCDR7
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // CR0
+ LLDB_INVALID_REGNUM, // CR1
+ LLDB_INVALID_REGNUM, // CR2
+ LLDB_INVALID_REGNUM, // CR3
+ LLDB_INVALID_REGNUM, // CR4
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ lldb_dr0_i386, // DR0
+ lldb_dr1_i386, // DR1
+ lldb_dr2_i386, // DR2
+ lldb_dr3_i386, // DR3
+ lldb_dr4_i386, // DR4
+ lldb_dr5_i386, // DR5
+ lldb_dr6_i386, // DR6
+ lldb_dr7_i386, // DR7
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // GDTR
+ LLDB_INVALID_REGNUM, // GDTL
+ LLDB_INVALID_REGNUM, // IDTR
+ LLDB_INVALID_REGNUM, // IDTL
+ LLDB_INVALID_REGNUM, // LDTR
+ LLDB_INVALID_REGNUM, // TR
+ LLDB_INVALID_REGNUM, // PSEUDO1
+ LLDB_INVALID_REGNUM, // PSEUDO2
+ LLDB_INVALID_REGNUM, // PSEUDO3
+ LLDB_INVALID_REGNUM, // PSEUDO4
+ LLDB_INVALID_REGNUM, // PSEUDO5
+ LLDB_INVALID_REGNUM, // PSEUDO6
+ LLDB_INVALID_REGNUM, // PSEUDO7
+ LLDB_INVALID_REGNUM, // PSEUDO8
+ LLDB_INVALID_REGNUM, // PSEUDO9
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ lldb_st0_i386, // ST0
+ lldb_st1_i386, // ST1
+ lldb_st2_i386, // ST2
+ lldb_st3_i386, // ST3
+ lldb_st4_i386, // ST4
+ lldb_st5_i386, // ST5
+ lldb_st6_i386, // ST6
+ lldb_st7_i386, // ST7
+ LLDB_INVALID_REGNUM, // CTRL
+ LLDB_INVALID_REGNUM, // STAT
+ LLDB_INVALID_REGNUM, // TAG
+ LLDB_INVALID_REGNUM, // FPIP
+ LLDB_INVALID_REGNUM, // FPCS
+ LLDB_INVALID_REGNUM, // FPDO
+ LLDB_INVALID_REGNUM, // FPDS
+ LLDB_INVALID_REGNUM, // ISEM
+ LLDB_INVALID_REGNUM, // FPEIP
+ LLDB_INVALID_REGNUM, // FPEDO
+ lldb_mm0_i386, // MM0
+ lldb_mm1_i386, // MM1
+ lldb_mm2_i386, // MM2
+ lldb_mm3_i386, // MM3
+ lldb_mm4_i386, // MM4
+ lldb_mm5_i386, // MM5
+ lldb_mm6_i386, // MM6
+ lldb_mm7_i386, // MM7
+ lldb_xmm0_i386, // XMM0
+ lldb_xmm1_i386, // XMM1
+ lldb_xmm2_i386, // XMM2
+ lldb_xmm3_i386, // XMM3
+ lldb_xmm4_i386, // XMM4
+ lldb_xmm5_i386, // XMM5
+ lldb_xmm6_i386, // XMM6
+ lldb_xmm7_i386 // XMM7
+};
+
+static const uint32_t g_code_view_to_lldb_registers_x86_64[] = {
+ LLDB_INVALID_REGNUM, // NONE
+ lldb_al_x86_64, // AL
+ lldb_cl_x86_64, // CL
+ lldb_dl_x86_64, // DL
+ lldb_bl_x86_64, // BL
+ lldb_ah_x86_64, // AH
+ lldb_ch_x86_64, // CH
+ lldb_dh_x86_64, // DH
+ lldb_bh_x86_64, // BH
+ lldb_ax_x86_64, // AX
+ lldb_cx_x86_64, // CX
+ lldb_dx_x86_64, // DX
+ lldb_bx_x86_64, // BX
+ lldb_sp_x86_64, // SP
+ lldb_bp_x86_64, // BP
+ lldb_si_x86_64, // SI
+ lldb_di_x86_64, // DI
+ lldb_eax_x86_64, // EAX
+ lldb_ecx_x86_64, // ECX
+ lldb_edx_x86_64, // EDX
+ lldb_ebx_x86_64, // EBX
+ lldb_esp_x86_64, // ESP
+ lldb_ebp_x86_64, // EBP
+ lldb_esi_x86_64, // ESI
+ lldb_edi_x86_64, // EDI
+ lldb_es_x86_64, // ES
+ lldb_cs_x86_64, // CS
+ lldb_ss_x86_64, // SS
+ lldb_ds_x86_64, // DS
+ lldb_fs_x86_64, // FS
+ lldb_gs_x86_64, // GS
+ LLDB_INVALID_REGNUM, // IP
+ LLDB_INVALID_REGNUM, // FLAGS
+ LLDB_INVALID_REGNUM, // EIP
+ LLDB_INVALID_REGNUM, // EFLAGS
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // TEMP
+ LLDB_INVALID_REGNUM, // TEMPH
+ LLDB_INVALID_REGNUM, // QUOTE
+ LLDB_INVALID_REGNUM, // PCDR3
+ LLDB_INVALID_REGNUM, // PCDR4
+ LLDB_INVALID_REGNUM, // PCDR5
+ LLDB_INVALID_REGNUM, // PCDR6
+ LLDB_INVALID_REGNUM, // PCDR7
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // CR0
+ LLDB_INVALID_REGNUM, // CR1
+ LLDB_INVALID_REGNUM, // CR2
+ LLDB_INVALID_REGNUM, // CR3
+ LLDB_INVALID_REGNUM, // CR4
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ lldb_dr0_x86_64, // DR0
+ lldb_dr1_x86_64, // DR1
+ lldb_dr2_x86_64, // DR2
+ lldb_dr3_x86_64, // DR3
+ lldb_dr4_x86_64, // DR4
+ lldb_dr5_x86_64, // DR5
+ lldb_dr6_x86_64, // DR6
+ lldb_dr7_x86_64, // DR7
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // GDTR
+ LLDB_INVALID_REGNUM, // GDTL
+ LLDB_INVALID_REGNUM, // IDTR
+ LLDB_INVALID_REGNUM, // IDTL
+ LLDB_INVALID_REGNUM, // LDTR
+ LLDB_INVALID_REGNUM, // TR
+ LLDB_INVALID_REGNUM, // PSEUDO1
+ LLDB_INVALID_REGNUM, // PSEUDO2
+ LLDB_INVALID_REGNUM, // PSEUDO3
+ LLDB_INVALID_REGNUM, // PSEUDO4
+ LLDB_INVALID_REGNUM, // PSEUDO5
+ LLDB_INVALID_REGNUM, // PSEUDO6
+ LLDB_INVALID_REGNUM, // PSEUDO7
+ LLDB_INVALID_REGNUM, // PSEUDO8
+ LLDB_INVALID_REGNUM, // PSEUDO9
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ lldb_st0_x86_64, // ST0
+ lldb_st1_x86_64, // ST1
+ lldb_st2_x86_64, // ST2
+ lldb_st3_x86_64, // ST3
+ lldb_st4_x86_64, // ST4
+ lldb_st5_x86_64, // ST5
+ lldb_st6_x86_64, // ST6
+ lldb_st7_x86_64, // ST7
+ LLDB_INVALID_REGNUM, // CTRL
+ LLDB_INVALID_REGNUM, // STAT
+ LLDB_INVALID_REGNUM, // TAG
+ LLDB_INVALID_REGNUM, // FPIP
+ LLDB_INVALID_REGNUM, // FPCS
+ LLDB_INVALID_REGNUM, // FPDO
+ LLDB_INVALID_REGNUM, // FPDS
+ LLDB_INVALID_REGNUM, // ISEM
+ LLDB_INVALID_REGNUM, // FPEIP
+ LLDB_INVALID_REGNUM, // FPEDO
+ lldb_mm0_x86_64, // MM0
+ lldb_mm1_x86_64, // MM1
+ lldb_mm2_x86_64, // MM2
+ lldb_mm3_x86_64, // MM3
+ lldb_mm4_x86_64, // MM4
+ lldb_mm5_x86_64, // MM5
+ lldb_mm6_x86_64, // MM6
+ lldb_mm7_x86_64, // MM7
+ lldb_xmm0_x86_64, // XMM0
+ lldb_xmm1_x86_64, // XMM1
+ lldb_xmm2_x86_64, // XMM2
+ lldb_xmm3_x86_64, // XMM3
+ lldb_xmm4_x86_64, // XMM4
+ lldb_xmm5_x86_64, // XMM5
+ lldb_xmm6_x86_64, // XMM6
+ lldb_xmm7_x86_64, // XMM7
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM,
+ lldb_mxcsr_x86_64, // MXCSR
+ LLDB_INVALID_REGNUM, // EDXEAX
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, // EMM0L
+ LLDB_INVALID_REGNUM, // EMM1L
+ LLDB_INVALID_REGNUM, // EMM2L
+ LLDB_INVALID_REGNUM, // EMM3L
+ LLDB_INVALID_REGNUM, // EMM4L
+ LLDB_INVALID_REGNUM, // EMM5L
+ LLDB_INVALID_REGNUM, // EMM6L
+ LLDB_INVALID_REGNUM, // EMM7L
+ LLDB_INVALID_REGNUM, // EMM0H
+ LLDB_INVALID_REGNUM, // EMM1H
+ LLDB_INVALID_REGNUM, // EMM2H
+ LLDB_INVALID_REGNUM, // EMM3H
+ LLDB_INVALID_REGNUM, // EMM4H
+ LLDB_INVALID_REGNUM, // EMM5H
+ LLDB_INVALID_REGNUM, // EMM6H
+ LLDB_INVALID_REGNUM, // EMM7H
+ LLDB_INVALID_REGNUM, // MM00
+ LLDB_INVALID_REGNUM, // MM01
+ LLDB_INVALID_REGNUM, // MM10
+ LLDB_INVALID_REGNUM, // MM11
+ LLDB_INVALID_REGNUM, // MM20
+ LLDB_INVALID_REGNUM, // MM21
+ LLDB_INVALID_REGNUM, // MM30
+ LLDB_INVALID_REGNUM, // MM31
+ LLDB_INVALID_REGNUM, // MM40
+ LLDB_INVALID_REGNUM, // MM41
+ LLDB_INVALID_REGNUM, // MM50
+ LLDB_INVALID_REGNUM, // MM51
+ LLDB_INVALID_REGNUM, // MM60
+ LLDB_INVALID_REGNUM, // MM61
+ LLDB_INVALID_REGNUM, // MM70
+ LLDB_INVALID_REGNUM, // MM71
+ lldb_xmm8_x86_64, // XMM8
+ lldb_xmm9_x86_64, // XMM9
+ lldb_xmm10_x86_64, // XMM10
+ lldb_xmm11_x86_64, // XMM11
+ lldb_xmm12_x86_64, // XMM12
+ lldb_xmm13_x86_64, // XMM13
+ lldb_xmm14_x86_64, // XMM14
+ lldb_xmm15_x86_64, // XMM15
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM,
+ lldb_sil_x86_64, // SIL
+ lldb_dil_x86_64, // DIL
+ lldb_bpl_x86_64, // BPL
+ lldb_spl_x86_64, // SPL
+ lldb_rax_x86_64, // RAX
+ lldb_rbx_x86_64, // RBX
+ lldb_rcx_x86_64, // RCX
+ lldb_rdx_x86_64, // RDX
+ lldb_rsi_x86_64, // RSI
+ lldb_rdi_x86_64, // RDI
+ lldb_rbp_x86_64, // RBP
+ lldb_rsp_x86_64, // RSP
+ lldb_r8_x86_64, // R8
+ lldb_r9_x86_64, // R9
+ lldb_r10_x86_64, // R10
+ lldb_r11_x86_64, // R11
+ lldb_r12_x86_64, // R12
+ lldb_r13_x86_64, // R13
+ lldb_r14_x86_64, // R14
+ lldb_r15_x86_64, // R15
+ lldb_r8l_x86_64, // R8B
+ lldb_r9l_x86_64, // R9B
+ lldb_r10l_x86_64, // R10B
+ lldb_r11l_x86_64, // R11B
+ lldb_r12l_x86_64, // R12B
+ lldb_r13l_x86_64, // R13B
+ lldb_r14l_x86_64, // R14B
+ lldb_r15l_x86_64, // R15B
+ lldb_r8w_x86_64, // R8W
+ lldb_r9w_x86_64, // R9W
+ lldb_r10w_x86_64, // R10W
+ lldb_r11w_x86_64, // R11W
+ lldb_r12w_x86_64, // R12W
+ lldb_r13w_x86_64, // R13W
+ lldb_r14w_x86_64, // R14W
+ lldb_r15w_x86_64, // R15W
+ lldb_r8d_x86_64, // R8D
+ lldb_r9d_x86_64, // R9D
+ lldb_r10d_x86_64, // R10D
+ lldb_r11d_x86_64, // R11D
+ lldb_r12d_x86_64, // R12D
+ lldb_r13d_x86_64, // R13D
+ lldb_r14d_x86_64, // R14D
+ lldb_r15d_x86_64, // R15D
+ lldb_ymm0_x86_64, // AMD64_YMM0
+ lldb_ymm1_x86_64, // AMD64_YMM1
+ lldb_ymm2_x86_64, // AMD64_YMM2
+ lldb_ymm3_x86_64, // AMD64_YMM3
+ lldb_ymm4_x86_64, // AMD64_YMM4
+ lldb_ymm5_x86_64, // AMD64_YMM5
+ lldb_ymm6_x86_64, // AMD64_YMM6
+ lldb_ymm7_x86_64, // AMD64_YMM7
+ lldb_ymm8_x86_64, // AMD64_YMM8
+ lldb_ymm9_x86_64, // AMD64_YMM9
+ lldb_ymm10_x86_64, // AMD64_YMM10
+ lldb_ymm11_x86_64, // AMD64_YMM11
+ lldb_ymm12_x86_64, // AMD64_YMM12
+ lldb_ymm13_x86_64, // AMD64_YMM13
+ lldb_ymm14_x86_64, // AMD64_YMM14
+ lldb_ymm15_x86_64, // AMD64_YMM15
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
+ lldb_bnd0_x86_64, // BND0
+ lldb_bnd1_x86_64, // BND1
+ lldb_bnd2_x86_64 // BND2
+};
+
+uint32_t lldb_private::npdb::GetLLDBRegisterNumber(
+ llvm::Triple::ArchType arch_type, llvm::codeview::RegisterId register_id) {
+ switch (arch_type) {
+ case llvm::Triple::x86:
+ if (static_cast<uint16_t>(register_id) <
+ sizeof(g_code_view_to_lldb_registers_x86) /
+ sizeof(g_code_view_to_lldb_registers_x86[0]))
+ return g_code_view_to_lldb_registers_x86[static_cast<uint16_t>(
+ register_id)];
+
+ switch (register_id) {
+ case llvm::codeview::RegisterId::MXCSR:
+ return lldb_mxcsr_i386;
+ case llvm::codeview::RegisterId::BND0:
+ return lldb_bnd0_i386;
+ case llvm::codeview::RegisterId::BND1:
+ return lldb_bnd1_i386;
+ case llvm::codeview::RegisterId::BND2:
+ return lldb_bnd2_i386;
+ default:
+ return LLDB_INVALID_REGNUM;
+ }
+ case llvm::Triple::x86_64:
+ if (static_cast<uint16_t>(register_id) <
+ sizeof(g_code_view_to_lldb_registers_x86_64) /
+ sizeof(g_code_view_to_lldb_registers_x86_64[0]))
+ return g_code_view_to_lldb_registers_x86_64[static_cast<uint16_t>(
+ register_id)];
+
+ return LLDB_INVALID_REGNUM;
+ default:
+ return LLDB_INVALID_REGNUM;
+ }
+}
diff --git a/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h b/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h
new file mode 100644
index 0000000000000..b1c31e0c17855
--- /dev/null
+++ b/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h
@@ -0,0 +1,24 @@
+//===-- CodeViewRegisterMapping.h -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_Plugins_SymbolFile_PDB_CodeViewRegisterMapping_h_
+#define lldb_Plugins_SymbolFile_PDB_CodeViewRegisterMapping_h_
+
+#include "llvm/ADT/Triple.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+
+namespace lldb_private {
+namespace npdb {
+
+uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type,
+ llvm::codeview::RegisterId register_id);
+
+} // namespace npdb
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
index 67ea05767fdee..1838204e4ca67 100644
--- a/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp
@@ -1,9 +1,8 @@
//===-- CompileUnitIndex.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -125,11 +124,20 @@ CompilandIndexItem &CompileUnitIndex::GetOrCreateCompiland(uint16_t modi) {
uint16_t stream = descriptor.getModuleStreamIndex();
std::unique_ptr<llvm::msf::MappedBlockStream> stream_data =
m_index.pdb().createIndexedStream(stream);
+
+
+ std::unique_ptr<CompilandIndexItem>& cci = result.first->second;
+
+ if (!stream_data) {
+ llvm::pdb::ModuleDebugStreamRef debug_stream(descriptor, nullptr);
+ cci = llvm::make_unique<CompilandIndexItem>(PdbCompilandId{ modi }, debug_stream, std::move(descriptor));
+ return *cci;
+ }
+
llvm::pdb::ModuleDebugStreamRef debug_stream(descriptor,
std::move(stream_data));
- cantFail(debug_stream.reload());
- std::unique_ptr<CompilandIndexItem> &cci = result.first->second;
+ cantFail(debug_stream.reload());
cci = llvm::make_unique<CompilandIndexItem>(
PdbCompilandId{modi}, std::move(debug_stream), std::move(descriptor));
diff --git a/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
index c965870da44b7..44a1c8cdd9c2f 100644
--- a/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
+++ b/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.h
@@ -1,9 +1,8 @@
//===-- CompileUnitIndex.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
index 7b62530e46807..3d8bfb0587217 100644
--- a/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
@@ -1,15 +1,13 @@
//===-- DWARFLocationExpression.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "DWARFLocationExpression.h"
-#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamBuffer.h"
@@ -24,6 +22,8 @@
#include "llvm/Support/Endian.h"
#include "PdbUtil.h"
+#include "CodeViewRegisterMapping.h"
+#include "PdbFPOProgramToDWARFExpression.h"
using namespace lldb;
using namespace lldb_private;
@@ -31,448 +31,6 @@ using namespace lldb_private::npdb;
using namespace llvm::codeview;
using namespace llvm::pdb;
-static const uint32_t g_code_view_to_lldb_registers_x86[] = {
- LLDB_INVALID_REGNUM, // NONE
- lldb_al_i386, // AL
- lldb_cl_i386, // CL
- lldb_dl_i386, // DL
- lldb_bl_i386, // BL
- lldb_ah_i386, // AH
- lldb_ch_i386, // CH
- lldb_dh_i386, // DH
- lldb_bh_i386, // BH
- lldb_ax_i386, // AX
- lldb_cx_i386, // CX
- lldb_dx_i386, // DX
- lldb_bx_i386, // BX
- lldb_sp_i386, // SP
- lldb_bp_i386, // BP
- lldb_si_i386, // SI
- lldb_di_i386, // DI
- lldb_eax_i386, // EAX
- lldb_ecx_i386, // ECX
- lldb_edx_i386, // EDX
- lldb_ebx_i386, // EBX
- lldb_esp_i386, // ESP
- lldb_ebp_i386, // EBP
- lldb_esi_i386, // ESI
- lldb_edi_i386, // EDI
- lldb_es_i386, // ES
- lldb_cs_i386, // CS
- lldb_ss_i386, // SS
- lldb_ds_i386, // DS
- lldb_fs_i386, // FS
- lldb_gs_i386, // GS
- LLDB_INVALID_REGNUM, // IP
- LLDB_INVALID_REGNUM, // FLAGS
- lldb_eip_i386, // EIP
- lldb_eflags_i386, // EFLAGS
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // TEMP
- LLDB_INVALID_REGNUM, // TEMPH
- LLDB_INVALID_REGNUM, // QUOTE
- LLDB_INVALID_REGNUM, // PCDR3
- LLDB_INVALID_REGNUM, // PCDR4
- LLDB_INVALID_REGNUM, // PCDR5
- LLDB_INVALID_REGNUM, // PCDR6
- LLDB_INVALID_REGNUM, // PCDR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // CR0
- LLDB_INVALID_REGNUM, // CR1
- LLDB_INVALID_REGNUM, // CR2
- LLDB_INVALID_REGNUM, // CR3
- LLDB_INVALID_REGNUM, // CR4
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_dr0_i386, // DR0
- lldb_dr1_i386, // DR1
- lldb_dr2_i386, // DR2
- lldb_dr3_i386, // DR3
- lldb_dr4_i386, // DR4
- lldb_dr5_i386, // DR5
- lldb_dr6_i386, // DR6
- lldb_dr7_i386, // DR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // GDTR
- LLDB_INVALID_REGNUM, // GDTL
- LLDB_INVALID_REGNUM, // IDTR
- LLDB_INVALID_REGNUM, // IDTL
- LLDB_INVALID_REGNUM, // LDTR
- LLDB_INVALID_REGNUM, // TR
- LLDB_INVALID_REGNUM, // PSEUDO1
- LLDB_INVALID_REGNUM, // PSEUDO2
- LLDB_INVALID_REGNUM, // PSEUDO3
- LLDB_INVALID_REGNUM, // PSEUDO4
- LLDB_INVALID_REGNUM, // PSEUDO5
- LLDB_INVALID_REGNUM, // PSEUDO6
- LLDB_INVALID_REGNUM, // PSEUDO7
- LLDB_INVALID_REGNUM, // PSEUDO8
- LLDB_INVALID_REGNUM, // PSEUDO9
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_st0_i386, // ST0
- lldb_st1_i386, // ST1
- lldb_st2_i386, // ST2
- lldb_st3_i386, // ST3
- lldb_st4_i386, // ST4
- lldb_st5_i386, // ST5
- lldb_st6_i386, // ST6
- lldb_st7_i386, // ST7
- LLDB_INVALID_REGNUM, // CTRL
- LLDB_INVALID_REGNUM, // STAT
- LLDB_INVALID_REGNUM, // TAG
- LLDB_INVALID_REGNUM, // FPIP
- LLDB_INVALID_REGNUM, // FPCS
- LLDB_INVALID_REGNUM, // FPDO
- LLDB_INVALID_REGNUM, // FPDS
- LLDB_INVALID_REGNUM, // ISEM
- LLDB_INVALID_REGNUM, // FPEIP
- LLDB_INVALID_REGNUM, // FPEDO
- lldb_mm0_i386, // MM0
- lldb_mm1_i386, // MM1
- lldb_mm2_i386, // MM2
- lldb_mm3_i386, // MM3
- lldb_mm4_i386, // MM4
- lldb_mm5_i386, // MM5
- lldb_mm6_i386, // MM6
- lldb_mm7_i386, // MM7
- lldb_xmm0_i386, // XMM0
- lldb_xmm1_i386, // XMM1
- lldb_xmm2_i386, // XMM2
- lldb_xmm3_i386, // XMM3
- lldb_xmm4_i386, // XMM4
- lldb_xmm5_i386, // XMM5
- lldb_xmm6_i386, // XMM6
- lldb_xmm7_i386 // XMM7
-};
-
-static const uint32_t g_code_view_to_lldb_registers_x86_64[] = {
- LLDB_INVALID_REGNUM, // NONE
- lldb_al_x86_64, // AL
- lldb_cl_x86_64, // CL
- lldb_dl_x86_64, // DL
- lldb_bl_x86_64, // BL
- lldb_ah_x86_64, // AH
- lldb_ch_x86_64, // CH
- lldb_dh_x86_64, // DH
- lldb_bh_x86_64, // BH
- lldb_ax_x86_64, // AX
- lldb_cx_x86_64, // CX
- lldb_dx_x86_64, // DX
- lldb_bx_x86_64, // BX
- lldb_sp_x86_64, // SP
- lldb_bp_x86_64, // BP
- lldb_si_x86_64, // SI
- lldb_di_x86_64, // DI
- lldb_eax_x86_64, // EAX
- lldb_ecx_x86_64, // ECX
- lldb_edx_x86_64, // EDX
- lldb_ebx_x86_64, // EBX
- lldb_esp_x86_64, // ESP
- lldb_ebp_x86_64, // EBP
- lldb_esi_x86_64, // ESI
- lldb_edi_x86_64, // EDI
- lldb_es_x86_64, // ES
- lldb_cs_x86_64, // CS
- lldb_ss_x86_64, // SS
- lldb_ds_x86_64, // DS
- lldb_fs_x86_64, // FS
- lldb_gs_x86_64, // GS
- LLDB_INVALID_REGNUM, // IP
- LLDB_INVALID_REGNUM, // FLAGS
- LLDB_INVALID_REGNUM, // EIP
- LLDB_INVALID_REGNUM, // EFLAGS
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // TEMP
- LLDB_INVALID_REGNUM, // TEMPH
- LLDB_INVALID_REGNUM, // QUOTE
- LLDB_INVALID_REGNUM, // PCDR3
- LLDB_INVALID_REGNUM, // PCDR4
- LLDB_INVALID_REGNUM, // PCDR5
- LLDB_INVALID_REGNUM, // PCDR6
- LLDB_INVALID_REGNUM, // PCDR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // CR0
- LLDB_INVALID_REGNUM, // CR1
- LLDB_INVALID_REGNUM, // CR2
- LLDB_INVALID_REGNUM, // CR3
- LLDB_INVALID_REGNUM, // CR4
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_dr0_x86_64, // DR0
- lldb_dr1_x86_64, // DR1
- lldb_dr2_x86_64, // DR2
- lldb_dr3_x86_64, // DR3
- lldb_dr4_x86_64, // DR4
- lldb_dr5_x86_64, // DR5
- lldb_dr6_x86_64, // DR6
- lldb_dr7_x86_64, // DR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // GDTR
- LLDB_INVALID_REGNUM, // GDTL
- LLDB_INVALID_REGNUM, // IDTR
- LLDB_INVALID_REGNUM, // IDTL
- LLDB_INVALID_REGNUM, // LDTR
- LLDB_INVALID_REGNUM, // TR
- LLDB_INVALID_REGNUM, // PSEUDO1
- LLDB_INVALID_REGNUM, // PSEUDO2
- LLDB_INVALID_REGNUM, // PSEUDO3
- LLDB_INVALID_REGNUM, // PSEUDO4
- LLDB_INVALID_REGNUM, // PSEUDO5
- LLDB_INVALID_REGNUM, // PSEUDO6
- LLDB_INVALID_REGNUM, // PSEUDO7
- LLDB_INVALID_REGNUM, // PSEUDO8
- LLDB_INVALID_REGNUM, // PSEUDO9
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_st0_x86_64, // ST0
- lldb_st1_x86_64, // ST1
- lldb_st2_x86_64, // ST2
- lldb_st3_x86_64, // ST3
- lldb_st4_x86_64, // ST4
- lldb_st5_x86_64, // ST5
- lldb_st6_x86_64, // ST6
- lldb_st7_x86_64, // ST7
- LLDB_INVALID_REGNUM, // CTRL
- LLDB_INVALID_REGNUM, // STAT
- LLDB_INVALID_REGNUM, // TAG
- LLDB_INVALID_REGNUM, // FPIP
- LLDB_INVALID_REGNUM, // FPCS
- LLDB_INVALID_REGNUM, // FPDO
- LLDB_INVALID_REGNUM, // FPDS
- LLDB_INVALID_REGNUM, // ISEM
- LLDB_INVALID_REGNUM, // FPEIP
- LLDB_INVALID_REGNUM, // FPEDO
- lldb_mm0_x86_64, // MM0
- lldb_mm1_x86_64, // MM1
- lldb_mm2_x86_64, // MM2
- lldb_mm3_x86_64, // MM3
- lldb_mm4_x86_64, // MM4
- lldb_mm5_x86_64, // MM5
- lldb_mm6_x86_64, // MM6
- lldb_mm7_x86_64, // MM7
- lldb_xmm0_x86_64, // XMM0
- lldb_xmm1_x86_64, // XMM1
- lldb_xmm2_x86_64, // XMM2
- lldb_xmm3_x86_64, // XMM3
- lldb_xmm4_x86_64, // XMM4
- lldb_xmm5_x86_64, // XMM5
- lldb_xmm6_x86_64, // XMM6
- lldb_xmm7_x86_64, // XMM7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM,
- lldb_mxcsr_x86_64, // MXCSR
- LLDB_INVALID_REGNUM, // EDXEAX
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // EMM0L
- LLDB_INVALID_REGNUM, // EMM1L
- LLDB_INVALID_REGNUM, // EMM2L
- LLDB_INVALID_REGNUM, // EMM3L
- LLDB_INVALID_REGNUM, // EMM4L
- LLDB_INVALID_REGNUM, // EMM5L
- LLDB_INVALID_REGNUM, // EMM6L
- LLDB_INVALID_REGNUM, // EMM7L
- LLDB_INVALID_REGNUM, // EMM0H
- LLDB_INVALID_REGNUM, // EMM1H
- LLDB_INVALID_REGNUM, // EMM2H
- LLDB_INVALID_REGNUM, // EMM3H
- LLDB_INVALID_REGNUM, // EMM4H
- LLDB_INVALID_REGNUM, // EMM5H
- LLDB_INVALID_REGNUM, // EMM6H
- LLDB_INVALID_REGNUM, // EMM7H
- LLDB_INVALID_REGNUM, // MM00
- LLDB_INVALID_REGNUM, // MM01
- LLDB_INVALID_REGNUM, // MM10
- LLDB_INVALID_REGNUM, // MM11
- LLDB_INVALID_REGNUM, // MM20
- LLDB_INVALID_REGNUM, // MM21
- LLDB_INVALID_REGNUM, // MM30
- LLDB_INVALID_REGNUM, // MM31
- LLDB_INVALID_REGNUM, // MM40
- LLDB_INVALID_REGNUM, // MM41
- LLDB_INVALID_REGNUM, // MM50
- LLDB_INVALID_REGNUM, // MM51
- LLDB_INVALID_REGNUM, // MM60
- LLDB_INVALID_REGNUM, // MM61
- LLDB_INVALID_REGNUM, // MM70
- LLDB_INVALID_REGNUM, // MM71
- lldb_xmm8_x86_64, // XMM8
- lldb_xmm9_x86_64, // XMM9
- lldb_xmm10_x86_64, // XMM10
- lldb_xmm11_x86_64, // XMM11
- lldb_xmm12_x86_64, // XMM12
- lldb_xmm13_x86_64, // XMM13
- lldb_xmm14_x86_64, // XMM14
- lldb_xmm15_x86_64, // XMM15
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM,
- lldb_sil_x86_64, // SIL
- lldb_dil_x86_64, // DIL
- lldb_bpl_x86_64, // BPL
- lldb_spl_x86_64, // SPL
- lldb_rax_x86_64, // RAX
- lldb_rbx_x86_64, // RBX
- lldb_rcx_x86_64, // RCX
- lldb_rdx_x86_64, // RDX
- lldb_rsi_x86_64, // RSI
- lldb_rdi_x86_64, // RDI
- lldb_rbp_x86_64, // RBP
- lldb_rsp_x86_64, // RSP
- lldb_r8_x86_64, // R8
- lldb_r9_x86_64, // R9
- lldb_r10_x86_64, // R10
- lldb_r11_x86_64, // R11
- lldb_r12_x86_64, // R12
- lldb_r13_x86_64, // R13
- lldb_r14_x86_64, // R14
- lldb_r15_x86_64, // R15
- lldb_r8l_x86_64, // R8B
- lldb_r9l_x86_64, // R9B
- lldb_r10l_x86_64, // R10B
- lldb_r11l_x86_64, // R11B
- lldb_r12l_x86_64, // R12B
- lldb_r13l_x86_64, // R13B
- lldb_r14l_x86_64, // R14B
- lldb_r15l_x86_64, // R15B
- lldb_r8w_x86_64, // R8W
- lldb_r9w_x86_64, // R9W
- lldb_r10w_x86_64, // R10W
- lldb_r11w_x86_64, // R11W
- lldb_r12w_x86_64, // R12W
- lldb_r13w_x86_64, // R13W
- lldb_r14w_x86_64, // R14W
- lldb_r15w_x86_64, // R15W
- lldb_r8d_x86_64, // R8D
- lldb_r9d_x86_64, // R9D
- lldb_r10d_x86_64, // R10D
- lldb_r11d_x86_64, // R11D
- lldb_r12d_x86_64, // R12D
- lldb_r13d_x86_64, // R13D
- lldb_r14d_x86_64, // R14D
- lldb_r15d_x86_64, // R15D
- lldb_ymm0_x86_64, // AMD64_YMM0
- lldb_ymm1_x86_64, // AMD64_YMM1
- lldb_ymm2_x86_64, // AMD64_YMM2
- lldb_ymm3_x86_64, // AMD64_YMM3
- lldb_ymm4_x86_64, // AMD64_YMM4
- lldb_ymm5_x86_64, // AMD64_YMM5
- lldb_ymm6_x86_64, // AMD64_YMM6
- lldb_ymm7_x86_64, // AMD64_YMM7
- lldb_ymm8_x86_64, // AMD64_YMM8
- lldb_ymm9_x86_64, // AMD64_YMM9
- lldb_ymm10_x86_64, // AMD64_YMM10
- lldb_ymm11_x86_64, // AMD64_YMM11
- lldb_ymm12_x86_64, // AMD64_YMM12
- lldb_ymm13_x86_64, // AMD64_YMM13
- lldb_ymm14_x86_64, // AMD64_YMM14
- lldb_ymm15_x86_64, // AMD64_YMM15
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_bnd0_x86_64, // BND0
- lldb_bnd1_x86_64, // BND1
- lldb_bnd2_x86_64 // BND2
-};
-
-uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type,
- llvm::codeview::RegisterId register_id) {
- switch (arch_type) {
- case llvm::Triple::x86:
- if (static_cast<uint16_t>(register_id) <
- sizeof(g_code_view_to_lldb_registers_x86) /
- sizeof(g_code_view_to_lldb_registers_x86[0]))
- return g_code_view_to_lldb_registers_x86[static_cast<uint16_t>(
- register_id)];
-
- switch (register_id) {
- case llvm::codeview::RegisterId::MXCSR:
- return lldb_mxcsr_i386;
- case llvm::codeview::RegisterId::BND0:
- return lldb_bnd0_i386;
- case llvm::codeview::RegisterId::BND1:
- return lldb_bnd1_i386;
- case llvm::codeview::RegisterId::BND2:
- return lldb_bnd2_i386;
- default:
- return LLDB_INVALID_REGNUM;
- }
- case llvm::Triple::x86_64:
- if (static_cast<uint16_t>(register_id) <
- sizeof(g_code_view_to_lldb_registers_x86_64) /
- sizeof(g_code_view_to_lldb_registers_x86_64[0]))
- return g_code_view_to_lldb_registers_x86_64[static_cast<uint16_t>(
- register_id)];
-
- return LLDB_INVALID_REGNUM;
- default:
- return LLDB_INVALID_REGNUM;
- }
-}
-
uint32_t GetGenericRegisterNumber(llvm::codeview::RegisterId register_id) {
if (register_id == llvm::codeview::RegisterId::VFRAME)
return LLDB_REGNUM_GENERIC_FP;
@@ -553,13 +111,13 @@ static DWARFExpression MakeLocationExpressionInternal(lldb::ModuleSP module,
uint32_t address_size = architecture.GetAddressByteSize();
uint32_t byte_size = architecture.GetDataByteSize();
if (byte_order == eByteOrderInvalid || address_size == 0)
- return DWARFExpression(nullptr);
+ return DWARFExpression();
RegisterKind register_kind = eRegisterKindDWARF;
StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order);
if (!writer(stream, register_kind))
- return DWARFExpression(nullptr);
+ return DWARFExpression();
DataBufferSP buffer =
std::make_shared<DataBufferHeap>(stream.GetData(), stream.GetSize());
@@ -610,6 +168,33 @@ DWARFExpression lldb_private::npdb::MakeRegRelLocationExpression(
return MakeRegisterBasedLocationExpressionInternal(reg, offset, module);
}
+static bool EmitVFrameEvaluationDWARFExpression(
+ llvm::StringRef program, llvm::Triple::ArchType arch_type, Stream &stream) {
+ // VFrame value always stored in $TO pseudo-register
+ return TranslateFPOProgramToDWARFExpression(program, "$T0", arch_type,
+ stream);
+}
+
+DWARFExpression lldb_private::npdb::MakeVFrameRelLocationExpression(
+ llvm::StringRef fpo_program, int32_t offset, lldb::ModuleSP module) {
+ return MakeLocationExpressionInternal(
+ module, [&](Stream &stream, RegisterKind &register_kind) -> bool {
+ const ArchSpec &architecture = module->GetArchitecture();
+
+ if (!EmitVFrameEvaluationDWARFExpression(fpo_program, architecture.GetMachine(),
+ stream))
+ return false;
+
+ stream.PutHex8(llvm::dwarf::DW_OP_consts);
+ stream.PutSLEB128(offset);
+ stream.PutHex8(llvm::dwarf::DW_OP_plus);
+
+ register_kind = eRegisterKindLLDB;
+
+ return true;
+ });
+}
+
DWARFExpression lldb_private::npdb::MakeGlobalLocationExpression(
uint16_t section, uint32_t offset, ModuleSP module) {
assert(section > 0);
@@ -622,13 +207,7 @@ DWARFExpression lldb_private::npdb::MakeGlobalLocationExpression(
SectionList *section_list = module->GetSectionList();
assert(section_list);
- // Section indices in PDB are 1-based, but in DWARF they are 0-based, so
- // we need to subtract 1.
- uint32_t section_idx = section - 1;
- if (section_idx >= section_list->GetSize())
- return false;
-
- auto section_ptr = section_list->GetSectionAtIndex(section_idx);
+ auto section_ptr = section_list->FindSectionByID(section);
if (!section_ptr)
return false;
diff --git a/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
index 670e95ee8e3c0..c37d715babdc6 100644
--- a/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
+++ b/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
@@ -1,9 +1,8 @@
//===-- DWARFLocationExpression.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,6 +30,9 @@ MakeEnregisteredLocationExpression(llvm::codeview::RegisterId reg,
DWARFExpression MakeRegRelLocationExpression(llvm::codeview::RegisterId reg,
int32_t offset,
lldb::ModuleSP module);
+DWARFExpression MakeVFrameRelLocationExpression(llvm::StringRef fpo_program,
+ int32_t offset,
+ lldb::ModuleSP module);
DWARFExpression MakeGlobalLocationExpression(uint16_t section, uint32_t offset,
lldb::ModuleSP module);
DWARFExpression MakeConstantLocationExpression(
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
index 8917fd092385d..4991be8e70ced 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp
@@ -205,13 +205,17 @@ GetNestedTagDefinition(const NestedTypeRecord &Record,
return std::move(child);
}
+static bool IsAnonymousNamespaceName(llvm::StringRef name) {
+ return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
+}
+
PdbAstBuilder::PdbAstBuilder(ObjectFile &obj, PdbIndex &index)
: m_index(index), m_clang(GetClangASTContext(obj)) {
BuildParentMap();
}
-clang::DeclContext &PdbAstBuilder::GetTranslationUnitDecl() {
- return *m_clang.GetTranslationUnitDecl();
+lldb_private::CompilerDeclContext PdbAstBuilder::GetTranslationUnitDecl() {
+ return ToCompilerDeclContext(*m_clang.GetTranslationUnitDecl());
}
std::pair<clang::DeclContext *, std::string>
@@ -256,7 +260,7 @@ PdbAstBuilder::CreateDeclInfoForType(const TagRecord &record, TypeIndex ti) {
for (llvm::ms_demangle::Node *scope : scopes) {
auto *nii = static_cast<llvm::ms_demangle::NamedIdentifierNode *>(scope);
std::string str = nii->toString();
- context = m_clang.GetUniqueNamespaceDeclaration(str.c_str(), context);
+ context = GetOrCreateNamespaceDecl(str.c_str(), *context);
}
return {context, uname};
}
@@ -488,7 +492,7 @@ clang::Decl *PdbAstBuilder::GetOrCreateDeclForUid(PdbSymUid uid) {
clang::DeclContext *PdbAstBuilder::GetOrCreateDeclContextForUid(PdbSymUid uid) {
if (uid.kind() == PdbSymUidKind::CompilandSym) {
if (uid.asCompilandSym().offset == 0)
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
}
clang::Decl *decl = GetOrCreateDeclForUid(uid);
@@ -503,7 +507,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
MSVCUndecoratedNameParser parser(name);
llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
- clang::DeclContext *context = &GetTranslationUnitDecl();
+ auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
llvm::StringRef uname = specs.back().GetBaseName();
specs = specs.drop_back();
@@ -525,7 +529,7 @@ PdbAstBuilder::CreateDeclInfoForUndecoratedName(llvm::StringRef name) {
// If that fails, treat it as a series of namespaces.
for (const MSVCUndecoratedNameSpecifier &spec : specs) {
std::string ns_name = spec.GetBaseName().str();
- context = m_clang.GetUniqueNamespaceDeclaration(ns_name.c_str(), context);
+ context = GetOrCreateNamespaceDecl(ns_name.c_str(), *context);
}
return {context, uname};
}
@@ -544,7 +548,7 @@ PdbAstBuilder::GetParentDeclContextForSymbol(const CVSymbol &sym) {
StringView name{pub->Name.begin(), pub->Name.size()};
llvm::ms_demangle::SymbolNode *node = demangler.parse(name);
if (!node)
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
llvm::ArrayRef<llvm::ms_demangle::Node *> name_components{
node->Name->Components->Nodes, node->Name->Components->Count - 1};
@@ -565,10 +569,10 @@ PdbAstBuilder::GetParentDeclContextForSymbol(const CVSymbol &sym) {
}
// It's not a type. It must be a series of namespaces.
- clang::DeclContext *context = &GetTranslationUnitDecl();
+ auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
while (!name_components.empty()) {
std::string ns = name_components.front()->toString();
- context = m_clang.GetUniqueNamespaceDeclaration(ns.c_str(), context);
+ context = GetOrCreateNamespaceDecl(ns.c_str(), *context);
name_components = name_components.drop_front();
}
return context;
@@ -593,7 +597,7 @@ clang::DeclContext *PdbAstBuilder::GetParentDeclContext(PdbSymUid uid) {
PdbTypeSymId type_id = uid.asTypeSym();
auto iter = m_parent_types.find(type_id.index);
if (iter == m_parent_types.end())
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
return GetOrCreateDeclContextForUid(PdbTypeSymId(iter->second));
}
case PdbSymUidKind::FieldListMember:
@@ -631,7 +635,7 @@ clang::DeclContext *PdbAstBuilder::GetParentDeclContext(PdbSymUid uid) {
default:
break;
}
- return &GetTranslationUnitDecl();
+ return FromCompilerDeclContext(GetTranslationUnitDecl());
}
bool PdbAstBuilder::CompleteType(clang::QualType qt) {
@@ -805,9 +809,10 @@ clang::Decl *PdbAstBuilder::TryGetDecl(PdbSymUid uid) const {
}
clang::NamespaceDecl *
-PdbAstBuilder::GetOrCreateNamespaceDecl(llvm::StringRef name,
+PdbAstBuilder::GetOrCreateNamespaceDecl(const char *name,
clang::DeclContext &context) {
- return m_clang.GetUniqueNamespaceDeclaration(name.str().c_str(), &context);
+ return m_clang.GetUniqueNamespaceDeclaration(
+ IsAnonymousNamespaceName(name) ? nullptr : name, &context);
}
clang::BlockDecl *
@@ -861,7 +866,8 @@ clang::VarDecl *PdbAstBuilder::GetOrCreateVariableDecl(PdbGlobalSymId var_id) {
return llvm::dyn_cast<clang::VarDecl>(decl);
CVSymbol sym = m_index.ReadSymbolRecord(var_id);
- return CreateVariableDecl(PdbSymUid(var_id), sym, GetTranslationUnitDecl());
+ auto context = FromCompilerDeclContext(GetTranslationUnitDecl());
+ return CreateVariableDecl(PdbSymUid(var_id), sym, *context);
}
clang::TypedefNameDecl *
@@ -933,7 +939,14 @@ clang::QualType PdbAstBuilder::CreateType(PdbTypeSymId type) {
if (cvt.kind() == LF_PROCEDURE) {
ProcedureRecord pr;
llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
- return CreateProcedureType(pr);
+ return CreateFunctionType(pr.ArgumentList, pr.ReturnType, pr.CallConv);
+ }
+
+ if (cvt.kind() == LF_MFUNCTION) {
+ MemberFunctionRecord mfr;
+ llvm::cantFail(
+ TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
+ return CreateFunctionType(mfr.ArgumentList, mfr.ReturnType, mfr.CallConv);
}
return {};
@@ -1117,10 +1130,11 @@ clang::QualType PdbAstBuilder::CreateArrayType(const ArrayRecord &ar) {
return clang::QualType::getFromOpaquePtr(array_ct.GetOpaqueQualType());
}
-clang::QualType
-PdbAstBuilder::CreateProcedureType(const ProcedureRecord &proc) {
+clang::QualType PdbAstBuilder::CreateFunctionType(
+ TypeIndex args_type_idx, TypeIndex return_type_idx,
+ llvm::codeview::CallingConvention calling_convention) {
TpiStream &stream = m_index.tpi();
- CVType args_cvt = stream.getType(proc.ArgumentList);
+ CVType args_cvt = stream.getType(args_type_idx);
ArgListRecord args;
llvm::cantFail(
TypeDeserializer::deserializeAs<ArgListRecord>(args_cvt, args));
@@ -1138,10 +1152,10 @@ PdbAstBuilder::CreateProcedureType(const ProcedureRecord &proc) {
arg_types.push_back(ToCompilerType(arg_type));
}
- clang::QualType return_type = GetOrCreateType(proc.ReturnType);
+ clang::QualType return_type = GetOrCreateType(return_type_idx);
llvm::Optional<clang::CallingConv> cc =
- TranslateCallingConvention(proc.CallConv);
+ TranslateCallingConvention(calling_convention);
if (!cc)
return {};
@@ -1340,6 +1354,10 @@ PdbAstBuilder::ToCompilerDeclContext(clang::DeclContext &context) {
return {&m_clang, &context};
}
+clang::Decl * PdbAstBuilder::FromCompilerDecl(CompilerDecl decl) {
+ return static_cast<clang::Decl *>(decl.GetOpaqueDecl());
+}
+
clang::DeclContext *
PdbAstBuilder::FromCompilerDeclContext(CompilerDeclContext context) {
return static_cast<clang::DeclContext *>(context.GetOpaqueDeclContext());
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
index e3c0346f935eb..67d024741e0db 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
+++ b/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.h
@@ -1,9 +1,8 @@
//===-- PdbAstBuilder.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -51,19 +50,15 @@ struct DeclStatus {
class PdbAstBuilder {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
PdbAstBuilder(ObjectFile &obj, PdbIndex &index);
- clang::DeclContext &GetTranslationUnitDecl();
+ lldb_private::CompilerDeclContext GetTranslationUnitDecl();
clang::Decl *GetOrCreateDeclForUid(PdbSymUid uid);
clang::DeclContext *GetOrCreateDeclContextForUid(PdbSymUid uid);
clang::DeclContext *GetParentDeclContext(PdbSymUid uid);
- clang::NamespaceDecl *GetOrCreateNamespaceDecl(llvm::StringRef name,
- clang::DeclContext &context);
clang::FunctionDecl *GetOrCreateFunctionDecl(PdbCompilandSymId func_id);
clang::BlockDecl *GetOrCreateBlockDecl(PdbCompilandSymId block_id);
clang::VarDecl *GetOrCreateVariableDecl(PdbCompilandSymId scope_id,
@@ -81,6 +76,7 @@ public:
CompilerDecl ToCompilerDecl(clang::Decl &decl);
CompilerType ToCompilerType(clang::QualType qt);
CompilerDeclContext ToCompilerDeclContext(clang::DeclContext &context);
+ clang::Decl * FromCompilerDecl(CompilerDecl decl);
clang::DeclContext *FromCompilerDeclContext(CompilerDeclContext context);
ClangASTContext &clang() { return m_clang; }
@@ -103,7 +99,8 @@ private:
clang::QualType CreateEnumType(PdbTypeSymId id,
const llvm::codeview::EnumRecord &record);
clang::QualType
- CreateProcedureType(const llvm::codeview::ProcedureRecord &proc);
+ CreateFunctionType(TypeIndex args_type_idx, TypeIndex return_type_idx,
+ llvm::codeview::CallingConvention calling_convention);
clang::QualType CreateType(PdbTypeSymId type);
void CreateFunctionParameters(PdbCompilandSymId func_id,
@@ -116,6 +113,9 @@ private:
clang::DeclContext *
GetParentDeclContextForSymbol(const llvm::codeview::CVSymbol &sym);
+ clang::NamespaceDecl *GetOrCreateNamespaceDecl(const char *name,
+ clang::DeclContext &context);
+
void ParseAllNamespacesPlusChildrenOf(llvm::Optional<llvm::StringRef> parent);
void ParseDeclsForSimpleContext(clang::DeclContext &context);
void ParseBlockChildren(PdbCompilandSymId block_id);
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp b/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
new file mode 100644
index 0000000000000..79dd010ff3119
--- /dev/null
+++ b/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.cpp
@@ -0,0 +1,137 @@
+//===-- PdbFPOProgramToDWARFExpression.cpp ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "PdbFPOProgramToDWARFExpression.h"
+#include "CodeViewRegisterMapping.h"
+
+#include "lldb/Core/StreamBuffer.h"
+#include "lldb/Symbol/PostfixExpression.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/ADT/DenseMap.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/CodeView/EnumTables.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::postfix;
+
+static uint32_t ResolveLLDBRegisterNum(llvm::StringRef reg_name, llvm::Triple::ArchType arch_type) {
+ // lookup register name to get lldb register number
+ llvm::codeview::CPUType cpu_type;
+ switch (arch_type) {
+ case llvm::Triple::ArchType::aarch64:
+ cpu_type = llvm::codeview::CPUType::ARM64;
+ break;
+
+ default:
+ cpu_type = llvm::codeview::CPUType::X64;
+ break;
+ }
+
+ llvm::ArrayRef<llvm::EnumEntry<uint16_t>> register_names =
+ llvm::codeview::getRegisterNames(cpu_type);
+ auto it = llvm::find_if(
+ register_names,
+ [&reg_name](const llvm::EnumEntry<uint16_t> &register_entry) {
+ return reg_name.compare_lower(register_entry.Name) == 0;
+ });
+
+ if (it == register_names.end())
+ return LLDB_INVALID_REGNUM;
+
+ auto reg_id = static_cast<llvm::codeview::RegisterId>(it->Value);
+ return npdb::GetLLDBRegisterNumber(arch_type, reg_id);
+}
+
+static bool ParseFPOSingleAssignmentProgram(llvm::StringRef program,
+ llvm::BumpPtrAllocator &alloc,
+ llvm::StringRef &register_name,
+ Node *&ast) {
+ // lvalue of assignment is always first token
+ // rvalue program goes next
+ std::tie(register_name, program) = getToken(program);
+ if (register_name.empty())
+ return false;
+
+ ast = Parse(program, alloc);
+ return ast != nullptr;
+}
+
+static Node *ParseFPOProgram(llvm::StringRef program,
+ llvm::StringRef register_name,
+ llvm::Triple::ArchType arch_type,
+ llvm::BumpPtrAllocator &alloc) {
+ llvm::DenseMap<llvm::StringRef, Node *> dependent_programs;
+
+ size_t cur = 0;
+ while (true) {
+ size_t assign_index = program.find('=', cur);
+ if (assign_index == llvm::StringRef::npos) {
+ llvm::StringRef tail = program.slice(cur, llvm::StringRef::npos);
+ if (!tail.trim().empty()) {
+ // missing assign operator
+ return nullptr;
+ }
+ break;
+ }
+ llvm::StringRef assignment_program = program.slice(cur, assign_index);
+
+ llvm::StringRef lvalue_name;
+ Node *rvalue_ast = nullptr;
+ if (!ParseFPOSingleAssignmentProgram(assignment_program, alloc, lvalue_name,
+ rvalue_ast)) {
+ return nullptr;
+ }
+
+ lldbassert(rvalue_ast);
+
+ // Emplace valid dependent subtrees to make target assignment independent
+ // from predecessors. Resolve all other SymbolNodes as registers.
+ bool success =
+ ResolveSymbols(rvalue_ast, [&](SymbolNode &symbol) -> Node * {
+ if (Node *node = dependent_programs.lookup(symbol.GetName()))
+ return node;
+ uint32_t reg_num =
+ ResolveLLDBRegisterNum(symbol.GetName().drop_front(1), arch_type);
+
+ if (reg_num == LLDB_INVALID_REGNUM)
+ return nullptr;
+
+ return MakeNode<RegisterNode>(alloc, reg_num);
+ });
+ if (!success)
+ return nullptr;
+
+ if (lvalue_name == register_name) {
+ // found target assignment program - no need to parse further
+ return rvalue_ast;
+ }
+
+ dependent_programs[lvalue_name] = rvalue_ast;
+ cur = assign_index + 1;
+ }
+
+ return nullptr;
+}
+
+bool lldb_private::npdb::TranslateFPOProgramToDWARFExpression(
+ llvm::StringRef program, llvm::StringRef register_name,
+ llvm::Triple::ArchType arch_type, Stream &stream) {
+ llvm::BumpPtrAllocator node_alloc;
+ Node *target_program =
+ ParseFPOProgram(program, register_name, arch_type, node_alloc);
+ if (target_program == nullptr) {
+ return false;
+ }
+
+ ToDWARF(*target_program, stream);
+ return true;
+}
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h b/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h
new file mode 100644
index 0000000000000..107e26fb04cb1
--- /dev/null
+++ b/source/Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h
@@ -0,0 +1,28 @@
+//===-- PdbFPOProgramToDWARFExpression.h ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef lldb_Plugins_SymbolFile_PDB_PDBFPOProgramToDWARFExpression_h_
+#define lldb_Plugins_SymbolFile_PDB_PDBFPOProgramToDWARFExpression_h_
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
+
+namespace lldb_private {
+class Stream;
+
+namespace npdb {
+
+bool TranslateFPOProgramToDWARFExpression(llvm::StringRef program,
+ llvm::StringRef register_name,
+ llvm::Triple::ArchType arch_type,
+ lldb_private::Stream &stream);
+
+} // namespace npdb
+} // namespace lldb_private
+
+#endif
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp b/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
index 9f5dab6c2e840..ba9a95b16e18d 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
@@ -1,9 +1,8 @@
//===-- PdbIndex.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -133,9 +132,8 @@ void PdbIndex::BuildAddrToSymbolMap(CompilandIndexItem &cci) {
PdbCompilandSymId cu_sym_id(modi, iter.offset());
- // If the debug info is incorrect, we could have multiple symbols with the
- // same address. So use try_emplace instead of insert, and the first one
- // will win.
+ // It's rare, but we could have multiple symbols with the same address
+ // because of identical comdat folding. Right now, the first one will win.
cci.m_symbols_by_va.insert(std::make_pair(va, PdbSymUid(cu_sym_id)));
}
}
@@ -187,8 +185,6 @@ std::vector<SymbolAndUid> PdbIndex::FindSymbolsByVa(lldb::addr_t va) {
}
CVSymbol PdbIndex::ReadSymbolRecord(PdbCompilandSymId cu_sym) const {
- // We need to subtract 4 here to adjust for the codeview debug magic
- // at the beginning of the debug info stream.
const CompilandIndexItem *cci = compilands().GetCompiland(cu_sym.modi);
auto iter = cci->m_debug_stream.getSymbolArray().at(cu_sym.offset);
lldbassert(iter != cci->m_debug_stream.getSymbolArray().end());
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbIndex.h b/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
index 839d4e6606e42..b30e7870bbdb3 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
+++ b/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
@@ -1,9 +1,8 @@
//===-- PdbIndex.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -115,6 +114,7 @@ public:
create(std::unique_ptr<llvm::pdb::PDBFile>);
void SetLoadAddress(lldb::addr_t addr) { m_load_address = addr; }
+ lldb::addr_t GetLoadAddress() const { return m_load_address; }
void ParseSectionContribs();
llvm::pdb::PDBFile &pdb() { return *m_file; }
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp
index e5424568da474..e5ad23f813eb0 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.cpp
@@ -1,9 +1,8 @@
//===-- PdbSymUid.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
index 1166bee4e3270..7252d63c1ab4e 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
+++ b/source/Plugins/SymbolFile/NativePDB/PdbSymUid.h
@@ -1,9 +1,8 @@
//===-- PdbSymUid.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// A unique identification scheme for Pdb records.
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp b/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
index 317725dd250e0..1f5c97da81cfc 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
@@ -1,9 +1,8 @@
//===-- PdbUtil.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,9 +14,11 @@
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
+#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
#include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h"
+#include "lldb/Symbol/Block.h"
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/lldb-enumerations.h"
@@ -43,7 +44,7 @@ MakeRangeList(const PdbIndex &index, const LocalVariableAddrRange &range,
gaps = gaps.drop_front();
}
- result.Append(start, end);
+ result.Append(start, end - start);
return result;
}
@@ -507,8 +508,78 @@ VariableInfo lldb_private::npdb::GetVariableNameInfo(CVSymbol sym) {
return {};
}
+static llvm::FixedStreamArray<FrameData>::Iterator
+GetCorrespondingFrameData(lldb::addr_t load_addr,
+ const DebugFrameDataSubsectionRef &fpo_data,
+ const Variable::RangeList &ranges) {
+ lldbassert(!ranges.IsEmpty());
+
+ // assume that all variable ranges correspond to one frame data
+ using RangeListEntry = Variable::RangeList::Entry;
+ const RangeListEntry &range = ranges.GetEntryRef(0);
+
+ auto it = fpo_data.begin();
+
+ // start by searching first frame data range containing variable range
+ for (; it != fpo_data.end(); ++it) {
+ RangeListEntry fd_range(load_addr + it->RvaStart, it->CodeSize);
+
+ if (fd_range.Contains(range)) {
+ break;
+ }
+ }
+
+ // then first most nested entry that still contains variable range
+ auto found = it;
+ for (; it != fpo_data.end(); ++it) {
+ RangeListEntry fd_range(load_addr + it->RvaStart, it->CodeSize);
+
+ if (!fd_range.Contains(range)) {
+ break;
+ }
+ found = it;
+ }
+
+ return found;
+}
+
+static bool GetFrameDataProgram(PdbIndex &index,
+ const Variable::RangeList &ranges,
+ llvm::StringRef &out_program) {
+ const DebugFrameDataSubsectionRef &new_fpo_data =
+ index.dbi().getNewFpoRecords();
+
+ auto frame_data_it =
+ GetCorrespondingFrameData(index.GetLoadAddress(), new_fpo_data, ranges);
+ if (frame_data_it == new_fpo_data.end())
+ return false;
+
+ PDBStringTable &strings = cantFail(index.pdb().getStringTable());
+ out_program = cantFail(strings.getStringForID(frame_data_it->FrameFunc));
+ return true;
+}
+
+static RegisterId GetBaseFrameRegister(PdbIndex &index,
+ PdbCompilandSymId frame_proc_id,
+ bool is_parameter) {
+ CVSymbol frame_proc_cvs = index.ReadSymbolRecord(frame_proc_id);
+ lldbassert(frame_proc_cvs.kind() == S_FRAMEPROC);
+
+ FrameProcSym frame_proc(SymbolRecordKind::FrameProcSym);
+ cantFail(SymbolDeserializer::deserializeAs<FrameProcSym>(frame_proc_cvs,
+ frame_proc));
+
+ CPUType cpu_type = index.compilands()
+ .GetCompiland(frame_proc_id.modi)
+ ->m_compile_opts->Machine;
+
+ return is_parameter ? frame_proc.getParamFramePtrReg(cpu_type)
+ : frame_proc.getLocalFramePtrReg(cpu_type);
+}
+
VariableInfo lldb_private::npdb::GetVariableLocationInfo(
- PdbIndex &index, PdbCompilandSymId var_id, lldb::ModuleSP module) {
+ PdbIndex &index, PdbCompilandSymId var_id, Block &block,
+ lldb::ModuleSP module) {
CVSymbol sym = index.ReadSymbolRecord(var_id);
@@ -543,13 +614,69 @@ VariableInfo lldb_private::npdb::GetVariableLocationInfo(
SymbolRecordKind::DefRangeFramePointerRelSym);
cantFail(SymbolDeserializer::deserializeAs<DefRangeFramePointerRelSym>(
loc_specifier_cvs, loc));
- // FIXME: The register needs to come from the S_FRAMEPROC symbol.
- result.location =
- MakeRegRelLocationExpression(RegisterId::RSP, loc.Offset, module);
- result.ranges = MakeRangeList(index, loc.Range, loc.Gaps);
- } else {
- // FIXME: Handle other kinds
+
+ Variable::RangeList ranges = MakeRangeList(index, loc.Range, loc.Gaps);
+
+ // TODO: may be better to pass function scope and not lookup it every
+ // time? find nearest parent function block
+ Block *cur = &block;
+ while (cur->GetParent()) {
+ cur = cur->GetParent();
+ }
+ PdbCompilandSymId func_scope_id =
+ PdbSymUid(cur->GetID()).asCompilandSym();
+ CVSymbol func_block_cvs = index.ReadSymbolRecord(func_scope_id);
+ lldbassert(func_block_cvs.kind() == S_GPROC32 ||
+ func_block_cvs.kind() == S_LPROC32);
+
+ PdbCompilandSymId frame_proc_id(
+ func_scope_id.modi, func_scope_id.offset + func_block_cvs.length());
+
+ bool is_parameter =
+ ((local.Flags & LocalSymFlags::IsParameter) != LocalSymFlags::None);
+ RegisterId base_reg =
+ GetBaseFrameRegister(index, frame_proc_id, is_parameter);
+
+ if (base_reg == RegisterId::VFRAME) {
+ llvm::StringRef program;
+ if (GetFrameDataProgram(index, ranges, program)) {
+ result.location =
+ MakeVFrameRelLocationExpression(program, loc.Offset, module);
+ result.ranges = std::move(ranges);
+ } else {
+ // invalid variable
+ }
+ } else {
+ result.location =
+ MakeRegRelLocationExpression(base_reg, loc.Offset, module);
+ result.ranges = std::move(ranges);
+ }
+ } else if (loc_specifier_cvs.kind() == S_DEFRANGE_REGISTER_REL) {
+ DefRangeRegisterRelSym loc(SymbolRecordKind::DefRangeRegisterRelSym);
+ cantFail(SymbolDeserializer::deserializeAs<DefRangeRegisterRelSym>(
+ loc_specifier_cvs, loc));
+
+ Variable::RangeList ranges = MakeRangeList(index, loc.Range, loc.Gaps);
+
+ RegisterId base_reg = (RegisterId)(uint16_t)loc.Hdr.Register;
+
+ if (base_reg == RegisterId::VFRAME) {
+ llvm::StringRef program;
+ if (GetFrameDataProgram(index, ranges, program)) {
+ result.location = MakeVFrameRelLocationExpression(
+ program, loc.Hdr.BasePointerOffset, module);
+ result.ranges = std::move(ranges);
+ } else {
+ // invalid variable
+ }
+ } else {
+ result.location = MakeRegRelLocationExpression(
+ base_reg, loc.Hdr.BasePointerOffset, module);
+ result.ranges = std::move(ranges);
+ }
}
+
+ // FIXME: Handle other kinds
return result;
}
llvm_unreachable("Symbol is not a local variable!");
diff --git a/source/Plugins/SymbolFile/NativePDB/PdbUtil.h b/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
index 570c300b6a2bc..6f675b56dca40 100644
--- a/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
+++ b/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
@@ -1,9 +1,8 @@
//===-- PdbUtil.h -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -142,7 +141,7 @@ LookThroughModifierRecord(llvm::codeview::CVType modifier);
llvm::StringRef DropNameScope(llvm::StringRef name);
VariableInfo GetVariableNameInfo(llvm::codeview::CVSymbol symbol);
-VariableInfo GetVariableLocationInfo(PdbIndex &index, PdbCompilandSymId var_id,
+VariableInfo GetVariableLocationInfo(PdbIndex &index, PdbCompilandSymId var_id, Block& block,
lldb::ModuleSP module);
size_t GetTypeSizeForSimpleKind(llvm::codeview::SimpleTypeKind kind);
diff --git a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
index 7e97e2b37724b..e27d4699ae2fa 100644
--- a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFileNativePDB.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -74,6 +73,8 @@ static lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
return lldb::LanguageType::eLanguageTypeC_plus_plus;
case PDB_Lang::C:
return lldb::LanguageType::eLanguageTypeC;
+ case PDB_Lang::Swift:
+ return lldb::LanguageType::eLanguageTypeSwift;
default:
return lldb::LanguageType::eLanguageTypeUnknown;
}
@@ -316,7 +317,7 @@ uint32_t SymbolFileNativePDB::CalculateAbilities() {
}
void SymbolFileNativePDB::InitializeObject() {
- m_obj_load_address = m_obj_file->GetFileOffset();
+ m_obj_load_address = m_obj_file->GetBaseAddress().GetFileAddress();
m_index->SetLoadAddress(m_obj_load_address);
m_index->ParseSectionContribs();
@@ -594,6 +595,17 @@ TypeSP SymbolFileNativePDB::CreateArrayType(PdbTypeSymId type_id,
return array_sp;
}
+
+TypeSP SymbolFileNativePDB::CreateFunctionType(PdbTypeSymId type_id,
+ const MemberFunctionRecord &mfr,
+ CompilerType ct) {
+ Declaration decl;
+ return std::make_shared<lldb_private::Type>(
+ toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID,
+ lldb_private::Type::eEncodingIsUID, decl, ct,
+ lldb_private::Type::eResolveStateFull);
+}
+
TypeSP SymbolFileNativePDB::CreateProcedureType(PdbTypeSymId type_id,
const ProcedureRecord &pr,
CompilerType ct) {
@@ -654,6 +666,11 @@ TypeSP SymbolFileNativePDB::CreateType(PdbTypeSymId type_id, CompilerType ct) {
llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
return CreateProcedureType(type_id, pr, ct);
}
+ if (cvt.kind() == LF_MFUNCTION) {
+ MemberFunctionRecord mfr;
+ llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
+ return CreateFunctionType(type_id, mfr, ct);
+ }
return nullptr;
}
@@ -1137,7 +1154,7 @@ bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit,
}
bool SymbolFileNativePDB::ParseImportedModules(
- const SymbolContext &sc, std::vector<ConstString> &imported_modules) {
+ const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
// PDB does not yet support module debug info
return false;
}
@@ -1151,7 +1168,7 @@ size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) {
void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); }
uint32_t SymbolFileNativePDB::FindGlobalVariables(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
@@ -1178,7 +1195,7 @@ uint32_t SymbolFileNativePDB::FindGlobalVariables(
}
uint32_t SymbolFileNativePDB::FindFunctions(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
SymbolContextList &sc_list) {
// For now we only support lookup by method name.
@@ -1219,7 +1236,7 @@ uint32_t SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
}
uint32_t SymbolFileNativePDB::FindTypes(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
if (!append)
@@ -1316,7 +1333,9 @@ VariableSP SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id,
PdbCompilandSymId var_id,
bool is_param) {
ModuleSP module = GetObjectFile()->GetModule();
- VariableInfo var_info = GetVariableLocationInfo(*m_index, var_id, module);
+ Block &block = GetOrCreateBlock(scope_id);
+ VariableInfo var_info =
+ GetVariableLocationInfo(*m_index, var_id, block, module);
if (!var_info.location || !var_info.ranges)
return nullptr;
@@ -1549,7 +1568,7 @@ size_t SymbolFileNativePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
}
CompilerDeclContext
-SymbolFileNativePDB::FindNamespace(const ConstString &name,
+SymbolFileNativePDB::FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
return {};
}
diff --git a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
index dcf3fe365ef12..20daff219a0a4 100644
--- a/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
+++ b/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
@@ -1,9 +1,8 @@
//===-- SymbolFileNativePDB.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -45,9 +44,7 @@ class SymbolFileNativePDB : public SymbolFile {
friend class UdtRecordCompleter;
public:
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -60,9 +57,7 @@ public:
static SymbolFile *CreateInstance(ObjectFile *obj_file);
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolFileNativePDB(ObjectFile *ofile);
~SymbolFileNativePDB() override;
@@ -71,9 +66,7 @@ public:
void InitializeObject() override;
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
@@ -95,13 +88,13 @@ public:
FileSpecList &support_files) override;
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;
- bool
- ParseImportedModules(const SymbolContext &sc,
- std::vector<ConstString> &imported_modules) override;
+ bool ParseImportedModules(
+ const SymbolContext &sc,
+ std::vector<lldb_private::SourceModule> &imported_modules) override;
size_t ParseBlocksRecursive(Function &func) override;
- uint32_t FindGlobalVariables(const ConstString &name,
+ uint32_t FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
VariableList &variables) override;
@@ -130,7 +123,7 @@ public:
size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
TypeList &type_list) override;
- uint32_t FindFunctions(const ConstString &name,
+ uint32_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -139,7 +132,7 @@ public:
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
- uint32_t FindTypes(const ConstString &name,
+ uint32_t FindTypes(ConstString name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
@@ -151,7 +144,7 @@ public:
TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language) override;
CompilerDeclContext
- FindNamespace(const ConstString &name,
+ FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) override;
ConstString GetPluginName() override;
@@ -187,6 +180,9 @@ private:
lldb::TypeSP CreateArrayType(PdbTypeSymId type_id,
const llvm::codeview::ArrayRecord &ar,
CompilerType ct);
+ lldb::TypeSP CreateFunctionType(PdbTypeSymId type_id,
+ const llvm::codeview::MemberFunctionRecord &pr,
+ CompilerType ct);
lldb::TypeSP CreateProcedureType(PdbTypeSymId type_id,
const llvm::codeview::ProcedureRecord &pr,
CompilerType ct);
diff --git a/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
index 239dfbee625d1..3c494dc839861 100644
--- a/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
+++ b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.cpp
@@ -50,7 +50,8 @@ UdtRecordCompleter::UdtRecordCompleter(PdbTypeSymId id,
}
clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex(
- llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access) {
+ llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access,
+ llvm::Optional<uint64_t> vtable_idx) {
PdbTypeSymId type_id(ti);
clang::QualType qt = m_ast_builder.GetOrCreateType(type_id);
@@ -58,13 +59,32 @@ clang::QualType UdtRecordCompleter::AddBaseClassForTypeIndex(
std::unique_ptr<clang::CXXBaseSpecifier> base_spec =
m_ast_builder.clang().CreateBaseClassSpecifier(
- qt.getAsOpaquePtr(), TranslateMemberAccess(access), false,
- udt_cvt.kind() == LF_CLASS);
+ qt.getAsOpaquePtr(), TranslateMemberAccess(access),
+ vtable_idx.hasValue(), udt_cvt.kind() == LF_CLASS);
lldbassert(base_spec);
- m_bases.push_back(std::move(base_spec));
+
+ m_bases.push_back(
+ std::make_pair(vtable_idx.getValueOr(0), std::move(base_spec)));
+
return qt;
}
+void UdtRecordCompleter::AddMethod(llvm::StringRef name, TypeIndex type_idx,
+ MemberAccess access, MethodOptions options,
+ MemberAttributes attrs) {
+ clang::QualType method_qt =
+ m_ast_builder.GetOrCreateType(PdbTypeSymId(type_idx));
+ m_ast_builder.CompleteType(method_qt);
+
+ lldb::AccessType access_type = TranslateMemberAccess(access);
+ bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
+ MethodOptions::CompilerGenerated;
+ m_ast_builder.clang().AddMethodToCXXRecordType(
+ m_derived_ct.GetOpaqueQualType(), name.data(), nullptr,
+ m_ast_builder.ToCompilerType(method_qt), access_type, attrs.isVirtual(),
+ attrs.isStatic(), false, false, false, is_artificial);
+}
+
Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
BaseClassRecord &base) {
clang::QualType base_qt =
@@ -82,9 +102,8 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
VirtualBaseClassRecord &base) {
- AddBaseClassForTypeIndex(base.BaseType, base.getAccess());
+ AddBaseClassForTypeIndex(base.BaseType, base.getAccess(), base.VTableIndex);
- // FIXME: Handle virtual base offsets.
return Error::success();
}
@@ -158,11 +177,27 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
OneMethodRecord &one_method) {
+ AddMethod(one_method.Name, one_method.Type, one_method.getAccess(),
+ one_method.getOptions(), one_method.Attrs);
+
return Error::success();
}
Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
OverloadedMethodRecord &overloaded) {
+ TypeIndex method_list_idx = overloaded.MethodList;
+
+ CVType method_list_type = m_tpi.getType(method_list_idx);
+ assert(method_list_type.kind() == LF_METHODLIST);
+
+ MethodOverloadListRecord method_list;
+ llvm::cantFail(TypeDeserializer::deserializeAs<MethodOverloadListRecord>(
+ method_list_type, method_list));
+
+ for (const OneMethodRecord &method : method_list.Methods)
+ AddMethod(overloaded.Name, method.Type, method.getAccess(),
+ method.getOptions(), method.Attrs);
+
return Error::success();
}
@@ -177,9 +212,19 @@ Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
}
void UdtRecordCompleter::complete() {
+ // Ensure the correct order for virtual bases.
+ std::stable_sort(m_bases.begin(), m_bases.end(),
+ [](const IndexedBase &lhs, const IndexedBase &rhs) {
+ return lhs.first < rhs.first;
+ });
+
+ std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
+ bases.reserve(m_bases.size());
+ for (auto &ib : m_bases)
+ bases.push_back(std::move(ib.second));
+
ClangASTContext &clang = m_ast_builder.clang();
- clang.TransferBaseClasses(m_derived_ct.GetOpaqueQualType(),
- std::move(m_bases));
+ clang.TransferBaseClasses(m_derived_ct.GetOpaqueQualType(), std::move(bases));
clang.AddMethodOverridesForCXXRecordType(m_derived_ct.GetOpaqueQualType());
ClangASTContext::BuildIndirectFields(m_derived_ct);
diff --git a/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
index 469685126e59b..55397582209b8 100644
--- a/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
+++ b/source/Plugins/SymbolFile/NativePDB/UdtRecordCompleter.h
@@ -1,9 +1,8 @@
-//===-- SymbolFileNativePDB.h -----------------------------------*- C++ -*-===//
+//===-- UdtRecordCompleter.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,6 +35,9 @@ namespace npdb {
class PdbAstBuilder;
class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks {
+ using IndexedBase =
+ std::pair<uint64_t, std::unique_ptr<clang::CXXBaseSpecifier>>;
+
union UdtTagRecord {
UdtTagRecord() {}
llvm::codeview::UnionRecord ur;
@@ -48,7 +50,7 @@ class UdtRecordCompleter : public llvm::codeview::TypeVisitorCallbacks {
clang::TagDecl &m_tag_decl;
PdbAstBuilder &m_ast_builder;
llvm::pdb::TpiStream &m_tpi;
- std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> m_bases;
+ std::vector<IndexedBase> m_bases;
ClangASTImporter::LayoutInfo m_layout;
public:
@@ -65,8 +67,13 @@ public:
void complete();
private:
- clang::QualType AddBaseClassForTypeIndex(llvm::codeview::TypeIndex ti,
- llvm::codeview::MemberAccess access);
+ clang::QualType AddBaseClassForTypeIndex(
+ llvm::codeview::TypeIndex ti, llvm::codeview::MemberAccess access,
+ llvm::Optional<uint64_t> vtable_idx = llvm::Optional<uint64_t>());
+ void AddMethod(llvm::StringRef name, llvm::codeview::TypeIndex type_idx,
+ llvm::codeview::MemberAccess access,
+ llvm::codeview::MethodOptions options,
+ llvm::codeview::MemberAttributes attrs);
};
} // namespace npdb
diff --git a/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 65e718bedaf11..82cfcfbb040fc 100644
--- a/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1,9 +1,8 @@
//===-- PDBASTParser.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -568,9 +567,12 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
ast_typedef = ast_typedef.AddVolatileModifier();
GetDeclarationForSymbol(type, decl);
+ llvm::Optional<uint64_t> size;
+ if (type_def->getLength())
+ size = type_def->getLength();
return std::make_shared<lldb_private::Type>(
type_def->getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
- type_def->getLength(), nullptr, target_type->GetID(),
+ size, nullptr, target_type->GetID(),
lldb_private::Type::eEncodingIsTypedefUID, decl, ast_typedef,
lldb_private::Type::eResolveStateFull);
} break;
@@ -637,16 +639,19 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
GetDeclarationForSymbol(type, decl);
return std::make_shared<lldb_private::Type>(
- type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name), 0,
- nullptr, LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl,
- func_sig_ast_type, lldb_private::Type::eResolveStateFull);
+ type.getSymIndexId(), m_ast.GetSymbolFile(), ConstString(name),
+ llvm::None, nullptr, LLDB_INVALID_UID,
+ lldb_private::Type::eEncodingIsUID, decl, func_sig_ast_type,
+ lldb_private::Type::eResolveStateFull);
} break;
case PDB_SymType::ArrayType: {
auto array_type = llvm::dyn_cast<PDBSymbolTypeArray>(&type);
assert(array_type);
uint32_t num_elements = array_type->getCount();
uint32_t element_uid = array_type->getElementTypeId();
- uint32_t bytes = array_type->getLength();
+ llvm::Optional<uint64_t> bytes;
+ if (uint64_t size = array_type->getLength())
+ bytes = size;
// If array rank > 0, PDB gives the element type at N=0. So element type
// will parsed in the order N=0, N=1,..., N=rank sequentially.
@@ -682,10 +687,12 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
if (builtin_kind == PDB_BuiltinType::None)
return nullptr;
- uint64_t bytes = builtin_type->getLength();
+ llvm::Optional<uint64_t> bytes;
+ if (uint64_t size = builtin_type->getLength())
+ bytes = size;
Encoding encoding = TranslateBuiltinEncoding(builtin_kind);
CompilerType builtin_ast_type = GetBuiltinTypeForPDBEncodingAndBitSize(
- m_ast, *builtin_type, encoding, bytes * 8);
+ m_ast, *builtin_type, encoding, bytes.getValueOr(0) * 8);
if (builtin_type->isConstType())
builtin_ast_type = builtin_ast_type.AddConstModifier();
diff --git a/source/Plugins/SymbolFile/PDB/PDBASTParser.h b/source/Plugins/SymbolFile/PDB/PDBASTParser.h
index 02353870ab603..9221d42b20206 100644
--- a/source/Plugins/SymbolFile/PDB/PDBASTParser.h
+++ b/source/Plugins/SymbolFile/PDB/PDBASTParser.h
@@ -1,9 +1,8 @@
//===-- PDBASTParser.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
index 9f398ef9b0478..1c17bf6563b36 100644
--- a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
+++ b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
@@ -1,9 +1,8 @@
//===-- PDBLocationToDWARFExpression.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,487 +12,64 @@
#include "lldb/Core/StreamBuffer.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Expression/DWARFExpression.h"
+#include "lldb/Symbol/Variable.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
+#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
-#include "Plugins/Process/Utility/lldb-x86-register-enums.h"
+#include "Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h"
+#include "Plugins/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpression.h"
using namespace lldb;
using namespace lldb_private;
+using namespace lldb_private::npdb;
using namespace llvm::pdb;
-namespace {
-const uint32_t g_code_view_to_lldb_registers_x86[] = {
- LLDB_INVALID_REGNUM, // NONE
- lldb_al_i386, // AL
- lldb_cl_i386, // CL
- lldb_dl_i386, // DL
- lldb_bl_i386, // BL
- lldb_ah_i386, // AH
- lldb_ch_i386, // CH
- lldb_dh_i386, // DH
- lldb_bh_i386, // BH
- lldb_ax_i386, // AX
- lldb_cx_i386, // CX
- lldb_dx_i386, // DX
- lldb_bx_i386, // BX
- lldb_sp_i386, // SP
- lldb_bp_i386, // BP
- lldb_si_i386, // SI
- lldb_di_i386, // DI
- lldb_eax_i386, // EAX
- lldb_ecx_i386, // ECX
- lldb_edx_i386, // EDX
- lldb_ebx_i386, // EBX
- lldb_esp_i386, // ESP
- lldb_ebp_i386, // EBP
- lldb_esi_i386, // ESI
- lldb_edi_i386, // EDI
- lldb_es_i386, // ES
- lldb_cs_i386, // CS
- lldb_ss_i386, // SS
- lldb_ds_i386, // DS
- lldb_fs_i386, // FS
- lldb_gs_i386, // GS
- LLDB_INVALID_REGNUM, // IP
- LLDB_INVALID_REGNUM, // FLAGS
- lldb_eip_i386, // EIP
- lldb_eflags_i386, // EFLAGS
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // TEMP
- LLDB_INVALID_REGNUM, // TEMPH
- LLDB_INVALID_REGNUM, // QUOTE
- LLDB_INVALID_REGNUM, // PCDR3
- LLDB_INVALID_REGNUM, // PCDR4
- LLDB_INVALID_REGNUM, // PCDR5
- LLDB_INVALID_REGNUM, // PCDR6
- LLDB_INVALID_REGNUM, // PCDR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // CR0
- LLDB_INVALID_REGNUM, // CR1
- LLDB_INVALID_REGNUM, // CR2
- LLDB_INVALID_REGNUM, // CR3
- LLDB_INVALID_REGNUM, // CR4
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_dr0_i386, // DR0
- lldb_dr1_i386, // DR1
- lldb_dr2_i386, // DR2
- lldb_dr3_i386, // DR3
- lldb_dr4_i386, // DR4
- lldb_dr5_i386, // DR5
- lldb_dr6_i386, // DR6
- lldb_dr7_i386, // DR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // GDTR
- LLDB_INVALID_REGNUM, // GDTL
- LLDB_INVALID_REGNUM, // IDTR
- LLDB_INVALID_REGNUM, // IDTL
- LLDB_INVALID_REGNUM, // LDTR
- LLDB_INVALID_REGNUM, // TR
- LLDB_INVALID_REGNUM, // PSEUDO1
- LLDB_INVALID_REGNUM, // PSEUDO2
- LLDB_INVALID_REGNUM, // PSEUDO3
- LLDB_INVALID_REGNUM, // PSEUDO4
- LLDB_INVALID_REGNUM, // PSEUDO5
- LLDB_INVALID_REGNUM, // PSEUDO6
- LLDB_INVALID_REGNUM, // PSEUDO7
- LLDB_INVALID_REGNUM, // PSEUDO8
- LLDB_INVALID_REGNUM, // PSEUDO9
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_st0_i386, // ST0
- lldb_st1_i386, // ST1
- lldb_st2_i386, // ST2
- lldb_st3_i386, // ST3
- lldb_st4_i386, // ST4
- lldb_st5_i386, // ST5
- lldb_st6_i386, // ST6
- lldb_st7_i386, // ST7
- LLDB_INVALID_REGNUM, // CTRL
- LLDB_INVALID_REGNUM, // STAT
- LLDB_INVALID_REGNUM, // TAG
- LLDB_INVALID_REGNUM, // FPIP
- LLDB_INVALID_REGNUM, // FPCS
- LLDB_INVALID_REGNUM, // FPDO
- LLDB_INVALID_REGNUM, // FPDS
- LLDB_INVALID_REGNUM, // ISEM
- LLDB_INVALID_REGNUM, // FPEIP
- LLDB_INVALID_REGNUM, // FPEDO
- lldb_mm0_i386, // MM0
- lldb_mm1_i386, // MM1
- lldb_mm2_i386, // MM2
- lldb_mm3_i386, // MM3
- lldb_mm4_i386, // MM4
- lldb_mm5_i386, // MM5
- lldb_mm6_i386, // MM6
- lldb_mm7_i386, // MM7
- lldb_xmm0_i386, // XMM0
- lldb_xmm1_i386, // XMM1
- lldb_xmm2_i386, // XMM2
- lldb_xmm3_i386, // XMM3
- lldb_xmm4_i386, // XMM4
- lldb_xmm5_i386, // XMM5
- lldb_xmm6_i386, // XMM6
- lldb_xmm7_i386 // XMM7
-};
-
-const uint32_t g_code_view_to_lldb_registers_x86_64[] = {
- LLDB_INVALID_REGNUM, // NONE
- lldb_al_x86_64, // AL
- lldb_cl_x86_64, // CL
- lldb_dl_x86_64, // DL
- lldb_bl_x86_64, // BL
- lldb_ah_x86_64, // AH
- lldb_ch_x86_64, // CH
- lldb_dh_x86_64, // DH
- lldb_bh_x86_64, // BH
- lldb_ax_x86_64, // AX
- lldb_cx_x86_64, // CX
- lldb_dx_x86_64, // DX
- lldb_bx_x86_64, // BX
- lldb_sp_x86_64, // SP
- lldb_bp_x86_64, // BP
- lldb_si_x86_64, // SI
- lldb_di_x86_64, // DI
- lldb_eax_x86_64, // EAX
- lldb_ecx_x86_64, // ECX
- lldb_edx_x86_64, // EDX
- lldb_ebx_x86_64, // EBX
- lldb_esp_x86_64, // ESP
- lldb_ebp_x86_64, // EBP
- lldb_esi_x86_64, // ESI
- lldb_edi_x86_64, // EDI
- lldb_es_x86_64, // ES
- lldb_cs_x86_64, // CS
- lldb_ss_x86_64, // SS
- lldb_ds_x86_64, // DS
- lldb_fs_x86_64, // FS
- lldb_gs_x86_64, // GS
- LLDB_INVALID_REGNUM, // IP
- LLDB_INVALID_REGNUM, // FLAGS
- LLDB_INVALID_REGNUM, // EIP
- LLDB_INVALID_REGNUM, // EFLAGS
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // TEMP
- LLDB_INVALID_REGNUM, // TEMPH
- LLDB_INVALID_REGNUM, // QUOTE
- LLDB_INVALID_REGNUM, // PCDR3
- LLDB_INVALID_REGNUM, // PCDR4
- LLDB_INVALID_REGNUM, // PCDR5
- LLDB_INVALID_REGNUM, // PCDR6
- LLDB_INVALID_REGNUM, // PCDR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // CR0
- LLDB_INVALID_REGNUM, // CR1
- LLDB_INVALID_REGNUM, // CR2
- LLDB_INVALID_REGNUM, // CR3
- LLDB_INVALID_REGNUM, // CR4
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_dr0_x86_64, // DR0
- lldb_dr1_x86_64, // DR1
- lldb_dr2_x86_64, // DR2
- lldb_dr3_x86_64, // DR3
- lldb_dr4_x86_64, // DR4
- lldb_dr5_x86_64, // DR5
- lldb_dr6_x86_64, // DR6
- lldb_dr7_x86_64, // DR7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // GDTR
- LLDB_INVALID_REGNUM, // GDTL
- LLDB_INVALID_REGNUM, // IDTR
- LLDB_INVALID_REGNUM, // IDTL
- LLDB_INVALID_REGNUM, // LDTR
- LLDB_INVALID_REGNUM, // TR
- LLDB_INVALID_REGNUM, // PSEUDO1
- LLDB_INVALID_REGNUM, // PSEUDO2
- LLDB_INVALID_REGNUM, // PSEUDO3
- LLDB_INVALID_REGNUM, // PSEUDO4
- LLDB_INVALID_REGNUM, // PSEUDO5
- LLDB_INVALID_REGNUM, // PSEUDO6
- LLDB_INVALID_REGNUM, // PSEUDO7
- LLDB_INVALID_REGNUM, // PSEUDO8
- LLDB_INVALID_REGNUM, // PSEUDO9
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_st0_x86_64, // ST0
- lldb_st1_x86_64, // ST1
- lldb_st2_x86_64, // ST2
- lldb_st3_x86_64, // ST3
- lldb_st4_x86_64, // ST4
- lldb_st5_x86_64, // ST5
- lldb_st6_x86_64, // ST6
- lldb_st7_x86_64, // ST7
- LLDB_INVALID_REGNUM, // CTRL
- LLDB_INVALID_REGNUM, // STAT
- LLDB_INVALID_REGNUM, // TAG
- LLDB_INVALID_REGNUM, // FPIP
- LLDB_INVALID_REGNUM, // FPCS
- LLDB_INVALID_REGNUM, // FPDO
- LLDB_INVALID_REGNUM, // FPDS
- LLDB_INVALID_REGNUM, // ISEM
- LLDB_INVALID_REGNUM, // FPEIP
- LLDB_INVALID_REGNUM, // FPEDO
- lldb_mm0_x86_64, // MM0
- lldb_mm1_x86_64, // MM1
- lldb_mm2_x86_64, // MM2
- lldb_mm3_x86_64, // MM3
- lldb_mm4_x86_64, // MM4
- lldb_mm5_x86_64, // MM5
- lldb_mm6_x86_64, // MM6
- lldb_mm7_x86_64, // MM7
- lldb_xmm0_x86_64, // XMM0
- lldb_xmm1_x86_64, // XMM1
- lldb_xmm2_x86_64, // XMM2
- lldb_xmm3_x86_64, // XMM3
- lldb_xmm4_x86_64, // XMM4
- lldb_xmm5_x86_64, // XMM5
- lldb_xmm6_x86_64, // XMM6
- lldb_xmm7_x86_64, // XMM7
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM,
- lldb_mxcsr_x86_64, // MXCSR
- LLDB_INVALID_REGNUM, // EDXEAX
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, // EMM0L
- LLDB_INVALID_REGNUM, // EMM1L
- LLDB_INVALID_REGNUM, // EMM2L
- LLDB_INVALID_REGNUM, // EMM3L
- LLDB_INVALID_REGNUM, // EMM4L
- LLDB_INVALID_REGNUM, // EMM5L
- LLDB_INVALID_REGNUM, // EMM6L
- LLDB_INVALID_REGNUM, // EMM7L
- LLDB_INVALID_REGNUM, // EMM0H
- LLDB_INVALID_REGNUM, // EMM1H
- LLDB_INVALID_REGNUM, // EMM2H
- LLDB_INVALID_REGNUM, // EMM3H
- LLDB_INVALID_REGNUM, // EMM4H
- LLDB_INVALID_REGNUM, // EMM5H
- LLDB_INVALID_REGNUM, // EMM6H
- LLDB_INVALID_REGNUM, // EMM7H
- LLDB_INVALID_REGNUM, // MM00
- LLDB_INVALID_REGNUM, // MM01
- LLDB_INVALID_REGNUM, // MM10
- LLDB_INVALID_REGNUM, // MM11
- LLDB_INVALID_REGNUM, // MM20
- LLDB_INVALID_REGNUM, // MM21
- LLDB_INVALID_REGNUM, // MM30
- LLDB_INVALID_REGNUM, // MM31
- LLDB_INVALID_REGNUM, // MM40
- LLDB_INVALID_REGNUM, // MM41
- LLDB_INVALID_REGNUM, // MM50
- LLDB_INVALID_REGNUM, // MM51
- LLDB_INVALID_REGNUM, // MM60
- LLDB_INVALID_REGNUM, // MM61
- LLDB_INVALID_REGNUM, // MM70
- LLDB_INVALID_REGNUM, // MM71
- lldb_xmm8_x86_64, // XMM8
- lldb_xmm9_x86_64, // XMM9
- lldb_xmm10_x86_64, // XMM10
- lldb_xmm11_x86_64, // XMM11
- lldb_xmm12_x86_64, // XMM12
- lldb_xmm13_x86_64, // XMM13
- lldb_xmm14_x86_64, // XMM14
- lldb_xmm15_x86_64, // XMM15
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM,
- lldb_sil_x86_64, // SIL
- lldb_dil_x86_64, // DIL
- lldb_bpl_x86_64, // BPL
- lldb_spl_x86_64, // SPL
- lldb_rax_x86_64, // RAX
- lldb_rbx_x86_64, // RBX
- lldb_rcx_x86_64, // RCX
- lldb_rdx_x86_64, // RDX
- lldb_rsi_x86_64, // RSI
- lldb_rdi_x86_64, // RDI
- lldb_rbp_x86_64, // RBP
- lldb_rsp_x86_64, // RSP
- lldb_r8_x86_64, // R8
- lldb_r9_x86_64, // R9
- lldb_r10_x86_64, // R10
- lldb_r11_x86_64, // R11
- lldb_r12_x86_64, // R12
- lldb_r13_x86_64, // R13
- lldb_r14_x86_64, // R14
- lldb_r15_x86_64, // R15
- lldb_r8l_x86_64, // R8B
- lldb_r9l_x86_64, // R9B
- lldb_r10l_x86_64, // R10B
- lldb_r11l_x86_64, // R11B
- lldb_r12l_x86_64, // R12B
- lldb_r13l_x86_64, // R13B
- lldb_r14l_x86_64, // R14B
- lldb_r15l_x86_64, // R15B
- lldb_r8w_x86_64, // R8W
- lldb_r9w_x86_64, // R9W
- lldb_r10w_x86_64, // R10W
- lldb_r11w_x86_64, // R11W
- lldb_r12w_x86_64, // R12W
- lldb_r13w_x86_64, // R13W
- lldb_r14w_x86_64, // R14W
- lldb_r15w_x86_64, // R15W
- lldb_r8d_x86_64, // R8D
- lldb_r9d_x86_64, // R9D
- lldb_r10d_x86_64, // R10D
- lldb_r11d_x86_64, // R11D
- lldb_r12d_x86_64, // R12D
- lldb_r13d_x86_64, // R13D
- lldb_r14d_x86_64, // R14D
- lldb_r15d_x86_64, // R15D
- lldb_ymm0_x86_64, // AMD64_YMM0
- lldb_ymm1_x86_64, // AMD64_YMM1
- lldb_ymm2_x86_64, // AMD64_YMM2
- lldb_ymm3_x86_64, // AMD64_YMM3
- lldb_ymm4_x86_64, // AMD64_YMM4
- lldb_ymm5_x86_64, // AMD64_YMM5
- lldb_ymm6_x86_64, // AMD64_YMM6
- lldb_ymm7_x86_64, // AMD64_YMM7
- lldb_ymm8_x86_64, // AMD64_YMM8
- lldb_ymm9_x86_64, // AMD64_YMM9
- lldb_ymm10_x86_64, // AMD64_YMM10
- lldb_ymm11_x86_64, // AMD64_YMM11
- lldb_ymm12_x86_64, // AMD64_YMM12
- lldb_ymm13_x86_64, // AMD64_YMM13
- lldb_ymm14_x86_64, // AMD64_YMM14
- lldb_ymm15_x86_64, // AMD64_YMM15
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM,
- lldb_bnd0_x86_64, // BND0
- lldb_bnd1_x86_64, // BND1
- lldb_bnd2_x86_64 // BND2
-};
-
-uint32_t GetLLDBRegisterNumber(llvm::Triple::ArchType arch_type,
- llvm::codeview::RegisterId register_id) {
- switch (arch_type) {
- case llvm::Triple::x86:
- if (static_cast<uint16_t>(register_id) <
- sizeof(g_code_view_to_lldb_registers_x86) /
- sizeof(g_code_view_to_lldb_registers_x86[0]))
- return g_code_view_to_lldb_registers_x86[static_cast<uint16_t>(
- register_id)];
-
- switch (register_id) {
- case llvm::codeview::RegisterId::MXCSR:
- return lldb_mxcsr_i386;
- case llvm::codeview::RegisterId::BND0:
- return lldb_bnd0_i386;
- case llvm::codeview::RegisterId::BND1:
- return lldb_bnd1_i386;
- case llvm::codeview::RegisterId::BND2:
- return lldb_bnd2_i386;
- default:
- return LLDB_INVALID_REGNUM;
+static std::unique_ptr<IPDBFrameData>
+GetCorrespondingFrameData(const IPDBSession &session,
+ const Variable::RangeList &ranges) {
+ auto enumFrameData = session.getFrameData();
+ if (!enumFrameData)
+ return nullptr;
+
+ std::unique_ptr<IPDBFrameData> found;
+ while (auto fd = enumFrameData->getNext()) {
+ Range<lldb::addr_t, lldb::addr_t> fdRange(fd->getVirtualAddress(),
+ fd->getLengthBlock());
+
+ for (size_t i = 0; i < ranges.GetSize(); i++) {
+ auto range = ranges.GetEntryAtIndex(i);
+ if (!range)
+ continue;
+
+ if (!range->DoesIntersect(fdRange))
+ continue;
+
+ found = std::move(fd);
+
+ break;
}
- case llvm::Triple::x86_64:
- if (static_cast<uint16_t>(register_id) <
- sizeof(g_code_view_to_lldb_registers_x86_64) /
- sizeof(g_code_view_to_lldb_registers_x86_64[0]))
- return g_code_view_to_lldb_registers_x86_64[static_cast<uint16_t>(
- register_id)];
-
- return LLDB_INVALID_REGNUM;
- default:
- return LLDB_INVALID_REGNUM;
}
-}
-
-uint32_t GetGenericRegisterNumber(llvm::codeview::RegisterId register_id) {
- if (register_id == llvm::codeview::RegisterId::VFRAME)
- return LLDB_REGNUM_GENERIC_FP;
- return LLDB_INVALID_REGNUM;
+ return found;
}
-uint32_t GetRegisterNumber(llvm::Triple::ArchType arch_type,
- llvm::codeview::RegisterId register_id,
- RegisterKind &register_kind) {
- register_kind = eRegisterKindLLDB;
- uint32_t reg_num = GetLLDBRegisterNumber(arch_type, register_id);
- if (reg_num != LLDB_INVALID_REGNUM)
- return reg_num;
-
- register_kind = eRegisterKindGeneric;
- return GetGenericRegisterNumber(register_id);
+static bool EmitVFrameEvaluationDWARFExpression(
+ llvm::StringRef program, llvm::Triple::ArchType arch_type, Stream &stream) {
+ // VFrame value always stored in $TO pseudo-register
+ return TranslateFPOProgramToDWARFExpression(program, "$T0", arch_type,
+ stream);
}
-} // namespace
-DWARFExpression ConvertPDBLocationToDWARFExpression(ModuleSP module,
- const PDBSymbolData &symbol,
- bool &is_constant) {
+DWARFExpression ConvertPDBLocationToDWARFExpression(
+ ModuleSP module, const PDBSymbolData &symbol,
+ const Variable::RangeList &ranges, bool &is_constant) {
is_constant = true;
if (!module)
- return DWARFExpression(nullptr);
+ return DWARFExpression();
const ArchSpec &architecture = module->GetArchitecture();
llvm::Triple::ArchType arch_type = architecture.GetMachine();
@@ -501,7 +77,7 @@ DWARFExpression ConvertPDBLocationToDWARFExpression(ModuleSP module,
uint32_t address_size = architecture.GetAddressByteSize();
uint32_t byte_size = architecture.GetDataByteSize();
if (byte_order == eByteOrderInvalid || address_size == 0)
- return DWARFExpression(nullptr);
+ return DWARFExpression();
RegisterKind register_kind = eRegisterKindDWARF;
StreamBuffer<32> stream(Stream::eBinary, address_size, byte_order);
@@ -512,15 +88,13 @@ DWARFExpression ConvertPDBLocationToDWARFExpression(ModuleSP module,
SectionList *section_list = module->GetSectionList();
if (!section_list)
- return DWARFExpression(nullptr);
+ return DWARFExpression();
- uint32_t section_idx = symbol.getAddressSection() - 1;
- if (section_idx >= section_list->GetSize())
- return DWARFExpression(nullptr);
+ uint32_t section_id = symbol.getAddressSection();
- auto section = section_list->GetSectionAtIndex(section_idx);
+ auto section = section_list->FindSectionByID(section_id);
if (!section)
- return DWARFExpression(nullptr);
+ return DWARFExpression();
uint32_t offset = symbol.getAddressOffset();
stream.PutMaxHex64(section->GetFileAddress() + offset, address_size,
@@ -531,10 +105,32 @@ DWARFExpression ConvertPDBLocationToDWARFExpression(ModuleSP module,
break;
}
case PDB_LocType::RegRel: {
- uint32_t reg_num =
- GetRegisterNumber(arch_type, symbol.getRegisterId(), register_kind);
- if (reg_num == LLDB_INVALID_REGNUM)
- return DWARFExpression(nullptr);
+ uint32_t reg_num;
+ auto reg_id = symbol.getRegisterId();
+ if (reg_id == llvm::codeview::RegisterId::VFRAME) {
+ if (auto fd = GetCorrespondingFrameData(symbol.getSession(), ranges)) {
+ if (EmitVFrameEvaluationDWARFExpression(fd->getProgram(), arch_type,
+ stream)) {
+ int32_t offset = symbol.getOffset();
+ stream.PutHex8(DW_OP_consts);
+ stream.PutSLEB128(offset);
+ stream.PutHex8(DW_OP_plus);
+
+ register_kind = eRegisterKindLLDB;
+
+ is_constant = false;
+ break;
+ }
+ }
+
+ register_kind = eRegisterKindGeneric;
+ reg_num = LLDB_REGNUM_GENERIC_FP;
+ } else {
+ register_kind = eRegisterKindLLDB;
+ reg_num = GetLLDBRegisterNumber(arch_type, reg_id);
+ if (reg_num == LLDB_INVALID_REGNUM)
+ return DWARFExpression();
+ }
if (reg_num > 31) {
stream.PutHex8(DW_OP_bregx);
@@ -550,10 +146,10 @@ DWARFExpression ConvertPDBLocationToDWARFExpression(ModuleSP module,
break;
}
case PDB_LocType::Enregistered: {
- uint32_t reg_num =
- GetRegisterNumber(arch_type, symbol.getRegisterId(), register_kind);
+ register_kind = eRegisterKindLLDB;
+ uint32_t reg_num = GetLLDBRegisterNumber(arch_type, symbol.getRegisterId());
if (reg_num == LLDB_INVALID_REGNUM)
- return DWARFExpression(nullptr);
+ return DWARFExpression();
if (reg_num > 31) {
stream.PutHex8(DW_OP_regx);
@@ -572,7 +168,7 @@ DWARFExpression ConvertPDBLocationToDWARFExpression(ModuleSP module,
break;
}
default:
- return DWARFExpression(nullptr);
+ return DWARFExpression();
}
DataBufferSP buffer =
diff --git a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
index 37b80dfccb845..2e9d1386d5378 100644
--- a/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
+++ b/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
@@ -1,9 +1,8 @@
//===-- PDBLocationToDWARFExpression.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,6 +10,7 @@
#define lldb_Plugins_SymbolFile_PDB_PDBLocationToDWARFExpression_h_
#include "lldb/Core/Module.h"
+#include "lldb/Symbol/Variable.h"
namespace lldb_private {
class DWARFExpression;
@@ -22,24 +22,26 @@ class PDBSymbolData;
}
} // namespace llvm
-//------------------------------------------------------------------------------
/// Converts a location information from a PDB symbol to a DWARF expression
///
-/// @param[in] module
+/// \param[in] module
/// The module \a symbol belongs to.
///
-/// @param[in] symbol
+/// \param[in] symbol
/// The symbol with a location information to convert.
///
-/// @param[out] is_constant
+/// \param[in] ranges
+/// Ranges where this variable is valid.
+///
+/// \param[out] is_constant
/// Set to \b true if the result expression is a constant value data,
/// and \b false if it is a DWARF bytecode.
///
-/// @return
+/// \return
/// The DWARF expression corresponding to the location data of \a symbol.
-//------------------------------------------------------------------------------
lldb_private::DWARFExpression
ConvertPDBLocationToDWARFExpression(lldb::ModuleSP module,
const llvm::pdb::PDBSymbolData &symbol,
+ const lldb_private::Variable::RangeList &ranges,
bool &is_constant);
#endif
diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index ad25842f4d05e..17dfcdaceb9cb 100644
--- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFilePDB.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -65,6 +64,8 @@ lldb::LanguageType TranslateLanguage(PDB_Lang lang) {
return lldb::LanguageType::eLanguageTypeC_plus_plus;
case PDB_Lang::C:
return lldb::LanguageType::eLanguageTypeC;
+ case PDB_Lang::Swift:
+ return lldb::LanguageType::eLanguageTypeSwift;
default:
return lldb::LanguageType::eLanguageTypeUnknown;
}
@@ -123,7 +124,7 @@ SymbolFilePDB::CreateInstance(lldb_private::ObjectFile *obj_file) {
SymbolFilePDB::SymbolFilePDB(lldb_private::ObjectFile *object_file)
: SymbolFile(object_file), m_session_up(), m_global_scope_up(),
- m_cached_compile_unit_count(0), m_tu_decl_ctx_up() {}
+ m_cached_compile_unit_count(0) {}
SymbolFilePDB::~SymbolFilePDB() {}
@@ -182,20 +183,12 @@ uint32_t SymbolFilePDB::CalculateAbilities() {
}
void SymbolFilePDB::InitializeObject() {
- lldb::addr_t obj_load_address = m_obj_file->GetFileOffset();
+ lldb::addr_t obj_load_address = m_obj_file->GetBaseAddress().GetFileAddress();
lldbassert(obj_load_address && obj_load_address != LLDB_INVALID_ADDRESS);
m_session_up->setLoadAddress(obj_load_address);
if (!m_global_scope_up)
m_global_scope_up = m_session_up->getGlobalScope();
lldbassert(m_global_scope_up.get());
-
- TypeSystem *type_system =
- GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(type_system);
- lldbassert(clang_type_system);
- m_tu_decl_ctx_up = llvm::make_unique<CompilerDeclContext>(
- type_system, clang_type_system->GetTranslationUnitDecl());
}
uint32_t SymbolFilePDB::GetNumCompileUnits() {
@@ -308,7 +301,8 @@ SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func,
comp_unit.AddFunction(func_sp);
- TypeSystem *type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
+ LanguageType lang = ParseLanguage(comp_unit);
+ TypeSystem *type_system = GetTypeSystemForLanguage(lang);
if (!type_system)
return nullptr;
ClangASTContext *clang_type_system =
@@ -378,7 +372,7 @@ bool SymbolFilePDB::ParseSupportFiles(
bool SymbolFilePDB::ParseImportedModules(
const lldb_private::SymbolContext &sc,
- std::vector<lldb_private::ConstString> &imported_modules) {
+ std::vector<SourceModule> &imported_modules) {
// PDB does not yet support module debug info
return false;
}
@@ -934,12 +928,25 @@ VariableSP SymbolFilePDB::ParseVariableForPDBData(
Variable::RangeList ranges;
SymbolContextScope *context_scope = sc.comp_unit;
- if (scope == eValueTypeVariableLocal) {
+ if (scope == eValueTypeVariableLocal || scope == eValueTypeVariableArgument) {
if (sc.function) {
- context_scope = sc.function->GetBlock(true).FindBlockByID(
- pdb_data.getLexicalParentId());
- if (context_scope == nullptr)
- context_scope = sc.function;
+ Block &function_block = sc.function->GetBlock(true);
+ Block *block =
+ function_block.FindBlockByID(pdb_data.getLexicalParentId());
+ if (!block)
+ block = &function_block;
+
+ context_scope = block;
+
+ for (size_t i = 0, num_ranges = block->GetNumRanges(); i < num_ranges;
+ ++i) {
+ AddressRange range;
+ if (!block->GetRangeAtIndex(i, range))
+ continue;
+
+ ranges.Append(range.GetBaseAddress().GetFileAddress(),
+ range.GetByteSize());
+ }
}
}
@@ -952,7 +959,7 @@ VariableSP SymbolFilePDB::ParseVariableForPDBData(
bool is_constant;
DWARFExpression location = ConvertPDBLocationToDWARFExpression(
- GetObjectFile()->GetModule(), pdb_data, is_constant);
+ GetObjectFile()->GetModule(), pdb_data, ranges, is_constant);
var_sp = std::make_shared<Variable>(
var_uid, var_name.c_str(), mangled_cstr, type_sp, scope, context_scope,
@@ -1034,7 +1041,7 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc,
}
uint32_t SymbolFilePDB::FindGlobalVariables(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, lldb_private::VariableList &variables) {
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
@@ -1234,7 +1241,7 @@ void SymbolFilePDB::CacheFunctionNames() {
}
uint32_t SymbolFilePDB::FindFunctions(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines, bool append,
lldb_private::SymbolContextList &sc_list) {
@@ -1337,11 +1344,9 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
return;
while (auto pub_symbol = results->getNext()) {
- auto section_idx = pub_symbol->getAddressSection() - 1;
- if (section_idx >= section_list->GetSize())
- continue;
+ auto section_id = pub_symbol->getAddressSection();
- auto section = section_list->GetSectionAtIndex(section_idx);
+ auto section = section_list->FindSectionByID(section_id);
if (!section)
continue;
@@ -1376,7 +1381,7 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
}
uint32_t SymbolFilePDB::FindTypes(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
@@ -1618,7 +1623,7 @@ PDBASTParser *SymbolFilePDB::GetPDBAstParser() {
lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) {
auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
auto clang_type_system = llvm::dyn_cast_or_null<ClangASTContext>(type_system);
diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
index 81288093b7d83..ba3099aaec4d3 100644
--- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -1,9 +1,8 @@
//===-- SymbolFilePDB.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@ class PDBASTParser;
class SymbolFilePDB : public lldb_private::SymbolFile {
public:
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -40,9 +37,7 @@ public:
static lldb_private::SymbolFile *
CreateInstance(lldb_private::ObjectFile *obj_file);
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolFilePDB(lldb_private::ObjectFile *ofile);
~SymbolFilePDB() override;
@@ -51,9 +46,7 @@ public:
void InitializeObject() override;
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
@@ -75,7 +68,7 @@ public:
bool ParseImportedModules(
const lldb_private::SymbolContext &sc,
- std::vector<lldb_private::ConstString> &imported_modules) override;
+ std::vector<lldb_private::SourceModule> &imported_modules) override;
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
@@ -111,7 +104,7 @@ public:
lldb_private::SymbolContextList &sc_list) override;
uint32_t
- FindGlobalVariables(const lldb_private::ConstString &name,
+ FindGlobalVariables(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@@ -121,7 +114,7 @@ public:
lldb_private::VariableList &variables) override;
uint32_t
- FindFunctions(const lldb_private::ConstString &name,
+ FindFunctions(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask, bool include_inlines,
bool append, lldb_private::SymbolContextList &sc_list) override;
@@ -137,7 +130,7 @@ public:
void AddSymbols(lldb_private::Symtab &symtab) override;
uint32_t
- FindTypes(const lldb_private::ConstString &name,
+ FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
@@ -159,7 +152,7 @@ public:
GetTypeSystemForLanguage(lldb::LanguageType language) override;
lldb_private::CompilerDeclContext FindNamespace(
- const lldb_private::ConstString &name,
+ lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
lldb_private::ConstString GetPluginName() override;
@@ -253,7 +246,6 @@ private:
std::unique_ptr<llvm::pdb::IPDBSession> m_session_up;
std::unique_ptr<llvm::pdb::PDBSymbolExe> m_global_scope_up;
uint32_t m_cached_compile_unit_count;
- std::unique_ptr<lldb_private::CompilerDeclContext> m_tu_decl_ctx_up;
lldb_private::UniqueCStringMap<uint32_t> m_func_full_names;
lldb_private::UniqueCStringMap<uint32_t> m_func_base_names;
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 08778bd1ba707..a1b21e51b0fe5 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -1,13 +1,13 @@
//===-- SymbolFileSymtab.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "SymbolFileSymtab.h"
+
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Symbol/CompileUnit.h"
@@ -20,6 +20,8 @@
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Timer.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -62,11 +64,9 @@ uint32_t SymbolFileSymtab::CalculateAbilities() {
if (m_obj_file) {
const Symtab *symtab = m_obj_file->GetSymtab();
if (symtab) {
- //----------------------------------------------------------------------
// The snippet of code below will get the indexes the module symbol table
// entries that are code, data, or function related (debug info), sort
// them by value (address) and dump the sorted symbols.
- //----------------------------------------------------------------------
if (symtab->AppendSymbolIndexesWithType(eSymbolTypeSourceFile,
m_source_indexes)) {
abilities |= CompileUnits;
@@ -124,9 +124,9 @@ CompUnitSP SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx) {
const Symbol *cu_symbol =
m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]);
if (cu_symbol)
- cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL,
+ cu_sp = std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr,
cu_symbol->GetName().AsCString(), 0,
- eLanguageTypeUnknown, eLazyBoolNo));
+ eLanguageTypeUnknown, eLazyBoolNo);
}
return cu_sp;
}
@@ -139,8 +139,8 @@ size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) {
size_t num_added = 0;
// We must at least have a valid compile unit
const Symtab *symtab = m_obj_file->GetSymtab();
- const Symbol *curr_symbol = NULL;
- const Symbol *next_symbol = NULL;
+ const Symbol *curr_symbol = nullptr;
+ const Symbol *next_symbol = nullptr;
// const char *prefix = m_obj_file->SymbolPrefix();
// if (prefix == NULL)
// prefix == "";
@@ -188,10 +188,10 @@ size_t SymbolFileSymtab::ParseFunctions(CompileUnit &comp_unit) {
LLDB_INVALID_UID, // We don't have any type info
// for this function
curr_symbol->GetMangled(), // Linker/mangled name
- NULL, // no return type for a code symbol...
+ nullptr, // no return type for a code symbol...
func_range)); // first address range
- if (func_sp.get() != NULL) {
+ if (func_sp.get() != nullptr) {
comp_unit.AddFunction(func_sp);
++num_added;
}
@@ -219,7 +219,7 @@ bool SymbolFileSymtab::ParseSupportFiles(CompileUnit &comp_unit,
}
bool SymbolFileSymtab::ParseImportedModules(
- const SymbolContext &sc, std::vector<ConstString> &imported_modules) {
+ const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
return false;
}
@@ -230,7 +230,7 @@ size_t SymbolFileSymtab::ParseVariablesForContext(const SymbolContext &sc) {
}
Type *SymbolFileSymtab::ResolveTypeUID(lldb::user_id_t type_uid) {
- return NULL;
+ return nullptr;
}
llvm::Optional<SymbolFile::ArrayInfo>
@@ -246,7 +246,7 @@ bool SymbolFileSymtab::CompleteType(lldb_private::CompilerType &compiler_type) {
uint32_t SymbolFileSymtab::ResolveSymbolContext(const Address &so_addr,
SymbolContextItem resolve_scope,
SymbolContext &sc) {
- if (m_obj_file->GetSymtab() == NULL)
+ if (m_obj_file->GetSymtab() == nullptr)
return 0;
uint32_t resolved_flags = 0;
@@ -259,9 +259,7 @@ uint32_t SymbolFileSymtab::ResolveSymbolContext(const Address &so_addr,
return resolved_flags;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString SymbolFileSymtab::GetPluginName() {
return GetPluginNameStatic();
}
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index e4ec7a1813339..bc9a531419aec 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -1,9 +1,8 @@
//===-- SymbolFileSymtab.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,16 +17,12 @@
class SymbolFileSymtab : public lldb_private::SymbolFile {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolFileSymtab(lldb_private::ObjectFile *obj_file);
~SymbolFileSymtab() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -41,9 +36,7 @@ public:
uint32_t CalculateAbilities() override;
- //------------------------------------------------------------------
// Compile Unit function calls
- //------------------------------------------------------------------
uint32_t GetNumCompileUnits() override;
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
@@ -64,7 +57,7 @@ public:
bool ParseImportedModules(
const lldb_private::SymbolContext &sc,
- std::vector<lldb_private::ConstString> &imported_modules) override;
+ std::vector<lldb_private::SourceModule> &imported_modules) override;
size_t ParseBlocksRecursive(lldb_private::Function &func) override;
@@ -86,9 +79,7 @@ public:
lldb::TypeClass type_mask,
lldb_private::TypeList &type_list) override;
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
index 425b612d786f0..f279af61a1315 100644
--- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
+++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp
@@ -1,9 +1,8 @@
//===-- SymbolVendorELF.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,23 +15,20 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/Host.h"
-#include "lldb/Host/Symbols.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Target.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// SymbolVendorELF constructor
-//----------------------------------------------------------------------
SymbolVendorELF::SymbolVendorELF(const lldb::ModuleSP &module_sp)
: SymbolVendor(module_sp) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SymbolVendorELF::~SymbolVendorELF() {}
void SymbolVendorELF::Initialize() {
@@ -54,31 +50,29 @@ const char *SymbolVendorELF::GetPluginDescriptionStatic() {
"executables.";
}
-//----------------------------------------------------------------------
// CreateInstance
//
// Platforms can register a callback to use when creating symbol vendors to
// allow for complex debug information file setups, and to also allow for
// finding separate debug information files.
-//----------------------------------------------------------------------
SymbolVendor *
SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
lldb_private::Stream *feedback_strm) {
if (!module_sp)
- return NULL;
+ return nullptr;
ObjectFile *obj_file = module_sp->GetObjectFile();
if (!obj_file)
- return NULL;
+ return nullptr;
static ConstString obj_file_elf("elf");
ConstString obj_name = obj_file->GetPluginName();
if (obj_name != obj_file_elf)
- return NULL;
+ return nullptr;
- lldb_private::UUID uuid;
- if (!obj_file->GetUUID(&uuid))
- return NULL;
+ lldb_private::UUID uuid = obj_file->GetUUID();
+ if (!uuid)
+ return nullptr;
// Get the .gnu_debuglink file (if specified).
FileSpecList file_spec_list = obj_file->GetDebugSymbolFilePaths();
@@ -90,7 +84,7 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
// If we have no debug symbol files, then nothing to do.
if (file_spec_list.IsEmpty())
- return NULL;
+ return nullptr;
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, "SymbolVendorELF::CreateInstance (module = %s)",
@@ -104,7 +98,9 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
FileSystem::Instance().Resolve(module_spec.GetFileSpec());
module_spec.GetSymbolFileSpec() = fspec;
module_spec.GetUUID() = uuid;
- FileSpec dsym_fspec = Symbols::LocateExecutableSymbolFile(module_spec);
+ FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
+ FileSpec dsym_fspec =
+ Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
if (dsym_fspec) {
DataBufferSP dsym_file_data_sp;
lldb::offset_t dsym_file_data_offset = 0;
@@ -157,12 +153,10 @@ SymbolVendorELF::CreateInstance(const lldb::ModuleSP &module_sp,
}
}
}
- return NULL;
+ return nullptr;
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
ConstString SymbolVendorELF::GetPluginName() { return GetPluginNameStatic(); }
uint32_t SymbolVendorELF::GetPluginVersion() { return 1; }
diff --git a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
index b0d956e31dc9c..0cd740da5ce39 100644
--- a/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
+++ b/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.h
@@ -1,9 +1,8 @@
//===-- SymbolVendorELF.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,16 +14,12 @@
class SymbolVendorELF : public lldb_private::SymbolVendor {
public:
- //------------------------------------------------------------------
// Constructors and Destructors
- //------------------------------------------------------------------
SymbolVendorELF(const lldb::ModuleSP &module_sp);
~SymbolVendorELF() override;
- //------------------------------------------------------------------
// Static Functions
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -37,9 +32,7 @@ public:
CreateInstance(const lldb::ModuleSP &module_sp,
lldb_private::Stream *feedback_strm);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
lldb_private::ConstString GetPluginName() override;
uint32_t GetPluginVersion() override;
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
index b70c2c44d3e69..4aa9fb634b61a 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
@@ -1,9 +1,8 @@
//===-- UnwindAssemblyInstEmulation.cpp --------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,9 +28,7 @@
using namespace lldb;
using namespace lldb_private;
-//-----------------------------------------------------------------------------------------------
// UnwindAssemblyInstEmulation method definitions
-//-----------------------------------------------------------------------------------------------
bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
AddressRange &range, Thread &thread, UnwindPlan &unwind_plan) {
@@ -57,11 +54,11 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
return false;
if (range.GetByteSize() > 0 && range.GetBaseAddress().IsValid() &&
- m_inst_emulator_ap.get()) {
+ m_inst_emulator_up.get()) {
// The instruction emulation subclass setup the unwind plan for the first
// instruction.
- m_inst_emulator_ap->CreateFunctionEntryUnwind(unwind_plan);
+ m_inst_emulator_up->CreateFunctionEntryUnwind(unwind_plan);
// CreateFunctionEntryUnwind should have created the first row. If it
// doesn't, then we are done.
@@ -70,8 +67,8 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
const bool prefer_file_cache = true;
DisassemblerSP disasm_sp(Disassembler::DisassembleBytes(
- m_arch, NULL, NULL, range.GetBaseAddress(), opcode_data, opcode_size,
- 99999, prefer_file_cache));
+ m_arch, nullptr, nullptr, range.GetBaseAddress(), opcode_data,
+ opcode_size, 99999, prefer_file_cache));
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
@@ -83,7 +80,7 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
const uint32_t addr_byte_size = m_arch.GetAddressByteSize();
const bool show_address = true;
const bool show_bytes = true;
- m_inst_emulator_ap->GetRegisterInfo(unwind_plan.GetRegisterKind(),
+ m_inst_emulator_up->GetRegisterInfo(unwind_plan.GetRegisterKind(),
unwind_plan.GetInitialCFARegister(),
m_cfa_reg_info);
@@ -129,14 +126,14 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
// cache the pc register number (in whatever register numbering this
// UnwindPlan uses) for quick reference during instruction parsing.
RegisterInfo pc_reg_info;
- m_inst_emulator_ap->GetRegisterInfo(
+ m_inst_emulator_up->GetRegisterInfo(
eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, pc_reg_info);
// cache the return address register number (in whatever register
// numbering this UnwindPlan uses) for quick reference during
// instruction parsing.
RegisterInfo ra_reg_info;
- m_inst_emulator_ap->GetRegisterInfo(
+ m_inst_emulator_up->GetRegisterInfo(
eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA, ra_reg_info);
// The architecture dependent condition code of the last processed
@@ -170,12 +167,12 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
m_register_values = it->second.second;
}
- m_inst_emulator_ap->SetInstruction(inst->GetOpcode(),
+ m_inst_emulator_up->SetInstruction(inst->GetOpcode(),
inst->GetAddress(), nullptr);
if (last_condition !=
- m_inst_emulator_ap->GetInstructionCondition()) {
- if (m_inst_emulator_ap->GetInstructionCondition() !=
+ m_inst_emulator_up->GetInstructionCondition()) {
+ if (m_inst_emulator_up->GetInstructionCondition() !=
EmulateInstruction::UnconditionalCondition &&
saved_unwind_states.count(current_offset) == 0) {
// If we don't have a saved row for the current offset then
@@ -216,13 +213,13 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly(
lldb_private::FormatEntity::Entry format;
FormatEntity::Parse("${frame.pc}: ", format);
inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize(), show_address,
- show_bytes, NULL, NULL, NULL, &format, 0);
+ show_bytes, nullptr, nullptr, nullptr, &format, 0);
log->PutString(strm.GetString());
}
- last_condition = m_inst_emulator_ap->GetInstructionCondition();
+ last_condition = m_inst_emulator_up->GetInstructionCondition();
- m_inst_emulator_ap->EvaluateInstruction(
+ m_inst_emulator_up->EvaluateInstruction(
eEmulateInstructionOptionIgnoreConditions);
// If the current instruction is a branch forward then save the
@@ -297,18 +294,16 @@ bool UnwindAssemblyInstEmulation::FirstNonPrologueInsn(
UnwindAssembly *
UnwindAssemblyInstEmulation::CreateInstance(const ArchSpec &arch) {
- std::unique_ptr<EmulateInstruction> inst_emulator_ap(
+ std::unique_ptr<EmulateInstruction> inst_emulator_up(
EmulateInstruction::FindPlugin(arch, eInstructionTypePrologueEpilogue,
- NULL));
+ nullptr));
// Make sure that all prologue instructions are handled
- if (inst_emulator_ap.get())
- return new UnwindAssemblyInstEmulation(arch, inst_emulator_ap.release());
- return NULL;
+ if (inst_emulator_up)
+ return new UnwindAssemblyInstEmulation(arch, inst_emulator_up.release());
+ return nullptr;
}
-//------------------------------------------------------------------
// PluginInterface protocol in UnwindAssemblyParser_x86
-//------------------------------------------------------------------
ConstString UnwindAssemblyInstEmulation::GetPluginName() {
return GetPluginNameStatic();
}
diff --git a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
index 5539b5217e9e6..9125bd5b1fe3c 100644
--- a/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
+++ b/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
@@ -1,9 +1,8 @@
//===-- UnwindAssemblyInstEmulation.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -48,9 +47,7 @@ public:
static lldb_private::UnwindAssembly *
CreateInstance(const lldb_private::ArchSpec &arch);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
@@ -67,14 +64,14 @@ private:
// Call CreateInstance to get an instance of this class
UnwindAssemblyInstEmulation(const lldb_private::ArchSpec &arch,
lldb_private::EmulateInstruction *inst_emulator)
- : UnwindAssembly(arch), m_inst_emulator_ap(inst_emulator),
- m_range_ptr(NULL), m_unwind_plan_ptr(NULL), m_curr_row(),
+ : UnwindAssembly(arch), m_inst_emulator_up(inst_emulator),
+ m_range_ptr(nullptr), m_unwind_plan_ptr(nullptr), m_curr_row(),
m_cfa_reg_info(), m_fp_is_cfa(false), m_register_values(),
m_pushed_regs(), m_curr_row_modified(false),
m_forward_branch_offset(0) {
- if (m_inst_emulator_ap.get()) {
- m_inst_emulator_ap->SetBaton(this);
- m_inst_emulator_ap->SetCallbacks(ReadMemory, WriteMemory, ReadRegister,
+ if (m_inst_emulator_up.get()) {
+ m_inst_emulator_up->SetBaton(this);
+ m_inst_emulator_up->SetCallbacks(ReadMemory, WriteMemory, ReadRegister,
WriteRegister);
}
}
@@ -129,7 +126,7 @@ private:
bool GetRegisterValue(const lldb_private::RegisterInfo &reg_info,
lldb_private::RegisterValue &reg_value);
- std::unique_ptr<lldb_private::EmulateInstruction> m_inst_emulator_ap;
+ std::unique_ptr<lldb_private::EmulateInstruction> m_inst_emulator_up;
lldb_private::AddressRange *m_range_ptr;
lldb_private::UnwindPlan *m_unwind_plan_ptr;
lldb_private::UnwindPlan::RowSP m_curr_row;
diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
index 04f9cbbf03ae3..ce168f0210471 100644
--- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
+++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
@@ -1,9 +1,8 @@
//===-- UnwindAssembly-x86.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,9 +30,7 @@
using namespace lldb;
using namespace lldb_private;
-//-----------------------------------------------------------------------------------------------
// UnwindAssemblyParser_x86 method definitions
-//-----------------------------------------------------------------------------------------------
UnwindAssembly_x86::UnwindAssembly_x86(const ArchSpec &arch)
: lldb_private::UnwindAssembly(arch),
@@ -242,12 +239,10 @@ UnwindAssembly *UnwindAssembly_x86::CreateInstance(const ArchSpec &arch) {
const llvm::Triple::ArchType cpu = arch.GetMachine();
if (cpu == llvm::Triple::x86 || cpu == llvm::Triple::x86_64)
return new UnwindAssembly_x86(arch);
- return NULL;
+ return nullptr;
}
-//------------------------------------------------------------------
// PluginInterface protocol in UnwindAssemblyParser_x86
-//------------------------------------------------------------------
ConstString UnwindAssembly_x86::GetPluginName() {
return GetPluginNameStatic();
diff --git a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
index c4052a8489da7..7c198bbc33afc 100644
--- a/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
+++ b/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h
@@ -1,9 +1,8 @@
//===-- UnwindAssembly-x86.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,9 +41,7 @@ public:
static lldb_private::UnwindAssembly *
CreateInstance(const lldb_private::ArchSpec &arch);
- //------------------------------------------------------------------
// PluginInterface protocol
- //------------------------------------------------------------------
static void Initialize();
static void Terminate();
diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
index f8e70204e5098..43041ca1bb2fb 100644
--- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
+++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.cpp
@@ -1,14 +1,15 @@
//===-- x86AssemblyInspectionEngine.cpp -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "x86AssemblyInspectionEngine.h"
+#include <memory>
+
#include "llvm-c/Disassembler.h"
#include "lldb/Core/Address.h"
@@ -365,8 +366,8 @@ bool x86AssemblyInspectionEngine::push_reg_p(int &regno) {
uint8_t *p = m_cur_insn;
int regno_prefix_bit = 0;
// If we have a rex prefix byte, check to see if a B bit is set
- if (m_wordsize == 8 && *p == 0x41) {
- regno_prefix_bit = 1 << 3;
+ if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+ regno_prefix_bit = (*p & 1) << 3;
p++;
}
if (*p >= 0x50 && *p <= 0x57) {
@@ -563,8 +564,8 @@ bool x86AssemblyInspectionEngine::pop_reg_p(int &regno) {
uint8_t *p = m_cur_insn;
int regno_prefix_bit = 0;
// If we have a rex prefix byte, check to see if a B bit is set
- if (m_wordsize == 8 && *p == 0x41) {
- regno_prefix_bit = 1 << 3;
+ if (m_wordsize == 8 && (*p & 0xfe) == 0x40) {
+ regno_prefix_bit = (*p & 1) << 3;
p++;
}
if (*p >= 0x58 && *p <= 0x5f) {
@@ -666,10 +667,207 @@ bool x86AssemblyInspectionEngine::mov_reg_to_local_stack_frame_p(
return false;
}
-// ret [0xc9] or [0xc2 imm8] or [0xca imm8]
+// Returns true if this is a jmp instruction where we can't
+// know the destination address statically.
+//
+// ff e0 jmpq *%rax
+// ff e1 jmpq *%rcx
+// ff 60 28 jmpq *0x28(%rax)
+// ff 60 60 jmpq *0x60(%rax)
+bool x86AssemblyInspectionEngine::jmp_to_reg_p() {
+ if (*m_cur_insn != 0xff)
+ return false;
+
+ // The second byte is a ModR/M /4 byte, strip off the registers
+ uint8_t second_byte_sans_reg = *(m_cur_insn + 1) & ~7;
+
+ // Don't handle 0x24 disp32, because the target address is
+ // knowable statically - pc_rel_branch_or_jump_p() will
+ // return the target address.
+
+ // [reg]
+ if (second_byte_sans_reg == 0x20)
+ return true;
+
+ // [reg]+disp8
+ if (second_byte_sans_reg == 0x60)
+ return true;
+
+ // [reg]+disp32
+ if (second_byte_sans_reg == 0xa0)
+ return true;
+
+ // reg
+ if (second_byte_sans_reg == 0xe0)
+ return true;
+
+ // disp32
+ // jumps to an address stored in memory, the value can't be cached
+ // in an unwind plan.
+ if (second_byte_sans_reg == 0x24)
+ return true;
+
+ // use SIB byte
+ // ff 24 fe jmpq *(%rsi,%rdi,8)
+ if (second_byte_sans_reg == 0x24)
+ return true;
+
+ return false;
+}
+
+// Detect branches to fixed pc-relative offsets.
+// Returns the offset from the address of the next instruction
+// that may be branch/jumped to.
+//
+// Cannot determine the offset of a JMP that jumps to the address in
+// a register ("jmpq *%rax") or offset from a register value
+// ("jmpq *0x28(%rax)"), this method will return false on those
+// instructions.
+//
+// These instructions all end in either a relative 8/16/32 bit value
+// depending on the instruction and the current execution mode of the
+// inferior process. Once we know the size of the opcode instruction,
+// we can use the total instruction length to determine the size of
+// the relative offset without having to compute it correctly.
+
+bool x86AssemblyInspectionEngine::pc_rel_branch_or_jump_p (
+ const int instruction_length, int &offset)
+{
+ int opcode_size = 0;
+
+ uint8_t b1 = m_cur_insn[0];
+
+ switch (b1) {
+ case 0x77: // JA/JNBE rel8
+ case 0x73: // JAE/JNB/JNC rel8
+ case 0x72: // JB/JC/JNAE rel8
+ case 0x76: // JBE/JNA rel8
+ case 0xe3: // JCXZ/JECXZ/JRCXZ rel8
+ case 0x74: // JE/JZ rel8
+ case 0x7f: // JG/JNLE rel8
+ case 0x7d: // JGE/JNL rel8
+ case 0x7c: // JL/JNGE rel8
+ case 0x7e: // JNG/JLE rel8
+ case 0x71: // JNO rel8
+ case 0x7b: // JNP/JPO rel8
+ case 0x79: // JNS rel8
+ case 0x75: // JNE/JNZ rel8
+ case 0x70: // JO rel8
+ case 0x7a: // JP/JPE rel8
+ case 0x78: // JS rel8
+ case 0xeb: // JMP rel8
+ case 0xe9: // JMP rel16/rel32
+ opcode_size = 1;
+ break;
+ default:
+ break;
+ }
+ if (b1 == 0x0f && opcode_size == 0) {
+ uint8_t b2 = m_cur_insn[1];
+ switch (b2) {
+ case 0x87: // JA/JNBE rel16/rel32
+ case 0x86: // JBE/JNA rel16/rel32
+ case 0x84: // JE/JZ rel16/rel32
+ case 0x8f: // JG/JNLE rel16/rel32
+ case 0x8d: // JNL/JGE rel16/rel32
+ case 0x8e: // JLE rel16/rel32
+ case 0x82: // JB/JC/JNAE rel16/rel32
+ case 0x83: // JAE/JNB/JNC rel16/rel32
+ case 0x85: // JNE/JNZ rel16/rel32
+ case 0x8c: // JL/JNGE rel16/rel32
+ case 0x81: // JNO rel16/rel32
+ case 0x8b: // JNP/JPO rel16/rel32
+ case 0x89: // JNS rel16/rel32
+ case 0x80: // JO rel16/rel32
+ case 0x8a: // JP rel16/rel32
+ case 0x88: // JS rel16/rel32
+ opcode_size = 2;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (opcode_size == 0)
+ return false;
+
+ offset = 0;
+ if (instruction_length - opcode_size == 1) {
+ int8_t rel8 = (int8_t) *(m_cur_insn + opcode_size);
+ offset = rel8;
+ } else if (instruction_length - opcode_size == 2) {
+ int16_t rel16 = extract_2_signed (m_cur_insn + opcode_size);
+ offset = rel16;
+ } else if (instruction_length - opcode_size == 4) {
+ int32_t rel32 = extract_4_signed (m_cur_insn + opcode_size);
+ offset = rel32;
+ } else {
+ return false;
+ }
+ return true;
+}
+
+// Returns true if this instruction is a intra-function branch or jump -
+// a branch/jump within the bounds of this same function.
+// Cannot predict where a jump through a register value ("jmpq *%rax")
+// will go, so it will return false on that instruction.
+bool x86AssemblyInspectionEngine::local_branch_p (
+ const addr_t current_func_text_offset,
+ const AddressRange &func_range,
+ const int instruction_length,
+ addr_t &target_insn_offset) {
+ int offset;
+ if (pc_rel_branch_or_jump_p (instruction_length, offset) && offset != 0) {
+ addr_t next_pc_value = current_func_text_offset + instruction_length;
+ if (offset < 0 && addr_t(-offset) > current_func_text_offset) {
+ // Branch target is before the start of this function
+ return false;
+ }
+ if (offset + next_pc_value > func_range.GetByteSize()) {
+ // Branch targets outside this function's bounds
+ return false;
+ }
+ // This instruction branches to target_insn_offset (byte offset into the function)
+ target_insn_offset = next_pc_value + offset;
+ return true;
+ }
+ return false;
+}
+
+// Returns true if this instruction is a inter-function branch or jump - a
+// branch/jump to another function.
+// Cannot predict where a jump through a register value ("jmpq *%rax")
+// will go, so it will return false on that instruction.
+bool x86AssemblyInspectionEngine::non_local_branch_p (
+ const addr_t current_func_text_offset,
+ const AddressRange &func_range,
+ const int instruction_length) {
+ int offset;
+ addr_t target_insn_offset;
+ if (pc_rel_branch_or_jump_p (instruction_length, offset)) {
+ return !local_branch_p(current_func_text_offset,func_range,instruction_length,target_insn_offset);
+ }
+ return false;
+}
+
+// ret [0xc3] or [0xcb] or [0xc2 imm16] or [0xca imm16]
bool x86AssemblyInspectionEngine::ret_pattern_p() {
uint8_t *p = m_cur_insn;
- return *p == 0xc9 || *p == 0xc2 || *p == 0xca || *p == 0xc3;
+ return *p == 0xc3 || *p == 0xc2 || *p == 0xca || *p == 0xcb;
+}
+
+uint16_t x86AssemblyInspectionEngine::extract_2(uint8_t *b) {
+ uint16_t v = 0;
+ for (int i = 1; i >= 0; i--)
+ v = (v << 8) | b[i];
+ return v;
+}
+
+int16_t x86AssemblyInspectionEngine::extract_2_signed(uint8_t *b) {
+ int16_t v = 0;
+ for (int i = 1; i >= 0; i--)
+ v = (v << 8) | b[i];
+ return v;
}
uint32_t x86AssemblyInspectionEngine::extract_4(uint8_t *b) {
@@ -679,6 +877,14 @@ uint32_t x86AssemblyInspectionEngine::extract_4(uint8_t *b) {
return v;
}
+int32_t x86AssemblyInspectionEngine::extract_4_signed(uint8_t *b) {
+ int32_t v = 0;
+ for (int i = 3; i >= 0; i--)
+ v = (v << 8) | b[i];
+ return v;
+}
+
+
bool x86AssemblyInspectionEngine::instruction_length(uint8_t *insn_p,
int &length,
uint32_t buffer_remaining_bytes) {
@@ -704,7 +910,6 @@ bool x86AssemblyInspectionEngine::machine_regno_to_lldb_regno(
return true;
}
return false;
- return false;
}
bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
@@ -1028,25 +1233,47 @@ bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly(
}
}
- else if (ret_pattern_p() && prologue_completed_row.get()) {
- // Reinstate the saved prologue setup for any instructions that come
- // after the ret instruction
-
- UnwindPlan::Row *newrow = new UnwindPlan::Row;
- *newrow = *prologue_completed_row.get();
- row.reset(newrow);
- current_sp_bytes_offset_from_fa =
- prologue_completed_sp_bytes_offset_from_cfa;
- is_aligned = prologue_completed_is_aligned;
-
- saved_registers.clear();
- saved_registers.resize(prologue_completed_saved_registers.size(), false);
- for (size_t i = 0; i < prologue_completed_saved_registers.size(); ++i) {
- saved_registers[i] = prologue_completed_saved_registers[i];
+ else if (prologue_completed_row.get() &&
+ (ret_pattern_p() ||
+ non_local_branch_p (current_func_text_offset, func_range, insn_len) ||
+ jmp_to_reg_p())) {
+ // Check if the current instruction is the end of an epilogue sequence,
+ // and if so, re-instate the prologue-completed unwind state.
+
+ // The current instruction is a branch/jump outside this function,
+ // a ret, or a jump through a register value which we cannot
+ // determine the effcts of. Verify that the stack frame state
+ // has been unwound to the same as it was at function entry to avoid
+ // mis-identifying a JMP instruction as an epilogue.
+ UnwindPlan::Row::RegisterLocation sp, pc;
+ if (row->GetRegisterInfo(m_lldb_sp_regnum, sp) &&
+ row->GetRegisterInfo(m_lldb_ip_regnum, pc)) {
+ // Any ret instruction variant is definitely indicative of an
+ // epilogue; for other insn patterns verify that we're back to
+ // the original unwind state.
+ if (ret_pattern_p() ||
+ (sp.IsCFAPlusOffset() && sp.GetOffset() == 0 &&
+ pc.IsAtCFAPlusOffset() && pc.GetOffset() == -m_wordsize)) {
+ // Reinstate the saved prologue setup for any instructions that come
+ // after the epilogue
+
+ UnwindPlan::Row *newrow = new UnwindPlan::Row;
+ *newrow = *prologue_completed_row.get();
+ row.reset(newrow);
+ current_sp_bytes_offset_from_fa =
+ prologue_completed_sp_bytes_offset_from_cfa;
+ is_aligned = prologue_completed_is_aligned;
+
+ saved_registers.clear();
+ saved_registers.resize(prologue_completed_saved_registers.size(), false);
+ for (size_t i = 0; i < prologue_completed_saved_registers.size(); ++i) {
+ saved_registers[i] = prologue_completed_saved_registers[i];
+ }
+
+ in_epilogue = true;
+ row_updated = true;
+ }
}
-
- in_epilogue = true;
- row_updated = true;
}
// call next instruction
@@ -1173,7 +1400,7 @@ bool x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite(
*new_row = *original_last_row;
new_row->SetOffset(offset);
unwind_plan.AppendRow(new_row);
- row.reset(new UnwindPlan::Row());
+ row = std::make_shared<UnwindPlan::Row>();
*row = *new_row;
reinstate_unwind_state = false;
unwind_plan_updated = true;
diff --git a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
index e02b510ba1f95..680598abdeff9 100644
--- a/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
+++ b/source/Plugins/UnwindAssembly/x86/x86AssemblyInspectionEngine.h
@@ -1,9 +1,8 @@
//===-- x86AssemblyInspectionEngine.h ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -115,7 +114,19 @@ private:
bool call_next_insn_pattern_p();
bool mov_reg_to_local_stack_frame_p(int &regno, int &rbp_offset);
bool ret_pattern_p();
+ bool jmp_to_reg_p();
+ bool pc_rel_branch_or_jump_p (const int instruction_length, int &offset);
+ bool non_local_branch_p (const lldb::addr_t current_func_text_offset,
+ const lldb_private::AddressRange &func_range,
+ const int instruction_length);
+ bool local_branch_p (const lldb::addr_t current_func_text_offset,
+ const lldb_private::AddressRange &func_range,
+ const int instruction_length,
+ lldb::addr_t &target_insn_offset);
+ uint16_t extract_2(uint8_t *b);
+ int16_t extract_2_signed(uint8_t *b);
uint32_t extract_4(uint8_t *b);
+ int32_t extract_4_signed(uint8_t *b);
bool instruction_length(uint8_t *insn, int &length, uint32_t buffer_remaining_bytes);
diff --git a/source/Symbol/ArmUnwindInfo.cpp b/source/Symbol/ArmUnwindInfo.cpp
index 08f28073be21b..b9fd84b1e706e 100644
--- a/source/Symbol/ArmUnwindInfo.cpp
+++ b/source/Symbol/ArmUnwindInfo.cpp
@@ -1,9 +1,8 @@
//===-- ArmUnwindInfo.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -305,7 +304,7 @@ bool ArmUnwindInfo::GetUnwindPlan(Target &target, const Address &addr,
// 11001yyy
// Spare (yyy != 000, 001)
return false;
- } else if ((byte1 & 0xf8) == 0xc0) {
+ } else if ((byte1 & 0xf8) == 0xd0) {
// 11010nnn
// Pop VFP double-precision registers D[8]-D[8+nnn] saved (as if) by
// FSTMFDD (see remark d)
diff --git a/source/Symbol/Block.cpp b/source/Symbol/Block.cpp
index d0342355911cf..6fe617080f961 100644
--- a/source/Symbol/Block.cpp
+++ b/source/Symbol/Block.cpp
@@ -1,9 +1,8 @@
//===-- Block.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,6 +16,8 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/Log.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -211,6 +212,21 @@ Block *Block::GetInlinedParent() {
return nullptr;
}
+Block *Block::GetContainingInlinedBlockWithCallSite(
+ const Declaration &find_call_site) {
+ Block *inlined_block = GetContainingInlinedBlock();
+
+ while (inlined_block) {
+ const auto *function_info = inlined_block->GetInlinedFunctionInfo();
+
+ if (function_info &&
+ function_info->GetCallSite().FileAndLineEqual(find_call_site))
+ return inlined_block;
+ inlined_block = inlined_block->GetInlinedParent();
+ }
+ return nullptr;
+}
+
bool Block::GetRangeContainingOffset(const addr_t offset, Range &range) {
const Range *range_ptr = m_ranges.FindEntryThatContains(offset);
if (range_ptr) {
@@ -364,8 +380,8 @@ void Block::AddChild(const BlockSP &child_block_sp) {
void Block::SetInlinedFunctionInfo(const char *name, const char *mangled,
const Declaration *decl_ptr,
const Declaration *call_decl_ptr) {
- m_inlineInfoSP.reset(
- new InlineFunctionInfo(name, mangled, decl_ptr, call_decl_ptr));
+ m_inlineInfoSP = std::make_shared<InlineFunctionInfo>(name, mangled, decl_ptr,
+ call_decl_ptr);
}
VariableListSP Block::GetBlockVariableList(bool can_create) {
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 85436b630b7d7..205523355ce0b 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -1,9 +1,8 @@
//===-- ClangASTContext.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -53,6 +52,7 @@
#include "clang/Basic/TargetOptions.h"
#include "clang/Frontend/FrontendOptions.h"
#include "clang/Frontend/LangStandard.h"
+#include "clang/Sema/Sema.h"
#ifdef LLDB_DEFINED_NDEBUG_FOR_CLANG
#undef NDEBUG
@@ -86,7 +86,6 @@
#include "lldb/Symbol/VerifyDecl.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Language.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/DataExtractor.h"
@@ -95,6 +94,7 @@
#include "lldb/Utility/RegularExpression.h"
#include "lldb/Utility/Scalar.h"
+#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
#include "Plugins/SymbolFile/PDB/PDBASTParser.h"
@@ -654,19 +654,17 @@ static void ParseLangArgs(LangOptions &Opts, InputKind IK, const char *triple) {
}
ClangASTContext::ClangASTContext(const char *target_triple)
- : TypeSystem(TypeSystem::eKindClang), m_target_triple(), m_ast_ap(),
- m_language_options_ap(), m_source_manager_ap(), m_diagnostics_engine_ap(),
- m_target_options_rp(), m_target_info_ap(), m_identifier_table_ap(),
- m_selector_table_ap(), m_builtins_ap(), m_callback_tag_decl(nullptr),
+ : TypeSystem(TypeSystem::eKindClang), m_target_triple(), m_ast_up(),
+ m_language_options_up(), m_source_manager_up(), m_diagnostics_engine_up(),
+ m_target_options_rp(), m_target_info_up(), m_identifier_table_up(),
+ m_selector_table_up(), m_builtins_up(), m_callback_tag_decl(nullptr),
m_callback_objc_decl(nullptr), m_callback_baton(nullptr),
m_pointer_byte_size(0), m_ast_owned(false) {
if (target_triple && target_triple[0])
SetTargetTriple(target_triple);
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ClangASTContext::~ClangASTContext() { Finalize(); }
ConstString ClangASTContext::GetPluginNameStatic() {
@@ -715,13 +713,13 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language,
new ClangASTContextForExpressions(*target));
if (ast_sp) {
ast_sp->SetArchitecture(fixed_arch);
- ast_sp->m_scratch_ast_source_ap.reset(
+ ast_sp->m_scratch_ast_source_up.reset(
new ClangASTSource(target->shared_from_this()));
lldbassert(ast_sp->getFileManager());
- ast_sp->m_scratch_ast_source_ap->InstallASTContext(
+ ast_sp->m_scratch_ast_source_up->InstallASTContext(
*ast_sp->getASTContext(), *ast_sp->getFileManager(), true);
llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> proxy_ast_source(
- ast_sp->m_scratch_ast_source_ap->CreateProxy());
+ ast_sp->m_scratch_ast_source_up->CreateProxy());
ast_sp->SetExternalSource(proxy_ast_source);
return ast_sp;
}
@@ -764,37 +762,43 @@ void ClangASTContext::Terminate() {
}
void ClangASTContext::Finalize() {
- if (m_ast_ap.get()) {
- GetASTMap().Erase(m_ast_ap.get());
+ if (m_ast_up) {
+ GetASTMap().Erase(m_ast_up.get());
if (!m_ast_owned)
- m_ast_ap.release();
+ m_ast_up.release();
}
- m_builtins_ap.reset();
- m_selector_table_ap.reset();
- m_identifier_table_ap.reset();
- m_target_info_ap.reset();
+ m_builtins_up.reset();
+ m_selector_table_up.reset();
+ m_identifier_table_up.reset();
+ m_target_info_up.reset();
m_target_options_rp.reset();
- m_diagnostics_engine_ap.reset();
- m_source_manager_ap.reset();
- m_language_options_ap.reset();
- m_ast_ap.reset();
- m_scratch_ast_source_ap.reset();
+ m_diagnostics_engine_up.reset();
+ m_source_manager_up.reset();
+ m_language_options_up.reset();
+ m_ast_up.reset();
+ m_scratch_ast_source_up.reset();
}
void ClangASTContext::Clear() {
- m_ast_ap.reset();
- m_language_options_ap.reset();
- m_source_manager_ap.reset();
- m_diagnostics_engine_ap.reset();
+ m_ast_up.reset();
+ m_language_options_up.reset();
+ m_source_manager_up.reset();
+ m_diagnostics_engine_up.reset();
m_target_options_rp.reset();
- m_target_info_ap.reset();
- m_identifier_table_ap.reset();
- m_selector_table_ap.reset();
- m_builtins_ap.reset();
+ m_target_info_up.reset();
+ m_identifier_table_up.reset();
+ m_selector_table_up.reset();
+ m_builtins_up.reset();
m_pointer_byte_size = 0;
}
+void ClangASTContext::setSema(Sema *s) {
+ // Ensure that the new sema actually belongs to our ASTContext.
+ assert(s == nullptr || &s->getASTContext() == m_ast_up.get());
+ m_sema = s;
+}
+
const char *ClangASTContext::GetTargetTriple() {
return m_target_triple.c_str();
}
@@ -816,10 +820,10 @@ bool ClangASTContext::HasExternalSource() {
}
void ClangASTContext::SetExternalSource(
- llvm::IntrusiveRefCntPtr<ExternalASTSource> &ast_source_ap) {
+ llvm::IntrusiveRefCntPtr<ExternalASTSource> &ast_source_up) {
ASTContext *ast = getASTContext();
if (ast) {
- ast->setExternalSource(ast_source_ap);
+ ast->setExternalSource(ast_source_up);
ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(true);
}
}
@@ -828,52 +832,52 @@ void ClangASTContext::RemoveExternalSource() {
ASTContext *ast = getASTContext();
if (ast) {
- llvm::IntrusiveRefCntPtr<ExternalASTSource> empty_ast_source_ap;
- ast->setExternalSource(empty_ast_source_ap);
+ llvm::IntrusiveRefCntPtr<ExternalASTSource> empty_ast_source_up;
+ ast->setExternalSource(empty_ast_source_up);
ast->getTranslationUnitDecl()->setHasExternalLexicalStorage(false);
}
}
void ClangASTContext::setASTContext(clang::ASTContext *ast_ctx) {
if (!m_ast_owned) {
- m_ast_ap.release();
+ m_ast_up.release();
}
m_ast_owned = false;
- m_ast_ap.reset(ast_ctx);
+ m_ast_up.reset(ast_ctx);
GetASTMap().Insert(ast_ctx, this);
}
ASTContext *ClangASTContext::getASTContext() {
- if (m_ast_ap.get() == nullptr) {
+ if (m_ast_up == nullptr) {
m_ast_owned = true;
- m_ast_ap.reset(new ASTContext(*getLanguageOptions(), *getSourceManager(),
+ m_ast_up.reset(new ASTContext(*getLanguageOptions(), *getSourceManager(),
*getIdentifierTable(), *getSelectorTable(),
*getBuiltinContext()));
- m_ast_ap->getDiagnostics().setClient(getDiagnosticConsumer(), false);
+ m_ast_up->getDiagnostics().setClient(getDiagnosticConsumer(), false);
// This can be NULL if we don't know anything about the architecture or if
// the target for an architecture isn't enabled in the llvm/clang that we
// built
TargetInfo *target_info = getTargetInfo();
if (target_info)
- m_ast_ap->InitBuiltinTypes(*target_info);
+ m_ast_up->InitBuiltinTypes(*target_info);
if ((m_callback_tag_decl || m_callback_objc_decl) && m_callback_baton) {
- m_ast_ap->getTranslationUnitDecl()->setHasExternalLexicalStorage();
- // m_ast_ap->getTranslationUnitDecl()->setHasExternalVisibleStorage();
+ m_ast_up->getTranslationUnitDecl()->setHasExternalLexicalStorage();
+ // m_ast_up->getTranslationUnitDecl()->setHasExternalVisibleStorage();
}
- GetASTMap().Insert(m_ast_ap.get(), this);
+ GetASTMap().Insert(m_ast_up.get(), this);
- llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_ap(
+ llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> ast_source_up(
new ClangExternalASTSourceCallbacks(
ClangASTContext::CompleteTagDecl,
ClangASTContext::CompleteObjCInterfaceDecl, nullptr,
ClangASTContext::LayoutRecordType, this));
- SetExternalSource(ast_source_ap);
+ SetExternalSource(ast_source_up);
}
- return m_ast_ap.get();
+ return m_ast_up.get();
}
ClangASTContext *ClangASTContext::GetASTContext(clang::ASTContext *ast) {
@@ -882,61 +886,62 @@ ClangASTContext *ClangASTContext::GetASTContext(clang::ASTContext *ast) {
}
Builtin::Context *ClangASTContext::getBuiltinContext() {
- if (m_builtins_ap.get() == nullptr)
- m_builtins_ap.reset(new Builtin::Context());
- return m_builtins_ap.get();
+ if (m_builtins_up == nullptr)
+ m_builtins_up.reset(new Builtin::Context());
+ return m_builtins_up.get();
}
IdentifierTable *ClangASTContext::getIdentifierTable() {
- if (m_identifier_table_ap.get() == nullptr)
- m_identifier_table_ap.reset(
+ if (m_identifier_table_up == nullptr)
+ m_identifier_table_up.reset(
new IdentifierTable(*ClangASTContext::getLanguageOptions(), nullptr));
- return m_identifier_table_ap.get();
+ return m_identifier_table_up.get();
}
LangOptions *ClangASTContext::getLanguageOptions() {
- if (m_language_options_ap.get() == nullptr) {
- m_language_options_ap.reset(new LangOptions());
- ParseLangArgs(*m_language_options_ap, InputKind::ObjCXX, GetTargetTriple());
- // InitializeLangOptions(*m_language_options_ap, InputKind::ObjCXX);
+ if (m_language_options_up == nullptr) {
+ m_language_options_up.reset(new LangOptions());
+ ParseLangArgs(*m_language_options_up, InputKind::ObjCXX, GetTargetTriple());
+ // InitializeLangOptions(*m_language_options_up, InputKind::ObjCXX);
}
- return m_language_options_ap.get();
+ return m_language_options_up.get();
}
SelectorTable *ClangASTContext::getSelectorTable() {
- if (m_selector_table_ap.get() == nullptr)
- m_selector_table_ap.reset(new SelectorTable());
- return m_selector_table_ap.get();
+ if (m_selector_table_up == nullptr)
+ m_selector_table_up.reset(new SelectorTable());
+ return m_selector_table_up.get();
}
clang::FileManager *ClangASTContext::getFileManager() {
- if (m_file_manager_ap.get() == nullptr) {
+ if (m_file_manager_up == nullptr) {
clang::FileSystemOptions file_system_options;
- m_file_manager_ap.reset(new clang::FileManager(file_system_options));
+ m_file_manager_up.reset(new clang::FileManager(
+ file_system_options, FileSystem::Instance().GetVirtualFileSystem()));
}
- return m_file_manager_ap.get();
+ return m_file_manager_up.get();
}
clang::SourceManager *ClangASTContext::getSourceManager() {
- if (m_source_manager_ap.get() == nullptr)
- m_source_manager_ap.reset(
+ if (m_source_manager_up == nullptr)
+ m_source_manager_up.reset(
new clang::SourceManager(*getDiagnosticsEngine(), *getFileManager()));
- return m_source_manager_ap.get();
+ return m_source_manager_up.get();
}
clang::DiagnosticsEngine *ClangASTContext::getDiagnosticsEngine() {
- if (m_diagnostics_engine_ap.get() == nullptr) {
+ if (m_diagnostics_engine_up == nullptr) {
llvm::IntrusiveRefCntPtr<DiagnosticIDs> diag_id_sp(new DiagnosticIDs());
- m_diagnostics_engine_ap.reset(
+ m_diagnostics_engine_up.reset(
new DiagnosticsEngine(diag_id_sp, new DiagnosticOptions()));
}
- return m_diagnostics_engine_ap.get();
+ return m_diagnostics_engine_up.get();
}
clang::MangleContext *ClangASTContext::getMangleContext() {
- if (m_mangle_ctx_ap.get() == nullptr)
- m_mangle_ctx_ap.reset(getASTContext()->createMangleContext());
- return m_mangle_ctx_ap.get();
+ if (m_mangle_ctx_up == nullptr)
+ m_mangle_ctx_up.reset(getASTContext()->createMangleContext());
+ return m_mangle_ctx_up.get();
}
class NullDiagnosticConsumer : public DiagnosticConsumer {
@@ -946,7 +951,7 @@ public:
}
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
- const clang::Diagnostic &info) {
+ const clang::Diagnostic &info) override {
if (m_log) {
llvm::SmallVector<char, 32> diag_str(10);
info.FormatDiagnostic(diag_str);
@@ -964,16 +969,16 @@ private:
};
DiagnosticConsumer *ClangASTContext::getDiagnosticConsumer() {
- if (m_diagnostic_consumer_ap.get() == nullptr)
- m_diagnostic_consumer_ap.reset(new NullDiagnosticConsumer);
+ if (m_diagnostic_consumer_up == nullptr)
+ m_diagnostic_consumer_up.reset(new NullDiagnosticConsumer);
- return m_diagnostic_consumer_ap.get();
+ return m_diagnostic_consumer_up.get();
}
std::shared_ptr<clang::TargetOptions> &ClangASTContext::getTargetOptions() {
- if (m_target_options_rp.get() == nullptr && !m_target_triple.empty()) {
+ if (m_target_options_rp == nullptr && !m_target_triple.empty()) {
m_target_options_rp = std::make_shared<clang::TargetOptions>();
- if (m_target_options_rp.get() != nullptr)
+ if (m_target_options_rp != nullptr)
m_target_options_rp->Triple = m_target_triple;
}
return m_target_options_rp;
@@ -981,10 +986,10 @@ std::shared_ptr<clang::TargetOptions> &ClangASTContext::getTargetOptions() {
TargetInfo *ClangASTContext::getTargetInfo() {
// target_triple should be something like "x86_64-apple-macosx"
- if (m_target_info_ap.get() == nullptr && !m_target_triple.empty())
- m_target_info_ap.reset(TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(),
+ if (m_target_info_up == nullptr && !m_target_triple.empty())
+ m_target_info_up.reset(TargetInfo::CreateTargetInfo(*getDiagnosticsEngine(),
getTargetOptions()));
- return m_target_info_ap.get();
+ return m_target_info_up.get();
}
#pragma mark Basic Types
@@ -1065,7 +1070,7 @@ CompilerType ClangASTContext::GetBuiltinTypeForEncodingAndBitSize(
}
lldb::BasicType
-ClangASTContext::GetBasicTypeEnumeration(const ConstString &name) {
+ClangASTContext::GetBasicTypeEnumeration(ConstString name) {
if (name) {
typedef UniqueCStringMap<lldb::BasicType> TypeNameToBasicTypeMap;
static TypeNameToBasicTypeMap g_type_map;
@@ -1131,7 +1136,7 @@ ClangASTContext::GetBasicTypeEnumeration(const ConstString &name) {
}
CompilerType ClangASTContext::GetBasicType(ASTContext *ast,
- const ConstString &name) {
+ ConstString name) {
if (ast) {
lldb::BasicType basic_type = ClangASTContext::GetBasicTypeEnumeration(name);
return ClangASTContext::GetBasicType(ast, basic_type);
@@ -1410,7 +1415,14 @@ clang::Decl *ClangASTContext::CopyDecl(ASTContext *dst_ast, ASTContext *src_ast,
FileManager file_manager(file_system_options);
ASTImporter importer(*dst_ast, file_manager, *src_ast, file_manager, false);
- return importer.Import(source_decl);
+ if (llvm::Expected<clang::Decl *> ret_or_error =
+ importer.Import(source_decl)) {
+ return *ret_or_error;
+ } else {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG_ERROR(log, ret_or_error.takeError(), "Couldn't import decl: {0}");
+ return nullptr;
+ }
}
bool ClangASTContext::AreTypesSame(CompilerType type1, CompilerType type2,
@@ -1550,25 +1562,24 @@ static TemplateParameterList *CreateTemplateParameterList(
}
}
- if (template_param_infos.packed_args &&
- template_param_infos.packed_args->args.size()) {
+ if (template_param_infos.packed_args) {
IdentifierInfo *identifier_info = nullptr;
if (template_param_infos.pack_name && template_param_infos.pack_name[0])
identifier_info = &ast->Idents.get(template_param_infos.pack_name);
const bool parameter_pack_true = true;
- if (IsValueParam(template_param_infos.packed_args->args[0])) {
+
+ if (!template_param_infos.packed_args->args.empty() &&
+ IsValueParam(template_param_infos.packed_args->args[0])) {
template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
- *ast, decl_context,
- SourceLocation(), SourceLocation(), depth, num_template_params,
- identifier_info,
+ *ast, decl_context, SourceLocation(), SourceLocation(), depth,
+ num_template_params, identifier_info,
template_param_infos.packed_args->args[0].getIntegralType(),
parameter_pack_true, nullptr));
} else {
template_param_decls.push_back(TemplateTypeParmDecl::Create(
- *ast, decl_context,
- SourceLocation(), SourceLocation(), depth, num_template_params,
- identifier_info,
- is_typename, parameter_pack_true));
+ *ast, decl_context, SourceLocation(), SourceLocation(), depth,
+ num_template_params, identifier_info, is_typename,
+ parameter_pack_true));
}
}
clang::Expr *const requires_clause = nullptr; // TODO: Concepts
@@ -1604,10 +1615,11 @@ clang::FunctionTemplateDecl *ClangASTContext::CreateFunctionTemplateDecl(
void ClangASTContext::CreateFunctionTemplateSpecializationInfo(
FunctionDecl *func_decl, clang::FunctionTemplateDecl *func_tmpl_decl,
const TemplateParameterInfos &infos) {
- TemplateArgumentList template_args(TemplateArgumentList::OnStack, infos.args);
+ TemplateArgumentList *template_args_ptr =
+ TemplateArgumentList::CreateCopy(func_decl->getASTContext(), infos.args);
- func_decl->setFunctionTemplateSpecialization(func_tmpl_decl, &template_args,
- nullptr);
+ func_decl->setFunctionTemplateSpecialization(func_tmpl_decl,
+ template_args_ptr, nullptr);
}
ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
@@ -1656,6 +1668,7 @@ ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
decl_ctx, // What decl context do we use here? TU? The actual decl
// context?
SourceLocation(), decl_name, template_param_list, template_cxx_decl);
+ template_cxx_decl->setDescribedClassTemplate(class_template_decl);
if (class_template_decl) {
if (access_type != eAccessNone)
@@ -1893,9 +1906,8 @@ ClangASTContext::GetNumBaseClasses(const CXXRecordDecl *cxx_record_decl,
#pragma mark Namespace Declarations
-NamespaceDecl *
-ClangASTContext::GetUniqueNamespaceDeclaration(const char *name,
- DeclContext *decl_ctx) {
+NamespaceDecl *ClangASTContext::GetUniqueNamespaceDeclaration(
+ const char *name, DeclContext *decl_ctx, bool is_inline) {
NamespaceDecl *namespace_decl = nullptr;
ASTContext *ast = getASTContext();
TranslationUnitDecl *translation_unit_decl = ast->getTranslationUnitDecl();
@@ -1913,7 +1925,7 @@ ClangASTContext::GetUniqueNamespaceDeclaration(const char *name,
}
namespace_decl =
- NamespaceDecl::Create(*ast, decl_ctx, false, SourceLocation(),
+ NamespaceDecl::Create(*ast, decl_ctx, is_inline, SourceLocation(),
SourceLocation(), &identifier_info, nullptr);
decl_ctx->addDecl(namespace_decl);
@@ -1943,7 +1955,8 @@ ClangASTContext::GetUniqueNamespaceDeclaration(const char *name,
assert(namespace_decl ==
parent_namespace_decl->getAnonymousNamespace());
} else {
- // BAD!!!
+ assert(false && "GetUniqueNamespaceDeclaration called with no name and "
+ "no namespace as decl_ctx");
}
}
}
@@ -1954,12 +1967,13 @@ ClangASTContext::GetUniqueNamespaceDeclaration(const char *name,
}
NamespaceDecl *ClangASTContext::GetUniqueNamespaceDeclaration(
- clang::ASTContext *ast, const char *name, clang::DeclContext *decl_ctx) {
+ clang::ASTContext *ast, const char *name, clang::DeclContext *decl_ctx,
+ bool is_inline) {
ClangASTContext *ast_ctx = ClangASTContext::GetASTContext(ast);
if (ast_ctx == nullptr)
return nullptr;
- return ast_ctx->GetUniqueNamespaceDeclaration(name, decl_ctx);
+ return ast_ctx->GetUniqueNamespaceDeclaration(name, decl_ctx, is_inline);
}
clang::BlockDecl *
@@ -2158,7 +2172,7 @@ FunctionDecl *ClangASTContext::CreateFunctionDeclaration(
*ast, decl_ctx, SourceLocation(), SourceLocation(), declarationName,
ClangUtil::GetQualType(function_clang_type), nullptr,
(clang::StorageClass)storage, is_inline, hasWrittenPrototype,
- isConstexprSpecified);
+ isConstexprSpecified ? CSK_constexpr : CSK_unspecified);
if (func_decl)
decl_ctx->addDecl(func_decl);
@@ -2234,7 +2248,7 @@ void ClangASTContext::SetFunctionParameters(FunctionDecl *function_decl,
CompilerType
ClangASTContext::CreateBlockPointerType(const CompilerType &function_type) {
- QualType block_type = m_ast_ap->getBlockPointerType(
+ QualType block_type = m_ast_up->getBlockPointerType(
clang::QualType::getFromOpaquePtr(function_type.GetOpaqueQualType()));
return CompilerType(this, block_type.getAsOpaquePtr());
@@ -2272,7 +2286,7 @@ CompilerType ClangASTContext::CreateArrayType(const CompilerType &element_type,
}
CompilerType ClangASTContext::CreateStructForIdentifier(
- const ConstString &type_name,
+ ConstString type_name,
const std::initializer_list<std::pair<const char *, CompilerType>>
&type_fields,
bool packed) {
@@ -2297,7 +2311,7 @@ CompilerType ClangASTContext::CreateStructForIdentifier(
}
CompilerType ClangASTContext::GetOrCreateStructForIdentifier(
- const ConstString &type_name,
+ ConstString type_name,
const std::initializer_list<std::pair<const char *, CompilerType>>
&type_fields,
bool packed) {
@@ -2435,21 +2449,17 @@ void ClangASTContext::DumpDeclHiearchy(clang::Decl *decl) {
bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl,
clang::Decl *rhs_decl) {
if (lhs_decl && rhs_decl) {
- //----------------------------------------------------------------------
// Make sure the decl kinds match first
- //----------------------------------------------------------------------
const clang::Decl::Kind lhs_decl_kind = lhs_decl->getKind();
const clang::Decl::Kind rhs_decl_kind = rhs_decl->getKind();
if (lhs_decl_kind == rhs_decl_kind) {
- //------------------------------------------------------------------
// Now check that the decl contexts kinds are all equivalent before we
// have to check any names of the decl contexts...
- //------------------------------------------------------------------
clang::DeclContext *lhs_decl_ctx = lhs_decl->getDeclContext();
clang::DeclContext *rhs_decl_ctx = rhs_decl->getDeclContext();
if (lhs_decl_ctx && rhs_decl_ctx) {
- while (1) {
+ while (true) {
if (lhs_decl_ctx && rhs_decl_ctx) {
const clang::Decl::Kind lhs_decl_ctx_kind =
lhs_decl_ctx->getDeclKind();
@@ -2467,9 +2477,7 @@ bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl,
return false;
}
- //--------------------------------------------------------------
// Now make sure the name of the decls match
- //--------------------------------------------------------------
clang::NamedDecl *lhs_named_decl =
llvm::dyn_cast<clang::NamedDecl>(lhs_decl);
clang::NamedDecl *rhs_named_decl =
@@ -2485,13 +2493,11 @@ bool ClangASTContext::DeclsAreEquivalent(clang::Decl *lhs_decl,
} else
return false;
- //--------------------------------------------------------------
// We know that the decl context kinds all match, so now we need to
// make sure the names match as well
- //--------------------------------------------------------------
lhs_decl_ctx = lhs_decl->getDeclContext();
rhs_decl_ctx = rhs_decl->getDeclContext();
- while (1) {
+ while (true) {
switch (lhs_decl_ctx->getDeclKind()) {
case clang::Decl::TranslationUnit:
// We don't care about the translation unit names
@@ -2830,9 +2836,7 @@ ConvertAccessTypeToObjCIvarAccessControl(AccessType access) {
return clang::ObjCIvarDecl::None;
}
-//----------------------------------------------------------------------
// Tests
-//----------------------------------------------------------------------
bool ClangASTContext::IsAggregateType(lldb::opaque_compiler_type_t type) {
clang::QualType qual_type(GetCanonicalQualType(type));
@@ -3324,7 +3328,7 @@ bool ClangASTContext::IsBlockPointerType(
const clang::BlockPointerType *block_pointer_type =
qual_type->getAs<clang::BlockPointerType>();
QualType pointee_type = block_pointer_type->getPointeeType();
- QualType function_pointer_type = m_ast_ap->getPointerType(pointee_type);
+ QualType function_pointer_type = m_ast_up->getPointerType(pointee_type);
*function_pointer_type_ptr =
CompilerType(getASTContext(), function_pointer_type);
}
@@ -3909,6 +3913,14 @@ bool ClangASTContext::IsVoidType(lldb::opaque_compiler_type_t type) {
return GetCanonicalQualType(type)->isVoidType();
}
+bool ClangASTContext::CanPassInRegisters(const CompilerType &type) {
+ if (auto *record_decl =
+ ClangASTContext::GetAsRecordDecl(type)) {
+ return record_decl->canPassInRegisters();
+ }
+ return false;
+}
+
bool ClangASTContext::SupportsLanguage(lldb::LanguageType language) {
return ClangASTContextSupportsLanguage(language);
}
@@ -3994,9 +4006,7 @@ bool ClangASTContext::GetObjCClassName(const CompilerType &type,
return false;
}
-//----------------------------------------------------------------------
// Type Completion
-//----------------------------------------------------------------------
bool ClangASTContext::GetCompleteType(lldb::opaque_compiler_type_t type) {
if (!type)
@@ -4264,9 +4274,11 @@ ClangASTContext::GetMinimumLanguage(lldb::opaque_compiler_type_t type) {
if (qual_type->isAnyPointerType()) {
if (qual_type->isObjCObjectPointerType())
return lldb::eLanguageTypeObjC;
+ if (qual_type->getPointeeCXXRecordDecl())
+ return lldb::eLanguageTypeC_plus_plus;
clang::QualType pointee_type(qual_type->getPointeeType());
- if (pointee_type->getPointeeCXXRecordDecl() != nullptr)
+ if (pointee_type->getPointeeCXXRecordDecl())
return lldb::eLanguageTypeC_plus_plus;
if (pointee_type->isObjCObjectOrInterfaceType())
return lldb::eLanguageTypeObjC;
@@ -4474,6 +4486,8 @@ ClangASTContext::GetTypeClass(lldb::opaque_compiler_type_t type) {
case clang::Type::DependentAddressSpace:
break;
+ case clang::Type::MacroQualified:
+ break;
}
// We don't know hot to display this type...
return lldb::eTypeClassOther;
@@ -4485,9 +4499,7 @@ unsigned ClangASTContext::GetTypeQualifiers(lldb::opaque_compiler_type_t type) {
return 0;
}
-//----------------------------------------------------------------------
// Creating related types
-//----------------------------------------------------------------------
CompilerType
ClangASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
@@ -4999,19 +5011,16 @@ ClangASTContext::GetTypedefedType(lldb::opaque_compiler_type_t type) {
return CompilerType();
}
-//----------------------------------------------------------------------
// Create related types using the current type's AST
-//----------------------------------------------------------------------
CompilerType ClangASTContext::GetBasicTypeFromAST(lldb::BasicType basic_type) {
return ClangASTContext::GetBasicType(getASTContext(), basic_type);
}
-//----------------------------------------------------------------------
// Exploring the type
-//----------------------------------------------------------------------
-uint64_t ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
- ExecutionContextScope *exe_scope) {
+Optional<uint64_t>
+ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
+ ExecutionContextScope *exe_scope) {
if (GetCompleteType(type)) {
clang::QualType qual_type(GetCanonicalQualType(type));
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
@@ -5020,7 +5029,7 @@ uint64_t ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
if (GetCompleteType(type))
return getASTContext()->getTypeSize(qual_type);
else
- return 0;
+ return None;
break;
case clang::Type::ObjCInterface:
@@ -5028,7 +5037,7 @@ uint64_t ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
ExecutionContext exe_ctx(exe_scope);
Process *process = exe_ctx.GetProcessPtr();
if (process) {
- ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get(*process);
if (objc_runtime) {
uint64_t bit_size = 0;
if (objc_runtime->GetTypeBitSize(
@@ -5065,10 +5074,14 @@ uint64_t ClangASTContext::GetBitSize(lldb::opaque_compiler_type_t type,
return bit_size +
getASTContext()->getTypeSize(
getASTContext()->ObjCBuiltinClassTy);
- return bit_size;
+ // Function types actually have a size of 0, that's not an error.
+ if (qual_type->isFunctionProtoType())
+ return bit_size;
+ if (bit_size)
+ return bit_size;
}
}
- return 0;
+ return None;
}
size_t ClangASTContext::GetTypeBitAlign(lldb::opaque_compiler_type_t type) {
@@ -5343,6 +5356,8 @@ lldb::Encoding ClangASTContext::GetEncoding(lldb::opaque_compiler_type_t type,
case clang::Type::DependentAddressSpace:
break;
+ case clang::Type::MacroQualified:
+ break;
}
count = 0;
return lldb::eEncodingInvalid;
@@ -5510,6 +5525,8 @@ lldb::Format ClangASTContext::GetFormat(lldb::opaque_compiler_type_t type) {
case clang::Type::DependentAddressSpace:
break;
+ case clang::Type::MacroQualified:
+ break;
}
// We don't know hot to display this type...
return lldb::eFormatBytes;
@@ -5734,7 +5751,7 @@ uint32_t ClangASTContext::GetNumChildren(lldb::opaque_compiler_type_t type,
return num_children;
}
-CompilerType ClangASTContext::GetBuiltinTypeByName(const ConstString &name) {
+CompilerType ClangASTContext::GetBuiltinTypeByName(ConstString name) {
return GetBasicType(GetBasicTypeEnumeration(name));
}
@@ -5814,7 +5831,7 @@ ClangASTContext::GetBasicTypeEnumeration(lldb::opaque_compiler_type_t type) {
void ClangASTContext::ForEachEnumerator(
lldb::opaque_compiler_type_t type,
std::function<bool(const CompilerType &integer_type,
- const ConstString &name,
+ ConstString name,
const llvm::APSInt &value)> const &callback) {
const clang::EnumType *enum_type =
llvm::dyn_cast<clang::EnumType>(GetCanonicalQualType(type));
@@ -6827,7 +6844,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
process = exe_ctx->GetProcessPtr();
if (process) {
ObjCLanguageRuntime *objc_runtime =
- process->GetObjCLanguageRuntime();
+ ObjCLanguageRuntime::Get(*process);
if (objc_runtime != nullptr) {
CompilerType parent_ast_type(getASTContext(),
parent_qual_type);
@@ -6887,7 +6904,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
} else {
child_is_deref_of_parent = true;
const char *parent_name =
- valobj ? valobj->GetName().GetCString() : NULL;
+ valobj ? valobj->GetName().GetCString() : nullptr;
if (parent_name) {
child_name.assign(1, '*');
child_name += parent_name;
@@ -6968,7 +6985,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
child_is_deref_of_parent = true;
const char *parent_name =
- valobj ? valobj->GetName().GetCString() : NULL;
+ valobj ? valobj->GetName().GetCString() : nullptr;
if (parent_name) {
child_name.assign(1, '*');
child_name += parent_name;
@@ -7005,7 +7022,7 @@ CompilerType ClangASTContext::GetChildCompilerTypeAtIndex(
language_flags);
} else {
const char *parent_name =
- valobj ? valobj->GetName().GetCString() : NULL;
+ valobj ? valobj->GetName().GetCString() : nullptr;
if (parent_name) {
child_name.assign(1, '&');
child_name += parent_name;
@@ -7835,7 +7852,7 @@ clang::EnumDecl *ClangASTContext::GetAsEnumDecl(const CompilerType &type) {
llvm::dyn_cast<clang::EnumType>(ClangUtil::GetCanonicalQualType(type));
if (enutype)
return enutype->getDecl();
- return NULL;
+ return nullptr;
}
clang::RecordDecl *ClangASTContext::GetAsRecordDecl(const CompilerType &type) {
@@ -8173,6 +8190,10 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
if (is_artificial)
return nullptr; // skip everything artificial
+ const clang::ExplicitSpecifier explicit_spec(
+ nullptr /*expr*/, is_explicit
+ ? clang::ExplicitSpecKind::ResolvedTrue
+ : clang::ExplicitSpecKind::ResolvedFalse);
if (name[0] == '~') {
cxx_dtor_decl = clang::CXXDestructorDecl::Create(
*getASTContext(), cxx_record_decl, clang::SourceLocation(),
@@ -8191,7 +8212,7 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
clang::SourceLocation()),
method_qual_type,
nullptr, // TypeSourceInfo *
- is_explicit, is_inline, is_artificial, false /*is_constexpr*/);
+ explicit_spec, is_inline, is_artificial, CSK_unspecified);
cxx_method_decl = cxx_ctor_decl;
} else {
clang::StorageClass SC = is_static ? clang::SC_Static : clang::SC_None;
@@ -8214,7 +8235,7 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
clang::SourceLocation()),
method_qual_type,
nullptr, // TypeSourceInfo *
- SC, is_inline, false /*is_constexpr*/, clang::SourceLocation());
+ SC, is_inline, CSK_unspecified, clang::SourceLocation());
} else if (num_params == 0) {
// Conversion operators don't take params...
cxx_method_decl = clang::CXXConversionDecl::Create(
@@ -8226,7 +8247,7 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
clang::SourceLocation()),
method_qual_type,
nullptr, // TypeSourceInfo *
- is_inline, is_explicit, false /*is_constexpr*/,
+ is_inline, explicit_spec, CSK_unspecified,
clang::SourceLocation());
}
}
@@ -8237,7 +8258,7 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
clang::DeclarationNameInfo(decl_name, clang::SourceLocation()),
method_qual_type,
nullptr, // TypeSourceInfo *
- SC, is_inline, false /*is_constexpr*/, clang::SourceLocation());
+ SC, is_inline, CSK_unspecified, clang::SourceLocation());
}
}
@@ -8250,7 +8271,7 @@ clang::CXXMethodDecl *ClangASTContext::AddMethodToCXXRecordType(
if (is_attr_used)
cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
- if (mangled_name != NULL) {
+ if (mangled_name != nullptr) {
cxx_method_decl->addAttr(
clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
}
@@ -9076,11 +9097,19 @@ ClangASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type,
return 0;
}
-//----------------------------------------------------------------------
// Dumping types
-//----------------------------------------------------------------------
#define DEPTH_INCREMENT 2
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void
+ClangASTContext::dump(lldb::opaque_compiler_type_t type) const {
+ if (!type)
+ return;
+ clang::QualType qual_type(GetQualType(type));
+ qual_type.dump();
+}
+#endif
+
void ClangASTContext::Dump(Stream &s) {
Decl *tu = Decl::castFromDeclContext(GetTranslationUnitDecl());
tu->dump(s.AsRawOstream());
@@ -9610,7 +9639,7 @@ bool ClangASTContext::DumpTypeValue(
break;
}
}
- return 0;
+ return false;
}
void ClangASTContext::DumpSummary(lldb::opaque_compiler_type_t type,
@@ -9849,7 +9878,7 @@ clang::ClassTemplateDecl *ClangASTContext::ParseClassTemplateDecl(
template_basename.c_str(), tag_decl_kind,
template_param_infos);
}
- return NULL;
+ return nullptr;
}
void ClangASTContext::CompleteTagDecl(void *baton, clang::TagDecl *decl) {
@@ -9874,15 +9903,15 @@ void ClangASTContext::CompleteObjCInterfaceDecl(
}
DWARFASTParser *ClangASTContext::GetDWARFParser() {
- if (!m_dwarf_ast_parser_ap)
- m_dwarf_ast_parser_ap.reset(new DWARFASTParserClang(*this));
- return m_dwarf_ast_parser_ap.get();
+ if (!m_dwarf_ast_parser_up)
+ m_dwarf_ast_parser_up.reset(new DWARFASTParserClang(*this));
+ return m_dwarf_ast_parser_up.get();
}
PDBASTParser *ClangASTContext::GetPDBParser() {
- if (!m_pdb_ast_parser_ap)
- m_pdb_ast_parser_ap.reset(new PDBASTParser(*this));
- return m_pdb_ast_parser_ap.get();
+ if (!m_pdb_ast_parser_up)
+ m_pdb_ast_parser_up.reset(new PDBASTParser(*this));
+ return m_pdb_ast_parser_up.get();
}
bool ClangASTContext::LayoutRecordType(
@@ -9895,10 +9924,10 @@ bool ClangASTContext::LayoutRecordType(
&vbase_offsets) {
ClangASTContext *ast = (ClangASTContext *)baton;
lldb_private::ClangASTImporter *importer = nullptr;
- if (ast->m_dwarf_ast_parser_ap)
- importer = &ast->m_dwarf_ast_parser_ap->GetClangASTImporter();
- if (!importer && ast->m_pdb_ast_parser_ap)
- importer = &ast->m_pdb_ast_parser_ap->GetClangASTImporter();
+ if (ast->m_dwarf_ast_parser_up)
+ importer = &ast->m_dwarf_ast_parser_up->GetClangASTImporter();
+ if (!importer && ast->m_pdb_ast_parser_up)
+ importer = &ast->m_pdb_ast_parser_up->GetClangASTImporter();
if (!importer)
return false;
@@ -9906,9 +9935,7 @@ bool ClangASTContext::LayoutRecordType(
field_offsets, base_offsets, vbase_offsets);
}
-//----------------------------------------------------------------------
// CompilerDecl override functions
-//----------------------------------------------------------------------
ConstString ClangASTContext::DeclGetName(void *opaque_decl) {
if (opaque_decl) {
@@ -9996,9 +10023,7 @@ CompilerType ClangASTContext::DeclGetFunctionArgumentType(void *opaque_decl,
return CompilerType();
}
-//----------------------------------------------------------------------
// CompilerDeclContext functions
-//----------------------------------------------------------------------
std::vector<CompilerDecl> ClangASTContext::DeclContextFindDeclByName(
void *opaque_decl_ctx, ConstString name, const bool ignore_using_decls) {
@@ -10249,6 +10274,23 @@ bool ClangASTContext::DeclContextIsClassMethod(
return false;
}
+bool ClangASTContext::DeclContextIsContainedInLookup(
+ void *opaque_decl_ctx, void *other_opaque_decl_ctx) {
+ auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx;
+ auto *other = (clang::DeclContext *)other_opaque_decl_ctx;
+
+ do {
+ // A decl context always includes its own contents in its lookup.
+ if (decl_ctx == other)
+ return true;
+
+ // If we have an inline namespace, then the lookup of the parent context
+ // also includes the inline namespace contents.
+ } while (other->isInlineNamespace() && (other = other->getParent()));
+
+ return false;
+}
+
clang::DeclContext *
ClangASTContext::DeclContextGetAsDeclContext(const CompilerDeclContext &dc) {
if (dc.IsClang())
@@ -10314,13 +10356,14 @@ ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target)
UserExpression *ClangASTContextForExpressions::GetUserExpression(
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options) {
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj) {
TargetSP target_sp = m_target_wp.lock();
if (!target_sp)
return nullptr;
return new ClangUserExpression(*target_sp.get(), expr, prefix, language,
- desired_type, options);
+ desired_type, options, ctx_obj);
}
FunctionCaller *ClangASTContextForExpressions::GetFunctionCaller(
@@ -10355,6 +10398,6 @@ ClangASTContextForExpressions::GetPersistentExpressionState() {
clang::ExternalASTMerger &
ClangASTContextForExpressions::GetMergerUnchecked() {
- lldbassert(m_scratch_ast_source_ap != nullptr);
- return m_scratch_ast_source_ap->GetMergerUnchecked();
+ lldbassert(m_scratch_ast_source_up != nullptr);
+ return m_scratch_ast_source_up->GetMergerUnchecked();
}
diff --git a/source/Symbol/ClangASTImporter.cpp b/source/Symbol/ClangASTImporter.cpp
index 621441449c208..32d0c47693b0e 100644
--- a/source/Symbol/ClangASTImporter.cpp
+++ b/source/Symbol/ClangASTImporter.cpp
@@ -1,9 +1,8 @@
//===-- ClangASTImporter.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,8 +16,12 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
+#include "clang/Sema/Lookup.h"
+#include "clang/Sema/Sema.h"
#include "llvm/Support/raw_ostream.h"
+#include <memory>
+
using namespace lldb_private;
using namespace clang;
@@ -55,12 +58,22 @@ void ClangASTMetrics::DumpCounters(Log *log) {
clang::QualType ClangASTImporter::CopyType(clang::ASTContext *dst_ast,
clang::ASTContext *src_ast,
clang::QualType type) {
- MinionSP minion_sp(GetMinion(dst_ast, src_ast));
+ ImporterDelegateSP delegate_sp(GetDelegate(dst_ast, src_ast));
- if (minion_sp)
- return minion_sp->Import(type);
+ ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
- return QualType();
+ if (!delegate_sp)
+ return QualType();
+
+ llvm::Expected<QualType> ret_or_error = delegate_sp->Import(type);
+ if (!ret_or_error) {
+ Log *log =
+ lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+ LLDB_LOG_ERROR(log, ret_or_error.takeError(),
+ "Couldn't import type: {0}");
+ return QualType();
+ }
+ return *ret_or_error;
}
lldb::opaque_compiler_type_t
@@ -94,38 +107,39 @@ CompilerType ClangASTImporter::CopyType(ClangASTContext &dst_ast,
clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
clang::ASTContext *src_ast,
clang::Decl *decl) {
- MinionSP minion_sp;
+ ImporterDelegateSP delegate_sp;
- minion_sp = GetMinion(dst_ast, src_ast);
+ delegate_sp = GetDelegate(dst_ast, src_ast);
- if (minion_sp) {
- clang::Decl *result = minion_sp->Import(decl);
+ ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
- if (!result) {
- Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ if (!delegate_sp)
+ return nullptr;
- if (log) {
- lldb::user_id_t user_id = LLDB_INVALID_UID;
- ClangASTMetadata *metadata = GetDeclMetadata(decl);
- if (metadata)
- user_id = metadata->GetUserID();
-
- if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
- log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s "
- "'%s', metadata 0x%" PRIx64,
- decl->getDeclKindName(),
- named_decl->getNameAsString().c_str(), user_id);
- else
- log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s, "
- "metadata 0x%" PRIx64,
- decl->getDeclKindName(), user_id);
- }
+ llvm::Expected<clang::Decl *> result = delegate_sp->Import(decl);
+ if (!result) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ LLDB_LOG_ERROR(log, result.takeError(), "Couldn't import decl: {0}");
+ if (log) {
+ lldb::user_id_t user_id = LLDB_INVALID_UID;
+ ClangASTMetadata *metadata = GetDeclMetadata(decl);
+ if (metadata)
+ user_id = metadata->GetUserID();
+
+ if (NamedDecl *named_decl = dyn_cast<NamedDecl>(decl))
+ log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s "
+ "'%s', metadata 0x%" PRIx64,
+ decl->getDeclKindName(),
+ named_decl->getNameAsString().c_str(), user_id);
+ else
+ log->Printf(" [ClangASTImporter] WARNING: Failed to import a %s, "
+ "metadata 0x%" PRIx64,
+ decl->getDeclKindName(), user_id);
}
-
- return result;
+ return nullptr;
}
- return nullptr;
+ return *result;
}
class DeclContextOverride {
@@ -247,9 +261,9 @@ ClangASTImporter::DeportType(clang::ASTContext *dst_ctx,
(unsigned long long)type, static_cast<void *>(src_ctx),
static_cast<void *>(dst_ctx));
- MinionSP minion_sp(GetMinion(dst_ctx, src_ctx));
+ ImporterDelegateSP delegate_sp(GetDelegate(dst_ctx, src_ctx));
- if (!minion_sp)
+ if (!delegate_sp)
return nullptr;
std::set<NamedDecl *> decls_to_deport;
@@ -263,11 +277,11 @@ ClangASTImporter::DeportType(clang::ASTContext *dst_ctx,
tag_type->getDecl());
}
- minion_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported);
+ delegate_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported);
lldb::opaque_compiler_type_t result = CopyType(dst_ctx, src_ctx, type);
- minion_sp->ExecuteDeportWorkQueues();
+ delegate_sp->ExecuteDeportWorkQueues();
if (!result)
return nullptr;
@@ -286,9 +300,9 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
decl->getDeclKindName(), static_cast<void *>(decl),
static_cast<void *>(src_ctx), static_cast<void *>(dst_ctx));
- MinionSP minion_sp(GetMinion(dst_ctx, src_ctx));
+ ImporterDelegateSP delegate_sp(GetDelegate(dst_ctx, src_ctx));
- if (!minion_sp)
+ if (!delegate_sp)
return nullptr;
std::set<NamedDecl *> decls_to_deport;
@@ -298,11 +312,11 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
decl_context_override.OverrideAllDeclsFromContainingFunction(decl);
- minion_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported);
+ delegate_sp->InitDeportWorkQueues(&decls_to_deport, &decls_already_deported);
clang::Decl *result = CopyDecl(dst_ctx, src_ctx, decl);
- minion_sp->ExecuteDeportWorkQueues();
+ delegate_sp->ExecuteDeportWorkQueues();
if (!result)
return nullptr;
@@ -332,7 +346,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
const clang::CXXRecordDecl *cxx_record_decl =
qual_type->getAsCXXRecordDecl();
if (cxx_record_decl) {
- if (ResolveDeclOrigin(cxx_record_decl, NULL, NULL))
+ if (ResolveDeclOrigin(cxx_record_decl, nullptr, nullptr))
return true;
}
} break;
@@ -341,7 +355,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
clang::EnumDecl *enum_decl =
llvm::cast<clang::EnumType>(qual_type)->getDecl();
if (enum_decl) {
- if (ResolveDeclOrigin(enum_decl, NULL, NULL))
+ if (ResolveDeclOrigin(enum_decl, nullptr, nullptr))
return true;
}
} break;
@@ -356,7 +370,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
// We currently can't complete objective C types through the newly added
// ASTContext because it only supports TagDecl objects right now...
if (class_interface_decl) {
- if (ResolveDeclOrigin(class_interface_decl, NULL, NULL))
+ if (ResolveDeclOrigin(class_interface_decl, nullptr, nullptr))
return true;
}
}
@@ -408,7 +422,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
const clang::CXXRecordDecl *cxx_record_decl =
qual_type->getAsCXXRecordDecl();
if (cxx_record_decl) {
- if (ResolveDeclOrigin(cxx_record_decl, NULL, NULL))
+ if (ResolveDeclOrigin(cxx_record_decl, nullptr, nullptr))
return CompleteAndFetchChildren(qual_type);
}
} break;
@@ -417,7 +431,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
clang::EnumDecl *enum_decl =
llvm::cast<clang::EnumType>(qual_type)->getDecl();
if (enum_decl) {
- if (ResolveDeclOrigin(enum_decl, NULL, NULL))
+ if (ResolveDeclOrigin(enum_decl, nullptr, nullptr))
return CompleteAndFetchChildren(qual_type);
}
} break;
@@ -432,7 +446,7 @@ bool ClangASTImporter::Import(const CompilerType &type) {
// We currently can't complete objective C types through the newly added
// ASTContext because it only supports TagDecl objects right now...
if (class_interface_decl) {
- if (ResolveDeclOrigin(class_interface_decl, NULL, NULL))
+ if (ResolveDeclOrigin(class_interface_decl, nullptr, nullptr))
return CompleteAndFetchChildren(qual_type);
}
}
@@ -554,10 +568,13 @@ bool ClangASTImporter::CompleteTagDecl(clang::TagDecl *decl) {
if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
return false;
- MinionSP minion_sp(GetMinion(&decl->getASTContext(), decl_origin.ctx));
+ ImporterDelegateSP delegate_sp(
+ GetDelegate(&decl->getASTContext(), decl_origin.ctx));
- if (minion_sp)
- minion_sp->ImportDefinitionTo(decl, decl_origin.decl);
+ ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp,
+ &decl->getASTContext());
+ if (delegate_sp)
+ delegate_sp->ImportDefinitionTo(decl, decl_origin.decl);
return true;
}
@@ -571,10 +588,11 @@ bool ClangASTImporter::CompleteTagDeclWithOrigin(clang::TagDecl *decl,
if (!ClangASTContext::GetCompleteDecl(origin_ast_ctx, origin_decl))
return false;
- MinionSP minion_sp(GetMinion(&decl->getASTContext(), origin_ast_ctx));
+ ImporterDelegateSP delegate_sp(
+ GetDelegate(&decl->getASTContext(), origin_ast_ctx));
- if (minion_sp)
- minion_sp->ImportDefinitionTo(decl, origin_decl);
+ if (delegate_sp)
+ delegate_sp->ImportDefinitionTo(decl, origin_decl);
ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext());
@@ -597,11 +615,11 @@ bool ClangASTImporter::CompleteObjCInterfaceDecl(
if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl))
return false;
- MinionSP minion_sp(
- GetMinion(&interface_decl->getASTContext(), decl_origin.ctx));
+ ImporterDelegateSP delegate_sp(
+ GetDelegate(&interface_decl->getASTContext(), decl_origin.ctx));
- if (minion_sp)
- minion_sp->ImportDefinitionTo(interface_decl, decl_origin.decl);
+ if (delegate_sp)
+ delegate_sp->ImportDefinitionTo(interface_decl, decl_origin.decl);
if (ObjCInterfaceDecl *super_class = interface_decl->getSuperClass())
RequireCompleteType(clang::QualType(super_class->getTypeForDecl(), 0));
@@ -613,6 +631,8 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) {
if (!RequireCompleteType(type))
return false;
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
if (const TagType *tag_type = type->getAs<TagType>()) {
TagDecl *tag_decl = tag_type->getDecl();
@@ -621,12 +641,22 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) {
if (!decl_origin.Valid())
return false;
- MinionSP minion_sp(GetMinion(&tag_decl->getASTContext(), decl_origin.ctx));
+ ImporterDelegateSP delegate_sp(
+ GetDelegate(&tag_decl->getASTContext(), decl_origin.ctx));
+
+ ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp,
+ &tag_decl->getASTContext());
TagDecl *origin_tag_decl = llvm::dyn_cast<TagDecl>(decl_origin.decl);
for (Decl *origin_child_decl : origin_tag_decl->decls()) {
- minion_sp->Import(origin_child_decl);
+ llvm::Expected<Decl *> imported_or_err =
+ delegate_sp->Import(origin_child_decl);
+ if (!imported_or_err) {
+ LLDB_LOG_ERROR(log, imported_or_err.takeError(),
+ "Couldn't import decl: {0}");
+ return false;
+ }
}
if (RecordDecl *record_decl = dyn_cast<RecordDecl>(origin_tag_decl)) {
@@ -644,14 +674,20 @@ bool ClangASTImporter::CompleteAndFetchChildren(clang::QualType type) {
if (!decl_origin.Valid())
return false;
- MinionSP minion_sp(
- GetMinion(&objc_interface_decl->getASTContext(), decl_origin.ctx));
+ ImporterDelegateSP delegate_sp(
+ GetDelegate(&objc_interface_decl->getASTContext(), decl_origin.ctx));
ObjCInterfaceDecl *origin_interface_decl =
llvm::dyn_cast<ObjCInterfaceDecl>(decl_origin.decl);
for (Decl *origin_child_decl : origin_interface_decl->decls()) {
- minion_sp->Import(origin_child_decl);
+ llvm::Expected<Decl *> imported_or_err =
+ delegate_sp->Import(origin_child_decl);
+ if (!imported_or_err) {
+ LLDB_LOG_ERROR(log, imported_or_err.takeError(),
+ "Couldn't import decl: {0}");
+ return false;
+ }
}
return true;
@@ -766,7 +802,7 @@ void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) {
NamespaceMapSP new_map;
- new_map.reset(new NamespaceMap);
+ new_map = std::make_shared<NamespaceMap>();
if (context_md->m_map_completer) {
std::string namespace_string = decl->getDeclName().getAsString();
@@ -802,7 +838,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
if (!md)
return;
- md->m_minions.erase(src_ast);
+ md->m_delegates.erase(src_ast);
for (OriginMap::iterator iter = md->m_origins.begin();
iter != md->m_origins.end();) {
@@ -815,7 +851,25 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
ClangASTImporter::MapCompleter::~MapCompleter() { return; }
-void ClangASTImporter::Minion::InitDeportWorkQueues(
+llvm::Expected<Decl *>
+ClangASTImporter::ASTImporterDelegate::ImportImpl(Decl *From) {
+ if (m_std_handler) {
+ llvm::Optional<Decl *> D = m_std_handler->Import(From);
+ if (D) {
+ // Make sure we don't use this decl later to map it back to it's original
+ // decl. The decl the CxxModuleHandler created has nothing to do with
+ // the one from debug info, and linking those two would just cause the
+ // ASTImporter to try 'updating' the module decl with the minimal one from
+ // the debug info.
+ m_decls_to_ignore.insert(*D);
+ return *D;
+ }
+ }
+
+ return ASTImporter::ImportImpl(From);
+}
+
+void ClangASTImporter::ASTImporterDelegate::InitDeportWorkQueues(
std::set<clang::NamedDecl *> *decls_to_deport,
std::set<clang::NamedDecl *> *decls_already_deported) {
assert(!m_decls_to_deport);
@@ -825,7 +879,7 @@ void ClangASTImporter::Minion::InitDeportWorkQueues(
m_decls_already_deported = decls_already_deported;
}
-void ClangASTImporter::Minion::ExecuteDeportWorkQueues() {
+void ClangASTImporter::ASTImporterDelegate::ExecuteDeportWorkQueues() {
assert(m_decls_to_deport);
assert(m_decls_already_deported);
@@ -872,8 +926,8 @@ void ClangASTImporter::Minion::ExecuteDeportWorkQueues() {
m_decls_already_deported = nullptr;
}
-void ClangASTImporter::Minion::ImportDefinitionTo(clang::Decl *to,
- clang::Decl *from) {
+void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
+ clang::Decl *to, clang::Decl *from) {
ASTImporter::Imported(from, to);
/*
@@ -886,11 +940,39 @@ void ClangASTImporter::Minion::ImportDefinitionTo(clang::Decl *to,
to_cxx_record->startDefinition();
*/
- ImportDefinition(from);
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
+ if (llvm::Error err = ImportDefinition(from)) {
+ LLDB_LOG_ERROR(log, std::move(err),
+ "[ClangASTImporter] Error during importing definition: {0}");
+ return;
+ }
if (clang::TagDecl *to_tag = dyn_cast<clang::TagDecl>(to)) {
if (clang::TagDecl *from_tag = dyn_cast<clang::TagDecl>(from)) {
to_tag->setCompleteDefinition(from_tag->isCompleteDefinition());
+
+ if (Log *log_ast =
+ lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST)) {
+ std::string name_string;
+ if (NamedDecl *from_named_decl = dyn_cast<clang::NamedDecl>(from)) {
+ llvm::raw_string_ostream name_stream(name_string);
+ from_named_decl->printName(name_stream);
+ name_stream.flush();
+ }
+ LLDB_LOG(log_ast, "==== [ClangASTImporter][TUDecl: {0}] Imported "
+ "({1}Decl*){2}, named {3} (from "
+ "(Decl*){4})",
+ static_cast<void *>(to->getTranslationUnitDecl()),
+ from->getDeclKindName(), static_cast<void *>(to), name_string,
+ static_cast<void *>(from));
+
+ // Log the AST of the TU.
+ std::string ast_string;
+ llvm::raw_string_ostream ast_stream(ast_string);
+ to->getTranslationUnitDecl()->dump(ast_stream);
+ LLDB_LOG(log_ast, "{0}", ast_string);
+ }
}
}
@@ -916,13 +998,17 @@ void ClangASTImporter::Minion::ImportDefinitionTo(clang::Decl *to,
if (!from_superclass)
break;
- Decl *imported_from_superclass_decl = Import(from_superclass);
+ llvm::Expected<Decl *> imported_from_superclass_decl =
+ Import(from_superclass);
- if (!imported_from_superclass_decl)
+ if (!imported_from_superclass_decl) {
+ LLDB_LOG_ERROR(log, imported_from_superclass_decl.takeError(),
+ "Couldn't import decl: {0}");
break;
+ }
ObjCInterfaceDecl *imported_from_superclass =
- dyn_cast<ObjCInterfaceDecl>(imported_from_superclass_decl);
+ dyn_cast<ObjCInterfaceDecl>(*imported_from_superclass_decl);
if (!imported_from_superclass)
break;
@@ -932,16 +1018,21 @@ void ClangASTImporter::Minion::ImportDefinitionTo(clang::Decl *to,
to_objc_interface->setSuperClass(m_source_ctx->getTrivialTypeSourceInfo(
m_source_ctx->getObjCInterfaceType(imported_from_superclass)));
- } while (0);
+ } while (false);
}
}
-clang::Decl *ClangASTImporter::Minion::Imported(clang::Decl *from,
- clang::Decl *to) {
+void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
+ clang::Decl *to) {
ClangASTMetrics::RegisterClangImport();
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+ // Some decls shouldn't be tracked here because they were not created by
+ // copying 'from' to 'to'. Just exit early for those.
+ if (m_decls_to_ignore.find(to) != m_decls_to_ignore.end())
+ return clang::ASTImporter::Imported(from, to);
+
lldb::user_id_t user_id = LLDB_INVALID_UID;
ClangASTMetadata *metadata = m_master.GetDeclMetadata(from);
if (metadata)
@@ -983,8 +1074,8 @@ clang::Decl *ClangASTImporter::Minion::Imported(clang::Decl *from,
to_context_md->m_origins[to] = origin_iter->second;
}
- MinionSP direct_completer =
- m_master.GetMinion(&to->getASTContext(), origin_iter->second.ctx);
+ ImporterDelegateSP direct_completer =
+ m_master.GetDelegate(&to->getASTContext(), origin_iter->second.ctx);
if (direct_completer.get() != this)
direct_completer->ASTImporter::Imported(origin_iter->second.decl, to);
@@ -1095,11 +1186,10 @@ clang::Decl *ClangASTImporter::Minion::Imported(clang::Decl *from,
}
}
}
-
- return clang::ASTImporter::Imported(from, to);
}
-clang::Decl *ClangASTImporter::Minion::GetOriginalDecl(clang::Decl *To) {
+clang::Decl *
+ClangASTImporter::ASTImporterDelegate::GetOriginalDecl(clang::Decl *To) {
ASTContextMetadataSP to_context_md =
m_master.GetContextMetadata(&To->getASTContext());
diff --git a/source/Symbol/ClangExternalASTSourceCallbacks.cpp b/source/Symbol/ClangExternalASTSourceCallbacks.cpp
index a96ef19b02f5d..c35fc585bfa56 100644
--- a/source/Symbol/ClangExternalASTSourceCallbacks.cpp
+++ b/source/Symbol/ClangExternalASTSourceCallbacks.cpp
@@ -1,9 +1,8 @@
//===-- ClangExternalASTSourceCallbacks.cpp ---------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Symbol/ClangExternalASTSourceCommon.cpp b/source/Symbol/ClangExternalASTSourceCommon.cpp
index 992a76352d927..3dcf9051d0a48 100644
--- a/source/Symbol/ClangExternalASTSourceCommon.cpp
+++ b/source/Symbol/ClangExternalASTSourceCommon.cpp
@@ -1,9 +1,8 @@
//===-- ClangExternalASTSourceCommon.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Symbol/ClangUtil.cpp b/source/Symbol/ClangUtil.cpp
index 687fba7c7c330..86be895fadcba 100644
--- a/source/Symbol/ClangUtil.cpp
+++ b/source/Symbol/ClangUtil.cpp
@@ -1,9 +1,8 @@
//===-- ClangUtil.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// A collection of helper methods and data structures for manipulating clang
// types and decls.
diff --git a/source/Symbol/CompactUnwindInfo.cpp b/source/Symbol/CompactUnwindInfo.cpp
index 6f0f35f278c4d..3a2a4d3a09e62 100644
--- a/source/Symbol/CompactUnwindInfo.cpp
+++ b/source/Symbol/CompactUnwindInfo.cpp
@@ -1,9 +1,8 @@
//===-- CompactUnwindInfo.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,10 +17,12 @@
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
-#include <algorithm>
#include "llvm/Support/MathExtras.h"
+#include <algorithm>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -156,9 +157,7 @@ FLAGS_ANONYMOUS_ENUM(){
llvm::countTrailingZeros(static_cast<uint32_t>(mask), llvm::ZB_Width)) & \
(((1 << llvm::countPopulation(static_cast<uint32_t>(mask)))) - 1))
-//----------------------
// constructor
-//----------------------
CompactUnwindInfo::CompactUnwindInfo(ObjectFile &objfile, SectionSP &section_sp)
: m_objfile(objfile), m_section_sp(section_sp),
@@ -166,9 +165,7 @@ CompactUnwindInfo::CompactUnwindInfo(ObjectFile &objfile, SectionSP &section_sp)
m_indexes_computed(eLazyBoolCalculate), m_unwindinfo_data(),
m_unwindinfo_data_computed(false), m_unwind_header() {}
-//----------------------
// destructor
-//----------------------
CompactUnwindInfo::~CompactUnwindInfo() {}
@@ -189,7 +186,7 @@ bool CompactUnwindInfo::GetUnwindPlan(Target &target, Address addr,
if (log && log->GetVerbose()) {
StreamString strm;
addr.Dump(
- &strm, NULL,
+ &strm, nullptr,
Address::DumpStyle::DumpStyleResolvedDescriptionNoFunctionArguments,
Address::DumpStyle::DumpStyleFileAddress,
arch.GetAddressByteSize());
@@ -264,8 +261,8 @@ void CompactUnwindInfo::ScanIndex(const ProcessSP &process_sp) {
// have a live process and can read them out of memory.
if (process_sp.get() == nullptr)
return;
- m_section_contents_if_encrypted.reset(
- new DataBufferHeap(m_section_sp->GetByteSize(), 0));
+ m_section_contents_if_encrypted =
+ std::make_shared<DataBufferHeap>(m_section_sp->GetByteSize(), 0);
Status error;
if (process_sp->ReadMemory(
m_section_sp->GetLoadBaseAddress(&process_sp->GetTarget()),
diff --git a/source/Symbol/CompileUnit.cpp b/source/Symbol/CompileUnit.cpp
index 74512c8914402..5fb9b6b9f7292 100644
--- a/source/Symbol/CompileUnit.cpp
+++ b/source/Symbol/CompileUnit.cpp
@@ -1,9 +1,8 @@
//===-- CompileUnit.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,7 +22,7 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
lldb_private::LazyBool is_optimized)
: ModuleChild(module_sp), FileSpec(pathname), UserID(cu_sym_id),
m_user_data(user_data), m_language(language), m_flags(0),
- m_support_files(), m_line_table_ap(), m_variables(),
+ m_support_files(), m_line_table_up(), m_variables(),
m_is_optimized(is_optimized) {
if (language != eLanguageTypeUnknown)
m_flags.Set(flagsParsedLanguage);
@@ -36,7 +35,7 @@ CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
lldb_private::LazyBool is_optimized)
: ModuleChild(module_sp), FileSpec(fspec), UserID(cu_sym_id),
m_user_data(user_data), m_language(language), m_flags(0),
- m_support_files(), m_line_table_ap(), m_variables(),
+ m_support_files(), m_line_table_up(), m_variables(),
m_is_optimized(is_optimized) {
if (language != eLanguageTypeUnknown)
m_flags.Set(flagsParsedLanguage);
@@ -82,12 +81,10 @@ void CompileUnit::ForeachFunction(
return;
}
-//----------------------------------------------------------------------
// Dump the current contents of this object. No functions that cause on demand
// parsing of functions, globals, statics are called, so this is a good
// function to call to get an idea of the current contents of the CompileUnit
// object.
-//----------------------------------------------------------------------
void CompileUnit::Dump(Stream *s, bool show_context) const {
const char *language = Language::GetNameForLanguageType(m_language);
@@ -117,14 +114,11 @@ void CompileUnit::Dump(Stream *s, bool show_context) const {
}
}
-//----------------------------------------------------------------------
// Add a function to this compile unit
-//----------------------------------------------------------------------
void CompileUnit::AddFunction(FunctionSP &funcSP) {
m_functions_by_uid[funcSP->GetID()] = funcSP;
}
-//----------------------------------------------------------------------
// Find functions using the Mangled::Tokens token list. This function currently
// implements an interactive approach designed to find all instances of certain
// functions. It isn't designed to the quickest way to lookup functions as it
@@ -146,7 +140,6 @@ void CompileUnit::AddFunction(FunctionSP &funcSP) {
// method should be able to take advantage of any accelerator tables available
// in the debug information (which is parsed by the SymbolFile parser plug-ins
// and registered with each Module).
-//----------------------------------------------------------------------
// void
// CompileUnit::FindFunctions(const Mangled::Tokens& tokens)
//{
@@ -190,7 +183,7 @@ lldb::LanguageType CompileUnit::GetLanguage() {
}
LineTable *CompileUnit::GetLineTable() {
- if (m_line_table_ap.get() == nullptr) {
+ if (m_line_table_up == nullptr) {
if (m_flags.IsClear(flagsParsedLineTable)) {
m_flags.Set(flagsParsedLineTable);
SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
@@ -198,7 +191,7 @@ LineTable *CompileUnit::GetLineTable() {
symbol_vendor->ParseLineTable(*this);
}
}
- return m_line_table_ap.get();
+ return m_line_table_up.get();
}
void CompileUnit::SetLineTable(LineTable *line_table) {
@@ -206,7 +199,7 @@ void CompileUnit::SetLineTable(LineTable *line_table) {
m_flags.Clear(flagsParsedLineTable);
else
m_flags.Set(flagsParsedLineTable);
- m_line_table_ap.reset(line_table);
+ m_line_table_up.reset(line_table);
}
DebugMacros *CompileUnit::GetDebugMacros() {
@@ -255,7 +248,7 @@ uint32_t CompileUnit::FindLineEntry(uint32_t start_idx, uint32_t line,
// All the line table entries actually point to the version of the Compile
// Unit that is in the support files (the one at 0 was artificially added.)
// So prefer the one further on in the support files if it exists...
- FileSpecList &support_files = GetSupportFiles();
+ const FileSpecList &support_files = GetSupportFiles();
const bool full = true;
file_idx = support_files.FindFileIndex(
1, support_files.GetFileSpecAtIndex(0), full);
@@ -391,7 +384,7 @@ void CompileUnit::SetVariableList(VariableListSP &variables) {
m_variables = variables;
}
-const std::vector<ConstString> &CompileUnit::GetImportedModules() {
+const std::vector<SourceModule> &CompileUnit::GetImportedModules() {
if (m_imported_modules.empty() &&
m_flags.IsClear(flagsParsedImportedModules)) {
m_flags.Set(flagsParsedImportedModules);
@@ -404,7 +397,7 @@ const std::vector<ConstString> &CompileUnit::GetImportedModules() {
return m_imported_modules;
}
-FileSpecList &CompileUnit::GetSupportFiles() {
+const FileSpecList &CompileUnit::GetSupportFiles() {
if (m_support_files.GetSize() == 0) {
if (m_flags.IsClear(flagsParsedSupportFiles)) {
m_flags.Set(flagsParsedSupportFiles);
diff --git a/source/Symbol/CompilerDecl.cpp b/source/Symbol/CompilerDecl.cpp
index 2b632c5eb5d04..2c64113a2bbeb 100644
--- a/source/Symbol/CompilerDecl.cpp
+++ b/source/Symbol/CompilerDecl.cpp
@@ -1,9 +1,8 @@
//===-- CompilerDecl.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Symbol/CompilerDeclContext.cpp b/source/Symbol/CompilerDeclContext.cpp
index 43a83bbca77bd..a6f046c4eb22e 100644
--- a/source/Symbol/CompilerDeclContext.cpp
+++ b/source/Symbol/CompilerDeclContext.cpp
@@ -1,9 +1,8 @@
//===-- CompilerDeclContext.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -60,6 +59,19 @@ bool CompilerDeclContext::IsClassMethod(lldb::LanguageType *language_ptr,
return false;
}
+bool CompilerDeclContext::IsContainedInLookup(CompilerDeclContext other) const {
+ if (!IsValid())
+ return false;
+
+ // If the other context is just the current context, we don't need to go
+ // over the type system to know that the lookup is identical.
+ if (this == &other)
+ return true;
+
+ return m_type_system->DeclContextIsContainedInLookup(m_opaque_decl_ctx,
+ other.m_opaque_decl_ctx);
+}
+
bool lldb_private::operator==(const lldb_private::CompilerDeclContext &lhs,
const lldb_private::CompilerDeclContext &rhs) {
return lhs.GetTypeSystem() == rhs.GetTypeSystem() &&
diff --git a/source/Symbol/CompilerType.cpp b/source/Symbol/CompilerType.cpp
index 7e381abd7d11e..bb9a1a642e422 100644
--- a/source/Symbol/CompilerType.cpp
+++ b/source/Symbol/CompilerType.cpp
@@ -1,9 +1,8 @@
//===-- CompilerType.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,17 +35,13 @@ CompilerType::CompilerType(TypeSystem *type_system,
CompilerType::CompilerType(clang::ASTContext *ast, clang::QualType qual_type)
: m_type(qual_type.getAsOpaquePtr()),
m_type_system(ClangASTContext::GetASTContext(ast)) {
-#ifdef LLDB_CONFIGURATION_DEBUG
if (m_type)
assert(m_type_system != nullptr);
-#endif
}
CompilerType::~CompilerType() {}
-//----------------------------------------------------------------------
// Tests
-//----------------------------------------------------------------------
bool CompilerType::IsAggregateType() const {
if (IsValid())
@@ -149,7 +144,7 @@ bool CompilerType::IsBlockPointerType(
CompilerType *function_pointer_type_ptr) const {
if (IsValid())
return m_type_system->IsBlockPointerType(m_type, function_pointer_type_ptr);
- return 0;
+ return false;
}
bool CompilerType::IsIntegerType(bool &is_signed) const {
@@ -273,9 +268,7 @@ bool CompilerType::IsBeingDefined() const {
return m_type_system->IsBeingDefined(m_type);
}
-//----------------------------------------------------------------------
// Type Completion
-//----------------------------------------------------------------------
bool CompilerType::GetCompleteType() const {
if (!IsValid())
@@ -283,9 +276,7 @@ bool CompilerType::GetCompleteType() const {
return m_type_system->GetCompleteType(m_type);
}
-//----------------------------------------------------------------------
// AST related queries
-//----------------------------------------------------------------------
size_t CompilerType::GetPointerByteSize() const {
if (m_type_system)
return m_type_system->GetPointerByteSize();
@@ -354,9 +345,7 @@ unsigned CompilerType::GetTypeQualifiers() const {
return 0;
}
-//----------------------------------------------------------------------
// Creating related types
-//----------------------------------------------------------------------
CompilerType CompilerType::GetArrayElementType(uint64_t *stride) const {
if (IsValid()) {
@@ -490,9 +479,7 @@ CompilerType CompilerType::GetTypedefedType() const {
return CompilerType();
}
-//----------------------------------------------------------------------
// Create related types using the current type's AST
-//----------------------------------------------------------------------
CompilerType
CompilerType::GetBasicTypeFromAST(lldb::BasicType basic_type) const {
@@ -500,9 +487,7 @@ CompilerType::GetBasicTypeFromAST(lldb::BasicType basic_type) const {
return m_type_system->GetBasicTypeFromAST(basic_type);
return CompilerType();
}
-//----------------------------------------------------------------------
// Exploring the type
-//----------------------------------------------------------------------
llvm::Optional<uint64_t>
CompilerType::GetBitSize(ExecutionContextScope *exe_scope) const {
@@ -554,7 +539,7 @@ lldb::BasicType CompilerType::GetBasicTypeEnumeration() const {
void CompilerType::ForEachEnumerator(
std::function<bool(const CompilerType &integer_type,
- const ConstString &name,
+ ConstString name,
const llvm::APSInt &value)> const &callback) const {
if (IsValid())
return m_type_system->ForEachEnumerator(m_type, callback);
@@ -751,9 +736,7 @@ size_t CompilerType::ConvertStringToFloatValue(const char *s, uint8_t *dst,
return 0;
}
-//----------------------------------------------------------------------
// Dumping types
-//----------------------------------------------------------------------
#define DEPTH_INCREMENT 2
void CompilerType::DumpValue(ExecutionContext *exe_ctx, Stream *s,
@@ -803,6 +786,15 @@ void CompilerType::DumpTypeDescription(Stream *s) const {
}
}
+#ifndef NDEBUG
+LLVM_DUMP_METHOD void CompilerType::dump() const {
+ if (IsValid())
+ m_type_system->dump(m_type);
+ else
+ llvm::errs() << "<invalid>\n";
+}
+#endif
+
bool CompilerType::GetValueAsScalar(const lldb_private::DataExtractor &data,
lldb::offset_t data_byte_offset,
size_t data_byte_size,
@@ -1003,7 +995,7 @@ bool CompilerType::ReadFromMemory(lldb_private::ExecutionContext *exe_ctx,
return false;
auto byte_size =
- GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
if (!byte_size)
return false;
@@ -1048,7 +1040,7 @@ bool CompilerType::WriteToMemory(lldb_private::ExecutionContext *exe_ctx,
return false;
auto byte_size =
- GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
+ GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr);
if (!byte_size)
return false;
diff --git a/source/Symbol/CxxModuleHandler.cpp b/source/Symbol/CxxModuleHandler.cpp
new file mode 100644
index 0000000000000..68a2aab80bd6e
--- /dev/null
+++ b/source/Symbol/CxxModuleHandler.cpp
@@ -0,0 +1,283 @@
+//===-- CxxModuleHandler.cpp ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/CxxModuleHandler.h"
+
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Utility/Log.h"
+#include "clang/Sema/Lookup.h"
+#include "llvm/Support/Error.h"
+
+using namespace lldb_private;
+using namespace clang;
+
+CxxModuleHandler::CxxModuleHandler(ASTImporter &importer, ASTContext *target)
+ : m_importer(&importer),
+ m_sema(ClangASTContext::GetASTContext(target)->getSema()) {
+
+ std::initializer_list<const char *> supported_names = {
+ // containers
+ "deque",
+ "forward_list",
+ "list",
+ "queue",
+ "stack",
+ "vector",
+ // pointers
+ "shared_ptr",
+ "unique_ptr",
+ "weak_ptr",
+ // utility
+ "allocator",
+ };
+ m_supported_templates.insert(supported_names.begin(), supported_names.end());
+}
+
+/// Builds a list of scopes that point into the given context.
+///
+/// \param sema The sema that will be using the scopes.
+/// \param ctxt The context that the scope should look into.
+/// \param result A list of scopes. The scopes need to be freed by the caller
+/// (except the TUScope which is owned by the sema).
+static void makeScopes(Sema &sema, DeclContext *ctxt,
+ std::vector<Scope *> &result) {
+ // FIXME: The result should be a list of unique_ptrs, but the TUScope makes
+ // this currently impossible as it's owned by the Sema.
+
+ if (auto parent = ctxt->getParent()) {
+ makeScopes(sema, parent, result);
+
+ Scope *scope =
+ new Scope(result.back(), Scope::DeclScope, sema.getDiagnostics());
+ scope->setEntity(ctxt);
+ result.push_back(scope);
+ } else
+ result.push_back(sema.TUScope);
+}
+
+/// Uses the Sema to look up the given name in the given DeclContext.
+static std::unique_ptr<LookupResult>
+emulateLookupInCtxt(Sema &sema, llvm::StringRef name, DeclContext *ctxt) {
+ IdentifierInfo &ident = sema.getASTContext().Idents.get(name);
+
+ std::unique_ptr<LookupResult> lookup_result;
+ lookup_result.reset(new LookupResult(sema, DeclarationName(&ident),
+ SourceLocation(),
+ Sema::LookupOrdinaryName));
+
+ // Usually during parsing we already encountered the scopes we would use. But
+ // here don't have these scopes so we have to emulate the behavior of the
+ // Sema during parsing.
+ std::vector<Scope *> scopes;
+ makeScopes(sema, ctxt, scopes);
+
+ // Now actually perform the lookup with the sema.
+ sema.LookupName(*lookup_result, scopes.back());
+
+ // Delete all the allocated scopes beside the translation unit scope (which
+ // has depth 0).
+ for (Scope *s : scopes)
+ if (s->getDepth() != 0)
+ delete s;
+
+ return lookup_result;
+}
+
+/// Error class for handling problems when finding a certain DeclContext.
+struct MissingDeclContext : public llvm::ErrorInfo<MissingDeclContext> {
+
+ static char ID;
+
+ MissingDeclContext(DeclContext *context, std::string error)
+ : m_context(context), m_error(error) {}
+
+ DeclContext *m_context;
+ std::string m_error;
+
+ void log(llvm::raw_ostream &OS) const override {
+ OS << llvm::formatv("error when reconstructing context of kind {0}:{1}",
+ m_context->getDeclKindName(), m_error);
+ }
+
+ std::error_code convertToErrorCode() const override {
+ return llvm::inconvertibleErrorCode();
+ }
+};
+
+char MissingDeclContext::ID = 0;
+
+/// Given a foreign decl context, this function finds the equivalent local
+/// decl context in the ASTContext of the given Sema. Potentially deserializes
+/// decls from the 'std' module if necessary.
+static llvm::Expected<DeclContext *>
+getEqualLocalDeclContext(Sema &sema, DeclContext *foreign_ctxt) {
+
+ // Inline namespaces don't matter for lookups, so let's skip them.
+ while (foreign_ctxt && foreign_ctxt->isInlineNamespace())
+ foreign_ctxt = foreign_ctxt->getParent();
+
+ // If the foreign context is the TU, we just return the local TU.
+ if (foreign_ctxt->isTranslationUnit())
+ return sema.getASTContext().getTranslationUnitDecl();
+
+ // Recursively find/build the parent DeclContext.
+ llvm::Expected<DeclContext *> parent =
+ getEqualLocalDeclContext(sema, foreign_ctxt->getParent());
+ if (!parent)
+ return parent;
+
+ // We currently only support building namespaces.
+ if (foreign_ctxt->isNamespace()) {
+ NamedDecl *ns = llvm::dyn_cast<NamedDecl>(foreign_ctxt);
+ llvm::StringRef ns_name = ns->getName();
+
+ auto lookup_result = emulateLookupInCtxt(sema, ns_name, *parent);
+ for (NamedDecl *named_decl : *lookup_result) {
+ if (DeclContext *DC = llvm::dyn_cast<DeclContext>(named_decl))
+ return DC->getPrimaryContext();
+ }
+ return llvm::make_error<MissingDeclContext>(
+ foreign_ctxt,
+ "Couldn't find namespace " + ns->getQualifiedNameAsString());
+ }
+
+ return llvm::make_error<MissingDeclContext>(foreign_ctxt, "Unknown context ");
+}
+
+/// Returns true iff tryInstantiateStdTemplate supports instantiating a template
+/// with the given template arguments.
+static bool templateArgsAreSupported(ArrayRef<TemplateArgument> a) {
+ for (const TemplateArgument &arg : a) {
+ switch (arg.getKind()) {
+ case TemplateArgument::Type:
+ case TemplateArgument::Integral:
+ break;
+ default:
+ // TemplateArgument kind hasn't been handled yet.
+ return false;
+ }
+ }
+ return true;
+}
+
+/// Constructor function for Clang declarations. Ensures that the created
+/// declaration is registered with the ASTImporter.
+template <typename T, typename... Args>
+T *createDecl(ASTImporter &importer, Decl *from_d, Args &&... args) {
+ T *to_d = T::Create(std::forward<Args>(args)...);
+ importer.RegisterImportedDecl(from_d, to_d);
+ return to_d;
+}
+
+llvm::Optional<Decl *> CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
+ // If we don't have a template to instiantiate, then there is nothing to do.
+ auto td = dyn_cast<ClassTemplateSpecializationDecl>(d);
+ if (!td)
+ return {};
+
+ // We only care about templates in the std namespace.
+ if (!td->getDeclContext()->isStdNamespace())
+ return {};
+
+ // We have a whitelist of supported template names.
+ if (m_supported_templates.find(td->getName()) == m_supported_templates.end())
+ return {};
+
+ // Early check if we even support instantiating this template. We do this
+ // before we import anything into the target AST.
+ auto &foreign_args = td->getTemplateInstantiationArgs();
+ if (!templateArgsAreSupported(foreign_args.asArray()))
+ return {};
+
+ // Find the local DeclContext that corresponds to the DeclContext of our
+ // decl we want to import.
+ auto to_context = getEqualLocalDeclContext(*m_sema, td->getDeclContext());
+ if (!to_context)
+ return {};
+
+ // Look up the template in our local context.
+ std::unique_ptr<LookupResult> lookup =
+ emulateLookupInCtxt(*m_sema, td->getName(), *to_context);
+
+ ClassTemplateDecl *new_class_template = nullptr;
+ for (auto LD : *lookup) {
+ if ((new_class_template = dyn_cast<ClassTemplateDecl>(LD)))
+ break;
+ }
+ if (!new_class_template)
+ return {};
+
+ // Import the foreign template arguments.
+ llvm::SmallVector<TemplateArgument, 4> imported_args;
+
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS);
+
+ // If this logic is changed, also update templateArgsAreSupported.
+ for (const TemplateArgument &arg : foreign_args.asArray()) {
+ switch (arg.getKind()) {
+ case TemplateArgument::Type: {
+ llvm::Expected<QualType> type = m_importer->Import(arg.getAsType());
+ if (!type) {
+ LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
+ return {};
+ }
+ imported_args.push_back(TemplateArgument(*type));
+ break;
+ }
+ case TemplateArgument::Integral: {
+ llvm::APSInt integral = arg.getAsIntegral();
+ llvm::Expected<QualType> type =
+ m_importer->Import(arg.getIntegralType());
+ if (!type) {
+ LLDB_LOG_ERROR(log, type.takeError(), "Couldn't import type: {0}");
+ return {};
+ }
+ imported_args.push_back(
+ TemplateArgument(d->getASTContext(), integral, *type));
+ break;
+ }
+ default:
+ assert(false && "templateArgsAreSupported not updated?");
+ }
+ }
+
+ // Find the class template specialization declaration that
+ // corresponds to these arguments.
+ void *InsertPos = nullptr;
+ ClassTemplateSpecializationDecl *result =
+ new_class_template->findSpecialization(imported_args, InsertPos);
+
+ if (result) {
+ // We found an existing specialization in the module that fits our arguments
+ // so we can treat it as the result and register it with the ASTImporter.
+ m_importer->RegisterImportedDecl(d, result);
+ return result;
+ }
+
+ // Instantiate the template.
+ result = createDecl<ClassTemplateSpecializationDecl>(
+ *m_importer, d, m_sema->getASTContext(),
+ new_class_template->getTemplatedDecl()->getTagKind(),
+ new_class_template->getDeclContext(),
+ new_class_template->getTemplatedDecl()->getLocation(),
+ new_class_template->getLocation(), new_class_template, imported_args,
+ nullptr);
+
+ new_class_template->AddSpecialization(result, InsertPos);
+ if (new_class_template->isOutOfLine())
+ result->setLexicalDeclContext(
+ new_class_template->getLexicalDeclContext());
+ return result;
+}
+
+llvm::Optional<Decl *> CxxModuleHandler::Import(Decl *d) {
+ if (!isValid())
+ return {};
+
+ return tryInstantiateStdTemplate(d);
+}
diff --git a/source/Symbol/DWARFCallFrameInfo.cpp b/source/Symbol/DWARFCallFrameInfo.cpp
index c8c3a10026a27..0ab9fa4b7bbdd 100644
--- a/source/Symbol/DWARFCallFrameInfo.cpp
+++ b/source/Symbol/DWARFCallFrameInfo.cpp
@@ -1,9 +1,8 @@
//===-- DWARFCallFrameInfo.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,12 +23,10 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// GetDwarfEHPtr
//
// Used for calls when the value type is specified by a DWARF EH Frame pointer
// encoding.
-//----------------------------------------------------------------------
static uint64_t
GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr,
uint32_t eh_ptr_enc, addr_t pc_rel_addr, addr_t text_addr,
@@ -41,9 +38,7 @@ GetGNUEHPointer(const DataExtractor &DE, offset_t *offset_ptr,
uint64_t baseAddress = 0;
uint64_t addressValue = 0;
const uint32_t addr_size = DE.GetAddressByteSize();
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(addr_size == 4 || addr_size == 8);
-#endif
bool signExtendValue = false;
// Decode the base part or adjust our offset
@@ -151,8 +146,15 @@ DWARFCallFrameInfo::DWARFCallFrameInfo(ObjectFile &objfile,
SectionSP &section_sp, Type type)
: m_objfile(objfile), m_section_sp(section_sp), m_type(type) {}
-bool DWARFCallFrameInfo::GetUnwindPlan(Address addr, UnwindPlan &unwind_plan) {
+bool DWARFCallFrameInfo::GetUnwindPlan(const Address &addr,
+ UnwindPlan &unwind_plan) {
+ return GetUnwindPlan(AddressRange(addr, 1), unwind_plan);
+}
+
+bool DWARFCallFrameInfo::GetUnwindPlan(const AddressRange &range,
+ UnwindPlan &unwind_plan) {
FDEEntryMap::Entry fde_entry;
+ Address addr = range.GetBaseAddress();
// Make sure that the Address we're searching for is the same object file as
// this DWARFCallFrameInfo, we only store File offsets in m_fde_index.
@@ -161,9 +163,9 @@ bool DWARFCallFrameInfo::GetUnwindPlan(Address addr, UnwindPlan &unwind_plan) {
module_sp->GetObjectFile() != &m_objfile)
return false;
- if (!GetFDEEntryByFileAddress(addr.GetFileAddress(), fde_entry))
- return false;
- return FDEToUnwindPlan(fde_entry.data, addr, unwind_plan);
+ if (llvm::Optional<FDEEntryMap::Entry> entry = GetFirstFDEEntryInRange(range))
+ return FDEToUnwindPlan(entry->data, addr, unwind_plan);
+ return false;
}
bool DWARFCallFrameInfo::GetAddressRange(Address addr, AddressRange &range) {
@@ -188,23 +190,21 @@ bool DWARFCallFrameInfo::GetAddressRange(Address addr, AddressRange &range) {
return true;
}
-bool DWARFCallFrameInfo::GetFDEEntryByFileAddress(
- addr_t file_addr, FDEEntryMap::Entry &fde_entry) {
- if (m_section_sp.get() == nullptr || m_section_sp->IsEncrypted())
- return false;
+llvm::Optional<DWARFCallFrameInfo::FDEEntryMap::Entry>
+DWARFCallFrameInfo::GetFirstFDEEntryInRange(const AddressRange &range) {
+ if (!m_section_sp || m_section_sp->IsEncrypted())
+ return llvm::None;
GetFDEIndex();
- if (m_fde_index.IsEmpty())
- return false;
-
- FDEEntryMap::Entry *fde = m_fde_index.FindEntryThatContains(file_addr);
+ addr_t start_file_addr = range.GetBaseAddress().GetFileAddress();
+ const FDEEntryMap::Entry *fde =
+ m_fde_index.FindEntryThatContainsOrFollows(start_file_addr);
+ if (fde && fde->DoesIntersect(
+ FDEEntryMap::Range(start_file_addr, range.GetByteSize())))
+ return *fde;
- if (fde == nullptr)
- return false;
-
- fde_entry = *fde;
- return true;
+ return llvm::None;
}
void DWARFCallFrameInfo::GetFunctionAddressAndSizeVector(
@@ -231,7 +231,7 @@ DWARFCallFrameInfo::GetCIE(dw_offset_t cie_offset) {
if (pos != m_cie_map.end()) {
// Parse and cache the CIE
- if (pos->second.get() == nullptr)
+ if (pos->second == nullptr)
pos->second = ParseCIE(cie_offset);
return pos->second.get();
@@ -999,61 +999,6 @@ bool DWARFCallFrameInfo::HandleCommonDwarfOpcode(uint8_t primary_opcode,
uint32_t block_len = (uint32_t)m_cfi_data.GetULEB128(&offset);
const uint8_t *block_data =
(const uint8_t *)m_cfi_data.GetData(&offset, block_len);
- //#if defined(__i386__) || defined(__x86_64__)
- // // The EH frame info for EIP and RIP contains code that
- // looks for traps to
- // // be a specific type and increments the PC.
- // // For i386:
- // // DW_CFA_val_expression where:
- // // eip = DW_OP_breg6(+28), DW_OP_deref, DW_OP_dup,
- // DW_OP_plus_uconst(0x34),
- // // DW_OP_deref, DW_OP_swap, DW_OP_plus_uconst(0),
- // DW_OP_deref,
- // // DW_OP_dup, DW_OP_lit3, DW_OP_ne, DW_OP_swap,
- // DW_OP_lit4, DW_OP_ne,
- // // DW_OP_and, DW_OP_plus
- // // This basically does a:
- // // eip = ucontenxt.mcontext32->gpr.eip;
- // // if (ucontenxt.mcontext32->exc.trapno != 3 &&
- // ucontenxt.mcontext32->exc.trapno != 4)
- // // eip++;
- // //
- // // For x86_64:
- // // DW_CFA_val_expression where:
- // // rip = DW_OP_breg3(+48), DW_OP_deref, DW_OP_dup,
- // DW_OP_plus_uconst(0x90), DW_OP_deref,
- // // DW_OP_swap, DW_OP_plus_uconst(0),
- // DW_OP_deref_size(4), DW_OP_dup, DW_OP_lit3,
- // // DW_OP_ne, DW_OP_swap, DW_OP_lit4, DW_OP_ne,
- // DW_OP_and, DW_OP_plus
- // // This basically does a:
- // // rip = ucontenxt.mcontext64->gpr.rip;
- // // if (ucontenxt.mcontext64->exc.trapno != 3 &&
- // ucontenxt.mcontext64->exc.trapno != 4)
- // // rip++;
- // // The trap comparisons and increments are not needed as
- // it hoses up the unwound PC which
- // // is expected to point at least past the instruction that
- // causes the fault/trap. So we
- // // take it out by trimming the expression right at the
- // first "DW_OP_swap" opcodes
- // if (block_data != NULL && thread->GetPCRegNum(Thread::GCC)
- // == reg_num)
- // {
- // if (thread->Is64Bit())
- // {
- // if (block_len > 9 && block_data[8] == DW_OP_swap
- // && block_data[9] == DW_OP_plus_uconst)
- // block_len = 8;
- // }
- // else
- // {
- // if (block_len > 8 && block_data[7] == DW_OP_swap
- // && block_data[8] == DW_OP_plus_uconst)
- // block_len = 7;
- // }
- // }
- //#endif
reg_location.SetIsDWARFExpression(block_data, block_len);
row.SetRegisterInfo(reg_num, reg_location);
return true;
diff --git a/source/Symbol/DebugMacros.cpp b/source/Symbol/DebugMacros.cpp
index 22576ee1ce26c..d119a78868a42 100644
--- a/source/Symbol/DebugMacros.cpp
+++ b/source/Symbol/DebugMacros.cpp
@@ -1,9 +1,8 @@
//===-- DebugMacros.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Symbol/DeclVendor.cpp b/source/Symbol/DeclVendor.cpp
new file mode 100644
index 0000000000000..0a912a2fd2142
--- /dev/null
+++ b/source/Symbol/DeclVendor.cpp
@@ -0,0 +1,29 @@
+//===-- DeclVendor.cpp ------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/DeclVendor.h"
+
+#include "lldb/Symbol/ClangASTContext.h"
+
+#include <vector>
+
+using namespace lldb;
+using namespace lldb_private;
+
+std::vector<CompilerType> DeclVendor::FindTypes(ConstString name,
+ uint32_t max_matches) {
+ // FIXME: This depends on clang, but should be able to support any
+ // TypeSystem.
+ std::vector<CompilerType> ret;
+ std::vector<clang::NamedDecl *> decls;
+ if (FindDecls(name, /*append*/ true, max_matches, decls))
+ for (auto *decl : decls)
+ if (auto type = ClangASTContext::GetTypeForDecl(decl))
+ ret.push_back(type);
+ return ret;
+}
diff --git a/source/Symbol/Declaration.cpp b/source/Symbol/Declaration.cpp
index 83df578da2e3b..d78ba967d280b 100644
--- a/source/Symbol/Declaration.cpp
+++ b/source/Symbol/Declaration.cpp
@@ -1,9 +1,8 @@
//===-- Declaration.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -84,6 +83,11 @@ int Declaration::Compare(const Declaration &a, const Declaration &b) {
return 0;
}
+bool Declaration::FileAndLineEqual(const Declaration &declaration) const {
+ int file_compare = FileSpec::Compare(this->m_file, declaration.m_file, true);
+ return file_compare == 0 && this->m_line == declaration.m_line;
+}
+
bool lldb_private::operator==(const Declaration &lhs, const Declaration &rhs) {
#ifdef LLDB_ENABLE_DECLARATION_COLUMNS
if (lhs.GetColumn() == rhs.GetColumn())
diff --git a/source/Symbol/FuncUnwinders.cpp b/source/Symbol/FuncUnwinders.cpp
index 35ce72f32b61e..09cb9b00aaf3b 100644
--- a/source/Symbol/FuncUnwinders.cpp
+++ b/source/Symbol/FuncUnwinders.cpp
@@ -1,9 +1,8 @@
//===-- FuncUnwinders.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,22 +13,24 @@
#include "lldb/Symbol/CompactUnwindInfo.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Symbol/UnwindTable.h"
#include "lldb/Target/ABI.h"
#include "lldb/Target/ExecutionContext.h"
#include "lldb/Target/Process.h"
+#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/RegisterNumber.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Target/UnwindAssembly.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//------------------------------------------------
/// constructor
-//------------------------------------------------
FuncUnwinders::FuncUnwinders(UnwindTable &unwind_table, AddressRange range)
: m_unwind_table(unwind_table), m_range(range), m_mutex(),
@@ -43,35 +44,35 @@ FuncUnwinders::FuncUnwinders(UnwindTable &unwind_table, AddressRange range)
m_tried_unwind_plan_eh_frame_augmented(false),
m_tried_unwind_plan_debug_frame_augmented(false),
m_tried_unwind_plan_compact_unwind(false),
- m_tried_unwind_plan_arm_unwind(false), m_tried_unwind_fast(false),
+ m_tried_unwind_plan_arm_unwind(false),
+ m_tried_unwind_plan_symbol_file(false), m_tried_unwind_fast(false),
m_tried_unwind_arch_default(false),
m_tried_unwind_arch_default_at_func_entry(false),
m_first_non_prologue_insn() {}
-//------------------------------------------------
/// destructor
-//------------------------------------------------
FuncUnwinders::~FuncUnwinders() {}
UnwindPlanSP FuncUnwinders::GetUnwindPlanAtCallSite(Target &target,
- int current_offset) {
+ Thread &thread) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target, current_offset))
+ if (UnwindPlanSP plan_sp = GetSymbolFileUnwindPlan(thread))
return plan_sp;
- if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target, current_offset))
+ if (UnwindPlanSP plan_sp = GetDebugFrameUnwindPlan(target))
return plan_sp;
- if (UnwindPlanSP plan_sp = GetCompactUnwindUnwindPlan(target, current_offset))
+ if (UnwindPlanSP plan_sp = GetEHFrameUnwindPlan(target))
return plan_sp;
- if (UnwindPlanSP plan_sp = GetArmUnwindUnwindPlan(target, current_offset))
+ if (UnwindPlanSP plan_sp = GetCompactUnwindUnwindPlan(target))
+ return plan_sp;
+ if (UnwindPlanSP plan_sp = GetArmUnwindUnwindPlan(target))
return plan_sp;
return nullptr;
}
-UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target,
- int current_offset) {
+UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_compact_unwind.size() > 0)
return m_unwind_plan_compact_unwind[0]; // FIXME support multiple compact
@@ -82,8 +83,6 @@ UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target,
m_tried_unwind_plan_compact_unwind = true;
if (m_range.GetBaseAddress().IsValid()) {
Address current_pc(m_range.GetBaseAddress());
- if (current_offset != -1)
- current_pc.SetOffset(current_pc.GetOffset() + current_offset);
CompactUnwindInfo *compact_unwind = m_unwind_table.GetCompactUnwindInfo();
if (compact_unwind) {
UnwindPlanSP unwind_plan_sp(new UnwindPlan(lldb::eRegisterKindGeneric));
@@ -98,53 +97,43 @@ UnwindPlanSP FuncUnwinders::GetCompactUnwindUnwindPlan(Target &target,
return UnwindPlanSP();
}
-UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target,
- int current_offset) {
+UnwindPlanSP FuncUnwinders::GetEHFrameUnwindPlan(Target &target) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_eh_frame_sp.get() || m_tried_unwind_plan_eh_frame)
return m_unwind_plan_eh_frame_sp;
m_tried_unwind_plan_eh_frame = true;
if (m_range.GetBaseAddress().IsValid()) {
- Address current_pc(m_range.GetBaseAddress());
- if (current_offset != -1)
- current_pc.SetOffset(current_pc.GetOffset() + current_offset);
DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo();
if (eh_frame) {
- m_unwind_plan_eh_frame_sp.reset(
- new UnwindPlan(lldb::eRegisterKindGeneric));
- if (!eh_frame->GetUnwindPlan(current_pc, *m_unwind_plan_eh_frame_sp))
+ m_unwind_plan_eh_frame_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
+ if (!eh_frame->GetUnwindPlan(m_range, *m_unwind_plan_eh_frame_sp))
m_unwind_plan_eh_frame_sp.reset();
}
}
return m_unwind_plan_eh_frame_sp;
}
-UnwindPlanSP FuncUnwinders::GetDebugFrameUnwindPlan(Target &target,
- int current_offset) {
+UnwindPlanSP FuncUnwinders::GetDebugFrameUnwindPlan(Target &target) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_debug_frame_sp || m_tried_unwind_plan_debug_frame)
return m_unwind_plan_debug_frame_sp;
m_tried_unwind_plan_debug_frame = true;
if (m_range.GetBaseAddress().IsValid()) {
- Address current_pc(m_range.GetBaseAddress());
- if (current_offset != -1)
- current_pc.SetOffset(current_pc.GetOffset() + current_offset);
DWARFCallFrameInfo *debug_frame = m_unwind_table.GetDebugFrameInfo();
if (debug_frame) {
- m_unwind_plan_debug_frame_sp.reset(
- new UnwindPlan(lldb::eRegisterKindGeneric));
- if (!debug_frame->GetUnwindPlan(current_pc,
- *m_unwind_plan_debug_frame_sp))
+ m_unwind_plan_debug_frame_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
+ if (!debug_frame->GetUnwindPlan(m_range, *m_unwind_plan_debug_frame_sp))
m_unwind_plan_debug_frame_sp.reset();
}
}
return m_unwind_plan_debug_frame_sp;
}
-UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target,
- int current_offset) {
+UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_arm_unwind_sp.get() || m_tried_unwind_plan_arm_unwind)
return m_unwind_plan_arm_unwind_sp;
@@ -152,12 +141,10 @@ UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target,
m_tried_unwind_plan_arm_unwind = true;
if (m_range.GetBaseAddress().IsValid()) {
Address current_pc(m_range.GetBaseAddress());
- if (current_offset != -1)
- current_pc.SetOffset(current_pc.GetOffset() + current_offset);
ArmUnwindInfo *arm_unwind_info = m_unwind_table.GetArmUnwindInfo();
if (arm_unwind_info) {
- m_unwind_plan_arm_unwind_sp.reset(
- new UnwindPlan(lldb::eRegisterKindGeneric));
+ m_unwind_plan_arm_unwind_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (!arm_unwind_info->GetUnwindPlan(target, current_pc,
*m_unwind_plan_arm_unwind_sp))
m_unwind_plan_arm_unwind_sp.reset();
@@ -166,9 +153,40 @@ UnwindPlanSP FuncUnwinders::GetArmUnwindUnwindPlan(Target &target,
return m_unwind_plan_arm_unwind_sp;
}
+namespace {
+class RegisterContextToInfo: public SymbolFile::RegisterInfoResolver {
+public:
+ RegisterContextToInfo(RegisterContext &ctx) : m_ctx(ctx) {}
+
+ const RegisterInfo *ResolveName(llvm::StringRef name) const {
+ return m_ctx.GetRegisterInfoByName(name);
+ }
+ const RegisterInfo *ResolveNumber(lldb::RegisterKind kind,
+ uint32_t number) const {
+ return m_ctx.GetRegisterInfo(kind, number);
+ }
+
+private:
+ RegisterContext &m_ctx;
+};
+} // namespace
+
+UnwindPlanSP FuncUnwinders::GetSymbolFileUnwindPlan(Thread &thread) {
+ std::lock_guard<std::recursive_mutex> guard(m_mutex);
+ if (m_unwind_plan_symbol_file_sp.get() || m_tried_unwind_plan_symbol_file)
+ return m_unwind_plan_symbol_file_sp;
+
+ m_tried_unwind_plan_symbol_file = true;
+ if (SymbolFile *symfile = m_unwind_table.GetSymbolFile()) {
+ m_unwind_plan_symbol_file_sp = symfile->GetUnwindPlan(
+ m_range.GetBaseAddress(),
+ RegisterContextToInfo(*thread.GetRegisterContext()));
+ }
+ return m_unwind_plan_symbol_file_sp;
+}
+
UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
- Thread &thread,
- int current_offset) {
+ Thread &thread) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_eh_frame_augmented_sp.get() ||
m_tried_unwind_plan_eh_frame_augmented)
@@ -186,11 +204,12 @@ UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
m_tried_unwind_plan_eh_frame_augmented = true;
- UnwindPlanSP eh_frame_plan = GetEHFrameUnwindPlan(target, current_offset);
+ UnwindPlanSP eh_frame_plan = GetEHFrameUnwindPlan(target);
if (!eh_frame_plan)
return m_unwind_plan_eh_frame_augmented_sp;
- m_unwind_plan_eh_frame_augmented_sp.reset(new UnwindPlan(*eh_frame_plan));
+ m_unwind_plan_eh_frame_augmented_sp =
+ std::make_shared<UnwindPlan>(*eh_frame_plan);
// Augment the eh_frame instructions with epilogue descriptions if necessary
// so the UnwindPlan can be used at any instruction in the function.
@@ -207,9 +226,8 @@ UnwindPlanSP FuncUnwinders::GetEHFrameAugmentedUnwindPlan(Target &target,
return m_unwind_plan_eh_frame_augmented_sp;
}
-UnwindPlanSP
-FuncUnwinders::GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread,
- int current_offset) {
+UnwindPlanSP FuncUnwinders::GetDebugFrameAugmentedUnwindPlan(Target &target,
+ Thread &thread) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_debug_frame_augmented_sp.get() ||
m_tried_unwind_plan_debug_frame_augmented)
@@ -227,13 +245,12 @@ FuncUnwinders::GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread,
m_tried_unwind_plan_debug_frame_augmented = true;
- UnwindPlanSP debug_frame_plan =
- GetDebugFrameUnwindPlan(target, current_offset);
+ UnwindPlanSP debug_frame_plan = GetDebugFrameUnwindPlan(target);
if (!debug_frame_plan)
return m_unwind_plan_debug_frame_augmented_sp;
- m_unwind_plan_debug_frame_augmented_sp.reset(
- new UnwindPlan(*debug_frame_plan));
+ m_unwind_plan_debug_frame_augmented_sp =
+ std::make_shared<UnwindPlan>(*debug_frame_plan);
// Augment the debug_frame instructions with epilogue descriptions if
// necessary so the UnwindPlan can be used at any instruction in the
@@ -251,8 +268,7 @@ FuncUnwinders::GetDebugFrameAugmentedUnwindPlan(Target &target, Thread &thread,
}
UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target &target,
- Thread &thread,
- int current_offset) {
+ Thread &thread) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
if (m_unwind_plan_assembly_sp.get() || m_tried_unwind_plan_assembly ||
!m_unwind_table.GetAllowAssemblyEmulationUnwindPlans()) {
@@ -263,7 +279,8 @@ UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target &target,
UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
if (assembly_profiler_sp) {
- m_unwind_plan_assembly_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric));
+ m_unwind_plan_assembly_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (!assembly_profiler_sp->GetNonCallSiteUnwindPlanFromAssembly(
m_range, thread, *m_unwind_plan_assembly_sp)) {
m_unwind_plan_assembly_sp.reset();
@@ -307,16 +324,14 @@ LazyBool FuncUnwinders::CompareUnwindPlansForIdenticalInitialPCLocation(
}
UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target,
- Thread &thread,
- int current_offset) {
- UnwindPlanSP eh_frame_sp = GetEHFrameUnwindPlan(target, current_offset);
+ Thread &thread) {
+ UnwindPlanSP eh_frame_sp = GetEHFrameUnwindPlan(target);
if (!eh_frame_sp)
- eh_frame_sp = GetDebugFrameUnwindPlan(target, current_offset);
+ eh_frame_sp = GetDebugFrameUnwindPlan(target);
UnwindPlanSP arch_default_at_entry_sp =
GetUnwindPlanArchitectureDefaultAtFunctionEntry(thread);
UnwindPlanSP arch_default_sp = GetUnwindPlanArchitectureDefault(thread);
- UnwindPlanSP assembly_sp =
- GetAssemblyUnwindPlan(target, thread, current_offset);
+ UnwindPlanSP assembly_sp = GetAssemblyUnwindPlan(target, thread);
// This point of this code is to detect when a function is using a non-
// standard ABI, and the eh_frame correctly describes that alternate ABI.
@@ -345,11 +360,11 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanAtNonCallSite(Target &target,
return eh_frame_sp;
}
- if (UnwindPlanSP plan_sp =
- GetEHFrameAugmentedUnwindPlan(target, thread, current_offset))
+ if (UnwindPlanSP plan_sp = GetSymbolFileUnwindPlan(thread))
+ return plan_sp;
+ if (UnwindPlanSP plan_sp = GetDebugFrameAugmentedUnwindPlan(target, thread))
return plan_sp;
- if (UnwindPlanSP plan_sp =
- GetDebugFrameAugmentedUnwindPlan(target, thread, current_offset))
+ if (UnwindPlanSP plan_sp = GetEHFrameAugmentedUnwindPlan(target, thread))
return plan_sp;
return assembly_sp;
@@ -365,7 +380,8 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanFastUnwind(Target &target,
UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
if (assembly_profiler_sp) {
- m_unwind_plan_fast_sp.reset(new UnwindPlan(lldb::eRegisterKindGeneric));
+ m_unwind_plan_fast_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (!assembly_profiler_sp->GetFastUnwindPlan(m_range, thread,
*m_unwind_plan_fast_sp)) {
m_unwind_plan_fast_sp.reset();
@@ -386,8 +402,8 @@ UnwindPlanSP FuncUnwinders::GetUnwindPlanArchitectureDefault(Thread &thread) {
if (process_sp) {
ABI *abi = process_sp->GetABI().get();
if (abi) {
- m_unwind_plan_arch_default_sp.reset(
- new UnwindPlan(lldb::eRegisterKindGeneric));
+ m_unwind_plan_arch_default_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (!abi->CreateDefaultUnwindPlan(*m_unwind_plan_arch_default_sp)) {
m_unwind_plan_arch_default_sp.reset();
}
@@ -411,8 +427,8 @@ FuncUnwinders::GetUnwindPlanArchitectureDefaultAtFunctionEntry(Thread &thread) {
if (process_sp) {
ABI *abi = process_sp->GetABI().get();
if (abi) {
- m_unwind_plan_arch_default_at_func_entry_sp.reset(
- new UnwindPlan(lldb::eRegisterKindGeneric));
+ m_unwind_plan_arch_default_at_func_entry_sp =
+ std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
if (!abi->CreateFunctionEntryUnwindPlan(
*m_unwind_plan_arch_default_at_func_entry_sp)) {
m_unwind_plan_arch_default_at_func_entry_sp.reset();
@@ -453,9 +469,9 @@ FuncUnwinders::GetUnwindAssemblyProfiler(Target &target) {
Address FuncUnwinders::GetLSDAAddress(Target &target) {
Address lsda_addr;
- UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan(target, -1);
+ UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan(target);
if (unwind_plan_sp.get() == nullptr) {
- unwind_plan_sp = GetCompactUnwindUnwindPlan(target, -1);
+ unwind_plan_sp = GetCompactUnwindUnwindPlan(target);
}
if (unwind_plan_sp.get() && unwind_plan_sp->GetLSDAAddress().IsValid()) {
lsda_addr = unwind_plan_sp->GetLSDAAddress();
@@ -466,9 +482,9 @@ Address FuncUnwinders::GetLSDAAddress(Target &target) {
Address FuncUnwinders::GetPersonalityRoutinePtrAddress(Target &target) {
Address personality_addr;
- UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan(target, -1);
+ UnwindPlanSP unwind_plan_sp = GetEHFrameUnwindPlan(target);
if (unwind_plan_sp.get() == nullptr) {
- unwind_plan_sp = GetCompactUnwindUnwindPlan(target, -1);
+ unwind_plan_sp = GetCompactUnwindUnwindPlan(target);
}
if (unwind_plan_sp.get() &&
unwind_plan_sp->GetPersonalityFunctionPtr().IsValid()) {
diff --git a/source/Symbol/Function.cpp b/source/Symbol/Function.cpp
index f792a5c5213e7..951392c1f1bff 100644
--- a/source/Symbol/Function.cpp
+++ b/source/Symbol/Function.cpp
@@ -1,9 +1,8 @@
//===-- Function.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,14 +24,12 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Basic function information is contained in the FunctionInfo class. It is
// designed to contain the name, linkage name, and declaration location.
-//----------------------------------------------------------------------
FunctionInfo::FunctionInfo(const char *name, const Declaration *decl_ptr)
: m_name(name), m_declaration(decl_ptr) {}
-FunctionInfo::FunctionInfo(const ConstString &name, const Declaration *decl_ptr)
+FunctionInfo::FunctionInfo(ConstString name, const Declaration *decl_ptr)
: m_name(name), m_declaration(decl_ptr) {}
FunctionInfo::~FunctionInfo() {}
@@ -69,7 +66,7 @@ InlineFunctionInfo::InlineFunctionInfo(const char *name, const char *mangled,
: FunctionInfo(name, decl_ptr), m_mangled(ConstString(mangled), true),
m_call_decl(call_decl_ptr) {}
-InlineFunctionInfo::InlineFunctionInfo(const ConstString &name,
+InlineFunctionInfo::InlineFunctionInfo(ConstString name,
const Mangled &mangled,
const Declaration *decl_ptr,
const Declaration *call_decl_ptr)
@@ -130,9 +127,7 @@ size_t InlineFunctionInfo::MemorySize() const {
return FunctionInfo::MemorySize() + m_mangled.MemorySize();
}
-//----------------------------------------------------------------------
//
-//----------------------------------------------------------------------
CallEdge::CallEdge(const char *symbol_name, lldb::addr_t return_pc)
: return_pc(return_pc), resolved(false) {
lazy_callee.symbol_name = symbol_name;
@@ -183,15 +178,13 @@ lldb::addr_t CallEdge::GetReturnPCAddress(Function &caller,
return base.GetLoadAddress(&target) + return_pc;
}
-//----------------------------------------------------------------------
//
-//----------------------------------------------------------------------
Function::Function(CompileUnit *comp_unit, lldb::user_id_t func_uid,
lldb::user_id_t type_uid, const Mangled &mangled, Type *type,
const AddressRange &range)
: UserID(func_uid), m_comp_unit(comp_unit), m_type_uid(type_uid),
m_type(type), m_mangled(mangled), m_block(func_uid), m_range(range),
- m_frame_base(nullptr), m_flags(), m_prologue_byte_size(0) {
+ m_frame_base(), m_flags(), m_prologue_byte_size(0) {
m_block.SetParentScope(this);
assert(comp_unit != nullptr);
}
@@ -553,7 +546,7 @@ uint32_t Function::GetPrologueByteSize() {
// Now calculate the offset to pass the subsequent line 0 entries.
uint32_t first_non_zero_line = prologue_end_line_idx;
- while (1) {
+ while (true) {
LineEntry line_entry;
if (line_table->GetLineEntryAtIndex(first_non_zero_line,
line_entry)) {
@@ -596,10 +589,14 @@ uint32_t Function::GetPrologueByteSize() {
}
lldb::LanguageType Function::GetLanguage() const {
+ lldb::LanguageType lang = m_mangled.GuessLanguage();
+ if (lang != lldb::eLanguageTypeUnknown)
+ return lang;
+
if (m_comp_unit)
return m_comp_unit->GetLanguage();
- else
- return lldb::eLanguageTypeUnknown;
+
+ return lldb::eLanguageTypeUnknown;
}
ConstString Function::GetName() const {
diff --git a/source/Symbol/LineEntry.cpp b/source/Symbol/LineEntry.cpp
index bffcc5321b113..959a3274ec925 100644
--- a/source/Symbol/LineEntry.cpp
+++ b/source/Symbol/LineEntry.cpp
@@ -1,9 +1,8 @@
//===-- LineEntry.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -191,40 +190,62 @@ int LineEntry::Compare(const LineEntry &a, const LineEntry &b) {
return FileSpec::Compare(a.file, b.file, true);
}
-AddressRange LineEntry::GetSameLineContiguousAddressRange() const {
+AddressRange LineEntry::GetSameLineContiguousAddressRange(
+ bool include_inlined_functions) const {
// Add each LineEntry's range to complete_line_range until we find a
// different file / line number.
AddressRange complete_line_range = range;
+ auto symbol_context_scope = lldb::eSymbolContextLineEntry;
+ Declaration start_call_site(original_file, line);
+ if (include_inlined_functions)
+ symbol_context_scope |= lldb::eSymbolContextBlock;
while (true) {
SymbolContext next_line_sc;
Address range_end(complete_line_range.GetBaseAddress());
range_end.Slide(complete_line_range.GetByteSize());
- range_end.CalculateSymbolContext(&next_line_sc,
- lldb::eSymbolContextLineEntry);
+ range_end.CalculateSymbolContext(&next_line_sc, symbol_context_scope);
+
+ if (!next_line_sc.line_entry.IsValid() ||
+ next_line_sc.line_entry.range.GetByteSize() == 0)
+ break;
- if (next_line_sc.line_entry.IsValid() &&
- next_line_sc.line_entry.range.GetByteSize() > 0 &&
- original_file == next_line_sc.line_entry.original_file) {
+ if (original_file == next_line_sc.line_entry.original_file &&
+ (next_line_sc.line_entry.line == 0 ||
+ line == next_line_sc.line_entry.line)) {
// Include any line 0 entries - they indicate that this is compiler-
// generated code that does not correspond to user source code.
- if (next_line_sc.line_entry.line == 0) {
- complete_line_range.SetByteSize(
- complete_line_range.GetByteSize() +
- next_line_sc.line_entry.range.GetByteSize());
- continue;
- }
-
- if (line == next_line_sc.line_entry.line) {
- // next_line_sc is the same file & line as this LineEntry, so extend
- // our AddressRange by its size and continue to see if there are more
- // LineEntries that we can combine.
- complete_line_range.SetByteSize(
- complete_line_range.GetByteSize() +
- next_line_sc.line_entry.range.GetByteSize());
- continue;
- }
+ // next_line_sc is the same file & line as this LineEntry, so extend
+ // our AddressRange by its size and continue to see if there are more
+ // LineEntries that we can combine. However, if there was nothing to
+ // extend we're done.
+ if (!complete_line_range.Extend(next_line_sc.line_entry.range))
+ break;
+ continue;
}
+
+ if (include_inlined_functions && next_line_sc.block &&
+ next_line_sc.block->GetContainingInlinedBlock() != nullptr) {
+ // The next_line_sc might be in a different file if it's an inlined
+ // function. If this is the case then we still want to expand our line
+ // range to include them if the inlined function is at the same call site
+ // as this line entry. The current block could represent a nested inline
+ // function call so we need to need to check up the block tree to see if
+ // we find one.
+ auto inlined_parent_block =
+ next_line_sc.block->GetContainingInlinedBlockWithCallSite(
+ start_call_site);
+ if (!inlined_parent_block)
+ // We didn't find any parent inlined block with a call site at this line
+ // entry so this inlined function is probably at another line.
+ break;
+ // Extend our AddressRange by the size of the inlined block, but if there
+ // was nothing to add then we're done.
+ if (!complete_line_range.Extend(next_line_sc.line_entry.range))
+ break;
+ continue;
+ }
+
break;
}
return complete_line_range;
diff --git a/source/Symbol/LineTable.cpp b/source/Symbol/LineTable.cpp
index 06e30219f09a3..8d4d72c9a2a21 100644
--- a/source/Symbol/LineTable.cpp
+++ b/source/Symbol/LineTable.cpp
@@ -1,9 +1,8 @@
//===-- LineTable.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,15 +17,11 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// LineTable constructor
-//----------------------------------------------------------------------
LineTable::LineTable(CompileUnit *comp_unit)
: m_comp_unit(comp_unit), m_entries() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
LineTable::~LineTable() {}
void LineTable::InsertLineEntry(lldb::addr_t file_addr, uint32_t line,
@@ -126,7 +121,7 @@ void LineTable::InsertSequence(LineSequence *sequence) {
pos++;
}
-#ifdef LLDB_CONFIGURATION_DEBUG
+#ifndef NDEBUG
// If we aren't inserting at the beginning, the previous entry should
// terminate a sequence.
if (pos != begin_pos) {
@@ -137,7 +132,6 @@ void LineTable::InsertSequence(LineSequence *sequence) {
m_entries.insert(pos, seq->m_entries.begin(), seq->m_entries.end());
}
-//----------------------------------------------------------------------
LineTable::Entry::LessThanBinaryPredicate::LessThanBinaryPredicate(
LineTable *line_table)
: m_line_table(line_table) {}
@@ -445,7 +439,7 @@ size_t LineTable::GetContiguousFileAddressRanges(FileAddressRanges &file_ranges,
}
LineTable *LineTable::LinkLineTable(const FileRangeMap &file_range_map) {
- std::unique_ptr<LineTable> line_table_ap(new LineTable(m_comp_unit));
+ std::unique_ptr<LineTable> line_table_up(new LineTable(m_comp_unit));
LineSequenceImpl sequence;
const size_t count = m_entries.size();
LineEntry line_entry;
@@ -508,7 +502,7 @@ LineTable *LineTable::LinkLineTable(const FileRangeMap &file_range_map) {
sequence.m_entries.back().is_terminal_entry = true;
// Append the sequence since we just terminated the previous one
- line_table_ap->InsertSequence(&sequence);
+ line_table_up->InsertSequence(&sequence);
sequence.Clear();
}
@@ -524,7 +518,7 @@ LineTable *LineTable::LinkLineTable(const FileRangeMap &file_range_map) {
// insert this sequence into our new line table.
if (!sequence.m_entries.empty() &&
sequence.m_entries.back().is_terminal_entry) {
- line_table_ap->InsertSequence(&sequence);
+ line_table_up->InsertSequence(&sequence);
sequence.Clear();
prev_entry_was_linked = false;
} else {
@@ -533,7 +527,7 @@ LineTable *LineTable::LinkLineTable(const FileRangeMap &file_range_map) {
prev_file_addr = entry.file_addr;
range_changed = false;
}
- if (line_table_ap->m_entries.empty())
+ if (line_table_up->m_entries.empty())
return nullptr;
- return line_table_ap.release();
+ return line_table_up.release();
}
diff --git a/source/Host/common/Symbols.cpp b/source/Symbol/LocateSymbolFile.cpp
index ed1677cbcb58f..bfdb6e705f4a0 100644
--- a/source/Host/common/Symbols.cpp
+++ b/source/Symbol/LocateSymbolFile.cpp
@@ -1,17 +1,17 @@
-//===-- Symbols.cpp ---------------------------------------------*- C++ -*-===//
+//===-- LocateSymbolFile.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-#include "lldb/Host/Symbols.h"
+#include "lldb/Symbol/LocateSymbolFile.h"
+
+#include "lldb/Core/ModuleList.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataBuffer.h"
#include "lldb/Utility/DataExtractor.h"
@@ -55,9 +55,10 @@ static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec,
bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
UNUSED_IF_ASSERT_DISABLED(got_spec);
assert(got_spec);
- if ((uuid == NULL || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
- (arch == NULL || (spec.GetArchitecturePtr() &&
- spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
+ if ((uuid == nullptr || (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
+ (arch == nullptr ||
+ (spec.GetArchitecturePtr() &&
+ spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
return true;
}
}
@@ -67,8 +68,8 @@ static bool FileAtPathContainsArchAndUUID(const FileSpec &file_fspec,
// Given a binary exec_fspec, and a ModuleSpec with an architecture/uuid,
// return true if there is a matching dSYM bundle next to the exec_fspec,
-// and return that value in dsym_fspec.
-// If there is a .dSYM.yaa compressed archive next to the exec_fspec,
+// and return that value in dsym_fspec.
+// If there is a .dSYM.yaa compressed archive next to the exec_fspec,
// call through Symbols::DownloadObjectAndSymbolFile to download the
// expanded/uncompressed dSYM and return that filepath in dsym_fspec.
@@ -100,9 +101,9 @@ static bool LookForDsymNextToExecutablePath(const ModuleSpec &mod_spec,
// See if we have "../CF.framework" - so we'll look for
// CF.framework.dSYM/Contents/Resources/DWARF/CF
- // We need to drop the last suffix after '.' to match
+ // We need to drop the last suffix after '.' to match
// 'CF' in the DWARF subdir.
- std::string binary_name (filename.AsCString());
+ std::string binary_name(filename.AsCString());
auto last_dot = binary_name.find_last_of('.');
if (last_dot != std::string::npos) {
binary_name.erase(last_dot);
@@ -153,11 +154,13 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
const FileSpec &exec_fspec = module_spec.GetFileSpec();
if (exec_fspec) {
- if (::LookForDsymNextToExecutablePath (module_spec, exec_fspec, dsym_fspec)) {
- if (log) {
- log->Printf("dSYM with matching UUID & arch found at %s", dsym_fspec.GetPath().c_str());
- }
- return true;
+ if (::LookForDsymNextToExecutablePath(module_spec, exec_fspec,
+ dsym_fspec)) {
+ if (log) {
+ log->Printf("dSYM with matching UUID & arch found at %s",
+ dsym_fspec.GetPath().c_str());
+ }
+ return true;
} else {
FileSpec parent_dirs = exec_fspec;
@@ -183,7 +186,8 @@ static bool LocateDSYMInVincinityOfExecutable(const ModuleSpec &module_spec,
if (fn == nullptr)
break;
if (::strchr(fn, '.') != nullptr) {
- if (::LookForDsymNextToExecutablePath (module_spec, parent_dirs, dsym_fspec)) {
+ if (::LookForDsymNextToExecutablePath(module_spec, parent_dirs,
+ dsym_fspec)) {
if (log) {
log->Printf("dSYM with matching UUID & arch found at %s",
dsym_fspec.GetPath().c_str());
@@ -249,7 +253,9 @@ ModuleSpec Symbols::LocateExecutableObjectFile(const ModuleSpec &module_spec) {
// Keep "symbols.enable-external-lookup" description in sync with this function.
-FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
+FileSpec
+Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec,
+ const FileSpecList &default_search_paths) {
FileSpec symbol_file_spec = module_spec.GetSymbolFileSpec();
if (symbol_file_spec.IsAbsolute() &&
FileSystem::Instance().Exists(symbol_file_spec))
@@ -257,15 +263,15 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
const char *symbol_filename = symbol_file_spec.GetFilename().AsCString();
if (symbol_filename && symbol_filename[0]) {
- FileSpecList debug_file_search_paths(
- Target::GetDefaultDebugFileSearchPaths());
+ FileSpecList debug_file_search_paths = default_search_paths;
// Add module directory.
FileSpec module_file_spec = module_spec.GetFileSpec();
// We keep the unresolved pathname if it fails.
- FileSystem::Instance().ResolveSymbolicLink(module_file_spec, module_file_spec);
+ FileSystem::Instance().ResolveSymbolicLink(module_file_spec,
+ module_file_spec);
- const ConstString &file_dir = module_file_spec.GetDirectory();
+ ConstString file_dir = module_file_spec.GetDirectory();
{
FileSpec file_spec(file_dir.AsCString("."));
FileSystem::Instance().Resolve(file_spec);
@@ -307,7 +313,7 @@ FileSpec Symbols::LocateExecutableSymbolFile(const ModuleSpec &module_spec) {
// /usr/lib/debug/.build-id/ff/e7fe727889ad82bb153de2ad065b2189693315.debug
uuid_str = module_uuid.GetAsString("");
std::transform(uuid_str.begin(), uuid_str.end(), uuid_str.begin(),
- ::tolower);
+ ::tolower);
uuid_str.insert(2, 1, '/');
uuid_str = uuid_str + ".debug";
}
diff --git a/source/Symbol/LocateSymbolFileMacOSX.cpp b/source/Symbol/LocateSymbolFileMacOSX.cpp
new file mode 100644
index 0000000000000..4e16382d53e77
--- /dev/null
+++ b/source/Symbol/LocateSymbolFileMacOSX.cpp
@@ -0,0 +1,657 @@
+//===-- LocateSymbolFileMacOSX.cpp ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/LocateSymbolFile.h"
+
+#include <dirent.h>
+#include <dlfcn.h>
+#include <pwd.h>
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#include "Host/macosx/cfcpp/CFCBundle.h"
+#include "Host/macosx/cfcpp/CFCData.h"
+#include "Host/macosx/cfcpp/CFCReleaser.h"
+#include "Host/macosx/cfcpp/CFCString.h"
+#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/CleanUp.h"
+#include "lldb/Utility/DataBuffer.h"
+#include "lldb/Utility/DataExtractor.h"
+#include "lldb/Utility/Endian.h"
+#include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/Timer.h"
+#include "lldb/Utility/UUID.h"
+#include "mach/machine.h"
+
+#include "llvm/Support/FileSystem.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+static CFURLRef (*g_dlsym_DBGCopyFullDSYMURLForUUID)(CFUUIDRef uuid, CFURLRef exec_url) = nullptr;
+static CFDictionaryRef (*g_dlsym_DBGCopyDSYMPropertyLists)(CFURLRef dsym_url) = nullptr;
+
+int LocateMacOSXFilesUsingDebugSymbols(const ModuleSpec &module_spec,
+ ModuleSpec &return_module_spec) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ if (!ModuleList::GetGlobalModuleListProperties().GetEnableExternalLookup()) {
+ if (log)
+ log->Printf("Spotlight lookup for .dSYM bundles is disabled.");
+ return 0;
+ }
+
+ return_module_spec = module_spec;
+ return_module_spec.GetFileSpec().Clear();
+ return_module_spec.GetSymbolFileSpec().Clear();
+
+ int items_found = 0;
+
+ if (g_dlsym_DBGCopyFullDSYMURLForUUID == nullptr ||
+ g_dlsym_DBGCopyDSYMPropertyLists == nullptr) {
+ void *handle = dlopen ("/System/Library/PrivateFrameworks/DebugSymbols.framework/DebugSymbols", RTLD_LAZY | RTLD_LOCAL);
+ if (handle) {
+ g_dlsym_DBGCopyFullDSYMURLForUUID = (CFURLRef (*)(CFUUIDRef, CFURLRef)) dlsym (handle, "DBGCopyFullDSYMURLForUUID");
+ g_dlsym_DBGCopyDSYMPropertyLists = (CFDictionaryRef (*)(CFURLRef)) dlsym (handle, "DBGCopyDSYMPropertyLists");
+ }
+ }
+
+ if (g_dlsym_DBGCopyFullDSYMURLForUUID == nullptr ||
+ g_dlsym_DBGCopyDSYMPropertyLists == nullptr) {
+ return items_found;
+ }
+
+ const UUID *uuid = module_spec.GetUUIDPtr();
+ const ArchSpec *arch = module_spec.GetArchitecturePtr();
+
+ if (uuid && uuid->IsValid()) {
+ // Try and locate the dSYM file using DebugSymbols first
+ llvm::ArrayRef<uint8_t> module_uuid = uuid->GetBytes();
+ if (module_uuid.size() == 16) {
+ CFCReleaser<CFUUIDRef> module_uuid_ref(::CFUUIDCreateWithBytes(
+ NULL, module_uuid[0], module_uuid[1], module_uuid[2], module_uuid[3],
+ module_uuid[4], module_uuid[5], module_uuid[6], module_uuid[7],
+ module_uuid[8], module_uuid[9], module_uuid[10], module_uuid[11],
+ module_uuid[12], module_uuid[13], module_uuid[14], module_uuid[15]));
+
+ if (module_uuid_ref.get()) {
+ CFCReleaser<CFURLRef> exec_url;
+ const FileSpec *exec_fspec = module_spec.GetFileSpecPtr();
+ if (exec_fspec) {
+ char exec_cf_path[PATH_MAX];
+ if (exec_fspec->GetPath(exec_cf_path, sizeof(exec_cf_path)))
+ exec_url.reset(::CFURLCreateFromFileSystemRepresentation(
+ NULL, (const UInt8 *)exec_cf_path, strlen(exec_cf_path),
+ FALSE));
+ }
+
+ CFCReleaser<CFURLRef> dsym_url(
+ g_dlsym_DBGCopyFullDSYMURLForUUID(module_uuid_ref.get(), exec_url.get()));
+ char path[PATH_MAX];
+
+ if (dsym_url.get()) {
+ if (::CFURLGetFileSystemRepresentation(
+ dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
+ if (log) {
+ log->Printf("DebugSymbols framework returned dSYM path of %s for "
+ "UUID %s -- looking for the dSYM",
+ path, uuid->GetAsString().c_str());
+ }
+ FileSpec dsym_filespec(path);
+ if (path[0] == '~')
+ FileSystem::Instance().Resolve(dsym_filespec);
+
+ if (FileSystem::Instance().IsDirectory(dsym_filespec)) {
+ dsym_filespec =
+ Symbols::FindSymbolFileInBundle(dsym_filespec, uuid, arch);
+ ++items_found;
+ } else {
+ ++items_found;
+ }
+ return_module_spec.GetSymbolFileSpec() = dsym_filespec;
+ }
+
+ bool success = false;
+ if (log) {
+ if (::CFURLGetFileSystemRepresentation(
+ dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
+ log->Printf("DebugSymbols framework returned dSYM path of %s for "
+ "UUID %s -- looking for an exec file",
+ path, uuid->GetAsString().c_str());
+ }
+ }
+
+ CFCReleaser<CFDictionaryRef> dict(
+ g_dlsym_DBGCopyDSYMPropertyLists(dsym_url.get()));
+ CFDictionaryRef uuid_dict = NULL;
+ if (dict.get()) {
+ CFCString uuid_cfstr(uuid->GetAsString().c_str());
+ uuid_dict = static_cast<CFDictionaryRef>(
+ ::CFDictionaryGetValue(dict.get(), uuid_cfstr.get()));
+ }
+ if (uuid_dict) {
+ CFStringRef exec_cf_path =
+ static_cast<CFStringRef>(::CFDictionaryGetValue(
+ uuid_dict, CFSTR("DBGSymbolRichExecutable")));
+ if (exec_cf_path && ::CFStringGetFileSystemRepresentation(
+ exec_cf_path, path, sizeof(path))) {
+ if (log) {
+ log->Printf("plist bundle has exec path of %s for UUID %s",
+ path, uuid->GetAsString().c_str());
+ }
+ ++items_found;
+ FileSpec exec_filespec(path);
+ if (path[0] == '~')
+ FileSystem::Instance().Resolve(exec_filespec);
+ if (FileSystem::Instance().Exists(exec_filespec)) {
+ success = true;
+ return_module_spec.GetFileSpec() = exec_filespec;
+ }
+ }
+ }
+
+ if (!success) {
+ // No dictionary, check near the dSYM bundle for an executable that
+ // matches...
+ if (::CFURLGetFileSystemRepresentation(
+ dsym_url.get(), true, (UInt8 *)path, sizeof(path) - 1)) {
+ char *dsym_extension_pos = ::strstr(path, ".dSYM");
+ if (dsym_extension_pos) {
+ *dsym_extension_pos = '\0';
+ if (log) {
+ log->Printf("Looking for executable binary next to dSYM "
+ "bundle with name with name %s",
+ path);
+ }
+ FileSpec file_spec(path);
+ FileSystem::Instance().Resolve(file_spec);
+ ModuleSpecList module_specs;
+ ModuleSpec matched_module_spec;
+ using namespace llvm::sys::fs;
+ switch (get_file_type(file_spec.GetPath())) {
+
+ case file_type::directory_file: // Bundle directory?
+ {
+ CFCBundle bundle(path);
+ CFCReleaser<CFURLRef> bundle_exe_url(
+ bundle.CopyExecutableURL());
+ if (bundle_exe_url.get()) {
+ if (::CFURLGetFileSystemRepresentation(bundle_exe_url.get(),
+ true, (UInt8 *)path,
+ sizeof(path) - 1)) {
+ FileSpec bundle_exe_file_spec(path);
+ FileSystem::Instance().Resolve(bundle_exe_file_spec);
+ if (ObjectFile::GetModuleSpecifications(
+ bundle_exe_file_spec, 0, 0, module_specs) &&
+ module_specs.FindMatchingModuleSpec(
+ module_spec, matched_module_spec))
+
+ {
+ ++items_found;
+ return_module_spec.GetFileSpec() = bundle_exe_file_spec;
+ if (log) {
+ log->Printf("Executable binary %s next to dSYM is "
+ "compatible; using",
+ path);
+ }
+ }
+ }
+ }
+ } break;
+
+ case file_type::fifo_file: // Forget pipes
+ case file_type::socket_file: // We can't process socket files
+ case file_type::file_not_found: // File doesn't exist...
+ case file_type::status_error:
+ break;
+
+ case file_type::type_unknown:
+ case file_type::regular_file:
+ case file_type::symlink_file:
+ case file_type::block_file:
+ case file_type::character_file:
+ if (ObjectFile::GetModuleSpecifications(file_spec, 0, 0,
+ module_specs) &&
+ module_specs.FindMatchingModuleSpec(module_spec,
+ matched_module_spec))
+
+ {
+ ++items_found;
+ return_module_spec.GetFileSpec() = file_spec;
+ if (log) {
+ log->Printf("Executable binary %s next to dSYM is "
+ "compatible; using",
+ path);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return items_found;
+}
+
+FileSpec Symbols::FindSymbolFileInBundle(const FileSpec &dsym_bundle_fspec,
+ const lldb_private::UUID *uuid,
+ const ArchSpec *arch) {
+ char path[PATH_MAX];
+ if (dsym_bundle_fspec.GetPath(path, sizeof(path)) == 0)
+ return {};
+
+ ::strncat(path, "/Contents/Resources/DWARF", sizeof(path) - strlen(path) - 1);
+
+ DIR *dirp = opendir(path);
+ if (!dirp)
+ return {};
+
+ // Make sure we close the directory before exiting this scope.
+ CleanUp cleanup_dir(closedir, dirp);
+
+ FileSpec dsym_fspec;
+ dsym_fspec.GetDirectory().SetCString(path);
+ struct dirent *dp;
+ while ((dp = readdir(dirp)) != NULL) {
+ // Only search directories
+ if (dp->d_type == DT_DIR || dp->d_type == DT_UNKNOWN) {
+ if (dp->d_namlen == 1 && dp->d_name[0] == '.')
+ continue;
+
+ if (dp->d_namlen == 2 && dp->d_name[0] == '.' && dp->d_name[1] == '.')
+ continue;
+ }
+
+ if (dp->d_type == DT_REG || dp->d_type == DT_UNKNOWN) {
+ dsym_fspec.GetFilename().SetCString(dp->d_name);
+ ModuleSpecList module_specs;
+ if (ObjectFile::GetModuleSpecifications(dsym_fspec, 0, 0, module_specs)) {
+ ModuleSpec spec;
+ for (size_t i = 0; i < module_specs.GetSize(); ++i) {
+ bool got_spec = module_specs.GetModuleSpecAtIndex(i, spec);
+ UNUSED_IF_ASSERT_DISABLED(got_spec);
+ assert(got_spec);
+ if ((uuid == NULL ||
+ (spec.GetUUIDPtr() && spec.GetUUID() == *uuid)) &&
+ (arch == NULL ||
+ (spec.GetArchitecturePtr() &&
+ spec.GetArchitecture().IsCompatibleMatch(*arch)))) {
+ return dsym_fspec;
+ }
+ }
+ }
+ }
+ }
+
+ return {};
+}
+
+static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
+ ModuleSpec &module_spec) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ bool success = false;
+ if (uuid_dict != NULL && CFGetTypeID(uuid_dict) == CFDictionaryGetTypeID()) {
+ std::string str;
+ CFStringRef cf_str;
+ CFDictionaryRef cf_dict;
+
+ cf_str = (CFStringRef)CFDictionaryGetValue(
+ (CFDictionaryRef)uuid_dict, CFSTR("DBGSymbolRichExecutable"));
+ if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+ if (CFCString::FileSystemRepresentation(cf_str, str)) {
+ module_spec.GetFileSpec().SetFile(str.c_str(), FileSpec::Style::native);
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
+ if (log) {
+ log->Printf(
+ "From dsymForUUID plist: Symbol rich executable is at '%s'",
+ str.c_str());
+ }
+ }
+ }
+
+ cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+ CFSTR("DBGDSYMPath"));
+ if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+ if (CFCString::FileSystemRepresentation(cf_str, str)) {
+ module_spec.GetSymbolFileSpec().SetFile(str.c_str(),
+ FileSpec::Style::native);
+ FileSystem::Instance().Resolve(module_spec.GetFileSpec());
+ success = true;
+ if (log) {
+ log->Printf("From dsymForUUID plist: dSYM is at '%s'", str.c_str());
+ }
+ }
+ }
+
+ cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+ CFSTR("DBGArchitecture"));
+ if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+ if (CFCString::FileSystemRepresentation(cf_str, str))
+ module_spec.GetArchitecture().SetTriple(str.c_str());
+ }
+
+ std::string DBGBuildSourcePath;
+ std::string DBGSourcePath;
+
+ // If DBGVersion 1 or DBGVersion missing, ignore DBGSourcePathRemapping.
+ // If DBGVersion 2, strip last two components of path remappings from
+ // entries to fix an issue with a specific set of
+ // DBGSourcePathRemapping entries that lldb worked
+ // with.
+ // If DBGVersion 3, trust & use the source path remappings as-is.
+ //
+ cf_dict = (CFDictionaryRef)CFDictionaryGetValue(
+ (CFDictionaryRef)uuid_dict, CFSTR("DBGSourcePathRemapping"));
+ if (cf_dict && CFGetTypeID(cf_dict) == CFDictionaryGetTypeID()) {
+ // If we see DBGVersion with a value of 2 or higher, this is a new style
+ // DBGSourcePathRemapping dictionary
+ bool new_style_source_remapping_dictionary = false;
+ bool do_truncate_remapping_names = false;
+ std::string original_DBGSourcePath_value = DBGSourcePath;
+ cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+ CFSTR("DBGVersion"));
+ if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+ std::string version;
+ CFCString::FileSystemRepresentation(cf_str, version);
+ if (!version.empty() && isdigit(version[0])) {
+ int version_number = atoi(version.c_str());
+ if (version_number > 1) {
+ new_style_source_remapping_dictionary = true;
+ }
+ if (version_number == 2) {
+ do_truncate_remapping_names = true;
+ }
+ }
+ }
+
+ CFIndex kv_pair_count = CFDictionaryGetCount((CFDictionaryRef)uuid_dict);
+ if (kv_pair_count > 0) {
+ CFStringRef *keys =
+ (CFStringRef *)malloc(kv_pair_count * sizeof(CFStringRef));
+ CFStringRef *values =
+ (CFStringRef *)malloc(kv_pair_count * sizeof(CFStringRef));
+ if (keys != nullptr && values != nullptr) {
+ CFDictionaryGetKeysAndValues((CFDictionaryRef)uuid_dict,
+ (const void **)keys,
+ (const void **)values);
+ }
+ for (CFIndex i = 0; i < kv_pair_count; i++) {
+ DBGBuildSourcePath.clear();
+ DBGSourcePath.clear();
+ if (keys[i] && CFGetTypeID(keys[i]) == CFStringGetTypeID()) {
+ CFCString::FileSystemRepresentation(keys[i], DBGBuildSourcePath);
+ }
+ if (values[i] && CFGetTypeID(values[i]) == CFStringGetTypeID()) {
+ CFCString::FileSystemRepresentation(values[i], DBGSourcePath);
+ }
+ if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
+ // In the "old style" DBGSourcePathRemapping dictionary, the
+ // DBGSourcePath values (the "values" half of key-value path pairs)
+ // were wrong. Ignore them and use the universal DBGSourcePath
+ // string from earlier.
+ if (new_style_source_remapping_dictionary &&
+ !original_DBGSourcePath_value.empty()) {
+ DBGSourcePath = original_DBGSourcePath_value;
+ }
+ if (DBGSourcePath[0] == '~') {
+ FileSpec resolved_source_path(DBGSourcePath.c_str());
+ FileSystem::Instance().Resolve(resolved_source_path);
+ DBGSourcePath = resolved_source_path.GetPath();
+ }
+ // With version 2 of DBGSourcePathRemapping, we can chop off the
+ // last two filename parts from the source remapping and get a more
+ // general source remapping that still works. Add this as another
+ // option in addition to the full source path remap.
+ module_spec.GetSourceMappingList().Append(
+ ConstString(DBGBuildSourcePath.c_str()),
+ ConstString(DBGSourcePath.c_str()), true);
+ if (do_truncate_remapping_names) {
+ FileSpec build_path(DBGBuildSourcePath.c_str());
+ FileSpec source_path(DBGSourcePath.c_str());
+ build_path.RemoveLastPathComponent();
+ build_path.RemoveLastPathComponent();
+ source_path.RemoveLastPathComponent();
+ source_path.RemoveLastPathComponent();
+ module_spec.GetSourceMappingList().Append(
+ ConstString(build_path.GetPath().c_str()),
+ ConstString(source_path.GetPath().c_str()), true);
+ }
+ }
+ }
+ if (keys)
+ free(keys);
+ if (values)
+ free(values);
+ }
+ }
+
+ // If we have a DBGBuildSourcePath + DBGSourcePath pair, append them to the
+ // source remappings list.
+
+ cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+ CFSTR("DBGBuildSourcePath"));
+ if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+ CFCString::FileSystemRepresentation(cf_str, DBGBuildSourcePath);
+ }
+
+ cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
+ CFSTR("DBGSourcePath"));
+ if (cf_str && CFGetTypeID(cf_str) == CFStringGetTypeID()) {
+ CFCString::FileSystemRepresentation(cf_str, DBGSourcePath);
+ }
+
+ if (!DBGBuildSourcePath.empty() && !DBGSourcePath.empty()) {
+ if (DBGSourcePath[0] == '~') {
+ FileSpec resolved_source_path(DBGSourcePath.c_str());
+ FileSystem::Instance().Resolve(resolved_source_path);
+ DBGSourcePath = resolved_source_path.GetPath();
+ }
+ module_spec.GetSourceMappingList().Append(
+ ConstString(DBGBuildSourcePath.c_str()),
+ ConstString(DBGSourcePath.c_str()), true);
+ }
+ }
+ return success;
+}
+
+bool Symbols::DownloadObjectAndSymbolFile(ModuleSpec &module_spec,
+ bool force_lookup) {
+ bool success = false;
+ const UUID *uuid_ptr = module_spec.GetUUIDPtr();
+ const FileSpec *file_spec_ptr = module_spec.GetFileSpecPtr();
+
+ // It's expensive to check for the DBGShellCommands defaults setting, only do
+ // it once per lldb run and cache the result.
+ static bool g_have_checked_for_dbgshell_command = false;
+ static const char *g_dbgshell_command = NULL;
+ if (!g_have_checked_for_dbgshell_command) {
+ g_have_checked_for_dbgshell_command = true;
+ CFTypeRef defaults_setting = CFPreferencesCopyAppValue(
+ CFSTR("DBGShellCommands"), CFSTR("com.apple.DebugSymbols"));
+ if (defaults_setting &&
+ CFGetTypeID(defaults_setting) == CFStringGetTypeID()) {
+ char cstr_buf[PATH_MAX];
+ if (CFStringGetCString((CFStringRef)defaults_setting, cstr_buf,
+ sizeof(cstr_buf), kCFStringEncodingUTF8)) {
+ g_dbgshell_command =
+ strdup(cstr_buf); // this malloc'ed memory will never be freed
+ }
+ }
+ if (defaults_setting) {
+ CFRelease(defaults_setting);
+ }
+ }
+
+ // When g_dbgshell_command is NULL, the user has not enabled the use of an
+ // external program to find the symbols, don't run it for them.
+ if (!force_lookup && g_dbgshell_command == NULL) {
+ return false;
+ }
+
+ if (uuid_ptr ||
+ (file_spec_ptr && FileSystem::Instance().Exists(*file_spec_ptr))) {
+ static bool g_located_dsym_for_uuid_exe = false;
+ static bool g_dsym_for_uuid_exe_exists = false;
+ static char g_dsym_for_uuid_exe_path[PATH_MAX];
+ if (!g_located_dsym_for_uuid_exe) {
+ g_located_dsym_for_uuid_exe = true;
+ const char *dsym_for_uuid_exe_path_cstr =
+ getenv("LLDB_APPLE_DSYMFORUUID_EXECUTABLE");
+ FileSpec dsym_for_uuid_exe_spec;
+ if (dsym_for_uuid_exe_path_cstr) {
+ dsym_for_uuid_exe_spec.SetFile(dsym_for_uuid_exe_path_cstr,
+ FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dsym_for_uuid_exe_spec);
+ g_dsym_for_uuid_exe_exists =
+ FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
+ }
+
+ if (!g_dsym_for_uuid_exe_exists) {
+ dsym_for_uuid_exe_spec.SetFile("/usr/local/bin/dsymForUUID",
+ FileSpec::Style::native);
+ g_dsym_for_uuid_exe_exists =
+ FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
+ if (!g_dsym_for_uuid_exe_exists) {
+ long bufsize;
+ if ((bufsize = sysconf(_SC_GETPW_R_SIZE_MAX)) != -1) {
+ char buffer[bufsize];
+ struct passwd pwd;
+ struct passwd *tilde_rc = NULL;
+ // we are a library so we need to use the reentrant version of
+ // getpwnam()
+ if (getpwnam_r("rc", &pwd, buffer, bufsize, &tilde_rc) == 0 &&
+ tilde_rc && tilde_rc->pw_dir) {
+ std::string dsymforuuid_path(tilde_rc->pw_dir);
+ dsymforuuid_path += "/bin/dsymForUUID";
+ dsym_for_uuid_exe_spec.SetFile(dsymforuuid_path.c_str(),
+ FileSpec::Style::native);
+ g_dsym_for_uuid_exe_exists =
+ FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
+ }
+ }
+ }
+ }
+ if (!g_dsym_for_uuid_exe_exists && g_dbgshell_command != NULL) {
+ dsym_for_uuid_exe_spec.SetFile(g_dbgshell_command,
+ FileSpec::Style::native);
+ FileSystem::Instance().Resolve(dsym_for_uuid_exe_spec);
+ g_dsym_for_uuid_exe_exists =
+ FileSystem::Instance().Exists(dsym_for_uuid_exe_spec);
+ }
+
+ if (g_dsym_for_uuid_exe_exists)
+ dsym_for_uuid_exe_spec.GetPath(g_dsym_for_uuid_exe_path,
+ sizeof(g_dsym_for_uuid_exe_path));
+ }
+ if (g_dsym_for_uuid_exe_exists) {
+ std::string uuid_str;
+ char file_path[PATH_MAX];
+ file_path[0] = '\0';
+
+ if (uuid_ptr)
+ uuid_str = uuid_ptr->GetAsString();
+
+ if (file_spec_ptr)
+ file_spec_ptr->GetPath(file_path, sizeof(file_path));
+
+ StreamString command;
+ if (!uuid_str.empty())
+ command.Printf("%s --ignoreNegativeCache --copyExecutable %s",
+ g_dsym_for_uuid_exe_path, uuid_str.c_str());
+ else if (file_path[0] != '\0')
+ command.Printf("%s --ignoreNegativeCache --copyExecutable %s",
+ g_dsym_for_uuid_exe_path, file_path);
+
+ if (!command.GetString().empty()) {
+ Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
+ int exit_status = -1;
+ int signo = -1;
+ std::string command_output;
+ if (log) {
+ if (!uuid_str.empty())
+ log->Printf("Calling %s with UUID %s to find dSYM",
+ g_dsym_for_uuid_exe_path, uuid_str.c_str());
+ else if (file_path[0] != '\0')
+ log->Printf("Calling %s with file %s to find dSYM",
+ g_dsym_for_uuid_exe_path, file_path);
+ }
+ Status error = Host::RunShellCommand(
+ command.GetData(),
+ NULL, // current working directory
+ &exit_status, // Exit status
+ &signo, // Signal int *
+ &command_output, // Command output
+ std::chrono::seconds(
+ 120), // Large timeout to allow for long dsym download times
+ false); // Don't run in a shell (we don't need shell expansion)
+ if (error.Success() && exit_status == 0 && !command_output.empty()) {
+ CFCData data(CFDataCreateWithBytesNoCopy(
+ NULL, (const UInt8 *)command_output.data(), command_output.size(),
+ kCFAllocatorNull));
+
+ CFCReleaser<CFDictionaryRef> plist(
+ (CFDictionaryRef)::CFPropertyListCreateFromXMLData(
+ NULL, data.get(), kCFPropertyListImmutable, NULL));
+
+ if (plist.get() &&
+ CFGetTypeID(plist.get()) == CFDictionaryGetTypeID()) {
+ if (!uuid_str.empty()) {
+ CFCString uuid_cfstr(uuid_str.c_str());
+ CFDictionaryRef uuid_dict = (CFDictionaryRef)CFDictionaryGetValue(
+ plist.get(), uuid_cfstr.get());
+ success =
+ GetModuleSpecInfoFromUUIDDictionary(uuid_dict, module_spec);
+ } else {
+ const CFIndex num_values = ::CFDictionaryGetCount(plist.get());
+ if (num_values > 0) {
+ std::vector<CFStringRef> keys(num_values, NULL);
+ std::vector<CFDictionaryRef> values(num_values, NULL);
+ ::CFDictionaryGetKeysAndValues(plist.get(), NULL,
+ (const void **)&values[0]);
+ if (num_values == 1) {
+ return GetModuleSpecInfoFromUUIDDictionary(values[0],
+ module_spec);
+ } else {
+ for (CFIndex i = 0; i < num_values; ++i) {
+ ModuleSpec curr_module_spec;
+ if (GetModuleSpecInfoFromUUIDDictionary(values[i],
+ curr_module_spec)) {
+ if (module_spec.GetArchitecture().IsCompatibleMatch(
+ curr_module_spec.GetArchitecture())) {
+ module_spec = curr_module_spec;
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (log) {
+ if (!uuid_str.empty())
+ log->Printf("Called %s on %s, no matches",
+ g_dsym_for_uuid_exe_path, uuid_str.c_str());
+ else if (file_path[0] != '\0')
+ log->Printf("Called %s on %s, no matches",
+ g_dsym_for_uuid_exe_path, file_path);
+ }
+ }
+ }
+ }
+ }
+ return success;
+}
diff --git a/source/Symbol/ObjectFile.cpp b/source/Symbol/ObjectFile.cpp
index 86c18c7beb0b6..172d2b3f01e32 100644
--- a/source/Symbol/ObjectFile.cpp
+++ b/source/Symbol/ObjectFile.cpp
@@ -1,9 +1,8 @@
//===-- ObjectFile.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -57,13 +56,13 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
PluginManager::GetObjectContainerCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<ObjectContainer> object_container_ap(
+ std::unique_ptr<ObjectContainer> object_container_up(
create_object_container_callback(module_sp, data_sp,
data_offset, file, file_offset,
file_size));
- if (object_container_ap.get())
- object_file_sp = object_container_ap->GetObjectFile(file);
+ if (object_container_up)
+ object_file_sp = object_container_up->GetObjectFile(file);
if (object_file_sp.get())
return object_file_sp;
@@ -106,13 +105,13 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
PluginManager::GetObjectContainerCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<ObjectContainer> object_container_ap(
+ std::unique_ptr<ObjectContainer> object_container_up(
create_object_container_callback(module_sp, data_sp,
data_offset, file,
file_offset, file_size));
- if (object_container_ap.get())
- object_file_sp = object_container_ap->GetObjectFile(file);
+ if (object_container_up)
+ object_file_sp = object_container_up->GetObjectFile(file);
if (object_file_sp.get())
return object_file_sp;
@@ -148,12 +147,12 @@ ObjectFile::FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file,
PluginManager::GetObjectContainerCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<ObjectContainer> object_container_ap(
+ std::unique_ptr<ObjectContainer> object_container_up(
create_object_container_callback(module_sp, data_sp, data_offset,
file, file_offset, file_size));
- if (object_container_ap.get())
- object_file_sp = object_container_ap->GetObjectFile(file);
+ if (object_container_up)
+ object_file_sp = object_container_up->GetObjectFile(file);
if (object_file_sp.get())
return object_file_sp;
@@ -264,9 +263,8 @@ ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
: ModuleChild(module_sp),
m_file(), // This file could be different from the original module's file
m_type(eTypeInvalid), m_strata(eStrataInvalid),
- m_file_offset(file_offset), m_length(length), m_data(),
- m_unwind_table(*this), m_process_wp(),
- m_memory_addr(LLDB_INVALID_ADDRESS), m_sections_ap(), m_symtab_ap(),
+ m_file_offset(file_offset), m_length(length), m_data(), m_process_wp(),
+ m_memory_addr(LLDB_INVALID_ADDRESS), m_sections_up(), m_symtab_up(),
m_synthetic_symbol_idx(0) {
if (file_spec_ptr)
m_file = *file_spec_ptr;
@@ -287,9 +285,8 @@ ObjectFile::ObjectFile(const lldb::ModuleSP &module_sp,
DataBufferSP &header_data_sp)
: ModuleChild(module_sp), m_file(), m_type(eTypeInvalid),
m_strata(eStrataInvalid), m_file_offset(0), m_length(0), m_data(),
- m_unwind_table(*this), m_process_wp(process_sp),
- m_memory_addr(header_addr), m_sections_ap(), m_symtab_ap(),
- m_synthetic_symbol_idx(0) {
+ m_process_wp(process_sp), m_memory_addr(header_addr), m_sections_up(),
+ m_symtab_up(), m_synthetic_symbol_idx(0) {
if (header_data_sp)
m_data.SetData(header_data_sp, 0, header_data_sp->GetByteSize());
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
@@ -368,6 +365,7 @@ AddressClass ObjectFile::GetAddressClass(addr_t file_addr) {
case eSectionTypeDWARFDebugStrOffsets:
case eSectionTypeDWARFDebugStrOffsetsDwo:
case eSectionTypeDWARFDebugTypes:
+ case eSectionTypeDWARFDebugTypesDwo:
case eSectionTypeDWARFAppleNames:
case eSectionTypeDWARFAppleTypes:
case eSectionTypeDWARFAppleNamespaces:
@@ -464,12 +462,12 @@ DataBufferSP ObjectFile::ReadMemory(const ProcessSP &process_sp,
lldb::addr_t addr, size_t byte_size) {
DataBufferSP data_sp;
if (process_sp) {
- std::unique_ptr<DataBufferHeap> data_ap(new DataBufferHeap(byte_size, 0));
+ std::unique_ptr<DataBufferHeap> data_up(new DataBufferHeap(byte_size, 0));
Status error;
const size_t bytes_read = process_sp->ReadMemory(
- addr, data_ap->GetBytes(), data_ap->GetByteSize(), error);
+ addr, data_up->GetBytes(), data_up->GetByteSize(), error);
if (bytes_read == byte_size)
- data_sp.reset(data_ap.release());
+ data_sp.reset(data_up.release());
}
return data_sp;
}
@@ -536,9 +534,7 @@ size_t ObjectFile::ReadSectionData(Section *section,
return 0;
}
-//----------------------------------------------------------------------
// Get the section data the file on disk
-//----------------------------------------------------------------------
size_t ObjectFile::ReadSectionData(Section *section,
DataExtractor &section_data) {
// If some other objectfile owns this data, pass this to them.
@@ -602,13 +598,13 @@ void ObjectFile::ClearSymtab() {
if (log)
log->Printf("%p ObjectFile::ClearSymtab () symtab = %p",
static_cast<void *>(this),
- static_cast<void *>(m_symtab_ap.get()));
- m_symtab_ap.reset();
+ static_cast<void *>(m_symtab_up.get()));
+ m_symtab_up.reset();
}
}
SectionList *ObjectFile::GetSectionList(bool update_module_section_list) {
- if (m_sections_ap.get() == nullptr) {
+ if (m_sections_up == nullptr) {
if (update_module_section_list) {
ModuleSP module_sp(GetModule());
if (module_sp) {
@@ -620,7 +616,7 @@ SectionList *ObjectFile::GetSectionList(bool update_module_section_list) {
CreateSections(unified_section_list);
}
}
- return m_sections_ap.get();
+ return m_sections_up.get();
}
lldb::SymbolType
diff --git a/source/Symbol/PostfixExpression.cpp b/source/Symbol/PostfixExpression.cpp
new file mode 100644
index 0000000000000..148653561a4ed
--- /dev/null
+++ b/source/Symbol/PostfixExpression.cpp
@@ -0,0 +1,227 @@
+//===-- PostfixExpression.cpp -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements support for postfix expressions found in several symbol
+// file formats, and their conversion to DWARF.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Symbol/PostfixExpression.h"
+#include "lldb/Core/dwarf.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/ADT/StringExtras.h"
+
+using namespace lldb_private;
+using namespace lldb_private::postfix;
+
+static llvm::Optional<BinaryOpNode::OpType>
+GetBinaryOpType(llvm::StringRef token) {
+ if (token.size() != 1)
+ return llvm::None;
+ switch (token[0]) {
+ case '@':
+ return BinaryOpNode::Align;
+ case '-':
+ return BinaryOpNode::Minus;
+ case '+':
+ return BinaryOpNode::Plus;
+ }
+ return llvm::None;
+}
+
+static llvm::Optional<UnaryOpNode::OpType>
+GetUnaryOpType(llvm::StringRef token) {
+ if (token == "^")
+ return UnaryOpNode::Deref;
+ return llvm::None;
+}
+
+Node *postfix::Parse(llvm::StringRef expr, llvm::BumpPtrAllocator &alloc) {
+ llvm::SmallVector<Node *, 4> stack;
+
+ llvm::StringRef token;
+ while (std::tie(token, expr) = getToken(expr), !token.empty()) {
+ if (auto op_type = GetBinaryOpType(token)) {
+ // token is binary operator
+ if (stack.size() < 2)
+ return nullptr;
+
+ Node *right = stack.pop_back_val();
+ Node *left = stack.pop_back_val();
+ stack.push_back(MakeNode<BinaryOpNode>(alloc, *op_type, *left, *right));
+ continue;
+ }
+
+ if (auto op_type = GetUnaryOpType(token)) {
+ // token is unary operator
+ if (stack.empty())
+ return nullptr;
+
+ Node *operand = stack.pop_back_val();
+ stack.push_back(MakeNode<UnaryOpNode>(alloc, *op_type, *operand));
+ continue;
+ }
+
+ int64_t value;
+ if (to_integer(token, value, 10)) {
+ // token is integer literal
+ stack.push_back(MakeNode<IntegerNode>(alloc, value));
+ continue;
+ }
+
+ stack.push_back(MakeNode<SymbolNode>(alloc, token));
+ }
+
+ if (stack.size() != 1)
+ return nullptr;
+
+ return stack.back();
+}
+
+namespace {
+class SymbolResolver : public Visitor<bool> {
+public:
+ SymbolResolver(llvm::function_ref<Node *(SymbolNode &symbol)> replacer)
+ : m_replacer(replacer) {}
+
+ using Visitor<bool>::Dispatch;
+
+private:
+ bool Visit(BinaryOpNode &binary, Node *&) override {
+ return Dispatch(binary.Left()) && Dispatch(binary.Right());
+ }
+
+ bool Visit(InitialValueNode &, Node *&) override { return true; }
+ bool Visit(IntegerNode &, Node *&) override { return true; }
+ bool Visit(RegisterNode &, Node *&) override { return true; }
+
+ bool Visit(SymbolNode &symbol, Node *&ref) override {
+ if (Node *replacement = m_replacer(symbol)) {
+ ref = replacement;
+ if (replacement != &symbol)
+ return Dispatch(ref);
+ return true;
+ }
+ return false;
+ }
+
+ bool Visit(UnaryOpNode &unary, Node *&) override {
+ return Dispatch(unary.Operand());
+ }
+
+ llvm::function_ref<Node *(SymbolNode &symbol)> m_replacer;
+};
+
+class DWARFCodegen : public Visitor<> {
+public:
+ DWARFCodegen(Stream &stream) : m_out_stream(stream) {}
+
+ using Visitor<>::Dispatch;
+
+private:
+ void Visit(BinaryOpNode &binary, Node *&) override;
+
+ void Visit(InitialValueNode &val, Node *&) override;
+
+ void Visit(IntegerNode &integer, Node *&) override {
+ m_out_stream.PutHex8(DW_OP_consts);
+ m_out_stream.PutSLEB128(integer.GetValue());
+ ++m_stack_depth;
+ }
+
+ void Visit(RegisterNode &reg, Node *&) override;
+
+ void Visit(SymbolNode &symbol, Node *&) override {
+ llvm_unreachable("Symbols should have been resolved by now!");
+ }
+
+ void Visit(UnaryOpNode &unary, Node *&) override;
+
+ Stream &m_out_stream;
+
+ /// The number keeping track of the evaluation stack depth at any given
+ /// moment. Used for implementing InitialValueNodes. We start with
+ /// m_stack_depth = 1, assuming that the initial value is already on the
+ /// stack. This initial value will be the value of all InitialValueNodes. If
+ /// the expression does not contain InitialValueNodes, then m_stack_depth is
+ /// not used, and the generated expression will run correctly even without an
+ /// initial value.
+ size_t m_stack_depth = 1;
+};
+} // namespace
+
+void DWARFCodegen::Visit(BinaryOpNode &binary, Node *&) {
+ Dispatch(binary.Left());
+ Dispatch(binary.Right());
+
+ switch (binary.GetOpType()) {
+ case BinaryOpNode::Plus:
+ m_out_stream.PutHex8(DW_OP_plus);
+ // NOTE: can be optimized by using DW_OP_plus_uconst opcpode
+ // if right child node is constant value
+ break;
+ case BinaryOpNode::Minus:
+ m_out_stream.PutHex8(DW_OP_minus);
+ break;
+ case BinaryOpNode::Align:
+ // emit align operator a @ b as
+ // a & ~(b - 1)
+ // NOTE: implicitly assuming that b is power of 2
+ m_out_stream.PutHex8(DW_OP_lit1);
+ m_out_stream.PutHex8(DW_OP_minus);
+ m_out_stream.PutHex8(DW_OP_not);
+
+ m_out_stream.PutHex8(DW_OP_and);
+ break;
+ }
+ --m_stack_depth; // Two pops, one push.
+}
+
+void DWARFCodegen::Visit(InitialValueNode &, Node *&) {
+ // We never go below the initial stack, so we can pick the initial value from
+ // the bottom of the stack at any moment.
+ assert(m_stack_depth >= 1);
+ m_out_stream.PutHex8(DW_OP_pick);
+ m_out_stream.PutHex8(m_stack_depth - 1);
+ ++m_stack_depth;
+}
+
+void DWARFCodegen::Visit(RegisterNode &reg, Node *&) {
+ uint32_t reg_num = reg.GetRegNum();
+ assert(reg_num != LLDB_INVALID_REGNUM);
+
+ if (reg_num > 31) {
+ m_out_stream.PutHex8(DW_OP_bregx);
+ m_out_stream.PutULEB128(reg_num);
+ } else
+ m_out_stream.PutHex8(DW_OP_breg0 + reg_num);
+
+ m_out_stream.PutSLEB128(0);
+ ++m_stack_depth;
+}
+
+void DWARFCodegen::Visit(UnaryOpNode &unary, Node *&) {
+ Dispatch(unary.Operand());
+
+ switch (unary.GetOpType()) {
+ case UnaryOpNode::Deref:
+ m_out_stream.PutHex8(DW_OP_deref);
+ break;
+ }
+ // Stack depth unchanged.
+}
+
+bool postfix::ResolveSymbols(
+ Node *&node, llvm::function_ref<Node *(SymbolNode &)> replacer) {
+ return SymbolResolver(replacer).Dispatch(node);
+}
+
+void postfix::ToDWARF(Node &node, Stream &stream) {
+ Node *ptr = &node;
+ DWARFCodegen(stream).Dispatch(ptr);
+}
diff --git a/source/Symbol/Symbol.cpp b/source/Symbol/Symbol.cpp
index 8d055c1c6712b..589f69244a480 100644
--- a/source/Symbol/Symbol.cpp
+++ b/source/Symbol/Symbol.cpp
@@ -1,9 +1,8 @@
//===-- Symbol.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,7 +28,8 @@ Symbol::Symbol()
m_is_external(false), m_size_is_sibling(false),
m_size_is_synthesized(false), m_size_is_valid(false),
m_demangled_is_synthesized(false), m_contains_linker_annotations(false),
- m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(), m_flags() {}
+ m_is_weak(false), m_type(eSymbolTypeInvalid), m_mangled(), m_addr_range(),
+ m_flags() {}
Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
SymbolType type, bool external, bool is_debug,
@@ -42,7 +42,8 @@ Symbol::Symbol(uint32_t symID, const char *name, bool name_is_mangled,
m_is_debug(is_debug), m_is_external(external), m_size_is_sibling(false),
m_size_is_synthesized(false), m_size_is_valid(size_is_valid || size > 0),
m_demangled_is_synthesized(false),
- m_contains_linker_annotations(contains_linker_annotations), m_type(type),
+ m_contains_linker_annotations(contains_linker_annotations),
+ m_is_weak(false), m_type(type),
m_mangled(ConstString(name), name_is_mangled),
m_addr_range(section_sp, offset, size), m_flags(flags) {}
@@ -57,8 +58,9 @@ Symbol::Symbol(uint32_t symID, const Mangled &mangled, SymbolType type,
m_size_is_synthesized(false),
m_size_is_valid(size_is_valid || range.GetByteSize() > 0),
m_demangled_is_synthesized(false),
- m_contains_linker_annotations(contains_linker_annotations), m_type(type),
- m_mangled(mangled), m_addr_range(range), m_flags(flags) {}
+ m_contains_linker_annotations(contains_linker_annotations),
+ m_is_weak(false), m_type(type), m_mangled(mangled), m_addr_range(range),
+ m_flags(flags) {}
Symbol::Symbol(const Symbol &rhs)
: SymbolContextScope(rhs), m_uid(rhs.m_uid), m_type_data(rhs.m_type_data),
@@ -69,7 +71,7 @@ Symbol::Symbol(const Symbol &rhs)
m_size_is_valid(rhs.m_size_is_valid),
m_demangled_is_synthesized(rhs.m_demangled_is_synthesized),
m_contains_linker_annotations(rhs.m_contains_linker_annotations),
- m_type(rhs.m_type), m_mangled(rhs.m_mangled),
+ m_is_weak(rhs.m_is_weak), m_type(rhs.m_type), m_mangled(rhs.m_mangled),
m_addr_range(rhs.m_addr_range), m_flags(rhs.m_flags) {}
const Symbol &Symbol::operator=(const Symbol &rhs) {
@@ -86,6 +88,7 @@ const Symbol &Symbol::operator=(const Symbol &rhs) {
m_size_is_valid = rhs.m_size_is_valid;
m_demangled_is_synthesized = rhs.m_demangled_is_synthesized;
m_contains_linker_annotations = rhs.m_contains_linker_annotations;
+ m_is_weak = rhs.m_is_weak;
m_type = rhs.m_type;
m_mangled = rhs.m_mangled;
m_addr_range = rhs.m_addr_range;
@@ -107,6 +110,7 @@ void Symbol::Clear() {
m_size_is_valid = false;
m_demangled_is_synthesized = false;
m_contains_linker_annotations = false;
+ m_is_weak = false;
m_type = eSymbolTypeInvalid;
m_flags = 0;
m_addr_range.Clear();
@@ -146,7 +150,7 @@ FileSpec Symbol::GetReExportedSymbolSharedLibrary() const {
return FileSpec();
}
-void Symbol::SetReExportedSymbolName(const ConstString &name) {
+void Symbol::SetReExportedSymbolName(ConstString name) {
SetType(eSymbolTypeReExported);
// For eSymbolTypeReExported, the "const char *" from a ConstString is used
// as the offset in the address range base address.
@@ -326,7 +330,7 @@ uint32_t Symbol::GetPrologueByteSize() {
return 0;
}
-bool Symbol::Compare(const ConstString &name, SymbolType type) const {
+bool Symbol::Compare(ConstString name, SymbolType type) const {
if (type == eSymbolTypeAny || m_type == type)
return m_mangled.GetMangledName() == name ||
m_mangled.GetDemangledName(GetLanguage()) == name;
diff --git a/source/Symbol/SymbolContext.cpp b/source/Symbol/SymbolContext.cpp
index da00875bfa151..a0b35cf3d0b99 100644
--- a/source/Symbol/SymbolContext.cpp
+++ b/source/Symbol/SymbolContext.cpp
@@ -1,9 +1,8 @@
//===-- SymbolContext.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -48,11 +47,6 @@ SymbolContext::SymbolContext(const TargetSP &t, const ModuleSP &m,
line_entry = *le;
}
-SymbolContext::SymbolContext(const SymbolContext &rhs)
- : target_sp(rhs.target_sp), module_sp(rhs.module_sp),
- comp_unit(rhs.comp_unit), function(rhs.function), block(rhs.block),
- line_entry(rhs.line_entry), symbol(rhs.symbol), variable(rhs.variable) {}
-
SymbolContext::SymbolContext(SymbolContextScope *sc_scope)
: target_sp(), module_sp(), comp_unit(nullptr), function(nullptr),
block(nullptr), line_entry(), symbol(nullptr), variable(nullptr) {
@@ -507,7 +501,7 @@ bool SymbolContext::GetParentOfInlinedScope(const Address &curr_frame_pc,
}
#ifdef LLDB_CONFIGURATION_DEBUG
else {
- ObjectFile *objfile = NULL;
+ ObjectFile *objfile = nullptr;
if (module_sp) {
SymbolVendor *symbol_vendor = module_sp->GetSymbolVendor();
if (symbol_vendor) {
@@ -587,10 +581,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
curr_block->GetContainingInlinedBlock() != nullptr)
isInlinedblock = true;
- //----------------------------------------------------------------------
// Find all types that match the current block if we have one and put them
// first in the list. Keep iterating up through all blocks.
- //----------------------------------------------------------------------
while (curr_block != nullptr && !isInlinedblock) {
type_map.ForEach(
[curr_block, &type_list](const lldb::TypeSP &type_sp) -> bool {
@@ -608,10 +600,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
});
curr_block = curr_block->GetParent();
}
- //----------------------------------------------------------------------
// Find all types that match the current function, if we have onem, and put
// them next in the list.
- //----------------------------------------------------------------------
if (function != nullptr && !type_map.Empty()) {
const size_t old_type_list_size = type_list.GetSize();
type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
@@ -629,10 +619,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- //----------------------------------------------------------------------
// Find all types that match the current compile unit, if we have one, and
// put them next in the list.
- //----------------------------------------------------------------------
if (comp_unit != nullptr && !type_map.Empty()) {
const size_t old_type_list_size = type_list.GetSize();
@@ -651,10 +639,8 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- //----------------------------------------------------------------------
// Find all types that match the current module, if we have one, and put them
// next in the list.
- //----------------------------------------------------------------------
if (module_sp && !type_map.Empty()) {
const size_t old_type_list_size = type_list.GetSize();
type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
@@ -671,9 +657,7 @@ void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
type_map.Remove(type_list.GetTypeAtIndex(i));
}
}
- //----------------------------------------------------------------------
// Any types that are left get copied into the list an any order.
- //----------------------------------------------------------------------
if (!type_map.Empty()) {
type_map.ForEach([&type_list](const lldb::TypeSP &type_sp) -> bool {
type_list.Insert(type_sp);
@@ -745,7 +729,7 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
uint32_t line_index = 0;
bool found = false;
- while (1) {
+ while (true) {
LineEntry this_line;
line_index = comp_unit->FindLineEntry(line_index, line_entry.line, nullptr,
false, &this_line);
@@ -794,7 +778,7 @@ bool SymbolContext::GetAddressRangeFromHereToEndLine(uint32_t end_line,
}
const Symbol *
-SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error) {
+SymbolContext::FindBestGlobalDataSymbol(ConstString name, Status &error) {
error.Clear();
if (!target_sp) {
@@ -950,16 +934,14 @@ SymbolContext::FindBestGlobalDataSymbol(const ConstString &name, Status &error)
}
-//----------------------------------------------------------------------
//
// SymbolContextSpecifier
//
-//----------------------------------------------------------------------
SymbolContextSpecifier::SymbolContextSpecifier(const TargetSP &target_sp)
- : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_ap(),
+ : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_up(),
m_start_line(0), m_end_line(0), m_function_spec(), m_class_name(),
- m_address_range_ap(), m_type(eNothingSpecified) {}
+ m_address_range_up(), m_type(eNothingSpecified) {}
SymbolContextSpecifier::~SymbolContextSpecifier() {}
@@ -1008,7 +990,7 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
// CompUnits can't necessarily be resolved here, since an inlined function
// might show up in a number of CompUnits. Instead we just convert to a
// FileSpec and store it away.
- m_file_spec_ap.reset(new FileSpec(spec_string));
+ m_file_spec_up.reset(new FileSpec(spec_string));
m_type |= eFileSpecified;
break;
case eLineStartSpecified:
@@ -1040,12 +1022,12 @@ bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
void SymbolContextSpecifier::Clear() {
m_module_spec.clear();
- m_file_spec_ap.reset();
+ m_file_spec_up.reset();
m_function_spec.clear();
m_class_name.clear();
m_start_line = 0;
m_end_line = 0;
- m_address_range_ap.reset();
+ m_address_range_up.reset();
m_type = eNothingSpecified;
}
@@ -1071,7 +1053,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
}
}
if (m_type & eFileSpecified) {
- if (m_file_spec_ap.get()) {
+ if (m_file_spec_up) {
// If we don't have a block or a comp_unit, then we aren't going to match
// a source file.
if (sc.block == nullptr && sc.comp_unit == nullptr)
@@ -1085,7 +1067,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
if (inline_info != nullptr) {
was_inlined = true;
if (!FileSpec::Equal(inline_info->GetDeclaration().GetFile(),
- *(m_file_spec_ap.get()), false))
+ *(m_file_spec_up.get()), false))
return false;
}
}
@@ -1093,7 +1075,7 @@ bool SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) {
// Next check the comp unit, but only if the SymbolContext was not
// inlined.
if (!was_inlined && sc.comp_unit != nullptr) {
- if (!FileSpec::Equal(*(sc.comp_unit), *(m_file_spec_ap.get()), false))
+ if (!FileSpec::Equal(*(sc.comp_unit), *(m_file_spec_up.get()), false))
return false;
}
}
@@ -1166,8 +1148,8 @@ void SymbolContextSpecifier::GetDescription(
s->Printf("Module: %s\n", m_module_spec.c_str());
}
- if (m_type == eFileSpecified && m_file_spec_ap.get() != nullptr) {
- m_file_spec_ap->GetPath(path_str, PATH_MAX);
+ if (m_type == eFileSpecified && m_file_spec_up != nullptr) {
+ m_file_spec_up->GetPath(path_str, PATH_MAX);
s->Indent();
s->Printf("File: %s", path_str);
if (m_type == eLineStartSpecified) {
@@ -1204,21 +1186,19 @@ void SymbolContextSpecifier::GetDescription(
s->Printf("Class name: %s.\n", m_class_name.c_str());
}
- if (m_type == eAddressRangeSpecified && m_address_range_ap.get() != nullptr) {
+ if (m_type == eAddressRangeSpecified && m_address_range_up != nullptr) {
s->Indent();
s->PutCString("Address range: ");
- m_address_range_ap->Dump(s, m_target_sp.get(),
+ m_address_range_up->Dump(s, m_target_sp.get(),
Address::DumpStyleLoadAddress,
Address::DumpStyleFileAddress);
s->PutCString("\n");
}
}
-//----------------------------------------------------------------------
//
// SymbolContextList
//
-//----------------------------------------------------------------------
SymbolContextList::SymbolContextList() : m_symbol_contexts() {}
diff --git a/source/Symbol/SymbolFile.cpp b/source/Symbol/SymbolFile.cpp
index 6087374969fb7..77ab2223ec07f 100644
--- a/source/Symbol/SymbolFile.cpp
+++ b/source/Symbol/SymbolFile.cpp
@@ -1,9 +1,8 @@
//===-- SymbolFile.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,7 +31,7 @@ std::recursive_mutex &SymbolFile::GetModuleMutex() const {
}
SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
- std::unique_ptr<SymbolFile> best_symfile_ap;
+ std::unique_ptr<SymbolFile> best_symfile_up;
if (obj_file != nullptr) {
// We need to test the abilities of this section list. So create what it
@@ -58,13 +57,13 @@ SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
(create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file));
+ std::unique_ptr<SymbolFile> curr_symfile_up(create_callback(obj_file));
- if (curr_symfile_ap.get()) {
- const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
+ if (curr_symfile_up) {
+ const uint32_t sym_file_abilities = curr_symfile_up->GetAbilities();
if (sym_file_abilities > best_symfile_abilities) {
best_symfile_abilities = sym_file_abilities;
- best_symfile_ap.reset(curr_symfile_ap.release());
+ best_symfile_up.reset(curr_symfile_up.release());
// If any symbol file parser has all of the abilities, then we should
// just stop looking.
if ((kAllAbilities & sym_file_abilities) == kAllAbilities)
@@ -72,13 +71,13 @@ SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
}
}
}
- if (best_symfile_ap.get()) {
+ if (best_symfile_up) {
// Let the winning symbol file parser initialize itself more completely
// now that it has been chosen
- best_symfile_ap->InitializeObject();
+ best_symfile_up->InitializeObject();
}
}
- return best_symfile_ap.release();
+ return best_symfile_up.release();
}
TypeList *SymbolFile::GetTypeList() {
@@ -103,7 +102,7 @@ uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
}
uint32_t
-SymbolFile::FindGlobalVariables(const ConstString &name,
+SymbolFile::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, VariableList &variables) {
return 0;
@@ -115,7 +114,7 @@ uint32_t SymbolFile::FindGlobalVariables(const RegularExpression &regex,
return 0;
}
-uint32_t SymbolFile::FindFunctions(const ConstString &name,
+uint32_t SymbolFile::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -140,7 +139,7 @@ void SymbolFile::GetMangledNamesForFunction(
}
uint32_t SymbolFile::FindTypes(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
@@ -169,3 +168,5 @@ void SymbolFile::AssertModuleLock() {
"Module is not locked");
#endif
}
+
+SymbolFile::RegisterInfoResolver::~RegisterInfoResolver() = default;
diff --git a/source/Symbol/SymbolVendor.cpp b/source/Symbol/SymbolVendor.cpp
index a9badc15a5d60..b9f3a5fe3926c 100644
--- a/source/Symbol/SymbolVendor.cpp
+++ b/source/Symbol/SymbolVendor.cpp
@@ -1,9 +1,8 @@
//===-- SymbolVendor.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,61 +18,60 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// FindPlugin
//
// Platforms can register a callback to use when creating symbol vendors to
// allow for complex debug information file setups, and to also allow for
// finding separate debug information files.
-//----------------------------------------------------------------------
SymbolVendor *SymbolVendor::FindPlugin(const lldb::ModuleSP &module_sp,
lldb_private::Stream *feedback_strm) {
- std::unique_ptr<SymbolVendor> instance_ap;
+ std::unique_ptr<SymbolVendor> instance_up;
SymbolVendorCreateInstance create_callback;
for (size_t idx = 0;
(create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- instance_ap.reset(create_callback(module_sp, feedback_strm));
+ instance_up.reset(create_callback(module_sp, feedback_strm));
- if (instance_ap.get()) {
- return instance_ap.release();
+ if (instance_up) {
+ return instance_up.release();
}
}
// The default implementation just tries to create debug information using
// the file representation for the module.
- instance_ap.reset(new SymbolVendor(module_sp));
- if (instance_ap.get()) {
- ObjectFile *objfile = module_sp->GetObjectFile();
- if (objfile)
- instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this());
+ ObjectFileSP sym_objfile_sp;
+ FileSpec sym_spec = module_sp->GetSymbolFileFileSpec();
+ if (sym_spec && sym_spec != module_sp->GetObjectFile()->GetFileSpec()) {
+ DataBufferSP data_sp;
+ offset_t data_offset = 0;
+ sym_objfile_sp = ObjectFile::FindPlugin(
+ module_sp, &sym_spec, 0, FileSystem::Instance().GetByteSize(sym_spec),
+ data_sp, data_offset);
}
- return instance_ap.release();
+ if (!sym_objfile_sp)
+ sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();
+ instance_up.reset(new SymbolVendor(module_sp));
+ instance_up->AddSymbolFileRepresentation(sym_objfile_sp);
+ return instance_up.release();
}
-//----------------------------------------------------------------------
// SymbolVendor constructor
-//----------------------------------------------------------------------
SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp)
- : ModuleChild(module_sp), m_type_list(), m_compile_units(),
- m_sym_file_ap(), m_symtab() {}
+ : ModuleChild(module_sp), m_type_list(), m_compile_units(), m_sym_file_up(),
+ m_symtab() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
SymbolVendor::~SymbolVendor() {}
-//----------------------------------------------------------------------
// Add a representation given an object file.
-//----------------------------------------------------------------------
void SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (objfile_sp) {
m_objfile_sp = objfile_sp;
- m_sym_file_ap.reset(SymbolFile::FindPlugin(objfile_sp.get()));
+ m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp.get()));
}
}
}
@@ -106,12 +104,12 @@ size_t SymbolVendor::GetNumCompileUnits() {
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_compile_units.empty()) {
- if (m_sym_file_ap.get()) {
+ if (m_sym_file_up) {
// Resize our array of compile unit shared pointers -- which will each
// remain NULL until someone asks for the actual compile unit
// information. When this happens, the symbol file will be asked to
// parse this compile unit information.
- m_compile_units.resize(m_sym_file_ap->GetNumCompileUnits());
+ m_compile_units.resize(m_sym_file_up->GetNumCompileUnits());
}
}
}
@@ -122,8 +120,8 @@ lldb::LanguageType SymbolVendor::ParseLanguage(CompileUnit &comp_unit) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseLanguage(comp_unit);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseLanguage(comp_unit);
}
return eLanguageTypeUnknown;
}
@@ -132,8 +130,8 @@ size_t SymbolVendor::ParseFunctions(CompileUnit &comp_unit) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseFunctions(comp_unit);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseFunctions(comp_unit);
}
return 0;
}
@@ -142,8 +140,8 @@ bool SymbolVendor::ParseLineTable(CompileUnit &comp_unit) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseLineTable(comp_unit);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseLineTable(comp_unit);
}
return false;
}
@@ -152,8 +150,8 @@ bool SymbolVendor::ParseDebugMacros(CompileUnit &comp_unit) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseDebugMacros(comp_unit);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseDebugMacros(comp_unit);
}
return false;
}
@@ -162,8 +160,8 @@ bool SymbolVendor::ParseSupportFiles(CompileUnit &comp_unit,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseSupportFiles(comp_unit, support_files);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseSupportFiles(comp_unit, support_files);
}
return false;
}
@@ -172,19 +170,19 @@ bool SymbolVendor::ParseIsOptimized(CompileUnit &comp_unit) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseIsOptimized(comp_unit);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseIsOptimized(comp_unit);
}
return false;
}
bool SymbolVendor::ParseImportedModules(
- const SymbolContext &sc, std::vector<ConstString> &imported_modules) {
+ const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseImportedModules(sc, imported_modules);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseImportedModules(sc, imported_modules);
}
return false;
}
@@ -193,8 +191,8 @@ size_t SymbolVendor::ParseBlocksRecursive(Function &func) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseBlocksRecursive(func);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseBlocksRecursive(func);
}
return 0;
}
@@ -203,8 +201,8 @@ size_t SymbolVendor::ParseTypes(CompileUnit &comp_unit) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseTypes(comp_unit);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseTypes(comp_unit);
}
return 0;
}
@@ -213,8 +211,8 @@ size_t SymbolVendor::ParseVariablesForContext(const SymbolContext &sc) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ParseVariablesForContext(sc);
+ if (m_sym_file_up)
+ return m_sym_file_up->ParseVariablesForContext(sc);
}
return 0;
}
@@ -223,8 +221,8 @@ Type *SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ResolveTypeUID(type_uid);
+ if (m_sym_file_up)
+ return m_sym_file_up->ResolveTypeUID(type_uid);
}
return nullptr;
}
@@ -235,8 +233,8 @@ uint32_t SymbolVendor::ResolveSymbolContext(const Address &so_addr,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc);
+ if (m_sym_file_up)
+ return m_sym_file_up->ResolveSymbolContext(so_addr, resolve_scope, sc);
}
return 0;
}
@@ -248,22 +246,22 @@ uint32_t SymbolVendor::ResolveSymbolContext(const FileSpec &file_spec,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines,
+ if (m_sym_file_up)
+ return m_sym_file_up->ResolveSymbolContext(file_spec, line, check_inlines,
resolve_scope, sc_list);
}
return 0;
}
size_t
-SymbolVendor::FindGlobalVariables(const ConstString &name,
+SymbolVendor::FindGlobalVariables(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, VariableList &variables) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->FindGlobalVariables(name, parent_decl_ctx,
+ if (m_sym_file_up)
+ return m_sym_file_up->FindGlobalVariables(name, parent_decl_ctx,
max_matches, variables);
}
return 0;
@@ -275,13 +273,13 @@ size_t SymbolVendor::FindGlobalVariables(const RegularExpression &regex,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->FindGlobalVariables(regex, max_matches, variables);
+ if (m_sym_file_up)
+ return m_sym_file_up->FindGlobalVariables(regex, max_matches, variables);
}
return 0;
}
-size_t SymbolVendor::FindFunctions(const ConstString &name,
+size_t SymbolVendor::FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
FunctionNameType name_type_mask,
bool include_inlines, bool append,
@@ -289,8 +287,8 @@ size_t SymbolVendor::FindFunctions(const ConstString &name,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->FindFunctions(name, parent_decl_ctx, name_type_mask,
+ if (m_sym_file_up)
+ return m_sym_file_up->FindFunctions(name, parent_decl_ctx, name_type_mask,
include_inlines, append, sc_list);
}
return 0;
@@ -302,23 +300,23 @@ size_t SymbolVendor::FindFunctions(const RegularExpression &regex,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->FindFunctions(regex, include_inlines, append,
+ if (m_sym_file_up)
+ return m_sym_file_up->FindFunctions(regex, include_inlines, append,
sc_list);
}
return 0;
}
size_t SymbolVendor::FindTypes(
- const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
+ ConstString name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->FindTypes(name, parent_decl_ctx, append,
+ if (m_sym_file_up)
+ return m_sym_file_up->FindTypes(name, parent_decl_ctx, append,
max_matches, searched_symbol_files,
types);
}
@@ -332,8 +330,8 @@ size_t SymbolVendor::FindTypes(const std::vector<CompilerContext> &context,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->FindTypes(context, append, types);
+ if (m_sym_file_up)
+ return m_sym_file_up->FindTypes(context, append, types);
}
if (!append)
types.Clear();
@@ -345,21 +343,21 @@ size_t SymbolVendor::GetTypes(SymbolContextScope *sc_scope, TypeClass type_mask,
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- return m_sym_file_ap->GetTypes(sc_scope, type_mask, type_list);
+ if (m_sym_file_up)
+ return m_sym_file_up->GetTypes(sc_scope, type_mask, type_list);
}
return 0;
}
CompilerDeclContext
-SymbolVendor::FindNamespace(const ConstString &name,
+SymbolVendor::FindNamespace(ConstString name,
const CompilerDeclContext *parent_decl_ctx) {
CompilerDeclContext namespace_decl_ctx;
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
- if (m_sym_file_ap.get())
- namespace_decl_ctx = m_sym_file_ap->FindNamespace(name, parent_decl_ctx);
+ if (m_sym_file_up)
+ namespace_decl_ctx = m_sym_file_up->FindNamespace(name, parent_decl_ctx);
}
return namespace_decl_ctx;
}
@@ -374,9 +372,9 @@ void SymbolVendor::Dump(Stream *s) {
s->Printf("%p: ", static_cast<void *>(this));
s->Indent();
s->PutCString("SymbolVendor");
- if (m_sym_file_ap.get()) {
- *s << " " << m_sym_file_ap->GetPluginName();
- ObjectFile *objfile = m_sym_file_ap->GetObjectFile();
+ if (m_sym_file_up) {
+ *s << " " << m_sym_file_up->GetPluginName();
+ ObjectFile *objfile = m_sym_file_up->GetObjectFile();
if (objfile) {
const FileSpec &objfile_file_spec = objfile->GetFileSpec();
if (objfile_file_spec) {
@@ -387,8 +385,8 @@ void SymbolVendor::Dump(Stream *s) {
}
}
s->EOL();
- if (m_sym_file_ap)
- m_sym_file_ap->Dump(*s);
+ if (m_sym_file_up)
+ m_sym_file_up->Dump(*s);
s->IndentMore();
m_type_list.Dump(s, show_context);
@@ -396,7 +394,7 @@ void SymbolVendor::Dump(Stream *s) {
cu_end = m_compile_units.end();
for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos) {
// We currently only dump the compile units that have been parsed
- if (cu_pos->get())
+ if (*cu_pos)
(*cu_pos)->Dump(s, show_context);
}
@@ -416,7 +414,7 @@ CompUnitSP SymbolVendor::GetCompileUnitAtIndex(size_t idx) {
if (idx < num_compile_units) {
cu_sp = m_compile_units[idx];
if (cu_sp.get() == nullptr) {
- m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx);
+ m_compile_units[idx] = m_sym_file_up->ParseCompileUnitAtIndex(idx);
cu_sp = m_compile_units[idx];
}
}
@@ -425,8 +423,8 @@ CompUnitSP SymbolVendor::GetCompileUnitAtIndex(size_t idx) {
}
FileSpec SymbolVendor::GetMainFileSpec() const {
- if (m_sym_file_ap.get()) {
- const ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile();
+ if (m_sym_file_up) {
+ const ObjectFile *symfile_objfile = m_sym_file_up->GetObjectFile();
if (symfile_objfile)
return symfile_objfile->GetFileSpec();
}
@@ -449,8 +447,8 @@ Symtab *SymbolVendor::GetSymtab() {
return nullptr;
m_symtab = objfile->GetSymtab();
- if (m_symtab && m_sym_file_ap)
- m_sym_file_ap->AddSymbols(*m_symtab);
+ if (m_symtab && m_sym_file_up)
+ m_sym_file_up->AddSymbols(*m_symtab);
return m_symtab;
}
@@ -470,8 +468,8 @@ void SymbolVendor::SectionFileAddressesChanged() {
ModuleSP module_sp(GetModule());
if (module_sp) {
ObjectFile *module_objfile = module_sp->GetObjectFile();
- if (m_sym_file_ap.get()) {
- ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile();
+ if (m_sym_file_up) {
+ ObjectFile *symfile_objfile = m_sym_file_up->GetObjectFile();
if (symfile_objfile != module_objfile)
symfile_objfile->SectionFileAddressesChanged();
}
@@ -482,9 +480,7 @@ void SymbolVendor::SectionFileAddressesChanged() {
}
}
-//------------------------------------------------------------------
// PluginInterface protocol
-//------------------------------------------------------------------
lldb_private::ConstString SymbolVendor::GetPluginName() {
static ConstString g_name("vendor-default");
return g_name;
diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp
index 2472580a41d56..29c390e838781 100644
--- a/source/Symbol/Symtab.cpp
+++ b/source/Symbol/Symtab.cpp
@@ -1,9 +1,8 @@
//===-- Symtab.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -217,9 +216,6 @@ const Symbol *Symtab::SymbolAtIndex(size_t idx) const {
return nullptr;
}
-//----------------------------------------------------------------------
-// InitNameIndexes
-//----------------------------------------------------------------------
static bool lldb_skip_name(llvm::StringRef mangled,
Mangled::ManglingScheme scheme) {
switch (scheme) {
@@ -262,25 +258,7 @@ void Symtab::InitNameIndexes() {
Timer scoped_timer(func_cat, "%s", LLVM_PRETTY_FUNCTION);
// Create the name index vector to be able to quickly search by name
const size_t num_symbols = m_symbols.size();
-#if 1
m_name_to_index.Reserve(num_symbols);
-#else
- // TODO: benchmark this to see if we save any memory. Otherwise we
- // will always keep the memory reserved in the vector unless we pull some
- // STL swap magic and then recopy...
- uint32_t actual_count = 0;
- for (const_iterator pos = m_symbols.begin(), end = m_symbols.end();
- pos != end; ++pos) {
- const Mangled &mangled = pos->GetMangled();
- if (mangled.GetMangledName())
- ++actual_count;
-
- if (mangled.GetDemangledName())
- ++actual_count;
- }
-
- m_name_to_index.Reserve(actual_count);
-#endif
// The "const char *" in "class_contexts" and backlog::value_type::second
// must come from a ConstString::GetCString()
@@ -291,10 +269,8 @@ void Symtab::InitNameIndexes() {
// Instantiation of the demangler is expensive, so better use a single one
// for all entries during batch processing.
RichManglingContext rmc;
- NameToIndexMap::Entry entry;
-
- for (entry.value = 0; entry.value < num_symbols; ++entry.value) {
- Symbol *symbol = &m_symbols[entry.value];
+ for (uint32_t value = 0; value < num_symbols; ++value) {
+ Symbol *symbol = &m_symbols[value];
// Don't let trampolines get into the lookup by name map If we ever need
// the trampoline symbols to be searchable by name we can remove this and
@@ -306,52 +282,46 @@ void Symtab::InitNameIndexes() {
// If the symbol's name string matched a Mangled::ManglingScheme, it is
// stored in the mangled field.
Mangled &mangled = symbol->GetMangled();
- entry.cstring = mangled.GetMangledName();
- if (entry.cstring) {
- m_name_to_index.Append(entry);
+ if (ConstString name = mangled.GetMangledName()) {
+ m_name_to_index.Append(name, value);
if (symbol->ContainsLinkerAnnotations()) {
// If the symbol has linker annotations, also add the version without
// the annotations.
- entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations(
- entry.cstring.GetStringRef()));
- m_name_to_index.Append(entry);
+ ConstString stripped = ConstString(
+ m_objfile->StripLinkerSymbolAnnotations(name.GetStringRef()));
+ m_name_to_index.Append(stripped, value);
}
const SymbolType type = symbol->GetType();
if (type == eSymbolTypeCode || type == eSymbolTypeResolver) {
if (mangled.DemangleWithRichManglingInfo(rmc, lldb_skip_name))
- RegisterMangledNameEntry(entry, class_contexts, backlog, rmc);
+ RegisterMangledNameEntry(value, class_contexts, backlog, rmc);
}
}
// Symbol name strings that didn't match a Mangled::ManglingScheme, are
// stored in the demangled field.
- entry.cstring = mangled.GetDemangledName(symbol->GetLanguage());
- if (entry.cstring) {
- m_name_to_index.Append(entry);
+ if (ConstString name = mangled.GetDemangledName(symbol->GetLanguage())) {
+ m_name_to_index.Append(name, value);
if (symbol->ContainsLinkerAnnotations()) {
// If the symbol has linker annotations, also add the version without
// the annotations.
- entry.cstring = ConstString(m_objfile->StripLinkerSymbolAnnotations(
- entry.cstring.GetStringRef()));
- m_name_to_index.Append(entry);
+ name = ConstString(
+ m_objfile->StripLinkerSymbolAnnotations(name.GetStringRef()));
+ m_name_to_index.Append(name, value);
}
- }
- // If the demangled name turns out to be an ObjC name, and is a category
- // name, add the version without categories to the index too.
- ObjCLanguage::MethodName objc_method(entry.cstring.GetStringRef(), true);
- if (objc_method.IsValid(true)) {
- entry.cstring = objc_method.GetSelector();
- m_selector_to_index.Append(entry);
-
- ConstString objc_method_no_category(
- objc_method.GetFullNameWithoutCategory(true));
- if (objc_method_no_category) {
- entry.cstring = objc_method_no_category;
- m_name_to_index.Append(entry);
+ // If the demangled name turns out to be an ObjC name, and is a category
+ // name, add the version without categories to the index too.
+ ObjCLanguage::MethodName objc_method(name.GetStringRef(), true);
+ if (objc_method.IsValid(true)) {
+ m_selector_to_index.Append(objc_method.GetSelector(), value);
+
+ if (ConstString objc_method_no_category =
+ objc_method.GetFullNameWithoutCategory(true))
+ m_name_to_index.Append(objc_method_no_category, value);
}
}
}
@@ -372,7 +342,7 @@ void Symtab::InitNameIndexes() {
}
void Symtab::RegisterMangledNameEntry(
- NameToIndexMap::Entry &entry, std::set<const char *> &class_contexts,
+ uint32_t value, std::set<const char *> &class_contexts,
std::vector<std::pair<NameToIndexMap::Entry, const char *>> &backlog,
RichManglingContext &rmc) {
// Only register functions that have a base name.
@@ -382,7 +352,7 @@ void Symtab::RegisterMangledNameEntry(
return;
// The base name will be our entry's name.
- entry.cstring = ConstString(base_name);
+ NameToIndexMap::Entry entry(ConstString(base_name), value);
rmc.ParseFunctionDeclContextName();
llvm::StringRef decl_context = rmc.GetBufferRef();
@@ -450,24 +420,21 @@ void Symtab::AppendSymbolNamesToMap(const IndexCollection &indexes,
std::lock_guard<std::recursive_mutex> guard(m_mutex);
// Create the name index vector to be able to quickly search by name
- NameToIndexMap::Entry entry;
const size_t num_indexes = indexes.size();
for (size_t i = 0; i < num_indexes; ++i) {
- entry.value = indexes[i];
+ uint32_t value = indexes[i];
assert(i < m_symbols.size());
- const Symbol *symbol = &m_symbols[entry.value];
+ const Symbol *symbol = &m_symbols[value];
const Mangled &mangled = symbol->GetMangled();
if (add_demangled) {
- entry.cstring = mangled.GetDemangledName(symbol->GetLanguage());
- if (entry.cstring)
- name_to_index_map.Append(entry);
+ if (ConstString name = mangled.GetDemangledName(symbol->GetLanguage()))
+ name_to_index_map.Append(name, value);
}
if (add_mangled) {
- entry.cstring = mangled.GetMangledName();
- if (entry.cstring)
- name_to_index_map.Append(entry);
+ if (ConstString name = mangled.GetMangledName())
+ name_to_index_map.Append(name, value);
}
}
}
@@ -626,7 +593,7 @@ void Symtab::SortSymbolIndexesByValue(std::vector<uint32_t> &indexes,
}
}
-uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name,
+uint32_t Symtab::AppendSymbolIndexesWithName(ConstString symbol_name,
std::vector<uint32_t> &indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -641,7 +608,7 @@ uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name,
return 0;
}
-uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name,
+uint32_t Symtab::AppendSymbolIndexesWithName(ConstString symbol_name,
Debug symbol_debug_type,
Visibility symbol_visibility,
std::vector<uint32_t> &indexes) {
@@ -668,7 +635,7 @@ uint32_t Symtab::AppendSymbolIndexesWithName(const ConstString &symbol_name,
}
uint32_t
-Symtab::AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name,
+Symtab::AppendSymbolIndexesWithNameAndType(ConstString symbol_name,
SymbolType symbol_type,
std::vector<uint32_t> &indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -687,7 +654,7 @@ Symtab::AppendSymbolIndexesWithNameAndType(const ConstString &symbol_name,
}
uint32_t Symtab::AppendSymbolIndexesWithNameAndType(
- const ConstString &symbol_name, SymbolType symbol_type,
+ ConstString symbol_name, SymbolType symbol_type,
Debug symbol_debug_type, Visibility symbol_visibility,
std::vector<uint32_t> &indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -772,7 +739,7 @@ Symbol *Symtab::FindSymbolWithType(SymbolType symbol_type,
}
size_t
-Symtab::FindAllSymbolsWithNameAndType(const ConstString &name,
+Symtab::FindAllSymbolsWithNameAndType(ConstString name,
SymbolType symbol_type,
std::vector<uint32_t> &symbol_indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -793,7 +760,7 @@ Symtab::FindAllSymbolsWithNameAndType(const ConstString &name,
}
size_t Symtab::FindAllSymbolsWithNameAndType(
- const ConstString &name, SymbolType symbol_type, Debug symbol_debug_type,
+ ConstString name, SymbolType symbol_type, Debug symbol_debug_type,
Visibility symbol_visibility, std::vector<uint32_t> &symbol_indexes) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -824,7 +791,7 @@ size_t Symtab::FindAllSymbolsMatchingRexExAndType(
return symbol_indexes.size();
}
-Symbol *Symtab::FindFirstSymbolWithNameAndType(const ConstString &name,
+Symbol *Symtab::FindFirstSymbolWithNameAndType(ConstString name,
SymbolType symbol_type,
Debug symbol_debug_type,
Visibility symbol_visibility) {
@@ -929,8 +896,14 @@ void Symtab::InitAddressIndexes() {
for (size_t i = 0; i < num_entries; i++) {
FileRangeToIndexMap::Entry *entry =
m_file_addr_to_index.GetMutableEntryAtIndex(i);
- if (entry->GetByteSize() == 0) {
- addr_t curr_base_addr = entry->GetRangeBase();
+ if (entry->GetByteSize() > 0)
+ continue;
+ addr_t curr_base_addr = entry->GetRangeBase();
+ // Symbols with non-zero size will show after zero-sized symbols on the
+ // same address. So do not set size of a non-last zero-sized symbol.
+ if (i == num_entries - 1 ||
+ m_file_addr_to_index.GetMutableEntryAtIndex(i + 1)
+ ->GetRangeBase() != curr_base_addr) {
const RangeVector<addr_t, addr_t>::Entry *containing_section =
section_ranges.FindEntryThatContains(curr_base_addr);
@@ -1051,7 +1024,7 @@ void Symtab::SymbolIndicesToSymbolContextList(
}
}
-size_t Symtab::FindFunctionSymbols(const ConstString &name,
+size_t Symtab::FindFunctionSymbols(ConstString name,
uint32_t name_type_mask,
SymbolContextList &sc_list) {
size_t count = 0;
@@ -1152,5 +1125,5 @@ const Symbol *Symtab::GetParent(Symbol *child_symbol) const {
return symbol;
}
}
- return NULL;
+ return nullptr;
}
diff --git a/source/Symbol/Type.cpp b/source/Symbol/Type.cpp
index e966c269408a4..4ee8330ce288f 100644
--- a/source/Symbol/Type.cpp
+++ b/source/Symbol/Type.cpp
@@ -1,9 +1,8 @@
//===-- Type.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -108,7 +107,7 @@ Type *SymbolFileType::GetType() {
}
Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file,
- const ConstString &name, uint64_t byte_size,
+ ConstString name, llvm::Optional<uint64_t> byte_size,
SymbolContextScope *context, user_id_t encoding_uid,
EncodingDataType encoding_uid_type, const Declaration &decl,
const CompilerType &compiler_type,
@@ -116,7 +115,14 @@ Type::Type(lldb::user_id_t uid, SymbolFile *symbol_file,
: std::enable_shared_from_this<Type>(), UserID(uid), m_name(name),
m_symbol_file(symbol_file), m_context(context), m_encoding_type(nullptr),
m_encoding_uid(encoding_uid), m_encoding_uid_type(encoding_uid_type),
- m_byte_size(byte_size), m_decl(decl), m_compiler_type(compiler_type) {
+ m_decl(decl), m_compiler_type(compiler_type) {
+ if (byte_size) {
+ m_byte_size = *byte_size;
+ m_byte_size_has_value = true;
+ } else {
+ m_byte_size = 0;
+ m_byte_size_has_value = false;
+ }
m_flags.compiler_type_resolve_state =
(compiler_type ? compiler_type_resolve_state : eResolveStateUnresolved);
m_flags.is_complete_objc_class = false;
@@ -126,32 +132,19 @@ Type::Type()
: std::enable_shared_from_this<Type>(), UserID(0), m_name("<INVALID TYPE>"),
m_symbol_file(nullptr), m_context(nullptr), m_encoding_type(nullptr),
m_encoding_uid(LLDB_INVALID_UID), m_encoding_uid_type(eEncodingInvalid),
- m_byte_size(0), m_decl(), m_compiler_type() {
+ m_byte_size(0), m_byte_size_has_value(false), m_decl(),
+ m_compiler_type() {
m_flags.compiler_type_resolve_state = eResolveStateUnresolved;
m_flags.is_complete_objc_class = false;
}
-Type::Type(const Type &rhs)
- : std::enable_shared_from_this<Type>(rhs), UserID(rhs), m_name(rhs.m_name),
- m_symbol_file(rhs.m_symbol_file), m_context(rhs.m_context),
- m_encoding_type(rhs.m_encoding_type), m_encoding_uid(rhs.m_encoding_uid),
- m_encoding_uid_type(rhs.m_encoding_uid_type),
- m_byte_size(rhs.m_byte_size), m_decl(rhs.m_decl),
- m_compiler_type(rhs.m_compiler_type), m_flags(rhs.m_flags) {}
-
-const Type &Type::operator=(const Type &rhs) {
- if (this != &rhs) {
- }
- return *this;
-}
-
void Type::GetDescription(Stream *s, lldb::DescriptionLevel level,
bool show_name) {
*s << "id = " << (const UserID &)*this;
// Call the name accessor to make sure we resolve the type name
if (show_name) {
- const ConstString &type_name = GetName();
+ ConstString type_name = GetName();
if (type_name) {
*s << ", name = \"" << type_name << '"';
ConstString qualified_type_name(GetQualifiedName());
@@ -214,7 +207,7 @@ void Type::Dump(Stream *s, bool show_context) {
if (m_name)
*s << ", name = \"" << m_name << "\"";
- if (m_byte_size != 0)
+ if (m_byte_size_has_value)
s->Printf(", size = %" PRIu64, m_byte_size);
if (show_context && m_context != nullptr) {
@@ -270,7 +263,7 @@ void Type::Dump(Stream *s, bool show_context) {
s->EOL();
}
-const ConstString &Type::GetName() {
+ConstString Type::GetName() {
if (!m_name)
m_name = GetForwardCompilerType().GetConstTypeName();
return m_name;
@@ -293,7 +286,7 @@ void Type::DumpValue(ExecutionContext *exe_ctx, Stream *s,
GetForwardCompilerType().DumpValue(
exe_ctx, s, format == lldb::eFormatDefault ? GetFormat() : format, data,
- data_byte_offset, GetByteSize(),
+ data_byte_offset, GetByteSize().getValueOr(0),
0, // Bitfield bit size
0, // Bitfield bit offset
show_types, show_summary, verbose, 0);
@@ -306,36 +299,46 @@ Type *Type::GetEncodingType() {
return m_encoding_type;
}
-uint64_t Type::GetByteSize() {
- if (m_byte_size == 0) {
- switch (m_encoding_uid_type) {
- case eEncodingInvalid:
- case eEncodingIsSyntheticUID:
- break;
- case eEncodingIsUID:
- case eEncodingIsConstUID:
- case eEncodingIsRestrictUID:
- case eEncodingIsVolatileUID:
- case eEncodingIsTypedefUID: {
- Type *encoding_type = GetEncodingType();
- if (encoding_type)
- m_byte_size = encoding_type->GetByteSize();
- if (m_byte_size == 0)
- if (llvm::Optional<uint64_t> size =
- GetLayoutCompilerType().GetByteSize(nullptr))
- m_byte_size = *size;
- } break;
+llvm::Optional<uint64_t> Type::GetByteSize() {
+ if (m_byte_size_has_value)
+ return m_byte_size;
+
+ switch (m_encoding_uid_type) {
+ case eEncodingInvalid:
+ case eEncodingIsSyntheticUID:
+ break;
+ case eEncodingIsUID:
+ case eEncodingIsConstUID:
+ case eEncodingIsRestrictUID:
+ case eEncodingIsVolatileUID:
+ case eEncodingIsTypedefUID: {
+ Type *encoding_type = GetEncodingType();
+ if (encoding_type)
+ if (llvm::Optional<uint64_t> size = encoding_type->GetByteSize()) {
+ m_byte_size = *size;
+ m_byte_size_has_value = true;
+ return m_byte_size;
+ }
+
+ if (llvm::Optional<uint64_t> size =
+ GetLayoutCompilerType().GetByteSize(nullptr)) {
+ m_byte_size = *size;
+ m_byte_size_has_value = true;
+ return m_byte_size;
+ }
+ } break;
// If we are a pointer or reference, then this is just a pointer size;
case eEncodingIsPointerUID:
case eEncodingIsLValueReferenceUID:
case eEncodingIsRValueReferenceUID: {
- if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture())
+ if (ArchSpec arch = m_symbol_file->GetObjectFile()->GetArchitecture()) {
m_byte_size = arch.GetAddressByteSize();
+ m_byte_size_has_value = true;
+ }
} break;
- }
}
- return m_byte_size;
+ return {};
}
uint32_t Type::GetNumChildren(bool omit_empty_base_classes) {
@@ -389,7 +392,7 @@ bool Type::ReadFromMemory(ExecutionContext *exe_ctx, lldb::addr_t addr,
return false;
}
- const uint64_t byte_size = GetByteSize();
+ const uint64_t byte_size = GetByteSize().getValueOr(0);
if (data.GetByteSize() < byte_size) {
lldb::DataBufferSP data_sp(new DataBufferHeap(byte_size, '\0'));
data.SetData(data_sp);
@@ -678,32 +681,21 @@ ModuleSP Type::GetModule() {
return ModuleSP();
}
-TypeAndOrName::TypeAndOrName() : m_type_pair(), m_type_name() {}
-
-TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) : m_type_pair(in_type_sp) {
- if (in_type_sp)
+TypeAndOrName::TypeAndOrName(TypeSP &in_type_sp) {
+ if (in_type_sp) {
+ m_compiler_type = in_type_sp->GetForwardCompilerType();
m_type_name = in_type_sp->GetName();
+ }
}
TypeAndOrName::TypeAndOrName(const char *in_type_str)
: m_type_name(in_type_str) {}
-TypeAndOrName::TypeAndOrName(const TypeAndOrName &rhs)
- : m_type_pair(rhs.m_type_pair), m_type_name(rhs.m_type_name) {}
-
TypeAndOrName::TypeAndOrName(ConstString &in_type_const_string)
: m_type_name(in_type_const_string) {}
-TypeAndOrName &TypeAndOrName::operator=(const TypeAndOrName &rhs) {
- if (this != &rhs) {
- m_type_name = rhs.m_type_name;
- m_type_pair = rhs.m_type_pair;
- }
- return *this;
-}
-
bool TypeAndOrName::operator==(const TypeAndOrName &other) const {
- if (m_type_pair != other.m_type_pair)
+ if (m_compiler_type != other.m_compiler_type)
return false;
if (m_type_name != other.m_type_name)
return false;
@@ -717,12 +709,12 @@ bool TypeAndOrName::operator!=(const TypeAndOrName &other) const {
ConstString TypeAndOrName::GetName() const {
if (m_type_name)
return m_type_name;
- if (m_type_pair)
- return m_type_pair.GetName();
+ if (m_compiler_type)
+ return m_compiler_type.GetTypeName();
return ConstString("<invalid>");
}
-void TypeAndOrName::SetName(const ConstString &type_name) {
+void TypeAndOrName::SetName(ConstString type_name) {
m_type_name = type_name;
}
@@ -731,42 +723,34 @@ void TypeAndOrName::SetName(const char *type_name_cstr) {
}
void TypeAndOrName::SetTypeSP(lldb::TypeSP type_sp) {
- m_type_pair.SetType(type_sp);
- if (m_type_pair)
- m_type_name = m_type_pair.GetName();
+ if (type_sp) {
+ m_compiler_type = type_sp->GetForwardCompilerType();
+ m_type_name = type_sp->GetName();
+ } else
+ Clear();
}
void TypeAndOrName::SetCompilerType(CompilerType compiler_type) {
- m_type_pair.SetType(compiler_type);
- if (m_type_pair)
- m_type_name = m_type_pair.GetName();
+ m_compiler_type = compiler_type;
+ if (m_compiler_type)
+ m_type_name = m_compiler_type.GetTypeName();
}
bool TypeAndOrName::IsEmpty() const {
- return !((bool)m_type_name || (bool)m_type_pair);
+ return !((bool)m_type_name || (bool)m_compiler_type);
}
void TypeAndOrName::Clear() {
m_type_name.Clear();
- m_type_pair.Clear();
+ m_compiler_type.Clear();
}
bool TypeAndOrName::HasName() const { return (bool)m_type_name; }
-bool TypeAndOrName::HasTypeSP() const {
- return m_type_pair.GetTypeSP().get() != nullptr;
-}
-
bool TypeAndOrName::HasCompilerType() const {
- return m_type_pair.GetCompilerType().IsValid();
+ return m_compiler_type.IsValid();
}
-TypeImpl::TypeImpl() : m_module_wp(), m_static_type(), m_dynamic_type() {}
-
-TypeImpl::TypeImpl(const TypeImpl &rhs)
- : m_module_wp(rhs.m_module_wp), m_static_type(rhs.m_static_type),
- m_dynamic_type(rhs.m_dynamic_type) {}
-
TypeImpl::TypeImpl(const lldb::TypeSP &type_sp)
: m_module_wp(), m_static_type(), m_dynamic_type() {
SetType(type_sp);
@@ -778,7 +762,7 @@ TypeImpl::TypeImpl(const CompilerType &compiler_type)
}
TypeImpl::TypeImpl(const lldb::TypeSP &type_sp, const CompilerType &dynamic)
- : m_module_wp(), m_static_type(type_sp), m_dynamic_type(dynamic) {
+ : m_module_wp(), m_static_type(), m_dynamic_type(dynamic) {
SetType(type_sp, dynamic);
}
@@ -788,22 +772,19 @@ TypeImpl::TypeImpl(const CompilerType &static_type,
SetType(static_type, dynamic_type);
}
-TypeImpl::TypeImpl(const TypePair &pair, const CompilerType &dynamic)
- : m_module_wp(), m_static_type(), m_dynamic_type() {
- SetType(pair, dynamic);
-}
-
void TypeImpl::SetType(const lldb::TypeSP &type_sp) {
- m_static_type.SetType(type_sp);
- if (type_sp)
+ if (type_sp) {
+ m_static_type = type_sp->GetForwardCompilerType();
m_module_wp = type_sp->GetModule();
- else
+ } else {
+ m_static_type.Clear();
m_module_wp = lldb::ModuleWP();
+ }
}
void TypeImpl::SetType(const CompilerType &compiler_type) {
m_module_wp = lldb::ModuleWP();
- m_static_type.SetType(compiler_type);
+ m_static_type = compiler_type;
}
void TypeImpl::SetType(const lldb::TypeSP &type_sp,
@@ -815,25 +796,10 @@ void TypeImpl::SetType(const lldb::TypeSP &type_sp,
void TypeImpl::SetType(const CompilerType &compiler_type,
const CompilerType &dynamic) {
m_module_wp = lldb::ModuleWP();
- m_static_type.SetType(compiler_type);
+ m_static_type = compiler_type;
m_dynamic_type = dynamic;
}
-void TypeImpl::SetType(const TypePair &pair, const CompilerType &dynamic) {
- m_module_wp = pair.GetModule();
- m_static_type = pair;
- m_dynamic_type = dynamic;
-}
-
-TypeImpl &TypeImpl::operator=(const TypeImpl &rhs) {
- if (rhs != *this) {
- m_module_wp = rhs.m_module_wp;
- m_static_type = rhs.m_static_type;
- m_dynamic_type = rhs.m_dynamic_type;
- }
- return *this;
-}
-
bool TypeImpl::CheckModule(lldb::ModuleSP &module_sp) const {
// Check if we have a module for this type. If we do and the shared pointer
// is can be successfully initialized with m_module_wp, return true. Else
@@ -892,7 +858,7 @@ ConstString TypeImpl::GetName() const {
if (CheckModule(module_sp)) {
if (m_dynamic_type)
return m_dynamic_type.GetTypeName();
- return m_static_type.GetName();
+ return m_static_type.GetTypeName();
}
return ConstString();
}
@@ -935,10 +901,10 @@ TypeImpl TypeImpl::GetReferenceType() const {
ModuleSP module_sp;
if (CheckModule(module_sp)) {
if (m_dynamic_type.IsValid()) {
- return TypeImpl(m_static_type.GetReferenceType(),
+ return TypeImpl(m_static_type.GetLValueReferenceType(),
m_dynamic_type.GetLValueReferenceType());
}
- return TypeImpl(m_static_type.GetReferenceType());
+ return TypeImpl(m_static_type.GetLValueReferenceType());
}
return TypeImpl();
}
@@ -959,10 +925,10 @@ TypeImpl TypeImpl::GetDereferencedType() const {
ModuleSP module_sp;
if (CheckModule(module_sp)) {
if (m_dynamic_type.IsValid()) {
- return TypeImpl(m_static_type.GetDereferencedType(),
+ return TypeImpl(m_static_type.GetNonReferenceType(),
m_dynamic_type.GetNonReferenceType());
}
- return TypeImpl(m_static_type.GetDereferencedType());
+ return TypeImpl(m_static_type.GetNonReferenceType());
}
return TypeImpl();
}
@@ -971,10 +937,10 @@ TypeImpl TypeImpl::GetUnqualifiedType() const {
ModuleSP module_sp;
if (CheckModule(module_sp)) {
if (m_dynamic_type.IsValid()) {
- return TypeImpl(m_static_type.GetUnqualifiedType(),
+ return TypeImpl(m_static_type.GetFullyUnqualifiedType(),
m_dynamic_type.GetFullyUnqualifiedType());
}
- return TypeImpl(m_static_type.GetUnqualifiedType());
+ return TypeImpl(m_static_type.GetFullyUnqualifiedType());
}
return TypeImpl();
}
@@ -998,7 +964,7 @@ CompilerType TypeImpl::GetCompilerType(bool prefer_dynamic) {
if (m_dynamic_type.IsValid())
return m_dynamic_type;
}
- return m_static_type.GetCompilerType();
+ return m_static_type;
}
return CompilerType();
}
@@ -1010,9 +976,9 @@ TypeSystem *TypeImpl::GetTypeSystem(bool prefer_dynamic) {
if (m_dynamic_type.IsValid())
return m_dynamic_type.GetTypeSystem();
}
- return m_static_type.GetCompilerType().GetTypeSystem();
+ return m_static_type.GetTypeSystem();
}
- return NULL;
+ return nullptr;
}
bool TypeImpl::GetDescription(lldb_private::Stream &strm,
@@ -1024,7 +990,7 @@ bool TypeImpl::GetDescription(lldb_private::Stream &strm,
m_dynamic_type.DumpTypeDescription(&strm);
strm.Printf("\nStatic:\n");
}
- m_static_type.GetCompilerType().DumpTypeDescription(&strm);
+ m_static_type.DumpTypeDescription(&strm);
} else {
strm.PutCString("Invalid TypeImpl module for type has been deleted\n");
}
@@ -1092,7 +1058,7 @@ CompilerType TypeMemberFunctionImpl::GetArgumentAtIndex(size_t idx) const {
}
TypeEnumMemberImpl::TypeEnumMemberImpl(const lldb::TypeImplSP &integer_type_sp,
- const ConstString &name,
+ ConstString name,
const llvm::APSInt &value)
: m_integer_type_sp(integer_type_sp), m_name(name), m_value(value),
m_valid((bool)name && (bool)integer_type_sp)
diff --git a/source/Symbol/TypeList.cpp b/source/Symbol/TypeList.cpp
index 26a646e64693c..1813e8ecca9a9 100644
--- a/source/Symbol/TypeList.cpp
+++ b/source/Symbol/TypeList.cpp
@@ -1,9 +1,8 @@
//===-- TypeList.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,7 @@ using namespace lldb_private;
TypeList::TypeList() : m_types() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
TypeList::~TypeList() {}
void TypeList::Insert(const TypeSP &type_sp) {
@@ -34,9 +31,7 @@ void TypeList::Insert(const TypeSP &type_sp) {
m_types.push_back(type_sp);
}
-//----------------------------------------------------------------------
// Find a base type by its unique ID.
-//----------------------------------------------------------------------
// TypeSP
// TypeList::FindType(lldb::user_id_t uid)
//{
@@ -46,11 +41,9 @@ void TypeList::Insert(const TypeSP &type_sp) {
// return TypeSP();
//}
-//----------------------------------------------------------------------
// Find a type by name.
-//----------------------------------------------------------------------
// TypeList
-// TypeList::FindTypes (const ConstString &name)
+// TypeList::FindTypes (ConstString name)
//{
// // Do we ever need to make a lookup by name map? Here we are doing
// // a linear search which isn't going to be fast.
diff --git a/source/Symbol/TypeMap.cpp b/source/Symbol/TypeMap.cpp
index 337278c202ed2..bc6e272449f0c 100644
--- a/source/Symbol/TypeMap.cpp
+++ b/source/Symbol/TypeMap.cpp
@@ -1,9 +1,8 @@
//===-- TypeMap.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,9 +34,7 @@ using namespace clang;
TypeMap::TypeMap() : m_types() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
TypeMap::~TypeMap() {}
void TypeMap::Insert(const TypeSP &type_sp) {
@@ -62,9 +59,7 @@ bool TypeMap::InsertUnique(const TypeSP &type_sp) {
return true;
}
-//----------------------------------------------------------------------
// Find a base type by its unique ID.
-//----------------------------------------------------------------------
// TypeSP
// TypeMap::FindType(lldb::user_id_t uid)
//{
@@ -74,11 +69,9 @@ bool TypeMap::InsertUnique(const TypeSP &type_sp) {
// return TypeSP();
//}
-//----------------------------------------------------------------------
// Find a type by name.
-//----------------------------------------------------------------------
// TypeMap
-// TypeMap::FindTypes (const ConstString &name)
+// TypeMap::FindTypes (ConstString name)
//{
// // Do we ever need to make a lookup by name map? Here we are doing
// // a linear search which isn't going to be fast.
diff --git a/source/Symbol/TypeSystem.cpp b/source/Symbol/TypeSystem.cpp
index 91d347edfc798..fb9c8e71acb35 100644
--- a/source/Symbol/TypeSystem.cpp
+++ b/source/Symbol/TypeSystem.cpp
@@ -1,9 +1,8 @@
//===-- TypeSystem.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -93,7 +92,7 @@ CompilerType TypeSystem::CreateTypedef(lldb::opaque_compiler_type_t type,
return CompilerType();
}
-CompilerType TypeSystem::GetBuiltinTypeByName(const ConstString &name) {
+CompilerType TypeSystem::GetBuiltinTypeByName(ConstString name) {
return CompilerType();
}
diff --git a/source/Symbol/UnwindPlan.cpp b/source/Symbol/UnwindPlan.cpp
index 0f8d9bf7e5a44..774f9cb587eeb 100644
--- a/source/Symbol/UnwindPlan.cpp
+++ b/source/Symbol/UnwindPlan.cpp
@@ -1,16 +1,17 @@
//===-- UnwindPlan.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/UnwindPlan.h"
+#include "lldb/Expression/DWARFExpression.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
+#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Log.h"
@@ -65,6 +66,30 @@ void UnwindPlan::Row::RegisterLocation::SetIsDWARFExpression(
m_location.expr.length = len;
}
+static llvm::Optional<std::pair<lldb::ByteOrder, uint32_t>>
+GetByteOrderAndAddrSize(Thread *thread) {
+ if (!thread)
+ return llvm::None;
+ ProcessSP process_sp = thread->GetProcess();
+ if (!process_sp)
+ return llvm::None;
+ ArchSpec arch = process_sp->GetTarget().GetArchitecture();
+ return std::make_pair(arch.GetByteOrder(), arch.GetAddressByteSize());
+}
+
+static void DumpDWARFExpr(Stream &s, llvm::ArrayRef<uint8_t> expr, Thread *thread) {
+ if (auto order_and_width = GetByteOrderAndAddrSize(thread)) {
+ DataExtractor extractor(expr.data(), expr.size(), order_and_width->first,
+ order_and_width->second);
+ if (!DWARFExpression::PrintDWARFExpression(s, extractor,
+ order_and_width->second,
+ /*dwarf_ref_size*/ 4,
+ /*location_expression*/ false))
+ s.PutCString("invalid-dwarf-expr");
+ } else
+ s.PutCString("dwarf-expr");
+}
+
void UnwindPlan::Row::RegisterLocation::Dump(Stream &s,
const UnwindPlan *unwind_plan,
const UnwindPlan::Row *row,
@@ -121,9 +146,12 @@ void UnwindPlan::Row::RegisterLocation::Dump(Stream &s,
case isDWARFExpression: {
s.PutChar('=');
if (m_type == atDWARFExpression)
- s.PutCString("[dwarf-expr]");
- else
- s.PutCString("dwarf-expr");
+ s.PutChar('[');
+ DumpDWARFExpr(
+ s, llvm::makeArrayRef(m_location.expr.opcodes, m_location.expr.length),
+ thread);
+ if (m_type == atDWARFExpression)
+ s.PutChar(']');
} break;
}
}
@@ -173,7 +201,9 @@ void UnwindPlan::Row::FAValue::Dump(Stream &s, const UnwindPlan *unwind_plan,
s.PutChar(']');
break;
case isDWARFExpression:
- s.PutCString("dwarf-expr");
+ DumpDWARFExpr(s,
+ llvm::makeArrayRef(m_value.expr.opcodes, m_value.expr.length),
+ thread);
break;
default:
s.PutCString("unspecified");
diff --git a/source/Symbol/UnwindTable.cpp b/source/Symbol/UnwindTable.cpp
index 4f0b875c5c6fb..a8f451dc46430 100644
--- a/source/Symbol/UnwindTable.cpp
+++ b/source/Symbol/UnwindTable.cpp
@@ -1,9 +1,8 @@
//===-- UnwindTable.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,6 +18,7 @@
#include "lldb/Symbol/FuncUnwinders.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
// There is one UnwindTable object per ObjectFile. It contains a list of Unwind
// objects -- one per function, populated lazily -- for the ObjectFile. Each
@@ -27,8 +27,8 @@
using namespace lldb;
using namespace lldb_private;
-UnwindTable::UnwindTable(ObjectFile &objfile)
- : m_object_file(objfile), m_unwinds(), m_initialized(false), m_mutex(),
+UnwindTable::UnwindTable(Module &module)
+ : m_module(module), m_unwinds(), m_initialized(false), m_mutex(),
m_eh_frame_up(), m_compact_unwind_up(), m_arm_unwind_up() {}
// We can't do some of this initialization when the ObjectFile is running its
@@ -43,33 +43,36 @@ void UnwindTable::Initialize() {
if (m_initialized) // check again once we've acquired the lock
return;
m_initialized = true;
+ ObjectFile *object_file = m_module.GetObjectFile();
+ if (!object_file)
+ return;
- SectionList *sl = m_object_file.GetSectionList();
+ SectionList *sl = m_module.GetSectionList();
if (!sl)
return;
SectionSP sect = sl->FindSectionByType(eSectionTypeEHFrame, true);
if (sect.get()) {
m_eh_frame_up.reset(
- new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::EH));
+ new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::EH));
}
sect = sl->FindSectionByType(eSectionTypeDWARFDebugFrame, true);
if (sect) {
m_debug_frame_up.reset(
- new DWARFCallFrameInfo(m_object_file, sect, DWARFCallFrameInfo::DWARF));
+ new DWARFCallFrameInfo(*object_file, sect, DWARFCallFrameInfo::DWARF));
}
sect = sl->FindSectionByType(eSectionTypeCompactUnwind, true);
if (sect) {
- m_compact_unwind_up.reset(new CompactUnwindInfo(m_object_file, sect));
+ m_compact_unwind_up.reset(new CompactUnwindInfo(*object_file, sect));
}
sect = sl->FindSectionByType(eSectionTypeARMexidx, true);
if (sect) {
SectionSP sect_extab = sl->FindSectionByType(eSectionTypeARMextab, true);
if (sect_extab.get()) {
- m_arm_unwind_up.reset(new ArmUnwindInfo(m_object_file, sect, sect_extab));
+ m_arm_unwind_up.reset(new ArmUnwindInfo(*object_file, sect, sect_extab));
}
}
}
@@ -149,8 +152,7 @@ UnwindTable::GetUncachedFuncUnwindersContainingAddress(const Address &addr,
void UnwindTable::Dump(Stream &s) {
std::lock_guard<std::mutex> guard(m_mutex);
- s.Printf("UnwindTable for '%s':\n",
- m_object_file.GetFileSpec().GetPath().c_str());
+ s.Format("UnwindTable for '{0}':\n", m_module.GetFileSpec());
const_iterator begin = m_unwinds.begin();
const_iterator end = m_unwinds.end();
for (const_iterator pos = begin; pos != end; ++pos) {
@@ -180,10 +182,16 @@ ArmUnwindInfo *UnwindTable::GetArmUnwindInfo() {
return m_arm_unwind_up.get();
}
-ArchSpec UnwindTable::GetArchitecture() {
- return m_object_file.GetArchitecture();
+SymbolFile *UnwindTable::GetSymbolFile() {
+ if (SymbolVendor *vendor = m_module.GetSymbolVendor())
+ return vendor->GetSymbolFile();
+ return nullptr;
}
+ArchSpec UnwindTable::GetArchitecture() { return m_module.GetArchitecture(); }
+
bool UnwindTable::GetAllowAssemblyEmulationUnwindPlans() {
- return m_object_file.AllowAssemblyEmulationUnwindPlans();
+ if (ObjectFile *object_file = m_module.GetObjectFile())
+ return object_file->AllowAssemblyEmulationUnwindPlans();
+ return false;
}
diff --git a/source/Symbol/Variable.cpp b/source/Symbol/Variable.cpp
index ffed48a33bf11..29a7a5191f610 100644
--- a/source/Symbol/Variable.cpp
+++ b/source/Symbol/Variable.cpp
@@ -1,9 +1,8 @@
//===-- Variable.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,9 +35,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Variable constructor
-//----------------------------------------------------------------------
Variable::Variable(
lldb::user_id_t uid, const char *name,
const char *mangled, // The mangled or fully qualified name of the variable.
@@ -53,9 +50,7 @@ Variable::Variable(
m_artificial(artificial), m_loc_is_const_data(false),
m_static_member(static_member) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Variable::~Variable() {}
lldb::LanguageType Variable::GetLanguage() const {
@@ -75,7 +70,7 @@ ConstString Variable::GetName() const {
ConstString Variable::GetUnqualifiedName() const { return m_name; }
-bool Variable::NameMatches(const ConstString &name) const {
+bool Variable::NameMatches(ConstString name) const {
if (m_name == name)
return true;
SymbolContext variable_sc;
diff --git a/source/Symbol/VariableList.cpp b/source/Symbol/VariableList.cpp
index e7a482e158b19..51312472e2652 100644
--- a/source/Symbol/VariableList.cpp
+++ b/source/Symbol/VariableList.cpp
@@ -1,9 +1,8 @@
//===-- VariableList.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,14 +16,10 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// VariableList constructor
-//----------------------------------------------------------------------
VariableList::VariableList() : m_variables() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
VariableList::~VariableList() {}
void VariableList::AddVariable(const VariableSP &var_sp) {
@@ -74,7 +69,7 @@ uint32_t VariableList::FindVariableIndex(const VariableSP &var_sp) {
return UINT32_MAX;
}
-VariableSP VariableList::FindVariable(const ConstString &name,
+VariableSP VariableList::FindVariable(ConstString name,
bool include_static_members) {
VariableSP var_sp;
iterator pos, end = m_variables.end();
@@ -89,7 +84,7 @@ VariableSP VariableList::FindVariable(const ConstString &name,
return var_sp;
}
-VariableSP VariableList::FindVariable(const ConstString &name,
+VariableSP VariableList::FindVariable(ConstString name,
lldb::ValueType value_type,
bool include_static_members) {
VariableSP var_sp;
diff --git a/source/Symbol/VerifyDecl.cpp b/source/Symbol/VerifyDecl.cpp
index 96ed47a527a88..1873d3a5d03c9 100644
--- a/source/Symbol/VerifyDecl.cpp
+++ b/source/Symbol/VerifyDecl.cpp
@@ -1,13 +1,15 @@
//===-- VerifyDecl.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Symbol/VerifyDecl.h"
#include "clang/AST/DeclBase.h"
-void lldb_private::VerifyDecl(clang::Decl *decl) { decl->getAccess(); }
+void lldb_private::VerifyDecl(clang::Decl *decl) {
+ assert(decl && "VerifyDecl called with nullptr?");
+ decl->getAccess();
+}
diff --git a/source/Target/ABI.cpp b/source/Target/ABI.cpp
index 96e09b75094af..28cd9aec665cb 100644
--- a/source/Target/ABI.cpp
+++ b/source/Target/ABI.cpp
@@ -1,17 +1,16 @@
//===-- ABI.cpp -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/ABI.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectConstResult.h"
+#include "lldb/Expression/ExpressionVariable.h"
#include "lldb/Symbol/CompilerType.h"
#include "lldb/Symbol/TypeSystem.h"
#include "lldb/Target/Target.h"
@@ -40,7 +39,7 @@ ABI::FindPlugin(lldb::ProcessSP process_sp, const ArchSpec &arch) {
ABI::~ABI() = default;
-bool ABI::GetRegisterInfoByName(const ConstString &name, RegisterInfo &info) {
+bool ABI::GetRegisterInfoByName(ConstString name, RegisterInfo &info) {
uint32_t count = 0;
const RegisterInfo *register_info_array = GetRegisterInfoArray(count);
if (register_info_array) {
@@ -125,11 +124,11 @@ ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
return_valobj_sp = const_valobj_sp;
- ExpressionVariableSP clang_expr_variable_sp(
+ ExpressionVariableSP expr_variable_sp(
persistent_expression_state->CreatePersistentVariable(
return_valobj_sp));
- assert(clang_expr_variable_sp);
+ assert(expr_variable_sp);
// Set flags and live data as appropriate
@@ -142,21 +141,21 @@ ValueObjectSP ABI::GetReturnValueObject(Thread &thread, CompilerType &ast_type,
break;
case Value::eValueTypeScalar:
case Value::eValueTypeVector:
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVIsFreezeDried;
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVIsLLDBAllocated;
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVNeedsAllocation;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVIsFreezeDried;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVIsLLDBAllocated;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVNeedsAllocation;
break;
case Value::eValueTypeLoadAddress:
- clang_expr_variable_sp->m_live_sp = live_valobj_sp;
- clang_expr_variable_sp->m_flags |=
- ClangExpressionVariable::EVIsProgramReference;
+ expr_variable_sp->m_live_sp = live_valobj_sp;
+ expr_variable_sp->m_flags |=
+ ExpressionVariable::EVIsProgramReference;
break;
}
- return_valobj_sp = clang_expr_variable_sp->GetValueObject();
+ return_valobj_sp = expr_variable_sp->GetValueObject();
}
return return_valobj_sp;
}
diff --git a/source/Target/ExecutionContext.cpp b/source/Target/ExecutionContext.cpp
index 7f1f0331c922f..77327372f88bf 100644
--- a/source/Target/ExecutionContext.cpp
+++ b/source/Target/ExecutionContext.cpp
@@ -1,9 +1,8 @@
//===-- ExecutionContext.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -225,30 +224,22 @@ ExecutionContextScope *ExecutionContext::GetBestExecutionContextScope() const {
}
Target &ExecutionContext::GetTargetRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_target_sp);
-#endif
return *m_target_sp;
}
Process &ExecutionContext::GetProcessRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_process_sp);
-#endif
return *m_process_sp;
}
Thread &ExecutionContext::GetThreadRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_thread_sp);
-#endif
return *m_thread_sp;
}
StackFrame &ExecutionContext::GetFrameRef() const {
-#if defined(LLDB_CONFIGURATION_DEBUG) || defined(LLDB_CONFIGURATION_RELEASE)
assert(m_frame_sp);
-#endif
return *m_frame_sp;
}
diff --git a/source/Target/InstrumentationRuntime.cpp b/source/Target/InstrumentationRuntime.cpp
index e948d43d50af7..4c2eb064fbb05 100644
--- a/source/Target/InstrumentationRuntime.cpp
+++ b/source/Target/InstrumentationRuntime.cpp
@@ -1,9 +1,8 @@
//===-- InstrumentationRuntime.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
diff --git a/source/Target/InstrumentationRuntimeStopInfo.cpp b/source/Target/InstrumentationRuntimeStopInfo.cpp
index dbbd4f4fc1d8c..f2767ffbff0d9 100644
--- a/source/Target/InstrumentationRuntimeStopInfo.cpp
+++ b/source/Target/InstrumentationRuntimeStopInfo.cpp
@@ -1,9 +1,8 @@
//===-- InstrumentationRuntimeStopInfo.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/JITLoader.cpp b/source/Target/JITLoader.cpp
index ddadcfa87a0ad..e7c13bddcb361 100644
--- a/source/Target/JITLoader.cpp
+++ b/source/Target/JITLoader.cpp
@@ -1,9 +1,8 @@
//===-- JITLoader.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/JITLoaderList.cpp b/source/Target/JITLoaderList.cpp
index 1e908bd543afb..4d1f06d0843e8 100644
--- a/source/Target/JITLoaderList.cpp
+++ b/source/Target/JITLoaderList.cpp
@@ -1,9 +1,8 @@
//===-- JITLoaderList.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/Language.cpp b/source/Target/Language.cpp
index 5c7a4097dd6ff..3c3ef2841d444 100644
--- a/source/Target/Language.cpp
+++ b/source/Target/Language.cpp
@@ -1,10 +1,9 @@
//===-- Language.cpp -------------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -274,6 +273,24 @@ bool Language::LanguageIsC(LanguageType language) {
}
}
+bool Language::LanguageIsCFamily(LanguageType language) {
+ switch (language) {
+ case eLanguageTypeC:
+ case eLanguageTypeC89:
+ case eLanguageTypeC99:
+ case eLanguageTypeC11:
+ case eLanguageTypeC_plus_plus:
+ case eLanguageTypeC_plus_plus_03:
+ case eLanguageTypeC_plus_plus_11:
+ case eLanguageTypeC_plus_plus_14:
+ case eLanguageTypeObjC_plus_plus:
+ case eLanguageTypeObjC:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool Language::LanguageIsPascal(LanguageType language) {
switch (language) {
case eLanguageTypePascal83:
@@ -331,6 +348,15 @@ LanguageType Language::GetPrimaryLanguage(LanguageType language) {
}
}
+std::set<lldb::LanguageType> Language::GetSupportedLanguages() {
+ std::set<lldb::LanguageType> supported_languages;
+ ForEach([&](Language *lang) {
+ supported_languages.emplace(lang->GetLanguageType());
+ return true;
+ });
+ return supported_languages;
+}
+
void Language::GetLanguagesSupportingTypeSystems(
std::set<lldb::LanguageType> &languages,
std::set<lldb::LanguageType> &languages_for_expressions) {
@@ -391,7 +417,7 @@ bool Language::ImageListTypeScavenger::Find_Impl(
images.FindTypes(nullptr, cs_key, false, UINT32_MAX, searched_sym_files,
matches);
for (const auto &match : matches.Types()) {
- if (match.get()) {
+ if (match) {
CompilerType compiler_type(match->GetFullCompilerType());
compiler_type = AdjustForInclusion(compiler_type);
if (!compiler_type)
@@ -444,12 +470,8 @@ void Language::GetDefaultExceptionResolverDescription(bool catch_on,
s.Printf("Exception breakpoint (catch: %s throw: %s)",
catch_on ? "on" : "off", throw_on ? "on" : "off");
}
-//----------------------------------------------------------------------
// Constructor
-//----------------------------------------------------------------------
Language::Language() {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Language::~Language() {}
diff --git a/source/Target/LanguageRuntime.cpp b/source/Target/LanguageRuntime.cpp
index ea6914fb076d1..dd44158106132 100644
--- a/source/Target/LanguageRuntime.cpp
+++ b/source/Target/LanguageRuntime.cpp
@@ -1,23 +1,23 @@
//===-- LanguageRuntime.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/LanguageRuntime.h"
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Interpreter/CommandInterpreter.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
+char LanguageRuntime::ID = 0;
+
ExceptionSearchFilter::ExceptionSearchFilter(const lldb::TargetSP &target_sp,
lldb::LanguageType language,
bool update_module_list)
@@ -202,7 +202,7 @@ protected:
LanguageRuntime *LanguageRuntime::FindPlugin(Process *process,
lldb::LanguageType language) {
- std::unique_ptr<LanguageRuntime> language_runtime_ap;
+ std::unique_ptr<LanguageRuntime> language_runtime_up;
LanguageRuntimeCreateInstance create_callback;
for (uint32_t idx = 0;
@@ -210,10 +210,10 @@ LanguageRuntime *LanguageRuntime::FindPlugin(Process *process,
PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) !=
nullptr;
++idx) {
- language_runtime_ap.reset(create_callback(process, language));
+ language_runtime_up.reset(create_callback(process, language));
- if (language_runtime_ap)
- return language_runtime_ap.release();
+ if (language_runtime_up)
+ return language_runtime_up.release();
}
return nullptr;
@@ -223,19 +223,24 @@ LanguageRuntime::LanguageRuntime(Process *process) : m_process(process) {}
LanguageRuntime::~LanguageRuntime() = default;
-Breakpoint::BreakpointPreconditionSP
-LanguageRuntime::CreateExceptionPrecondition(lldb::LanguageType language,
- bool catch_bp, bool throw_bp) {
- switch (language) {
- case eLanguageTypeObjC:
- if (throw_bp)
- return Breakpoint::BreakpointPreconditionSP(
- new ObjCLanguageRuntime::ObjCExceptionPrecondition());
- break;
- default:
- break;
+BreakpointPreconditionSP
+LanguageRuntime::GetExceptionPrecondition(LanguageType language,
+ bool throw_bp) {
+ LanguageRuntimeCreateInstance create_callback;
+ for (uint32_t idx = 0;
+ (create_callback =
+ PluginManager::GetLanguageRuntimeCreateCallbackAtIndex(idx)) !=
+ nullptr;
+ idx++) {
+ if (auto precondition_callback =
+ PluginManager::GetLanguageRuntimeGetExceptionPreconditionAtIndex(
+ idx)) {
+ if (BreakpointPreconditionSP precond =
+ precondition_callback(language, throw_bp))
+ return precond;
+ }
}
- return Breakpoint::BreakpointPreconditionSP();
+ return BreakpointPreconditionSP();
}
BreakpointSP LanguageRuntime::CreateExceptionBreakpoint(
@@ -251,10 +256,8 @@ BreakpointSP LanguageRuntime::CreateExceptionBreakpoint(
target.CreateBreakpoint(filter_sp, resolver_sp, is_internal, hardware,
resolve_indirect_functions));
if (exc_breakpt_sp) {
- Breakpoint::BreakpointPreconditionSP precondition_sp =
- CreateExceptionPrecondition(language, catch_bp, throw_bp);
- if (precondition_sp)
- exc_breakpt_sp->SetPrecondition(precondition_sp);
+ if (auto precond = GetExceptionPrecondition(language, throw_bp))
+ exc_breakpt_sp->SetPrecondition(precond);
if (is_internal)
exc_breakpt_sp->SetBreakpointKind("exception");
@@ -291,7 +294,3 @@ void LanguageRuntime::InitializeCommands(CommandObject *parent) {
}
}
}
-
-lldb::SearchFilterSP LanguageRuntime::CreateExceptionSearchFilter() {
- return m_process->GetTarget().GetSearchFilterForModule(nullptr);
-}
diff --git a/source/Target/Memory.cpp b/source/Target/Memory.cpp
index 190c5057e8811..31a378069cec8 100644
--- a/source/Target/Memory.cpp
+++ b/source/Target/Memory.cpp
@@ -1,34 +1,31 @@
//===-- Memory.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/Memory.h"
-#include <inttypes.h>
-#include "lldb/Core/RangeMap.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/Log.h"
+#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/State.h"
+#include <cinttypes>
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// MemoryCache constructor
-//----------------------------------------------------------------------
MemoryCache::MemoryCache(Process &process)
: m_mutex(), m_L1_cache(), m_L2_cache(), m_invalid_ranges(),
m_process(process),
m_L2_cache_line_byte_size(process.GetMemoryCacheLineSize()) {}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
MemoryCache::~MemoryCache() {}
void MemoryCache::Clear(bool clear_invalid_ranges) {
@@ -145,7 +142,7 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len,
}
AddrRange chunk_range(pos->first, pos->second->GetByteSize());
if (chunk_range.Contains(read_range)) {
- memcpy(dst, pos->second->GetBytes() + addr - chunk_range.GetRangeBase(),
+ memcpy(dst, pos->second->GetBytes() + (addr - chunk_range.GetRangeBase()),
dst_len);
return dst_len;
}
@@ -227,17 +224,17 @@ size_t MemoryCache::Read(addr_t addr, void *dst, size_t dst_len,
if (bytes_left > 0) {
assert((curr_addr % cache_line_byte_size) == 0);
- std::unique_ptr<DataBufferHeap> data_buffer_heap_ap(
+ std::unique_ptr<DataBufferHeap> data_buffer_heap_up(
new DataBufferHeap(cache_line_byte_size, 0));
size_t process_bytes_read = m_process.ReadMemoryFromInferior(
- curr_addr, data_buffer_heap_ap->GetBytes(),
- data_buffer_heap_ap->GetByteSize(), error);
+ curr_addr, data_buffer_heap_up->GetBytes(),
+ data_buffer_heap_up->GetByteSize(), error);
if (process_bytes_read == 0)
return dst_len - bytes_left;
if (process_bytes_read != cache_line_byte_size)
- data_buffer_heap_ap->SetByteSize(process_bytes_read);
- m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_ap.release());
+ data_buffer_heap_up->SetByteSize(process_bytes_read);
+ m_L2_cache[curr_addr] = DataBufferSP(data_buffer_heap_up.release());
// We have read data and put it into the cache, continue through the
// loop again to get the data out of the cache...
}
@@ -358,8 +355,8 @@ AllocatedMemoryCache::AllocatePage(uint32_t byte_size, uint32_t permissions,
}
if (addr != LLDB_INVALID_ADDRESS) {
- block_sp.reset(
- new AllocatedBlock(addr, page_byte_size, permissions, chunk_size));
+ block_sp = std::make_shared<AllocatedBlock>(addr, page_byte_size,
+ permissions, chunk_size);
m_memory_map.insert(std::make_pair(permissions, block_sp));
}
return block_sp;
diff --git a/source/Target/MemoryHistory.cpp b/source/Target/MemoryHistory.cpp
index eae9314825529..37148e1e72e9a 100644
--- a/source/Target/MemoryHistory.cpp
+++ b/source/Target/MemoryHistory.cpp
@@ -1,9 +1,8 @@
//===-- MemoryHistory.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/ModuleCache.cpp b/source/Target/ModuleCache.cpp
index daf787b1fb222..444c9806f98bf 100644
--- a/source/Target/ModuleCache.cpp
+++ b/source/Target/ModuleCache.cpp
@@ -1,9 +1,8 @@
//===--------------------- ModuleCache.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/OperatingSystem.cpp b/source/Target/OperatingSystem.cpp
index 099bfd055ed12..c78c197db5be9 100644
--- a/source/Target/OperatingSystem.cpp
+++ b/source/Target/OperatingSystem.cpp
@@ -1,9 +1,8 @@
//===-- OperatingSystem.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,10 +22,10 @@ OperatingSystem *OperatingSystem::FindPlugin(Process *process,
PluginManager::GetOperatingSystemCreateCallbackForPluginName(
const_plugin_name);
if (create_callback) {
- std::unique_ptr<OperatingSystem> instance_ap(
+ std::unique_ptr<OperatingSystem> instance_up(
create_callback(process, true));
- if (instance_ap)
- return instance_ap.release();
+ if (instance_up)
+ return instance_up.release();
}
} else {
for (uint32_t idx = 0;
@@ -34,10 +33,10 @@ OperatingSystem *OperatingSystem::FindPlugin(Process *process,
PluginManager::GetOperatingSystemCreateCallbackAtIndex(idx)) !=
nullptr;
++idx) {
- std::unique_ptr<OperatingSystem> instance_ap(
+ std::unique_ptr<OperatingSystem> instance_up(
create_callback(process, false));
- if (instance_ap)
- return instance_ap.release();
+ if (instance_up)
+ return instance_up.release();
}
}
return nullptr;
diff --git a/source/Target/PathMappingList.cpp b/source/Target/PathMappingList.cpp
index c2249cce89b9a..58c2c43c93683 100644
--- a/source/Target/PathMappingList.cpp
+++ b/source/Target/PathMappingList.cpp
@@ -1,9 +1,8 @@
//===-- PathMappingList.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -31,15 +30,13 @@ namespace {
// with the raw path pair, which doesn't work anymore because the paths have
// been normalized when the debug info was loaded. So we need to store
// nomalized path pairs to ensure things match up.
- ConstString NormalizePath(const ConstString &path) {
+ ConstString NormalizePath(ConstString path) {
// If we use "path" to construct a FileSpec, it will normalize the path for
// us. We then grab the string and turn it back into a ConstString.
return ConstString(FileSpec(path.GetStringRef()).GetPath());
}
}
-//----------------------------------------------------------------------
// PathMappingList constructor
-//----------------------------------------------------------------------
PathMappingList::PathMappingList()
: m_pairs(), m_callback(nullptr), m_callback_baton(nullptr), m_mod_id(0) {}
@@ -63,8 +60,8 @@ const PathMappingList &PathMappingList::operator=(const PathMappingList &rhs) {
PathMappingList::~PathMappingList() = default;
-void PathMappingList::Append(const ConstString &path,
- const ConstString &replacement, bool notify) {
+void PathMappingList::Append(ConstString path,
+ ConstString replacement, bool notify) {
++m_mod_id;
m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
if (notify && m_callback)
@@ -82,8 +79,8 @@ void PathMappingList::Append(const PathMappingList &rhs, bool notify) {
}
}
-void PathMappingList::Insert(const ConstString &path,
- const ConstString &replacement, uint32_t index,
+void PathMappingList::Insert(ConstString path,
+ ConstString replacement, uint32_t index,
bool notify) {
++m_mod_id;
iterator insert_iter;
@@ -97,8 +94,8 @@ void PathMappingList::Insert(const ConstString &path,
m_callback(*this, m_callback_baton);
}
-bool PathMappingList::Replace(const ConstString &path,
- const ConstString &replacement, uint32_t index,
+bool PathMappingList::Replace(ConstString path,
+ ConstString replacement, uint32_t index,
bool notify) {
if (index >= m_pairs.size())
return false;
@@ -147,7 +144,7 @@ void PathMappingList::Clear(bool notify) {
m_callback(*this, m_callback_baton);
}
-bool PathMappingList::RemapPath(const ConstString &path,
+bool PathMappingList::RemapPath(ConstString path,
ConstString &new_path) const {
std::string remapped;
if (RemapPath(path.GetStringRef(), remapped)) {
@@ -202,32 +199,51 @@ bool PathMappingList::ReverseRemapPath(const FileSpec &file, FileSpec &fixed) co
bool PathMappingList::FindFile(const FileSpec &orig_spec,
FileSpec &new_spec) const {
- if (!m_pairs.empty()) {
- char orig_path[PATH_MAX];
- const size_t orig_path_len =
- orig_spec.GetPath(orig_path, sizeof(orig_path));
- if (orig_path_len > 0) {
- const_iterator pos, end = m_pairs.end();
- for (pos = m_pairs.begin(); pos != end; ++pos) {
- const size_t prefix_len = pos->first.GetLength();
-
- if (orig_path_len >= prefix_len) {
- if (::strncmp(pos->first.GetCString(), orig_path, prefix_len) == 0) {
- new_spec.SetFile(pos->second.GetCString(), FileSpec::Style::native);
- new_spec.AppendPathComponent(orig_path + prefix_len);
- if (FileSystem::Instance().Exists(new_spec))
- return true;
- }
- }
- }
+ if (m_pairs.empty())
+ return false;
+
+ std::string orig_path = orig_spec.GetPath();
+
+ if (orig_path.empty())
+ return false;
+
+ bool orig_is_relative = orig_spec.IsRelative();
+
+ for (auto entry : m_pairs) {
+ llvm::StringRef orig_ref(orig_path);
+ llvm::StringRef prefix_ref = entry.first.GetStringRef();
+ if (orig_ref.size() < prefix_ref.size())
+ continue;
+ // We consider a relative prefix or one of just "." to
+ // mean "only apply to relative paths".
+ bool prefix_is_relative = false;
+
+ if (prefix_ref == ".") {
+ prefix_is_relative = true;
+ // Remove the "." since it will have been removed from the
+ // FileSpec paths already.
+ prefix_ref = prefix_ref.drop_front();
+ } else {
+ FileSpec prefix_spec(prefix_ref, FileSpec::Style::native);
+ prefix_is_relative = prefix_spec.IsRelative();
+ }
+ if (prefix_is_relative != orig_is_relative)
+ continue;
+
+ if (orig_ref.consume_front(prefix_ref)) {
+ new_spec.SetFile(entry.second.GetCString(), FileSpec::Style::native);
+ new_spec.AppendPathComponent(orig_ref);
+ if (FileSystem::Instance().Exists(new_spec))
+ return true;
}
}
+
new_spec.Clear();
return false;
}
-bool PathMappingList::Replace(const ConstString &path,
- const ConstString &new_path, bool notify) {
+bool PathMappingList::Replace(ConstString path,
+ ConstString new_path, bool notify) {
uint32_t idx = FindIndexForPath(path);
if (idx < m_pairs.size()) {
++m_mod_id;
@@ -239,7 +255,7 @@ bool PathMappingList::Replace(const ConstString &path,
return false;
}
-bool PathMappingList::Remove(const ConstString &path, bool notify) {
+bool PathMappingList::Remove(ConstString path, bool notify) {
iterator pos = FindIteratorForPath(path);
if (pos != m_pairs.end()) {
++m_mod_id;
@@ -252,7 +268,7 @@ bool PathMappingList::Remove(const ConstString &path, bool notify) {
}
PathMappingList::const_iterator
-PathMappingList::FindIteratorForPath(const ConstString &path) const {
+PathMappingList::FindIteratorForPath(ConstString path) const {
const_iterator pos;
const_iterator begin = m_pairs.begin();
const_iterator end = m_pairs.end();
@@ -265,7 +281,7 @@ PathMappingList::FindIteratorForPath(const ConstString &path) const {
}
PathMappingList::iterator
-PathMappingList::FindIteratorForPath(const ConstString &path) {
+PathMappingList::FindIteratorForPath(ConstString path) {
iterator pos;
iterator begin = m_pairs.begin();
iterator end = m_pairs.end();
@@ -287,7 +303,7 @@ bool PathMappingList::GetPathsAtIndex(uint32_t idx, ConstString &path,
return false;
}
-uint32_t PathMappingList::FindIndexForPath(const ConstString &orig_path) const {
+uint32_t PathMappingList::FindIndexForPath(ConstString orig_path) const {
const ConstString path = NormalizePath(orig_path);
const_iterator pos;
const_iterator begin = m_pairs.begin();
diff --git a/source/Target/Platform.cpp b/source/Target/Platform.cpp
index 400b3c92b5abf..710f82eaefa9c 100644
--- a/source/Target/Platform.cpp
+++ b/source/Target/Platform.cpp
@@ -1,15 +1,15 @@
//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <algorithm>
#include <csignal>
#include <fstream>
+#include <memory>
#include <vector>
#include "llvm/Support/FileSystem.h"
@@ -79,7 +79,7 @@ ConstString PlatformProperties::GetSettingName() {
}
PlatformProperties::PlatformProperties() {
- m_collection_sp.reset(new OptionValueProperties(GetSettingName()));
+ m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
m_collection_sp->Initialize(g_properties);
auto module_cache_dir = GetModuleCacheDirectory();
@@ -117,7 +117,6 @@ bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {
nullptr, ePropertyModuleCacheDirectory, dir_spec);
}
-//------------------------------------------------------------------
/// Get the native host platform plug-in.
///
/// There should only be one of these for each host that LLDB runs
@@ -126,7 +125,6 @@ bool PlatformProperties::SetModuleCacheDirectory(const FileSpec &dir_spec) {
///
/// This platform will be used as the default platform when launching
/// or attaching to processes unless another platform is specified.
-//------------------------------------------------------------------
PlatformSP Platform::GetHostPlatform() { return GetHostPlatformSP(); }
static std::vector<PlatformSP> &GetPlatformList() {
@@ -180,7 +178,7 @@ Platform::LocateExecutableScriptingResources(Target *target, Module &module,
}
// PlatformSP
-// Platform::FindPlugin (Process *process, const ConstString &plugin_name)
+// Platform::FindPlugin (Process *process, ConstString plugin_name)
//{
// PlatformCreateInstance create_callback = nullptr;
// if (plugin_name)
@@ -267,7 +265,7 @@ bool Platform::GetModuleSpec(const FileSpec &module_file_spec,
module_spec);
}
-PlatformSP Platform::Find(const ConstString &name) {
+PlatformSP Platform::Find(ConstString name) {
if (name) {
static ConstString g_host_platform_name("host");
if (name == g_host_platform_name)
@@ -282,7 +280,7 @@ PlatformSP Platform::Find(const ConstString &name) {
return PlatformSP();
}
-PlatformSP Platform::Create(const ConstString &name, Status &error) {
+PlatformSP Platform::Create(ConstString name, Status &error) {
PlatformCreateInstance create_callback = nullptr;
lldb::PlatformSP platform_sp;
if (name) {
@@ -377,29 +375,25 @@ ArchSpec Platform::GetAugmentedArchSpec(Platform *platform, llvm::StringRef trip
return HostInfo::GetAugmentedArchSpec(triple);
}
-//------------------------------------------------------------------
/// Default Constructor
-//------------------------------------------------------------------
Platform::Platform(bool is_host)
: m_is_host(is_host), m_os_version_set_while_connected(false),
m_system_arch_set_while_connected(false), m_sdk_sysroot(), m_sdk_build(),
m_working_dir(), m_remote_url(), m_name(), m_system_arch(), m_mutex(),
- m_uid_map(), m_gid_map(), m_max_uid_name_len(0), m_max_gid_name_len(0),
- m_supports_rsync(false), m_rsync_opts(), m_rsync_prefix(),
- m_supports_ssh(false), m_ssh_opts(), m_ignores_remote_hostname(false),
- m_trap_handlers(), m_calculated_trap_handlers(false),
+ m_max_uid_name_len(0), m_max_gid_name_len(0), m_supports_rsync(false),
+ m_rsync_opts(), m_rsync_prefix(), m_supports_ssh(false), m_ssh_opts(),
+ m_ignores_remote_hostname(false), m_trap_handlers(),
+ m_calculated_trap_handlers(false),
m_module_cache(llvm::make_unique<ModuleCache>()) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
log->Printf("%p Platform::Platform()", static_cast<void *>(this));
}
-//------------------------------------------------------------------
/// Destructor.
///
/// The destructor is virtual since this class is designed to be
/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
Platform::~Platform() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
if (log)
@@ -834,34 +828,6 @@ bool Platform::SetRemoteWorkingDirectory(const FileSpec &working_dir) {
return true;
}
-const char *Platform::GetUserName(uint32_t uid) {
-#if !defined(LLDB_DISABLE_POSIX)
- const char *user_name = GetCachedUserName(uid);
- if (user_name)
- return user_name;
- if (IsHost()) {
- std::string name;
- if (HostInfo::LookupUserName(uid, name))
- return SetCachedUserName(uid, name.c_str(), name.size());
- }
-#endif
- return nullptr;
-}
-
-const char *Platform::GetGroupName(uint32_t gid) {
-#if !defined(LLDB_DISABLE_POSIX)
- const char *group_name = GetCachedGroupName(gid);
- if (group_name)
- return group_name;
- if (IsHost()) {
- std::string name;
- if (HostInfo::LookupGroupName(gid, name))
- return SetCachedGroupName(gid, name.c_str(), name.size());
- }
-#endif
- return nullptr;
-}
-
bool Platform::SetOSVersion(llvm::VersionTuple version) {
if (IsHost()) {
// We don't need anyone setting the OS version for the host platform, we
@@ -1060,11 +1026,11 @@ Status Platform::LaunchProcess(ProcessLaunchInfo &launch_info) {
uint32_t num_resumes = GetResumeCountForLaunchInfo(launch_info);
if (log) {
const FileSpec &shell = launch_info.GetShell();
- const char *shell_str = (shell) ? shell.GetPath().c_str() : "<null>";
+ std::string shell_str = (shell) ? shell.GetPath() : "<null>";
log->Printf(
"Platform::%s GetResumeCountForLaunchInfo() returned %" PRIu32
", shell is '%s'",
- __FUNCTION__, num_resumes, shell_str);
+ __FUNCTION__, num_resumes, shell_str.c_str());
}
if (!launch_info.ConvertArgumentsForLaunchingInShell(
@@ -1226,10 +1192,8 @@ Platform::GetPlatformForArchitecture(const ArchSpec &arch,
return platform_sp;
}
-//------------------------------------------------------------------
/// Lets a platform answer if it is compatible with a given
/// architecture and the target triple contained within.
-//------------------------------------------------------------------
bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
bool exact_arch_match,
ArchSpec *compatible_arch_ptr) {
@@ -1740,9 +1704,9 @@ const UnixSignalsSP &Platform::GetRemoteUnixSignals() {
return s_default_unix_signals_sp;
}
-const UnixSignalsSP &Platform::GetUnixSignals() {
+UnixSignalsSP Platform::GetUnixSignals() {
if (IsHost())
- return Host::GetUnixSignals();
+ return UnixSignals::CreateForHost();
return GetRemoteUnixSignals();
}
diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp
index fb3b758912ebd..6c634dba00c7f 100644
--- a/source/Target/Process.cpp
+++ b/source/Target/Process.cpp
@@ -1,13 +1,13 @@
//===-- Process.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <atomic>
+#include <memory>
#include <mutex>
#include "llvm/Support/ScopedPrinter.h"
@@ -22,7 +22,7 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/StreamFile.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/IRDynamicChecks.h"
+#include "lldb/Expression/DynamicCheckerFunctions.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Expression/UtilityFunction.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
@@ -39,15 +39,14 @@
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/ABI.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/InstrumentationRuntime.h"
#include "lldb/Target/JITLoader.h"
#include "lldb/Target/JITLoaderList.h"
+#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/MemoryHistory.h"
#include "lldb/Target/MemoryRegionInfo.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/OperatingSystem.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
@@ -64,6 +63,7 @@
#include "lldb/Utility/Event.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/NameMatches.h"
+#include "lldb/Utility/ProcessInfo.h"
#include "lldb/Utility/SelectHelper.h"
#include "lldb/Utility/State.h"
@@ -83,7 +83,7 @@ using namespace std::chrono;
class ProcessOptionValueProperties : public OptionValueProperties {
public:
- ProcessOptionValueProperties(const ConstString &name)
+ ProcessOptionValueProperties(ConstString name)
: OptionValueProperties(name) {}
// This constructor is used when creating ProcessOptionValueProperties when
@@ -143,7 +143,11 @@ static constexpr PropertyDefinition g_properties[] = {
"stepping and variable availability may not behave as expected."},
{"stop-on-exec", OptionValue::eTypeBoolean, true, true,
nullptr, {},
- "If true, stop when a shared library is loaded or unloaded."}};
+ "If true, stop when a shared library is loaded or unloaded."},
+ {"utility-expression-timeout", OptionValue::eTypeUInt64, false, 15,
+ nullptr, {},
+ "The time in seconds to wait for LLDB-internal utility expressions."}
+};
enum {
ePropertyDisableMemCache,
@@ -155,7 +159,8 @@ enum {
ePropertyDetachKeepsStopped,
ePropertyMemCacheLineSize,
ePropertyWarningOptimization,
- ePropertyStopOnExec
+ ePropertyStopOnExec,
+ ePropertyUtilityExpressionTimeout,
};
ProcessProperties::ProcessProperties(lldb_private::Process *process)
@@ -164,15 +169,15 @@ ProcessProperties::ProcessProperties(lldb_private::Process *process)
{
if (process == nullptr) {
// Global process properties, set them up one time
- m_collection_sp.reset(
- new ProcessOptionValueProperties(ConstString("process")));
+ m_collection_sp =
+ std::make_shared<ProcessOptionValueProperties>(ConstString("process"));
m_collection_sp->Initialize(g_properties);
m_collection_sp->AppendProperty(
ConstString("thread"), ConstString("Settings specific to threads."),
true, Thread::GetGlobalProperties()->GetValueProperties());
} else {
- m_collection_sp.reset(
- new ProcessOptionValueProperties(Process::GetGlobalProperties().get()));
+ m_collection_sp = std::make_shared<ProcessOptionValueProperties>(
+ Process::GetGlobalProperties().get());
m_collection_sp->SetValueChangedCallback(
ePropertyPythonOSPluginPath,
ProcessProperties::OptionValueChangedCallback, this);
@@ -278,138 +283,11 @@ bool ProcessProperties::GetStopOnExec() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
-void ProcessInstanceInfo::Dump(Stream &s, Platform *platform) const {
- const char *cstr;
- if (m_pid != LLDB_INVALID_PROCESS_ID)
- s.Printf(" pid = %" PRIu64 "\n", m_pid);
-
- if (m_parent_pid != LLDB_INVALID_PROCESS_ID)
- s.Printf(" parent = %" PRIu64 "\n", m_parent_pid);
-
- if (m_executable) {
- s.Printf(" name = %s\n", m_executable.GetFilename().GetCString());
- s.PutCString(" file = ");
- m_executable.Dump(&s);
- s.EOL();
- }
- const uint32_t argc = m_arguments.GetArgumentCount();
- if (argc > 0) {
- for (uint32_t i = 0; i < argc; i++) {
- const char *arg = m_arguments.GetArgumentAtIndex(i);
- if (i < 10)
- s.Printf(" arg[%u] = %s\n", i, arg);
- else
- s.Printf("arg[%u] = %s\n", i, arg);
- }
- }
-
- s.Format("{0}", m_environment);
-
- if (m_arch.IsValid()) {
- s.Printf(" arch = ");
- m_arch.DumpTriple(s);
- s.EOL();
- }
-
- if (m_uid != UINT32_MAX) {
- cstr = platform->GetUserName(m_uid);
- s.Printf(" uid = %-5u (%s)\n", m_uid, cstr ? cstr : "");
- }
- if (m_gid != UINT32_MAX) {
- cstr = platform->GetGroupName(m_gid);
- s.Printf(" gid = %-5u (%s)\n", m_gid, cstr ? cstr : "");
- }
- if (m_euid != UINT32_MAX) {
- cstr = platform->GetUserName(m_euid);
- s.Printf(" euid = %-5u (%s)\n", m_euid, cstr ? cstr : "");
- }
- if (m_egid != UINT32_MAX) {
- cstr = platform->GetGroupName(m_egid);
- s.Printf(" egid = %-5u (%s)\n", m_egid, cstr ? cstr : "");
- }
-}
-
-void ProcessInstanceInfo::DumpTableHeader(Stream &s, Platform *platform,
- bool show_args, bool verbose) {
- const char *label;
- if (show_args || verbose)
- label = "ARGUMENTS";
- else
- label = "NAME";
-
- if (verbose) {
- s.Printf("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE "
- " %s\n",
- label);
- s.PutCString("====== ====== ========== ========== ========== ========== "
- "======================== ============================\n");
- } else {
- s.Printf("PID PARENT USER TRIPLE %s\n", label);
- s.PutCString("====== ====== ========== ======================== "
- "============================\n");
- }
-}
-
-void ProcessInstanceInfo::DumpAsTableRow(Stream &s, Platform *platform,
- bool show_args, bool verbose) const {
- if (m_pid != LLDB_INVALID_PROCESS_ID) {
- const char *cstr;
- s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", m_pid, m_parent_pid);
-
- StreamString arch_strm;
- if (m_arch.IsValid())
- m_arch.DumpTriple(arch_strm);
-
- if (verbose) {
- cstr = platform->GetUserName(m_uid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_uid);
-
- cstr = platform->GetGroupName(m_gid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_gid);
-
- cstr = platform->GetUserName(m_euid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_euid);
-
- cstr = platform->GetGroupName(m_egid);
- if (cstr &&
- cstr[0]) // Watch for empty string that indicates lookup failed
- s.Printf("%-10s ", cstr);
- else
- s.Printf("%-10u ", m_egid);
-
- s.Printf("%-24s ", arch_strm.GetData());
- } else {
- s.Printf("%-10s %-24s ", platform->GetUserName(m_euid),
- arch_strm.GetData());
- }
-
- if (verbose || show_args) {
- const uint32_t argc = m_arguments.GetArgumentCount();
- if (argc > 0) {
- for (uint32_t i = 0; i < argc; i++) {
- if (i > 0)
- s.PutChar(' ');
- s.PutCString(m_arguments.GetArgumentAtIndex(i));
- }
- }
- } else {
- s.PutCString(GetName());
- }
-
- s.EOL();
- }
+std::chrono::seconds ProcessProperties::GetUtilityExpressionTimeout() const {
+ const uint32_t idx = ePropertyUtilityExpressionTimeout;
+ uint64_t value = m_collection_sp->GetPropertyAtIndexAsUInt64(
+ nullptr, idx, g_properties[idx].default_uint_value);
+ return std::chrono::seconds(value);
}
Status ProcessLaunchCommandOptions::SetOptionValue(
@@ -581,89 +459,6 @@ llvm::ArrayRef<OptionDefinition> ProcessLaunchCommandOptions::GetDefinitions() {
return llvm::makeArrayRef(g_process_launch_options);
}
-bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
- if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
- return true;
- const char *match_name = m_match_info.GetName();
- if (!match_name)
- return true;
-
- return lldb_private::NameMatches(process_name, m_name_match_type, match_name);
-}
-
-bool ProcessInstanceInfoMatch::Matches(
- const ProcessInstanceInfo &proc_info) const {
- if (!NameMatches(proc_info.GetName()))
- return false;
-
- if (m_match_info.ProcessIDIsValid() &&
- m_match_info.GetProcessID() != proc_info.GetProcessID())
- return false;
-
- if (m_match_info.ParentProcessIDIsValid() &&
- m_match_info.GetParentProcessID() != proc_info.GetParentProcessID())
- return false;
-
- if (m_match_info.UserIDIsValid() &&
- m_match_info.GetUserID() != proc_info.GetUserID())
- return false;
-
- if (m_match_info.GroupIDIsValid() &&
- m_match_info.GetGroupID() != proc_info.GetGroupID())
- return false;
-
- if (m_match_info.EffectiveUserIDIsValid() &&
- m_match_info.GetEffectiveUserID() != proc_info.GetEffectiveUserID())
- return false;
-
- if (m_match_info.EffectiveGroupIDIsValid() &&
- m_match_info.GetEffectiveGroupID() != proc_info.GetEffectiveGroupID())
- return false;
-
- if (m_match_info.GetArchitecture().IsValid() &&
- !m_match_info.GetArchitecture().IsCompatibleMatch(
- proc_info.GetArchitecture()))
- return false;
- return true;
-}
-
-bool ProcessInstanceInfoMatch::MatchAllProcesses() const {
- if (m_name_match_type != NameMatch::Ignore)
- return false;
-
- if (m_match_info.ProcessIDIsValid())
- return false;
-
- if (m_match_info.ParentProcessIDIsValid())
- return false;
-
- if (m_match_info.UserIDIsValid())
- return false;
-
- if (m_match_info.GroupIDIsValid())
- return false;
-
- if (m_match_info.EffectiveUserIDIsValid())
- return false;
-
- if (m_match_info.EffectiveGroupIDIsValid())
- return false;
-
- if (m_match_info.GetArchitecture().IsValid())
- return false;
-
- if (m_match_all_users)
- return false;
-
- return true;
-}
-
-void ProcessInstanceInfoMatch::Clear() {
- m_match_info.Clear();
- m_name_match_type = NameMatch::Ignore;
- m_match_all_users = false;
-}
-
ProcessSP Process::FindPlugin(lldb::TargetSP target_sp,
llvm::StringRef plugin_name,
ListenerSP listener_sp,
@@ -734,13 +529,13 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
m_thread_list(this), m_extended_thread_list(this),
m_extended_thread_stop_id(0), m_queue_list(this), m_queue_list_stop_id(0),
m_notifications(), m_image_tokens(), m_listener_sp(listener_sp),
- m_breakpoint_site_list(), m_dynamic_checkers_ap(),
+ m_breakpoint_site_list(), m_dynamic_checkers_up(),
m_unix_signals_sp(unix_signals_sp), m_abi_sp(), m_process_input_reader(),
m_stdio_communication("process.stdio"), m_stdio_communication_mutex(),
m_stdin_forward(false), m_stdout_data(), m_stderr_data(),
m_profile_data_comm_mutex(), m_profile_data(), m_iohandler_sync(0),
m_memory_cache(*this), m_allocated_memory_cache(*this),
- m_should_detach(false), m_next_event_action_ap(), m_public_run_lock(),
+ m_should_detach(false), m_next_event_action_up(), m_public_run_lock(),
m_private_run_lock(), m_finalizing(false), m_finalize_called(false),
m_clear_thread_plans_on_stop(false), m_force_next_event_delivery(false),
m_last_broadcast_state(eStateInvalid), m_destroy_in_process(false),
@@ -848,12 +643,12 @@ void Process::Finalize() {
// We need to destroy the loader before the derived Process class gets
// destroyed since it is very likely that undoing the loader will require
// access to the real process.
- m_dynamic_checkers_ap.reset();
+ m_dynamic_checkers_up.reset();
m_abi_sp.reset();
- m_os_ap.reset();
- m_system_runtime_ap.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
+ m_os_up.reset();
+ m_system_runtime_up.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
m_thread_list_real.Destroy();
m_thread_list.Destroy();
m_extended_thread_list.Destroy();
@@ -864,9 +659,12 @@ void Process::Finalize() {
m_image_tokens.clear();
m_memory_cache.Clear();
m_allocated_memory_cache.Clear();
- m_language_runtimes.clear();
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ m_language_runtimes.clear();
+ }
m_instrumentation_runtimes.clear();
- m_next_event_action_ap.reset();
+ m_next_event_action_up.reset();
// Clear the last natural stop ID since it has a strong reference to this
// process
m_mod_id.SetStopEventForLastNaturalStopID(EventSP());
@@ -1506,12 +1304,12 @@ void Process::UpdateThreadListIfNeeded() {
}
void Process::UpdateQueueListIfNeeded() {
- if (m_system_runtime_ap) {
+ if (m_system_runtime_up) {
if (m_queue_list.GetSize() == 0 ||
m_queue_list_stop_id != GetLastNaturalStopID()) {
const StateType state = GetPrivateState();
if (StateIsStoppedState(state, true)) {
- m_system_runtime_ap->PopulateQueueList(m_queue_list);
+ m_system_runtime_up->PopulateQueueList(m_queue_list);
m_queue_list_stop_id = GetLastNaturalStopID();
}
}
@@ -1552,16 +1350,6 @@ StateType Process::GetState() {
return m_public_state.GetValue();
}
-bool Process::StateChangedIsExternallyHijacked() {
- if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
- const char *hijacking_name = GetHijackingListenerName();
- if (hijacking_name &&
- strcmp(hijacking_name, "lldb.Process.ResumeSynchronous.hijack"))
- return true;
- }
- return false;
-}
-
void Process::SetPublicState(StateType new_state, bool restarted) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
@@ -1615,6 +1403,8 @@ Status Process::Resume() {
return error;
}
+static const char *g_resume_sync_name = "lldb.Process.ResumeSynchronous.hijack";
+
Status Process::ResumeSynchronous(Stream *stream) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_STATE |
LIBLLDB_LOG_PROCESS));
@@ -1628,13 +1418,13 @@ Status Process::ResumeSynchronous(Stream *stream) {
}
ListenerSP listener_sp(
- Listener::MakeListener("lldb.Process.ResumeSynchronous.hijack"));
+ Listener::MakeListener(g_resume_sync_name));
HijackProcessEvents(listener_sp);
Status error = PrivateResume();
if (error.Success()) {
StateType state =
- WaitForProcessToStop(llvm::None, NULL, true, listener_sp, stream);
+ WaitForProcessToStop(llvm::None, nullptr, true, listener_sp, stream);
const bool must_be_alive =
false; // eStateExited is ok, so this must be false
if (!StateIsStoppedState(state, must_be_alive))
@@ -1652,6 +1442,26 @@ Status Process::ResumeSynchronous(Stream *stream) {
return error;
}
+bool Process::StateChangedIsExternallyHijacked() {
+ if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
+ const char *hijacking_name = GetHijackingListenerName();
+ if (hijacking_name &&
+ strcmp(hijacking_name, g_resume_sync_name))
+ return true;
+ }
+ return false;
+}
+
+bool Process::StateChangedIsHijackedForSynchronousResume() {
+ if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
+ const char *hijacking_name = GetHijackingListenerName();
+ if (hijacking_name &&
+ strcmp(hijacking_name, g_resume_sync_name) == 0)
+ return true;
+ }
+ return false;
+}
+
StateType Process::GetPrivateState() { return m_private_state.GetValue(); }
void Process::SetPrivateState(StateType new_state) {
@@ -1736,38 +1546,54 @@ const lldb::ABISP &Process::GetABI() {
return m_abi_sp;
}
+std::vector<LanguageRuntime *>
+Process::GetLanguageRuntimes(bool retry_if_null) {
+ std::vector<LanguageRuntime *> language_runtimes;
+
+ if (m_finalizing)
+ return language_runtimes;
+
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ // Before we pass off a copy of the language runtimes, we must make sure that
+ // our collection is properly populated. It's possible that some of the
+ // language runtimes were not loaded yet, either because nobody requested it
+ // yet or the proper condition for loading wasn't yet met (e.g. libc++.so
+ // hadn't been loaded).
+ for (const lldb::LanguageType lang_type : Language::GetSupportedLanguages()) {
+ if (LanguageRuntime *runtime = GetLanguageRuntime(lang_type, retry_if_null))
+ language_runtimes.emplace_back(runtime);
+ }
+
+ return language_runtimes;
+}
+
LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language,
bool retry_if_null) {
if (m_finalizing)
return nullptr;
+ LanguageRuntime *runtime = nullptr;
+
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntimeCollection::iterator pos;
pos = m_language_runtimes.find(language);
- if (pos == m_language_runtimes.end() || (retry_if_null && !(*pos).second)) {
+ if (pos == m_language_runtimes.end() || (retry_if_null && !pos->second)) {
lldb::LanguageRuntimeSP runtime_sp(
LanguageRuntime::FindPlugin(this, language));
m_language_runtimes[language] = runtime_sp;
- return runtime_sp.get();
+ runtime = runtime_sp.get();
} else
- return (*pos).second.get();
-}
+ runtime = pos->second.get();
-CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
- LanguageRuntime *runtime =
- GetLanguageRuntime(eLanguageTypeC_plus_plus, retry_if_null);
- if (runtime != nullptr &&
- runtime->GetLanguageType() == eLanguageTypeC_plus_plus)
- return static_cast<CPPLanguageRuntime *>(runtime);
- return nullptr;
-}
+ if (runtime)
+ // It's possible that a language runtime can support multiple LanguageTypes,
+ // for example, CPPLanguageRuntime will support eLanguageTypeC_plus_plus,
+ // eLanguageTypeC_plus_plus_03, etc. Because of this, we should get the
+ // primary language type and make sure that our runtime supports it.
+ assert(runtime->GetLanguageType() == Language::GetPrimaryLanguage(language));
-ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
- LanguageRuntime *runtime =
- GetLanguageRuntime(eLanguageTypeObjC, retry_if_null);
- if (runtime != nullptr && runtime->GetLanguageType() == eLanguageTypeObjC)
- return static_cast<ObjCLanguageRuntime *>(runtime);
- return nullptr;
+ return runtime;
}
bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
@@ -1783,16 +1609,16 @@ bool Process::IsPossibleDynamicValue(ValueObject &in_value) {
return runtime ? runtime->CouldHaveDynamicValue(in_value) : false;
}
- LanguageRuntime *cpp_runtime = GetLanguageRuntime(eLanguageTypeC_plus_plus);
- if (cpp_runtime && cpp_runtime->CouldHaveDynamicValue(in_value))
- return true;
+ for (LanguageRuntime *runtime : GetLanguageRuntimes()) {
+ if (runtime->CouldHaveDynamicValue(in_value))
+ return true;
+ }
- LanguageRuntime *objc_runtime = GetLanguageRuntime(eLanguageTypeObjC);
- return objc_runtime ? objc_runtime->CouldHaveDynamicValue(in_value) : false;
+ return false;
}
void Process::SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers) {
- m_dynamic_checkers_ap.reset(dynamic_checkers);
+ m_dynamic_checkers_up.reset(dynamic_checkers);
}
BreakpointSiteList &Process::GetBreakpointSiteList() {
@@ -2413,67 +2239,64 @@ size_t Process::WriteMemory(addr_t addr, const void *buf, size_t size,
// may have placed in our tasks memory.
BreakpointSiteList bp_sites_in_range;
+ if (!m_breakpoint_site_list.FindInRange(addr, addr + size, bp_sites_in_range))
+ return WriteMemoryPrivate(addr, buf, size, error);
- if (m_breakpoint_site_list.FindInRange(addr, addr + size,
- bp_sites_in_range)) {
- // No breakpoint sites overlap
- if (bp_sites_in_range.IsEmpty())
- return WriteMemoryPrivate(addr, buf, size, error);
- else {
- const uint8_t *ubuf = (const uint8_t *)buf;
- uint64_t bytes_written = 0;
+ // No breakpoint sites overlap
+ if (bp_sites_in_range.IsEmpty())
+ return WriteMemoryPrivate(addr, buf, size, error);
- bp_sites_in_range.ForEach([this, addr, size, &bytes_written, &ubuf,
- &error](BreakpointSite *bp) -> void {
+ const uint8_t *ubuf = (const uint8_t *)buf;
+ uint64_t bytes_written = 0;
- if (error.Success()) {
- addr_t intersect_addr;
- size_t intersect_size;
- size_t opcode_offset;
- const bool intersects = bp->IntersectsRange(
- addr, size, &intersect_addr, &intersect_size, &opcode_offset);
- UNUSED_IF_ASSERT_DISABLED(intersects);
- assert(intersects);
- assert(addr <= intersect_addr && intersect_addr < addr + size);
- assert(addr < intersect_addr + intersect_size &&
- intersect_addr + intersect_size <= addr + size);
- assert(opcode_offset + intersect_size <= bp->GetByteSize());
-
- // Check for bytes before this breakpoint
- const addr_t curr_addr = addr + bytes_written;
- if (intersect_addr > curr_addr) {
- // There are some bytes before this breakpoint that we need to just
- // write to memory
- size_t curr_size = intersect_addr - curr_addr;
- size_t curr_bytes_written = WriteMemoryPrivate(
- curr_addr, ubuf + bytes_written, curr_size, error);
- bytes_written += curr_bytes_written;
- if (curr_bytes_written != curr_size) {
- // We weren't able to write all of the requested bytes, we are
- // done looping and will return the number of bytes that we have
- // written so far.
- if (error.Success())
- error.SetErrorToGenericError();
- }
- }
- // Now write any bytes that would cover up any software breakpoints
- // directly into the breakpoint opcode buffer
- ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset,
- ubuf + bytes_written, intersect_size);
- bytes_written += intersect_size;
- }
- });
+ bp_sites_in_range.ForEach([this, addr, size, &bytes_written, &ubuf,
+ &error](BreakpointSite *bp) -> void {
+ if (error.Fail())
+ return;
- if (bytes_written < size)
- WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
- size - bytes_written, error);
+ addr_t intersect_addr;
+ size_t intersect_size;
+ size_t opcode_offset;
+ const bool intersects = bp->IntersectsRange(
+ addr, size, &intersect_addr, &intersect_size, &opcode_offset);
+ UNUSED_IF_ASSERT_DISABLED(intersects);
+ assert(intersects);
+ assert(addr <= intersect_addr && intersect_addr < addr + size);
+ assert(addr < intersect_addr + intersect_size &&
+ intersect_addr + intersect_size <= addr + size);
+ assert(opcode_offset + intersect_size <= bp->GetByteSize());
+
+ // Check for bytes before this breakpoint
+ const addr_t curr_addr = addr + bytes_written;
+ if (intersect_addr > curr_addr) {
+ // There are some bytes before this breakpoint that we need to just
+ // write to memory
+ size_t curr_size = intersect_addr - curr_addr;
+ size_t curr_bytes_written =
+ WriteMemoryPrivate(curr_addr, ubuf + bytes_written, curr_size, error);
+ bytes_written += curr_bytes_written;
+ if (curr_bytes_written != curr_size) {
+ // We weren't able to write all of the requested bytes, we are
+ // done looping and will return the number of bytes that we have
+ // written so far.
+ if (error.Success())
+ error.SetErrorToGenericError();
+ }
}
- } else {
- return WriteMemoryPrivate(addr, buf, size, error);
- }
+ // Now write any bytes that would cover up any software breakpoints
+ // directly into the breakpoint opcode buffer
+ ::memcpy(bp->GetSavedOpcodeBytes() + opcode_offset, ubuf + bytes_written,
+ intersect_size);
+ bytes_written += intersect_size;
+ });
// Write any remaining bytes after the last breakpoint if we have any left
- return 0; // bytes_written;
+ if (bytes_written < size)
+ bytes_written +=
+ WriteMemoryPrivate(addr + bytes_written, ubuf + bytes_written,
+ size - bytes_written, error);
+
+ return bytes_written;
}
size_t Process::WriteScalarToMemory(addr_t addr, const Scalar &scalar,
@@ -2708,7 +2531,7 @@ Process::WaitForProcessStopPrivate(EventSP &event_sp,
void Process::LoadOperatingSystemPlugin(bool flush) {
if (flush)
m_thread_list.Clear();
- m_os_ap.reset(OperatingSystem::FindPlugin(this, nullptr));
+ m_os_up.reset(OperatingSystem::FindPlugin(this, nullptr));
if (flush)
Flush();
}
@@ -2716,115 +2539,119 @@ void Process::LoadOperatingSystemPlugin(bool flush) {
Status Process::Launch(ProcessLaunchInfo &launch_info) {
Status error;
m_abi_sp.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
- m_system_runtime_ap.reset();
- m_os_ap.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
+ m_system_runtime_up.reset();
+ m_os_up.reset();
m_process_input_reader.reset();
Module *exe_module = GetTarget().GetExecutableModulePointer();
- if (exe_module) {
- char local_exec_file_path[PATH_MAX];
- char platform_exec_file_path[PATH_MAX];
- exe_module->GetFileSpec().GetPath(local_exec_file_path,
- sizeof(local_exec_file_path));
- exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
- sizeof(platform_exec_file_path));
- if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
- // Install anything that might need to be installed prior to launching.
- // For host systems, this will do nothing, but if we are connected to a
- // remote platform it will install any needed binaries
- error = GetTarget().Install(&launch_info);
- if (error.Fail())
- return error;
+ if (!exe_module) {
+ error.SetErrorString("executable module does not exist");
+ return error;
+ }
- if (PrivateStateThreadIsValid())
- PausePrivateStateThread();
+ char local_exec_file_path[PATH_MAX];
+ char platform_exec_file_path[PATH_MAX];
+ exe_module->GetFileSpec().GetPath(local_exec_file_path,
+ sizeof(local_exec_file_path));
+ exe_module->GetPlatformFileSpec().GetPath(platform_exec_file_path,
+ sizeof(platform_exec_file_path));
+ if (FileSystem::Instance().Exists(exe_module->GetFileSpec())) {
+ // Install anything that might need to be installed prior to launching.
+ // For host systems, this will do nothing, but if we are connected to a
+ // remote platform it will install any needed binaries
+ error = GetTarget().Install(&launch_info);
+ if (error.Fail())
+ return error;
- error = WillLaunch(exe_module);
- if (error.Success()) {
- const bool restarted = false;
- SetPublicState(eStateLaunching, restarted);
- m_should_detach = false;
+ if (PrivateStateThreadIsValid())
+ PausePrivateStateThread();
- if (m_public_run_lock.TrySetRunning()) {
- // Now launch using these arguments.
- error = DoLaunch(exe_module, launch_info);
- } else {
- // This shouldn't happen
- error.SetErrorString("failed to acquire process run lock");
+ error = WillLaunch(exe_module);
+ if (error.Success()) {
+ const bool restarted = false;
+ SetPublicState(eStateLaunching, restarted);
+ m_should_detach = false;
+
+ if (m_public_run_lock.TrySetRunning()) {
+ // Now launch using these arguments.
+ error = DoLaunch(exe_module, launch_info);
+ } else {
+ // This shouldn't happen
+ error.SetErrorString("failed to acquire process run lock");
+ }
+
+ if (error.Fail()) {
+ if (GetID() != LLDB_INVALID_PROCESS_ID) {
+ SetID(LLDB_INVALID_PROCESS_ID);
+ const char *error_string = error.AsCString();
+ if (error_string == nullptr)
+ error_string = "launch failed";
+ SetExitStatus(-1, error_string);
}
+ } else {
+ EventSP event_sp;
+
+ // Now wait for the process to launch and return control to us, and then
+ // call DidLaunch:
+ StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
+
+ if (state == eStateInvalid || !event_sp) {
+ // We were able to launch the process, but we failed to catch the
+ // initial stop.
+ error.SetErrorString("failed to catch stop after launch");
+ SetExitStatus(0, "failed to catch stop after launch");
+ Destroy(false);
+ } else if (state == eStateStopped || state == eStateCrashed) {
+ DidLaunch();
+
+ DynamicLoader *dyld = GetDynamicLoader();
+ if (dyld)
+ dyld->DidLaunch();
+
+ GetJITLoaders().DidLaunch();
+
+ SystemRuntime *system_runtime = GetSystemRuntime();
+ if (system_runtime)
+ system_runtime->DidLaunch();
+
+ if (!m_os_up)
+ LoadOperatingSystemPlugin(false);
+
+ // We successfully launched the process and stopped, now it the
+ // right time to set up signal filters before resuming.
+ UpdateAutomaticSignalFiltering();
+
+ // Note, the stop event was consumed above, but not handled. This
+ // was done to give DidLaunch a chance to run. The target is either
+ // stopped or crashed. Directly set the state. This is done to
+ // prevent a stop message with a bunch of spurious output on thread
+ // status, as well as not pop a ProcessIOHandler.
+ SetPublicState(state, false);
+
+ if (PrivateStateThreadIsValid())
+ ResumePrivateStateThread();
+ else
+ StartPrivateStateThread();
- if (error.Fail()) {
- if (GetID() != LLDB_INVALID_PROCESS_ID) {
- SetID(LLDB_INVALID_PROCESS_ID);
- const char *error_string = error.AsCString();
- if (error_string == nullptr)
- error_string = "launch failed";
- SetExitStatus(-1, error_string);
- }
- } else {
- EventSP event_sp;
-
- // Now wait for the process to launch and return control to us, and then call
- // DidLaunch:
- StateType state = WaitForProcessStopPrivate(event_sp, seconds(10));
-
- if (state == eStateInvalid || !event_sp) {
- // We were able to launch the process, but we failed to catch the
- // initial stop.
- error.SetErrorString("failed to catch stop after launch");
- SetExitStatus(0, "failed to catch stop after launch");
- Destroy(false);
- } else if (state == eStateStopped || state == eStateCrashed) {
- DidLaunch();
-
- DynamicLoader *dyld = GetDynamicLoader();
- if (dyld)
- dyld->DidLaunch();
-
- GetJITLoaders().DidLaunch();
-
- SystemRuntime *system_runtime = GetSystemRuntime();
- if (system_runtime)
- system_runtime->DidLaunch();
-
- if (!m_os_ap)
- LoadOperatingSystemPlugin(false);
-
- // We successfully launched the process and stopped, now it the
- // right time to set up signal filters before resuming.
- UpdateAutomaticSignalFiltering();
-
- // Note, the stop event was consumed above, but not handled. This
- // was done to give DidLaunch a chance to run. The target is either
- // stopped or crashed. Directly set the state. This is done to
- // prevent a stop message with a bunch of spurious output on thread
- // status, as well as not pop a ProcessIOHandler.
- SetPublicState(state, false);
-
- if (PrivateStateThreadIsValid())
- ResumePrivateStateThread();
- else
- StartPrivateStateThread();
-
- // Target was stopped at entry as was intended. Need to notify the
- // listeners about it.
- if (state == eStateStopped &&
- launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
- HandlePrivateEvent(event_sp);
- } else if (state == eStateExited) {
- // We exited while trying to launch somehow. Don't call DidLaunch
- // as that's not likely to work, and return an invalid pid.
+ // Target was stopped at entry as was intended. Need to notify the
+ // listeners about it.
+ if (state == eStateStopped &&
+ launch_info.GetFlags().Test(eLaunchFlagStopAtEntry))
HandlePrivateEvent(event_sp);
- }
+ } else if (state == eStateExited) {
+ // We exited while trying to launch somehow. Don't call DidLaunch
+ // as that's not likely to work, and return an invalid pid.
+ HandlePrivateEvent(event_sp);
}
}
- } else {
- error.SetErrorStringWithFormat("file doesn't exist: '%s'",
- local_exec_file_path);
}
+ } else {
+ error.SetErrorStringWithFormat("file doesn't exist: '%s'",
+ local_exec_file_path);
}
+
return error;
}
@@ -2850,7 +2677,7 @@ Status Process::LoadCore() {
if (system_runtime)
system_runtime->DidAttach();
- if (!m_os_ap)
+ if (!m_os_up)
LoadOperatingSystemPlugin(false);
// We successfully loaded a core file, now pretend we stopped so we can
@@ -2860,7 +2687,7 @@ Status Process::LoadCore() {
// Wait for a stopped event since we just posted one above...
lldb::EventSP event_sp;
StateType state =
- WaitForProcessToStop(seconds(10), &event_sp, true, listener_sp);
+ WaitForProcessToStop(llvm::None, &event_sp, true, listener_sp);
if (!StateIsStoppedState(state, false)) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
@@ -2876,25 +2703,25 @@ Status Process::LoadCore() {
}
DynamicLoader *Process::GetDynamicLoader() {
- if (!m_dyld_ap)
- m_dyld_ap.reset(DynamicLoader::FindPlugin(this, nullptr));
- return m_dyld_ap.get();
+ if (!m_dyld_up)
+ m_dyld_up.reset(DynamicLoader::FindPlugin(this, nullptr));
+ return m_dyld_up.get();
}
-const lldb::DataBufferSP Process::GetAuxvData() { return DataBufferSP(); }
+DataExtractor Process::GetAuxvData() { return DataExtractor(); }
JITLoaderList &Process::GetJITLoaders() {
- if (!m_jit_loaders_ap) {
- m_jit_loaders_ap.reset(new JITLoaderList());
- JITLoader::LoadPlugins(this, *m_jit_loaders_ap);
+ if (!m_jit_loaders_up) {
+ m_jit_loaders_up.reset(new JITLoaderList());
+ JITLoader::LoadPlugins(this, *m_jit_loaders_up);
}
- return *m_jit_loaders_ap;
+ return *m_jit_loaders_up;
}
SystemRuntime *Process::GetSystemRuntime() {
- if (!m_system_runtime_ap)
- m_system_runtime_ap.reset(SystemRuntime::FindPlugin(this));
- return m_system_runtime_ap.get();
+ if (!m_system_runtime_up)
+ m_system_runtime_up.reset(SystemRuntime::FindPlugin(this));
+ return m_system_runtime_up.get();
}
Process::AttachCompletionHandler::AttachCompletionHandler(Process *process,
@@ -2984,10 +2811,10 @@ ListenerSP ProcessAttachInfo::GetListenerForProcess(Debugger &debugger) {
Status Process::Attach(ProcessAttachInfo &attach_info) {
m_abi_sp.reset();
m_process_input_reader.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
- m_system_runtime_ap.reset();
- m_os_ap.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
+ m_system_runtime_up.reset();
+ m_os_up.reset();
lldb::pid_t attach_pid = attach_info.GetProcessID();
Status error;
@@ -3045,11 +2872,10 @@ Status Process::Attach(ProcessAttachInfo &attach_info) {
process_name, sizeof(process_name));
if (num_matches > 1) {
StreamString s;
- ProcessInstanceInfo::DumpTableHeader(s, platform_sp.get(), true,
- false);
+ ProcessInstanceInfo::DumpTableHeader(s, true, false);
for (size_t i = 0; i < num_matches; i++) {
process_infos.GetProcessInfoAtIndex(i).DumpAsTableRow(
- s, platform_sp.get(), true, false);
+ s, platform_sp->GetUserIDResolver(), true, false);
}
error.SetErrorStringWithFormat(
"more than one process named %s:\n%s", process_name,
@@ -3193,8 +3019,16 @@ void Process::CompleteAttach() {
}
}
- if (!m_os_ap)
+ if (!m_os_up) {
LoadOperatingSystemPlugin(false);
+ if (m_os_up) {
+ // Somebody might have gotten threads before now, but we need to force the
+ // update after we've loaded the OperatingSystem plugin or it won't get a
+ // chance to process the threads.
+ m_thread_list.Clear();
+ UpdateThreadListIfNeeded();
+ }
+ }
// Figure out which one is the executable, and set that in our target:
const ModuleList &target_modules = GetTarget().GetImages();
std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
@@ -3754,14 +3588,20 @@ bool Process::StartPrivateStateThread(bool is_secondary_thread) {
// Create the private state thread, and start it running.
PrivateStateThreadArgs *args_ptr =
new PrivateStateThreadArgs(this, is_secondary_thread);
- m_private_state_thread =
+ llvm::Expected<HostThread> private_state_thread =
ThreadLauncher::LaunchThread(thread_name, Process::PrivateStateThread,
- (void *)args_ptr, nullptr, 8 * 1024 * 1024);
- if (m_private_state_thread.IsJoinable()) {
- ResumePrivateStateThread();
- return true;
- } else
+ (void *)args_ptr, 8 * 1024 * 1024);
+ if (!private_state_thread) {
+ LLDB_LOG(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST),
+ "failed to launch host thread: {}",
+ llvm::toString(private_state_thread.takeError()));
return false;
+ }
+
+ assert(private_state_thread->IsJoinable());
+ m_private_state_thread = *private_state_thread;
+ ResumePrivateStateThread();
+ return true;
}
void Process::PausePrivateStateThread() {
@@ -3810,10 +3650,10 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
bool receipt_received = false;
if (PrivateStateThreadIsValid()) {
while (!receipt_received) {
- // Check for a receipt for 2 seconds and then check if the private
+ // Check for a receipt for n seconds and then check if the private
// state thread is still around.
receipt_received =
- event_receipt_sp->WaitForEventReceived(std::chrono::seconds(2));
+ event_receipt_sp->WaitForEventReceived(GetUtilityExpressionTimeout());
if (!receipt_received) {
// Check if the private state thread is still around. If it isn't
// then we are done waiting
@@ -3824,7 +3664,7 @@ void Process::ControlPrivateStateThread(uint32_t signal) {
}
if (signal == eBroadcastInternalStateControlStop) {
- thread_result_t result = NULL;
+ thread_result_t result = {};
m_private_state_thread.Join(&result);
m_private_state_thread.Reset();
}
@@ -3851,9 +3691,9 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
Process::ProcessEventData::GetStateFromEvent(event_sp.get());
// First check to see if anybody wants a shot at this event:
- if (m_next_event_action_ap) {
+ if (m_next_event_action_up) {
NextEventAction::EventActionResult action_result =
- m_next_event_action_ap->PerformAction(event_sp);
+ m_next_event_action_up->PerformAction(event_sp);
if (log)
log->Printf("Ran next event action, result was %d.", action_result);
@@ -3871,7 +3711,7 @@ void Process::HandlePrivateEvent(EventSP &event_sp) {
// to exit so the next event will kill us.
if (new_state != eStateExited) {
// FIXME: should cons up an exited event, and discard this one.
- SetExitStatus(0, m_next_event_action_ap->GetExitString());
+ SetExitStatus(0, m_next_event_action_up->GetExitString());
SetNextEventAction(nullptr);
return;
}
@@ -4099,12 +3939,10 @@ thread_result_t Process::RunPrivateStateThread(bool is_secondary_thread) {
// it was doing yet, so don't try to change it on the way out.
if (!is_secondary_thread)
m_public_run_lock.SetStopped();
- return NULL;
+ return {};
}
-//------------------------------------------------------------------
// Process Event Data
-//------------------------------------------------------------------
Process::ProcessEventData::ProcessEventData()
: EventData(), m_process_wp(), m_state(eStateInvalid), m_restarted(false),
@@ -4120,12 +3958,12 @@ Process::ProcessEventData::ProcessEventData(const ProcessSP &process_sp,
Process::ProcessEventData::~ProcessEventData() = default;
-const ConstString &Process::ProcessEventData::GetFlavorString() {
+ConstString Process::ProcessEventData::GetFlavorString() {
static ConstString g_flavor("Process::ProcessEventData");
return g_flavor;
}
-const ConstString &Process::ProcessEventData::GetFlavor() const {
+ConstString Process::ProcessEventData::GetFlavor() const {
return ProcessEventData::GetFlavorString();
}
@@ -4260,15 +4098,24 @@ void Process::ProcessEventData::DoOnRemoval(Event *event_ptr) {
// public resume.
process_sp->PrivateResume();
} else {
- // If we didn't restart, run the Stop Hooks here: They might also
- // restart the target, so watch for that.
- process_sp->GetTarget().RunStopHooks();
- if (process_sp->GetPrivateState() == eStateRunning)
- SetRestarted(true);
+ bool hijacked =
+ process_sp->IsHijackedForEvent(eBroadcastBitStateChanged) &&
+ !process_sp->StateChangedIsHijackedForSynchronousResume();
+
+ if (!hijacked) {
+ // If we didn't restart, run the Stop Hooks here.
+ // Don't do that if state changed events aren't hooked up to the
+ // public (or SyncResume) broadcasters. StopHooks are just for
+ // real public stops. They might also restart the target,
+ // so watch for that.
+ process_sp->GetTarget().RunStopHooks();
+ if (process_sp->GetPrivateState() == eStateRunning)
+ SetRestarted(true);
}
}
}
}
+}
void Process::ProcessEventData::Dump(Stream *s) const {
ProcessSP process_sp(m_process_wp.lock());
@@ -4439,7 +4286,7 @@ void Process::BroadcastStructuredData(const StructuredData::ObjectSP &object_sp,
}
StructuredDataPluginSP
-Process::GetStructuredDataPlugin(const ConstString &type_name) const {
+Process::GetStructuredDataPlugin(ConstString type_name) const {
auto find_it = m_structured_data_plugin_map.find(type_name);
if (find_it != m_structured_data_plugin_map.end())
return find_it->second;
@@ -4471,9 +4318,7 @@ size_t Process::GetAsyncProfileData(char *buf, size_t buf_size, Status &error) {
return bytes_available;
}
-//------------------------------------------------------------------
// Process STDIO
-//------------------------------------------------------------------
size_t Process::GetSTDOUT(char *buf, size_t buf_size, Status &error) {
std::lock_guard<std::recursive_mutex> guard(m_stdio_communication_mutex);
@@ -4658,11 +4503,11 @@ protected:
void Process::SetSTDIOFileDescriptor(int fd) {
// First set up the Read Thread for reading/handling process I/O
- std::unique_ptr<ConnectionFileDescriptor> conn_ap(
+ std::unique_ptr<ConnectionFileDescriptor> conn_up(
new ConnectionFileDescriptor(fd, true));
- if (conn_ap) {
- m_stdio_communication.SetConnection(conn_ap.release());
+ if (conn_up) {
+ m_stdio_communication.SetConnection(conn_up.release());
if (m_stdio_communication.IsConnected()) {
m_stdio_communication.SetReadThreadBytesReceivedCallback(
STDIOReadThreadBytesReceived, this);
@@ -4671,7 +4516,8 @@ void Process::SetSTDIOFileDescriptor(int fd) {
// Now read thread is set up, set up input reader.
if (!m_process_input_reader)
- m_process_input_reader.reset(new IOHandlerProcessSTDIO(this, fd));
+ m_process_input_reader =
+ std::make_shared<IOHandlerProcessSTDIO>(this, fd);
}
}
}
@@ -5096,7 +4942,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
}
got_event =
- listener_sp->GetEvent(event_sp, std::chrono::milliseconds(500));
+ listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
if (!got_event) {
if (log)
log->Printf("Process::RunThreadPlan(): didn't get any event after "
@@ -5327,7 +5173,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
log->PutCString("Process::RunThreadPlan(): Halt succeeded.");
got_event =
- listener_sp->GetEvent(event_sp, std::chrono::milliseconds(500));
+ listener_sp->GetEvent(event_sp, GetUtilityExpressionTimeout());
if (got_event) {
stop_state =
@@ -5530,7 +5376,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx,
event_explanation = ts.GetData();
}
- } while (0);
+ } while (false);
if (event_explanation)
log->Printf("Process::RunThreadPlan(): execution interrupted: %s %s",
@@ -5782,15 +5628,18 @@ void Process::DidExec() {
Target &target = GetTarget();
target.CleanupProcess();
target.ClearModules(false);
- m_dynamic_checkers_ap.reset();
+ m_dynamic_checkers_up.reset();
m_abi_sp.reset();
- m_system_runtime_ap.reset();
- m_os_ap.reset();
- m_dyld_ap.reset();
- m_jit_loaders_ap.reset();
+ m_system_runtime_up.reset();
+ m_os_up.reset();
+ m_dyld_up.reset();
+ m_jit_loaders_up.reset();
m_image_tokens.clear();
m_allocated_memory_cache.Clear();
- m_language_runtimes.clear();
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ m_language_runtimes.clear();
+ }
m_instrumentation_runtimes.clear();
m_thread_list.DiscardThreadPlans();
m_memory_cache.Clear(true);
@@ -5859,19 +5708,22 @@ void Process::ModulesDidLoad(ModuleList &module_list) {
// Iterate over a copy of this language runtime list in case the language
// runtime ModulesDidLoad somehow causes the language runtime to be
// unloaded.
- LanguageRuntimeCollection language_runtimes(m_language_runtimes);
- for (const auto &pair : language_runtimes) {
- // We must check language_runtime_sp to make sure it is not nullptr as we
- // might cache the fact that we didn't have a language runtime for a
- // language.
- LanguageRuntimeSP language_runtime_sp = pair.second;
- if (language_runtime_sp)
- language_runtime_sp->ModulesDidLoad(module_list);
+ {
+ std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
+ LanguageRuntimeCollection language_runtimes(m_language_runtimes);
+ for (const auto &pair : language_runtimes) {
+ // We must check language_runtime_sp to make sure it is not nullptr as we
+ // might cache the fact that we didn't have a language runtime for a
+ // language.
+ LanguageRuntimeSP language_runtime_sp = pair.second;
+ if (language_runtime_sp)
+ language_runtime_sp->ModulesDidLoad(module_list);
+ }
}
// If we don't have an operating system plug-in, try to load one since
// loading shared libraries might cause a new one to try and load
- if (!m_os_ap)
+ if (!m_os_up)
LoadOperatingSystemPlugin(false);
// Give structured-data plugins a chance to see the modified modules.
@@ -5945,7 +5797,8 @@ ThreadCollectionSP Process::GetHistoryThreads(lldb::addr_t addr) {
return threads;
}
- threads.reset(new ThreadCollection(memory_history->GetHistoryThreads(addr)));
+ threads = std::make_shared<ThreadCollection>(
+ memory_history->GetHistoryThreads(addr));
return threads;
}
@@ -6017,7 +5870,8 @@ Process::AdvanceAddressToNextBranchInstruction(Address default_stop_addr,
}
uint32_t branch_index =
- insn_list->GetIndexOfNextBranchInstruction(insn_offset, target);
+ insn_list->GetIndexOfNextBranchInstruction(insn_offset, target,
+ false /* ignore_calls*/);
if (branch_index == UINT32_MAX) {
return retval;
}
@@ -6061,7 +5915,7 @@ Process::GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) {
}
Status
-Process::ConfigureStructuredData(const ConstString &type_name,
+Process::ConfigureStructuredData(ConstString type_name,
const StructuredData::ObjectSP &config_sp) {
// If you get this, the Process-derived class needs to implement a method to
// enable an already-reported asynchronous structured data feature. See
diff --git a/source/Target/ProcessInfo.cpp b/source/Target/ProcessInfo.cpp
deleted file mode 100644
index 1ada6123fa1ea..0000000000000
--- a/source/Target/ProcessInfo.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "lldb/Target/ProcessInfo.h"
-
-#include <climits>
-
-#include "lldb/Host/PosixApi.h"
-#include "lldb/Utility/Stream.h"
-
-#include "llvm/ADT/SmallString.h"
-
-using namespace lldb;
-using namespace lldb_private;
-
-ProcessInfo::ProcessInfo()
- : m_executable(), m_arguments(), m_environment(), m_uid(UINT32_MAX),
- m_gid(UINT32_MAX), m_arch(), m_pid(LLDB_INVALID_PROCESS_ID) {}
-
-ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
- lldb::pid_t pid)
- : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX),
- m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}
-
-void ProcessInfo::Clear() {
- m_executable.Clear();
- m_arguments.Clear();
- m_environment.clear();
- m_uid = UINT32_MAX;
- m_gid = UINT32_MAX;
- m_arch.Clear();
- m_pid = LLDB_INVALID_PROCESS_ID;
-}
-
-const char *ProcessInfo::GetName() const {
- return m_executable.GetFilename().GetCString();
-}
-
-size_t ProcessInfo::GetNameLength() const {
- return m_executable.GetFilename().GetLength();
-}
-
-void ProcessInfo::Dump(Stream &s, Platform *platform) const {
- s << "Executable: " << GetName() << "\n";
- s << "Triple: ";
- m_arch.DumpTriple(s);
- s << "\n";
-
- s << "Arguments:\n";
- m_arguments.Dump(s);
-
- s.Format("Environment:\n{0}", m_environment);
-}
-
-void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,
- bool add_exe_file_as_first_arg) {
- if (exe_file) {
- m_executable = exe_file;
- if (add_exe_file_as_first_arg) {
- llvm::SmallString<128> filename;
- exe_file.GetPath(filename);
- if (!filename.empty())
- m_arguments.InsertArgumentAtIndex(0, filename);
- }
- } else {
- m_executable.Clear();
- }
-}
-
-llvm::StringRef ProcessInfo::GetArg0() const {
- return m_arg0;
-}
-
-void ProcessInfo::SetArg0(llvm::StringRef arg) {
- m_arg0 = arg;
-}
-
-void ProcessInfo::SetArguments(char const **argv,
- bool first_arg_is_executable) {
- m_arguments.SetArguments(argv);
-
- // Is the first argument the executable?
- if (first_arg_is_executable) {
- const char *first_arg = m_arguments.GetArgumentAtIndex(0);
- if (first_arg) {
- // Yes the first argument is an executable, set it as the executable in
- // the launch options. Don't resolve the file path as the path could be a
- // remote platform path
- m_executable.SetFile(first_arg, FileSpec::Style::native);
- }
- }
-}
-
-void ProcessInfo::SetArguments(const Args &args, bool first_arg_is_executable) {
- // Copy all arguments
- m_arguments = args;
-
- // Is the first argument the executable?
- if (first_arg_is_executable) {
- const char *first_arg = m_arguments.GetArgumentAtIndex(0);
- if (first_arg) {
- // Yes the first argument is an executable, set it as the executable in
- // the launch options. Don't resolve the file path as the path could be a
- // remote platform path
- m_executable.SetFile(first_arg, FileSpec::Style::native);
- }
- }
-}
diff --git a/source/Target/Queue.cpp b/source/Target/Queue.cpp
index c0683d10b1517..fc2a93dbe8993 100644
--- a/source/Target/Queue.cpp
+++ b/source/Target/Queue.cpp
@@ -1,9 +1,8 @@
//===-- Queue.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/QueueItem.cpp b/source/Target/QueueItem.cpp
index a20fa918a758e..47ff9e028fcbd 100644
--- a/source/Target/QueueItem.cpp
+++ b/source/Target/QueueItem.cpp
@@ -1,9 +1,8 @@
//===-- QueueItem.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/QueueList.cpp b/source/Target/QueueList.cpp
index ae9e7b93793b5..796825135187b 100644
--- a/source/Target/QueueList.cpp
+++ b/source/Target/QueueList.cpp
@@ -1,9 +1,8 @@
//===-- QueueList.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/RegisterContext.cpp b/source/Target/RegisterContext.cpp
index 976f9e8b45e7b..c960260f30c88 100644
--- a/source/Target/RegisterContext.cpp
+++ b/source/Target/RegisterContext.cpp
@@ -1,9 +1,8 @@
//===-- RegisterContext.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/RegisterNumber.cpp b/source/Target/RegisterNumber.cpp
index 8b01bd103395a..63b58d3582fd0 100644
--- a/source/Target/RegisterNumber.cpp
+++ b/source/Target/RegisterNumber.cpp
@@ -1,9 +1,8 @@
//===--------------------- RegisterNumber.cpp -------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/RemoteAwarePlatform.cpp b/source/Target/RemoteAwarePlatform.cpp
new file mode 100644
index 0000000000000..1704e1533e9cb
--- /dev/null
+++ b/source/Target/RemoteAwarePlatform.cpp
@@ -0,0 +1,284 @@
+//===-- RemoteAwarePlatform.cpp ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Target/RemoteAwarePlatform.h"
+#include "lldb/Host/FileCache.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostInfo.h"
+
+using namespace lldb_private;
+
+bool RemoteAwarePlatform::GetModuleSpec(const FileSpec &module_file_spec,
+ const ArchSpec &arch,
+ ModuleSpec &module_spec) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetModuleSpec(module_file_spec, arch,
+ module_spec);
+
+ return Platform::GetModuleSpec(module_file_spec, arch, module_spec);
+}
+
+Status RemoteAwarePlatform::RunShellCommand(
+ const char *command, const FileSpec &working_dir, int *status_ptr,
+ int *signo_ptr, std::string *command_output,
+ const Timeout<std::micro> &timeout) {
+ if (IsHost())
+ return Host::RunShellCommand(command, working_dir, status_ptr, signo_ptr,
+ command_output, timeout);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->RunShellCommand(
+ command, working_dir, status_ptr, signo_ptr, command_output, timeout);
+ return Status("unable to run a remote command without a platform");
+}
+
+Status RemoteAwarePlatform::MakeDirectory(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->MakeDirectory(file_spec, file_permissions);
+ return Platform::MakeDirectory(file_spec, file_permissions);
+}
+
+Status RemoteAwarePlatform::GetFilePermissions(const FileSpec &file_spec,
+ uint32_t &file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFilePermissions(file_spec,
+ file_permissions);
+ return Platform::GetFilePermissions(file_spec, file_permissions);
+}
+
+Status RemoteAwarePlatform::SetFilePermissions(const FileSpec &file_spec,
+ uint32_t file_permissions) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->SetFilePermissions(file_spec,
+ file_permissions);
+ return Platform::SetFilePermissions(file_spec, file_permissions);
+}
+
+lldb::user_id_t RemoteAwarePlatform::OpenFile(const FileSpec &file_spec,
+ uint32_t flags, uint32_t mode,
+ Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().OpenFile(file_spec, flags, mode, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->OpenFile(file_spec, flags, mode, error);
+ return Platform::OpenFile(file_spec, flags, mode, error);
+}
+
+bool RemoteAwarePlatform::CloseFile(lldb::user_id_t fd, Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().CloseFile(fd, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CloseFile(fd, error);
+ return Platform::CloseFile(fd, error);
+}
+
+uint64_t RemoteAwarePlatform::ReadFile(lldb::user_id_t fd, uint64_t offset,
+ void *dst, uint64_t dst_len,
+ Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().ReadFile(fd, offset, dst, dst_len, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ReadFile(fd, offset, dst, dst_len, error);
+ return Platform::ReadFile(fd, offset, dst, dst_len, error);
+}
+
+uint64_t RemoteAwarePlatform::WriteFile(lldb::user_id_t fd, uint64_t offset,
+ const void *src, uint64_t src_len,
+ Status &error) {
+ if (IsHost())
+ return FileCache::GetInstance().WriteFile(fd, offset, src, src_len, error);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->WriteFile(fd, offset, src, src_len, error);
+ return Platform::WriteFile(fd, offset, src, src_len, error);
+}
+
+lldb::user_id_t RemoteAwarePlatform::GetFileSize(const FileSpec &file_spec) {
+ if (IsHost()) {
+ uint64_t Size;
+ if (llvm::sys::fs::file_size(file_spec.GetPath(), Size))
+ return 0;
+ return Size;
+ }
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileSize(file_spec);
+ return Platform::GetFileSize(file_spec);
+}
+
+Status RemoteAwarePlatform::CreateSymlink(const FileSpec &src,
+ const FileSpec &dst) {
+ if (IsHost())
+ return FileSystem::Instance().Symlink(src, dst);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CreateSymlink(src, dst);
+ return Platform::CreateSymlink(src, dst);
+}
+
+bool RemoteAwarePlatform::GetFileExists(const FileSpec &file_spec) {
+ if (IsHost())
+ return FileSystem::Instance().Exists(file_spec);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileExists(file_spec);
+ return Platform::GetFileExists(file_spec);
+}
+
+Status RemoteAwarePlatform::Unlink(const FileSpec &file_spec) {
+ if (IsHost())
+ return llvm::sys::fs::remove(file_spec.GetPath());
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->Unlink(file_spec);
+ return Platform::Unlink(file_spec);
+}
+
+bool RemoteAwarePlatform::CalculateMD5(const FileSpec &file_spec, uint64_t &low,
+ uint64_t &high) {
+ if (IsHost())
+ return Platform::CalculateMD5(file_spec, low, high);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->CalculateMD5(file_spec, low, high);
+ return false;
+}
+
+FileSpec RemoteAwarePlatform::GetRemoteWorkingDirectory() {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteWorkingDirectory();
+ return Platform::GetRemoteWorkingDirectory();
+}
+
+bool RemoteAwarePlatform::SetRemoteWorkingDirectory(
+ const FileSpec &working_dir) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->SetRemoteWorkingDirectory(working_dir);
+ return Platform::SetRemoteWorkingDirectory(working_dir);
+}
+
+Status RemoteAwarePlatform::GetFileWithUUID(const FileSpec &platform_file,
+ const UUID *uuid_ptr,
+ FileSpec &local_file) {
+ if (IsRemote() && m_remote_platform_sp)
+ return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+ local_file);
+
+ // Default to the local case
+ local_file = platform_file;
+ return Status();
+}
+
+bool RemoteAwarePlatform::GetRemoteOSVersion() {
+ if (m_remote_platform_sp) {
+ m_os_version = m_remote_platform_sp->GetOSVersion();
+ return !m_os_version.empty();
+ }
+ return false;
+}
+
+bool RemoteAwarePlatform::GetRemoteOSBuildString(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSBuildString(s);
+ s.clear();
+ return false;
+}
+
+bool RemoteAwarePlatform::GetRemoteOSKernelDescription(std::string &s) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteOSKernelDescription(s);
+ s.clear();
+ return false;
+}
+
+ArchSpec RemoteAwarePlatform::GetRemoteSystemArchitecture() {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetRemoteSystemArchitecture();
+ return ArchSpec();
+}
+
+const char *RemoteAwarePlatform::GetHostname() {
+ if (IsHost())
+ return Platform::GetHostname();
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetHostname();
+ return nullptr;
+}
+
+UserIDResolver &RemoteAwarePlatform::GetUserIDResolver() {
+ if (IsHost())
+ return HostInfo::GetUserIDResolver();
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetUserIDResolver();
+ return UserIDResolver::GetNoopResolver();
+}
+
+Environment RemoteAwarePlatform::GetEnvironment() {
+ if (IsRemote()) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetEnvironment();
+ return Environment();
+ }
+ return Host::GetEnvironment();
+}
+
+bool RemoteAwarePlatform::IsConnected() const {
+ if (IsHost())
+ return true;
+ else if (m_remote_platform_sp)
+ return m_remote_platform_sp->IsConnected();
+ return false;
+}
+
+bool RemoteAwarePlatform::GetProcessInfo(lldb::pid_t pid,
+ ProcessInstanceInfo &process_info) {
+ if (IsHost())
+ return Platform::GetProcessInfo(pid, process_info);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->GetProcessInfo(pid, process_info);
+ return false;
+}
+
+uint32_t
+RemoteAwarePlatform::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+ ProcessInstanceInfoList &process_infos) {
+ if (IsHost())
+ return Platform::FindProcesses(match_info, process_infos);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->FindProcesses(match_info, process_infos);
+ return 0;
+}
+
+lldb::ProcessSP RemoteAwarePlatform::ConnectProcess(llvm::StringRef connect_url,
+ llvm::StringRef plugin_name,
+ Debugger &debugger,
+ Target *target,
+ Status &error) {
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->ConnectProcess(connect_url, plugin_name,
+ debugger, target, error);
+ return Platform::ConnectProcess(connect_url, plugin_name, debugger, target,
+ error);
+}
+
+Status RemoteAwarePlatform::LaunchProcess(ProcessLaunchInfo &launch_info) {
+ Status error;
+
+ if (IsHost()) {
+ error = Platform::LaunchProcess(launch_info);
+ } else {
+ if (m_remote_platform_sp)
+ error = m_remote_platform_sp->LaunchProcess(launch_info);
+ else
+ error.SetErrorString("the platform is not currently connected");
+ }
+ return error;
+}
+
+Status RemoteAwarePlatform::KillProcess(const lldb::pid_t pid) {
+ if (IsHost())
+ return Platform::KillProcess(pid);
+ if (m_remote_platform_sp)
+ return m_remote_platform_sp->KillProcess(pid);
+ return Status("the platform is not currently connected");
+}
diff --git a/source/Target/SectionLoadHistory.cpp b/source/Target/SectionLoadHistory.cpp
index 1229933793ffb..ec16b58b4451c 100644
--- a/source/Target/SectionLoadHistory.cpp
+++ b/source/Target/SectionLoadHistory.cpp
@@ -1,9 +1,8 @@
//===-- SectionLoadHistory.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -81,7 +80,7 @@ SectionLoadHistory::GetSectionLoadListForStopID(uint32_t stop_id,
StopIDToSectionLoadList::reverse_iterator rpos =
m_stop_id_to_section_load_list.rbegin();
SectionLoadListSP section_load_list_sp(
- new SectionLoadList(*rpos->second.get()));
+ new SectionLoadList(*rpos->second));
m_stop_id_to_section_load_list[stop_id] = section_load_list_sp;
return section_load_list_sp.get();
}
@@ -98,7 +97,7 @@ SectionLoadList &SectionLoadHistory::GetCurrentSectionLoadList() {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
SectionLoadList *section_load_list =
GetSectionLoadListForStopID(eStopIDNow, read_only);
- assert(section_load_list != NULL);
+ assert(section_load_list != nullptr);
return *section_load_list;
}
diff --git a/source/Target/SectionLoadList.cpp b/source/Target/SectionLoadList.cpp
index ea9f7ea9911ca..598f49ca13de0 100644
--- a/source/Target/SectionLoadList.cpp
+++ b/source/Target/SectionLoadList.cpp
@@ -1,9 +1,8 @@
//===-- SectionLoadList.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,8 +27,9 @@ SectionLoadList::SectionLoadList(const SectionLoadList &rhs)
}
void SectionLoadList::operator=(const SectionLoadList &rhs) {
- std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex);
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex);
+ std::lock(m_mutex, rhs.m_mutex);
+ std::lock_guard<std::recursive_mutex> lhs_guard(m_mutex, std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.m_mutex, std::adopt_lock);
m_addr_to_sect = rhs.m_addr_to_sect;
m_sect_to_addr = rhs.m_sect_to_addr;
}
diff --git a/source/Target/StackFrame.cpp b/source/Target/StackFrame.cpp
index 3cea6444596c7..f8b22d96e16fb 100644
--- a/source/Target/StackFrame.cpp
+++ b/source/Target/StackFrame.cpp
@@ -1,9 +1,8 @@
//===-- StackFrame.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,6 +33,8 @@
#include "lldb/lldb-enumerations.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -258,12 +259,10 @@ Block *StackFrame::GetFrameBlock() {
return nullptr;
}
-//----------------------------------------------------------------------
// Get the symbol context if we already haven't done so by resolving the
// PC address as much as possible. This way when we pass around a
// StackFrame object, everyone will have as much information as possible and no
// one will ever have to look things up manually.
-//----------------------------------------------------------------------
const SymbolContext &
StackFrame::GetSymbolContext(SymbolContextItem resolve_scope) {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
@@ -423,7 +422,7 @@ VariableList *StackFrame::GetVariableList(bool get_file_globals) {
const bool get_child_variables = true;
const bool can_create = true;
const bool stop_if_child_block_is_inlined_function = true;
- m_variable_list_sp.reset(new VariableList());
+ m_variable_list_sp = std::make_shared<VariableList>();
frame_block->AppendBlockVariables(can_create, get_child_variables,
stop_if_child_block_is_inlined_function,
[](Variable *v) { return true; },
@@ -641,7 +640,12 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath(
valobj_sp = valobj_sp->Dereference(deref_error);
if (error.Fail()) {
error.SetErrorStringWithFormatv(
- "Failed to dereference sythetic value: %s", deref_error);
+ "Failed to dereference sythetic value: {0}", deref_error);
+ return ValueObjectSP();
+ }
+ // Some synthetic plug-ins fail to set the error in Dereference
+ if (!valobj_sp) {
+ error.SetErrorString("Failed to dereference sythetic value");
return ValueObjectSP();
}
expr_is_ptr = false;
@@ -1174,7 +1178,7 @@ ValueObjectSP StackFrame::TrackGlobalVariable(const VariableSP &variable_sp,
VariableList *var_list = GetVariableList(true);
// If this frame has no variables, create a new list
if (var_list == nullptr)
- m_variable_list_sp.reset(new VariableList());
+ m_variable_list_sp = std::make_shared<VariableList>();
// Add the global/static variable to this frame
m_variable_list_sp->AddVariable(variable_sp);
@@ -1447,33 +1451,31 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,
return GetValueForOffset(frame, pointee, offset);
}
-//------------------------------------------------------------------
/// Attempt to reconstruct the ValueObject for the address contained in a
/// given register plus an offset.
///
-/// @params [in] frame
+/// \params [in] frame
/// The current stack frame.
///
-/// @params [in] reg
+/// \params [in] reg
/// The register.
///
-/// @params [in] offset
+/// \params [in] offset
/// The offset from the register.
///
-/// @param [in] disassembler
+/// \param [in] disassembler
/// A disassembler containing instructions valid up to the current PC.
///
-/// @param [in] variables
+/// \param [in] variables
/// The variable list from the current frame,
///
-/// @param [in] pc
+/// \param [in] pc
/// The program counter for the instruction considered the 'user'.
///
-/// @return
+/// \return
/// A string describing the base for the ExpressionPath. This could be a
/// variable, a register value, an argument, or a function return value.
/// The ValueObject if found. If valid, it has a valid ExpressionPath.
-//------------------------------------------------------------------
lldb::ValueObjectSP DoGuessValueAt(StackFrame &frame, ConstString reg,
int64_t offset, Disassembler &disassembler,
VariableList &variables, const Address &pc) {
diff --git a/source/Target/StackFrameList.cpp b/source/Target/StackFrameList.cpp
index fc9fcec6c076d..5492dda46402d 100644
--- a/source/Target/StackFrameList.cpp
+++ b/source/Target/StackFrameList.cpp
@@ -1,9 +1,8 @@
//===-- StackFrameList.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,14 +24,14 @@
#include "lldb/Utility/Log.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include <memory>
+
//#define DEBUG_STACK_FRAMES 1
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// StackFrameList constructor
-//----------------------------------------------------------------------
StackFrameList::StackFrameList(Thread &thread,
const lldb::StackFrameListSP &prev_frames_sp,
bool show_inline_frames)
@@ -466,9 +465,9 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
pc = reg_ctx_sp->GetPC();
}
- unwind_frame_sp.reset(new StackFrame(m_thread.shared_from_this(),
- m_frames.size(), idx, reg_ctx_sp,
- cfa, pc, nullptr));
+ unwind_frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), m_frames.size(), idx, reg_ctx_sp,
+ cfa, pc, nullptr);
m_frames.push_back(unwind_frame_sp);
}
} else {
@@ -484,9 +483,9 @@ void StackFrameList::GetFramesUpTo(uint32_t end_idx) {
break;
}
const bool cfa_is_valid = true;
- unwind_frame_sp.reset(
- new StackFrame(m_thread.shared_from_this(), m_frames.size(), idx, cfa,
- cfa_is_valid, pc, StackFrame::Kind::Regular, nullptr));
+ unwind_frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), m_frames.size(), idx, cfa, cfa_is_valid,
+ pc, StackFrame::Kind::Regular, nullptr);
// Create synthetic tail call frames between the previous frame and the
// newly-found frame. The new frame's index may change after this call,
@@ -664,9 +663,9 @@ StackFrameSP StackFrameList::GetFrameAtIndex(uint32_t idx) {
addr_t pc, cfa;
if (unwinder->GetFrameInfoAtIndex(idx, cfa, pc)) {
const bool cfa_is_valid = true;
- frame_sp.reset(new StackFrame(m_thread.shared_from_this(), idx, idx,
- cfa, cfa_is_valid, pc,
- StackFrame::Kind::Regular, nullptr));
+ frame_sp = std::make_shared<StackFrame>(
+ m_thread.shared_from_this(), idx, idx, cfa, cfa_is_valid, pc,
+ StackFrame::Kind::Regular, nullptr);
Function *function =
frame_sp->GetSymbolContext(eSymbolContextFunction).function;
@@ -818,11 +817,11 @@ void StackFrameList::Clear() {
m_concrete_frames_fetched = 0;
}
-void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
+void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_up,
lldb::StackFrameListSP &prev_sp) {
std::unique_lock<std::recursive_mutex> current_lock, previous_lock;
- if (curr_ap)
- current_lock = std::unique_lock<std::recursive_mutex>(curr_ap->m_mutex);
+ if (curr_up)
+ current_lock = std::unique_lock<std::recursive_mutex>(curr_up->m_mutex);
if (prev_sp)
previous_lock = std::unique_lock<std::recursive_mutex>(prev_sp->m_mutex);
@@ -834,18 +833,18 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
else
s.PutCString("NULL");
s.PutCString("\nCurr:\n");
- if (curr_ap)
- curr_ap->Dump(&s);
+ if (curr_up)
+ curr_up->Dump(&s);
else
s.PutCString("NULL");
s.EOL();
#endif
- if (!curr_ap || curr_ap->GetNumFrames(false) == 0) {
+ if (!curr_up || curr_up->GetNumFrames(false) == 0) {
#if defined(DEBUG_STACK_FRAMES)
s.PutCString("No current frames, leave previous frames alone...\n");
#endif
- curr_ap.release();
+ curr_up.release();
return;
}
@@ -856,11 +855,11 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
// We either don't have any previous frames, or since we have more than one
// current frames it means we have all the frames and can safely replace
// our previous frames.
- prev_sp.reset(curr_ap.release());
+ prev_sp.reset(curr_up.release());
return;
}
- const uint32_t num_curr_frames = curr_ap->GetNumFrames(false);
+ const uint32_t num_curr_frames = curr_up->GetNumFrames(false);
if (num_curr_frames > 1) {
#if defined(DEBUG_STACK_FRAMES)
@@ -869,7 +868,7 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
#endif
// We have more than one current frames it means we have all the frames and
// can safely replace our previous frames.
- prev_sp.reset(curr_ap.release());
+ prev_sp.reset(curr_up.release());
#if defined(DEBUG_STACK_FRAMES)
s.PutCString("\nMerged:\n");
@@ -879,7 +878,7 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
}
StackFrameSP prev_frame_zero_sp(prev_sp->GetFrameAtIndex(0));
- StackFrameSP curr_frame_zero_sp(curr_ap->GetFrameAtIndex(0));
+ StackFrameSP curr_frame_zero_sp(curr_up->GetFrameAtIndex(0));
StackID curr_stack_id(curr_frame_zero_sp->GetStackID());
StackID prev_stack_id(prev_frame_zero_sp->GetStackID());
@@ -909,7 +908,7 @@ void StackFrameList::Merge(std::unique_ptr<StackFrameList> &curr_ap,
prev_sp->m_frames.insert(prev_sp->m_frames.begin(), curr_frame_zero_sp);
}
- curr_ap.release();
+ curr_up.release();
#if defined(DEBUG_STACK_FRAMES)
s.PutCString("\nMerged:\n");
diff --git a/source/Target/StackFrameRecognizer.cpp b/source/Target/StackFrameRecognizer.cpp
index 152f4a198e20d..567d694bf093e 100644
--- a/source/Target/StackFrameRecognizer.cpp
+++ b/source/Target/StackFrameRecognizer.cpp
@@ -1,9 +1,8 @@
//===-- StackFrameRecognizer.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,8 +17,6 @@
using namespace lldb;
using namespace lldb_private;
-#ifndef LLDB_DISABLE_PYTHON
-
class ScriptedRecognizedStackFrame : public RecognizedStackFrame {
public:
ScriptedRecognizedStackFrame(ValueObjectListSP args) {
@@ -41,16 +38,20 @@ ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) {
ValueObjectListSP args =
m_interpreter->GetRecognizedArguments(m_python_object_sp, frame);
+ auto args_synthesized = ValueObjectListSP(new ValueObjectList());
+ for (const auto o : args->GetObjects()) {
+ args_synthesized->Append(ValueObjectRecognizerSynthesizedValue::Create(
+ *o, eValueTypeVariableArgument));
+ }
- return RecognizedStackFrameSP(new ScriptedRecognizedStackFrame(args));
+ return RecognizedStackFrameSP(
+ new ScriptedRecognizedStackFrame(args_synthesized));
}
-#endif
-
class StackFrameRecognizerManagerImpl {
public:
void AddRecognizer(StackFrameRecognizerSP recognizer,
- const ConstString &module, const ConstString &symbol,
+ ConstString module, ConstString symbol,
bool first_instruction_only) {
m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(),
symbol, RegularExpressionSP(),
@@ -153,8 +154,8 @@ StackFrameRecognizerManagerImpl &GetStackFrameRecognizerManagerImpl() {
}
void StackFrameRecognizerManager::AddRecognizer(
- StackFrameRecognizerSP recognizer, const ConstString &module,
- const ConstString &symbol, bool first_instruction_only) {
+ StackFrameRecognizerSP recognizer, ConstString module,
+ ConstString symbol, bool first_instruction_only) {
GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol,
first_instruction_only);
}
diff --git a/source/Target/StackID.cpp b/source/Target/StackID.cpp
index d6640b24ad5c7..a8f6b787f4b4f 100644
--- a/source/Target/StackID.cpp
+++ b/source/Target/StackID.cpp
@@ -1,9 +1,8 @@
//===-- StackID.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Target/StopInfo.cpp b/source/Target/StopInfo.cpp
index 4e13c588b4845..6db0c2b037e9b 100644
--- a/source/Target/StopInfo.cpp
+++ b/source/Target/StopInfo.cpp
@@ -1,9 +1,8 @@
//===-- StopInfo.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -79,9 +78,7 @@ bool StopInfo::HasTargetRunSinceMe() {
return false;
}
-//----------------------------------------------------------------------
// StopInfoBreakpoint
-//----------------------------------------------------------------------
namespace lldb_private {
class StopInfoBreakpoint : public StopInfo {
@@ -576,9 +573,7 @@ private:
bool m_was_one_shot;
};
-//----------------------------------------------------------------------
// StopInfoWatchpoint
-//----------------------------------------------------------------------
class StopInfoWatchpoint : public StopInfo {
public:
@@ -913,9 +908,7 @@ private:
lldb::addr_t m_watch_hit_addr;
};
-//----------------------------------------------------------------------
// StopInfoUnixSignal
-//----------------------------------------------------------------------
class StopInfoUnixSignal : public StopInfo {
public:
@@ -990,9 +983,7 @@ public:
}
};
-//----------------------------------------------------------------------
// StopInfoTrace
-//----------------------------------------------------------------------
class StopInfoTrace : public StopInfo {
public:
@@ -1010,9 +1001,7 @@ public:
}
};
-//----------------------------------------------------------------------
// StopInfoException
-//----------------------------------------------------------------------
class StopInfoException : public StopInfo {
public:
@@ -1034,9 +1023,7 @@ public:
}
};
-//----------------------------------------------------------------------
// StopInfoThreadPlan
-//----------------------------------------------------------------------
class StopInfoThreadPlan : public StopInfo {
public:
@@ -1079,9 +1066,7 @@ private:
ExpressionVariableSP m_expression_variable_sp;
};
-//----------------------------------------------------------------------
// StopInfoExec
-//----------------------------------------------------------------------
class StopInfoExec : public StopInfo {
public:
@@ -1211,7 +1196,7 @@ StopInfo::GetCrashingDereference(StopInfoSP &stop_info_sp,
address_loc += (sizeof(address_string) - 1);
- uint64_t address = strtoull(address_loc, 0, 0);
+ uint64_t address = strtoull(address_loc, nullptr, 0);
if (crashing_address) {
*crashing_address = address;
}
diff --git a/source/Target/StructuredDataPlugin.cpp b/source/Target/StructuredDataPlugin.cpp
index fe267e5e45a04..a22902d99f7c1 100644
--- a/source/Target/StructuredDataPlugin.cpp
+++ b/source/Target/StructuredDataPlugin.cpp
@@ -1,9 +1,8 @@
//===-- StructuredDataPlugin.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,7 +23,7 @@ public:
"Parent for per-plugin structured data commands",
"plugin structured-data <plugin>") {}
- ~CommandStructuredData() {}
+ ~CommandStructuredData() override {}
};
}
@@ -33,7 +32,7 @@ StructuredDataPlugin::StructuredDataPlugin(const ProcessWP &process_wp)
StructuredDataPlugin::~StructuredDataPlugin() {}
-bool StructuredDataPlugin::GetEnabled(const ConstString &type_name) const {
+bool StructuredDataPlugin::GetEnabled(ConstString type_name) const {
// By default, plugins are always enabled. Plugin authors should override
// this if there is an enabled/disabled state for their plugin.
return true;
diff --git a/source/Target/SystemRuntime.cpp b/source/Target/SystemRuntime.cpp
index 574c01cb5ae1e..286bea09f854f 100644
--- a/source/Target/SystemRuntime.cpp
+++ b/source/Target/SystemRuntime.cpp
@@ -1,9 +1,8 @@
//===-- SystemRuntime.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,16 +20,14 @@ SystemRuntime *SystemRuntime::FindPlugin(Process *process) {
(create_callback = PluginManager::GetSystemRuntimeCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- std::unique_ptr<SystemRuntime> instance_ap(create_callback(process));
- if (instance_ap)
- return instance_ap.release();
+ std::unique_ptr<SystemRuntime> instance_up(create_callback(process));
+ if (instance_up)
+ return instance_up.release();
}
return nullptr;
}
-//----------------------------------------------------------------------
// SystemRuntime constructor
-//----------------------------------------------------------------------
SystemRuntime::SystemRuntime(Process *process)
: m_process(process), m_types() {}
diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp
index 437f92abdab3b..4941cb585c554 100644
--- a/source/Target/Target.cpp
+++ b/source/Target/Target.cpp
@@ -1,17 +1,15 @@
//===-- Target.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/Target.h"
-#include "Plugins/ExpressionParser/Clang/ClangASTSource.h"
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
-#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
+#include "lldb/Breakpoint/BreakpointPrecondition.h"
#include "lldb/Breakpoint/BreakpointResolver.h"
#include "lldb/Breakpoint/BreakpointResolverAddress.h"
#include "lldb/Breakpoint/BreakpointResolverFileLine.h"
@@ -39,12 +37,12 @@
#include "lldb/Interpreter/OptionValues.h"
#include "lldb/Interpreter/Property.h"
#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangASTImporter.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Target/Language.h"
#include "lldb/Target/LanguageRuntime.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/StackFrame.h"
@@ -58,6 +56,10 @@
#include "lldb/Utility/State.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
+
+#include "llvm/ADT/ScopeExit.h"
+
+#include <memory>
#include <mutex>
using namespace lldb;
@@ -90,7 +92,7 @@ Target::Target(Debugger &debugger, const ArchSpec &target_arch,
m_breakpoint_list(false), m_internal_breakpoint_list(true),
m_watchpoint_list(), m_process_sp(), m_search_filter_sp(),
m_image_search_paths(ImageSearchPathsChanged, this), m_ast_importer_sp(),
- m_source_manager_ap(), m_stop_hooks(), m_stop_hook_next_id(0),
+ m_source_manager_up(), m_stop_hooks(), m_stop_hook_next_id(0),
m_valid(true), m_suppress_stop_hooks(false),
m_is_dummy_target(is_dummy_target),
m_stats_storage(static_cast<int>(StatisticKind::StatisticMax))
@@ -498,12 +500,13 @@ Target::GetSearchFilterForModule(const FileSpec *containingModule) {
if (containingModule != nullptr) {
// TODO: We should look into sharing module based search filters
// across many breakpoints like we do for the simple target based one
- filter_sp.reset(
- new SearchFilterByModule(shared_from_this(), *containingModule));
+ filter_sp = std::make_shared<SearchFilterByModule>(shared_from_this(),
+ *containingModule);
} else {
if (!m_search_filter_sp)
- m_search_filter_sp.reset(
- new SearchFilterForUnconstrainedSearches(shared_from_this()));
+ m_search_filter_sp =
+ std::make_shared<SearchFilterForUnconstrainedSearches>(
+ shared_from_this());
filter_sp = m_search_filter_sp;
}
return filter_sp;
@@ -515,12 +518,13 @@ Target::GetSearchFilterForModuleList(const FileSpecList *containingModules) {
if (containingModules && containingModules->GetSize() != 0) {
// TODO: We should look into sharing module based search filters
// across many breakpoints like we do for the simple target based one
- filter_sp.reset(
- new SearchFilterByModuleList(shared_from_this(), *containingModules));
+ filter_sp = std::make_shared<SearchFilterByModuleList>(shared_from_this(),
+ *containingModules);
} else {
if (!m_search_filter_sp)
- m_search_filter_sp.reset(
- new SearchFilterForUnconstrainedSearches(shared_from_this()));
+ m_search_filter_sp =
+ std::make_shared<SearchFilterForUnconstrainedSearches>(
+ shared_from_this());
filter_sp = m_search_filter_sp;
}
return filter_sp;
@@ -537,11 +541,11 @@ SearchFilterSP Target::GetSearchFilterForModuleAndCUList(
// We could make a special "CU List only SearchFilter". Better yet was if
// these could be composable, but that will take a little reworking.
- filter_sp.reset(new SearchFilterByModuleListAndCU(
- shared_from_this(), FileSpecList(), *containingSourceFiles));
+ filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
+ shared_from_this(), FileSpecList(), *containingSourceFiles);
} else {
- filter_sp.reset(new SearchFilterByModuleListAndCU(
- shared_from_this(), *containingModules, *containingSourceFiles));
+ filter_sp = std::make_shared<SearchFilterByModuleListAndCU>(
+ shared_from_this(), *containingModules, *containingSourceFiles);
}
return filter_sp;
}
@@ -569,8 +573,7 @@ Target::CreateExceptionBreakpoint(enum lldb::LanguageType language,
BreakpointSP exc_bkpt_sp = LanguageRuntime::CreateExceptionBreakpoint(
*this, language, catch_bp, throw_bp, internal);
if (exc_bkpt_sp && additional_args) {
- Breakpoint::BreakpointPreconditionSP precondition_sp =
- exc_bkpt_sp->GetPrecondition();
+ BreakpointPreconditionSP precondition_sp = exc_bkpt_sp->GetPrecondition();
if (precondition_sp && additional_args) {
if (error)
*error = precondition_sp->ConfigurePrecondition(*additional_args);
@@ -605,19 +608,17 @@ Target::CreateScriptedBreakpoint(const llvm::StringRef class_name,
} else if (has_modules) {
filter_sp = GetSearchFilterForModuleList(containingModules);
} else {
- filter_sp.reset(new SearchFilterForUnconstrainedSearches(shared_from_this()));
+ filter_sp = std::make_shared<SearchFilterForUnconstrainedSearches>(
+ shared_from_this());
}
StructuredDataImpl *extra_args_impl = new StructuredDataImpl();
if (extra_args_sp)
extra_args_impl->SetObjectSP(extra_args_sp);
-
- BreakpointResolverSP resolver_sp(new
- BreakpointResolverScripted(nullptr, class_name,
- depth,
- extra_args_impl,
- *GetDebugger().GetCommandInterpreter()
- .GetScriptInterpreter()));
+
+ BreakpointResolverSP resolver_sp(new BreakpointResolverScripted(
+ nullptr, class_name, depth, extra_args_impl,
+ *GetDebugger().GetScriptInterpreter()));
return CreateBreakpoint(filter_sp, resolver_sp, internal, false, true);
}
@@ -697,7 +698,7 @@ void Target::AddBreakpointName(BreakpointName *bp_name) {
m_breakpoint_names.insert(std::make_pair(bp_name->GetName(), bp_name));
}
-BreakpointName *Target::FindBreakpointName(const ConstString &name,
+BreakpointName *Target::FindBreakpointName(ConstString name,
bool can_create,
Status &error)
{
@@ -722,7 +723,7 @@ BreakpointName *Target::FindBreakpointName(const ConstString &name,
}
void
-Target::DeleteBreakpointName(const ConstString &name)
+Target::DeleteBreakpointName(ConstString name)
{
BreakpointNameList::iterator iter = m_breakpoint_names.find(name);
@@ -735,7 +736,7 @@ Target::DeleteBreakpointName(const ConstString &name)
}
void Target::RemoveNameFromBreakpoint(lldb::BreakpointSP &bp_sp,
- const ConstString &name)
+ ConstString name)
{
bp_sp->RemoveName(name.AsCString());
}
@@ -848,7 +849,7 @@ WatchpointSP Target::CreateWatchpoint(lldb::addr_t addr, size_t size,
}
if (!wp_sp) {
- wp_sp.reset(new Watchpoint(*this, addr, size, type));
+ wp_sp = std::make_shared<Watchpoint>(*this, addr, size, type);
wp_sp->SetWatchpointType(kind, notify);
m_watchpoint_list.Add(wp_sp, true);
}
@@ -1025,7 +1026,7 @@ Status Target::SerializeBreakpointsToFile(const FileSpec &file,
}
if (!break_store_ptr) {
- break_store_sp.reset(new StructuredData::Array());
+ break_store_sp = std::make_shared<StructuredData::Array>();
break_store_ptr = break_store_sp.get();
}
@@ -1438,7 +1439,8 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
"Target::SetExecutableModule (executable = '%s')",
executable_sp->GetFileSpec().GetPath().c_str());
- m_images.Append(executable_sp); // The first image is our executable file
+ const bool notify = true;
+ m_images.Append(executable_sp, notify); // The first image is our executable file
// If we haven't set an architecture yet, reset our architecture based on
// what we found in the executable module.
@@ -1466,6 +1468,7 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
}
if (executable_objfile && load_dependents) {
+ ModuleList added_modules;
executable_objfile->GetDependentModules(dependent_files);
for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
FileSpec dependent_file_spec(
@@ -1478,13 +1481,16 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
platform_dependent_file_spec = dependent_file_spec;
ModuleSpec module_spec(platform_dependent_file_spec, m_arch.GetSpec());
- ModuleSP image_module_sp(GetSharedModule(module_spec));
+ ModuleSP image_module_sp(GetOrCreateModule(module_spec,
+ false /* notify */));
if (image_module_sp) {
+ added_modules.AppendIfNeeded (image_module_sp, false);
ObjectFile *objfile = image_module_sp->GetObjectFile();
if (objfile)
objfile->GetDependentModules(dependent_files);
}
}
+ ModulesDidLoad(added_modules);
}
}
}
@@ -1565,8 +1571,9 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform) {
arch_spec.GetArchitectureName(),
arch_spec.GetTriple().getTriple().c_str());
ModuleSpec module_spec(executable_sp->GetFileSpec(), other);
+ FileSpecList search_paths = GetExecutableSearchPaths();
Status error = ModuleList::GetSharedModule(module_spec, executable_sp,
- &GetExecutableSearchPaths(),
+ &search_paths,
nullptr, nullptr);
if (!error.Fail() && executable_sp) {
@@ -1602,20 +1609,19 @@ bool Target::MergeArchitecture(const ArchSpec &arch_spec) {
return false;
}
-void Target::WillClearList(const ModuleList &module_list) {}
+void Target::NotifyWillClearList(const ModuleList &module_list) {}
-void Target::ModuleAdded(const ModuleList &module_list,
+void Target::NotifyModuleAdded(const ModuleList &module_list,
const ModuleSP &module_sp) {
// A module is being added to this target for the first time
if (m_valid) {
ModuleList my_module_list;
my_module_list.Append(module_sp);
- LoadScriptingResourceForModule(module_sp, this);
ModulesDidLoad(my_module_list);
}
}
-void Target::ModuleRemoved(const ModuleList &module_list,
+void Target::NotifyModuleRemoved(const ModuleList &module_list,
const ModuleSP &module_sp) {
// A module is being removed from this target.
if (m_valid) {
@@ -1625,7 +1631,7 @@ void Target::ModuleRemoved(const ModuleList &module_list,
}
}
-void Target::ModuleUpdated(const ModuleList &module_list,
+void Target::NotifyModuleUpdated(const ModuleList &module_list,
const ModuleSP &old_module_sp,
const ModuleSP &new_module_sp) {
// A module is replacing an already added module
@@ -1637,8 +1643,18 @@ void Target::ModuleUpdated(const ModuleList &module_list,
}
}
+void Target::NotifyModulesRemoved(lldb_private::ModuleList &module_list) {
+ ModulesDidUnload (module_list, false);
+}
+
+
void Target::ModulesDidLoad(ModuleList &module_list) {
- if (m_valid && module_list.GetSize()) {
+ const size_t num_images = module_list.GetSize();
+ if (m_valid && num_images) {
+ for (size_t idx = 0; idx < num_images; ++idx) {
+ ModuleSP module_sp(module_list.GetModuleAtIndex(idx));
+ LoadScriptingResourceForModule(module_sp, this);
+ }
m_breakpoint_list.UpdateBreakpoints(module_list, true, false);
m_internal_breakpoint_list.UpdateBreakpoints(module_list, true, false);
if (m_process_sp) {
@@ -1652,11 +1668,8 @@ void Target::ModulesDidLoad(ModuleList &module_list) {
void Target::SymbolsDidLoad(ModuleList &module_list) {
if (m_valid && module_list.GetSize()) {
if (m_process_sp) {
- LanguageRuntime *runtime =
- m_process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
- if (runtime) {
- ObjCLanguageRuntime *objc_runtime = (ObjCLanguageRuntime *)runtime;
- objc_runtime->SymbolsDidLoad(module_list);
+ for (LanguageRuntime *runtime : m_process_sp->GetLanguageRuntimes()) {
+ runtime->SymbolsDidLoad(module_list);
}
}
@@ -1840,7 +1853,7 @@ size_t Target::ReadCStringFromMemory(const Address &addr, std::string &out_str,
out_str.clear();
addr_t curr_addr = addr.GetLoadAddress(this);
Address address(addr);
- while (1) {
+ while (true) {
size_t length = ReadCStringFromMemory(address, buf, sizeof(buf), error);
if (length == 0)
break;
@@ -1980,8 +1993,8 @@ bool Target::ReadPointerFromMemory(const Address &addr, bool prefer_file_cache,
return false;
}
-ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
- Status *error_ptr) {
+ModuleSP Target::GetOrCreateModule(const ModuleSpec &module_spec, bool notify,
+ Status *error_ptr) {
ModuleSP module_sp;
Status error;
@@ -1997,7 +2010,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
ModuleSP old_module_sp; // This will get filled in if we have a new version
// of the library
bool did_create_module = false;
-
+ FileSpecList search_paths = GetExecutableSearchPaths();
// If there are image search path entries, try to use them first to acquire
// a suitable image.
if (m_image_search_paths.GetSize()) {
@@ -2008,7 +2021,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
transformed_spec.GetFileSpec().GetFilename() =
module_spec.GetFileSpec().GetFilename();
error = ModuleList::GetSharedModule(transformed_spec, module_sp,
- &GetExecutableSearchPaths(),
+ &search_paths,
&old_module_sp, &did_create_module);
}
}
@@ -2025,7 +2038,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
if (module_spec.GetUUID().IsValid()) {
// We have a UUID, it is OK to check the global module list...
error = ModuleList::GetSharedModule(module_spec, module_sp,
- &GetExecutableSearchPaths(),
+ &search_paths,
&old_module_sp, &did_create_module);
}
@@ -2035,7 +2048,7 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
if (m_platform_sp) {
error = m_platform_sp->GetSharedModule(
module_spec, m_process_sp.get(), module_sp,
- &GetExecutableSearchPaths(), &old_module_sp, &did_create_module);
+ &search_paths, &old_module_sp, &did_create_module);
} else {
error.SetErrorString("no platform is currently set");
}
@@ -2114,8 +2127,9 @@ ModuleSP Target::GetSharedModule(const ModuleSpec &module_spec,
Module *old_module_ptr = old_module_sp.get();
old_module_sp.reset();
ModuleList::RemoveSharedModuleIfOrphaned(old_module_ptr);
- } else
- m_images.Append(module_sp);
+ } else {
+ m_images.Append(module_sp, notify);
+ }
} else
module_sp.reset();
}
@@ -2200,7 +2214,8 @@ Target::GetPersistentExpressionStateForLanguage(lldb::LanguageType language) {
UserExpression *Target::GetUserExpressionForLanguage(
llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language,
Expression::ResultType desired_type,
- const EvaluateExpressionOptions &options, Status &error) {
+ const EvaluateExpressionOptions &options,
+ ValueObject *ctx_obj, Status &error) {
Status type_system_error;
TypeSystem *type_system =
@@ -2216,7 +2231,7 @@ UserExpression *Target::GetUserExpressionForLanguage(
}
user_expr = type_system->GetUserExpression(expr, prefix, language,
- desired_type, options);
+ desired_type, options, ctx_obj);
if (!user_expr)
error.SetErrorStringWithFormat(
"Could not create an expression for language %s",
@@ -2290,7 +2305,7 @@ ClangASTContext *Target::GetScratchClangASTContext(bool create_on_demand) {
ClangASTImporterSP Target::GetClangASTImporter() {
if (m_valid) {
if (!m_ast_importer_sp) {
- m_ast_importer_sp.reset(new ClangASTImporter());
+ m_ast_importer_sp = std::make_shared<ClangASTImporter>();
}
return m_ast_importer_sp;
}
@@ -2315,13 +2330,6 @@ FileSpecList Target::GetDefaultDebugFileSearchPaths() {
return FileSpecList();
}
-FileSpecList Target::GetDefaultClangModuleSearchPaths() {
- TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
- if (properties_sp)
- return properties_sp->GetClangModuleSearchPaths();
- return FileSpecList();
-}
-
ArchSpec Target::GetDefaultArchitecture() {
TargetPropertiesSP properties_sp(Target::GetGlobalProperties());
if (properties_sp)
@@ -2357,7 +2365,8 @@ Target *Target::GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr,
ExpressionResults Target::EvaluateExpression(
llvm::StringRef expr, ExecutionContextScope *exe_scope,
lldb::ValueObjectSP &result_valobj_sp,
- const EvaluateExpressionOptions &options, std::string *fixed_expression) {
+ const EvaluateExpressionOptions &options, std::string *fixed_expression,
+ ValueObject *ctx_obj) {
result_valobj_sp.reset();
ExpressionResults execution_results = eExpressionSetupError;
@@ -2365,10 +2374,11 @@ ExpressionResults Target::EvaluateExpression(
if (expr.empty())
return execution_results;
- // We shouldn't run stop hooks in expressions. Be sure to reset this if you
- // return anywhere within this function.
+ // We shouldn't run stop hooks in expressions.
bool old_suppress_value = m_suppress_stop_hooks;
m_suppress_stop_hooks = true;
+ auto on_exit = llvm::make_scope_exit([this, old_suppress_value]() {
+ m_suppress_stop_hooks = old_suppress_value; });
ExecutionContext exe_ctx;
@@ -2395,19 +2405,18 @@ ExpressionResults Target::EvaluateExpression(
} else {
llvm::StringRef prefix = GetExpressionPrefixContents();
Status error;
- execution_results = UserExpression::Evaluate(exe_ctx, options, expr, prefix,
- result_valobj_sp, error,
- 0, // Line Number
- fixed_expression);
+ execution_results =
+ UserExpression::Evaluate(exe_ctx, options, expr, prefix,
+ result_valobj_sp, error, fixed_expression,
+ nullptr, // Module
+ ctx_obj);
}
- m_suppress_stop_hooks = old_suppress_value;
-
return execution_results;
}
lldb::ExpressionVariableSP
-Target::GetPersistentVariable(const ConstString &name) {
+Target::GetPersistentVariable(ConstString name) {
lldb::ExpressionVariableSP variable_sp;
m_scratch_type_system_map.ForEach(
[name, &variable_sp](TypeSystem *type_system) -> bool {
@@ -2423,7 +2432,7 @@ Target::GetPersistentVariable(const ConstString &name) {
return variable_sp;
}
-lldb::addr_t Target::GetPersistentSymbol(const ConstString &name) {
+lldb::addr_t Target::GetPersistentSymbol(ConstString name) {
lldb::addr_t address = LLDB_INVALID_ADDRESS;
m_scratch_type_system_map.ForEach(
@@ -2460,9 +2469,9 @@ lldb::addr_t Target::GetBreakableLoadAddress(lldb::addr_t addr) {
}
SourceManager &Target::GetSourceManager() {
- if (!m_source_manager_ap)
- m_source_manager_ap.reset(new SourceManager(shared_from_this()));
- return *m_source_manager_ap;
+ if (!m_source_manager_up)
+ m_source_manager_up.reset(new SourceManager(shared_from_this()));
+ return *m_source_manager_up;
}
ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
@@ -2473,13 +2482,13 @@ ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
{
std::lock_guard<std::mutex> guard(s_clang_modules_decl_vendor_mutex);
- if (!m_clang_modules_decl_vendor_ap) {
- m_clang_modules_decl_vendor_ap.reset(
+ if (!m_clang_modules_decl_vendor_up) {
+ m_clang_modules_decl_vendor_up.reset(
ClangModulesDeclVendor::Create(*this));
}
}
- return m_clang_modules_decl_vendor_ap.get();
+ return m_clang_modules_decl_vendor_up.get();
}
Target::StopHookSP Target::CreateStopHook() {
@@ -2546,12 +2555,14 @@ void Target::RunStopHooks() {
StopHookCollection::iterator pos, end = m_stop_hooks.end();
- // If there aren't any active stop hooks, don't bother either:
+ // If there aren't any active stop hooks, don't bother either.
+ // Also see if any of the active hooks want to auto-continue.
bool any_active_hooks = false;
- for (pos = m_stop_hooks.begin(); pos != end; pos++) {
- if ((*pos).second->IsActive()) {
+ bool auto_continue = false;
+ for (auto hook : m_stop_hooks) {
+ if (hook.second->IsActive()) {
any_active_hooks = true;
- break;
+ auto_continue |= hook.second->GetAutoContinue();
}
}
if (!any_active_hooks)
@@ -2587,6 +2598,7 @@ void Target::RunStopHooks() {
bool hooks_ran = false;
bool print_hook_header = (m_stop_hooks.size() != 1);
bool print_thread_header = (num_exe_ctx != 1);
+ bool did_restart = false;
for (pos = m_stop_hooks.begin(); keep_going && pos != end; pos++) {
// result.Clear();
@@ -2629,12 +2641,16 @@ void Target::RunStopHooks() {
options.SetStopOnError(true);
options.SetEchoCommands(false);
options.SetPrintResults(true);
+ options.SetPrintErrors(true);
options.SetAddToHistory(false);
+ // Force Async:
+ bool old_async = GetDebugger().GetAsyncExecution();
+ GetDebugger().SetAsyncExecution(true);
GetDebugger().GetCommandInterpreter().HandleCommands(
cur_hook_sp->GetCommands(), &exc_ctx_with_reasons[i], options,
result);
-
+ GetDebugger().SetAsyncExecution(old_async);
// If the command started the target going again, we should bag out of
// running the stop hooks.
if ((result.GetStatus() == eReturnStatusSuccessContinuingNoResult) ||
@@ -2643,13 +2659,19 @@ void Target::RunStopHooks() {
StopHookCollection::iterator tmp = pos;
if (++tmp != end)
result.AppendMessageWithFormat("\nAborting stop hooks, hook %" PRIu64
- " set the program running.\n",
+ " set the program running.\n"
+ " Consider using '-G true' to make "
+ "stop hooks auto-continue.\n",
cur_hook_sp->GetID());
keep_going = false;
+ did_restart = true;
}
}
}
}
+ // Finally, if auto-continue was requested, do it now:
+ if (!did_restart && auto_continue)
+ m_process_sp->PrivateResume();
result.GetImmediateOutputStream()->Flush();
result.GetImmediateErrorStream()->Flush();
@@ -2906,17 +2928,11 @@ Status Target::Launch(ProcessLaunchInfo &launch_info, Stream *stream) {
if (state == eStateStopped) {
if (!launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) {
if (synchronous_execution) {
- error = m_process_sp->PrivateResume();
- if (error.Success()) {
- state = m_process_sp->WaitForProcessToStop(
- llvm::None, nullptr, true, hijack_listener_sp, stream);
- const bool must_be_alive =
- false; // eStateExited is ok, so this must be false
- if (!StateIsStoppedState(state, must_be_alive)) {
- error.SetErrorStringWithFormat("process isn't stopped: %s",
- StateAsCString(state));
- }
- }
+ // Now we have handled the stop-from-attach, and we are just switching
+ // to a synchronous resume. So we should switch to the SyncResume
+ // hijacker.
+ m_process_sp->RestoreProcessEvents();
+ m_process_sp->ResumeSynchronous(stream);
} else {
m_process_sp->RestoreProcessEvents();
error = m_process_sp->PrivateResume();
@@ -3130,19 +3146,18 @@ void Target::FinalizeFileActions(ProcessLaunchInfo &info) {
}
}
-//--------------------------------------------------------------
// Target::StopHook
-//--------------------------------------------------------------
Target::StopHook::StopHook(lldb::TargetSP target_sp, lldb::user_id_t uid)
: UserID(uid), m_target_sp(target_sp), m_commands(), m_specifier_sp(),
- m_thread_spec_ap(), m_active(true) {}
+ m_thread_spec_up() {}
Target::StopHook::StopHook(const StopHook &rhs)
: UserID(rhs.GetID()), m_target_sp(rhs.m_target_sp),
m_commands(rhs.m_commands), m_specifier_sp(rhs.m_specifier_sp),
- m_thread_spec_ap(), m_active(rhs.m_active) {
- if (rhs.m_thread_spec_ap)
- m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get()));
+ m_thread_spec_up(), m_active(rhs.m_active),
+ m_auto_continue(rhs.m_auto_continue) {
+ if (rhs.m_thread_spec_up)
+ m_thread_spec_up.reset(new ThreadSpec(*rhs.m_thread_spec_up));
}
Target::StopHook::~StopHook() = default;
@@ -3152,7 +3167,7 @@ void Target::StopHook::SetSpecifier(SymbolContextSpecifier *specifier) {
}
void Target::StopHook::SetThreadSpecifier(ThreadSpec *specifier) {
- m_thread_spec_ap.reset(specifier);
+ m_thread_spec_up.reset(specifier);
}
void Target::StopHook::GetDescription(Stream *s,
@@ -3167,6 +3182,9 @@ void Target::StopHook::GetDescription(Stream *s,
else
s->Indent("State: disabled\n");
+ if (m_auto_continue)
+ s->Indent("AutoContinue on\n");
+
if (m_specifier_sp) {
s->Indent();
s->PutCString("Specifier:\n");
@@ -3175,10 +3193,10 @@ void Target::StopHook::GetDescription(Stream *s,
s->SetIndentLevel(indent_level + 2);
}
- if (m_thread_spec_ap) {
+ if (m_thread_spec_up) {
StreamString tmp;
s->Indent("Thread:\n");
- m_thread_spec_ap->GetDescription(&tmp, level);
+ m_thread_spec_up->GetDescription(&tmp, level);
s->SetIndentLevel(indent_level + 4);
s->Indent(tmp.GetString());
s->PutCString("\n");
@@ -3195,9 +3213,7 @@ void Target::StopHook::GetDescription(Stream *s,
s->SetIndentLevel(indent_level);
}
-//--------------------------------------------------------------
// class TargetProperties
-//--------------------------------------------------------------
// clang-format off
static constexpr OptionEnumValueElement g_dynamic_value_types[] = {
@@ -3225,11 +3241,11 @@ static constexpr OptionEnumValueElement g_inline_breakpoint_enums[] = {
"Always look for inline breakpoint locations when setting file and line "
"breakpoints (slower but most accurate)."} };
-typedef enum x86DisassemblyFlavor {
+enum x86DisassemblyFlavor {
eX86DisFlavorDefault,
eX86DisFlavorIntel,
eX86DisFlavorATT
-} x86DisassemblyFlavor;
+};
static constexpr OptionEnumValueElement g_x86_dis_flavor_value_types[] = {
{eX86DisFlavorDefault, "default", "Disassembler default (currently att)."},
@@ -3310,6 +3326,9 @@ static constexpr PropertyDefinition g_properties[] = {
{"auto-import-clang-modules", OptionValue::eTypeBoolean, false, true,
nullptr, {},
"Automatically load Clang modules referred to by the program."},
+ {"import-std-module", OptionValue::eTypeBoolean, false, false,
+ nullptr, {},
+ "Import the C++ std module to improve debugging STL containers."},
{"auto-apply-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
{}, "Automatically apply fix-it hints to expressions."},
{"notify-about-fixits", OptionValue::eTypeBoolean, false, true, nullptr,
@@ -3448,6 +3467,7 @@ enum {
ePropertyDebugFileSearchPaths,
ePropertyClangModuleSearchPaths,
ePropertyAutoImportClangModules,
+ ePropertyImportStdModule,
ePropertyAutoApplyFixIts,
ePropertyNotifyAboutFixIts,
ePropertySaveObjects,
@@ -3485,7 +3505,7 @@ enum {
class TargetOptionValueProperties : public OptionValueProperties {
public:
- TargetOptionValueProperties(const ConstString &name)
+ TargetOptionValueProperties(ConstString name)
: OptionValueProperties(name), m_target(nullptr), m_got_host_env(false) {}
// This constructor is used when creating TargetOptionValueProperties when it
@@ -3554,9 +3574,7 @@ protected:
mutable bool m_got_host_env;
};
-//----------------------------------------------------------------------
// TargetProperties
-//----------------------------------------------------------------------
static constexpr PropertyDefinition g_experimental_properties[]{
{"inject-local-vars", OptionValue::eTypeBoolean, true, true, nullptr,
{},
@@ -3582,14 +3600,12 @@ TargetExperimentalProperties::TargetExperimentalProperties()
m_collection_sp->Initialize(g_experimental_properties);
}
-//----------------------------------------------------------------------
// TargetProperties
-//----------------------------------------------------------------------
TargetProperties::TargetProperties(Target *target)
: Properties(), m_launch_info() {
if (target) {
- m_collection_sp.reset(
- new TargetOptionValueProperties(target, Target::GetGlobalProperties()));
+ m_collection_sp = std::make_shared<TargetOptionValueProperties>(
+ target, Target::GetGlobalProperties());
// Set callbacks to update launch_info whenever "settins set" updated any
// of these properties
@@ -3637,8 +3653,8 @@ TargetProperties::TargetProperties(Target *target)
DisableASLRValueChangedCallback(this, nullptr);
DisableSTDIOValueChangedCallback(this, nullptr);
} else {
- m_collection_sp.reset(
- new TargetOptionValueProperties(ConstString("target")));
+ m_collection_sp =
+ std::make_shared<TargetOptionValueProperties>(ConstString("target"));
m_collection_sp->Initialize(g_properties);
m_experimental_properties_up.reset(new TargetExperimentalProperties());
m_collection_sp->AppendProperty(
@@ -3837,27 +3853,36 @@ PathMappingList &TargetProperties::GetSourcePathMap() const {
return option_value->GetCurrentValue();
}
-FileSpecList &TargetProperties::GetExecutableSearchPaths() {
+void TargetProperties::AppendExecutableSearchPaths(const FileSpec& dir) {
const uint32_t idx = ePropertyExecutableSearchPaths;
OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
+ option_value->AppendCurrentValue(dir);
+}
+
+FileSpecList TargetProperties::GetExecutableSearchPaths() {
+ const uint32_t idx = ePropertyExecutableSearchPaths;
+ const OptionValueFileSpecList *option_value =
+ m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
+ false, idx);
+ assert(option_value);
return option_value->GetCurrentValue();
}
-FileSpecList &TargetProperties::GetDebugFileSearchPaths() {
+FileSpecList TargetProperties::GetDebugFileSearchPaths() {
const uint32_t idx = ePropertyDebugFileSearchPaths;
- OptionValueFileSpecList *option_value =
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
return option_value->GetCurrentValue();
}
-FileSpecList &TargetProperties::GetClangModuleSearchPaths() {
+FileSpecList TargetProperties::GetClangModuleSearchPaths() {
const uint32_t idx = ePropertyClangModuleSearchPaths;
- OptionValueFileSpecList *option_value =
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
@@ -3870,6 +3895,12 @@ bool TargetProperties::GetEnableAutoImportClangModules() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
+bool TargetProperties::GetEnableImportStdModule() const {
+ const uint32_t idx = ePropertyImportStdModule;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_properties[idx].default_uint_value != 0);
+}
+
bool TargetProperties::GetEnableAutoApplyFixIts() const {
const uint32_t idx = ePropertyAutoApplyFixIts;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -4176,9 +4207,7 @@ void TargetProperties::DisableSTDIOValueChangedCallback(
this_->m_launch_info.GetFlags().Clear(lldb::eLaunchFlagDisableSTDIO);
}
-//----------------------------------------------------------------------
// Target::TargetEventData
-//----------------------------------------------------------------------
Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp)
: EventData(), m_target_sp(target_sp), m_module_list() {}
@@ -4189,7 +4218,7 @@ Target::TargetEventData::TargetEventData(const lldb::TargetSP &target_sp,
Target::TargetEventData::~TargetEventData() = default;
-const ConstString &Target::TargetEventData::GetFlavorString() {
+ConstString Target::TargetEventData::GetFlavorString() {
static ConstString g_flavor("Target::TargetEventData");
return g_flavor;
}
diff --git a/source/Target/TargetList.cpp b/source/Target/TargetList.cpp
index 5b262509cae79..7c7a36e97bbfe 100644
--- a/source/Target/TargetList.cpp
+++ b/source/Target/TargetList.cpp
@@ -1,9 +1,8 @@
//===-- TargetList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,9 +34,7 @@ ConstString &TargetList::GetStaticBroadcasterClass() {
return class_name;
}
-//----------------------------------------------------------------------
// TargetList constructor
-//----------------------------------------------------------------------
TargetList::TargetList(Debugger &debugger)
: Broadcaster(debugger.GetBroadcasterManager(),
TargetList::GetStaticBroadcasterClass().AsCString()),
@@ -45,9 +42,7 @@ TargetList::TargetList(Debugger &debugger)
CheckInWithManager();
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
TargetList::~TargetList() {
std::lock_guard<std::recursive_mutex> guard(m_target_list_mutex);
m_target_list.clear();
@@ -427,7 +422,7 @@ Status TargetList::CreateTargetInternal(Debugger &debugger,
if (file.GetDirectory()) {
FileSpec file_dir;
file_dir.GetDirectory() = file.GetDirectory();
- target_sp->GetExecutableSearchPaths().Append(file_dir);
+ target_sp->AppendExecutableSearchPaths(file_dir);
}
// Don't put the dummy target in the target list, it's held separately.
diff --git a/source/Target/Thread.cpp b/source/Target/Thread.cpp
index 569d7a0a0f9e2..7a6b49e552524 100644
--- a/source/Target/Thread.cpp
+++ b/source/Target/Thread.cpp
@@ -1,9 +1,8 @@
//===-- Thread.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,7 +22,7 @@
#include "lldb/Target/ABI.h"
#include "lldb/Target/DynamicLoader.h"
#include "lldb/Target/ExecutionContext.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/StackFrameRecognizer.h"
@@ -51,6 +50,8 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-enumerations.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -91,7 +92,7 @@ enum {
class ThreadOptionValueProperties : public OptionValueProperties {
public:
- ThreadOptionValueProperties(const ConstString &name)
+ ThreadOptionValueProperties(ConstString name)
: OptionValueProperties(name) {}
// This constructor is used when creating ThreadOptionValueProperties when it
@@ -122,12 +123,12 @@ public:
ThreadProperties::ThreadProperties(bool is_global) : Properties() {
if (is_global) {
- m_collection_sp.reset(
- new ThreadOptionValueProperties(ConstString("thread")));
+ m_collection_sp =
+ std::make_shared<ThreadOptionValueProperties>(ConstString("thread"));
m_collection_sp->Initialize(g_properties);
} else
- m_collection_sp.reset(
- new ThreadOptionValueProperties(Thread::GetGlobalProperties().get()));
+ m_collection_sp = std::make_shared<ThreadOptionValueProperties>(
+ Thread::GetGlobalProperties().get());
}
ThreadProperties::~ThreadProperties() = default;
@@ -137,9 +138,9 @@ const RegularExpression *ThreadProperties::GetSymbolsToAvoidRegexp() {
return m_collection_sp->GetPropertyAtIndexAsOptionValueRegex(nullptr, idx);
}
-FileSpecList &ThreadProperties::GetLibrariesToAvoid() const {
+FileSpecList ThreadProperties::GetLibrariesToAvoid() const {
const uint32_t idx = ePropertyStepAvoidLibraries;
- OptionValueFileSpecList *option_value =
+ const OptionValueFileSpecList *option_value =
m_collection_sp->GetPropertyAtIndexAsOptionValueFileSpecList(nullptr,
false, idx);
assert(option_value);
@@ -170,11 +171,9 @@ uint64_t ThreadProperties::GetMaxBacktraceDepth() const {
nullptr, idx, g_properties[idx].default_uint_value != 0);
}
-//------------------------------------------------------------------
// Thread Event Data
-//------------------------------------------------------------------
-const ConstString &Thread::ThreadEventData::GetFlavorString() {
+ConstString Thread::ThreadEventData::GetFlavorString() {
static ConstString g_flavor("Thread::ThreadEventData");
return g_flavor;
}
@@ -233,9 +232,7 @@ Thread::ThreadEventData::GetStackFrameFromEvent(const Event *event_ptr) {
return frame_sp;
}
-//------------------------------------------------------------------
// Thread class
-//------------------------------------------------------------------
ConstString &Thread::GetStaticBroadcasterClass() {
static ConstString class_name("lldb.thread");
@@ -255,7 +252,7 @@ Thread::Thread(Process &process, lldb::tid_t tid, bool use_invalid_index_id)
m_curr_frames_sp(), m_prev_frames_sp(),
m_resume_signal(LLDB_INVALID_SIGNAL_NUMBER),
m_resume_state(eStateRunning), m_temporary_resume_state(eStateRunning),
- m_unwinder_ap(), m_destroy_called(false),
+ m_unwinder_up(), m_destroy_called(false),
m_override_should_notify(eLazyBoolCalculate),
m_extended_info_fetched(false), m_extended_info() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
@@ -305,7 +302,7 @@ void Thread::DestroyThread() {
m_stop_info_sp.reset();
m_reg_context_sp.reset();
- m_unwinder_ap.reset();
+ m_unwinder_up.reset();
std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
m_curr_frames_sp.reset();
m_prev_frames_sp.reset();
@@ -561,8 +558,8 @@ bool Thread::RestoreRegisterStateFromCheckpoint(
// Clear out all stack frames as our world just changed.
ClearStackFrames();
reg_ctx_sp->InvalidateIfNeeded(true);
- if (m_unwinder_ap.get())
- m_unwinder_ap->Clear();
+ if (m_unwinder_up)
+ m_unwinder_up->Clear();
return ret;
}
}
@@ -856,7 +853,7 @@ bool Thread::ShouldStop(Event *event_ptr) {
// Otherwise, don't let the base plan override what the other plans say
// to do, since presumably if there were other plans they would know what
// to do...
- while (1) {
+ while (true) {
if (PlanIsBasePlan(current_plan))
break;
@@ -981,7 +978,7 @@ Vote Thread::ShouldReportStop(Event *event_ptr) {
} else {
Vote thread_vote = eVoteNoOpinion;
ThreadPlan *plan_ptr = GetCurrentPlan();
- while (1) {
+ while (true) {
if (plan_ptr->PlanExplainsStop(event_ptr)) {
thread_vote = plan_ptr->ShouldReportStop(event_ptr);
break;
@@ -1301,7 +1298,7 @@ void Thread::DiscardThreadPlans(bool force) {
return;
}
- while (1) {
+ while (true) {
int master_plan_idx;
bool discard = true;
@@ -1384,9 +1381,9 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
Status &status, LazyBool step_out_avoids_code_withoug_debug_info) {
ThreadPlanSP thread_plan_sp;
- thread_plan_sp.reset(new ThreadPlanStepOverRange(
+ thread_plan_sp = std::make_shared<ThreadPlanStepOverRange>(
*this, range, addr_context, stop_other_threads,
- step_out_avoids_code_withoug_debug_info));
+ step_out_avoids_code_withoug_debug_info);
status = QueueThreadPlan(thread_plan_sp, abort_other_plans);
return thread_plan_sp;
@@ -1398,10 +1395,12 @@ ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
bool abort_other_plans, const LineEntry &line_entry,
const SymbolContext &addr_context, lldb::RunMode stop_other_threads,
Status &status, LazyBool step_out_avoids_code_withoug_debug_info) {
+ const bool include_inlined_functions = true;
+ auto address_range =
+ line_entry.GetSameLineContiguousAddressRange(include_inlined_functions);
return QueueThreadPlanForStepOverRange(
- abort_other_plans, line_entry.GetSameLineContiguousAddressRange(),
- addr_context, stop_other_threads, status,
- step_out_avoids_code_withoug_debug_info);
+ abort_other_plans, address_range, addr_context, stop_other_threads,
+ status, step_out_avoids_code_withoug_debug_info);
}
ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
@@ -1431,8 +1430,10 @@ ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
lldb::RunMode stop_other_threads, Status &status,
LazyBool step_in_avoids_code_without_debug_info,
LazyBool step_out_avoids_code_without_debug_info) {
+ const bool include_inlined_functions = false;
return QueueThreadPlanForStepInRange(
- abort_other_plans, line_entry.GetSameLineContiguousAddressRange(),
+ abort_other_plans,
+ line_entry.GetSameLineContiguousAddressRange(include_inlined_functions),
addr_context, step_in_target, stop_other_threads, status,
step_in_avoids_code_without_debug_info,
step_out_avoids_code_without_debug_info);
@@ -1599,15 +1600,13 @@ void Thread::CalculateExecutionContext(ExecutionContext &exe_ctx) {
}
StackFrameListSP Thread::GetStackFrameList() {
- StackFrameListSP frame_list_sp;
std::lock_guard<std::recursive_mutex> guard(m_frame_mutex);
- if (m_curr_frames_sp) {
- frame_list_sp = m_curr_frames_sp;
- } else {
- frame_list_sp.reset(new StackFrameList(*this, m_prev_frames_sp, true));
- m_curr_frames_sp = frame_list_sp;
- }
- return frame_list_sp;
+
+ if (!m_curr_frames_sp)
+ m_curr_frames_sp =
+ std::make_shared<StackFrameList>(*this, m_prev_frames_sp, true);
+
+ return m_curr_frames_sp;
}
void Thread::ClearStackFrames() {
@@ -1678,7 +1677,7 @@ Status Thread::ReturnFromFrame(lldb::StackFrameSP frame_sp,
// FIXME: ValueObject::Cast doesn't currently work correctly, at least not
// for scalars.
// Turn that back on when that works.
- if (/* DISABLES CODE */ (0) && sc.function != nullptr) {
+ if (/* DISABLES CODE */ (false) && sc.function != nullptr) {
Type *function_type = sc.function->GetType();
if (function_type) {
CompilerType return_type =
@@ -2055,7 +2054,7 @@ size_t Thread::GetStackFrameStatus(Stream &strm, uint32_t first_frame,
}
Unwind *Thread::GetUnwinder() {
- if (!m_unwinder_ap) {
+ if (!m_unwinder_up) {
const ArchSpec target_arch(CalculateTarget()->GetArchitecture());
const llvm::Triple::ArchType machine = target_arch.GetMachine();
switch (machine) {
@@ -2073,16 +2072,16 @@ Unwind *Thread::GetUnwinder() {
case llvm::Triple::ppc64le:
case llvm::Triple::systemz:
case llvm::Triple::hexagon:
- m_unwinder_ap.reset(new UnwindLLDB(*this));
+ m_unwinder_up.reset(new UnwindLLDB(*this));
break;
default:
if (target_arch.GetTriple().getVendor() == llvm::Triple::Apple)
- m_unwinder_ap.reset(new UnwindMacOSXFrameBackchain(*this));
+ m_unwinder_up.reset(new UnwindMacOSXFrameBackchain(*this));
break;
}
}
- return m_unwinder_ap.get();
+ return m_unwinder_up.get();
}
void Thread::Flush() {
@@ -2210,25 +2209,27 @@ ValueObjectSP Thread::GetCurrentException() {
if (auto e = recognized_frame->GetExceptionObject())
return e;
- // FIXME: For now, only ObjC exceptions are supported. This should really
- // iterate over all language runtimes and ask them all to give us the current
- // exception.
- if (auto runtime = GetProcess()->GetObjCLanguageRuntime())
+ // NOTE: Even though this behavior is generalized, only ObjC is actually
+ // supported at the moment.
+ for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
if (auto e = runtime->GetExceptionObjectForThread(shared_from_this()))
return e;
+ }
return ValueObjectSP();
}
ThreadSP Thread::GetCurrentExceptionBacktrace() {
ValueObjectSP exception = GetCurrentException();
- if (!exception) return ThreadSP();
+ if (!exception)
+ return ThreadSP();
- // FIXME: For now, only ObjC exceptions are supported. This should really
- // iterate over all language runtimes and ask them all to give us the current
- // exception.
- auto runtime = GetProcess()->GetObjCLanguageRuntime();
- if (!runtime) return ThreadSP();
+ // NOTE: Even though this behavior is generalized, only ObjC is actually
+ // supported at the moment.
+ for (LanguageRuntime *runtime : GetProcess()->GetLanguageRuntimes()) {
+ if (auto bt = runtime->GetBacktraceThreadFromException(exception))
+ return bt;
+ }
- return runtime->GetBacktraceThreadFromException(exception);
+ return ThreadSP();
}
diff --git a/source/Target/ThreadCollection.cpp b/source/Target/ThreadCollection.cpp
index 2d63b67a6dbeb..cf3c1e2429999 100644
--- a/source/Target/ThreadCollection.cpp
+++ b/source/Target/ThreadCollection.cpp
@@ -1,9 +1,8 @@
//===-- ThreadCollection.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <stdlib.h>
diff --git a/source/Target/ThreadList.cpp b/source/Target/ThreadList.cpp
index 20c285963882e..afdfda3b0ae1a 100644
--- a/source/Target/ThreadList.cpp
+++ b/source/Target/ThreadList.cpp
@@ -1,9 +1,8 @@
//===-- ThreadList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -38,8 +37,10 @@ const ThreadList &ThreadList::operator=(const ThreadList &rhs) {
if (this != &rhs) {
// Lock both mutexes to make sure neither side changes anyone on us while
// the assignment occurs
- std::lock_guard<std::recursive_mutex> guard(GetMutex());
- std::lock_guard<std::recursive_mutex> rhs_guard(rhs.GetMutex());
+ std::lock(GetMutex(), rhs.GetMutex());
+ std::lock_guard<std::recursive_mutex> guard(GetMutex(), std::adopt_lock);
+ std::lock_guard<std::recursive_mutex> rhs_guard(rhs.GetMutex(),
+ std::adopt_lock);
m_process = rhs.m_process;
m_stop_id = rhs.m_stop_id;
diff --git a/source/Target/ThreadPlan.cpp b/source/Target/ThreadPlan.cpp
index 1f2c69c6e8a6b..1d8cc18db4d65 100644
--- a/source/Target/ThreadPlan.cpp
+++ b/source/Target/ThreadPlan.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlan.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlan constructor
-//----------------------------------------------------------------------
ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
Vote stop_vote, Vote run_vote)
: m_thread(thread), m_stop_vote(stop_vote), m_run_vote(run_vote),
@@ -33,9 +30,7 @@ ThreadPlan::ThreadPlan(ThreadPlanKind kind, const char *name, Thread &thread,
SetID(GetNextID());
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
ThreadPlan::~ThreadPlan() = default;
bool ThreadPlan::PlanExplainsStop(Event *event_ptr) {
@@ -161,9 +156,7 @@ bool ThreadPlan::IsUsuallyUnexplainedStopReason(lldb::StopReason reason) {
}
}
-//----------------------------------------------------------------------
// ThreadPlanNull
-//----------------------------------------------------------------------
ThreadPlanNull::ThreadPlanNull(Thread &thread)
: ThreadPlan(ThreadPlan::eKindNull, "Null Thread Plan", thread,
diff --git a/source/Target/ThreadPlanBase.cpp b/source/Target/ThreadPlanBase.cpp
index 058d1468e2413..9cd4bcb455be9 100644
--- a/source/Target/ThreadPlanBase.cpp
+++ b/source/Target/ThreadPlanBase.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanBase.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,11 +22,9 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanBase: This one always stops, and never has anything particular to
// do.
// FIXME: The "signal handling" policies should probably go here.
-//----------------------------------------------------------------------
ThreadPlanBase::ThreadPlanBase(Thread &thread)
: ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes,
diff --git a/source/Target/ThreadPlanCallFunction.cpp b/source/Target/ThreadPlanCallFunction.cpp
index 1131ec939b896..68d771c37946a 100644
--- a/source/Target/ThreadPlanCallFunction.cpp
+++ b/source/Target/ThreadPlanCallFunction.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallFunction.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,12 +24,12 @@
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanCallFunction: Plan to call a single function
-//----------------------------------------------------------------------
bool ThreadPlanCallFunction::ConstructorSetup(
Thread &thread, ABI *&abi, lldb::addr_t &start_load_addr,
lldb::addr_t &function_load_addr) {
@@ -405,8 +404,8 @@ void ThreadPlanCallFunction::DidPush() {
GetThread().SetStopInfoToNothing();
#ifndef SINGLE_STEP_EXPRESSIONS
- m_subplan_sp.reset(
- new ThreadPlanRunToAddress(m_thread, m_start_addr, m_stop_other_threads));
+ m_subplan_sp = std::make_shared<ThreadPlanRunToAddress>(
+ m_thread, m_start_addr, m_stop_other_threads);
m_thread.QueueThreadPlan(m_subplan_sp, false);
m_subplan_sp->SetPrivate(true);
diff --git a/source/Target/ThreadPlanCallFunctionUsingABI.cpp b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
index 08604d2c411a4..3155e6f7965f9 100644
--- a/source/Target/ThreadPlanCallFunctionUsingABI.cpp
+++ b/source/Target/ThreadPlanCallFunctionUsingABI.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallFunctionUsingABI.cpp ----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,10 +18,8 @@
using namespace lldb;
using namespace lldb_private;
-//--------------------------------------------------------------------------------------------
// ThreadPlanCallFunctionUsingABI: Plan to call a single function using the ABI
// instead of JIT
-//-------------------------------------------------------------------------------------------
ThreadPlanCallFunctionUsingABI::ThreadPlanCallFunctionUsingABI(
Thread &thread, const Address &function, llvm::Type &prototype,
llvm::Type &return_type, llvm::ArrayRef<ABI::CallArgument> args,
diff --git a/source/Target/ThreadPlanCallOnFunctionExit.cpp b/source/Target/ThreadPlanCallOnFunctionExit.cpp
index 2ea083dac45e9..3330adc0c2afc 100644
--- a/source/Target/ThreadPlanCallOnFunctionExit.cpp
+++ b/source/Target/ThreadPlanCallOnFunctionExit.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallOnFunctionExit.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -41,9 +40,7 @@ void ThreadPlanCallOnFunctionExit::DidPush() {
);
}
-// -------------------------------------------------------------------------
// ThreadPlan API
-// -------------------------------------------------------------------------
void ThreadPlanCallOnFunctionExit::GetDescription(
Stream *s, lldb::DescriptionLevel level) {
diff --git a/source/Target/ThreadPlanCallUserExpression.cpp b/source/Target/ThreadPlanCallUserExpression.cpp
index 1fbd346feeead..864808a4b5ea3 100644
--- a/source/Target/ThreadPlanCallUserExpression.cpp
+++ b/source/Target/ThreadPlanCallUserExpression.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanCallUserExpression.cpp -------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,7 @@
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Address.h"
#include "lldb/Expression/DiagnosticManager.h"
-#include "lldb/Expression/IRDynamicChecks.h"
+#include "lldb/Expression/DynamicCheckerFunctions.h"
#include "lldb/Expression/UserExpression.h"
#include "lldb/Host/HostInfo.h"
#include "lldb/Target/LanguageRuntime.h"
@@ -30,9 +29,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanCallUserExpression: Plan to call a single function
-//----------------------------------------------------------------------
ThreadPlanCallUserExpression::ThreadPlanCallUserExpression(
Thread &thread, Address &function, llvm::ArrayRef<lldb::addr_t> args,
diff --git a/source/Target/ThreadPlanPython.cpp b/source/Target/ThreadPlanPython.cpp
index 84b93bdc65833..8b30c4ea7cb15 100644
--- a/source/Target/ThreadPlanPython.cpp
+++ b/source/Target/ThreadPlanPython.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanPython.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,9 +23,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanPython
-//----------------------------------------------------------------------
ThreadPlanPython::ThreadPlanPython(Thread &thread, const char *class_name)
: ThreadPlan(ThreadPlan::eKindPython, "Python based Thread Plan", thread,
@@ -63,7 +60,6 @@ void ThreadPlanPython::DidPush() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
m_implementation_sp = script_interp->CreateScriptedThreadPlan(
@@ -83,7 +79,6 @@ bool ThreadPlanPython::ShouldStop(Event *event_ptr) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -107,7 +102,6 @@ bool ThreadPlanPython::IsPlanStale() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -131,7 +125,6 @@ bool ThreadPlanPython::DoPlanExplainsStop(Event *event_ptr) {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
@@ -170,7 +163,6 @@ lldb::StateType ThreadPlanPython::GetPlanRunState() {
ScriptInterpreter *script_interp = m_thread.GetProcess()
->GetTarget()
.GetDebugger()
- .GetCommandInterpreter()
.GetScriptInterpreter();
if (script_interp) {
bool script_error;
diff --git a/source/Target/ThreadPlanRunToAddress.cpp b/source/Target/ThreadPlanRunToAddress.cpp
index bd11f8b82f780..a973bd112796a 100644
--- a/source/Target/ThreadPlanRunToAddress.cpp
+++ b/source/Target/ThreadPlanRunToAddress.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanRunToAddress.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,9 +17,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanRunToAddress: Continue plan
-//----------------------------------------------------------------------
ThreadPlanRunToAddress::ThreadPlanRunToAddress(Thread &thread, Address &address,
bool stop_others)
diff --git a/source/Target/ThreadPlanShouldStopHere.cpp b/source/Target/ThreadPlanShouldStopHere.cpp
index 8062d8059c148..a0b7072a10719 100644
--- a/source/Target/ThreadPlanShouldStopHere.cpp
+++ b/source/Target/ThreadPlanShouldStopHere.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanShouldStopHere.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanShouldStopHere constructor
-//----------------------------------------------------------------------
ThreadPlanShouldStopHere::ThreadPlanShouldStopHere(ThreadPlan *owner)
: m_callbacks(), m_baton(nullptr), m_owner(owner),
m_flags(ThreadPlanShouldStopHere::eNone) {
@@ -133,7 +130,7 @@ ThreadPlanSP ThreadPlanShouldStopHere::DefaultStepFromHereCallback(
"Queueing StepInRange plan to step through line 0 code.");
return_plan_sp = current_plan->GetThread().QueueThreadPlanForStepInRange(
- false, range, sc, NULL, eOnlyDuringStepping, status,
+ false, range, sc, nullptr, eOnlyDuringStepping, status,
eLazyBoolCalculate, eLazyBoolNo);
}
}
diff --git a/source/Target/ThreadPlanStepInRange.cpp b/source/Target/ThreadPlanStepInRange.cpp
index 8f9889a9d68c3..2065fa55fa6aa 100644
--- a/source/Target/ThreadPlanStepInRange.cpp
+++ b/source/Target/ThreadPlanStepInRange.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepInRange.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,10 +28,8 @@ using namespace lldb_private;
uint32_t ThreadPlanStepInRange::s_default_flag_values =
ThreadPlanShouldStopHere::eStepInAvoidNoDebug;
-//----------------------------------------------------------------------
// ThreadPlanStepInRange: Step through a stack range, either stepping over or
// into based on the value of \a type.
-//----------------------------------------------------------------------
ThreadPlanStepInRange::ThreadPlanStepInRange(
Thread &thread, const AddressRange &range,
@@ -315,10 +312,10 @@ bool ThreadPlanStepInRange::ShouldStop(Event *event_ptr) {
void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
auto name_ref = llvm::StringRef::withNullAsEmpty(name);
- if (!m_avoid_regexp_ap)
- m_avoid_regexp_ap.reset(new RegularExpression(name_ref));
+ if (!m_avoid_regexp_up)
+ m_avoid_regexp_up.reset(new RegularExpression(name_ref));
- m_avoid_regexp_ap->Compile(name_ref);
+ m_avoid_regexp_up->Compile(name_ref);
}
void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {
@@ -351,7 +348,7 @@ bool ThreadPlanStepInRange::FrameMatchesAvoidCriteria() {
if (libraries_say_avoid)
return true;
- const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_ap.get();
+ const RegularExpression *avoid_regexp_to_use = m_avoid_regexp_up.get();
if (avoid_regexp_to_use == nullptr)
avoid_regexp_to_use = GetThread().GetSymbolsToAvoidRegexp();
diff --git a/source/Target/ThreadPlanStepInstruction.cpp b/source/Target/ThreadPlanStepInstruction.cpp
index 7707454c97988..a11b623c8acfb 100644
--- a/source/Target/ThreadPlanStepInstruction.cpp
+++ b/source/Target/ThreadPlanStepInstruction.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepInstruction.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,7 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepInstruction: Step over the current instruction
-//----------------------------------------------------------------------
ThreadPlanStepInstruction::ThreadPlanStepInstruction(Thread &thread,
bool step_over,
diff --git a/source/Target/ThreadPlanStepOut.cpp b/source/Target/ThreadPlanStepOut.cpp
index 378de53fafd7d..bf55c376513dc 100644
--- a/source/Target/ThreadPlanStepOut.cpp
+++ b/source/Target/ThreadPlanStepOut.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOut.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,14 +23,14 @@
#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Utility/Log.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
uint32_t ThreadPlanStepOut::s_default_flag_values = 0;
-//----------------------------------------------------------------------
// ThreadPlanStepOut: Step out of the current frame
-//----------------------------------------------------------------------
ThreadPlanStepOut::ThreadPlanStepOut(
Thread &thread, SymbolContext *context, bool first_insn, bool stop_others,
Vote stop_vote, Vote run_vote, uint32_t frame_idx,
@@ -85,9 +84,9 @@ ThreadPlanStepOut::ThreadPlanStepOut(
if (frame_idx > 0) {
// First queue a plan that gets us to this inlined frame, and when we get
// there we'll queue a second plan that walks us out of this frame.
- m_step_out_to_inline_plan_sp.reset(new ThreadPlanStepOut(
+ m_step_out_to_inline_plan_sp = std::make_shared<ThreadPlanStepOut>(
m_thread, nullptr, false, stop_others, eVoteNoOpinion, eVoteNoOpinion,
- frame_idx - 1, eLazyBoolNo, continue_to_next_branch));
+ frame_idx - 1, eLazyBoolNo, continue_to_next_branch);
static_cast<ThreadPlanStepOut *>(m_step_out_to_inline_plan_sp.get())
->SetShouldStopHereCallbacks(nullptr, nullptr);
m_step_out_to_inline_plan_sp->SetPrivate(true);
@@ -111,8 +110,9 @@ ThreadPlanStepOut::ThreadPlanStepOut(
return_address_decr_pc.CalculateSymbolContext(
&return_address_sc, lldb::eSymbolContextLineEntry);
if (return_address_sc.line_entry.IsValid()) {
- range =
- return_address_sc.line_entry.GetSameLineContiguousAddressRange();
+ const bool include_inlined_functions = false;
+ range = return_address_sc.line_entry.GetSameLineContiguousAddressRange(
+ include_inlined_functions);
if (range.GetByteSize() > 0) {
return_address =
m_thread.GetProcess()->AdvanceAddressToNextBranchInstruction(
@@ -450,8 +450,9 @@ bool ThreadPlanStepOut::QueueInlinedStepPlan(bool queue_now) {
m_stop_others ? lldb::eOnlyThisThread : lldb::eAllThreads;
const LazyBool avoid_no_debug = eLazyBoolNo;
- m_step_through_inline_plan_sp.reset(new ThreadPlanStepOverRange(
- m_thread, inline_range, inlined_sc, run_mode, avoid_no_debug));
+ m_step_through_inline_plan_sp =
+ std::make_shared<ThreadPlanStepOverRange>(
+ m_thread, inline_range, inlined_sc, run_mode, avoid_no_debug);
ThreadPlanStepOverRange *step_through_inline_plan_ptr =
static_cast<ThreadPlanStepOverRange *>(
m_step_through_inline_plan_sp.get());
diff --git a/source/Target/ThreadPlanStepOverBreakpoint.cpp b/source/Target/ThreadPlanStepOverBreakpoint.cpp
index 8b24bf94973b5..4770b57ab7f2e 100644
--- a/source/Target/ThreadPlanStepOverBreakpoint.cpp
+++ b/source/Target/ThreadPlanStepOverBreakpoint.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOverBreakpoint.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,10 +16,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepOverBreakpoint: Single steps over a breakpoint bp_site_sp at
// the pc.
-//----------------------------------------------------------------------
ThreadPlanStepOverBreakpoint::ThreadPlanStepOverBreakpoint(Thread &thread)
: ThreadPlan(
diff --git a/source/Target/ThreadPlanStepOverRange.cpp b/source/Target/ThreadPlanStepOverRange.cpp
index 129f30371f8d2..3aaeac9f5b21b 100644
--- a/source/Target/ThreadPlanStepOverRange.cpp
+++ b/source/Target/ThreadPlanStepOverRange.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepOverRange.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,10 +25,8 @@ using namespace lldb;
uint32_t ThreadPlanStepOverRange::s_default_flag_values = 0;
-//----------------------------------------------------------------------
// ThreadPlanStepOverRange: Step through a stack range, either stepping over or
// into based on the value of \a type.
-//----------------------------------------------------------------------
ThreadPlanStepOverRange::ThreadPlanStepOverRange(
Thread &thread, const AddressRange &range,
diff --git a/source/Target/ThreadPlanStepRange.cpp b/source/Target/ThreadPlanStepRange.cpp
index 7ba68ee84981b..49c72dbf09115 100644
--- a/source/Target/ThreadPlanStepRange.cpp
+++ b/source/Target/ThreadPlanStepRange.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepRange.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,10 +25,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepRange: Step through a stack range, either stepping over or
// into based on the value of \a type.
-//----------------------------------------------------------------------
ThreadPlanStepRange::ThreadPlanStepRange(ThreadPlanKind kind, const char *name,
Thread &thread,
@@ -129,8 +126,10 @@ bool ThreadPlanStepRange::InRange() {
new_context.line_entry.original_file) {
if (m_addr_context.line_entry.line == new_context.line_entry.line) {
m_addr_context = new_context;
- AddRange(
- m_addr_context.line_entry.GetSameLineContiguousAddressRange());
+ const bool include_inlined_functions =
+ GetKind() == eKindStepOverRange;
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange(
+ include_inlined_functions));
ret_value = true;
if (log) {
StreamString s;
@@ -145,8 +144,10 @@ bool ThreadPlanStepRange::InRange() {
} else if (new_context.line_entry.line == 0) {
new_context.line_entry.line = m_addr_context.line_entry.line;
m_addr_context = new_context;
- AddRange(
- m_addr_context.line_entry.GetSameLineContiguousAddressRange());
+ const bool include_inlined_functions =
+ GetKind() == eKindStepOverRange;
+ AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange(
+ include_inlined_functions));
ret_value = true;
if (log) {
StreamString s;
@@ -314,9 +315,10 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
return false;
else {
Target &target = GetThread().GetProcess()->GetTarget();
- uint32_t branch_index;
- branch_index =
- instructions->GetIndexOfNextBranchInstruction(pc_index, target);
+ const bool ignore_calls = GetKind() == eKindStepOverRange;
+ uint32_t branch_index =
+ instructions->GetIndexOfNextBranchInstruction(pc_index, target,
+ ignore_calls);
Address run_to_address;
diff --git a/source/Target/ThreadPlanStepThrough.cpp b/source/Target/ThreadPlanStepThrough.cpp
index d1f3c2219f6d7..e46eba00184e1 100644
--- a/source/Target/ThreadPlanStepThrough.cpp
+++ b/source/Target/ThreadPlanStepThrough.cpp
@@ -1,17 +1,15 @@
//===-- ThreadPlanStepThrough.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Target/ThreadPlanStepThrough.h"
#include "lldb/Breakpoint/Breakpoint.h"
-#include "lldb/Target/CPPLanguageRuntime.h"
#include "lldb/Target/DynamicLoader.h"
-#include "lldb/Target/ObjCLanguageRuntime.h"
+#include "lldb/Target/LanguageRuntime.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/Target.h"
@@ -21,12 +19,10 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepThrough: If the current instruction is a trampoline, step
// through it If it is the beginning of the prologue of a function, step
// through that as well.
// FIXME: At present only handles DYLD trampolines.
-//----------------------------------------------------------------------
ThreadPlanStepThrough::ThreadPlanStepThrough(Thread &thread,
StackID &m_stack_id,
@@ -88,22 +84,17 @@ void ThreadPlanStepThrough::LookForPlanToStepThroughFromCurrentPC() {
m_sub_plan_sp =
loader->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
- // If that didn't come up with anything, try the ObjC runtime plugin:
- if (!m_sub_plan_sp.get()) {
- ObjCLanguageRuntime *objc_runtime =
- m_thread.GetProcess()->GetObjCLanguageRuntime();
- if (objc_runtime)
+ // If the DynamicLoader was unable to provide us with a ThreadPlan, then we
+ // try the LanguageRuntimes.
+ if (!m_sub_plan_sp) {
+ for (LanguageRuntime *runtime :
+ m_thread.GetProcess()->GetLanguageRuntimes()) {
m_sub_plan_sp =
- objc_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+ runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
- CPPLanguageRuntime *cpp_runtime =
- m_thread.GetProcess()->GetCPPLanguageRuntime();
-
- // If the ObjC runtime did not provide us with a step though plan then if we
- // have it check the C++ runtime for a step though plan.
- if (!m_sub_plan_sp.get() && cpp_runtime)
- m_sub_plan_sp =
- cpp_runtime->GetStepThroughTrampolinePlan(m_thread, m_stop_others);
+ if (m_sub_plan_sp)
+ break;
+ }
}
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
diff --git a/source/Target/ThreadPlanStepUntil.cpp b/source/Target/ThreadPlanStepUntil.cpp
index 1335c62ba94cf..d4109c3d38daa 100644
--- a/source/Target/ThreadPlanStepUntil.cpp
+++ b/source/Target/ThreadPlanStepUntil.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanStepUntil.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,10 +19,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// ThreadPlanStepUntil: Run until we reach a given line number or step out of
// the current frame
-//----------------------------------------------------------------------
ThreadPlanStepUntil::ThreadPlanStepUntil(Thread &thread,
lldb::addr_t *address_list,
diff --git a/source/Target/ThreadPlanTracer.cpp b/source/Target/ThreadPlanTracer.cpp
index 04e29fd260805..4e79b6b1e59d0 100644
--- a/source/Target/ThreadPlanTracer.cpp
+++ b/source/Target/ThreadPlanTracer.cpp
@@ -1,9 +1,8 @@
//===-- ThreadPlanTracer.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -188,8 +187,6 @@ void ThreadPlanAssemblyTracer::Log() {
for (int arg_index = 0; arg_index < num_args; ++arg_index) {
Value value;
value.SetValueType(Value::eValueTypeScalar);
- // value.SetContext (Value::eContextTypeClangType,
- // intptr_type.GetOpaqueQualType());
value.SetCompilerType(intptr_type);
value_list.PushValue(value);
}
diff --git a/source/Target/ThreadSpec.cpp b/source/Target/ThreadSpec.cpp
index bae3d0b2238fb..1a733cb551e57 100644
--- a/source/Target/ThreadSpec.cpp
+++ b/source/Target/ThreadSpec.cpp
@@ -1,9 +1,8 @@
//===-- ThreadSpec.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,18 +21,6 @@ ThreadSpec::ThreadSpec()
: m_index(UINT32_MAX), m_tid(LLDB_INVALID_THREAD_ID), m_name(),
m_queue_name() {}
-ThreadSpec::ThreadSpec(const ThreadSpec &rhs)
- : m_index(rhs.m_index), m_tid(rhs.m_tid), m_name(rhs.m_name),
- m_queue_name(rhs.m_queue_name) {}
-
-const ThreadSpec &ThreadSpec::operator=(const ThreadSpec &rhs) {
- m_index = rhs.m_index;
- m_tid = rhs.m_tid;
- m_name = rhs.m_name;
- m_queue_name = rhs.m_queue_name;
- return *this;
-}
-
std::unique_ptr<ThreadSpec> ThreadSpec::CreateFromStructuredData(
const StructuredData::Dictionary &spec_dict, Status &error) {
uint32_t index = UINT32_MAX;
diff --git a/source/Target/UnixSignals.cpp b/source/Target/UnixSignals.cpp
index 1448535b8be46..33090a72df54e 100644
--- a/source/Target/UnixSignals.cpp
+++ b/source/Target/UnixSignals.cpp
@@ -1,9 +1,8 @@
//===-- UnixSignals.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#include "Plugins/Process/Utility/LinuxSignals.h"
#include "Plugins/Process/Utility/MipsLinuxSignals.h"
#include "Plugins/Process/Utility/NetBSDSignals.h"
+#include "lldb/Host/HostInfo.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Utility/ArchSpec.h"
@@ -51,9 +51,13 @@ lldb::UnixSignalsSP UnixSignals::Create(const ArchSpec &arch) {
}
}
-//----------------------------------------------------------------------
+lldb::UnixSignalsSP UnixSignals::CreateForHost() {
+ static lldb::UnixSignalsSP s_unix_signals_sp =
+ Create(HostInfo::GetArchitecture());
+ return s_unix_signals_sp;
+}
+
// UnixSignals constructor
-//----------------------------------------------------------------------
UnixSignals::UnixSignals() { Reset(); }
UnixSignals::UnixSignals(const UnixSignals &rhs) : m_signals(rhs.m_signals) {}
diff --git a/source/Target/UnwindAssembly.cpp b/source/Target/UnwindAssembly.cpp
index 06b6aef28da70..d3d8068687c03 100644
--- a/source/Target/UnwindAssembly.cpp
+++ b/source/Target/UnwindAssembly.cpp
@@ -1,9 +1,8 @@
//===-- UnwindAssembly.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,9 +21,9 @@ UnwindAssemblySP UnwindAssembly::FindPlugin(const ArchSpec &arch) {
(create_callback = PluginManager::GetUnwindAssemblyCreateCallbackAtIndex(
idx)) != nullptr;
++idx) {
- UnwindAssemblySP assembly_profiler_ap(create_callback(arch));
- if (assembly_profiler_ap)
- return assembly_profiler_ap;
+ UnwindAssemblySP assembly_profiler_up(create_callback(arch));
+ if (assembly_profiler_up)
+ return assembly_profiler_up;
}
return nullptr;
}
diff --git a/source/Utility/ARM64_DWARF_Registers.h b/source/Utility/ARM64_DWARF_Registers.h
index ce548a2aee80a..64f69d6435654 100644
--- a/source/Utility/ARM64_DWARF_Registers.h
+++ b/source/Utility/ARM64_DWARF_Registers.h
@@ -1,9 +1,8 @@
//===-- ARM64_DWARF_Registers.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/ARM64_ehframe_Registers.h b/source/Utility/ARM64_ehframe_Registers.h
index 7f49314b35391..9b5cd931bf28b 100644
--- a/source/Utility/ARM64_ehframe_Registers.h
+++ b/source/Utility/ARM64_ehframe_Registers.h
@@ -1,10 +1,9 @@
//===-- ARM64_ehframe_Registers.h -------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/ARM_DWARF_Registers.h b/source/Utility/ARM_DWARF_Registers.h
index ab91d8c99aa38..e33210dfbfbd4 100644
--- a/source/Utility/ARM_DWARF_Registers.h
+++ b/source/Utility/ARM_DWARF_Registers.h
@@ -1,9 +1,8 @@
//===-- ARM_DWARF_Registers.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/ARM_ehframe_Registers.h b/source/Utility/ARM_ehframe_Registers.h
index 2a4242314d526..1816b1d974975 100644
--- a/source/Utility/ARM_ehframe_Registers.h
+++ b/source/Utility/ARM_ehframe_Registers.h
@@ -1,10 +1,9 @@
//===-- ARM_ehframe_Registers.h -------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/ArchSpec.cpp b/source/Utility/ArchSpec.cpp
index 752fb182d79aa..81b87fff88d4b 100644
--- a/source/Utility/ArchSpec.cpp
+++ b/source/Utility/ArchSpec.cpp
@@ -1,9 +1,8 @@
//===-- ArchSpec.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -215,13 +214,7 @@ static const CoreDefinition g_core_definitions[] = {
ArchSpec::eCore_uknownMach32, "unknown-mach-32"},
{eByteOrderLittle, 8, 4, 4, llvm::Triple::UnknownArch,
ArchSpec::eCore_uknownMach64, "unknown-mach-64"},
-
- {eByteOrderBig, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba3,
- "kalimba3"},
- {eByteOrderLittle, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba4,
- "kalimba4"},
- {eByteOrderLittle, 4, 1, 1, llvm::Triple::kalimba, ArchSpec::eCore_kalimba5,
- "kalimba5"}};
+};
// Ensure that we have an entry in the g_core_definitions for each core. If you
// comment out an entry above, you will need to comment out the corresponding
@@ -453,12 +446,6 @@ static const ArchDefinitionEntry g_elf_arch_entries[] = {
ArchSpec::eMIPSSubType_mips64r6el, 0xFFFFFFFFu, 0xFFFFFFFFu}, // mips64r6el
{ArchSpec::eCore_hexagon_generic, llvm::ELF::EM_HEXAGON,
LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu}, // HEXAGON
- {ArchSpec::eCore_kalimba3, llvm::ELF::EM_CSR_KALIMBA,
- llvm::Triple::KalimbaSubArch_v3, 0xFFFFFFFFu, 0xFFFFFFFFu}, // KALIMBA
- {ArchSpec::eCore_kalimba4, llvm::ELF::EM_CSR_KALIMBA,
- llvm::Triple::KalimbaSubArch_v4, 0xFFFFFFFFu, 0xFFFFFFFFu}, // KALIMBA
- {ArchSpec::eCore_kalimba5, llvm::ELF::EM_CSR_KALIMBA,
- llvm::Triple::KalimbaSubArch_v5, 0xFFFFFFFFu, 0xFFFFFFFFu} // KALIMBA
};
static const ArchDefinition g_elf_arch_def = {
@@ -608,11 +595,7 @@ const char *ArchSpec::GetArchitectureName() const {
return "unknown";
}
-bool ArchSpec::IsMIPS() const {
- const llvm::Triple::ArchType machine = GetMachine();
- return machine == llvm::Triple::mips || machine == llvm::Triple::mipsel ||
- machine == llvm::Triple::mips64 || machine == llvm::Triple::mips64el;
-}
+bool ArchSpec::IsMIPS() const { return GetTriple().isMIPS(); }
std::string ArchSpec::GetTargetABI() const {
@@ -652,10 +635,8 @@ void ArchSpec::SetFlags(std::string elf_abi) {
std::string ArchSpec::GetClangTargetCPU() const {
std::string cpu;
- const llvm::Triple::ArchType machine = GetMachine();
- if (machine == llvm::Triple::mips || machine == llvm::Triple::mipsel ||
- machine == llvm::Triple::mips64 || machine == llvm::Triple::mips64el) {
+ if (IsMIPS()) {
switch (m_core) {
case ArchSpec::eCore_mips32:
case ArchSpec::eCore_mips32el:
@@ -729,30 +710,10 @@ uint32_t ArchSpec::GetMachOCPUSubType() const {
}
uint32_t ArchSpec::GetDataByteSize() const {
- switch (m_core) {
- case eCore_kalimba3:
- return 4;
- case eCore_kalimba4:
- return 1;
- case eCore_kalimba5:
- return 4;
- default:
- return 1;
- }
return 1;
}
uint32_t ArchSpec::GetCodeByteSize() const {
- switch (m_core) {
- case eCore_kalimba3:
- return 4;
- case eCore_kalimba4:
- return 1;
- case eCore_kalimba5:
- return 1;
- default:
- return 1;
- }
return 1;
}
@@ -764,7 +725,7 @@ llvm::Triple::ArchType ArchSpec::GetMachine() const {
return llvm::Triple::UnknownArch;
}
-const ConstString &ArchSpec::GetDistributionId() const {
+ConstString ArchSpec::GetDistributionId() const {
return m_distribution_id;
}
@@ -890,10 +851,9 @@ bool ArchSpec::ContainsOnlyArch(const llvm::Triple &normalized_triple) {
}
void ArchSpec::MergeFrom(const ArchSpec &other) {
- if (TripleVendorIsUnspecifiedUnknown() &&
- !other.TripleVendorIsUnspecifiedUnknown())
+ if (!TripleVendorWasSpecified() && other.TripleVendorWasSpecified())
GetTriple().setVendor(other.GetTriple().getVendor());
- if (TripleOSIsUnspecifiedUnknown() && !other.TripleOSIsUnspecifiedUnknown())
+ if (!TripleOSWasSpecified() && other.TripleOSWasSpecified())
GetTriple().setOS(other.GetTriple().getOS());
if (GetTriple().getArch() == llvm::Triple::UnknownArch) {
GetTriple().setArch(other.GetTriple().getArch());
@@ -904,10 +864,9 @@ void ArchSpec::MergeFrom(const ArchSpec &other) {
if (other.GetCore() != eCore_uknownMach64)
UpdateCore();
}
- if (GetTriple().getEnvironment() == llvm::Triple::UnknownEnvironment &&
- !TripleVendorWasSpecified()) {
- if (other.TripleVendorWasSpecified())
- GetTriple().setEnvironment(other.GetTriple().getEnvironment());
+ if (!TripleEnvironmentWasSpecified() &&
+ other.TripleEnvironmentWasSpecified()) {
+ GetTriple().setEnvironment(other.GetTriple().getEnvironment());
}
// If this and other are both arm ArchSpecs and this ArchSpec is a generic
// "some kind of arm" spec but the other ArchSpec is a specific arm core,
@@ -945,13 +904,13 @@ bool ArchSpec::SetArchitecture(ArchitectureType arch_type, uint32_t cpu,
m_triple.setVendor(llvm::Triple::Apple);
// Don't set the OS. It could be simulator, macosx, ios, watchos,
- // tvos, bridgeos. We could get close with the cpu type - but we
- // can't get it right all of the time. Better to leave this unset
- // so other sections of code will set it when they have more
- // information. NB: don't call m_triple.setOS (llvm::Triple::UnknownOS).
- // That sets the OSName to "unknown" and the
- // ArchSpec::TripleVendorWasSpecified() method says that any OSName
- // setting means it was specified.
+ // tvos, bridgeos. We could get close with the cpu type - but we
+ // can't get it right all of the time. Better to leave this unset
+ // so other sections of code will set it when they have more
+ // information. NB: don't call m_triple.setOS
+ // (llvm::Triple::UnknownOS). That sets the OSName to "unknown" and
+ // the ArchSpec::TripleVendorWasSpecified() method says that any
+ // OSName setting means it was specified.
} else if (arch_type == eArchTypeELF) {
switch (os) {
case llvm::ELF::ELFOSABI_AIX:
diff --git a/source/Utility/Args.cpp b/source/Utility/Args.cpp
index 3b5cf1715fb3a..77b0d43254a16 100644
--- a/source/Utility/Args.cpp
+++ b/source/Utility/Args.cpp
@@ -1,9 +1,8 @@
//===-- Args.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -96,7 +95,7 @@ ParseSingleArgument(llvm::StringRef command) {
bool arg_complete = false;
do {
// Skip over over regular characters and append them.
- size_t regular = command.find_first_of(" \t\"'`\\");
+ size_t regular = command.find_first_of(" \t\r\"'`\\");
arg += command.substr(0, regular);
command = command.substr(regular);
@@ -124,6 +123,7 @@ ParseSingleArgument(llvm::StringRef command) {
case ' ':
case '\t':
+ case '\r':
// We are not inside any quotes, we just found a space after an argument.
// We are done.
arg_complete = true;
@@ -166,9 +166,7 @@ Args::ArgEntry::ArgEntry(llvm::StringRef str, char quote) : quote(quote) {
ref = llvm::StringRef(c_str(), size);
}
-//----------------------------------------------------------------------
// Args constructor
-//----------------------------------------------------------------------
Args::Args(llvm::StringRef command) { SetCommandString(command); }
Args::Args(const Args &rhs) { *this = rhs; }
@@ -191,9 +189,7 @@ Args &Args::operator=(const Args &rhs) {
return *this;
}
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
Args::~Args() {}
void Args::Dump(Stream &s, const char *label_name) const {
@@ -546,7 +542,7 @@ void Args::EncodeEscapeSequences(const char *src, std::string &dst) {
p += i - 1;
unsigned long octal_value = ::strtoul(oct_str, nullptr, 8);
if (octal_value <= UINT8_MAX) {
- dst.append(1, (char)octal_value);
+ dst.append(1, static_cast<char>(octal_value));
}
}
break;
@@ -566,7 +562,7 @@ void Args::EncodeEscapeSequences(const char *src, std::string &dst) {
unsigned long hex_value = strtoul(hex_str, nullptr, 16);
if (hex_value <= UINT8_MAX)
- dst.append(1, (char)hex_value);
+ dst.append(1, static_cast<char>(hex_value));
} else {
dst.append(1, 'x');
}
@@ -641,14 +637,15 @@ std::string Args::EscapeLLDBCommandArgument(const std::string &arg,
case '\0':
chars_to_escape = " \t\\'\"`";
break;
- case '\'':
- chars_to_escape = "";
- break;
case '"':
chars_to_escape = "$\"`\\";
break;
+ case '`':
+ case '\'':
+ return arg;
default:
assert(false && "Unhandled quote character");
+ return arg;
}
std::string res;
diff --git a/source/Utility/Baton.cpp b/source/Utility/Baton.cpp
index 786be2fe99813..84e295e246864 100644
--- a/source/Utility/Baton.cpp
+++ b/source/Utility/Baton.cpp
@@ -1,9 +1,8 @@
//===-- Baton.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/Broadcaster.cpp b/source/Utility/Broadcaster.cpp
index 5b9b99801b22b..597888cfa0e2e 100644
--- a/source/Utility/Broadcaster.cpp
+++ b/source/Utility/Broadcaster.cpp
@@ -1,9 +1,8 @@
//===-- Broadcaster.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,6 +18,7 @@
#include <algorithm>
#include <memory>
#include <type_traits>
+#include <utility>
#include <assert.h>
#include <stddef.h>
@@ -28,11 +28,10 @@ using namespace lldb_private;
Broadcaster::Broadcaster(BroadcasterManagerSP manager_sp, const char *name)
: m_broadcaster_sp(std::make_shared<BroadcasterImpl>(*this)),
- m_manager_sp(manager_sp), m_broadcaster_name(name) {
+ m_manager_sp(std::move(manager_sp)), m_broadcaster_name(name) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Broadcaster::Broadcaster(\"%s\")",
- static_cast<void *>(this), GetBroadcasterName().AsCString());
+ LLDB_LOG(log, "{0} Broadcaster::Broadcaster(\"{1}\")",
+ static_cast<void *>(this), GetBroadcasterName().AsCString());
}
Broadcaster::BroadcasterImpl::BroadcasterImpl(Broadcaster &broadcaster)
@@ -41,9 +40,8 @@ Broadcaster::BroadcasterImpl::BroadcasterImpl(Broadcaster &broadcaster)
Broadcaster::~Broadcaster() {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
- if (log)
- log->Printf("%p Broadcaster::~Broadcaster(\"%s\")",
- static_cast<void *>(this), m_broadcaster_name.AsCString());
+ LLDB_LOG(log, "{0} Broadcaster::~Broadcaster(\"{1}\")",
+ static_cast<void *>(this), GetBroadcasterName().AsCString());
Clear();
}
@@ -213,8 +211,7 @@ void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent(EventSP &event_sp,
hijacking_listener_sp.reset();
}
- Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EVENTS));
- if (log) {
+ if (Log *log = lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EVENTS)) {
StreamString event_description;
event_sp->Dump(&event_description);
log->Printf("%p Broadcaster(\"%s\")::BroadcastEvent (event_sp = {%s}, "
@@ -225,18 +222,16 @@ void Broadcaster::BroadcasterImpl::PrivateBroadcastEvent(EventSP &event_sp,
}
if (hijacking_listener_sp) {
- if (unique &&
- hijacking_listener_sp->PeekAtNextEventForBroadcasterWithType(
- &m_broadcaster, event_type))
+ if (unique && hijacking_listener_sp->PeekAtNextEventForBroadcasterWithType(
+ &m_broadcaster, event_type))
return;
hijacking_listener_sp->AddEvent(event_sp);
} else {
for (auto &pair : GetListeners()) {
if (!(pair.second & event_type))
continue;
- if (unique &&
- pair.first->PeekAtNextEventForBroadcasterWithType(&m_broadcaster,
- event_type))
+ if (unique && pair.first->PeekAtNextEventForBroadcasterWithType(
+ &m_broadcaster, event_type))
continue;
pair.first->AddEvent(event_sp);
@@ -267,11 +262,11 @@ bool Broadcaster::BroadcasterImpl::HijackBroadcaster(
std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EVENTS));
- if (log)
- log->Printf(
- "%p Broadcaster(\"%s\")::HijackBroadcaster (listener(\"%s\")=%p)",
- static_cast<void *>(this), GetBroadcasterName(),
- listener_sp->m_name.c_str(), static_cast<void *>(listener_sp.get()));
+ LLDB_LOG(
+ log,
+ "{0} Broadcaster(\"{1}\")::HijackBroadcaster (listener(\"{2}\")={3})",
+ static_cast<void *>(this), GetBroadcasterName(),
+ listener_sp->m_name.c_str(), static_cast<void *>(listener_sp.get()));
m_hijacking_listeners.push_back(listener_sp);
m_hijacking_masks.push_back(event_mask);
return true;
@@ -288,24 +283,22 @@ bool Broadcaster::BroadcasterImpl::IsHijackedForEvent(uint32_t event_mask) {
const char *Broadcaster::BroadcasterImpl::GetHijackingListenerName() {
if (m_hijacking_listeners.size()) {
return m_hijacking_listeners.back()->GetName();
- } else {
- return nullptr;
}
+ return nullptr;
}
void Broadcaster::BroadcasterImpl::RestoreBroadcaster() {
std::lock_guard<std::recursive_mutex> guard(m_listeners_mutex);
if (!m_hijacking_listeners.empty()) {
+ ListenerSP listener_sp = m_hijacking_listeners.back();
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EVENTS));
- if (log) {
- ListenerSP listener_sp = m_hijacking_listeners.back();
- log->Printf("%p Broadcaster(\"%s\")::RestoreBroadcaster (about to pop "
- "listener(\"%s\")=%p)",
- static_cast<void *>(this), GetBroadcasterName(),
- listener_sp->m_name.c_str(),
- static_cast<void *>(listener_sp.get()));
- }
+ LLDB_LOG(log,
+ "{0} Broadcaster(\"{1}\")::RestoreBroadcaster (about to pop "
+ "listener(\"{2}\")={3})",
+ static_cast<void *>(this), GetBroadcasterName(),
+ listener_sp->m_name.c_str(),
+ static_cast<void *>(listener_sp.get()));
m_hijacking_listeners.pop_back();
}
if (!m_hijacking_masks.empty())
@@ -317,14 +310,11 @@ ConstString &Broadcaster::GetBroadcasterClass() const {
return class_name;
}
-BroadcastEventSpec::BroadcastEventSpec(const BroadcastEventSpec &rhs) = default;
-
bool BroadcastEventSpec::operator<(const BroadcastEventSpec &rhs) const {
if (GetBroadcasterClass() == rhs.GetBroadcasterClass()) {
return GetEventBits() < rhs.GetEventBits();
- } else {
- return GetBroadcasterClass() < rhs.GetBroadcasterClass();
}
+ return GetBroadcasterClass() < rhs.GetBroadcasterClass();
}
BroadcastEventSpec &BroadcastEventSpec::
@@ -337,7 +327,7 @@ lldb::BroadcasterManagerSP BroadcasterManager::MakeBroadcasterManager() {
}
uint32_t BroadcasterManager::RegisterListenerForEvents(
- const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec) {
+ const lldb::ListenerSP &listener_sp, const BroadcastEventSpec &event_spec) {
std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
collection::iterator iter = m_event_map.begin(), end_iter = m_event_map.end();
@@ -362,7 +352,7 @@ uint32_t BroadcasterManager::RegisterListenerForEvents(
}
bool BroadcasterManager::UnregisterListenerForEvents(
- const lldb::ListenerSP &listener_sp, BroadcastEventSpec event_spec) {
+ const lldb::ListenerSP &listener_sp, const BroadcastEventSpec &event_spec) {
std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
bool removed_some = false;
@@ -380,17 +370,16 @@ bool BroadcasterManager::UnregisterListenerForEvents(
iter = find_if(m_event_map.begin(), end_iter, predicate);
if (iter == end_iter) {
break;
- } else {
- uint32_t iter_event_bits = (*iter).first.GetEventBits();
- removed_some = true;
-
- if (event_bits_to_remove != iter_event_bits) {
- uint32_t new_event_bits = iter_event_bits & ~event_bits_to_remove;
- to_be_readded.push_back(BroadcastEventSpec(
- event_spec.GetBroadcasterClass(), new_event_bits));
- }
- m_event_map.erase(iter);
}
+ uint32_t iter_event_bits = (*iter).first.GetEventBits();
+ removed_some = true;
+
+ if (event_bits_to_remove != iter_event_bits) {
+ uint32_t new_event_bits = iter_event_bits & ~event_bits_to_remove;
+ to_be_readded.push_back(
+ BroadcastEventSpec(event_spec.GetBroadcasterClass(), new_event_bits));
+ }
+ m_event_map.erase(iter);
}
// Okay now add back the bits that weren't completely removed:
@@ -402,7 +391,7 @@ bool BroadcasterManager::UnregisterListenerForEvents(
}
ListenerSP BroadcasterManager::GetListenerForEventSpec(
- BroadcastEventSpec event_spec) const {
+ const BroadcastEventSpec &event_spec) const {
std::lock_guard<std::recursive_mutex> guard(m_manager_mutex);
collection::const_iterator iter, end_iter = m_event_map.end();
@@ -410,8 +399,8 @@ ListenerSP BroadcasterManager::GetListenerForEventSpec(
BroadcastEventSpecMatches(event_spec));
if (iter != end_iter)
return (*iter).second;
- else
- return nullptr;
+
+ return nullptr;
}
void BroadcasterManager::RemoveListener(Listener *listener) {
@@ -429,8 +418,8 @@ void BroadcasterManager::RemoveListener(Listener *listener) {
iter = find_if(m_event_map.begin(), end_iter, predicate);
if (iter == end_iter)
break;
- else
- m_event_map.erase(iter);
+
+ m_event_map.erase(iter);
}
}
@@ -446,8 +435,8 @@ void BroadcasterManager::RemoveListener(const lldb::ListenerSP &listener_sp) {
iter = find_if(m_event_map.begin(), end_iter, predicate);
if (iter == end_iter)
break;
- else
- m_event_map.erase(iter);
+
+ m_event_map.erase(iter);
}
}
diff --git a/source/Utility/CompletionRequest.cpp b/source/Utility/CompletionRequest.cpp
index 096661b7e99f8..c62ec4f56ffa9 100644
--- a/source/Utility/CompletionRequest.cpp
+++ b/source/Utility/CompletionRequest.cpp
@@ -1,9 +1,8 @@
//===-- CompletionRequest.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/Connection.cpp b/source/Utility/Connection.cpp
index 9f6114f6ed5de..483a0c941be44 100644
--- a/source/Utility/Connection.cpp
+++ b/source/Utility/Connection.cpp
@@ -1,9 +1,8 @@
//===-- Connection.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/ConstString.cpp b/source/Utility/ConstString.cpp
index 9b8bea71e2ad5..46b7ab259383e 100644
--- a/source/Utility/ConstString.cpp
+++ b/source/Utility/ConstString.cpp
@@ -1,9 +1,8 @@
//===-- ConstString.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -144,16 +143,14 @@ public:
const char *GetConstTrimmedCStringWithLength(const char *cstr,
size_t cstr_len) {
if (cstr != nullptr) {
- const size_t trimmed_len = std::min<size_t>(strlen(cstr), cstr_len);
+ const size_t trimmed_len = strnlen(cstr, cstr_len);
return GetConstCStringWithLength(cstr, trimmed_len);
}
return nullptr;
}
- //------------------------------------------------------------------
// Return the size in bytes that this object and any items in its collection
// of uniqued strings + data count values takes in memory.
- //------------------------------------------------------------------
size_t MemorySize() const {
size_t mem_size = sizeof(Pool);
for (const auto &pool : m_string_pools) {
@@ -178,7 +175,6 @@ protected:
std::array<PoolEntry, 256> m_string_pools;
};
-//----------------------------------------------------------------------
// Frameworks and dylibs aren't supposed to have global C++ initializers so we
// hide the string pool in a static function so that it will get initialized on
// the first call to this static function.
@@ -187,7 +183,6 @@ protected:
// can't guarantee that some objects won't get destroyed after the global
// destructor chain is run, and trying to make sure no destructors touch
// ConstStrings is difficult. So we leak the pool instead.
-//----------------------------------------------------------------------
static Pool &StringPool() {
static llvm::once_flag g_pool_initialization_flag;
static Pool *g_string_pool = nullptr;
@@ -205,9 +200,9 @@ ConstString::ConstString(const char *cstr, size_t cstr_len)
: m_string(StringPool().GetConstCStringWithLength(cstr, cstr_len)) {}
ConstString::ConstString(const llvm::StringRef &s)
- : m_string(StringPool().GetConstCStringWithLength(s.data(), s.size())) {}
+ : m_string(StringPool().GetConstCStringWithStringRef(s)) {}
-bool ConstString::operator<(const ConstString &rhs) const {
+bool ConstString::operator<(ConstString rhs) const {
if (m_string == rhs.m_string)
return false;
@@ -222,7 +217,7 @@ bool ConstString::operator<(const ConstString &rhs) const {
return lhs_string_ref.data() == nullptr;
}
-Stream &lldb_private::operator<<(Stream &s, const ConstString &str) {
+Stream &lldb_private::operator<<(Stream &s, ConstString str) {
const char *cstr = str.GetCString();
if (cstr != nullptr)
s << cstr;
@@ -234,7 +229,7 @@ size_t ConstString::GetLength() const {
return Pool::GetConstCStringLength(m_string);
}
-bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs,
+bool ConstString::Equals(ConstString lhs, ConstString rhs,
const bool case_sensitive) {
if (lhs.m_string == rhs.m_string)
return true;
@@ -251,7 +246,7 @@ bool ConstString::Equals(const ConstString &lhs, const ConstString &rhs,
return lhs_string_ref.equals_lower(rhs_string_ref);
}
-int ConstString::Compare(const ConstString &lhs, const ConstString &rhs,
+int ConstString::Compare(ConstString lhs, ConstString rhs,
const bool case_sensitive) {
// If the iterators are the same, this is the same string
const char *lhs_cstr = lhs.m_string;
@@ -303,7 +298,7 @@ void ConstString::SetString(const llvm::StringRef &s) {
}
void ConstString::SetStringWithMangledCounterpart(llvm::StringRef demangled,
- const ConstString &mangled) {
+ ConstString mangled) {
m_string = StringPool().GetConstCStringAndSetMangledCounterPart(
demangled, mangled.m_string);
}
diff --git a/source/Utility/DataBufferHeap.cpp b/source/Utility/DataBufferHeap.cpp
index 36cac0079ac06..5bff7775f138b 100644
--- a/source/Utility/DataBufferHeap.cpp
+++ b/source/Utility/DataBufferHeap.cpp
@@ -1,9 +1,8 @@
//===-- DataBufferHeap.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,64 +11,48 @@
using namespace lldb_private;
-//----------------------------------------------------------------------
// Default constructor
-//----------------------------------------------------------------------
DataBufferHeap::DataBufferHeap() : m_data() {}
-//----------------------------------------------------------------------
// Initialize this class with "n" characters and fill the buffer with "ch".
-//----------------------------------------------------------------------
DataBufferHeap::DataBufferHeap(lldb::offset_t n, uint8_t ch) : m_data() {
if (n < m_data.max_size())
m_data.assign(n, ch);
}
-//----------------------------------------------------------------------
// Initialize this class with a copy of the "n" bytes from the "bytes" buffer.
-//----------------------------------------------------------------------
DataBufferHeap::DataBufferHeap(const void *src, lldb::offset_t src_len)
: m_data() {
CopyData(src, src_len);
}
-//----------------------------------------------------------------------
// Virtual destructor since this class inherits from a pure virtual base class.
-//----------------------------------------------------------------------
DataBufferHeap::~DataBufferHeap() = default;
-//----------------------------------------------------------------------
// Return a pointer to the bytes owned by this object, or nullptr if the object
// contains no bytes.
-//----------------------------------------------------------------------
uint8_t *DataBufferHeap::GetBytes() {
return (m_data.empty() ? nullptr : m_data.data());
}
-//----------------------------------------------------------------------
// Return a const pointer to the bytes owned by this object, or nullptr if the
// object contains no bytes.
-//----------------------------------------------------------------------
const uint8_t *DataBufferHeap::GetBytes() const {
return (m_data.empty() ? nullptr : m_data.data());
}
-//----------------------------------------------------------------------
// Return the number of bytes this object currently contains.
-//----------------------------------------------------------------------
uint64_t DataBufferHeap::GetByteSize() const { return m_data.size(); }
-//----------------------------------------------------------------------
// Sets the number of bytes that this object should be able to contain. This
// can be used prior to copying data into the buffer.
-//----------------------------------------------------------------------
uint64_t DataBufferHeap::SetByteSize(uint64_t new_size) {
m_data.resize(new_size);
return m_data.size();
}
void DataBufferHeap::CopyData(const void *src, uint64_t src_len) {
- const uint8_t *src_u8 = (const uint8_t *)src;
+ const uint8_t *src_u8 = static_cast<const uint8_t *>(src);
if (src && src_len > 0)
m_data.assign(src_u8, src_u8 + src_len);
else
@@ -77,8 +60,8 @@ void DataBufferHeap::CopyData(const void *src, uint64_t src_len) {
}
void DataBufferHeap::AppendData(const void *src, uint64_t src_len) {
- m_data.insert(m_data.end(), (const uint8_t *)src,
- (const uint8_t *)src + src_len);
+ m_data.insert(m_data.end(), static_cast<const uint8_t *>(src),
+ static_cast<const uint8_t *>(src) + src_len);
}
void DataBufferHeap::Clear() {
diff --git a/source/Utility/DataBufferLLVM.cpp b/source/Utility/DataBufferLLVM.cpp
index 0ab3fe5afd46e..4227e9b39960f 100644
--- a/source/Utility/DataBufferLLVM.cpp
+++ b/source/Utility/DataBufferLLVM.cpp
@@ -1,9 +1,8 @@
//===--- DataBufferLLVM.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/DataEncoder.cpp b/source/Utility/DataEncoder.cpp
index c26c0fa63ab34..13c505e34e821 100644
--- a/source/Utility/DataEncoder.cpp
+++ b/source/Utility/DataEncoder.cpp
@@ -1,9 +1,8 @@
//===-- DataEncoder.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,29 +24,24 @@ using namespace lldb;
using namespace lldb_private;
using namespace llvm::support::endian;
-//----------------------------------------------------------------------
// Default constructor.
-//----------------------------------------------------------------------
DataEncoder::DataEncoder()
: m_start(nullptr), m_end(nullptr),
m_byte_order(endian::InlHostByteOrder()), m_addr_size(sizeof(void *)),
m_data_sp() {}
-//----------------------------------------------------------------------
// This constructor allows us to use data that is owned by someone else. The
// data must stay around as long as this object is valid.
-//----------------------------------------------------------------------
DataEncoder::DataEncoder(void *data, uint32_t length, ByteOrder endian,
uint8_t addr_size)
- : m_start((uint8_t *)data), m_end((uint8_t *)data + length),
- m_byte_order(endian), m_addr_size(addr_size), m_data_sp() {}
+ : m_start(static_cast<uint8_t *>(data)),
+ m_end(static_cast<uint8_t *>(data) + length), m_byte_order(endian),
+ m_addr_size(addr_size), m_data_sp() {}
-//----------------------------------------------------------------------
// Make a shared pointer reference to the shared data in "data_sp" and set the
// endian swapping setting to "swap", and the address size to "addr_size". The
// shared data reference will ensure the data lives as long as any DataEncoder
// objects exist that have a reference to this data.
-//----------------------------------------------------------------------
DataEncoder::DataEncoder(const DataBufferSP &data_sp, ByteOrder endian,
uint8_t addr_size)
: m_start(nullptr), m_end(nullptr), m_byte_order(endian),
@@ -57,10 +51,8 @@ DataEncoder::DataEncoder(const DataBufferSP &data_sp, ByteOrder endian,
DataEncoder::~DataEncoder() = default;
-//------------------------------------------------------------------
// Clears the object contents back to a default invalid state, and release any
// references to shared data that this object may contain.
-//------------------------------------------------------------------
void DataEncoder::Clear() {
m_start = nullptr;
m_end = nullptr;
@@ -69,10 +61,8 @@ void DataEncoder::Clear() {
m_data_sp.reset();
}
-//------------------------------------------------------------------
// If this object contains shared data, this function returns the offset into
// that shared data. Else zero is returned.
-//------------------------------------------------------------------
size_t DataEncoder::GetSharedDataOffset() const {
if (m_start != nullptr) {
const DataBuffer *data = m_data_sp.get();
@@ -87,7 +77,6 @@ size_t DataEncoder::GetSharedDataOffset() const {
return 0;
}
-//----------------------------------------------------------------------
// Set the data with which this object will extract from to data starting at
// BYTES and set the length of the data to LENGTH bytes long. The data is
// externally owned must be around at least as long as this object points to
@@ -95,7 +84,6 @@ size_t DataEncoder::GetSharedDataOffset() const {
// and can extract from it. If this object refers to any shared data upon
// entry, the reference to that data will be released. Is SWAP is set to true,
// any data extracted will be endian swapped.
-//----------------------------------------------------------------------
uint32_t DataEncoder::SetData(void *bytes, uint32_t length, ByteOrder endian) {
m_byte_order = endian;
m_data_sp.reset();
@@ -103,13 +91,12 @@ uint32_t DataEncoder::SetData(void *bytes, uint32_t length, ByteOrder endian) {
m_start = nullptr;
m_end = nullptr;
} else {
- m_start = (uint8_t *)bytes;
+ m_start = static_cast<uint8_t *>(bytes);
m_end = m_start + length;
}
return GetByteSize();
}
-//----------------------------------------------------------------------
// Assign the data for this object to be a subrange of the shared data in
// "data_sp" starting "data_offset" bytes into "data_sp" and ending
// "data_length" bytes later. If "data_offset" is not a valid offset into
@@ -121,7 +108,6 @@ uint32_t DataEncoder::SetData(void *bytes, uint32_t length, ByteOrder endian) {
// starting at "data_offset") to ensure the data stays around as long as it is
// needed. The address size and endian swap settings will remain unchanged from
// their current settings.
-//----------------------------------------------------------------------
uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset,
uint32_t data_length) {
m_start = m_end = nullptr;
@@ -153,12 +139,10 @@ uint32_t DataEncoder::SetData(const DataBufferSP &data_sp, uint32_t data_offset,
return new_size;
}
-//----------------------------------------------------------------------
// Extract a single unsigned char from the binary data and update the offset
// pointed to by "offset_ptr".
//
// RETURNS the byte that was extracted, or zero on failure.
-//----------------------------------------------------------------------
uint32_t DataEncoder::PutU8(uint32_t offset, uint8_t value) {
if (ValidOffset(offset)) {
m_start[offset] = value;
@@ -203,7 +187,6 @@ uint32_t DataEncoder::PutU64(uint32_t offset, uint64_t value) {
return UINT32_MAX;
}
-//----------------------------------------------------------------------
// Extract a single integer value from the data and update the offset pointed
// to by "offset_ptr". The size of the extracted integer is specified by the
// "byte_size" argument. "byte_size" should have a value >= 1 and <= 8 since
@@ -212,7 +195,6 @@ uint32_t DataEncoder::PutU64(uint32_t offset, uint64_t value) {
// returned.
//
// RETURNS the integer value that was extracted, or zero on failure.
-//----------------------------------------------------------------------
uint32_t DataEncoder::PutMaxU64(uint32_t offset, uint32_t byte_size,
uint64_t value) {
switch (byte_size) {
diff --git a/source/Utility/DataExtractor.cpp b/source/Utility/DataExtractor.cpp
index ae5a3f9b7d8f9..79a1f75d737c1 100644
--- a/source/Utility/DataExtractor.cpp
+++ b/source/Utility/DataExtractor.cpp
@@ -1,9 +1,8 @@
//===-- DataExtractor.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -125,10 +124,8 @@ DataExtractor::DataExtractor()
m_byte_order(endian::InlHostByteOrder()), m_addr_size(sizeof(void *)),
m_data_sp(), m_target_byte_size(1) {}
-//----------------------------------------------------------------------
// This constructor allows us to use data that is owned by someone else. The
// data must stay around as long as this object is valid.
-//----------------------------------------------------------------------
DataExtractor::DataExtractor(const void *data, offset_t length,
ByteOrder endian, uint32_t addr_size,
uint32_t target_byte_size /*=1*/)
@@ -137,44 +134,34 @@ DataExtractor::DataExtractor(const void *data, offset_t length,
length),
m_byte_order(endian), m_addr_size(addr_size), m_data_sp(),
m_target_byte_size(target_byte_size) {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(addr_size == 4 || addr_size == 8);
-#endif
}
-//----------------------------------------------------------------------
// Make a shared pointer reference to the shared data in "data_sp" and set the
// endian swapping setting to "swap", and the address size to "addr_size". The
// shared data reference will ensure the data lives as long as any
// DataExtractor objects exist that have a reference to this data.
-//----------------------------------------------------------------------
DataExtractor::DataExtractor(const DataBufferSP &data_sp, ByteOrder endian,
uint32_t addr_size,
uint32_t target_byte_size /*=1*/)
: m_start(nullptr), m_end(nullptr), m_byte_order(endian),
m_addr_size(addr_size), m_data_sp(),
m_target_byte_size(target_byte_size) {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(addr_size == 4 || addr_size == 8);
-#endif
SetData(data_sp);
}
-//----------------------------------------------------------------------
// Initialize this object with a subset of the data bytes in "data". If "data"
// contains shared data, then a reference to this shared data will added and
// the shared data will stay around as long as any object contains a reference
// to that data. The endian swap and address size settings are copied from
// "data".
-//----------------------------------------------------------------------
DataExtractor::DataExtractor(const DataExtractor &data, offset_t offset,
offset_t length, uint32_t target_byte_size /*=1*/)
: m_start(nullptr), m_end(nullptr), m_byte_order(data.m_byte_order),
m_addr_size(data.m_addr_size), m_data_sp(),
m_target_byte_size(target_byte_size) {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(m_addr_size == 4 || m_addr_size == 8);
-#endif
if (data.ValidOffset(offset)) {
offset_t bytes_available = data.GetByteSize() - offset;
if (length > bytes_available)
@@ -187,14 +174,10 @@ DataExtractor::DataExtractor(const DataExtractor &rhs)
: m_start(rhs.m_start), m_end(rhs.m_end), m_byte_order(rhs.m_byte_order),
m_addr_size(rhs.m_addr_size), m_data_sp(rhs.m_data_sp),
m_target_byte_size(rhs.m_target_byte_size) {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(m_addr_size == 4 || m_addr_size == 8);
-#endif
}
-//----------------------------------------------------------------------
// Assignment operator
-//----------------------------------------------------------------------
const DataExtractor &DataExtractor::operator=(const DataExtractor &rhs) {
if (this != &rhs) {
m_start = rhs.m_start;
@@ -208,10 +191,8 @@ const DataExtractor &DataExtractor::operator=(const DataExtractor &rhs) {
DataExtractor::~DataExtractor() = default;
-//------------------------------------------------------------------
// Clears the object contents back to a default invalid state, and release any
// references to shared data that this object may contain.
-//------------------------------------------------------------------
void DataExtractor::Clear() {
m_start = nullptr;
m_end = nullptr;
@@ -220,10 +201,8 @@ void DataExtractor::Clear() {
m_data_sp.reset();
}
-//------------------------------------------------------------------
// If this object contains shared data, this function returns the offset into
// that shared data. Else zero is returned.
-//------------------------------------------------------------------
size_t DataExtractor::GetSharedDataOffset() const {
if (m_start != nullptr) {
const DataBuffer *data = m_data_sp.get();
@@ -238,7 +217,6 @@ size_t DataExtractor::GetSharedDataOffset() const {
return 0;
}
-//----------------------------------------------------------------------
// Set the data with which this object will extract from to data starting at
// BYTES and set the length of the data to LENGTH bytes long. The data is
// externally owned must be around at least as long as this object points to
@@ -246,7 +224,6 @@ size_t DataExtractor::GetSharedDataOffset() const {
// and can extract from it. If this object refers to any shared data upon
// entry, the reference to that data will be released. Is SWAP is set to true,
// any data extracted will be endian swapped.
-//----------------------------------------------------------------------
lldb::offset_t DataExtractor::SetData(const void *bytes, offset_t length,
ByteOrder endian) {
m_byte_order = endian;
@@ -261,7 +238,6 @@ lldb::offset_t DataExtractor::SetData(const void *bytes, offset_t length,
return GetByteSize();
}
-//----------------------------------------------------------------------
// Assign the data for this object to be a subrange in "data" starting
// "data_offset" bytes into "data" and ending "data_length" bytes later. If
// "data_offset" is not a valid offset into "data", then this object will
@@ -272,14 +248,11 @@ lldb::offset_t DataExtractor::SetData(const void *bytes, offset_t length,
// a shared pointer to data, then the bytes referred to in "data" will need to
// exist at least as long as this object refers to those bytes. The address
// size and endian swap settings are copied from the current values in "data".
-//----------------------------------------------------------------------
lldb::offset_t DataExtractor::SetData(const DataExtractor &data,
offset_t data_offset,
offset_t data_length) {
m_addr_size = data.m_addr_size;
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(m_addr_size == 4 || m_addr_size == 8);
-#endif
// If "data" contains shared pointer to data, then we can use that
if (data.m_data_sp) {
m_byte_order = data.m_byte_order;
@@ -297,7 +270,6 @@ lldb::offset_t DataExtractor::SetData(const DataExtractor &data,
return 0;
}
-//----------------------------------------------------------------------
// Assign the data for this object to be a subrange of the shared data in
// "data_sp" starting "data_offset" bytes into "data_sp" and ending
// "data_length" bytes later. If "data_offset" is not a valid offset into
@@ -309,7 +281,6 @@ lldb::offset_t DataExtractor::SetData(const DataExtractor &data,
// starting at "data_offset") to ensure the data stays around as long as it is
// needed. The address size and endian swap settings will remain unchanged from
// their current settings.
-//----------------------------------------------------------------------
lldb::offset_t DataExtractor::SetData(const DataBufferSP &data_sp,
offset_t data_offset,
offset_t data_length) {
@@ -342,30 +313,27 @@ lldb::offset_t DataExtractor::SetData(const DataBufferSP &data_sp,
return new_size;
}
-//----------------------------------------------------------------------
// Extract a single unsigned char from the binary data and update the offset
// pointed to by "offset_ptr".
//
// RETURNS the byte that was extracted, or zero on failure.
-//----------------------------------------------------------------------
uint8_t DataExtractor::GetU8(offset_t *offset_ptr) const {
- const uint8_t *data = (const uint8_t *)GetData(offset_ptr, 1);
+ const uint8_t *data = static_cast<const uint8_t *>(GetData(offset_ptr, 1));
if (data)
return *data;
return 0;
}
-//----------------------------------------------------------------------
// Extract "count" unsigned chars from the binary data and update the offset
// pointed to by "offset_ptr". The extracted data is copied into "dst".
//
// RETURNS the non-nullptr buffer pointer upon successful extraction of
// all the requested bytes, or nullptr when the data is not available in the
// buffer due to being out of bounds, or insufficient data.
-//----------------------------------------------------------------------
void *DataExtractor::GetU8(offset_t *offset_ptr, void *dst,
uint32_t count) const {
- const uint8_t *data = (const uint8_t *)GetData(offset_ptr, count);
+ const uint8_t *data =
+ static_cast<const uint8_t *>(GetData(offset_ptr, count));
if (data) {
// Copy the data into the buffer
memcpy(dst, data, count);
@@ -376,15 +344,14 @@ void *DataExtractor::GetU8(offset_t *offset_ptr, void *dst,
return nullptr;
}
-//----------------------------------------------------------------------
// Extract a single uint16_t from the data and update the offset pointed to by
// "offset_ptr".
//
// RETURNS the uint16_t that was extracted, or zero on failure.
-//----------------------------------------------------------------------
uint16_t DataExtractor::GetU16(offset_t *offset_ptr) const {
uint16_t val = 0;
- const uint8_t *data = (const uint8_t *)GetData(offset_ptr, sizeof(val));
+ const uint8_t *data =
+ static_cast<const uint8_t *>(GetData(offset_ptr, sizeof(val)));
if (data) {
if (m_byte_order != endian::InlHostByteOrder())
val = ReadSwapInt16(data);
@@ -424,21 +391,20 @@ uint64_t DataExtractor::GetU64_unchecked(offset_t *offset_ptr) const {
return val;
}
-//----------------------------------------------------------------------
// Extract "count" uint16_t values from the binary data and update the offset
// pointed to by "offset_ptr". The extracted data is copied into "dst".
//
// RETURNS the non-nullptr buffer pointer upon successful extraction of
// all the requested bytes, or nullptr when the data is not available in the
// buffer due to being out of bounds, or insufficient data.
-//----------------------------------------------------------------------
void *DataExtractor::GetU16(offset_t *offset_ptr, void *void_dst,
uint32_t count) const {
const size_t src_size = sizeof(uint16_t) * count;
- const uint16_t *src = (const uint16_t *)GetData(offset_ptr, src_size);
+ const uint16_t *src =
+ static_cast<const uint16_t *>(GetData(offset_ptr, src_size));
if (src) {
if (m_byte_order != endian::InlHostByteOrder()) {
- uint16_t *dst_pos = (uint16_t *)void_dst;
+ uint16_t *dst_pos = static_cast<uint16_t *>(void_dst);
uint16_t *dst_end = dst_pos + count;
const uint16_t *src_pos = src;
while (dst_pos < dst_end) {
@@ -456,15 +422,14 @@ void *DataExtractor::GetU16(offset_t *offset_ptr, void *void_dst,
return nullptr;
}
-//----------------------------------------------------------------------
// Extract a single uint32_t from the data and update the offset pointed to by
// "offset_ptr".
//
// RETURNS the uint32_t that was extracted, or zero on failure.
-//----------------------------------------------------------------------
uint32_t DataExtractor::GetU32(offset_t *offset_ptr) const {
uint32_t val = 0;
- const uint8_t *data = (const uint8_t *)GetData(offset_ptr, sizeof(val));
+ const uint8_t *data =
+ static_cast<const uint8_t *>(GetData(offset_ptr, sizeof(val)));
if (data) {
if (m_byte_order != endian::InlHostByteOrder()) {
val = ReadSwapInt32(data);
@@ -475,21 +440,20 @@ uint32_t DataExtractor::GetU32(offset_t *offset_ptr) const {
return val;
}
-//----------------------------------------------------------------------
// Extract "count" uint32_t values from the binary data and update the offset
// pointed to by "offset_ptr". The extracted data is copied into "dst".
//
// RETURNS the non-nullptr buffer pointer upon successful extraction of
// all the requested bytes, or nullptr when the data is not available in the
// buffer due to being out of bounds, or insufficient data.
-//----------------------------------------------------------------------
void *DataExtractor::GetU32(offset_t *offset_ptr, void *void_dst,
uint32_t count) const {
const size_t src_size = sizeof(uint32_t) * count;
- const uint32_t *src = (const uint32_t *)GetData(offset_ptr, src_size);
+ const uint32_t *src =
+ static_cast<const uint32_t *>(GetData(offset_ptr, src_size));
if (src) {
if (m_byte_order != endian::InlHostByteOrder()) {
- uint32_t *dst_pos = (uint32_t *)void_dst;
+ uint32_t *dst_pos = static_cast<uint32_t *>(void_dst);
uint32_t *dst_end = dst_pos + count;
const uint32_t *src_pos = src;
while (dst_pos < dst_end) {
@@ -507,15 +471,14 @@ void *DataExtractor::GetU32(offset_t *offset_ptr, void *void_dst,
return nullptr;
}
-//----------------------------------------------------------------------
// Extract a single uint64_t from the data and update the offset pointed to by
// "offset_ptr".
//
// RETURNS the uint64_t that was extracted, or zero on failure.
-//----------------------------------------------------------------------
uint64_t DataExtractor::GetU64(offset_t *offset_ptr) const {
uint64_t val = 0;
- const uint8_t *data = (const uint8_t *)GetData(offset_ptr, sizeof(val));
+ const uint8_t *data =
+ static_cast<const uint8_t *>(GetData(offset_ptr, sizeof(val)));
if (data) {
if (m_byte_order != endian::InlHostByteOrder()) {
val = ReadSwapInt64(data);
@@ -526,20 +489,19 @@ uint64_t DataExtractor::GetU64(offset_t *offset_ptr) const {
return val;
}
-//----------------------------------------------------------------------
// GetU64
//
// Get multiple consecutive 64 bit values. Return true if the entire read
// succeeds and increment the offset pointed to by offset_ptr, else return
// false and leave the offset pointed to by offset_ptr unchanged.
-//----------------------------------------------------------------------
void *DataExtractor::GetU64(offset_t *offset_ptr, void *void_dst,
uint32_t count) const {
const size_t src_size = sizeof(uint64_t) * count;
- const uint64_t *src = (const uint64_t *)GetData(offset_ptr, src_size);
+ const uint64_t *src =
+ static_cast<const uint64_t *>(GetData(offset_ptr, src_size));
if (src) {
if (m_byte_order != endian::InlHostByteOrder()) {
- uint64_t *dst_pos = (uint64_t *)void_dst;
+ uint64_t *dst_pos = static_cast<uint64_t *>(void_dst);
uint64_t *dst_end = dst_pos + count;
const uint64_t *src_pos = src;
while (dst_pos < dst_end) {
@@ -640,10 +602,11 @@ int64_t DataExtractor::GetMaxS64Bitfield(offset_t *offset_ptr, size_t size,
lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
if (lsbcount > 0)
sval64 >>= lsbcount;
- uint64_t bitfield_mask = (((uint64_t)1) << bitfield_bit_size) - 1;
+ uint64_t bitfield_mask =
+ ((static_cast<uint64_t>(1)) << bitfield_bit_size) - 1;
sval64 &= bitfield_mask;
// sign extend if needed
- if (sval64 & (((uint64_t)1) << (bitfield_bit_size - 1)))
+ if (sval64 & ((static_cast<uint64_t>(1)) << (bitfield_bit_size - 1)))
sval64 |= ~bitfield_mask;
}
return sval64;
@@ -653,11 +616,12 @@ float DataExtractor::GetFloat(offset_t *offset_ptr) const {
typedef float float_type;
float_type val = 0.0;
const size_t src_size = sizeof(float_type);
- const float_type *src = (const float_type *)GetData(offset_ptr, src_size);
+ const float_type *src =
+ static_cast<const float_type *>(GetData(offset_ptr, src_size));
if (src) {
if (m_byte_order != endian::InlHostByteOrder()) {
- const uint8_t *src_data = (const uint8_t *)src;
- uint8_t *dst_data = (uint8_t *)&val;
+ const uint8_t *src_data = reinterpret_cast<const uint8_t *>(src);
+ uint8_t *dst_data = reinterpret_cast<uint8_t *>(&val);
for (size_t i = 0; i < sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
} else {
@@ -671,11 +635,12 @@ double DataExtractor::GetDouble(offset_t *offset_ptr) const {
typedef double float_type;
float_type val = 0.0;
const size_t src_size = sizeof(float_type);
- const float_type *src = (const float_type *)GetData(offset_ptr, src_size);
+ const float_type *src =
+ static_cast<const float_type *>(GetData(offset_ptr, src_size));
if (src) {
if (m_byte_order != endian::InlHostByteOrder()) {
- const uint8_t *src_data = (const uint8_t *)src;
- uint8_t *dst_data = (uint8_t *)&val;
+ const uint8_t *src_data = reinterpret_cast<const uint8_t *>(src);
+ uint8_t *dst_data = reinterpret_cast<uint8_t *>(&val);
for (size_t i = 0; i < sizeof(float_type); ++i)
dst_data[sizeof(float_type) - 1 - i] = src_data[i];
} else {
@@ -698,40 +663,30 @@ long double DataExtractor::GetLongDouble(offset_t *offset_ptr) const {
return val;
}
-//------------------------------------------------------------------
// Extract a single address from the data and update the offset pointed to by
// "offset_ptr". The size of the extracted address comes from the
// "this->m_addr_size" member variable and should be set correctly prior to
// extracting any address values.
//
// RETURNS the address that was extracted, or zero on failure.
-//------------------------------------------------------------------
uint64_t DataExtractor::GetAddress(offset_t *offset_ptr) const {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(m_addr_size == 4 || m_addr_size == 8);
-#endif
return GetMaxU64(offset_ptr, m_addr_size);
}
uint64_t DataExtractor::GetAddress_unchecked(offset_t *offset_ptr) const {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(m_addr_size == 4 || m_addr_size == 8);
-#endif
return GetMaxU64_unchecked(offset_ptr, m_addr_size);
}
-//------------------------------------------------------------------
// Extract a single pointer from the data and update the offset pointed to by
// "offset_ptr". The size of the extracted pointer comes from the
// "this->m_addr_size" member variable and should be set correctly prior to
// extracting any pointer values.
//
// RETURNS the pointer that was extracted, or zero on failure.
-//------------------------------------------------------------------
uint64_t DataExtractor::GetPointer(offset_t *offset_ptr) const {
-#ifdef LLDB_CONFIGURATION_DEBUG
assert(m_addr_size == 4 || m_addr_size == 8);
-#endif
return GetMaxU64(offset_ptr, m_addr_size);
}
@@ -745,7 +700,7 @@ size_t DataExtractor::ExtractBytes(offset_t offset, offset_t length,
length == 10 || length == 16 || length == 32);
for (uint32_t i = 0; i < length; ++i)
- ((uint8_t *)dst)[i] = src[length - i - 1];
+ (static_cast<uint8_t *>(dst))[i] = src[length - i - 1];
} else
::memcpy(dst, src, length);
return length;
@@ -791,8 +746,8 @@ DataExtractor::CopyByteOrderedData(offset_t src_offset, offset_t src_len,
!(m_byte_order == eByteOrderBig || m_byte_order == eByteOrderLittle))
return 0;
- uint8_t *dst = (uint8_t *)dst_void_ptr;
- const uint8_t *src = (const uint8_t *)PeekData(src_offset, src_len);
+ uint8_t *dst = static_cast<uint8_t *>(dst_void_ptr);
+ const uint8_t *src = PeekData(src_offset, src_len);
if (src) {
if (dst_len >= src_len) {
// We are copying the entire value from src into dst. Calculate how many,
@@ -853,7 +808,6 @@ DataExtractor::CopyByteOrderedData(offset_t src_offset, offset_t src_len,
return 0;
}
-//----------------------------------------------------------------------
// Extracts a variable length NULL terminated C string from the data at the
// offset pointed to by "offset_ptr". The "offset_ptr" will be updated with
// the offset of the byte that follows the NULL terminator byte.
@@ -861,12 +815,11 @@ DataExtractor::CopyByteOrderedData(offset_t src_offset, offset_t src_len,
// If the offset pointed to by "offset_ptr" is out of bounds, or if "length" is
// non-zero and there aren't enough available bytes, nullptr will be returned
// and "offset_ptr" will not be updated.
-//----------------------------------------------------------------------
const char *DataExtractor::GetCStr(offset_t *offset_ptr) const {
- const char *cstr = (const char *)PeekData(*offset_ptr, 1);
+ const char *cstr = reinterpret_cast<const char *>(PeekData(*offset_ptr, 1));
if (cstr) {
const char *cstr_end = cstr;
- const char *end = (const char *)m_end;
+ const char *end = reinterpret_cast<const char *>(m_end);
while (cstr_end < end && *cstr_end)
++cstr_end;
@@ -885,7 +838,6 @@ const char *DataExtractor::GetCStr(offset_t *offset_ptr) const {
return nullptr;
}
-//----------------------------------------------------------------------
// Extracts a NULL terminated C string from the fixed length field of length
// "len" at the offset pointed to by "offset_ptr". The "offset_ptr" will be
// updated with the offset of the byte that follows the fixed length field.
@@ -894,9 +846,8 @@ const char *DataExtractor::GetCStr(offset_t *offset_ptr) const {
// 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 and "offset_ptr"
// will not be updated.
-//----------------------------------------------------------------------
const char *DataExtractor::GetCStr(offset_t *offset_ptr, offset_t len) const {
- const char *cstr = (const char *)PeekData(*offset_ptr, len);
+ const char *cstr = reinterpret_cast<const char *>(PeekData(*offset_ptr, len));
if (cstr != nullptr) {
if (memchr(cstr, '\0', len) == nullptr) {
return nullptr;
@@ -907,28 +858,24 @@ const char *DataExtractor::GetCStr(offset_t *offset_ptr, offset_t len) const {
return nullptr;
}
-//------------------------------------------------------------------
// 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
// "offset" is verified to be a valid offset.
//
// Returns a valid C string pointer if "offset" is a valid offset in this
// object's data, else nullptr is returned.
-//------------------------------------------------------------------
const char *DataExtractor::PeekCStr(offset_t offset) const {
- return (const char *)PeekData(offset, 1);
+ return reinterpret_cast<const char *>(PeekData(offset, 1));
}
-//----------------------------------------------------------------------
// Extracts an unsigned LEB128 number from this object's data starting at the
// offset pointed to by "offset_ptr". The offset pointed to by "offset_ptr"
// will be updated with the offset of the byte following the last extracted
// byte.
//
// Returned the extracted integer value.
-//----------------------------------------------------------------------
uint64_t DataExtractor::GetULEB128(offset_t *offset_ptr) const {
- const uint8_t *src = (const uint8_t *)PeekData(*offset_ptr, 1);
+ const uint8_t *src = PeekData(*offset_ptr, 1);
if (src == nullptr)
return 0;
@@ -941,7 +888,7 @@ uint64_t DataExtractor::GetULEB128(offset_t *offset_ptr) const {
int shift = 7;
while (src < end) {
uint8_t byte = *src++;
- result |= (uint64_t)(byte & 0x7f) << shift;
+ result |= static_cast<uint64_t>(byte & 0x7f) << shift;
if ((byte & 0x80) == 0)
break;
shift += 7;
@@ -954,16 +901,14 @@ uint64_t DataExtractor::GetULEB128(offset_t *offset_ptr) const {
return 0;
}
-//----------------------------------------------------------------------
// Extracts an signed LEB128 number from this object's data starting at the
// offset pointed to by "offset_ptr". The offset pointed to by "offset_ptr"
// will be updated with the offset of the byte following the last extracted
// byte.
//
// Returned the extracted integer value.
-//----------------------------------------------------------------------
int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) const {
- const uint8_t *src = (const uint8_t *)PeekData(*offset_ptr, 1);
+ const uint8_t *src = PeekData(*offset_ptr, 1);
if (src == nullptr)
return 0;
@@ -980,7 +925,7 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) const {
while (src < end) {
bytecount++;
byte = *src++;
- result |= (int64_t)(byte & 0x7f) << shift;
+ result |= static_cast<int64_t>(byte & 0x7f) << shift;
shift += 7;
if ((byte & 0x80) == 0)
break;
@@ -996,17 +941,15 @@ int64_t DataExtractor::GetSLEB128(offset_t *offset_ptr) const {
return 0;
}
-//----------------------------------------------------------------------
// Skips a ULEB128 number (signed or unsigned) from this object's data starting
// at the offset pointed to by "offset_ptr". The offset pointed to by
// "offset_ptr" will be updated with the offset of the byte following the last
// extracted byte.
//
// Returns the number of bytes consumed during the extraction.
-//----------------------------------------------------------------------
uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const {
uint32_t bytes_consumed = 0;
- const uint8_t *src = (const uint8_t *)PeekData(*offset_ptr, 1);
+ const uint8_t *src = PeekData(*offset_ptr, 1);
if (src == nullptr)
return 0;
@@ -1021,7 +964,6 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const {
return bytes_consumed;
}
-//----------------------------------------------------------------------
// Dumps bytes from this object's data to the stream "s" starting
// "start_offset" bytes into this data, and ending with the byte before
// "end_offset". "base_addr" will be added to the offset into the dumped data
@@ -1031,7 +973,6 @@ uint32_t DataExtractor::Skip_LEB128(offset_t *offset_ptr) const {
// printf style formatting string. If "type_format" is nullptr, then an
// appropriate format string will be used for the supplied "type". If the
// stream "s" is nullptr, then the output will be send to Log().
-//----------------------------------------------------------------------
lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset,
offset_t length, uint64_t base_addr,
uint32_t num_per_line,
@@ -1055,7 +996,7 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset,
// Reset string offset and fill the current line string with address:
if (base_addr != LLDB_INVALID_ADDRESS)
sstr.Printf("0x%8.8" PRIx64 ":",
- (uint64_t)(base_addr + (offset - start_offset)));
+ static_cast<uint64_t>(base_addr + (offset - start_offset)));
}
switch (type) {
diff --git a/source/Utility/Environment.cpp b/source/Utility/Environment.cpp
index ea20267a2362e..1405336007124 100644
--- a/source/Utility/Environment.cpp
+++ b/source/Utility/Environment.cpp
@@ -1,9 +1,8 @@
//===-- Environment.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/Event.cpp b/source/Utility/Event.cpp
index ad9f6e340f8cd..579d0dac86ed6 100644
--- a/source/Utility/Event.cpp
+++ b/source/Utility/Event.cpp
@@ -1,9 +1,8 @@
//===-- Event.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,9 +25,7 @@ using namespace lldb_private;
#pragma mark -
#pragma mark Event
-//------------------------------------------------------------------
// Event functions
-//------------------------------------------------------------------
Event::Event(Broadcaster *broadcaster, uint32_t event_type, EventData *data)
: m_broadcaster_wp(broadcaster->GetBroadcasterImpl()), m_type(event_type),
@@ -88,9 +85,7 @@ void Event::DoOnRemoval() {
#pragma mark -
#pragma mark EventData
-//------------------------------------------------------------------
// EventData functions
-//------------------------------------------------------------------
EventData::EventData() = default;
@@ -101,9 +96,7 @@ void EventData::Dump(Stream *s) const { s->PutCString("Generic Event Data"); }
#pragma mark -
#pragma mark EventDataBytes
-//------------------------------------------------------------------
// EventDataBytes functions
-//------------------------------------------------------------------
EventDataBytes::EventDataBytes() : m_bytes() {}
@@ -121,12 +114,12 @@ EventDataBytes::EventDataBytes(const void *src, size_t src_len) : m_bytes() {
EventDataBytes::~EventDataBytes() = default;
-const ConstString &EventDataBytes::GetFlavorString() {
+ConstString EventDataBytes::GetFlavorString() {
static ConstString g_flavor("EventDataBytes");
return g_flavor;
}
-const ConstString &EventDataBytes::GetFlavor() const {
+ConstString EventDataBytes::GetFlavor() const {
return EventDataBytes::GetFlavorString();
}
@@ -150,7 +143,7 @@ size_t EventDataBytes::GetByteSize() const { return m_bytes.size(); }
void EventDataBytes::SetBytes(const void *src, size_t src_len) {
if (src != nullptr && src_len > 0)
- m_bytes.assign((const char *)src, src_len);
+ m_bytes.assign(static_cast<const char *>(src), src_len);
else
m_bytes.clear();
}
@@ -194,9 +187,7 @@ void EventDataBytes::SwapBytes(std::string &new_bytes) {
#pragma mark -
#pragma mark EventStructuredData
-//------------------------------------------------------------------
// EventDataStructuredData definitions
-//------------------------------------------------------------------
EventDataStructuredData::EventDataStructuredData()
: EventData(), m_process_sp(), m_object_sp(), m_plugin_sp() {}
@@ -209,11 +200,9 @@ EventDataStructuredData::EventDataStructuredData(
EventDataStructuredData::~EventDataStructuredData() {}
-//------------------------------------------------------------------
// EventDataStructuredData member functions
-//------------------------------------------------------------------
-const ConstString &EventDataStructuredData::GetFlavor() const {
+ConstString EventDataStructuredData::GetFlavor() const {
return EventDataStructuredData::GetFlavorString();
}
@@ -252,9 +241,7 @@ void EventDataStructuredData::SetStructuredDataPlugin(
m_plugin_sp = plugin_sp;
}
-//------------------------------------------------------------------
// EventDataStructuredData static functions
-//------------------------------------------------------------------
const EventDataStructuredData *
EventDataStructuredData::GetEventDataFromEvent(const Event *event_ptr) {
@@ -295,7 +282,7 @@ EventDataStructuredData::GetPluginFromEvent(const Event *event_ptr) {
return StructuredDataPluginSP();
}
-const ConstString &EventDataStructuredData::GetFlavorString() {
+ConstString EventDataStructuredData::GetFlavorString() {
static ConstString s_flavor("EventDataStructuredData");
return s_flavor;
}
diff --git a/source/Utility/FileCollector.cpp b/source/Utility/FileCollector.cpp
new file mode 100644
index 0000000000000..ed93591922056
--- /dev/null
+++ b/source/Utility/FileCollector.cpp
@@ -0,0 +1,182 @@
+//===-- FileCollector.cpp ---------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/FileCollector.h"
+
+#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
+
+using namespace lldb_private;
+using namespace llvm;
+
+static bool IsCaseSensitivePath(StringRef path) {
+ SmallString<256> tmp_dest = path, upper_dest, real_dest;
+
+ // Remove component traversals, links, etc.
+ if (!sys::fs::real_path(path, tmp_dest))
+ return true; // Current default value in vfs.yaml
+ path = tmp_dest;
+
+ // Change path to all upper case and ask for its real path, if the latter
+ // exists and is equal to path, it's not case sensitive. Default to case
+ // sensitive in the absence of real_path, since this is the YAMLVFSWriter
+ // default.
+ upper_dest = path.upper();
+ if (sys::fs::real_path(upper_dest, real_dest) && path.equals(real_dest))
+ return false;
+ return true;
+}
+
+FileCollector::FileCollector(const FileSpec &root, const FileSpec &overlay_root)
+ : m_root(root), m_overlay_root(overlay_root) {
+ sys::fs::create_directories(m_root.GetPath(), true);
+}
+
+bool FileCollector::GetRealPath(StringRef src_path,
+ SmallVectorImpl<char> &result) {
+ SmallString<256> real_path;
+ StringRef FileName = sys::path::filename(src_path);
+ std::string directory = sys::path::parent_path(src_path).str();
+ auto dir_with_symlink = m_symlink_map.find(directory);
+
+ // Use real_path to fix any symbolic link component present in a path.
+ // Computing the real path is expensive, cache the search through the
+ // parent path directory.
+ if (dir_with_symlink == m_symlink_map.end()) {
+ auto ec = sys::fs::real_path(directory, real_path);
+ if (ec)
+ return false;
+ m_symlink_map[directory] = real_path.str();
+ } else {
+ real_path = dir_with_symlink->second;
+ }
+
+ sys::path::append(real_path, FileName);
+ result.swap(real_path);
+ return true;
+}
+
+void FileCollector::AddFile(const Twine &file) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ std::string file_str = file.str();
+ if (MarkAsSeen(file_str))
+ AddFileImpl(file_str);
+}
+
+void FileCollector::AddFileImpl(StringRef src_path) {
+ std::string root = m_root.GetPath();
+
+ // We need an absolute src path to append to the root.
+ SmallString<256> absolute_src = src_path;
+ sys::fs::make_absolute(absolute_src);
+
+ // Canonicalize src to a native path to avoid mixed separator styles.
+ sys::path::native(absolute_src);
+
+ // Remove redundant leading "./" pieces and consecutive separators.
+ absolute_src = sys::path::remove_leading_dotslash(absolute_src);
+
+ // Canonicalize the source path by removing "..", "." components.
+ SmallString<256> virtual_path = absolute_src;
+ sys::path::remove_dots(virtual_path, /*remove_dot_dot=*/true);
+
+ // If a ".." component is present after a symlink component, remove_dots may
+ // lead to the wrong real destination path. Let the source be canonicalized
+ // like that but make sure we always use the real path for the destination.
+ SmallString<256> copy_from;
+ if (!GetRealPath(absolute_src, copy_from))
+ copy_from = virtual_path;
+
+ SmallString<256> dst_path = StringRef(root);
+ sys::path::append(dst_path, sys::path::relative_path(copy_from));
+
+ // Always map a canonical src path to its real path into the YAML, by doing
+ // this we map different virtual src paths to the same entry in the VFS
+ // overlay, which is a way to emulate symlink inside the VFS; this is also
+ // needed for correctness, not doing that can lead to module redefinition
+ // errors.
+ AddFileToMapping(virtual_path, dst_path);
+}
+
+/// Set the access and modification time for the given file from the given
+/// status object.
+static std::error_code
+CopyAccessAndModificationTime(StringRef filename,
+ const sys::fs::file_status &stat) {
+ int fd;
+
+ if (auto ec =
+ sys::fs::openFileForWrite(filename, fd, sys::fs::CD_OpenExisting))
+ return ec;
+
+ if (auto ec = sys::fs::setLastAccessAndModificationTime(
+ fd, stat.getLastAccessedTime(), stat.getLastModificationTime()))
+ return ec;
+
+ if (auto ec = sys::Process::SafelyCloseFileDescriptor(fd))
+ return ec;
+
+ return {};
+}
+
+std::error_code FileCollector::CopyFiles(bool stop_on_error) {
+ for (auto &entry : m_vfs_writer.getMappings()) {
+ // Create directory tree.
+ if (std::error_code ec =
+ sys::fs::create_directories(sys::path::parent_path(entry.RPath),
+ /*IgnoreExisting=*/true)) {
+ if (stop_on_error)
+ return ec;
+ }
+
+ // Copy file over.
+ if (std::error_code ec = sys::fs::copy_file(entry.VPath, entry.RPath)) {
+ if (stop_on_error)
+ return ec;
+ }
+
+ // Copy over permissions.
+ if (auto perms = sys::fs::getPermissions(entry.VPath)) {
+ if (std::error_code ec = sys::fs::setPermissions(entry.RPath, *perms)) {
+ if (stop_on_error)
+ return ec;
+ }
+ }
+
+ // Copy over modification time.
+ sys::fs::file_status stat;
+ if (std::error_code ec = sys::fs::status(entry.VPath, stat)) {
+ if (stop_on_error)
+ return ec;
+ continue;
+ }
+ CopyAccessAndModificationTime(entry.RPath, stat);
+ }
+ return {};
+}
+
+std::error_code FileCollector::WriteMapping(const FileSpec &mapping_file) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+
+ std::string root = m_overlay_root.GetPath();
+
+ m_vfs_writer.setOverlayDir(root);
+ m_vfs_writer.setCaseSensitivity(IsCaseSensitivePath(root));
+ m_vfs_writer.setUseExternalNames(false);
+
+ std::error_code ec;
+ raw_fd_ostream os(mapping_file.GetPath(), ec, sys::fs::F_Text);
+ if (ec)
+ return ec;
+
+ m_vfs_writer.write(os);
+
+ return {};
+}
diff --git a/source/Utility/FileSpec.cpp b/source/Utility/FileSpec.cpp
index 954968b7a8afa..35d22404b9480 100644
--- a/source/Utility/FileSpec.cpp
+++ b/source/Utility/FileSpec.cpp
@@ -1,9 +1,8 @@
//===-- FileSpec.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -68,9 +67,7 @@ void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) {
FileSpec::FileSpec() : m_style(GetNativeStyle()) {}
-//------------------------------------------------------------------
// Default constructor that can take an optional full path to a file on disk.
-//------------------------------------------------------------------
FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {
SetFile(path, style);
}
@@ -78,47 +75,33 @@ FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {
FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &Triple)
: FileSpec{path, Triple.isOSWindows() ? Style::windows : Style::posix} {}
-//------------------------------------------------------------------
-// Copy constructor
-//------------------------------------------------------------------
-FileSpec::FileSpec(const FileSpec &rhs)
- : m_directory(rhs.m_directory), m_filename(rhs.m_filename),
- m_is_resolved(rhs.m_is_resolved), m_style(rhs.m_style) {}
-
-//------------------------------------------------------------------
// Copy constructor
-//------------------------------------------------------------------
FileSpec::FileSpec(const FileSpec *rhs) : m_directory(), m_filename() {
if (rhs)
*this = *rhs;
}
-//------------------------------------------------------------------
// Virtual destructor in case anyone inherits from this class.
-//------------------------------------------------------------------
FileSpec::~FileSpec() {}
namespace {
-//------------------------------------------------------------------
/// Safely get a character at the specified index.
///
-/// @param[in] path
+/// \param[in] path
/// A full, partial, or relative path to a file.
///
-/// @param[in] i
+/// \param[in] i
/// An index into path which may or may not be valid.
///
-/// @return
+/// \return
/// The character at index \a i if the index is valid, or 0 if
/// the index is not valid.
-//------------------------------------------------------------------
inline char safeCharAtIndex(const llvm::StringRef &path, size_t i) {
if (i < path.size())
return path[i];
return 0;
}
-//------------------------------------------------------------------
/// Check if a path needs to be normalized.
///
/// Check if a path needs to be normalized. We currently consider a
@@ -131,12 +114,11 @@ inline char safeCharAtIndex(const llvm::StringRef &path, size_t i) {
/// need normalization since we aren't trying to resolve the path,
/// we are just trying to remove redundant things from the path.
///
-/// @param[in] path
+/// \param[in] path
/// A full, partial, or relative path to a file.
///
-/// @return
+/// \return
/// Returns \b true if the path needs to be normalized.
-//------------------------------------------------------------------
bool needsNormalization(const llvm::StringRef &path) {
if (path.empty())
return false;
@@ -192,9 +174,7 @@ bool needsNormalization(const llvm::StringRef &path) {
}
-//------------------------------------------------------------------
// Assignment operator.
-//------------------------------------------------------------------
const FileSpec &FileSpec::operator=(const FileSpec &rhs) {
if (this != &rhs) {
m_directory = rhs.m_directory;
@@ -207,11 +187,9 @@ const FileSpec &FileSpec::operator=(const FileSpec &rhs) {
void FileSpec::SetFile(llvm::StringRef pathname) { SetFile(pathname, m_style); }
-//------------------------------------------------------------------
// 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.
-//------------------------------------------------------------------
void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
m_filename.Clear();
m_directory.Clear();
@@ -254,22 +232,18 @@ void FileSpec::SetFile(llvm::StringRef path, const llvm::Triple &Triple) {
return SetFile(path, Triple.isOSWindows() ? Style::windows : Style::posix);
}
-//----------------------------------------------------------------------
// Convert to pointer operator. This allows code to check any FileSpec objects
// to see if they contain anything valid using code such as:
//
// if (file_spec)
// {}
-//----------------------------------------------------------------------
FileSpec::operator bool() const { return m_filename || m_directory; }
-//----------------------------------------------------------------------
// Logical NOT operator. This allows code to check any FileSpec objects to see
// if they are invalid using code such as:
//
// if (!file_spec)
// {}
-//----------------------------------------------------------------------
bool FileSpec::operator!() const { return !m_directory && !m_filename; }
bool FileSpec::DirectoryEquals(const FileSpec &rhs) const {
@@ -282,43 +256,32 @@ bool FileSpec::FileEquals(const FileSpec &rhs) const {
return ConstString::Equals(m_filename, rhs.m_filename, case_sensitive);
}
-//------------------------------------------------------------------
// Equal to operator
-//------------------------------------------------------------------
bool FileSpec::operator==(const FileSpec &rhs) const {
return FileEquals(rhs) && DirectoryEquals(rhs);
}
-//------------------------------------------------------------------
// Not equal to operator
-//------------------------------------------------------------------
bool FileSpec::operator!=(const FileSpec &rhs) const { return !(*this == rhs); }
-//------------------------------------------------------------------
// Less than operator
-//------------------------------------------------------------------
bool FileSpec::operator<(const FileSpec &rhs) const {
return FileSpec::Compare(*this, rhs, true) < 0;
}
-//------------------------------------------------------------------
// Dump a FileSpec object to a stream
-//------------------------------------------------------------------
Stream &lldb_private::operator<<(Stream &s, const FileSpec &f) {
f.Dump(&s);
return s;
}
-//------------------------------------------------------------------
// Clear this object by releasing both the directory and filename string values
// and making them both the empty string.
-//------------------------------------------------------------------
void FileSpec::Clear() {
m_directory.Clear();
m_filename.Clear();
}
-//------------------------------------------------------------------
// Compare two FileSpec objects. If "full" is true, then both the directory and
// the filename must match. If "full" is false, then the directory names for
// "a" and "b" are only compared if they are both non-empty. This allows a
@@ -327,7 +290,6 @@ void FileSpec::Clear() {
//
// Return -1 if the "a" is less than "b", 0 if "a" is equal to "b" and "1" if
// "a" is greater than "b".
-//------------------------------------------------------------------
int FileSpec::Compare(const FileSpec &a, const FileSpec &b, bool full) {
int result = 0;
@@ -366,11 +328,20 @@ bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full) {
return a == b;
}
-//------------------------------------------------------------------
+llvm::Optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolute_path) {
+ if (absolute_path.startswith("/"))
+ return Style::posix;
+ if (absolute_path.startswith(R"(\\)"))
+ return Style::windows;
+ if (absolute_path.size() > 3 && llvm::isAlpha(absolute_path[0]) &&
+ absolute_path.substr(1, 2) == R"(:\)")
+ return Style::windows;
+ return llvm::None;
+}
+
// Dump the object to the supplied stream. If the object contains a valid
// directory name, it will be displayed followed by a directory delimiter, and
// the filename.
-//------------------------------------------------------------------
void FileSpec::Dump(Stream *s) const {
if (s) {
std::string path{GetPath(true)};
@@ -383,30 +354,20 @@ void FileSpec::Dump(Stream *s) const {
FileSpec::Style FileSpec::GetPathStyle() const { return m_style; }
-//------------------------------------------------------------------
// Directory string get accessor.
-//------------------------------------------------------------------
ConstString &FileSpec::GetDirectory() { return m_directory; }
-//------------------------------------------------------------------
// Directory string const get accessor.
-//------------------------------------------------------------------
-const ConstString &FileSpec::GetDirectory() const { return m_directory; }
+ConstString FileSpec::GetDirectory() const { return m_directory; }
-//------------------------------------------------------------------
// Filename string get accessor.
-//------------------------------------------------------------------
ConstString &FileSpec::GetFilename() { return m_filename; }
-//------------------------------------------------------------------
// Filename string const get accessor.
-//------------------------------------------------------------------
-const ConstString &FileSpec::GetFilename() const { return m_filename; }
+ConstString FileSpec::GetFilename() const { return m_filename; }
-//------------------------------------------------------------------
// Extract the directory and path into a fixed buffer. This is needed as the
// directory and path are stored in separate string values.
-//------------------------------------------------------------------
size_t FileSpec::GetPath(char *path, size_t path_max_len,
bool denormalize) const {
if (!path)
@@ -452,10 +413,8 @@ ConstString FileSpec::GetFileNameStrippingExtension() const {
return ConstString(llvm::sys::path::stem(m_filename.GetStringRef(), m_style));
}
-//------------------------------------------------------------------
// 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.
-//------------------------------------------------------------------
size_t FileSpec::MemorySize() const {
return m_filename.MemorySize() + m_directory.MemorySize();
}
@@ -516,15 +475,13 @@ bool FileSpec::RemoveLastPathComponent() {
}
return false;
}
-//------------------------------------------------------------------
/// Returns true if the filespec represents an implementation source
/// file (files with a ".c", ".cpp", ".m", ".mm" (many more)
/// extension).
///
-/// @return
+/// \return
/// \b true if the filespec represents an implementation source
/// file, \b false otherwise.
-//------------------------------------------------------------------
bool FileSpec::IsSourceImplementationFile() const {
ConstString extension(GetFileNameExtension());
if (!extension)
@@ -557,6 +514,11 @@ bool FileSpec::IsAbsolute() const {
return llvm::sys::path::is_absolute(current_path, m_style);
}
+void FileSpec::MakeAbsolute(const FileSpec &dir) {
+ if (IsRelative())
+ PrependPathComponent(dir);
+}
+
void llvm::format_provider<FileSpec>::format(const FileSpec &F,
raw_ostream &Stream,
StringRef Style) {
diff --git a/source/Utility/IOObject.cpp b/source/Utility/IOObject.cpp
index df7929c4f9110..5e3ccddb6a307 100644
--- a/source/Utility/IOObject.cpp
+++ b/source/Utility/IOObject.cpp
@@ -1,9 +1,8 @@
//===-- IOObject.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/JSON.cpp b/source/Utility/JSON.cpp
index 725ea97955c68..2c3f6229eda11 100644
--- a/source/Utility/JSON.cpp
+++ b/source/Utility/JSON.cpp
@@ -1,9 +1,8 @@
//===--------------------- JSON.cpp -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -56,9 +55,9 @@ uint64_t JSONNumber::GetAsUnsigned() const {
case DataType::Unsigned:
return m_data.m_unsigned;
case DataType::Signed:
- return (uint64_t)m_data.m_signed;
+ return static_cast<uint64_t>(m_data.m_signed);
case DataType::Double:
- return (uint64_t)m_data.m_double;
+ return static_cast<uint64_t>(m_data.m_double);
}
llvm_unreachable("Unhandled data type");
}
@@ -66,11 +65,11 @@ uint64_t JSONNumber::GetAsUnsigned() const {
int64_t JSONNumber::GetAsSigned() const {
switch (m_data_type) {
case DataType::Unsigned:
- return (int64_t)m_data.m_unsigned;
+ return static_cast<int64_t>(m_data.m_unsigned);
case DataType::Signed:
return m_data.m_signed;
case DataType::Double:
- return (int64_t)m_data.m_double;
+ return static_cast<int64_t>(m_data.m_double);
}
llvm_unreachable("Unhandled data type");
}
@@ -78,9 +77,9 @@ int64_t JSONNumber::GetAsSigned() const {
double JSONNumber::GetAsDouble() const {
switch (m_data_type) {
case DataType::Unsigned:
- return (double)m_data.m_unsigned;
+ return static_cast<double>(m_data.m_unsigned);
case DataType::Signed:
- return (double)m_data.m_signed;
+ return static_cast<double>(m_data.m_signed);
case DataType::Double:
return m_data.m_double;
}
@@ -239,7 +238,7 @@ JSONParser::Token JSONParser::GetToken(std::string &value) {
break;
case '"': {
- while (1) {
+ while (true) {
bool was_escaped = false;
int escaped_ch = GetEscapedChar(was_escaped);
if (escaped_ch == -1) {
@@ -254,7 +253,7 @@ JSONParser::Token JSONParser::GetToken(std::string &value) {
const bool is_null = escaped_ch == 0;
if (was_escaped || (!is_end_quote && !is_null)) {
if (CHAR_MIN <= escaped_ch && escaped_ch <= CHAR_MAX) {
- value.append(1, (char)escaped_ch);
+ value.append(1, static_cast<char>(escaped_ch));
} else {
error.Printf("error: wide character support is needed for unicode "
"character 0x%4.4x at offset %" PRIu64,
@@ -454,7 +453,7 @@ JSONValue::SP JSONParser::ParseJSONObject() {
std::string value;
std::string key;
- while (1) {
+ while (true) {
JSONParser::Token token = GetToken(value);
if (token == JSONParser::Token::String) {
@@ -485,7 +484,7 @@ JSONValue::SP JSONParser::ParseJSONArray() {
std::string value;
std::string key;
- while (1) {
+ while (true) {
JSONValue::SP value_sp = ParseJSONValue();
if (value_sp)
array_up->AppendObject(value_sp);
diff --git a/source/Utility/LLDBAssert.cpp b/source/Utility/LLDBAssert.cpp
index 3902c89b2c833..75530d8063101 100644
--- a/source/Utility/LLDBAssert.cpp
+++ b/source/Utility/LLDBAssert.cpp
@@ -1,9 +1,8 @@
//===--------------------- LLDBAssert.cpp ------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,11 +21,16 @@ void lldb_private::lldb_assert(bool expression, const char *expr_text,
if (LLVM_LIKELY(expression))
return;
+ // In a Debug configuration lldb_assert() behaves like assert(0).
+ llvm_unreachable("lldb_assert failed");
+
+ // In a Release configuration it will print a warning and encourage the user
+ // to file a bug report, similar to LLVM’s crash handler, and then return
+ // execution.
errs() << format("Assertion failed: (%s), function %s, file %s, line %u\n",
expr_text, func, file, line);
errs() << "backtrace leading to the failure:\n";
llvm::sys::PrintStackTrace(errs());
errs() << "please file a bug report against lldb reporting this failure "
"log, and as many details as possible\n";
- abort();
}
diff --git a/source/Utility/Listener.cpp b/source/Utility/Listener.cpp
index a20859e53eebc..50c56406c2ca5 100644
--- a/source/Utility/Listener.cpp
+++ b/source/Utility/Listener.cpp
@@ -1,9 +1,8 @@
//===-- Listener.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -28,8 +27,8 @@ namespace {
class BroadcasterManagerWPMatcher {
public:
BroadcasterManagerWPMatcher(BroadcasterManagerSP manager_sp)
- : m_manager_sp(manager_sp) {}
- bool operator()(const BroadcasterManagerWP input_wp) const {
+ : m_manager_sp(std::move(manager_sp)) {}
+ bool operator()(const BroadcasterManagerWP &input_wp) const {
BroadcasterManagerSP input_sp = input_wp.lock();
return (input_sp && input_sp == m_manager_sp);
}
@@ -192,7 +191,7 @@ void Listener::BroadcasterManagerWillDestruct(BroadcasterManagerSP manager_sp) {
end_iter = m_broadcaster_managers.end();
BroadcasterManagerWP manager_wp;
- BroadcasterManagerWPMatcher matcher(manager_sp);
+ BroadcasterManagerWPMatcher matcher(std::move(manager_sp));
iter = std::find_if<broadcaster_manager_collection::iterator,
BroadcasterManagerWPMatcher>(
m_broadcaster_managers.begin(), end_iter, matcher);
@@ -239,7 +238,7 @@ public:
if (m_broadcaster_names) {
bool found_source = false;
- const ConstString &event_broadcaster_name =
+ ConstString event_broadcaster_name =
event_sp->GetBroadcaster()->GetBroadcasterName();
for (uint32_t i = 0; i < m_num_broadcaster_names; ++i) {
if (m_broadcaster_names[i] == event_broadcaster_name) {
@@ -425,7 +424,7 @@ size_t Listener::HandleBroadcastEvent(EventSP &event_sp) {
}
uint32_t
-Listener::StartListeningForEventSpec(BroadcasterManagerSP manager_sp,
+Listener::StartListeningForEventSpec(const BroadcasterManagerSP &manager_sp,
const BroadcastEventSpec &event_spec) {
if (!manager_sp)
return 0;
@@ -453,7 +452,7 @@ Listener::StartListeningForEventSpec(BroadcasterManagerSP manager_sp,
return bits_acquired;
}
-bool Listener::StopListeningForEventSpec(BroadcasterManagerSP manager_sp,
+bool Listener::StopListeningForEventSpec(const BroadcasterManagerSP &manager_sp,
const BroadcastEventSpec &event_spec) {
if (!manager_sp)
return false;
diff --git a/source/Utility/Log.cpp b/source/Utility/Log.cpp
index 2e8570b762aff..217b0d2ba97b1 100644
--- a/source/Utility/Log.cpp
+++ b/source/Utility/Log.cpp
@@ -1,9 +1,8 @@
//===-- Log.cpp -------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -110,9 +109,7 @@ const Flags Log::GetMask() const {
void Log::PutCString(const char *cstr) { Printf("%s", cstr); }
void Log::PutString(llvm::StringRef str) { PutCString(str.str().c_str()); }
-//----------------------------------------------------------------------
// Simple variable argument logging with flags.
-//----------------------------------------------------------------------
void Log::Printf(const char *format, ...) {
va_list args;
va_start(args, format);
@@ -120,11 +117,9 @@ void Log::Printf(const char *format, ...) {
va_end(args);
}
-//----------------------------------------------------------------------
// All logging eventually boils down to this function call. If we have a
// callback registered, then we call the logging callback. If we have a valid
// file handle, we also log to the file.
-//----------------------------------------------------------------------
void Log::VAPrintf(const char *format, va_list args) {
llvm::SmallString<64> FinalMessage;
llvm::raw_svector_ostream Stream(FinalMessage);
@@ -138,9 +133,7 @@ void Log::VAPrintf(const char *format, va_list args) {
WriteMessage(FinalMessage.str());
}
-//----------------------------------------------------------------------
// Printing of errors that are not fatal.
-//----------------------------------------------------------------------
void Log::Error(const char *format, ...) {
va_list args;
va_start(args, format);
@@ -155,9 +148,7 @@ void Log::VAError(const char *format, va_list args) {
Printf("error: %s", Content.c_str());
}
-//----------------------------------------------------------------------
// Printing of warnings that are not fatal only if verbose mode is enabled.
-//----------------------------------------------------------------------
void Log::Verbose(const char *format, ...) {
if (!GetVerbose())
return;
@@ -168,9 +159,7 @@ void Log::Verbose(const char *format, ...) {
va_end(args);
}
-//----------------------------------------------------------------------
// Printing of warnings that are not fatal.
-//----------------------------------------------------------------------
void Log::Warning(const char *format, ...) {
llvm::SmallString<64> Content;
va_list args;
diff --git a/source/Utility/Logging.cpp b/source/Utility/Logging.cpp
index b97a88b5edcb1..c0856e5d9267d 100644
--- a/source/Utility/Logging.cpp
+++ b/source/Utility/Logging.cpp
@@ -1,9 +1,8 @@
//===-- Logging.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,6 +17,7 @@ using namespace lldb_private;
static constexpr Log::Category g_categories[] = {
{{"api"}, {"log API calls and return values"}, LIBLLDB_LOG_API},
+ {{"ast"}, {"log AST"}, LIBLLDB_LOG_AST},
{{"break"}, {"log breakpoints"}, LIBLLDB_LOG_BREAKPOINTS},
{{"commands"}, {"log command argument parsing"}, LIBLLDB_LOG_COMMANDS},
{{"comm"}, {"log communication activities"}, LIBLLDB_LOG_COMMUNICATION},
diff --git a/source/Utility/NameMatches.cpp b/source/Utility/NameMatches.cpp
index a76df3f929e8b..5c9579ea73329 100644
--- a/source/Utility/NameMatches.cpp
+++ b/source/Utility/NameMatches.cpp
@@ -1,9 +1,8 @@
//===-- NameMatches.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/NameMatches.h"
diff --git a/source/Utility/PPC64LE_DWARF_Registers.h b/source/Utility/PPC64LE_DWARF_Registers.h
index 1a7503790e5da..548c1fda86002 100644
--- a/source/Utility/PPC64LE_DWARF_Registers.h
+++ b/source/Utility/PPC64LE_DWARF_Registers.h
@@ -1,9 +1,8 @@
//===-- PPC64LE_DWARF_Registers.h -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/PPC64LE_ehframe_Registers.h b/source/Utility/PPC64LE_ehframe_Registers.h
index c5763b3047117..77cb3e5924e76 100644
--- a/source/Utility/PPC64LE_ehframe_Registers.h
+++ b/source/Utility/PPC64LE_ehframe_Registers.h
@@ -1,9 +1,8 @@
//===-- PPC64LE_ehframe_Registers.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/PPC64_DWARF_Registers.h b/source/Utility/PPC64_DWARF_Registers.h
index 7e3619e0da4d4..6ba5b6ac37271 100644
--- a/source/Utility/PPC64_DWARF_Registers.h
+++ b/source/Utility/PPC64_DWARF_Registers.h
@@ -1,9 +1,8 @@
//===-- PPC64_DWARF_Registers.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/ProcessInfo.cpp b/source/Utility/ProcessInfo.cpp
new file mode 100644
index 0000000000000..b67ae87790006
--- /dev/null
+++ b/source/Utility/ProcessInfo.cpp
@@ -0,0 +1,310 @@
+//===-- ProcessInfo.cpp -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/ProcessInfo.h"
+
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
+#include "lldb/Utility/UserIDResolver.h"
+#include "llvm/ADT/SmallString.h"
+
+#include <climits>
+
+using namespace lldb;
+using namespace lldb_private;
+
+ProcessInfo::ProcessInfo()
+ : m_executable(), m_arguments(), m_environment(), m_uid(UINT32_MAX),
+ m_gid(UINT32_MAX), m_arch(), m_pid(LLDB_INVALID_PROCESS_ID) {}
+
+ProcessInfo::ProcessInfo(const char *name, const ArchSpec &arch,
+ lldb::pid_t pid)
+ : m_executable(name), m_arguments(), m_environment(), m_uid(UINT32_MAX),
+ m_gid(UINT32_MAX), m_arch(arch), m_pid(pid) {}
+
+void ProcessInfo::Clear() {
+ m_executable.Clear();
+ m_arguments.Clear();
+ m_environment.clear();
+ m_uid = UINT32_MAX;
+ m_gid = UINT32_MAX;
+ m_arch.Clear();
+ m_pid = LLDB_INVALID_PROCESS_ID;
+}
+
+const char *ProcessInfo::GetName() const {
+ return m_executable.GetFilename().GetCString();
+}
+
+size_t ProcessInfo::GetNameLength() const {
+ return m_executable.GetFilename().GetLength();
+}
+
+void ProcessInfo::Dump(Stream &s, Platform *platform) const {
+ s << "Executable: " << GetName() << "\n";
+ s << "Triple: ";
+ m_arch.DumpTriple(s);
+ s << "\n";
+
+ s << "Arguments:\n";
+ m_arguments.Dump(s);
+
+ s.Format("Environment:\n{0}", m_environment);
+}
+
+void ProcessInfo::SetExecutableFile(const FileSpec &exe_file,
+ bool add_exe_file_as_first_arg) {
+ if (exe_file) {
+ m_executable = exe_file;
+ if (add_exe_file_as_first_arg) {
+ llvm::SmallString<128> filename;
+ exe_file.GetPath(filename);
+ if (!filename.empty())
+ m_arguments.InsertArgumentAtIndex(0, filename);
+ }
+ } else {
+ m_executable.Clear();
+ }
+}
+
+llvm::StringRef ProcessInfo::GetArg0() const { return m_arg0; }
+
+void ProcessInfo::SetArg0(llvm::StringRef arg) { m_arg0 = arg; }
+
+void ProcessInfo::SetArguments(char const **argv,
+ bool first_arg_is_executable) {
+ m_arguments.SetArguments(argv);
+
+ // Is the first argument the executable?
+ if (first_arg_is_executable) {
+ const char *first_arg = m_arguments.GetArgumentAtIndex(0);
+ if (first_arg) {
+ // Yes the first argument is an executable, set it as the executable in
+ // the launch options. Don't resolve the file path as the path could be a
+ // remote platform path
+ m_executable.SetFile(first_arg, FileSpec::Style::native);
+ }
+ }
+}
+
+void ProcessInfo::SetArguments(const Args &args, bool first_arg_is_executable) {
+ // Copy all arguments
+ m_arguments = args;
+
+ // Is the first argument the executable?
+ if (first_arg_is_executable) {
+ const char *first_arg = m_arguments.GetArgumentAtIndex(0);
+ if (first_arg) {
+ // Yes the first argument is an executable, set it as the executable in
+ // the launch options. Don't resolve the file path as the path could be a
+ // remote platform path
+ m_executable.SetFile(first_arg, FileSpec::Style::native);
+ }
+ }
+}
+
+void ProcessInstanceInfo::Dump(Stream &s, UserIDResolver &resolver) const {
+ if (m_pid != LLDB_INVALID_PROCESS_ID)
+ s.Printf(" pid = %" PRIu64 "\n", m_pid);
+
+ if (m_parent_pid != LLDB_INVALID_PROCESS_ID)
+ s.Printf(" parent = %" PRIu64 "\n", m_parent_pid);
+
+ if (m_executable) {
+ s.Printf(" name = %s\n", m_executable.GetFilename().GetCString());
+ s.PutCString(" file = ");
+ m_executable.Dump(&s);
+ s.EOL();
+ }
+ const uint32_t argc = m_arguments.GetArgumentCount();
+ if (argc > 0) {
+ for (uint32_t i = 0; i < argc; i++) {
+ const char *arg = m_arguments.GetArgumentAtIndex(i);
+ if (i < 10)
+ s.Printf(" arg[%u] = %s\n", i, arg);
+ else
+ s.Printf("arg[%u] = %s\n", i, arg);
+ }
+ }
+
+ s.Format("{0}", m_environment);
+
+ if (m_arch.IsValid()) {
+ s.Printf(" arch = ");
+ m_arch.DumpTriple(s);
+ s.EOL();
+ }
+
+ if (UserIDIsValid()) {
+ s.Format(" uid = {0,-5} ({1})\n", GetUserID(),
+ resolver.GetUserName(GetUserID()).getValueOr(""));
+ }
+ if (GroupIDIsValid()) {
+ s.Format(" gid = {0,-5} ({1})\n", GetGroupID(),
+ resolver.GetGroupName(GetGroupID()).getValueOr(""));
+ }
+ if (EffectiveUserIDIsValid()) {
+ s.Format(" euid = {0,-5} ({1})\n", GetEffectiveUserID(),
+ resolver.GetUserName(GetEffectiveUserID()).getValueOr(""));
+ }
+ if (EffectiveGroupIDIsValid()) {
+ s.Format(" egid = {0,-5} ({1})\n", GetEffectiveGroupID(),
+ resolver.GetGroupName(GetEffectiveGroupID()).getValueOr(""));
+ }
+}
+
+void ProcessInstanceInfo::DumpTableHeader(Stream &s, bool show_args,
+ bool verbose) {
+ const char *label;
+ if (show_args || verbose)
+ label = "ARGUMENTS";
+ else
+ label = "NAME";
+
+ if (verbose) {
+ s.Printf("PID PARENT USER GROUP EFF USER EFF GROUP TRIPLE "
+ " %s\n",
+ label);
+ s.PutCString("====== ====== ========== ========== ========== ========== "
+ "======================== ============================\n");
+ } else {
+ s.Printf("PID PARENT USER TRIPLE %s\n", label);
+ s.PutCString("====== ====== ========== ======================== "
+ "============================\n");
+ }
+}
+
+void ProcessInstanceInfo::DumpAsTableRow(Stream &s, UserIDResolver &resolver,
+ bool show_args, bool verbose) const {
+ if (m_pid != LLDB_INVALID_PROCESS_ID) {
+ s.Printf("%-6" PRIu64 " %-6" PRIu64 " ", m_pid, m_parent_pid);
+
+ StreamString arch_strm;
+ if (m_arch.IsValid())
+ m_arch.DumpTriple(arch_strm);
+
+ auto print = [&](UserIDResolver::id_t id,
+ llvm::Optional<llvm::StringRef> (UserIDResolver::*get)(
+ UserIDResolver::id_t id)) {
+ if (auto name = (resolver.*get)(id))
+ s.Format("{0,-10} ", *name);
+ else
+ s.Format("{0,-10} ", id);
+ };
+ if (verbose) {
+ print(m_uid, &UserIDResolver::GetUserName);
+ print(m_gid, &UserIDResolver::GetGroupName);
+ print(m_euid, &UserIDResolver::GetUserName);
+ print(m_egid, &UserIDResolver::GetGroupName);
+
+ s.Printf("%-24s ", arch_strm.GetData());
+ } else {
+ print(m_euid, &UserIDResolver::GetUserName);
+ s.Printf(" %-24s ", arch_strm.GetData());
+ }
+
+ if (verbose || show_args) {
+ const uint32_t argc = m_arguments.GetArgumentCount();
+ if (argc > 0) {
+ for (uint32_t i = 0; i < argc; i++) {
+ if (i > 0)
+ s.PutChar(' ');
+ s.PutCString(m_arguments.GetArgumentAtIndex(i));
+ }
+ }
+ } else {
+ s.PutCString(GetName());
+ }
+
+ s.EOL();
+ }
+}
+
+bool ProcessInstanceInfoMatch::NameMatches(const char *process_name) const {
+ if (m_name_match_type == NameMatch::Ignore || process_name == nullptr)
+ return true;
+ const char *match_name = m_match_info.GetName();
+ if (!match_name)
+ return true;
+
+ return lldb_private::NameMatches(process_name, m_name_match_type, match_name);
+}
+
+bool ProcessInstanceInfoMatch::Matches(
+ const ProcessInstanceInfo &proc_info) const {
+ if (!NameMatches(proc_info.GetName()))
+ return false;
+
+ if (m_match_info.ProcessIDIsValid() &&
+ m_match_info.GetProcessID() != proc_info.GetProcessID())
+ return false;
+
+ if (m_match_info.ParentProcessIDIsValid() &&
+ m_match_info.GetParentProcessID() != proc_info.GetParentProcessID())
+ return false;
+
+ if (m_match_info.UserIDIsValid() &&
+ m_match_info.GetUserID() != proc_info.GetUserID())
+ return false;
+
+ if (m_match_info.GroupIDIsValid() &&
+ m_match_info.GetGroupID() != proc_info.GetGroupID())
+ return false;
+
+ if (m_match_info.EffectiveUserIDIsValid() &&
+ m_match_info.GetEffectiveUserID() != proc_info.GetEffectiveUserID())
+ return false;
+
+ if (m_match_info.EffectiveGroupIDIsValid() &&
+ m_match_info.GetEffectiveGroupID() != proc_info.GetEffectiveGroupID())
+ return false;
+
+ if (m_match_info.GetArchitecture().IsValid() &&
+ !m_match_info.GetArchitecture().IsCompatibleMatch(
+ proc_info.GetArchitecture()))
+ return false;
+ return true;
+}
+
+bool ProcessInstanceInfoMatch::MatchAllProcesses() const {
+ if (m_name_match_type != NameMatch::Ignore)
+ return false;
+
+ if (m_match_info.ProcessIDIsValid())
+ return false;
+
+ if (m_match_info.ParentProcessIDIsValid())
+ return false;
+
+ if (m_match_info.UserIDIsValid())
+ return false;
+
+ if (m_match_info.GroupIDIsValid())
+ return false;
+
+ if (m_match_info.EffectiveUserIDIsValid())
+ return false;
+
+ if (m_match_info.EffectiveGroupIDIsValid())
+ return false;
+
+ if (m_match_info.GetArchitecture().IsValid())
+ return false;
+
+ if (m_match_all_users)
+ return false;
+
+ return true;
+}
+
+void ProcessInstanceInfoMatch::Clear() {
+ m_match_info.Clear();
+ m_name_match_type = NameMatch::Ignore;
+ m_match_all_users = false;
+}
diff --git a/source/Utility/RegisterValue.cpp b/source/Utility/RegisterValue.cpp
index 27bffde637fba..a01c35a2818e4 100644
--- a/source/Utility/RegisterValue.cpp
+++ b/source/Utility/RegisterValue.cpp
@@ -1,9 +1,8 @@
//===-- RegisterValue.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -147,23 +146,25 @@ bool RegisterValue::GetScalarValue(Scalar &scalar) const {
scalar = *(const uint8_t *)buffer.bytes;
return true;
case 2:
- scalar = *(const uint16_t *)buffer.bytes;
+ scalar = *reinterpret_cast<const uint16_t *>(buffer.bytes);
return true;
case 4:
- scalar = *(const uint32_t *)buffer.bytes;
+ scalar = *reinterpret_cast<const uint32_t *>(buffer.bytes);
return true;
case 8:
- scalar = *(const uint64_t *)buffer.bytes;
+ scalar = *reinterpret_cast<const uint64_t *>(buffer.bytes);
return true;
case 16:
case 32:
+ case 64:
if (buffer.length % sizeof(uint64_t) == 0) {
const auto length_in_bits = buffer.length * 8;
const auto length_in_uint64 = buffer.length / sizeof(uint64_t);
scalar =
llvm::APInt(length_in_bits,
- llvm::ArrayRef<uint64_t>((const uint64_t *)buffer.bytes,
- length_in_uint64));
+ llvm::ArrayRef<uint64_t>(
+ reinterpret_cast<const uint64_t *>(buffer.bytes),
+ length_in_uint64));
return true;
}
break;
@@ -518,7 +519,7 @@ uint16_t RegisterValue::GetAsUInt16(uint16_t fail_value,
break;
case 1:
case 2:
- return *(const uint16_t *)buffer.bytes;
+ return *reinterpret_cast<const uint16_t *>(buffer.bytes);
}
} break;
}
@@ -548,7 +549,7 @@ uint32_t RegisterValue::GetAsUInt32(uint32_t fail_value,
case 1:
case 2:
case 4:
- return *(const uint32_t *)buffer.bytes;
+ return *reinterpret_cast<const uint32_t *>(buffer.bytes);
}
} break;
}
@@ -579,11 +580,11 @@ uint64_t RegisterValue::GetAsUInt64(uint64_t fail_value,
case 1:
return *(const uint8_t *)buffer.bytes;
case 2:
- return *(const uint16_t *)buffer.bytes;
+ return *reinterpret_cast<const uint16_t *>(buffer.bytes);
case 4:
- return *(const uint32_t *)buffer.bytes;
+ return *reinterpret_cast<const uint32_t *>(buffer.bytes);
case 8:
- return *(const uint64_t *)buffer.bytes;
+ return *reinterpret_cast<const uint64_t *>(buffer.bytes);
}
} break;
}
@@ -618,7 +619,7 @@ llvm::APInt RegisterValue::GetAsUInt128(const llvm::APInt &fail_value,
case 8:
case 16:
return llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- ((const type128 *)buffer.bytes)->x);
+ (reinterpret_cast<const type128 *>(buffer.bytes))->x);
}
} break;
}
diff --git a/source/Utility/RegularExpression.cpp b/source/Utility/RegularExpression.cpp
index 54f773365d992..0192e8b8a01a0 100644
--- a/source/Utility/RegularExpression.cpp
+++ b/source/Utility/RegularExpression.cpp
@@ -1,9 +1,8 @@
//===-- RegularExpression.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,10 +12,8 @@
#include <string>
-//----------------------------------------------------------------------
// Enable enhanced mode if it is available. This allows for things like \d for
// digit, \s for space, and many more, but it isn't available everywhere.
-//----------------------------------------------------------------------
#if defined(REG_ENHANCED)
#define DEFAULT_COMPILE_FLAGS (REG_ENHANCED | REG_EXTENDED)
#else
@@ -29,18 +26,15 @@ RegularExpression::RegularExpression() : m_re(), m_comp_err(1), m_preg() {
memset(&m_preg, 0, sizeof(m_preg));
}
-//----------------------------------------------------------------------
// Constructor that compiles "re" using "flags" and stores the resulting
// compiled regular expression into this object.
-//----------------------------------------------------------------------
RegularExpression::RegularExpression(llvm::StringRef str)
- : m_re(), m_comp_err(1), m_preg() {
- memset(&m_preg, 0, sizeof(m_preg));
+ : RegularExpression() {
Compile(str);
}
-RegularExpression::RegularExpression(const RegularExpression &rhs) {
- memset(&m_preg, 0, sizeof(m_preg));
+RegularExpression::RegularExpression(const RegularExpression &rhs)
+ : RegularExpression() {
Compile(rhs.GetText());
}
@@ -51,15 +45,12 @@ operator=(const RegularExpression &rhs) {
return *this;
}
-//----------------------------------------------------------------------
// Destructor
//
// Any previously compiled regular expression contained in this object will be
// freed.
-//----------------------------------------------------------------------
RegularExpression::~RegularExpression() { Free(); }
-//----------------------------------------------------------------------
// Compile a regular expression using the supplied regular expression text and
// flags. The compiled regular expression lives in this object so that it can
// be readily used for regular expression matches. Execute() can be called
@@ -69,7 +60,6 @@ RegularExpression::~RegularExpression() { Free(); }
// RETURNS
// True if the regular expression compiles successfully, false
// otherwise.
-//----------------------------------------------------------------------
bool RegularExpression::Compile(llvm::StringRef str) {
Free();
@@ -80,13 +70,11 @@ bool RegularExpression::Compile(llvm::StringRef str) {
return m_comp_err == 0;
}
-//----------------------------------------------------------------------
// Execute a regular expression match using the compiled regular expression
// that is already in this object against the match string "s". If any parens
// are used for regular expression matches "match_count" should indicate the
// number of regmatch_t values that are present in "match_ptr". The regular
// expression will be executed using the "execute_flags".
-//---------------------------------------------------------------------
bool RegularExpression::Execute(llvm::StringRef str, Match *match) const {
int err = 1;
if (m_comp_err == 0) {
@@ -155,19 +143,13 @@ bool RegularExpression::Match::GetMatchSpanningIndices(
return false;
}
-//----------------------------------------------------------------------
// Returns true if the regular expression compiled and is ready for execution.
-//----------------------------------------------------------------------
bool RegularExpression::IsValid() const { return m_comp_err == 0; }
-//----------------------------------------------------------------------
// Returns the text that was used to compile the current regular expression.
-//----------------------------------------------------------------------
llvm::StringRef RegularExpression::GetText() const { return m_re; }
-//----------------------------------------------------------------------
// Free any contained compiled regular expressions.
-//----------------------------------------------------------------------
void RegularExpression::Free() {
if (m_comp_err == 0) {
m_re.clear();
diff --git a/source/Utility/Reproducer.cpp b/source/Utility/Reproducer.cpp
index 6e85ba41767aa..479ed311d1ded 100644
--- a/source/Utility/Reproducer.cpp
+++ b/source/Utility/Reproducer.cpp
@@ -1,9 +1,8 @@
//===-- Reproducer.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,6 +51,8 @@ llvm::Error Reproducer::Initialize(ReproducerMode mode,
return Error::success();
}
+bool Reproducer::Initialized() { return InstanceImpl().operator bool(); }
+
void Reproducer::Terminate() {
lldbassert(InstanceImpl() && "Already terminated.");
InstanceImpl().reset();
@@ -178,10 +179,13 @@ void Generator::AddProvidersToIndex() {
sys::fs::OpenFlags::F_None);
yaml::Output yout(*strm);
+ std::vector<std::string> files;
+ files.reserve(m_providers.size());
for (auto &provider : m_providers) {
- auto &provider_info = provider.second->GetInfo();
- yout << const_cast<ProviderInfo &>(provider_info);
+ files.emplace_back(provider.second->GetFile());
}
+
+ yout << files;
}
Loader::Loader(const FileSpec &root) : m_root(root), m_loaded(false) {}
@@ -196,30 +200,86 @@ llvm::Error Loader::LoadIndex() {
if (auto err = error_or_file.getError())
return make_error<StringError>("unable to load reproducer index", err);
- std::vector<ProviderInfo> provider_info;
yaml::Input yin((*error_or_file)->getBuffer());
- yin >> provider_info;
-
+ yin >> m_files;
if (auto err = yin.error())
return make_error<StringError>("unable to read reproducer index", err);
- for (auto &info : provider_info)
- m_provider_info[info.name] = info;
+ // Sort files to speed up search.
+ llvm::sort(m_files);
+ // Remember that we've loaded the index.
m_loaded = true;
return llvm::Error::success();
}
-llvm::Optional<ProviderInfo> Loader::GetProviderInfo(StringRef name) {
+bool Loader::HasFile(StringRef file) {
assert(m_loaded);
+ auto it = std::lower_bound(m_files.begin(), m_files.end(), file.str());
+ return (it != m_files.end()) && (*it == file);
+}
+
+llvm::Expected<std::unique_ptr<DataRecorder>>
+DataRecorder::Create(const FileSpec &filename) {
+ std::error_code ec;
+ auto recorder = llvm::make_unique<DataRecorder>(std::move(filename), ec);
+ if (ec)
+ return llvm::errorCodeToError(ec);
+ return std::move(recorder);
+}
+
+DataRecorder *CommandProvider::GetNewDataRecorder() {
+ std::size_t i = m_data_recorders.size() + 1;
+ std::string filename = (llvm::Twine(Info::name) + llvm::Twine("-") +
+ llvm::Twine(i) + llvm::Twine(".txt"))
+ .str();
+ auto recorder_or_error =
+ DataRecorder::Create(GetRoot().CopyByAppendingPathComponent(filename));
+ if (!recorder_or_error) {
+ llvm::consumeError(recorder_or_error.takeError());
+ return nullptr;
+ }
+
+ m_data_recorders.push_back(std::move(*recorder_or_error));
+ return m_data_recorders.back().get();
+}
+
+void CommandProvider::Keep() {
+ std::vector<std::string> files;
+ for (auto &recorder : m_data_recorders) {
+ recorder->Stop();
+ files.push_back(recorder->GetFilename().GetPath());
+ }
+
+ FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
+ std::error_code ec;
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::F_Text);
+ if (ec)
+ return;
+ yaml::Output yout(os);
+ yout << files;
+}
- auto it = m_provider_info.find(name);
- if (it == m_provider_info.end())
- return llvm::None;
+void CommandProvider::Discard() { m_data_recorders.clear(); }
- return it->second;
+void VersionProvider::Keep() {
+ FileSpec file = GetRoot().CopyByAppendingPathComponent(Info::file);
+ std::error_code ec;
+ llvm::raw_fd_ostream os(file.GetPath(), ec, llvm::sys::fs::F_Text);
+ if (ec)
+ return;
+ os << m_version << "\n";
}
void ProviderBase::anchor() {}
char ProviderBase::ID = 0;
+char CommandProvider::ID = 0;
+char FileProvider::ID = 0;
+char VersionProvider::ID = 0;
+const char *CommandProvider::Info::file = "command-interpreter.yaml";
+const char *CommandProvider::Info::name = "command-interpreter";
+const char *FileProvider::Info::file = "files.yaml";
+const char *FileProvider::Info::name = "files";
+const char *VersionProvider::Info::file = "version.txt";
+const char *VersionProvider::Info::name = "version";
diff --git a/source/Utility/ReproducerInstrumentation.cpp b/source/Utility/ReproducerInstrumentation.cpp
new file mode 100644
index 0000000000000..473786ef4d3e3
--- /dev/null
+++ b/source/Utility/ReproducerInstrumentation.cpp
@@ -0,0 +1,122 @@
+//===-- ReproducerInstrumentation.cpp ---------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/ReproducerInstrumentation.h"
+#include "lldb/Utility/Reproducer.h"
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+
+void *IndexToObject::GetObjectForIndexImpl(unsigned idx) {
+ return m_mapping.lookup(idx);
+}
+
+void IndexToObject::AddObjectForIndexImpl(unsigned idx, void *object) {
+ assert(idx != 0 && "Cannot add object for sentinel");
+ m_mapping[idx] = object;
+}
+
+template <> char *Deserializer::Deserialize<char *>() {
+ return const_cast<char *>(Deserialize<const char *>());
+}
+
+template <> const char *Deserializer::Deserialize<const char *>() {
+ auto pos = m_buffer.find('\0');
+ if (pos == llvm::StringRef::npos)
+ return nullptr;
+ const char *str = m_buffer.data();
+ m_buffer = m_buffer.drop_front(pos + 1);
+ return str;
+}
+
+bool Registry::Replay(const FileSpec &file) {
+ auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath());
+ if (auto err = error_or_file.getError())
+ return false;
+
+ return Replay((*error_or_file)->getBuffer());
+}
+
+bool Registry::Replay(llvm::StringRef buffer) {
+#ifndef LLDB_REPRO_INSTR_TRACE
+ Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_API);
+#endif
+
+ Deserializer deserializer(buffer);
+ while (deserializer.HasData(1)) {
+ unsigned id = deserializer.Deserialize<unsigned>();
+
+#ifndef LLDB_REPRO_INSTR_TRACE
+ LLDB_LOG(log, "Replaying {0}: {1}", id, GetSignature(id));
+#else
+ llvm::errs() << "Replaying " << id << ": " << GetSignature(id) << "\n";
+#endif
+
+ GetReplayer(id)->operator()(deserializer);
+ }
+
+ return true;
+}
+
+void Registry::DoRegister(uintptr_t RunID, std::unique_ptr<Replayer> replayer,
+ SignatureStr signature) {
+ const unsigned id = m_replayers.size() + 1;
+ assert(m_replayers.find(RunID) == m_replayers.end());
+ m_replayers[RunID] = std::make_pair(std::move(replayer), id);
+ m_ids[id] =
+ std::make_pair(m_replayers[RunID].first.get(), std::move(signature));
+}
+
+unsigned Registry::GetID(uintptr_t addr) {
+ unsigned id = m_replayers[addr].second;
+ assert(id != 0 && "Forgot to add function to registry?");
+ return id;
+}
+
+std::string Registry::GetSignature(unsigned id) {
+ assert(m_ids.count(id) != 0 && "ID not in registry");
+ return m_ids[id].second.ToString();
+}
+
+Replayer *Registry::GetReplayer(unsigned id) {
+ assert(m_ids.count(id) != 0 && "ID not in registry");
+ return m_ids[id].first;
+}
+
+std::string Registry::SignatureStr::ToString() const {
+ return (result + (result.empty() ? "" : " ") + scope + "::" + name + args)
+ .str();
+}
+
+unsigned ObjectToIndex::GetIndexForObjectImpl(const void *object) {
+ unsigned index = m_mapping.size() + 1;
+ auto it = m_mapping.find(object);
+ if (it == m_mapping.end())
+ m_mapping[object] = index;
+ return m_mapping[object];
+}
+
+Recorder::Recorder(llvm::StringRef pretty_func, std::string &&pretty_args)
+ : m_serializer(nullptr), m_pretty_func(pretty_func),
+ m_pretty_args(pretty_args), m_local_boundary(false),
+ m_result_recorded(true) {
+ if (!g_global_boundary) {
+ g_global_boundary = true;
+ m_local_boundary = true;
+
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API), "{0} ({1})",
+ m_pretty_func, m_pretty_args);
+ }
+}
+
+Recorder::~Recorder() {
+ assert(m_result_recorded && "Did you forget LLDB_RECORD_RESULT?");
+ UpdateBoundary();
+}
+
+bool lldb_private::repro::Recorder::g_global_boundary;
diff --git a/source/Utility/Scalar.cpp b/source/Utility/Scalar.cpp
index a2bb86ffdb154..23d50b9eaba50 100644
--- a/source/Utility/Scalar.cpp
+++ b/source/Utility/Scalar.cpp
@@ -1,9 +1,8 @@
//===-- Scalar.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,6 +12,7 @@
#include "lldb/Utility/Endian.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
+#include "lldb/Utility/StreamString.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/SmallString.h"
@@ -23,10 +23,8 @@
using namespace lldb;
using namespace lldb_private;
-//----------------------------------------------------------------------
// Promote to max type currently follows the ANSI C rule for type promotion in
// expressions.
-//----------------------------------------------------------------------
static Scalar::Type PromoteToMaxType(
const Scalar &lhs, // The const left hand side object
const Scalar &rhs, // The const right hand side object
@@ -71,10 +69,7 @@ static Scalar::Type PromoteToMaxType(
return Scalar::e_void;
}
-Scalar::Scalar() : m_type(e_void), m_float((float)0) {}
-
-Scalar::Scalar(const Scalar &rhs)
- : m_type(rhs.m_type), m_integer(rhs.m_integer), m_float(rhs.m_float) {}
+Scalar::Scalar() : m_type(e_void), m_float(static_cast<float>(0)) {}
bool Scalar::GetData(DataExtractor &data, size_t limit_byte_size) const {
size_t byte_size = GetByteSize();
@@ -107,7 +102,7 @@ const void *Scalar::GetBytes() const {
const uint8_t *bytes;
static float_t flt_val;
static double_t dbl_val;
- static uint64_t swapped_words[4];
+ static uint64_t swapped_words[8];
switch (m_type) {
case e_void:
break;
@@ -126,12 +121,12 @@ const void *Scalar::GetBytes() const {
bytes += 8 - byte_size;
}
return bytes;
+ // getRawData always returns a pointer to an array of uint64_t values,
+ // where the least-significant word always comes first. On big-endian
+ // systems we need to swap the words.
case e_sint128:
case e_uint128:
apint_words = m_integer.getRawData();
- // getRawData always returns a pointer to an array of two uint64_t values,
- // where the least-significant word always comes first. On big-endian
- // systems we need to swap the two words.
if (endian::InlHostByteOrder() == eByteOrderBig) {
swapped_words[0] = apint_words[1];
swapped_words[1] = apint_words[0];
@@ -141,9 +136,6 @@ const void *Scalar::GetBytes() const {
case e_sint256:
case e_uint256:
apint_words = m_integer.getRawData();
- // getRawData always returns a pointer to an array of four uint64_t values,
- // where the least-significant word always comes first. On big-endian
- // systems we need to swap the four words.
if (endian::InlHostByteOrder() == eByteOrderBig) {
swapped_words[0] = apint_words[3];
swapped_words[1] = apint_words[2];
@@ -152,6 +144,21 @@ const void *Scalar::GetBytes() const {
apint_words = swapped_words;
}
return reinterpret_cast<const void *>(apint_words);
+ case e_sint512:
+ case e_uint512:
+ apint_words = m_integer.getRawData();
+ if (endian::InlHostByteOrder() == eByteOrderBig) {
+ swapped_words[0] = apint_words[7];
+ swapped_words[1] = apint_words[6];
+ swapped_words[2] = apint_words[5];
+ swapped_words[3] = apint_words[4];
+ swapped_words[4] = apint_words[3];
+ swapped_words[5] = apint_words[2];
+ swapped_words[6] = apint_words[1];
+ swapped_words[7] = apint_words[0];
+ apint_words = swapped_words;
+ }
+ return reinterpret_cast<const void *>(apint_words);
case e_float:
flt_val = m_float.convertToFloat();
return reinterpret_cast<const void *>(&flt_val);
@@ -188,6 +195,8 @@ size_t Scalar::GetByteSize() const {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
return (m_integer.getBitWidth() / 8);
case e_float:
return sizeof(float_t);
@@ -214,6 +223,8 @@ bool Scalar::IsZero() const {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_uint512:
+ case e_sint512:
return llvm::APInt::isSameValue(zero_int, m_integer);
case e_float:
case e_double:
@@ -235,6 +246,7 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
case e_slonglong:
case e_sint128:
case e_sint256:
+ case e_sint512:
s->PutCString(m_integer.toString(10, true));
break;
case e_uint:
@@ -242,6 +254,7 @@ void Scalar::GetValue(Stream *s, bool show_type) const {
case e_ulonglong:
case e_uint128:
case e_uint256:
+ case e_uint512:
s->PutCString(m_integer.toString(10, false));
break;
case e_float:
@@ -278,6 +291,10 @@ const char *Scalar::GetTypeAsCString() const {
return "int256_t";
case e_uint256:
return "unsigned int256_t";
+ case e_sint512:
+ return "int512_t";
+ case e_uint512:
+ return "unsigned int512_t";
case e_float:
return "float";
case e_double:
@@ -348,13 +365,13 @@ Scalar &Scalar::operator=(double v) {
Scalar &Scalar::operator=(long double v) {
m_type = e_long_double;
if (m_ieee_quad)
- m_float = llvm::APFloat(
- llvm::APFloat::IEEEquad(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+ m_float = llvm::APFloat(llvm::APFloat::IEEEquad(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ (reinterpret_cast<type128 *>(&v))->x));
else
- m_float = llvm::APFloat(
- llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, ((type128 *)&v)->x));
+ m_float = llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ (reinterpret_cast<type128 *>(&v))->x));
return *this;
}
@@ -387,6 +404,12 @@ Scalar &Scalar::operator=(llvm::APInt rhs) {
else
m_type = e_uint256;
break;
+ case 512:
+ if (m_integer.isSignedIntN(BITWIDTH_INT512))
+ m_type = e_sint512;
+ else
+ m_type = e_uint512;
+ break;
}
return *this;
}
@@ -443,6 +466,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, true,
@@ -507,6 +536,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, false,
@@ -567,6 +602,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, true,
@@ -623,6 +664,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, false,
@@ -675,6 +722,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, true,
@@ -723,6 +776,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, false,
@@ -771,6 +830,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.sextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, true,
@@ -815,6 +880,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, false,
@@ -859,6 +930,12 @@ bool Scalar::Promote(Scalar::Type type) {
success = true;
break;
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, true,
@@ -899,6 +976,13 @@ bool Scalar::Promote(Scalar::Type type) {
case e_uint256:
success = true;
break;
+
+ case e_sint512:
+ case e_uint512:
+ m_integer = m_integer.zextOrTrunc(BITWIDTH_INT512);
+ success = true;
+ break;
+
case e_float:
m_float = llvm::APFloat(llvm::APFloat::IEEEsingle());
m_float.convertFromAPInt(m_integer, false,
@@ -923,6 +1007,11 @@ bool Scalar::Promote(Scalar::Type type) {
}
break;
+ case e_sint512:
+ case e_uint512:
+ lldbassert(false && "unimplemented");
+ break;
+
case e_float:
switch (type) {
case e_void:
@@ -936,12 +1025,14 @@ bool Scalar::Promote(Scalar::Type type) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_uint512:
+ case e_sint512:
break;
case e_float:
success = true;
break;
case e_double:
- m_float = llvm::APFloat((double_t)m_float.convertToFloat());
+ m_float = llvm::APFloat(static_cast<double_t>(m_float.convertToFloat()));
success = true;
break;
@@ -969,6 +1060,8 @@ bool Scalar::Promote(Scalar::Type type) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
case e_float:
break;
case e_double:
@@ -998,6 +1091,8 @@ bool Scalar::Promote(Scalar::Type type) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
case e_float:
case e_double:
break;
@@ -1043,6 +1138,10 @@ const char *Scalar::GetValueTypeAsCString(Scalar::Type type) {
return "int256_t";
case e_uint256:
return "uint256_t";
+ case e_sint512:
+ return "int512_t";
+ case e_uint512:
+ return "uint512_t";
}
return "???";
}
@@ -1120,6 +1219,13 @@ bool Scalar::MakeSigned() {
m_type = e_sint256;
success = true;
break;
+ case e_sint512:
+ success = true;
+ break;
+ case e_uint512:
+ m_type = e_sint512;
+ success = true;
+ break;
case e_float:
success = true;
break;
@@ -1175,6 +1281,13 @@ bool Scalar::MakeUnsigned() {
case e_uint256:
success = true;
break;
+ case e_sint512:
+ m_type = e_uint512;
+ success = true;
+ break;
+ case e_uint512:
+ success = true;
+ break;
case e_float:
success = true;
break;
@@ -1203,14 +1316,18 @@ signed char Scalar::SChar(char fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (schar_t)(m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<schar_t>(
+ (m_integer.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue());
case e_float:
- return (schar_t)m_float.convertToFloat();
+ return static_cast<schar_t>(m_float.convertToFloat());
case e_double:
- return (schar_t)m_float.convertToDouble();
+ return static_cast<schar_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (schar_t)(ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue();
+ return static_cast<schar_t>(
+ (ldbl_val.sextOrTrunc(sizeof(schar_t) * 8)).getSExtValue());
}
return fail_value;
}
@@ -1229,14 +1346,18 @@ unsigned char Scalar::UChar(unsigned char fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (uchar_t)(m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<uchar_t>(
+ (m_integer.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue());
case e_float:
- return (uchar_t)m_float.convertToFloat();
+ return static_cast<uchar_t>(m_float.convertToFloat());
case e_double:
- return (uchar_t)m_float.convertToDouble();
+ return static_cast<uchar_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (uchar_t)(ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue();
+ return static_cast<uchar_t>(
+ (ldbl_val.zextOrTrunc(sizeof(uchar_t) * 8)).getZExtValue());
}
return fail_value;
}
@@ -1255,16 +1376,18 @@ short Scalar::SShort(short fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (sshort_t)(m_integer.sextOrTrunc(sizeof(sshort_t) * 8))
- .getSExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<sshort_t>(
+ (m_integer.sextOrTrunc(sizeof(sshort_t) * 8)).getSExtValue());
case e_float:
- return (sshort_t)m_float.convertToFloat();
+ return static_cast<sshort_t>(m_float.convertToFloat());
case e_double:
- return (sshort_t)m_float.convertToDouble();
+ return static_cast<sshort_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (sshort_t)(ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8))
- .getSExtValue();
+ return static_cast<sshort_t>(
+ (ldbl_val.sextOrTrunc(sizeof(sshort_t) * 8)).getSExtValue());
}
return fail_value;
}
@@ -1283,16 +1406,18 @@ unsigned short Scalar::UShort(unsigned short fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (ushort_t)(m_integer.zextOrTrunc(sizeof(ushort_t) * 8))
- .getZExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<ushort_t>(
+ (m_integer.zextOrTrunc(sizeof(ushort_t) * 8)).getZExtValue());
case e_float:
- return (ushort_t)m_float.convertToFloat();
+ return static_cast<ushort_t>(m_float.convertToFloat());
case e_double:
- return (ushort_t)m_float.convertToDouble();
+ return static_cast<ushort_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (ushort_t)(ldbl_val.zextOrTrunc(sizeof(ushort_t) * 8))
- .getZExtValue();
+ return static_cast<ushort_t>(
+ (ldbl_val.zextOrTrunc(sizeof(ushort_t) * 8)).getZExtValue());
}
return fail_value;
}
@@ -1311,14 +1436,18 @@ int Scalar::SInt(int fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (sint_t)(m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<sint_t>(
+ (m_integer.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue());
case e_float:
- return (sint_t)m_float.convertToFloat();
+ return static_cast<sint_t>(m_float.convertToFloat());
case e_double:
- return (sint_t)m_float.convertToDouble();
+ return static_cast<sint_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (sint_t)(ldbl_val.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue();
+ return static_cast<sint_t>(
+ (ldbl_val.sextOrTrunc(sizeof(sint_t) * 8)).getSExtValue());
}
return fail_value;
}
@@ -1337,14 +1466,18 @@ unsigned int Scalar::UInt(unsigned int fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (uint_t)(m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<uint_t>(
+ (m_integer.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue());
case e_float:
- return (uint_t)m_float.convertToFloat();
+ return static_cast<uint_t>(m_float.convertToFloat());
case e_double:
- return (uint_t)m_float.convertToDouble();
+ return static_cast<uint_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (uint_t)(ldbl_val.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue();
+ return static_cast<uint_t>(
+ (ldbl_val.zextOrTrunc(sizeof(uint_t) * 8)).getZExtValue());
}
return fail_value;
}
@@ -1363,14 +1496,18 @@ long Scalar::SLong(long fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (slong_t)(m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<slong_t>(
+ (m_integer.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue());
case e_float:
- return (slong_t)m_float.convertToFloat();
+ return static_cast<slong_t>(m_float.convertToFloat());
case e_double:
- return (slong_t)m_float.convertToDouble();
+ return static_cast<slong_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (slong_t)(ldbl_val.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue();
+ return static_cast<slong_t>(
+ (ldbl_val.sextOrTrunc(sizeof(slong_t) * 8)).getSExtValue());
}
return fail_value;
}
@@ -1389,14 +1526,18 @@ unsigned long Scalar::ULong(unsigned long fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (ulong_t)(m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<ulong_t>(
+ (m_integer.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue());
case e_float:
- return (ulong_t)m_float.convertToFloat();
+ return static_cast<ulong_t>(m_float.convertToFloat());
case e_double:
- return (ulong_t)m_float.convertToDouble();
+ return static_cast<ulong_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (ulong_t)(ldbl_val.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue();
+ return static_cast<ulong_t>(
+ (ldbl_val.zextOrTrunc(sizeof(ulong_t) * 8)).getZExtValue());
}
return fail_value;
}
@@ -1415,16 +1556,18 @@ long long Scalar::SLongLong(long long fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (slonglong_t)(m_integer.sextOrTrunc(sizeof(slonglong_t) * 8))
- .getSExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<slonglong_t>(
+ (m_integer.sextOrTrunc(sizeof(slonglong_t) * 8)).getSExtValue());
case e_float:
- return (slonglong_t)m_float.convertToFloat();
+ return static_cast<slonglong_t>(m_float.convertToFloat());
case e_double:
- return (slonglong_t)m_float.convertToDouble();
+ return static_cast<slonglong_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (slonglong_t)(ldbl_val.sextOrTrunc(sizeof(slonglong_t) * 8))
- .getSExtValue();
+ return static_cast<slonglong_t>(
+ (ldbl_val.sextOrTrunc(sizeof(slonglong_t) * 8)).getSExtValue());
}
return fail_value;
}
@@ -1443,21 +1586,23 @@ unsigned long long Scalar::ULongLong(unsigned long long fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (ulonglong_t)(m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8))
- .getZExtValue();
+ case e_sint512:
+ case e_uint512:
+ return static_cast<ulonglong_t>(
+ (m_integer.zextOrTrunc(sizeof(ulonglong_t) * 8)).getZExtValue());
case e_float:
- return (ulonglong_t)m_float.convertToFloat();
+ return static_cast<ulonglong_t>(m_float.convertToFloat());
case e_double: {
double d_val = m_float.convertToDouble();
llvm::APInt rounded_double =
llvm::APIntOps::RoundDoubleToAPInt(d_val, sizeof(ulonglong_t) * 8);
- return (ulonglong_t)(rounded_double.zextOrTrunc(sizeof(ulonglong_t) * 8))
- .getZExtValue();
+ return static_cast<ulonglong_t>(
+ (rounded_double.zextOrTrunc(sizeof(ulonglong_t) * 8)).getZExtValue());
}
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (ulonglong_t)(ldbl_val.zextOrTrunc(sizeof(ulonglong_t) * 8))
- .getZExtValue();
+ return static_cast<ulonglong_t>(
+ (ldbl_val.zextOrTrunc(sizeof(ulonglong_t) * 8)).getZExtValue());
}
return fail_value;
}
@@ -1476,6 +1621,8 @@ llvm::APInt Scalar::SInt128(llvm::APInt &fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
return m_integer;
case e_float:
case e_double:
@@ -1499,52 +1646,8 @@ llvm::APInt Scalar::UInt128(const llvm::APInt &fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return m_integer;
- case e_float:
- case e_double:
- case e_long_double:
- return m_float.bitcastToAPInt();
- }
- return fail_value;
-}
-
-llvm::APInt Scalar::SInt256(llvm::APInt &fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
- return m_integer;
- case e_float:
- case e_double:
- case e_long_double:
- return m_float.bitcastToAPInt();
- }
- return fail_value;
-}
-
-llvm::APInt Scalar::UInt256(const llvm::APInt &fail_value) const {
- switch (m_type) {
- case e_void:
- break;
- case e_sint:
- case e_uint:
- case e_slong:
- case e_ulong:
- case e_slonglong:
- case e_ulonglong:
- case e_sint128:
- case e_uint128:
- case e_sint256:
- case e_uint256:
+ case e_sint512:
+ case e_uint512:
return m_integer;
case e_float:
case e_double:
@@ -1568,11 +1671,13 @@ float Scalar::Float(float fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
return llvm::APIntOps::RoundAPIntToFloat(m_integer);
case e_float:
return m_float.convertToFloat();
case e_double:
- return (float_t)m_float.convertToDouble();
+ return static_cast<float_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
return ldbl_val.bitsToFloat();
@@ -1594,9 +1699,11 @@ double Scalar::Double(double fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
return llvm::APIntOps::RoundAPIntToDouble(m_integer);
case e_float:
- return (double_t)m_float.convertToFloat();
+ return static_cast<double_t>(m_float.convertToFloat());
case e_double:
return m_float.convertToDouble();
case e_long_double:
@@ -1620,14 +1727,17 @@ long double Scalar::LongDouble(long double fail_value) const {
case e_uint128:
case e_sint256:
case e_uint256:
- return (long_double_t)llvm::APIntOps::RoundAPIntToDouble(m_integer);
+ case e_sint512:
+ case e_uint512:
+ return static_cast<long_double_t>(
+ llvm::APIntOps::RoundAPIntToDouble(m_integer));
case e_float:
- return (long_double_t)m_float.convertToFloat();
+ return static_cast<long_double_t>(m_float.convertToFloat());
case e_double:
- return (long_double_t)m_float.convertToDouble();
+ return static_cast<long_double_t>(m_float.convertToDouble());
case e_long_double:
llvm::APInt ldbl_val = m_float.bitcastToAPInt();
- return (long_double_t)ldbl_val.bitsToDouble();
+ return static_cast<long_double_t>(ldbl_val.bitsToDouble());
}
return fail_value;
}
@@ -1651,6 +1761,8 @@ Scalar &Scalar::operator+=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer = a->m_integer + b->m_integer;
break;
@@ -1683,6 +1795,8 @@ Scalar &Scalar::operator<<=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
switch (rhs.m_type) {
case e_void:
case e_float:
@@ -1700,6 +1814,8 @@ Scalar &Scalar::operator<<=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer = m_integer << rhs.m_integer;
break;
}
@@ -1727,6 +1843,8 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
switch (rhs.m_type) {
case e_void:
case e_float:
@@ -1744,6 +1862,8 @@ bool Scalar::ShiftRightLogical(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer = m_integer.lshr(rhs.m_integer);
break;
}
@@ -1771,6 +1891,8 @@ Scalar &Scalar::operator>>=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
switch (rhs.m_type) {
case e_void:
case e_float:
@@ -1788,6 +1910,8 @@ Scalar &Scalar::operator>>=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer = m_integer.ashr(rhs.m_integer);
break;
}
@@ -1815,6 +1939,8 @@ Scalar &Scalar::operator&=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
switch (rhs.m_type) {
case e_void:
case e_float:
@@ -1832,6 +1958,8 @@ Scalar &Scalar::operator&=(const Scalar &rhs) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer &= rhs.m_integer;
break;
}
@@ -1850,6 +1978,7 @@ bool Scalar::AbsoluteValue() {
case e_slonglong:
case e_sint128:
case e_sint256:
+ case e_sint512:
if (m_integer.isNegative())
m_integer = -m_integer;
return true;
@@ -1860,6 +1989,7 @@ bool Scalar::AbsoluteValue() {
return true;
case e_uint128:
case e_uint256:
+ case e_uint512:
case e_float:
case e_double:
case e_long_double:
@@ -1883,6 +2013,8 @@ bool Scalar::UnaryNegate() {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer = -m_integer;
return true;
case e_float:
@@ -1906,6 +2038,8 @@ bool Scalar::OnesComplement() {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer = ~m_integer;
return true;
@@ -1938,6 +2072,8 @@ const Scalar lldb_private::operator+(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
result.m_integer = a->m_integer + b->m_integer;
break;
case Scalar::e_float:
@@ -1970,6 +2106,8 @@ const Scalar lldb_private::operator-(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
result.m_integer = a->m_integer - b->m_integer;
break;
case Scalar::e_float:
@@ -1997,6 +2135,7 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_slonglong:
case Scalar::e_sint128:
case Scalar::e_sint256:
+ case Scalar::e_sint512:
if (b->m_integer != 0) {
result.m_integer = a->m_integer.sdiv(b->m_integer);
return result;
@@ -2007,6 +2146,7 @@ const Scalar lldb_private::operator/(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_ulonglong:
case Scalar::e_uint128:
case Scalar::e_uint256:
+ case Scalar::e_uint512:
if (b->m_integer != 0) {
result.m_integer = a->m_integer.udiv(b->m_integer);
return result;
@@ -2048,6 +2188,8 @@ const Scalar lldb_private::operator*(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
result.m_integer = a->m_integer * b->m_integer;
break;
case Scalar::e_float:
@@ -2078,6 +2220,8 @@ const Scalar lldb_private::operator&(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
result.m_integer = a->m_integer & b->m_integer;
break;
case Scalar::e_void:
@@ -2110,6 +2254,8 @@ const Scalar lldb_private::operator|(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
result.m_integer = a->m_integer | b->m_integer;
break;
@@ -2142,6 +2288,7 @@ const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_slonglong:
case Scalar::e_sint128:
case Scalar::e_sint256:
+ case Scalar::e_sint512:
if (b->m_integer != 0) {
result.m_integer = a->m_integer.srem(b->m_integer);
return result;
@@ -2152,6 +2299,7 @@ const Scalar lldb_private::operator%(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_ulonglong:
case Scalar::e_uint128:
case Scalar::e_uint256:
+ case Scalar::e_uint512:
if (b->m_integer != 0) {
result.m_integer = a->m_integer.urem(b->m_integer);
return result;
@@ -2181,6 +2329,8 @@ const Scalar lldb_private::operator^(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
result.m_integer = a->m_integer ^ b->m_integer;
break;
@@ -2227,10 +2377,10 @@ Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
error.SetErrorStringWithFormat(
"'%s' is not a valid unsigned integer string value", value_str);
else if (!UIntValueIsValidForSize(uval64, byte_size))
- error.SetErrorStringWithFormat("value 0x%" PRIx64
- " is too large to fit in a %" PRIu64
- " byte unsigned integer value",
- uval64, (uint64_t)byte_size);
+ error.SetErrorStringWithFormat(
+ "value 0x%" PRIx64 " is too large to fit in a %" PRIu64
+ " byte unsigned integer value",
+ uval64, static_cast<uint64_t>(byte_size));
else {
m_type = Scalar::GetValueTypeForUnsignedIntegerWithByteSize(byte_size);
switch (m_type) {
@@ -2246,14 +2396,14 @@ Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
default:
error.SetErrorStringWithFormat(
"unsupported unsigned integer byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
break;
}
}
} else {
error.SetErrorStringWithFormat(
"unsupported unsigned integer byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
return error;
}
break;
@@ -2265,10 +2415,10 @@ Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
error.SetErrorStringWithFormat(
"'%s' is not a valid signed integer string value", value_str);
else if (!SIntValueIsValidForSize(sval64, byte_size))
- error.SetErrorStringWithFormat("value 0x%" PRIx64
- " is too large to fit in a %" PRIu64
- " byte signed integer value",
- sval64, (uint64_t)byte_size);
+ error.SetErrorStringWithFormat(
+ "value 0x%" PRIx64 " is too large to fit in a %" PRIu64
+ " byte signed integer value",
+ sval64, static_cast<uint64_t>(byte_size));
else {
m_type = Scalar::GetValueTypeForSignedIntegerWithByteSize(byte_size);
switch (m_type) {
@@ -2284,14 +2434,14 @@ Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
default:
error.SetErrorStringWithFormat(
"unsupported signed integer byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
break;
}
}
} else {
error.SetErrorStringWithFormat(
"unsupported signed integer byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
return error;
}
break;
@@ -2316,17 +2466,17 @@ Status Scalar::SetValueFromCString(const char *value_str, Encoding encoding,
value_str);
} else if (byte_size == sizeof(long double)) {
if (::sscanf(value_str, "%Lf", &l_val) == 1) {
- m_float =
- llvm::APFloat(llvm::APFloat::x87DoubleExtended(),
- llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
- ((type128 *)&l_val)->x));
+ m_float = llvm::APFloat(
+ llvm::APFloat::x87DoubleExtended(),
+ llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128,
+ (reinterpret_cast<type128 *>(&l_val))->x));
m_type = e_long_double;
} else
error.SetErrorStringWithFormat("'%s' is not a valid float string value",
value_str);
} else {
error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
return error;
}
break;
@@ -2359,45 +2509,45 @@ Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
switch (byte_size) {
case 1:
- operator=((uint8_t)data.GetU8(&offset));
+ operator=(data.GetU8(&offset));
break;
case 2:
- operator=((uint16_t)data.GetU16(&offset));
+ operator=(data.GetU16(&offset));
break;
case 4:
- operator=((uint32_t)data.GetU32(&offset));
+ operator=(data.GetU32(&offset));
break;
case 8:
- operator=((uint64_t)data.GetU64(&offset));
+ operator=(data.GetU64(&offset));
break;
case 16:
if (data.GetByteOrder() == eByteOrderBig) {
- int128.x[1] = (uint64_t)data.GetU64(&offset);
- int128.x[0] = (uint64_t)data.GetU64(&offset);
+ int128.x[1] = data.GetU64(&offset);
+ int128.x[0] = data.GetU64(&offset);
} else {
- int128.x[0] = (uint64_t)data.GetU64(&offset);
- int128.x[1] = (uint64_t)data.GetU64(&offset);
+ int128.x[0] = data.GetU64(&offset);
+ int128.x[1] = data.GetU64(&offset);
}
operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
break;
case 32:
if (data.GetByteOrder() == eByteOrderBig) {
- int256.x[3] = (uint64_t)data.GetU64(&offset);
- int256.x[2] = (uint64_t)data.GetU64(&offset);
- int256.x[1] = (uint64_t)data.GetU64(&offset);
- int256.x[0] = (uint64_t)data.GetU64(&offset);
+ int256.x[3] = data.GetU64(&offset);
+ int256.x[2] = data.GetU64(&offset);
+ int256.x[1] = data.GetU64(&offset);
+ int256.x[0] = data.GetU64(&offset);
} else {
- int256.x[0] = (uint64_t)data.GetU64(&offset);
- int256.x[1] = (uint64_t)data.GetU64(&offset);
- int256.x[2] = (uint64_t)data.GetU64(&offset);
- int256.x[3] = (uint64_t)data.GetU64(&offset);
+ int256.x[0] = data.GetU64(&offset);
+ int256.x[1] = data.GetU64(&offset);
+ int256.x[2] = data.GetU64(&offset);
+ int256.x[3] = data.GetU64(&offset);
}
operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x));
break;
default:
error.SetErrorStringWithFormat(
"unsupported unsigned integer byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
break;
}
} break;
@@ -2406,45 +2556,45 @@ Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
switch (byte_size) {
case 1:
- operator=((int8_t)data.GetU8(&offset));
+ operator=(static_cast<int8_t>(data.GetU8(&offset)));
break;
case 2:
- operator=((int16_t)data.GetU16(&offset));
+ operator=(static_cast<int16_t>(data.GetU16(&offset)));
break;
case 4:
- operator=((int32_t)data.GetU32(&offset));
+ operator=(static_cast<int32_t>(data.GetU32(&offset)));
break;
case 8:
- operator=((int64_t)data.GetU64(&offset));
+ operator=(static_cast<int64_t>(data.GetU64(&offset)));
break;
case 16:
if (data.GetByteOrder() == eByteOrderBig) {
- int128.x[1] = (uint64_t)data.GetU64(&offset);
- int128.x[0] = (uint64_t)data.GetU64(&offset);
+ int128.x[1] = data.GetU64(&offset);
+ int128.x[0] = data.GetU64(&offset);
} else {
- int128.x[0] = (uint64_t)data.GetU64(&offset);
- int128.x[1] = (uint64_t)data.GetU64(&offset);
+ int128.x[0] = data.GetU64(&offset);
+ int128.x[1] = data.GetU64(&offset);
}
operator=(llvm::APInt(BITWIDTH_INT128, NUM_OF_WORDS_INT128, int128.x));
break;
case 32:
if (data.GetByteOrder() == eByteOrderBig) {
- int256.x[3] = (uint64_t)data.GetU64(&offset);
- int256.x[2] = (uint64_t)data.GetU64(&offset);
- int256.x[1] = (uint64_t)data.GetU64(&offset);
- int256.x[0] = (uint64_t)data.GetU64(&offset);
+ int256.x[3] = data.GetU64(&offset);
+ int256.x[2] = data.GetU64(&offset);
+ int256.x[1] = data.GetU64(&offset);
+ int256.x[0] = data.GetU64(&offset);
} else {
- int256.x[0] = (uint64_t)data.GetU64(&offset);
- int256.x[1] = (uint64_t)data.GetU64(&offset);
- int256.x[2] = (uint64_t)data.GetU64(&offset);
- int256.x[3] = (uint64_t)data.GetU64(&offset);
+ int256.x[0] = data.GetU64(&offset);
+ int256.x[1] = data.GetU64(&offset);
+ int256.x[2] = data.GetU64(&offset);
+ int256.x[3] = data.GetU64(&offset);
}
operator=(llvm::APInt(BITWIDTH_INT256, NUM_OF_WORDS_INT256, int256.x));
break;
default:
error.SetErrorStringWithFormat(
"unsupported signed integer byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
break;
}
} break;
@@ -2452,14 +2602,14 @@ Status Scalar::SetValueFromData(DataExtractor &data, lldb::Encoding encoding,
lldb::offset_t offset = 0;
if (byte_size == sizeof(float))
- operator=((float)data.GetFloat(&offset));
+ operator=(data.GetFloat(&offset));
else if (byte_size == sizeof(double))
- operator=((double)data.GetDouble(&offset));
+ operator=(data.GetDouble(&offset));
else if (byte_size == sizeof(long double))
- operator=((long double)data.GetLongDouble(&offset));
+ operator=(data.GetLongDouble(&offset));
else
error.SetErrorStringWithFormat("unsupported float byte size: %" PRIu64 "",
- (uint64_t)byte_size);
+ static_cast<uint64_t>(byte_size));
} break;
}
@@ -2487,6 +2637,8 @@ bool Scalar::SignExtend(uint32_t sign_bit_pos) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
if (max_bit_pos == sign_bit_pos)
return true;
else if (sign_bit_pos < (max_bit_pos - 1)) {
@@ -2546,6 +2698,7 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) {
case Scalar::e_slonglong:
case Scalar::e_sint128:
case Scalar::e_sint256:
+ case Scalar::e_sint512:
m_integer = m_integer.ashr(bit_offset)
.sextOrTrunc(bit_size)
.sextOrSelf(8 * GetByteSize());
@@ -2556,6 +2709,7 @@ bool Scalar::ExtractBitfield(uint32_t bit_size, uint32_t bit_offset) {
case Scalar::e_ulonglong:
case Scalar::e_uint128:
case Scalar::e_uint256:
+ case Scalar::e_uint512:
m_integer = m_integer.lshr(bit_offset)
.zextOrTrunc(bit_size)
.zextOrSelf(8 * GetByteSize());
@@ -2586,6 +2740,8 @@ bool lldb_private::operator==(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_uint128:
case Scalar::e_sint256:
case Scalar::e_uint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
return a->m_integer == b->m_integer;
case Scalar::e_float:
case Scalar::e_double:
@@ -2617,6 +2773,8 @@ bool lldb_private::operator<(const Scalar &lhs, const Scalar &rhs) {
case Scalar::e_slonglong:
case Scalar::e_sint128:
case Scalar::e_sint256:
+ case Scalar::e_sint512:
+ case Scalar::e_uint512:
return a->m_integer.slt(b->m_integer);
case Scalar::e_uint:
case Scalar::e_ulong:
@@ -2660,6 +2818,8 @@ bool Scalar::ClearBit(uint32_t bit) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer.clearBit(bit);
return true;
case e_float:
@@ -2684,6 +2844,8 @@ bool Scalar::SetBit(uint32_t bit) {
case e_uint128:
case e_sint256:
case e_uint256:
+ case e_sint512:
+ case e_uint512:
m_integer.setBit(bit);
return true;
case e_float:
@@ -2693,3 +2855,9 @@ bool Scalar::SetBit(uint32_t bit) {
}
return false;
}
+
+llvm::raw_ostream &lldb_private::operator<<(llvm::raw_ostream &os, const Scalar &scalar) {
+ StreamString s;
+ scalar.GetValue(&s, /*show_type*/ true);
+ return os << s.GetString();
+}
diff --git a/source/Utility/SelectHelper.cpp b/source/Utility/SelectHelper.cpp
index 2979a67dc182c..ff21d99e400ab 100644
--- a/source/Utility/SelectHelper.cpp
+++ b/source/Utility/SelectHelper.cpp
@@ -1,9 +1,8 @@
//===-- SelectHelper.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -133,9 +132,7 @@ lldb_private::Status SelectHelper::Select() {
fd_set *read_fdset_ptr = nullptr;
fd_set *write_fdset_ptr = nullptr;
fd_set *error_fdset_ptr = nullptr;
-//----------------------------------------------------------------------
// Initialize and zero out the fdsets
-//----------------------------------------------------------------------
#if defined(__APPLE__)
llvm::SmallVector<fd_set, 1> read_fdset;
llvm::SmallVector<fd_set, 1> write_fdset;
@@ -177,9 +174,7 @@ lldb_private::Status SelectHelper::Select() {
error_fdset_ptr = &error_fdset;
}
#endif
- //----------------------------------------------------------------------
// Set the FD bits in the fdsets for read/write/error
- //----------------------------------------------------------------------
for (auto &pair : m_fd_map) {
const lldb::socket_t fd = pair.first;
@@ -193,17 +188,13 @@ lldb_private::Status SelectHelper::Select() {
FD_SET(fd, error_fdset_ptr);
}
- //----------------------------------------------------------------------
// Setup our timeout time value if needed
- //----------------------------------------------------------------------
struct timeval *tv_ptr = nullptr;
struct timeval tv = {0, 0};
- while (1) {
+ while (true) {
using namespace std::chrono;
- //------------------------------------------------------------------
// Setup out relative timeout based on the end time if we have one
- //------------------------------------------------------------------
if (m_end_time.hasValue()) {
tv_ptr = &tv;
const auto remaining_dur = duration_cast<microseconds>(
diff --git a/source/Utility/SharingPtr.cpp b/source/Utility/SharingPtr.cpp
index bdaedfb9b0495..45f2a773758b7 100644
--- a/source/Utility/SharingPtr.cpp
+++ b/source/Utility/SharingPtr.cpp
@@ -1,9 +1,8 @@
//===---------------------SharingPtr.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/State.cpp b/source/Utility/State.cpp
index 6ff8a4940b0f8..51fe92bad77e3 100644
--- a/source/Utility/State.cpp
+++ b/source/Utility/State.cpp
@@ -1,9 +1,8 @@
//===-- State.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/Status.cpp b/source/Utility/Status.cpp
index 062bd261ea8be..3d64fb810abfc 100644
--- a/source/Utility/Status.cpp
+++ b/source/Utility/Status.cpp
@@ -1,10 +1,9 @@
//===-- Status.cpp -----------------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -48,8 +47,6 @@ Status::Status(std::error_code EC)
: m_code(EC.value()), m_type(ErrorType::eErrorTypeGeneric),
m_string(EC.message()) {}
-Status::Status(const Status &rhs) = default;
-
Status::Status(const char *format, ...)
: m_code(0), m_type(eErrorTypeInvalid), m_string() {
va_list args;
@@ -96,9 +93,7 @@ llvm::Error Status::ToError() const {
llvm::inconvertibleErrorCode());
}
-//----------------------------------------------------------------------
// Assignment operator
-//----------------------------------------------------------------------
const Status &Status::operator=(const Status &rhs) {
if (this != &rhs) {
m_code = rhs.m_code;
@@ -127,11 +122,9 @@ static std::string RetrieveWin32ErrorString(uint32_t error_code) {
}
#endif
-//----------------------------------------------------------------------
// Get the error value as a NULL C string. The error string will be fetched and
// cached on demand. The cached error string value will remain until the error
// value is changed or cleared.
-//----------------------------------------------------------------------
const char *Status::AsCString(const char *default_error_str) const {
if (Success())
return nullptr;
@@ -168,35 +161,25 @@ const char *Status::AsCString(const char *default_error_str) const {
return m_string.c_str();
}
-//----------------------------------------------------------------------
// Clear the error and any cached error string that it might contain.
-//----------------------------------------------------------------------
void Status::Clear() {
m_code = 0;
m_type = eErrorTypeInvalid;
m_string.clear();
}
-//----------------------------------------------------------------------
// Access the error value.
-//----------------------------------------------------------------------
Status::ValueType Status::GetError() const { return m_code; }
-//----------------------------------------------------------------------
// Access the error type.
-//----------------------------------------------------------------------
ErrorType Status::GetType() const { return m_type; }
-//----------------------------------------------------------------------
// Returns true if this object contains a value that describes an error or
// otherwise non-success result.
-//----------------------------------------------------------------------
bool Status::Fail() const { return m_code != 0; }
-//----------------------------------------------------------------------
// Set accessor for the error value to "err" and the type to
// "eErrorTypeMachKernel"
-//----------------------------------------------------------------------
void Status::SetMachError(uint32_t err) {
m_code = err;
m_type = eErrorTypeMachKernel;
@@ -227,40 +210,32 @@ int Status::SetExpressionErrorWithFormat(lldb::ExpressionResults result,
return length;
}
-//----------------------------------------------------------------------
// Set accessor for the error value and type.
-//----------------------------------------------------------------------
void Status::SetError(ValueType err, ErrorType type) {
m_code = err;
m_type = type;
m_string.clear();
}
-//----------------------------------------------------------------------
// Update the error value to be "errno" and update the type to be "POSIX".
-//----------------------------------------------------------------------
void Status::SetErrorToErrno() {
m_code = errno;
m_type = eErrorTypePOSIX;
m_string.clear();
}
-//----------------------------------------------------------------------
// Update the error value to be LLDB_GENERIC_ERROR and update the type to be
// "Generic".
-//----------------------------------------------------------------------
void Status::SetErrorToGenericError() {
m_code = LLDB_GENERIC_ERROR;
m_type = eErrorTypeGeneric;
m_string.clear();
}
-//----------------------------------------------------------------------
// Set accessor for the error string value for a specific error. This allows
// any string 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.
-//----------------------------------------------------------------------
void Status::SetErrorString(llvm::StringRef err_str) {
if (!err_str.empty()) {
// If we have an error string, we should always at least have an error set
@@ -271,12 +246,10 @@ void Status::SetErrorString(llvm::StringRef err_str) {
m_string = err_str;
}
-//------------------------------------------------------------------
/// Set the current error string to a formatted error string.
///
-/// @param format
+/// \param format
/// A printf style format string
-//------------------------------------------------------------------
int Status::SetErrorStringWithFormat(const char *format, ...) {
if (format != nullptr && format[0]) {
va_list args;
@@ -307,10 +280,8 @@ int Status::SetErrorStringWithVarArg(const char *format, va_list args) {
return 0;
}
-//----------------------------------------------------------------------
// Returns true if the error code in this object is considered a successful
// return value.
-//----------------------------------------------------------------------
bool Status::Success() const { return m_code == 0; }
bool Status::WasInterrupted() const {
diff --git a/source/Utility/Stream.cpp b/source/Utility/Stream.cpp
index 54691c7066db6..c48a12acd9064 100644
--- a/source/Utility/Stream.cpp
+++ b/source/Utility/Stream.cpp
@@ -1,9 +1,8 @@
//===-- Stream.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,9 +29,7 @@ Stream::Stream()
: m_flags(0), m_addr_size(4), m_byte_order(endian::InlHostByteOrder()),
m_indent_level(0), m_forwarder(*this) {}
-//------------------------------------------------------------------
// Destructor
-//------------------------------------------------------------------
Stream::~Stream() {}
ByteOrder Stream::SetByteOrder(ByteOrder byte_order) {
@@ -41,14 +38,10 @@ ByteOrder Stream::SetByteOrder(ByteOrder byte_order) {
return old_byte_order;
}
-//------------------------------------------------------------------
// Put an offset "uval" out to the stream using the printf format in "format".
-//------------------------------------------------------------------
void Stream::Offset(uint32_t uval, const char *format) { Printf(format, uval); }
-//------------------------------------------------------------------
// Put an SLEB128 "uval" out to the stream using the printf format in "format".
-//------------------------------------------------------------------
size_t Stream::PutSLEB128(int64_t sval) {
if (m_flags.Test(eBinary))
return llvm::encodeSLEB128(sval, m_forwarder);
@@ -56,9 +49,7 @@ size_t Stream::PutSLEB128(int64_t sval) {
return Printf("0x%" PRIi64, sval);
}
-//------------------------------------------------------------------
// Put an ULEB128 "uval" out to the stream using the printf format in "format".
-//------------------------------------------------------------------
size_t Stream::PutULEB128(uint64_t uval) {
if (m_flags.Test(eBinary))
return llvm::encodeULEB128(uval, m_forwarder);
@@ -66,9 +57,7 @@ size_t Stream::PutULEB128(uint64_t uval) {
return Printf("0x%" PRIx64, uval);
}
-//------------------------------------------------------------------
// Print a raw NULL terminated C string to the stream.
-//------------------------------------------------------------------
size_t Stream::PutCString(llvm::StringRef str) {
size_t bytes_written = 0;
bytes_written = Write(str.data(), str.size());
@@ -79,18 +68,14 @@ size_t Stream::PutCString(llvm::StringRef str) {
return bytes_written;
}
-//------------------------------------------------------------------
// Print a double quoted NULL terminated C string to the stream using the
// printf format in "format".
-//------------------------------------------------------------------
void Stream::QuotedCString(const char *cstr, const char *format) {
Printf(format, cstr);
}
-//------------------------------------------------------------------
// Put an address "addr" out to the stream with optional prefix and suffix
// strings.
-//------------------------------------------------------------------
void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix,
const char *suffix) {
if (prefix == nullptr)
@@ -99,13 +84,11 @@ void Stream::Address(uint64_t addr, uint32_t addr_size, const char *prefix,
suffix = "";
// int addr_width = m_addr_size << 1;
// Printf ("%s0x%0*" PRIx64 "%s", prefix, addr_width, addr, suffix);
- Printf("%s0x%0*" PRIx64 "%s", prefix, addr_size * 2, (uint64_t)addr, suffix);
+ Printf("%s0x%0*" PRIx64 "%s", prefix, addr_size * 2, addr, suffix);
}
-//------------------------------------------------------------------
// Put an address range out to the stream with optional prefix and suffix
// strings.
-//------------------------------------------------------------------
void Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr,
uint32_t addr_size, const char *prefix,
const char *suffix) {
@@ -119,9 +102,7 @@ void Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr,
size_t Stream::PutChar(char ch) { return Write(&ch, 1); }
-//------------------------------------------------------------------
// Print some formatted output to the stream.
-//------------------------------------------------------------------
size_t Stream::Printf(const char *format, ...) {
va_list args;
va_start(args, format);
@@ -130,9 +111,7 @@ size_t Stream::Printf(const char *format, ...) {
return result;
}
-//------------------------------------------------------------------
// Print some formatted output to the stream.
-//------------------------------------------------------------------
size_t Stream::PrintfVarArg(const char *format, va_list args) {
llvm::SmallString<1024> buf;
VASprintf(buf, format, args);
@@ -144,15 +123,11 @@ size_t Stream::PrintfVarArg(const char *format, va_list args) {
return Write(buf.c_str(), length);
}
-//------------------------------------------------------------------
// Print and End of Line character to the stream
-//------------------------------------------------------------------
size_t Stream::EOL() { return PutChar('\n'); }
-//------------------------------------------------------------------
// Indent the current line using the current indentation level and print an
// optional string following the indentation spaces.
-//------------------------------------------------------------------
size_t Stream::Indent(const char *s) {
return Printf("%*.*s%s", m_indent_level, m_indent_level, "", s ? s : "");
}
@@ -162,17 +137,13 @@ size_t Stream::Indent(llvm::StringRef str) {
str.str().c_str());
}
-//------------------------------------------------------------------
// Stream a character "ch" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(char ch) {
PutChar(ch);
return *this;
}
-//------------------------------------------------------------------
// Stream the NULL terminated C string out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(const char *s) {
Printf("%s", s);
return *this;
@@ -183,96 +154,70 @@ Stream &Stream::operator<<(llvm::StringRef str) {
return *this;
}
-//------------------------------------------------------------------
// Stream the pointer value out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(const void *p) {
- Printf("0x%.*tx", (int)sizeof(const void *) * 2, (ptrdiff_t)p);
+ Printf("0x%.*tx", static_cast<int>(sizeof(const void *)) * 2, (ptrdiff_t)p);
return *this;
}
-//------------------------------------------------------------------
// Stream a uint8_t "uval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(uint8_t uval) {
PutHex8(uval);
return *this;
}
-//------------------------------------------------------------------
// Stream a uint16_t "uval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(uint16_t uval) {
PutHex16(uval, m_byte_order);
return *this;
}
-//------------------------------------------------------------------
// Stream a uint32_t "uval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(uint32_t uval) {
PutHex32(uval, m_byte_order);
return *this;
}
-//------------------------------------------------------------------
// Stream a uint64_t "uval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(uint64_t uval) {
PutHex64(uval, m_byte_order);
return *this;
}
-//------------------------------------------------------------------
// Stream a int8_t "sval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(int8_t sval) {
- Printf("%i", (int)sval);
+ Printf("%i", static_cast<int>(sval));
return *this;
}
-//------------------------------------------------------------------
// Stream a int16_t "sval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(int16_t sval) {
- Printf("%i", (int)sval);
+ Printf("%i", static_cast<int>(sval));
return *this;
}
-//------------------------------------------------------------------
// Stream a int32_t "sval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(int32_t sval) {
- Printf("%i", (int)sval);
+ Printf("%i", static_cast<int>(sval));
return *this;
}
-//------------------------------------------------------------------
// Stream a int64_t "sval" out to this stream.
-//------------------------------------------------------------------
Stream &Stream::operator<<(int64_t sval) {
Printf("%" PRIi64, sval);
return *this;
}
-//------------------------------------------------------------------
// Get the current indentation level
-//------------------------------------------------------------------
int Stream::GetIndentLevel() const { return m_indent_level; }
-//------------------------------------------------------------------
// Set the current indentation level
-//------------------------------------------------------------------
void Stream::SetIndentLevel(int indent_level) { m_indent_level = indent_level; }
-//------------------------------------------------------------------
// Increment the current indentation level
-//------------------------------------------------------------------
void Stream::IndentMore(int amount) { m_indent_level += amount; }
-//------------------------------------------------------------------
// Decrement the current indentation level
-//------------------------------------------------------------------
void Stream::IndentLess(int amount) {
if (m_indent_level >= amount)
m_indent_level -= amount;
@@ -280,29 +225,19 @@ void Stream::IndentLess(int amount) {
m_indent_level = 0;
}
-//------------------------------------------------------------------
// Get the address size in bytes
-//------------------------------------------------------------------
uint32_t Stream::GetAddressByteSize() const { return m_addr_size; }
-//------------------------------------------------------------------
// Set the address size in bytes
-//------------------------------------------------------------------
void Stream::SetAddressByteSize(uint32_t addr_size) { m_addr_size = addr_size; }
-//------------------------------------------------------------------
// The flags get accessor
-//------------------------------------------------------------------
Flags &Stream::GetFlags() { return m_flags; }
-//------------------------------------------------------------------
// The flags const get accessor
-//------------------------------------------------------------------
const Flags &Stream::GetFlags() const { return m_flags; }
-//------------------------------------------------------------------
// The byte order get accessor
-//------------------------------------------------------------------
lldb::ByteOrder Stream::GetByteOrder() const { return m_byte_order; }
@@ -360,10 +295,10 @@ size_t Stream::PutHex16(uint16_t uvalue, ByteOrder byte_order) {
if (byte_order == eByteOrderLittle) {
for (size_t byte = 0; byte < sizeof(uvalue); ++byte)
- _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
+ _PutHex8(static_cast<uint8_t>(uvalue >> (byte * 8)), false);
} else {
for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte)
- _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
+ _PutHex8(static_cast<uint8_t>(uvalue >> (byte * 8)), false);
}
return *delta;
}
@@ -376,10 +311,10 @@ size_t Stream::PutHex32(uint32_t uvalue, ByteOrder byte_order) {
if (byte_order == eByteOrderLittle) {
for (size_t byte = 0; byte < sizeof(uvalue); ++byte)
- _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
+ _PutHex8(static_cast<uint8_t>(uvalue >> (byte * 8)), false);
} else {
for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte)
- _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
+ _PutHex8(static_cast<uint8_t>(uvalue >> (byte * 8)), false);
}
return *delta;
}
@@ -392,10 +327,10 @@ size_t Stream::PutHex64(uint64_t uvalue, ByteOrder byte_order) {
if (byte_order == eByteOrderLittle) {
for (size_t byte = 0; byte < sizeof(uvalue); ++byte)
- _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
+ _PutHex8(static_cast<uint8_t>(uvalue >> (byte * 8)), false);
} else {
for (size_t byte = sizeof(uvalue) - 1; byte < sizeof(uvalue); --byte)
- _PutHex8((uint8_t)(uvalue >> (byte * 8)), false);
+ _PutHex8(static_cast<uint8_t>(uvalue >> (byte * 8)), false);
}
return *delta;
}
@@ -404,11 +339,11 @@ size_t Stream::PutMaxHex64(uint64_t uvalue, size_t byte_size,
lldb::ByteOrder byte_order) {
switch (byte_size) {
case 1:
- return PutHex8((uint8_t)uvalue);
+ return PutHex8(static_cast<uint8_t>(uvalue));
case 2:
- return PutHex16((uint16_t)uvalue, byte_order);
+ return PutHex16(static_cast<uint16_t>(uvalue), byte_order);
case 4:
- return PutHex32((uint32_t)uvalue, byte_order);
+ return PutHex32(static_cast<uint32_t>(uvalue), byte_order);
case 8:
return PutHex64(uvalue, byte_order);
}
@@ -451,7 +386,7 @@ size_t Stream::PutRawBytes(const void *s, size_t src_len,
if (dst_byte_order == eByteOrderInvalid)
dst_byte_order = m_byte_order;
- const uint8_t *src = (const uint8_t *)s;
+ const uint8_t *src = static_cast<const uint8_t *>(s);
bool binary_was_set = m_flags.Test(eBinary);
if (!binary_was_set)
m_flags.Set(eBinary);
@@ -478,7 +413,7 @@ size_t Stream::PutBytesAsRawHex8(const void *s, size_t src_len,
if (dst_byte_order == eByteOrderInvalid)
dst_byte_order = m_byte_order;
- const uint8_t *src = (const uint8_t *)s;
+ const uint8_t *src = static_cast<const uint8_t *>(s);
bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
if (src_byte_order == dst_byte_order) {
@@ -494,14 +429,12 @@ size_t Stream::PutBytesAsRawHex8(const void *s, size_t src_len,
return *delta;
}
-size_t Stream::PutCStringAsRawHex8(const char *s) {
+size_t Stream::PutStringAsRawHex8(llvm::StringRef s) {
ByteDelta delta(*this);
bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
- while(*s) {
- _PutHex8(*s, false);
- ++s;
- }
+ for (char c : s)
+ _PutHex8(c, false);
if (binary_is_set)
m_flags.Set(eBinary);
return *delta;
diff --git a/source/Utility/StreamCallback.cpp b/source/Utility/StreamCallback.cpp
index 97528439005a7..b3d3adea78bc5 100644
--- a/source/Utility/StreamCallback.cpp
+++ b/source/Utility/StreamCallback.cpp
@@ -1,9 +1,8 @@
//===-- StreamCallback.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/StreamGDBRemote.cpp b/source/Utility/StreamGDBRemote.cpp
index 9304d84f58a00..c710bbe3eecb3 100644
--- a/source/Utility/StreamGDBRemote.cpp
+++ b/source/Utility/StreamGDBRemote.cpp
@@ -1,9 +1,8 @@
//===-- StreamGDBRemote.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,7 +26,7 @@ StreamGDBRemote::~StreamGDBRemote() {}
int StreamGDBRemote::PutEscapedBytes(const void *s, size_t src_len) {
int bytes_written = 0;
- const uint8_t *src = (const uint8_t *)s;
+ const uint8_t *src = static_cast<const uint8_t *>(s);
bool binary_is_set = m_flags.Test(eBinary);
m_flags.Clear(eBinary);
while (src_len) {
diff --git a/source/Utility/StreamString.cpp b/source/Utility/StreamString.cpp
index 1520961988580..bf9814d6c3055 100644
--- a/source/Utility/StreamString.cpp
+++ b/source/Utility/StreamString.cpp
@@ -1,9 +1,8 @@
//===-- StreamString.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/StringExtractor.cpp b/source/Utility/StringExtractor.cpp
index ddf414702d8c0..502f468da3ccc 100644
--- a/source/Utility/StringExtractor.cpp
+++ b/source/Utility/StringExtractor.cpp
@@ -1,9 +1,8 @@
//===-- StringExtractor.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -25,9 +24,7 @@ static inline int xdigit_to_sint(char ch) {
return -1;
}
-//----------------------------------------------------------------------
// StringExtractor constructor
-//----------------------------------------------------------------------
StringExtractor::StringExtractor() : m_packet(), m_index(0) {}
StringExtractor::StringExtractor(llvm::StringRef packet_str)
@@ -41,26 +38,7 @@ StringExtractor::StringExtractor(const char *packet_cstr)
m_packet.assign(packet_cstr);
}
-//----------------------------------------------------------------------
-// StringExtractor copy constructor
-//----------------------------------------------------------------------
-StringExtractor::StringExtractor(const StringExtractor &rhs)
- : m_packet(rhs.m_packet), m_index(rhs.m_index) {}
-
-//----------------------------------------------------------------------
-// StringExtractor assignment operator
-//----------------------------------------------------------------------
-const StringExtractor &StringExtractor::operator=(const StringExtractor &rhs) {
- if (this != &rhs) {
- m_packet = rhs.m_packet;
- m_index = rhs.m_index;
- }
- return *this;
-}
-
-//----------------------------------------------------------------------
// Destructor
-//----------------------------------------------------------------------
StringExtractor::~StringExtractor() {}
char StringExtractor::GetChar(char fail_value) {
@@ -73,13 +51,11 @@ char StringExtractor::GetChar(char fail_value) {
return fail_value;
}
-//----------------------------------------------------------------------
// If a pair of valid hex digits exist at the head of the StringExtractor they
// are decoded into an unsigned byte and returned by this function
//
// If there is not a pair of valid hex digits at the head of the
// StringExtractor, it is left unchanged and -1 is returned
-//----------------------------------------------------------------------
int StringExtractor::DecodeHexU8() {
SkipSpaces();
if (GetBytesLeft() < 2) {
@@ -91,13 +67,11 @@ int StringExtractor::DecodeHexU8() {
return -1;
}
m_index += 2;
- return (uint8_t)((hi_nibble << 4) + lo_nibble);
+ return static_cast<uint8_t>((hi_nibble << 4) + lo_nibble);
}
-//----------------------------------------------------------------------
// Extract an unsigned character from two hex ASCII chars in the packet string,
// or return fail_value on failure
-//----------------------------------------------------------------------
uint8_t StringExtractor::GetHexU8(uint8_t fail_value, bool set_eof_on_fail) {
// On success, fail_value will be overwritten with the next character in the
// stream
@@ -113,7 +87,7 @@ bool StringExtractor::GetHexU8Ex(uint8_t &ch, bool set_eof_on_fail) {
// ch should not be changed in case of failure
return false;
}
- ch = (uint8_t)byte;
+ ch = static_cast<uint8_t>(byte);
return true;
}
@@ -198,12 +172,12 @@ uint32_t StringExtractor::GetHexMaxU32(bool little_endian,
if (m_index < m_packet.size() && ::isxdigit(m_packet[m_index])) {
nibble_lo = xdigit_to_sint(m_packet[m_index]);
++m_index;
- result |= ((uint32_t)nibble_hi << (shift_amount + 4));
- result |= ((uint32_t)nibble_lo << shift_amount);
+ result |= (static_cast<uint32_t>(nibble_hi) << (shift_amount + 4));
+ result |= (static_cast<uint32_t>(nibble_lo) << shift_amount);
nibble_count += 2;
shift_amount += 8;
} else {
- result |= ((uint32_t)nibble_hi << shift_amount);
+ result |= (static_cast<uint32_t>(nibble_hi) << shift_amount);
nibble_count += 1;
shift_amount += 4;
}
@@ -249,12 +223,12 @@ uint64_t StringExtractor::GetHexMaxU64(bool little_endian,
if (m_index < m_packet.size() && ::isxdigit(m_packet[m_index])) {
nibble_lo = xdigit_to_sint(m_packet[m_index]);
++m_index;
- result |= ((uint64_t)nibble_hi << (shift_amount + 4));
- result |= ((uint64_t)nibble_lo << shift_amount);
+ result |= (static_cast<uint64_t>(nibble_hi) << (shift_amount + 4));
+ result |= (static_cast<uint64_t>(nibble_lo) << shift_amount);
nibble_count += 2;
shift_amount += 8;
} else {
- result |= ((uint64_t)nibble_hi << shift_amount);
+ result |= (static_cast<uint64_t>(nibble_hi) << shift_amount);
nibble_count += 1;
shift_amount += 4;
}
@@ -305,19 +279,17 @@ size_t StringExtractor::GetHexBytes(llvm::MutableArrayRef<uint8_t> dest,
return bytes_extracted;
}
-//----------------------------------------------------------------------
// Decodes all valid hex encoded bytes at the head of the StringExtractor,
// limited by dst_len.
//
// Returns the number of bytes successfully decoded
-//----------------------------------------------------------------------
size_t StringExtractor::GetHexBytesAvail(llvm::MutableArrayRef<uint8_t> dest) {
size_t bytes_extracted = 0;
while (!dest.empty()) {
int decode = DecodeHexU8();
if (decode == -1)
break;
- dest[0] = (uint8_t)decode;
+ dest[0] = static_cast<uint8_t>(decode);
dest = dest.drop_front();
++bytes_extracted;
}
@@ -338,7 +310,7 @@ uint64_t StringExtractor::GetHexWithFixedSize(uint32_t byte_size,
uint32_t shift_amount;
for (i = 0, shift_amount = 0; i < byte_size && IsGood();
++i, shift_amount += 8) {
- result |= ((uint64_t)GetHexU8() << shift_amount);
+ result |= (static_cast<uint64_t>(GetHexU8()) << shift_amount);
}
} else {
// Big Endian
diff --git a/source/Utility/StringExtractorGDBRemote.cpp b/source/Utility/StringExtractorGDBRemote.cpp
index 2a8bd785576b6..a011e9246d15a 100644
--- a/source/Utility/StringExtractorGDBRemote.cpp
+++ b/source/Utility/StringExtractorGDBRemote.cpp
@@ -1,9 +1,8 @@
//===-- StringExtractorGDBRemote.cpp ----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -286,8 +285,8 @@ StringExtractorGDBRemote::GetServerPacketType() const {
break;
case 'X':
- if (PACKET_STARTS_WITH("qXfer:auxv:read::"))
- return eServerPacketType_qXfer_auxv_read;
+ if (PACKET_STARTS_WITH("qXfer:"))
+ return eServerPacketType_qXfer;
break;
}
break;
@@ -378,9 +377,7 @@ StringExtractorGDBRemote::GetServerPacketType() const {
break;
case 'g':
- if (packet_size == 1)
- return eServerPacketType_g;
- break;
+ return eServerPacketType_g;
case 'G':
return eServerPacketType_G;
diff --git a/source/Utility/StringLexer.cpp b/source/Utility/StringLexer.cpp
index d5c7fc6289884..958a9580db7ac 100644
--- a/source/Utility/StringLexer.cpp
+++ b/source/Utility/StringLexer.cpp
@@ -1,9 +1,8 @@
//===--------------------- StringLexer.cpp -----------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,6 @@ using namespace lldb_utility;
StringLexer::StringLexer(std::string s) : m_data(s), m_position(0) {}
-StringLexer::StringLexer(const StringLexer &rhs)
- : m_data(rhs.m_data), m_position(rhs.m_position) {}
-
StringLexer::Character StringLexer::Peek() { return m_data[m_position]; }
bool StringLexer::NextIf(Character c) {
diff --git a/source/Utility/StringList.cpp b/source/Utility/StringList.cpp
index 20bde1a39ac13..fb0d9be8797d4 100644
--- a/source/Utility/StringList.cpp
+++ b/source/Utility/StringList.cpp
@@ -1,9 +1,8 @@
//===-- StringList.cpp ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/StructuredData.cpp b/source/Utility/StructuredData.cpp
index 76a141af40b61..0e203f9739d16 100644
--- a/source/Utility/StructuredData.cpp
+++ b/source/Utility/StructuredData.cpp
@@ -1,9 +1,8 @@
//===---------------------StructuredData.cpp ---------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,9 +22,7 @@
using namespace lldb_private;
-//----------------------------------------------------------------------
// Functions that use a JSONParser to parse JSON into StructuredData
-//----------------------------------------------------------------------
static StructuredData::ObjectSP ParseJSONValue(JSONParser &json_parser);
static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser);
static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser);
@@ -54,7 +51,7 @@ static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser) {
std::string value;
std::string key;
- while (1) {
+ while (true) {
JSONParser::Token token = json_parser.GetToken(value);
if (token == JSONParser::Token::String) {
@@ -85,7 +82,7 @@ static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser) {
std::string value;
std::string key;
- while (1) {
+ while (true) {
StructuredData::ObjectSP value_sp = ParseJSONValue(json_parser);
if (value_sp)
array_up->AddItem(value_sp);
diff --git a/source/Utility/TildeExpressionResolver.cpp b/source/Utility/TildeExpressionResolver.cpp
index 4e2be77c49cb8..b58f45728ce7e 100644
--- a/source/Utility/TildeExpressionResolver.cpp
+++ b/source/Utility/TildeExpressionResolver.cpp
@@ -1,9 +1,8 @@
//===--------------------- TildeExpressionResolver.cpp ----------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/Timer.cpp b/source/Utility/Timer.cpp
index c56ac2192b334..6b46d8ba73642 100644
--- a/source/Utility/Timer.cpp
+++ b/source/Utility/Timer.cpp
@@ -1,9 +1,8 @@
//===-- Timer.cpp -----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "lldb/Utility/Timer.h"
@@ -42,6 +41,8 @@ static TimerStack &GetTimerStackForCurrentThread() {
Timer::Category::Category(const char *cat) : m_name(cat) {
m_nanos.store(0, std::memory_order_release);
+ m_nanos_total.store(0, std::memory_order_release);
+ m_count.store(0, std::memory_order_release);
Category *expected = g_categories;
do {
m_next = expected;
@@ -94,6 +95,8 @@ Timer::~Timer() {
// Keep total results for each category so we can dump results.
m_category.m_nanos += std::chrono::nanoseconds(timer_dur).count();
+ m_category.m_nanos_total += std::chrono::nanoseconds(total_dur).count();
+ m_category.m_count++;
}
void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; }
@@ -101,25 +104,38 @@ void Timer::SetDisplayDepth(uint32_t depth) { g_display_depth = depth; }
/* binary function predicate:
* - returns whether a person is less than another person
*/
-
-typedef std::pair<const char *, uint64_t> TimerEntry;
-
-static bool CategoryMapIteratorSortCriterion(const TimerEntry &lhs,
- const TimerEntry &rhs) {
- return lhs.second > rhs.second;
+namespace {
+struct Stats {
+ const char *name;
+ uint64_t nanos;
+ uint64_t nanos_total;
+ uint64_t count;
+};
+} // namespace
+
+static bool CategoryMapIteratorSortCriterion(const Stats &lhs,
+ const Stats &rhs) {
+ return lhs.nanos > rhs.nanos;
}
void Timer::ResetCategoryTimes() {
- for (Category *i = g_categories; i; i = i->m_next)
+ for (Category *i = g_categories; i; i = i->m_next) {
i->m_nanos.store(0, std::memory_order_release);
+ i->m_nanos_total.store(0, std::memory_order_release);
+ i->m_count.store(0, std::memory_order_release);
+ }
}
void Timer::DumpCategoryTimes(Stream *s) {
- std::vector<TimerEntry> sorted;
+ std::vector<Stats> sorted;
for (Category *i = g_categories; i; i = i->m_next) {
uint64_t nanos = i->m_nanos.load(std::memory_order_acquire);
- if (nanos)
- sorted.push_back(std::make_pair(i->m_name, nanos));
+ if (nanos) {
+ uint64_t nanos_total = i->m_nanos_total.load(std::memory_order_acquire);
+ uint64_t count = i->m_count.load(std::memory_order_acquire);
+ Stats stats{i->m_name, nanos, nanos_total, count};
+ sorted.push_back(stats);
+ }
}
if (sorted.empty())
return; // Later code will break without any elements.
@@ -127,6 +143,10 @@ void Timer::DumpCategoryTimes(Stream *s) {
// Sort by time
llvm::sort(sorted.begin(), sorted.end(), CategoryMapIteratorSortCriterion);
- for (const auto &timer : sorted)
- s->Printf("%.9f sec for %s\n", timer.second / 1000000000., timer.first);
+ for (const auto &stats : sorted)
+ s->Printf("%.9f sec (total: %.3fs; child: %.3fs; count: %" PRIu64
+ ") for %s\n",
+ stats.nanos / 1000000000., stats.nanos_total / 1000000000.,
+ (stats.nanos_total - stats.nanos) / 1000000000., stats.count,
+ stats.name);
}
diff --git a/source/Utility/UUID.cpp b/source/Utility/UUID.cpp
index b00878792c7e0..2a73f9a482ffd 100644
--- a/source/Utility/UUID.cpp
+++ b/source/Utility/UUID.cpp
@@ -1,9 +1,8 @@
//===-- UUID.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -110,3 +109,15 @@ size_t UUID::SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes) {
// Else return zero to indicate we were not able to parse a UUID value
return 0;
}
+
+size_t UUID::SetFromOptionalStringRef(llvm::StringRef str,
+ uint32_t num_uuid_bytes) {
+ size_t num_chars_consumed = SetFromStringRef(str, num_uuid_bytes);
+ if (num_chars_consumed) {
+ if (llvm::all_of(m_bytes, [](uint8_t b) { return b == 0; }))
+ Clear();
+ }
+
+ return num_chars_consumed;
+}
+
diff --git a/source/Utility/UriParser.cpp b/source/Utility/UriParser.cpp
index a6d81e7a2c8b8..b446958f2f47a 100644
--- a/source/Utility/UriParser.cpp
+++ b/source/Utility/UriParser.cpp
@@ -1,9 +1,8 @@
//===-- UriParser.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,9 +15,7 @@
using namespace lldb_private;
-//----------------------------------------------------------------------
// UriParser::Parse
-//----------------------------------------------------------------------
bool UriParser::Parse(llvm::StringRef uri, llvm::StringRef &scheme,
llvm::StringRef &hostname, int &port,
llvm::StringRef &path) {
diff --git a/source/Utility/UserID.cpp b/source/Utility/UserID.cpp
index e65b8fa87d817..b76a1cd84f824 100644
--- a/source/Utility/UserID.cpp
+++ b/source/Utility/UserID.cpp
@@ -1,9 +1,8 @@
//===-- UserID.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/UserIDResolver.cpp b/source/Utility/UserIDResolver.cpp
new file mode 100644
index 0000000000000..8aac6f948cd2f
--- /dev/null
+++ b/source/Utility/UserIDResolver.cpp
@@ -0,0 +1,44 @@
+//===-- UserIDResolver.cpp --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/Utility/UserIDResolver.h"
+#include "llvm/Support/ManagedStatic.h"
+
+using namespace lldb_private;
+
+UserIDResolver::~UserIDResolver() = default;
+
+llvm::Optional<llvm::StringRef> UserIDResolver::Get(
+ id_t id, Map &cache,
+ llvm::Optional<std::string> (UserIDResolver::*do_get)(id_t)) {
+
+ std::lock_guard<std::mutex> guard(m_mutex);
+ auto iter_bool = cache.try_emplace(id, llvm::None);
+ if (iter_bool.second)
+ iter_bool.first->second = (this->*do_get)(id);
+ if (iter_bool.first->second)
+ return llvm::StringRef(*iter_bool.first->second);
+ return llvm::None;
+}
+
+namespace {
+class NoopResolver : public UserIDResolver {
+protected:
+ llvm::Optional<std::string> DoGetUserName(id_t uid) override {
+ return llvm::None;
+ }
+
+ llvm::Optional<std::string> DoGetGroupName(id_t gid) override {
+ return llvm::None;
+ }
+};
+} // namespace
+
+static llvm::ManagedStatic<NoopResolver> g_noop_resolver;
+
+UserIDResolver &UserIDResolver::GetNoopResolver() { return *g_noop_resolver; }
diff --git a/source/Utility/UuidCompatibility.h b/source/Utility/UuidCompatibility.h
index df26f77ab52de..e992c0c79a1f8 100644
--- a/source/Utility/UuidCompatibility.h
+++ b/source/Utility/UuidCompatibility.h
@@ -1,9 +1,8 @@
//===-- UuidCompatibility.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/VASprintf.cpp b/source/Utility/VASprintf.cpp
index 4368a3738307c..2ee0f6676fa7e 100644
--- a/source/Utility/VASprintf.cpp
+++ b/source/Utility/VASprintf.cpp
@@ -1,9 +1,8 @@
-//===-- VASPrintf.cpp -------------------------------------------*- C++ -*-===//
+//===-- VASprintf.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/Utility/VMRange.cpp b/source/Utility/VMRange.cpp
index 20dc7dbbe7572..f3f4ae7efc3c1 100644
--- a/source/Utility/VMRange.cpp
+++ b/source/Utility/VMRange.cpp
@@ -1,9 +1,8 @@
//===-- VMRange.cpp ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/source/lldb.cpp b/source/lldb.cpp
index 1be0461977700..c96f5d9ee7e17 100644
--- a/source/lldb.cpp
+++ b/source/lldb.cpp
@@ -1,9 +1,8 @@
//===-- lldb.cpp ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,12 +13,8 @@ using namespace lldb_private;
#include "clang/Basic/Version.h"
-#ifdef HAVE_SVN_VERSION_INC
-#include "SVNVersion.inc"
-#endif
-
-#ifdef HAVE_APPLE_VERSION_INC
-#include "AppleVersion.inc"
+#ifdef HAVE_VCS_VERSION_INC
+#include "VCSVersion.inc"
#endif
static const char *GetLLDBRevision() {
diff --git a/tools/argdumper/argdumper.cpp b/tools/argdumper/argdumper.cpp
index 67fd309fa14c3..7fd8999c5dced 100644
--- a/tools/argdumper/argdumper.cpp
+++ b/tools/argdumper/argdumper.cpp
@@ -1,9 +1,8 @@
//===-- argdumper.cpp --------------------------------------------*- C++-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/driver/Driver.cpp b/tools/driver/Driver.cpp
index 71a613afd9bf4..043aba7b07baa 100644
--- a/tools/driver/Driver.cpp
+++ b/tools/driver/Driver.cpp
@@ -1,9 +1,8 @@
//===-- Driver.cpp ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,6 +13,7 @@
#include "lldb/API/SBDebugger.h"
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBLanguageRuntime.h"
+#include "lldb/API/SBReproducer.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
@@ -22,6 +22,7 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
@@ -112,24 +113,6 @@ Driver::Driver()
Driver::~Driver() { g_driver = nullptr; }
-void Driver::OptionData::AddLocalLLDBInit() {
- // If there is a local .lldbinit, add that to the list of things to be
- // sourced, if the settings permit it.
- SBFileSpec local_lldbinit(".lldbinit", true);
- SBFileSpec homedir_dot_lldb = SBHostOS::GetUserHomeDirectory();
- homedir_dot_lldb.AppendPathComponent(".lldbinit");
-
- // Only read .lldbinit in the current working directory if it's not the same
- // as the .lldbinit in the home directory (which is already being read in).
- if (local_lldbinit.Exists() && strcmp(local_lldbinit.GetDirectory(),
- homedir_dot_lldb.GetDirectory()) != 0) {
- char path[PATH_MAX];
- local_lldbinit.GetPath(path, sizeof(path));
- InitialCmdEntry entry(path, true, true, true);
- m_after_file_commands.push_back(entry);
- }
-}
-
void Driver::OptionData::AddInitialCommand(std::string command,
CommandPlacement placement,
bool is_file, SBError &error) {
@@ -149,33 +132,17 @@ void Driver::OptionData::AddInitialCommand(std::string command,
if (is_file) {
SBFileSpec file(command.c_str());
if (file.Exists())
- command_set->push_back(InitialCmdEntry(command, is_file, false));
+ command_set->push_back(InitialCmdEntry(command, is_file));
else if (file.ResolveExecutableLocation()) {
char final_path[PATH_MAX];
file.GetPath(final_path, sizeof(final_path));
- command_set->push_back(InitialCmdEntry(final_path, is_file, false));
+ command_set->push_back(InitialCmdEntry(final_path, is_file));
} else
error.SetErrorStringWithFormat(
"file specified in --source (-s) option doesn't exist: '%s'",
command.c_str());
} else
- command_set->push_back(InitialCmdEntry(command, is_file, false));
-}
-
-const char *Driver::GetFilename() const {
- if (m_option_data.m_args.empty())
- return nullptr;
- return m_option_data.m_args.front().c_str();
-}
-
-const char *Driver::GetCrashLogFilename() const {
- if (m_option_data.m_crash_log.empty())
- return nullptr;
- return m_option_data.m_crash_log.c_str();
-}
-
-lldb::ScriptLanguage Driver::GetScriptLanguage() const {
- return m_option_data.m_script_lang;
+ command_set->push_back(InitialCmdEntry(command, is_file));
}
void Driver::WriteCommandsForSourcing(CommandPlacement placement,
@@ -196,36 +163,6 @@ void Driver::WriteCommandsForSourcing(CommandPlacement placement,
for (const auto &command_entry : *command_set) {
const char *command = command_entry.contents.c_str();
if (command_entry.is_file) {
- // If this command_entry is a file to be sourced, and it's the ./.lldbinit
- // file (the .lldbinit
- // file in the current working directory), only read it if
- // target.load-cwd-lldbinit is 'true'.
- if (command_entry.is_cwd_lldbinit_file_read) {
- SBStringList strlist = lldb::SBDebugger::GetInternalVariableValue(
- "target.load-cwd-lldbinit", m_debugger.GetInstanceName());
- if (strlist.GetSize() == 1 &&
- strcmp(strlist.GetStringAtIndex(0), "warn") == 0) {
- FILE *output = m_debugger.GetOutputFileHandle();
- ::fprintf(
- output,
- "There is a .lldbinit file in the current directory which is not "
- "being read.\n"
- "To silence this warning without sourcing in the local "
- ".lldbinit,\n"
- "add the following to the lldbinit file in your home directory:\n"
- " settings set target.load-cwd-lldbinit false\n"
- "To allow lldb to source .lldbinit files in the current working "
- "directory,\n"
- "set the value of this variable to true. Only do so if you "
- "understand and\n"
- "accept the security risk.\n");
- return;
- }
- if (strlist.GetSize() == 1 &&
- strcmp(strlist.GetStringAtIndex(0), "false") == 0) {
- return;
- }
- }
bool source_quietly =
m_option_data.m_source_quietly || command_entry.source_quietly;
strm.Printf("command source -s %i '%s'\n",
@@ -235,8 +172,6 @@ void Driver::WriteCommandsForSourcing(CommandPlacement placement,
}
}
-bool Driver::GetDebugMode() const { return m_option_data.m_debug_mode; }
-
// Check the arguments that were passed to this program to make sure they are
// valid and to get their argument values (if any). Return a boolean value
// indicating whether or not to start up the full debugger (i.e. the Command
@@ -244,7 +179,6 @@ bool Driver::GetDebugMode() const { return m_option_data.m_debug_mode; }
// user only wanted help or version information.
SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
SBError error;
- m_option_data.AddLocalLLDBInit();
// This is kind of a pain, but since we make the debugger in the Driver's
// constructor, we can't know at that point whether we should read in init
@@ -288,6 +222,11 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
m_debugger.SkipAppInitFiles(true);
}
+ if (args.hasArg(OPT_local_lldbinit)) {
+ lldb::SBDebugger::SetInternalVariable("target.load-cwd-lldbinit", "true",
+ m_debugger.GetInstanceName());
+ }
+
if (args.hasArg(OPT_no_use_colors)) {
m_debugger.SetUseColor(false);
}
@@ -320,7 +259,7 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
if (auto *arg = args.getLastArg(OPT_script_language)) {
auto arg_value = arg->getValue();
- m_option_data.m_script_lang = m_debugger.GetScriptingLanguage(arg_value);
+ m_debugger.SetScriptLanguage(m_debugger.GetScriptingLanguage(arg_value));
}
if (args.hasArg(OPT_no_use_colors)) {
@@ -469,85 +408,58 @@ SBError Driver::ProcessArgs(const opt::InputArgList &args, bool &exiting) {
return error;
}
-static ::FILE *PrepareCommandsForSourcing(const char *commands_data,
- size_t commands_size, int fds[2]) {
- enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
-
- ::FILE *commands_file = nullptr;
- fds[0] = -1;
- fds[1] = -1;
- int err = 0;
-#ifdef _WIN32
- err = _pipe(fds, commands_size, O_BINARY);
-#else
- err = pipe(fds);
-#endif
- if (err == 0) {
- ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
- if (nrwr < 0) {
- WithColor::error()
- << format(
- "write(%i, %p, %" PRIu64
- ") failed (errno = %i) when trying to open LLDB commands pipe",
- fds[WRITE], static_cast<const void *>(commands_data),
- static_cast<uint64_t>(commands_size), errno)
- << '\n';
- } else if (static_cast<size_t>(nrwr) == commands_size) {
-// Close the write end of the pipe so when we give the read end to
-// the debugger/command interpreter it will exit when it consumes all
-// of the data
+static inline int OpenPipe(int fds[2], std::size_t size) {
#ifdef _WIN32
- _close(fds[WRITE]);
- fds[WRITE] = -1;
+ return _pipe(fds, size, O_BINARY);
#else
- close(fds[WRITE]);
- fds[WRITE] = -1;
+ (void)size;
+ return pipe(fds);
#endif
- // Now open the read file descriptor in a FILE * that we can give to
- // the debugger as an input handle
- commands_file = fdopen(fds[READ], "r");
- if (commands_file != nullptr) {
- fds[READ] = -1; // The FILE * 'commands_file' now owns the read
- // descriptor Hand ownership if the FILE * over to the
- // debugger for "commands_file".
- } else {
- WithColor::error() << format("fdopen(%i, \"r\") failed (errno = %i) "
- "when trying to open LLDB commands pipe",
- fds[READ], errno)
- << '\n';
- }
- }
- } else {
+}
+
+static ::FILE *PrepareCommandsForSourcing(const char *commands_data,
+ size_t commands_size) {
+ enum PIPES { READ, WRITE }; // Indexes for the read and write fds
+ int fds[2] = {-1, -1};
+
+ if (OpenPipe(fds, commands_size) != 0) {
WithColor::error()
<< "can't create pipe file descriptors for LLDB commands\n";
+ return nullptr;
}
- return commands_file;
-}
+ ssize_t nrwr = write(fds[WRITE], commands_data, commands_size);
+ if (size_t(nrwr) != commands_size) {
+ WithColor::error()
+ << format(
+ "write(%i, %p, %" PRIu64
+ ") failed (errno = %i) when trying to open LLDB commands pipe",
+ fds[WRITE], static_cast<const void *>(commands_data),
+ static_cast<uint64_t>(commands_size), errno)
+ << '\n';
+ llvm::sys::Process::SafelyCloseFileDescriptor(fds[READ]);
+ llvm::sys::Process::SafelyCloseFileDescriptor(fds[WRITE]);
+ return nullptr;
+ }
-void CleanupAfterCommandSourcing(int fds[2]) {
- enum PIPES { READ, WRITE }; // Constants 0 and 1 for READ and WRITE
+ // Close the write end of the pipe, so that the command interpreter will exit
+ // when it consumes all the data.
+ llvm::sys::Process::SafelyCloseFileDescriptor(fds[WRITE]);
- // Close any pipes that we still have ownership of
- if (fds[WRITE] != -1) {
-#ifdef _WIN32
- _close(fds[WRITE]);
- fds[WRITE] = -1;
-#else
- close(fds[WRITE]);
- fds[WRITE] = -1;
-#endif
+ // Open the read file descriptor as a FILE * that we can return as an input
+ // handle.
+ ::FILE *commands_file = fdopen(fds[READ], "rb");
+ if (commands_file == nullptr) {
+ WithColor::error() << format("fdopen(%i, \"rb\") failed (errno = %i) "
+ "when trying to open LLDB commands pipe",
+ fds[READ], errno)
+ << '\n';
+ llvm::sys::Process::SafelyCloseFileDescriptor(fds[READ]);
+ return nullptr;
}
- if (fds[READ] != -1) {
-#ifdef _WIN32
- _close(fds[READ]);
- fds[READ] = -1;
-#else
- close(fds[READ]);
- fds[READ] = -1;
-#endif
- }
+ // 'commands_file' now owns the read descriptor.
+ return commands_file;
}
std::string EscapeString(std::string arg) {
@@ -575,8 +487,8 @@ int Driver::MainLoop() {
m_debugger.SetErrorFileHandle(stderr, false);
m_debugger.SetOutputFileHandle(stdout, false);
- m_debugger.SetInputFileHandle(stdin,
- false); // Don't take ownership of STDIN yet...
+ // Don't take ownership of STDIN yet...
+ m_debugger.SetInputFileHandle(stdin, false);
m_debugger.SetUseExternalEditor(m_option_data.m_use_external_editor);
@@ -593,11 +505,18 @@ int Driver::MainLoop() {
// .lldbinit file in the user's home directory.
SBCommandReturnObject result;
sb_interpreter.SourceInitFileInHomeDirectory(result);
- if (GetDebugMode()) {
+ if (m_option_data.m_debug_mode) {
result.PutError(m_debugger.GetErrorFileHandle());
result.PutOutput(m_debugger.GetOutputFileHandle());
}
+ // Source the local .lldbinit file if it exists and we're allowed to source.
+ // Here we want to always print the return object because it contains the
+ // warning and instructions to load local lldbinit files.
+ sb_interpreter.SourceInitFileInCurrentWorkingDirectory(result);
+ result.PutError(m_debugger.GetErrorFileHandle());
+ result.PutOutput(m_debugger.GetOutputFileHandle());
+
// We allow the user to specify an exit code when calling quit which we will
// return when exiting.
m_debugger.GetCommandInterpreter().AllowExitCodeOnQuit(true);
@@ -609,150 +528,157 @@ int Driver::MainLoop() {
// are processed.
WriteCommandsForSourcing(eCommandPlacementBeforeFile, commands_stream);
- const size_t num_args = m_option_data.m_args.size();
- if (num_args > 0) {
- char arch_name[64];
- if (lldb::SBDebugger::GetDefaultArchitecture(arch_name, sizeof(arch_name)))
- commands_stream.Printf("target create --arch=%s %s", arch_name,
- EscapeString(m_option_data.m_args[0]).c_str());
- else
- commands_stream.Printf("target create %s",
- EscapeString(m_option_data.m_args[0]).c_str());
-
- if (!m_option_data.m_core_file.empty()) {
- commands_stream.Printf(" --core %s",
- EscapeString(m_option_data.m_core_file).c_str());
- }
- commands_stream.Printf("\n");
+ // If we're not in --repl mode, add the commands to process the file
+ // arguments, and the commands specified to run afterwards.
+ if (!m_option_data.m_repl) {
+ const size_t num_args = m_option_data.m_args.size();
+ if (num_args > 0) {
+ char arch_name[64];
+ if (lldb::SBDebugger::GetDefaultArchitecture(arch_name,
+ sizeof(arch_name)))
+ commands_stream.Printf("target create --arch=%s %s", arch_name,
+ EscapeString(m_option_data.m_args[0]).c_str());
+ else
+ commands_stream.Printf("target create %s",
+ EscapeString(m_option_data.m_args[0]).c_str());
- if (num_args > 1) {
- commands_stream.Printf("settings set -- target.run-args ");
- for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
- commands_stream.Printf(
- " %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
+ if (!m_option_data.m_core_file.empty()) {
+ commands_stream.Printf(" --core %s",
+ EscapeString(m_option_data.m_core_file).c_str());
+ }
commands_stream.Printf("\n");
- }
- } else if (!m_option_data.m_core_file.empty()) {
- commands_stream.Printf("target create --core %s\n",
- EscapeString(m_option_data.m_core_file).c_str());
- } else if (!m_option_data.m_process_name.empty()) {
- commands_stream.Printf("process attach --name %s",
- EscapeString(m_option_data.m_process_name).c_str());
- if (m_option_data.m_wait_for)
- commands_stream.Printf(" --waitfor");
+ if (num_args > 1) {
+ commands_stream.Printf("settings set -- target.run-args ");
+ for (size_t arg_idx = 1; arg_idx < num_args; ++arg_idx)
+ commands_stream.Printf(
+ " %s", EscapeString(m_option_data.m_args[arg_idx]).c_str());
+ commands_stream.Printf("\n");
+ }
+ } else if (!m_option_data.m_core_file.empty()) {
+ commands_stream.Printf("target create --core %s\n",
+ EscapeString(m_option_data.m_core_file).c_str());
+ } else if (!m_option_data.m_process_name.empty()) {
+ commands_stream.Printf(
+ "process attach --name %s",
+ EscapeString(m_option_data.m_process_name).c_str());
- commands_stream.Printf("\n");
+ if (m_option_data.m_wait_for)
+ commands_stream.Printf(" --waitfor");
- } else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid) {
- commands_stream.Printf("process attach --pid %" PRIu64 "\n",
- m_option_data.m_process_pid);
- }
+ commands_stream.Printf("\n");
+
+ } else if (LLDB_INVALID_PROCESS_ID != m_option_data.m_process_pid) {
+ commands_stream.Printf("process attach --pid %" PRIu64 "\n",
+ m_option_data.m_process_pid);
+ }
- WriteCommandsForSourcing(eCommandPlacementAfterFile, commands_stream);
+ WriteCommandsForSourcing(eCommandPlacementAfterFile, commands_stream);
+ } else if (!m_option_data.m_after_file_commands.empty()) {
+ // We're in repl mode and after-file-load commands were specified.
+ WithColor::warning() << "commands specified to run after file load (via -o "
+ "or -s) are ignored in REPL mode.\n";
+ }
- if (GetDebugMode()) {
+ if (m_option_data.m_debug_mode) {
result.PutError(m_debugger.GetErrorFileHandle());
result.PutOutput(m_debugger.GetOutputFileHandle());
}
- bool handle_events = true;
- bool spawn_thread = false;
-
- if (m_option_data.m_repl) {
- const char *repl_options = nullptr;
- if (!m_option_data.m_repl_options.empty())
- repl_options = m_option_data.m_repl_options.c_str();
- SBError error(m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
- if (error.Fail()) {
- const char *error_cstr = error.GetCString();
- if ((error_cstr != nullptr) && (error_cstr[0] != 0))
- WithColor::error() << error_cstr << '\n';
- else
- WithColor::error() << error.GetError() << '\n';
- }
- } else {
- // Check if we have any data in the commands stream, and if so, save it to a
- // temp file
- // so we can then run the command interpreter using the file contents.
- const char *commands_data = commands_stream.GetData();
- const size_t commands_size = commands_stream.GetSize();
-
- // The command file might have requested that we quit, this variable will
- // track that.
- bool quit_requested = false;
- bool stopped_for_crash = false;
- if ((commands_data != nullptr) && (commands_size != 0u)) {
- int initial_commands_fds[2];
- bool success = true;
- FILE *commands_file = PrepareCommandsForSourcing(
- commands_data, commands_size, initial_commands_fds);
- if (commands_file != nullptr) {
- m_debugger.SetInputFileHandle(commands_file, true);
-
- // Set the debugger into Sync mode when running the command file.
- // Otherwise command files
- // that run the target won't run in a sensible way.
- bool old_async = m_debugger.GetAsync();
- m_debugger.SetAsync(false);
- int num_errors;
-
- SBCommandInterpreterRunOptions options;
- options.SetStopOnError(true);
- if (m_option_data.m_batch)
- options.SetStopOnCrash(true);
-
- m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
- num_errors, quit_requested,
- stopped_for_crash);
-
- if (m_option_data.m_batch && stopped_for_crash &&
- !m_option_data.m_after_crash_commands.empty()) {
- int crash_command_fds[2];
- SBStream crash_commands_stream;
- WriteCommandsForSourcing(eCommandPlacementAfterCrash,
- crash_commands_stream);
- const char *crash_commands_data = crash_commands_stream.GetData();
- const size_t crash_commands_size = crash_commands_stream.GetSize();
- commands_file = PrepareCommandsForSourcing(
- crash_commands_data, crash_commands_size, crash_command_fds);
- if (commands_file != nullptr) {
- bool local_quit_requested;
- bool local_stopped_for_crash;
- m_debugger.SetInputFileHandle(commands_file, true);
-
- m_debugger.RunCommandInterpreter(
- handle_events, spawn_thread, options, num_errors,
- local_quit_requested, local_stopped_for_crash);
- if (local_quit_requested)
- quit_requested = true;
- }
+ const bool handle_events = true;
+ const bool spawn_thread = false;
+
+ // Check if we have any data in the commands stream, and if so, save it to a
+ // temp file
+ // so we can then run the command interpreter using the file contents.
+ const char *commands_data = commands_stream.GetData();
+ const size_t commands_size = commands_stream.GetSize();
+
+ // The command file might have requested that we quit, this variable will
+ // track that.
+ bool quit_requested = false;
+ bool stopped_for_crash = false;
+ if ((commands_data != nullptr) && (commands_size != 0u)) {
+ bool success = true;
+ FILE *commands_file =
+ PrepareCommandsForSourcing(commands_data, commands_size);
+ if (commands_file != nullptr) {
+ m_debugger.SetInputFileHandle(commands_file, true);
+
+ // Set the debugger into Sync mode when running the command file.
+ // Otherwise command files
+ // that run the target won't run in a sensible way.
+ bool old_async = m_debugger.GetAsync();
+ m_debugger.SetAsync(false);
+ int num_errors = 0;
+
+ SBCommandInterpreterRunOptions options;
+ options.SetStopOnError(true);
+ if (m_option_data.m_batch)
+ options.SetStopOnCrash(true);
+
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
+ num_errors, quit_requested,
+ stopped_for_crash);
+
+ if (m_option_data.m_batch && stopped_for_crash &&
+ !m_option_data.m_after_crash_commands.empty()) {
+ SBStream crash_commands_stream;
+ WriteCommandsForSourcing(eCommandPlacementAfterCrash,
+ crash_commands_stream);
+ const char *crash_commands_data = crash_commands_stream.GetData();
+ const size_t crash_commands_size = crash_commands_stream.GetSize();
+ commands_file = PrepareCommandsForSourcing(crash_commands_data,
+ crash_commands_size);
+ if (commands_file != nullptr) {
+ bool local_quit_requested;
+ bool local_stopped_for_crash;
+ m_debugger.SetInputFileHandle(commands_file, true);
+
+ m_debugger.RunCommandInterpreter(handle_events, spawn_thread, options,
+ num_errors, local_quit_requested,
+ local_stopped_for_crash);
+ if (local_quit_requested)
+ quit_requested = true;
}
- m_debugger.SetAsync(old_async);
- } else
- success = false;
-
- // Close any pipes that we still have ownership of
- CleanupAfterCommandSourcing(initial_commands_fds);
-
- // Something went wrong with command pipe
- if (!success) {
- exit(1);
}
- }
-
- // Now set the input file handle to STDIN and run the command
- // interpreter again in interactive mode and let the debugger
- // take ownership of stdin
+ m_debugger.SetAsync(old_async);
+ } else
+ success = false;
- bool go_interactive = true;
- if (quit_requested)
- go_interactive = false;
- else if (m_option_data.m_batch && !stopped_for_crash)
- go_interactive = false;
+ // Something went wrong with command pipe
+ if (!success) {
+ exit(1);
+ }
+ }
- if (go_interactive) {
- m_debugger.SetInputFileHandle(stdin, true);
+ // Now set the input file handle to STDIN and run the command
+ // interpreter again in interactive mode or repl mode and let the debugger
+ // take ownership of stdin
+
+ bool go_interactive = true;
+ if (quit_requested)
+ go_interactive = false;
+ else if (m_option_data.m_batch && !stopped_for_crash)
+ go_interactive = false;
+
+ if (go_interactive) {
+ m_debugger.SetInputFileHandle(stdin, true);
+
+ if (m_option_data.m_repl) {
+ const char *repl_options = nullptr;
+ if (!m_option_data.m_repl_options.empty())
+ repl_options = m_option_data.m_repl_options.c_str();
+ SBError error(
+ m_debugger.RunREPL(m_option_data.m_repl_lang, repl_options));
+ if (error.Fail()) {
+ const char *error_cstr = error.GetCString();
+ if ((error_cstr != nullptr) && (error_cstr[0] != 0))
+ WithColor::error() << error_cstr << '\n';
+ else
+ WithColor::error() << error.GetError() << '\n';
+ }
+ } else {
m_debugger.RunCommandInterpreter(handle_events, spawn_thread);
}
}
@@ -780,6 +706,9 @@ void sigwinch_handler(int signo) {
}
void sigint_handler(int signo) {
+#ifdef _WIN32 // Restore handler as it is not persistent on Windows
+ signal(SIGINT, sigint_handler);
+#endif
static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT;
if (g_driver != nullptr) {
if (!g_interrupt_sent.test_and_set()) {
@@ -838,17 +767,52 @@ EXAMPLES:
lldb -c /path/to/core
- Command options can be combined with either mode and cause lldb to run the
+ Command options can be combined with these modes and cause lldb to run the
specified commands before or after events, like loading the file or crashing,
in the order provided on the command line.
lldb -O 'settings set stop-disassembly-count 20' -o 'run' -o 'bt'
lldb -S /source/before/file -s /source/after/file
lldb -K /source/before/crash -k /source/after/crash
+
+ Note: In REPL mode no file is loaded, so commands specified to run after
+ loading the file (via -o or -s) will be ignored.
)___";
llvm::outs() << examples;
}
+llvm::Optional<int> InitializeReproducer(opt::InputArgList &input_args) {
+ if (auto *replay_path = input_args.getLastArg(OPT_replay)) {
+ if (const char *error = SBReproducer::Replay(replay_path->getValue())) {
+ WithColor::error() << "reproducer replay failed: " << error << '\n';
+ return 1;
+ }
+ return 0;
+ }
+
+ bool capture = input_args.hasArg(OPT_capture);
+ auto *capture_path = input_args.getLastArg(OPT_capture_path);
+
+ if (capture || capture_path) {
+ if (capture_path) {
+ if (!capture)
+ WithColor::warning() << "-capture-path specified without -capture\n";
+ if (const char *error = SBReproducer::Capture(capture_path->getValue())) {
+ WithColor::error() << "reproducer capture failed: " << error << '\n';
+ return 1;
+ }
+ } else {
+ const char *error = SBReproducer::Capture();
+ if (error) {
+ WithColor::error() << "reproducer capture failed: " << error << '\n';
+ return 1;
+ }
+ }
+ }
+
+ return llvm::None;
+}
+
int
#ifdef _MSC_VER
wmain(int argc, wchar_t const *wargv[])
@@ -889,27 +853,16 @@ main(int argc, char const *argv[])
<< '\n';
}
- SBInitializerOptions options;
-
- if (auto *arg = input_args.getLastArg(OPT_capture)) {
- auto arg_value = arg->getValue();
- options.SetReproducerPath(arg_value);
- options.SetCaptureReproducer(true);
+ if (auto exit_code = InitializeReproducer(input_args)) {
+ return *exit_code;
}
- if (auto *arg = input_args.getLastArg(OPT_replay)) {
- auto arg_value = arg->getValue();
- options.SetReplayReproducer(true);
- options.SetReproducerPath(arg_value);
- }
-
- SBError error = SBDebugger::Initialize(options);
+ SBError error = SBDebugger::InitializeWithErrorHandling();
if (error.Fail()) {
WithColor::error() << "initialization failed: " << error.GetCString()
<< '\n';
return 1;
}
-
SBHostOS::ThreadCreated("<lldb.driver.main-thread>");
signal(SIGINT, sigint_handler);
diff --git a/tools/driver/Driver.h b/tools/driver/Driver.h
index 3f2b0759255a0..f442458ae4010 100644
--- a/tools/driver/Driver.h
+++ b/tools/driver/Driver.h
@@ -1,9 +1,8 @@
//===-- Driver.h ------------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,11 +26,11 @@
class Driver : public lldb::SBBroadcaster {
public:
- typedef enum CommandPlacement {
+ enum CommandPlacement {
eCommandPlacementBeforeFile,
eCommandPlacementAfterFile,
eCommandPlacementAfterCrash,
- } CommandPlacement;
+ };
Driver();
@@ -39,48 +38,31 @@ public:
/// Runs the main loop.
///
- /// @return The exit code that the process should return.
+ /// \return The exit code that the process should return.
int MainLoop();
lldb::SBError ProcessArgs(const llvm::opt::InputArgList &args, bool &exiting);
- const char *GetFilename() const;
-
- const char *GetCrashLogFilename() const;
-
- const char *GetArchName() const;
-
- lldb::ScriptLanguage GetScriptLanguage() const;
-
void WriteCommandsForSourcing(CommandPlacement placement,
lldb::SBStream &strm);
- bool GetDebugMode() const;
-
struct OptionData {
- void AddLocalLLDBInit();
void AddInitialCommand(std::string command, CommandPlacement placement,
bool is_file, lldb::SBError &error);
struct InitialCmdEntry {
InitialCmdEntry(std::string contents, bool in_is_file,
- bool is_cwd_lldbinit_file_read, bool in_quiet = false)
+ bool in_quiet = false)
: contents(std::move(contents)), is_file(in_is_file),
- source_quietly(in_quiet),
- is_cwd_lldbinit_file_read(is_cwd_lldbinit_file_read) {}
+ source_quietly(in_quiet) {}
std::string contents;
bool is_file;
bool source_quietly;
-
- /// Remember if this is reading the local lldbinit file so we can skip it
- /// if not permitted.
- bool is_cwd_lldbinit_file_read;
};
std::vector<std::string> m_args;
- lldb::ScriptLanguage m_script_lang = lldb::eScriptLanguageDefault;
lldb::LanguageType m_repl_lang = lldb::eLanguageTypeUnknown;
lldb::pid_t m_process_pid = LLDB_INVALID_PROCESS_ID;
diff --git a/tools/driver/Options.td b/tools/driver/Options.td
index 563c0b54fb985..4ea98ee48fa26 100644
--- a/tools/driver/Options.td
+++ b/tools/driver/Options.td
@@ -95,6 +95,9 @@ def: Flag<["-"], "x">,
Alias<no_lldbinit>,
HelpText<"Alias for --no-lldbinit">,
Group<grp_command>;
+def local_lldbinit: F<"local-lldbinit">,
+ HelpText<"Allow the debugger to parse the .lldbinit files in the current working directory, unless --no-lldbinit is passed.">,
+ Group<grp_command>;
def batch: F<"batch">,
HelpText<"Tells the debugger to run the commands from -s, -S, -o & -O, and then quit.">,
@@ -219,9 +222,11 @@ def: Flag<["-"], "d">,
Alias<debug>,
HelpText<"Alias for --debug">;
-def capture: Separate<["--", "-"], "capture">,
+def capture: F<"capture">,
+ HelpText<"Tells the debugger to capture a reproducer.">;
+def capture_path: Separate<["--", "-"], "capture-path">,
MetaVarName<"<filename>">,
- HelpText<"Tells the debugger to capture a reproducer to <filename>.">;
+ HelpText<"Tells the debugger to use the given filename for the reproducer.">;
def replay: Separate<["--", "-"], "replay">,
MetaVarName<"<filename>">,
HelpText<"Tells the debugger to replay a reproducer from <filename>.">;
diff --git a/tools/driver/Platform.cpp b/tools/driver/Platform.cpp
index b1b7de8e8a228..f3a71eb79dec3 100644
--- a/tools/driver/Platform.cpp
+++ b/tools/driver/Platform.cpp
@@ -1,9 +1,8 @@
//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/driver/Platform.h b/tools/driver/Platform.h
index 1bb42f9cfc166..064491503e0ca 100644
--- a/tools/driver/Platform.h
+++ b/tools/driver/Platform.h
@@ -1,9 +1,8 @@
//===-- Platform.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-instr/Instrument.cpp b/tools/lldb-instr/Instrument.cpp
new file mode 100644
index 0000000000000..f30707c22b047
--- /dev/null
+++ b/tools/lldb-instr/Instrument.cpp
@@ -0,0 +1,356 @@
+#include "clang/AST/AST.h"
+#include "clang/AST/ASTConsumer.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/CodeGen/ObjectFilePCHContainerOperations.h"
+#include "clang/Frontend/ASTConsumers.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/FrontendActions.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/CommonOptionsParser.h"
+#include "clang/Tooling/Tooling.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include <sstream>
+#include <string>
+
+using namespace clang;
+using namespace clang::driver;
+using namespace clang::tooling;
+
+static llvm::cl::OptionCategory InstrCategory("LLDB Instrumentation Generator");
+
+/// Get the macro name for recording method calls.
+///
+/// LLDB_RECORD_METHOD
+/// LLDB_RECORD_METHOD_CONST
+/// LLDB_RECORD_METHOD_NO_ARGS
+/// LLDB_RECORD_METHOD_CONST_NO_ARGS
+/// LLDB_RECORD_STATIC_METHOD
+/// LLDB_RECORD_STATIC_METHOD_NO_ARGS
+static std::string GetRecordMethodMacroName(bool Static, bool Const,
+ bool NoArgs) {
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+
+ OS << "LLDB_RECORD";
+ if (Static)
+ OS << "_STATIC";
+ OS << "_METHOD";
+ if (Const)
+ OS << "_CONST";
+ if (NoArgs)
+ OS << "_NO_ARGS";
+
+ return OS.str();
+}
+
+/// Get the macro name for register methods.
+///
+/// LLDB_REGISTER_CONSTRUCTOR
+/// LLDB_REGISTER_METHOD
+/// LLDB_REGISTER_METHOD_CONST
+/// LLDB_REGISTER_STATIC_METHOD
+static std::string GetRegisterMethodMacroName(bool Static, bool Const) {
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+
+ OS << "LLDB_REGISTER";
+ if (Static)
+ OS << "_STATIC";
+ OS << "_METHOD";
+ if (Const)
+ OS << "_CONST";
+
+ return OS.str();
+}
+
+static std::string GetRecordMethodMacro(StringRef Result, StringRef Class,
+ StringRef Method, StringRef Signature,
+ StringRef Values, bool Static,
+ bool Const) {
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+
+ OS << GetRecordMethodMacroName(Static, Const, Values.empty());
+ OS << "(" << Result << ", " << Class << ", " << Method;
+
+ if (!Values.empty()) {
+ OS << ", (" << Signature << "), " << Values << ");\n\n";
+ } else {
+ OS << ");\n\n";
+ }
+
+ return OS.str();
+}
+
+static std::string GetRecordConstructorMacro(StringRef Class,
+ StringRef Signature,
+ StringRef Values) {
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+ if (!Values.empty()) {
+ OS << "LLDB_RECORD_CONSTRUCTOR(" << Class << ", (" << Signature << "), "
+ << Values << ");\n\n";
+ } else {
+ OS << "LLDB_RECORD_CONSTRUCTOR_NO_ARGS(" << Class << ");\n\n";
+ }
+ return OS.str();
+}
+
+static std::string GetRecordDummyMacro(StringRef Result, StringRef Class,
+ StringRef Method, StringRef Signature,
+ StringRef Values) {
+ assert(!Values.empty());
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+
+ OS << "LLDB_RECORD_DUMMY(" << Result << ", " << Class << ", " << Method;
+ OS << ", (" << Signature << "), " << Values << ");\n\n";
+
+ return OS.str();
+}
+
+static std::string GetRegisterConstructorMacro(StringRef Class,
+ StringRef Signature) {
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+ OS << "LLDB_REGISTER_CONSTRUCTOR(" << Class << ", (" << Signature << "));\n";
+ return OS.str();
+}
+
+static std::string GetRegisterMethodMacro(StringRef Result, StringRef Class,
+ StringRef Method, StringRef Signature,
+ bool Static, bool Const) {
+ std::string Macro;
+ llvm::raw_string_ostream OS(Macro);
+ OS << GetRegisterMethodMacroName(Static, Const);
+ OS << "(" << Result << ", " << Class << ", " << Method << ", (" << Signature
+ << "));\n";
+ return OS.str();
+}
+
+class SBReturnVisitor : public RecursiveASTVisitor<SBReturnVisitor> {
+public:
+ SBReturnVisitor(Rewriter &R) : MyRewriter(R) {}
+
+ bool VisitReturnStmt(ReturnStmt *Stmt) {
+ Expr *E = Stmt->getRetValue();
+
+ if (E->getBeginLoc().isMacroID())
+ return false;
+
+ SourceRange R(E->getBeginLoc(), E->getEndLoc());
+
+ StringRef WrittenExpr = Lexer::getSourceText(
+ CharSourceRange::getTokenRange(R), MyRewriter.getSourceMgr(),
+ MyRewriter.getLangOpts());
+
+ std::string ReplacementText =
+ "LLDB_RECORD_RESULT(" + WrittenExpr.str() + ")";
+ MyRewriter.ReplaceText(R, ReplacementText);
+
+ return true;
+ }
+
+private:
+ Rewriter &MyRewriter;
+};
+
+class SBVisitor : public RecursiveASTVisitor<SBVisitor> {
+public:
+ SBVisitor(Rewriter &R, ASTContext &Context)
+ : MyRewriter(R), Context(Context) {}
+
+ bool VisitCXXMethodDecl(CXXMethodDecl *Decl) {
+ // Not all decls should be registered. Please refer to that method's
+ // comment for details.
+ if (ShouldSkip(Decl))
+ return false;
+
+ // Skip CXXMethodDecls that already starts with a macro. This should make
+ // it easier to rerun the tool to find missing macros.
+ Stmt *Body = Decl->getBody();
+ for (auto &C : Body->children()) {
+ if (C->getBeginLoc().isMacroID())
+ return false;
+ break;
+ }
+
+ // Print 'bool' instead of '_Bool'.
+ PrintingPolicy Policy(Context.getLangOpts());
+ Policy.Bool = true;
+
+ // Unsupported signatures get a dummy macro.
+ bool ShouldInsertDummy = false;
+
+ // Collect the functions parameter types and names.
+ std::vector<std::string> ParamTypes;
+ std::vector<std::string> ParamNames;
+ for (auto *P : Decl->parameters()) {
+ QualType T = P->getType();
+ ParamTypes.push_back(T.getAsString(Policy));
+ ParamNames.push_back(P->getNameAsString());
+
+ // Currently we don't support functions that have void pointers or
+ // function pointers as an argument, in which case we insert a dummy
+ // macro.
+ ShouldInsertDummy |= T->isFunctionPointerType() || T->isVoidPointerType();
+ }
+
+ // Convert the two lists to string for the macros.
+ std::string ParamTypesStr = llvm::join(ParamTypes, ", ");
+ std::string ParamNamesStr = llvm::join(ParamNames, ", ");
+
+ CXXRecordDecl *Record = Decl->getParent();
+ QualType ReturnType = Decl->getReturnType();
+
+ // Construct the macros.
+ std::string Macro;
+ if (ShouldInsertDummy) {
+ // Don't insert a register call for dummy macros.
+ Macro = GetRecordDummyMacro(
+ ReturnType.getAsString(Policy), Record->getNameAsString(),
+ Decl->getNameAsString(), ParamTypesStr, ParamNamesStr);
+
+ } else if (isa<CXXConstructorDecl>(Decl)) {
+ llvm::outs() << GetRegisterConstructorMacro(Record->getNameAsString(),
+ ParamTypesStr);
+
+ Macro = GetRecordConstructorMacro(Record->getNameAsString(),
+ ParamTypesStr, ParamNamesStr);
+ } else {
+ llvm::outs() << GetRegisterMethodMacro(
+ ReturnType.getAsString(Policy), Record->getNameAsString(),
+ Decl->getNameAsString(), ParamTypesStr, Decl->isStatic(),
+ Decl->isConst());
+
+ Macro = GetRecordMethodMacro(
+ ReturnType.getAsString(Policy), Record->getNameAsString(),
+ Decl->getNameAsString(), ParamTypesStr, ParamNamesStr,
+ Decl->isStatic(), Decl->isConst());
+ }
+
+ // Insert the macro at the beginning of the function. We don't attempt to
+ // fix the formatting and instead rely on clang-format to fix it after the
+ // tool has run. This is also the reason that the macros end with two
+ // newlines, counting on clang-format to normalize this in case the macro
+ // got inserted before an existing newline.
+ SourceLocation InsertLoc = Lexer::getLocForEndOfToken(
+ Body->getBeginLoc(), 0, MyRewriter.getSourceMgr(),
+ MyRewriter.getLangOpts());
+ MyRewriter.InsertTextAfter(InsertLoc, Macro);
+
+ // If the function returns a class or struct, we need to wrap its return
+ // statement(s).
+ bool ShouldRecordResult = ReturnType->isStructureOrClassType() ||
+ ReturnType->getPointeeCXXRecordDecl();
+ if (!ShouldInsertDummy && ShouldRecordResult) {
+ SBReturnVisitor Visitor(MyRewriter);
+ Visitor.TraverseDecl(Decl);
+ }
+
+ return true;
+ }
+
+private:
+ /// Determine whether we need to consider the given CXXMethodDecl.
+ ///
+ /// Currently we skip the following cases:
+ /// 1. Decls outside the main source file,
+ /// 2. Decls that are only present in the source file,
+ /// 3. Decls that are not definitions,
+ /// 4. Non-public methods,
+ /// 5. Variadic methods.
+ /// 6. Destructors.
+ bool ShouldSkip(CXXMethodDecl *Decl) {
+ // Skip anything outside the main file.
+ if (!MyRewriter.getSourceMgr().isInMainFile(Decl->getBeginLoc()))
+ return true;
+
+ // Skip if the canonical decl in the current decl. It means that the method
+ // is declared in the implementation and is therefore not exposed as part
+ // of the API.
+ if (Decl == Decl->getCanonicalDecl())
+ return true;
+
+ // Skip decls that have no body, i.e. are just declarations.
+ Stmt *Body = Decl->getBody();
+ if (!Body)
+ return true;
+
+ // Skip non-public methods.
+ AccessSpecifier AS = Decl->getAccess();
+ if (AS != AccessSpecifier::AS_public)
+ return true;
+
+ // Skip variadic methods.
+ if (Decl->isVariadic())
+ return true;
+
+ // Skip destructors.
+ if (isa<CXXDestructorDecl>(Decl))
+ return true;
+
+ return false;
+ }
+
+ Rewriter &MyRewriter;
+ ASTContext &Context;
+};
+
+class SBConsumer : public ASTConsumer {
+public:
+ SBConsumer(Rewriter &R, ASTContext &Context) : Visitor(R, Context) {}
+
+ // Override the method that gets called for each parsed top-level
+ // declaration.
+ bool HandleTopLevelDecl(DeclGroupRef DR) override {
+ for (DeclGroupRef::iterator b = DR.begin(), e = DR.end(); b != e; ++b) {
+ Visitor.TraverseDecl(*b);
+ }
+ return true;
+ }
+
+private:
+ SBVisitor Visitor;
+};
+
+class SBAction : public ASTFrontendAction {
+public:
+ SBAction() = default;
+
+ bool BeginSourceFileAction(CompilerInstance &CI) override {
+ llvm::outs() << "{\n";
+ return true;
+ }
+
+ void EndSourceFileAction() override {
+ llvm::outs() << "}\n";
+ MyRewriter.overwriteChangedFiles();
+ }
+
+ std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
+ StringRef File) override {
+ MyRewriter.setSourceMgr(CI.getSourceManager(), CI.getLangOpts());
+ return llvm::make_unique<SBConsumer>(MyRewriter, CI.getASTContext());
+ }
+
+private:
+ Rewriter MyRewriter;
+};
+
+int main(int argc, const char **argv) {
+ CommonOptionsParser OP(argc, argv, InstrCategory,
+ "Utility for generating the macros for LLDB's "
+ "instrumentation framework.");
+
+ auto PCHOpts = std::make_shared<PCHContainerOperations>();
+ PCHOpts->registerWriter(llvm::make_unique<ObjectFilePCHContainerWriter>());
+ PCHOpts->registerReader(llvm::make_unique<ObjectFilePCHContainerReader>());
+
+ ClangTool T(OP.getCompilations(), OP.getSourcePathList(), PCHOpts);
+ return T.run(newFrontendActionFactory<SBAction>().get());
+}
diff --git a/tools/lldb-mi/MICmdArgContext.cpp b/tools/lldb-mi/MICmdArgContext.cpp
index 57f682bea22af..18da5b5d67a3c 100644
--- a/tools/lldb-mi/MICmdArgContext.cpp
+++ b/tools/lldb-mi/MICmdArgContext.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgContext.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgContext constructor.
// Type: Method.
// Args: None.
@@ -21,7 +19,6 @@
CMICmdArgContext::CMICmdArgContext() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgContext constructor.
// Type: Method.
// Args: vrCmdLineArgsRaw - (R) The text description of the arguments
@@ -33,7 +30,6 @@ CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw)
: m_strCmdArgsAndOptions(vrCmdLineArgsRaw) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgContext destructor.
// Type: Method.
// Args: None.
@@ -43,7 +39,6 @@ CMICmdArgContext::CMICmdArgContext(const CMIUtilString &vrCmdLineArgsRaw)
CMICmdArgContext::~CMICmdArgContext() {}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the remainder of the command's argument options left to
// parse.
// Type: Method.
@@ -56,7 +51,6 @@ const CMIUtilString &CMICmdArgContext::GetArgsLeftToParse() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Ask if this arguments string has any arguments.
// Type: Method.
// Args: None.
@@ -69,7 +63,6 @@ bool CMICmdArgContext::IsEmpty() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove the argument from the options text and any space after the
// argument
// if applicable.
@@ -128,7 +121,6 @@ bool CMICmdArgContext::RemoveArg(const CMIUtilString &vArg) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove the argument at the Nth word position along in the context
// string.
// Any space after the argument is removed if applicable. A search is
@@ -188,7 +180,6 @@ bool CMICmdArgContext::RemoveArgAtPos(const CMIUtilString &vArg,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve number of arguments or options present in the command's
// option text.
// Type: Method.
@@ -202,7 +193,6 @@ size_t CMICmdArgContext::GetNumberArgsPresent() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve all the arguments or options remaining in *this context.
// Type: Method.
// Args: None.
@@ -216,7 +206,6 @@ CMIUtilString::VecString_t CMICmdArgContext::GetArgs() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Copy assignment operator.
// Type: Method.
// Args: vOther - (R) The variable to copy from.
diff --git a/tools/lldb-mi/MICmdArgContext.h b/tools/lldb-mi/MICmdArgContext.h
index ed4f377d2fbeb..801d2d90cdc54 100644
--- a/tools/lldb-mi/MICmdArgContext.h
+++ b/tools/lldb-mi/MICmdArgContext.h
@@ -1,9 +1,8 @@
//===-- MICmdArgContext.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgSet.cpp b/tools/lldb-mi/MICmdArgSet.cpp
index ca942148908eb..0d67c03bfeae8 100644
--- a/tools/lldb-mi/MICmdArgSet.cpp
+++ b/tools/lldb-mi/MICmdArgSet.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgSet.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgSet constructor.
// Type: Method.
// Args: None.
@@ -25,7 +23,6 @@ CMICmdArgSet::CMICmdArgSet()
: m_bIsArgsPresentButNotHandledByCmd(false), m_constStrCommaSpc(", ") {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgSet destructor.
// Type: Method.
// Args: None.
@@ -38,7 +35,6 @@ CMICmdArgSet::~CMICmdArgSet() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources used by *this container object.
// Type: Method.
// Args: None.
@@ -67,7 +63,6 @@ void CMICmdArgSet::Destroy() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state flag indicating that the command set up ready to
// parse
// command arguments or options found that one or more arguments was
@@ -84,7 +79,6 @@ bool CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add the list of command's arguments to parse and validate another
// one.
// Type: Method.
@@ -95,7 +89,6 @@ bool CMICmdArgSet::IsArgsPresentButNotHandledByCmd() const {
void CMICmdArgSet::Add(CMICmdArgValBase *vArg) { m_setCmdArgs.push_back(vArg); }
//++
-//------------------------------------------------------------------------------------
// Details: After validating an options line of text (the context) and there is
// a failure,
// it is likely a mandatory command argument that is required is
@@ -111,7 +104,6 @@ const CMICmdArgSet::SetCmdArgs_t &CMICmdArgSet::GetArgsThatAreMissing() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: After validating an options line of text (the context) and there is
// a failure,
// it may be because one or more arguments were unable to extract a
@@ -127,7 +119,6 @@ const CMICmdArgSet::SetCmdArgs_t &CMICmdArgSet::GetArgsThatInvalid() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: The list of argument or option (objects) that were specified by the
// command
// and so recognised when parsed but were not handled. Ideally the
@@ -149,7 +140,6 @@ const CMICmdArgSet::SetCmdArgs_t &CMICmdArgSet::GetArgsNotHandledByCmd() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Given a set of command argument objects parse the context option
// string to
// find those argument and retrieve their value. If the function fails
@@ -200,7 +190,6 @@ bool CMICmdArgSet::Validate(const CMIUtilString &vStrMiCmd,
}
//++
-//------------------------------------------------------------------------------------
// Details: Having validated the command's options text and failed for some
// reason form
// the error message made up with the faults found.
@@ -311,7 +300,6 @@ bool CMICmdArgSet::ValidationFormErrorMessages(
}
//++
-//------------------------------------------------------------------------------------
// Details: Ask if the command's argument options text had any arguments.
// Type: Method.
// Args: None.
@@ -324,7 +312,6 @@ bool CMICmdArgSet::IsArgContextEmpty() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the number of arguments that are being used for the
// command.
// Type: Method.
@@ -335,7 +322,6 @@ bool CMICmdArgSet::IsArgContextEmpty() const {
size_t CMICmdArgSet::GetCount() const { return m_setCmdArgs.size(); }
//++
-//------------------------------------------------------------------------------------
// Details: Given a set of command argument objects retrieve the argument with
// the
// specified name.
@@ -365,7 +351,6 @@ bool CMICmdArgSet::GetArg(const CMIUtilString &vArgName,
}
//++
-//------------------------------------------------------------------------------------
// Details: Write a warning message to the MI Log file about the command's
// arguments or
// options that were found present but not handled.
diff --git a/tools/lldb-mi/MICmdArgSet.h b/tools/lldb-mi/MICmdArgSet.h
index 88716a91f0adb..4df5aaf515674 100644
--- a/tools/lldb-mi/MICmdArgSet.h
+++ b/tools/lldb-mi/MICmdArgSet.h
@@ -1,9 +1,8 @@
//===-- MICmdArgSet.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgValBase.cpp b/tools/lldb-mi/MICmdArgValBase.cpp
index 8b1706db93ef8..dc9c7e0257e75 100644
--- a/tools/lldb-mi/MICmdArgValBase.cpp
+++ b/tools/lldb-mi/MICmdArgValBase.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValBase.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MIUtilString.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValBase constructor.
// Type: Method.
// Args: None.
@@ -24,7 +22,6 @@ CMICmdArgValBase::CMICmdArgValBase()
m_bIsMissingOptions(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValBase constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -43,7 +40,6 @@ CMICmdArgValBase::CMICmdArgValBase(const CMIUtilString &vrArgName,
m_bIsMissingOptions(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state flag of whether the argument is handled by the
// command or
// not.
@@ -58,7 +54,6 @@ bool CMICmdArgValBase::GetIsMissingOptions() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state flag of whether the argument is handled by the
// command or
// not.
@@ -71,7 +66,6 @@ bool CMICmdArgValBase::GetIsMissingOptions() const {
bool CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the name of *this argument.
// Type: Method.
// Args: None.
@@ -81,7 +75,6 @@ bool CMICmdArgValBase::GetIsHandledByCmd() const { return m_bHandled; }
const CMIUtilString &CMICmdArgValBase::GetName() const { return m_strArgName; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state flag of whether the argument was found in the
// command's
// argument / options string.
@@ -94,7 +87,6 @@ const CMIUtilString &CMICmdArgValBase::GetName() const { return m_strArgName; }
bool CMICmdArgValBase::GetFound() const { return m_bFound; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state flag indicating whether the value was obtained
// from the
// text arguments string and is valid.
@@ -107,7 +99,6 @@ bool CMICmdArgValBase::GetFound() const { return m_bFound; }
bool CMICmdArgValBase::GetValid() const { return m_bValid; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state flag indicating whether *this argument is a
// mandatory
// argument for the command or is optional to be present.
@@ -120,7 +111,6 @@ bool CMICmdArgValBase::GetValid() const { return m_bValid; }
bool CMICmdArgValBase::GetIsMandatory() const { return m_bMandatory; }
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
diff --git a/tools/lldb-mi/MICmdArgValBase.h b/tools/lldb-mi/MICmdArgValBase.h
index 1b4582963e570..feb7fe4f04d38 100644
--- a/tools/lldb-mi/MICmdArgValBase.h
+++ b/tools/lldb-mi/MICmdArgValBase.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValBase.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -86,7 +85,6 @@ protected:
};
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValBaseTemplate constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -104,7 +102,6 @@ CMICmdArgValBaseTemplate<T>::CMICmdArgValBaseTemplate(
: CMICmdArgValBase(vrArgName, vbMandatory, vbHandleByCmd) {}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value the argument parsed from the command's argument /
// options
// text string.
diff --git a/tools/lldb-mi/MICmdArgValConsume.cpp b/tools/lldb-mi/MICmdArgValConsume.cpp
index 86c4f09125658..01d0013665968 100644
--- a/tools/lldb-mi/MICmdArgValConsume.cpp
+++ b/tools/lldb-mi/MICmdArgValConsume.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValConsume.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValConsume constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@
CMICmdArgValConsume::CMICmdArgValConsume() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValConsume constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -36,7 +33,6 @@ CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName,
: CMICmdArgValBaseTemplate(vrArgName, vbMandatory, true) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValConsume destructor.
// Type: Overidden.
// Args: None.
@@ -46,7 +42,6 @@ CMICmdArgValConsume::CMICmdArgValConsume(const CMIUtilString &vrArgName,
CMICmdArgValConsume::~CMICmdArgValConsume() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
@@ -82,7 +77,6 @@ bool CMICmdArgValConsume::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Nothing to examine as we just want to consume the argument or option
// (ignore
// it).
diff --git a/tools/lldb-mi/MICmdArgValConsume.h b/tools/lldb-mi/MICmdArgValConsume.h
index 1169eb9a4efe2..62207f04b6793 100644
--- a/tools/lldb-mi/MICmdArgValConsume.h
+++ b/tools/lldb-mi/MICmdArgValConsume.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValConsume.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgValFile.cpp b/tools/lldb-mi/MICmdArgValFile.cpp
index cb2ba01259034..7171b0fa8f186 100644
--- a/tools/lldb-mi/MICmdArgValFile.cpp
+++ b/tools/lldb-mi/MICmdArgValFile.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValFile.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValFile constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@
CMICmdArgValFile::CMICmdArgValFile() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValFile constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -39,7 +36,6 @@ CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName,
: CMICmdArgValBaseTemplate(vrArgName, vbMandatory, vbHandleByCmd) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValFile destructor.
// Type: Overridden.
// Args: None.
@@ -49,7 +45,6 @@ CMICmdArgValFile::CMICmdArgValFile(const CMIUtilString &vrArgName,
CMICmdArgValFile::~CMICmdArgValFile() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
@@ -102,7 +97,6 @@ bool CMICmdArgValFile::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Given some text extract the file name path from it. If a space is
// found in
// path done return the path surrounded in quotes.
@@ -125,7 +119,6 @@ CMICmdArgValFile::GetFileNamePath(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid file name path.
// Type: Method.
// Args: vrFileNamePath - (R) File's name and directory path.
@@ -162,7 +155,6 @@ bool CMICmdArgValFile::IsFilePath(const CMIUtilString &vrFileNamePath) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if the path contains valid characters for a file path.
// Letters can be
// either upper or lower case.
diff --git a/tools/lldb-mi/MICmdArgValFile.h b/tools/lldb-mi/MICmdArgValFile.h
index def870e76493e..8030cb783aab6 100644
--- a/tools/lldb-mi/MICmdArgValFile.h
+++ b/tools/lldb-mi/MICmdArgValFile.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValFile.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgValListBase.cpp b/tools/lldb-mi/MICmdArgValListBase.cpp
index ff18abaac38c9..bd175f3afe64a 100644
--- a/tools/lldb-mi/MICmdArgValListBase.cpp
+++ b/tools/lldb-mi/MICmdArgValListBase.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValListBase.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,7 +18,6 @@
#include "MICmdArgValThreadGrp.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase constructor.
// Type: Method.
// Args: None.
@@ -30,7 +28,6 @@ CMICmdArgValListBase::CMICmdArgValListBase()
: m_eArgType(eArgValType_invalid) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -48,7 +45,6 @@ CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName,
m_eArgType(eArgValType_invalid) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -69,7 +65,6 @@ CMICmdArgValListBase::CMICmdArgValListBase(const CMIUtilString &vrArgName,
m_eArgType(veType) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListBase destructor.
// Type: Overridden.
// Args: None.
@@ -82,7 +77,6 @@ CMICmdArgValListBase::~CMICmdArgValListBase() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Tear down resources used by *this object.
// Type: Method.
// Args: None.
@@ -103,7 +97,6 @@ void CMICmdArgValListBase::Destroy() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Create an CMICmdArgValBase derived object matching the type
// specified
// and put the option or argument's value inside it.
@@ -164,7 +157,6 @@ CMICmdArgValListBase::CreationObj(const CMIUtilString &vrTxt,
}
//++
-//------------------------------------------------------------------------------------
// Details: Validate the option or argument is the correct type.
// Type: Method.
// Args: vrTxt - (R) Text version the option or argument.
diff --git a/tools/lldb-mi/MICmdArgValListBase.h b/tools/lldb-mi/MICmdArgValListBase.h
index 03cef723e2e0e..4437ae19a87c5 100644
--- a/tools/lldb-mi/MICmdArgValListBase.h
+++ b/tools/lldb-mi/MICmdArgValListBase.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValListBase.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -46,7 +45,6 @@ public:
// Enums:
public:
//++
- //---------------------------------------------------------------------------------
// Details: CMICmdArgValListBase needs to know what type of argument to look
// for in
// the command options text. It also needs to create argument objects
diff --git a/tools/lldb-mi/MICmdArgValListOfN.cpp b/tools/lldb-mi/MICmdArgValListOfN.cpp
index 103008e98816b..b53424543b2b6 100644
--- a/tools/lldb-mi/MICmdArgValListOfN.cpp
+++ b/tools/lldb-mi/MICmdArgValListOfN.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValListOfN.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "MICmdArgValThreadGrp.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN constructor.
// Type: Method.
// Args: None.
@@ -28,7 +26,6 @@
CMICmdArgValListOfN::CMICmdArgValListOfN() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -48,7 +45,6 @@ CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName,
: CMICmdArgValListBase(vrArgName, vbMandatory, vbHandleByCmd, veType) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValListOfN destructor.
// Type: Overridden.
// Args: None.
@@ -58,7 +54,6 @@ CMICmdArgValListOfN::CMICmdArgValListOfN(const CMIUtilString &vrArgName,
CMICmdArgValListOfN::~CMICmdArgValListOfN() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// list of
// arguments based on the argument object type to look for.
@@ -88,7 +83,6 @@ bool CMICmdArgValListOfN::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Create list of argument objects each holding a value extract from
// the command
// options line.
@@ -125,7 +119,6 @@ bool CMICmdArgValListOfN::CreateList(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Type: Method.
@@ -158,7 +151,6 @@ bool CMICmdArgValListOfN::IsListOfN(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the list of CMICmdArgValBase derived option objects found
// following
// *this long option argument. For example "list-thread-groups [
diff --git a/tools/lldb-mi/MICmdArgValListOfN.h b/tools/lldb-mi/MICmdArgValListOfN.h
index 002970841672c..74e8c16f7d6e9 100644
--- a/tools/lldb-mi/MICmdArgValListOfN.h
+++ b/tools/lldb-mi/MICmdArgValListOfN.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValListOfN.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -62,7 +61,6 @@ private:
};
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the first argument or option value from the list of 1 or
// more options
// parsed from the command's options string.
diff --git a/tools/lldb-mi/MICmdArgValNumber.cpp b/tools/lldb-mi/MICmdArgValNumber.cpp
index 6ef6769391ece..ad2df79bf3d99 100644
--- a/tools/lldb-mi/MICmdArgValNumber.cpp
+++ b/tools/lldb-mi/MICmdArgValNumber.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValNumber.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber constructor.
// Type: Method.
// Args: None.
@@ -24,7 +22,6 @@ CMICmdArgValNumber::CMICmdArgValNumber()
m_nNumber(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -46,7 +43,6 @@ CMICmdArgValNumber::CMICmdArgValNumber(
m_nNumberFormatMask(vnNumberFormatMask), m_nNumber(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValNumber destructor.
// Type: Overridden.
// Args: None.
@@ -56,7 +52,6 @@ CMICmdArgValNumber::CMICmdArgValNumber(
CMICmdArgValNumber::~CMICmdArgValNumber() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
@@ -106,7 +101,6 @@ bool CMICmdArgValNumber::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Type: Method.
@@ -135,7 +129,6 @@ bool CMICmdArgValNumber::IsArgNumber(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Extract the thread group number from the thread group argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
@@ -154,7 +147,6 @@ bool CMICmdArgValNumber::ExtractNumber(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the thread group ID found in the argument.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmdArgValNumber.h b/tools/lldb-mi/MICmdArgValNumber.h
index 5f94fc86893f4..23c888e5d8068 100644
--- a/tools/lldb-mi/MICmdArgValNumber.h
+++ b/tools/lldb-mi/MICmdArgValNumber.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValNumber.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,7 +28,6 @@ class CMICmdArgValNumber : public CMICmdArgValBaseTemplate<MIint64> {
// Enums:
public:
//++
- //---------------------------------------------------------------------------------
// Details: CMICmdArgValNumber needs to know what format of argument to look
// for in
// the command options text.
diff --git a/tools/lldb-mi/MICmdArgValOptionLong.cpp b/tools/lldb-mi/MICmdArgValOptionLong.cpp
index 3824fe19188a8..3dc9d40f4b563 100644
--- a/tools/lldb-mi/MICmdArgValOptionLong.cpp
+++ b/tools/lldb-mi/MICmdArgValOptionLong.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValOptionLong.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: None.
@@ -23,7 +21,6 @@ CMICmdArgValOptionLong::CMICmdArgValOptionLong()
: m_nExpectingNOptions(0), m_eExpectingOptionType(eArgValType_invalid) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -41,7 +38,6 @@ CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName,
m_nExpectingNOptions(0), m_eExpectingOptionType(eArgValType_invalid) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -66,7 +62,6 @@ CMICmdArgValOptionLong::CMICmdArgValOptionLong(const CMIUtilString &vrArgName,
m_eExpectingOptionType(veType) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong destructor.
// Type: Overridden.
// Args: None.
@@ -79,7 +74,6 @@ CMICmdArgValOptionLong::~CMICmdArgValOptionLong() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Tear down resources used by *this object.
// Type: Method.
// Args: None.
@@ -100,7 +94,6 @@ void CMICmdArgValOptionLong::Destroy() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// long
// argument *this argument type is looking for.
@@ -168,7 +161,6 @@ bool CMICmdArgValOptionLong::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the text following *this argument and extract the options the
// values of
// CMICmdArgValListBase::m_eArgType forming argument objects for each
@@ -229,7 +221,6 @@ bool CMICmdArgValOptionLong::ExtractExpectedOptions(CMICmdArgContext &vrwTxt,
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid long type option
// argument.
// Long type argument looks like --someLongOption.
@@ -256,7 +247,6 @@ bool CMICmdArgValOptionLong::IsArgLongOption(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid long type option
// argument.
// Long type argument looks like --someLongOption.
@@ -271,7 +261,6 @@ bool CMICmdArgValOptionLong::IsArgOptionCorrect(
}
//++
-//------------------------------------------------------------------------------------
// Details: Does the argument name of the argument being parsed ATM match the
// name of
// *this argument object.
@@ -286,7 +275,6 @@ bool CMICmdArgValOptionLong::ArgNameMatch(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the list of CMICmdArgValBase derived option objects found
// following
// *this long option argument. For example "list-thread-groups [
diff --git a/tools/lldb-mi/MICmdArgValOptionLong.h b/tools/lldb-mi/MICmdArgValOptionLong.h
index cabe3799de86f..240829733680c 100644
--- a/tools/lldb-mi/MICmdArgValOptionLong.h
+++ b/tools/lldb-mi/MICmdArgValOptionLong.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValOptionLong.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -79,7 +78,6 @@ private:
};
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the first argument or option value from the list of 1 or
// more options
// parsed from the command's options string.
diff --git a/tools/lldb-mi/MICmdArgValOptionShort.cpp b/tools/lldb-mi/MICmdArgValOptionShort.cpp
index cd403aa8fd43c..7b7116cd5f18d 100644
--- a/tools/lldb-mi/MICmdArgValOptionShort.cpp
+++ b/tools/lldb-mi/MICmdArgValOptionShort.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValOptionShort.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@
CMICmdArgValOptionShort::CMICmdArgValOptionShort() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -39,7 +36,6 @@ CMICmdArgValOptionShort::CMICmdArgValOptionShort(const CMIUtilString &vrArgName,
: CMICmdArgValOptionLong(vrArgName, vbMandatory, vbHandleByCmd) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionLong constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -62,7 +58,6 @@ CMICmdArgValOptionShort::CMICmdArgValOptionShort(
vnExpectingNOptions) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValOptionShort destructor.
// Type: Overridden.
// Args: None.
@@ -72,7 +67,6 @@ CMICmdArgValOptionShort::CMICmdArgValOptionShort(
CMICmdArgValOptionShort::~CMICmdArgValOptionShort() {}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid short type option
// argument.
// Type: Method.
@@ -99,7 +93,6 @@ bool CMICmdArgValOptionShort::IsArgShortOption(
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid short type option
// argument.
// Long type argument looks like -f some short option.
@@ -114,7 +107,6 @@ bool CMICmdArgValOptionShort::IsArgOptionCorrect(
}
//++
-//------------------------------------------------------------------------------------
// Details: Does the argument name of the argument being parsed ATM match the
// name of
// *this argument object.
diff --git a/tools/lldb-mi/MICmdArgValOptionShort.h b/tools/lldb-mi/MICmdArgValOptionShort.h
index 09482899a3005..fd39c9e73a579 100644
--- a/tools/lldb-mi/MICmdArgValOptionShort.h
+++ b/tools/lldb-mi/MICmdArgValOptionShort.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValOptionShort.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgValPrintValues.cpp b/tools/lldb-mi/MICmdArgValPrintValues.cpp
index 722c4c258313f..a2ce45247375d 100644
--- a/tools/lldb-mi/MICmdArgValPrintValues.cpp
+++ b/tools/lldb-mi/MICmdArgValPrintValues.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValPrintValues.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValPrintValues constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@
CMICmdArgValPrintValues::CMICmdArgValPrintValues() : m_nPrintValues(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValPrintValues constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -40,7 +37,6 @@ CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName,
m_nPrintValues(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValPrintValues destructor.
// Type: Overridden.
// Args: None.
@@ -50,7 +46,6 @@ CMICmdArgValPrintValues::CMICmdArgValPrintValues(const CMIUtilString &vrArgName,
CMICmdArgValPrintValues::~CMICmdArgValPrintValues() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
@@ -77,7 +72,6 @@ bool CMICmdArgValPrintValues::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Type: Method.
@@ -96,7 +90,6 @@ bool CMICmdArgValPrintValues::IsArgPrintValues(
}
//++
-//------------------------------------------------------------------------------------
// Details: Extract the print-values from the print-values argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
@@ -121,7 +114,6 @@ bool CMICmdArgValPrintValues::ExtractPrintValues(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the print-values found in the argument.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmdArgValPrintValues.h b/tools/lldb-mi/MICmdArgValPrintValues.h
index ddfa7c24fcc1e..3fa8142c1ae5a 100644
--- a/tools/lldb-mi/MICmdArgValPrintValues.h
+++ b/tools/lldb-mi/MICmdArgValPrintValues.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValPrintValues.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgValString.cpp b/tools/lldb-mi/MICmdArgValString.cpp
index 28d4d18c361b6..bd105bc289b30 100644
--- a/tools/lldb-mi/MICmdArgValString.cpp
+++ b/tools/lldb-mi/MICmdArgValString.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValString.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: None.
@@ -24,7 +22,6 @@ CMICmdArgValString::CMICmdArgValString()
m_bHandleDirPaths(false), m_bHandleAnything(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: vbAnything - (R) True = Parse a string and accept anything, false =
@@ -37,7 +34,6 @@ CMICmdArgValString::CMICmdArgValString(const bool vbAnything)
m_bHandleDirPaths(false), m_bHandleAnything(vbAnything) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: vbHandleQuotes - (R) True = Parse a string surrounded by quotes
@@ -59,7 +55,6 @@ CMICmdArgValString::CMICmdArgValString(const bool vbHandleQuotes,
m_bHandleDirPaths(vbHandleDirPaths), m_bHandleAnything(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -86,7 +81,6 @@ CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName,
m_bHandleDirPaths(false), m_bHandleAnything(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValString constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -116,7 +110,6 @@ CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName,
m_bHandleDirPaths(vbHandleDirPaths), m_bHandleAnything(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValString destructor.
// Type: Overridden.
// Args: None.
@@ -126,7 +119,6 @@ CMICmdArgValString::CMICmdArgValString(const CMIUtilString &vrArgName,
CMICmdArgValString::~CMICmdArgValString() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
@@ -147,7 +139,6 @@ bool CMICmdArgValString::Validate(CMICmdArgContext &vrwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract only
// the next
// word delimited by the next space.
@@ -181,7 +172,6 @@ bool CMICmdArgValString::ValidateSingleText(CMICmdArgContext &vrwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract all
// the words
// between quotes then delimited by the next space.
@@ -213,7 +203,6 @@ bool CMICmdArgValString::ValidateQuotedText(CMICmdArgContext &vrwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Type: Method.
@@ -233,7 +222,6 @@ bool CMICmdArgValString::IsStringArg(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument or
// option value. If the string looks like a long option, short option,
@@ -276,7 +264,6 @@ bool CMICmdArgValString::IsStringArgSingleText(
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Take into account quotes surrounding the text. Note this function
@@ -327,7 +314,6 @@ bool CMICmdArgValString::IsStringArgQuotedText(
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Take into account quotes surrounding the text. Take into account
@@ -366,7 +352,6 @@ bool CMICmdArgValString::IsStringArgQuotedTextEmbedded(
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Take into account quotes surrounding the text. Take into account
diff --git a/tools/lldb-mi/MICmdArgValString.h b/tools/lldb-mi/MICmdArgValString.h
index e5a6107be507d..77041c2d0c9f6 100644
--- a/tools/lldb-mi/MICmdArgValString.h
+++ b/tools/lldb-mi/MICmdArgValString.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValString.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.cpp b/tools/lldb-mi/MICmdArgValThreadGrp.cpp
index 4ed83e6191e10..201d516525fd7 100644
--- a/tools/lldb-mi/MICmdArgValThreadGrp.cpp
+++ b/tools/lldb-mi/MICmdArgValThreadGrp.cpp
@@ -1,9 +1,8 @@
//===-- MICmdArgValThreadGrp.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdArgContext.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@
CMICmdArgValThreadGrp::CMICmdArgValThreadGrp() : m_nThreadGrp(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp constructor.
// Type: Method.
// Args: vrArgName - (R) Argument's name to search by.
@@ -40,7 +37,6 @@ CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName,
m_nThreadGrp(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdArgValThreadGrp destructor.
// Type: Overridden.
// Args: None.
@@ -50,7 +46,6 @@ CMICmdArgValThreadGrp::CMICmdArgValThreadGrp(const CMIUtilString &vrArgName,
CMICmdArgValThreadGrp::~CMICmdArgValThreadGrp() {}
//++
-//------------------------------------------------------------------------------------
// Details: Parse the command's argument options string and try to extract the
// value *this
// argument is looking for.
@@ -100,7 +95,6 @@ bool CMICmdArgValThreadGrp::Validate(CMICmdArgContext &vwArgContext) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the string and determine if it is a valid string type
// argument.
// Type: Method.
@@ -119,7 +113,6 @@ bool CMICmdArgValThreadGrp::IsArgThreadGrp(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Extract the thread group number from the thread group argument.
// Type: Method.
// Args: vrTxt - (R) Some text.
@@ -139,7 +132,6 @@ bool CMICmdArgValThreadGrp::ExtractNumber(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the thread group ID found in the argument.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmdArgValThreadGrp.h b/tools/lldb-mi/MICmdArgValThreadGrp.h
index bcdb156a1b144..12d3a1e90244e 100644
--- a/tools/lldb-mi/MICmdArgValThreadGrp.h
+++ b/tools/lldb-mi/MICmdArgValThreadGrp.h
@@ -1,9 +1,8 @@
//===-- MICmdArgValThreadGrp.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdBase.cpp b/tools/lldb-mi/MICmdBase.cpp
index 613f005cf754f..df36cfe86420f 100644
--- a/tools/lldb-mi/MICmdBase.cpp
+++ b/tools/lldb-mi/MICmdBase.cpp
@@ -1,9 +1,8 @@
//===-- MICmdBase.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MICmnMIValueConst.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdBase constructor.
// Type: Method.
// Args: None.
@@ -31,7 +29,6 @@ CMICmdBase::CMICmdBase()
m_ThreadArgMandatory(false), m_FrameArgMandatory(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdBase destructor.
// Type: Overrideable.
// Args: None.
@@ -41,7 +38,6 @@ CMICmdBase::CMICmdBase()
CMICmdBase::~CMICmdBase() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function.
// Type: Overridden.
// Args: None.
@@ -51,7 +47,6 @@ CMICmdBase::~CMICmdBase() {}
const SMICmdData &CMICmdBase::GetCmdData() const { return m_cmdData; }
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function.
// Type: Overridden.
// Args: None.
@@ -64,7 +59,6 @@ const CMIUtilString &CMICmdBase::GetErrorDescription() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: The CMICmdFactory requires this function. Retrieve the command and
// argument
// options description string.
@@ -76,7 +70,6 @@ const CMIUtilString &CMICmdBase::GetErrorDescription() const {
const CMIUtilString &CMICmdBase::GetMiCmd() const { return m_strMiCmd; }
//++
-//------------------------------------------------------------------------------------
// Details: Help parse the arguments that are common to all commands.
// Args: None.
// Return: None
@@ -96,7 +89,6 @@ void CMICmdBase::AddCommonArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. A command must be given working
// data and
// provide data about its status or provide information to other
@@ -111,7 +103,6 @@ void CMICmdBase::SetCmdData(const SMICmdData &vCmdData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: The command factory requires this function. The factory calls this
// function
// so it can obtain *this command's creation function.
@@ -125,7 +116,6 @@ CMICmdFactory::CmdCreatorFnPtr CMICmdBase::GetCmdCreatorFn() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: If a command is an event type (has callbacks registered with
// SBListener) it
// needs to inform the Invoker that it has finished its work so that
@@ -144,7 +134,6 @@ void CMICmdBase::CmdFinishedTellInvoker() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Returns the final version of the MI result record built up in the
// command's
// Acknowledge function. The one line text of MI result.
@@ -158,7 +147,6 @@ const CMIUtilString &CMICmdBase::GetMIResultRecord() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve from the command additional MI result to its 1 line
// response.
// Because of using LLDB additional 'fake'/hack output is sometimes
@@ -174,7 +162,6 @@ const CMIUtilString &CMICmdBase::GetMIResultRecordExtra() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Hss *this command got additional MI result to its 1 line response.
// Because of using LLDB additional 'fake'/hack output is sometimes
// required to
@@ -190,7 +177,6 @@ bool CMICmdBase::HasMIResultRecordExtra() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Short cut function to enter error information into the command's
// metadata
// object and set the command's error status.
@@ -213,7 +199,6 @@ void CMICmdBase::SetError(const CMIUtilString &rErrMsg) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Short cut function to check MI command's execute status and
// set an error in case of failure.
// Type: Method.
@@ -237,7 +222,6 @@ bool CMICmdBase::HandleSBError(const lldb::SBError &error,
}
//++
-//------------------------------------------------------------------------------------
// Details: Short cut function to check MI command's execute status and
// call specified handler function for success case.
// Type: Method.
@@ -254,7 +238,6 @@ bool CMICmdBase::HandleSBErrorWithSuccess(
}
//++
-//------------------------------------------------------------------------------------
// Details: Short cut function to check MI command's execute status and
// call specified handler function for error case.
// Type: Method.
@@ -271,7 +254,6 @@ bool CMICmdBase::HandleSBErrorWithFailure(
}
//++
-//------------------------------------------------------------------------------------
// Details: Ask a command to provide its unique identifier.
// Type: Method.
// Args: A unique identifier for this command class.
@@ -287,7 +269,6 @@ MIuint CMICmdBase::GetGUID() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -304,7 +285,6 @@ bool CMICmdBase::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Having previously given CMICmdArgSet m_setCmdArgs all the argument
// or option
// definitions for the command to handle proceed to parse and validate
@@ -331,7 +311,6 @@ bool CMICmdBase::ParseValidateCmdOptions() {
}
//++
-//------------------------------------------------------------------------------------
// Details: If the MI Driver is not operating via a client i.e. Eclipse but say
// operating
// on a executable passed in as a argument to the drive then what
diff --git a/tools/lldb-mi/MICmdBase.h b/tools/lldb-mi/MICmdBase.h
index fe6aadd669994..4e32ed6a52628 100644
--- a/tools/lldb-mi/MICmdBase.h
+++ b/tools/lldb-mi/MICmdBase.h
@@ -1,9 +1,8 @@
//===-- MICmdBase.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -137,7 +136,6 @@ protected:
};
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the command argument or option object pointer so that it
// can be
// examined. If the option found and valid get the value (number,
@@ -171,7 +169,6 @@ T *CMICmdBase::GetOption(const CMIUtilString &vStrOptionName) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the command argument or option object pointer using
// template function
// CMICmdBase::GetOption(). Should the argument (by name) not be found
diff --git a/tools/lldb-mi/MICmdCmd.cpp b/tools/lldb-mi/MICmdCmd.cpp
index a784580673f0f..081cff6fa51f8 100644
--- a/tools/lldb-mi/MICmdCmd.cpp
+++ b/tools/lldb-mi/MICmdCmd.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmd.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MICmdCmd.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnablePrettyPrinting constructor.
// Type: Method.
// Args: None.
@@ -31,7 +29,6 @@ CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnablePrettyPrinting destructor.
// Type: Overrideable.
// Args: None.
@@ -41,7 +38,6 @@ CMICmdCmdEnablePrettyPrinting::CMICmdCmdEnablePrettyPrinting() {
CMICmdCmdEnablePrettyPrinting::~CMICmdCmdEnablePrettyPrinting() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -58,7 +54,6 @@ bool CMICmdCmdEnablePrettyPrinting::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -80,7 +75,6 @@ bool CMICmdCmdEnablePrettyPrinting::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -93,12 +87,8 @@ CMICmdBase *CMICmdCmdEnablePrettyPrinting::CreateSelf() {
return new CMICmdCmdEnablePrettyPrinting();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSource constructor.
// Type: Method.
// Args: None.
@@ -114,7 +104,6 @@ CMICmdCmdSource::CMICmdCmdSource() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSource destructor.
// Type: Overrideable.
// Args: None.
@@ -124,7 +113,6 @@ CMICmdCmdSource::CMICmdCmdSource() {
CMICmdCmdSource::~CMICmdCmdSource() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -141,7 +129,6 @@ bool CMICmdCmdSource::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -160,7 +147,6 @@ bool CMICmdCmdSource::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmd.h b/tools/lldb-mi/MICmdCmd.h
index d3de49c4ded76..aeaaa4b01db68 100644
--- a/tools/lldb-mi/MICmdCmd.h
+++ b/tools/lldb-mi/MICmdCmd.h
@@ -1,9 +1,8 @@
//===-- MICmdCmd.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdBreak.cpp b/tools/lldb-mi/MICmdCmdBreak.cpp
index 0e42f8562ab40..1cd0bacf51d50 100644
--- a/tools/lldb-mi/MICmdCmdBreak.cpp
+++ b/tools/lldb-mi/MICmdCmdBreak.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdBreak.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,7 +33,6 @@
#include "MICmnStreamStdout.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakInsert constructor.
// Type: Method.
// Args: None.
@@ -58,7 +56,6 @@ CMICmdCmdBreakInsert::CMICmdCmdBreakInsert()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakInsert destructor.
// Type: Overrideable.
// Args: None.
@@ -68,7 +65,6 @@ CMICmdCmdBreakInsert::CMICmdCmdBreakInsert()
CMICmdCmdBreakInsert::~CMICmdCmdBreakInsert() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -105,7 +101,6 @@ bool CMICmdCmdBreakInsert::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Helper function for CMICmdCmdBreakInsert::Execute().
//
// Given a string, return the position of the ':' separator in 'file:func'
@@ -123,7 +118,6 @@ static size_t findFileSeparatorPos(const std::string &x) {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -324,7 +318,6 @@ bool CMICmdCmdBreakInsert::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -360,7 +353,6 @@ bool CMICmdCmdBreakInsert::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -373,12 +365,8 @@ CMICmdBase *CMICmdCmdBreakInsert::CreateSelf() {
return new CMICmdCmdBreakInsert();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDelete constructor.
// Type: Method.
// Args: None.
@@ -395,7 +383,6 @@ CMICmdCmdBreakDelete::CMICmdCmdBreakDelete()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDelete destructor.
// Type: Overrideable.
// Args: None.
@@ -405,7 +392,6 @@ CMICmdCmdBreakDelete::CMICmdCmdBreakDelete()
CMICmdCmdBreakDelete::~CMICmdCmdBreakDelete() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -423,7 +409,6 @@ bool CMICmdCmdBreakDelete::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -462,7 +447,6 @@ bool CMICmdCmdBreakDelete::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -481,7 +465,6 @@ bool CMICmdCmdBreakDelete::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -494,12 +477,8 @@ CMICmdBase *CMICmdCmdBreakDelete::CreateSelf() {
return new CMICmdCmdBreakDelete();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDisable constructor.
// Type: Method.
// Args: None.
@@ -517,7 +496,6 @@ CMICmdCmdBreakDisable::CMICmdCmdBreakDisable()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakDisable destructor.
// Type: Overrideable.
// Args: None.
@@ -527,7 +505,6 @@ CMICmdCmdBreakDisable::CMICmdCmdBreakDisable()
CMICmdCmdBreakDisable::~CMICmdCmdBreakDisable() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -545,7 +522,6 @@ bool CMICmdCmdBreakDisable::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -582,7 +558,6 @@ bool CMICmdCmdBreakDisable::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -613,7 +588,6 @@ bool CMICmdCmdBreakDisable::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -626,12 +600,8 @@ CMICmdBase *CMICmdCmdBreakDisable::CreateSelf() {
return new CMICmdCmdBreakDisable();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakEnable constructor.
// Type: Method.
// Args: None.
@@ -649,7 +619,6 @@ CMICmdCmdBreakEnable::CMICmdCmdBreakEnable()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakEnable destructor.
// Type: Overrideable.
// Args: None.
@@ -659,7 +628,6 @@ CMICmdCmdBreakEnable::CMICmdCmdBreakEnable()
CMICmdCmdBreakEnable::~CMICmdCmdBreakEnable() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -677,7 +645,6 @@ bool CMICmdCmdBreakEnable::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -714,7 +681,6 @@ bool CMICmdCmdBreakEnable::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -745,7 +711,6 @@ bool CMICmdCmdBreakEnable::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -758,12 +723,8 @@ CMICmdBase *CMICmdCmdBreakEnable::CreateSelf() {
return new CMICmdCmdBreakEnable();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakAfter constructor.
// Type: Method.
// Args: None.
@@ -781,7 +742,6 @@ CMICmdCmdBreakAfter::CMICmdCmdBreakAfter()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakAfter destructor.
// Type: Overrideable.
// Args: None.
@@ -791,7 +751,6 @@ CMICmdCmdBreakAfter::CMICmdCmdBreakAfter()
CMICmdCmdBreakAfter::~CMICmdCmdBreakAfter() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -809,7 +768,6 @@ bool CMICmdCmdBreakAfter::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -855,7 +813,6 @@ bool CMICmdCmdBreakAfter::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -874,7 +831,6 @@ bool CMICmdCmdBreakAfter::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -887,12 +843,8 @@ CMICmdBase *CMICmdCmdBreakAfter::CreateSelf() {
return new CMICmdCmdBreakAfter();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakCondition constructor.
// Type: Method.
// Args: None.
@@ -915,7 +867,6 @@ CMICmdCmdBreakCondition::CMICmdCmdBreakCondition()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdBreakCondition destructor.
// Type: Overrideable.
// Args: None.
@@ -925,7 +876,6 @@ CMICmdCmdBreakCondition::CMICmdCmdBreakCondition()
CMICmdCmdBreakCondition::~CMICmdCmdBreakCondition() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -947,7 +897,6 @@ bool CMICmdCmdBreakCondition::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -994,7 +943,6 @@ bool CMICmdCmdBreakCondition::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1013,7 +961,6 @@ bool CMICmdCmdBreakCondition::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1027,7 +974,6 @@ CMICmdBase *CMICmdCmdBreakCondition::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: A breakpoint expression can be passed to *this command as:
// a single string i.e. '2' -> ok.
// a quoted string i.e. "a > 100" -> ok
diff --git a/tools/lldb-mi/MICmdCmdBreak.h b/tools/lldb-mi/MICmdCmdBreak.h
index 7640e50a2bbff..00c5aa236eac4 100644
--- a/tools/lldb-mi/MICmdCmdBreak.h
+++ b/tools/lldb-mi/MICmdCmdBreak.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdBreak.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdData.cpp b/tools/lldb-mi/MICmdCmdData.cpp
index 7a4845bba4301..e0a1657651998 100644
--- a/tools/lldb-mi/MICmdCmdData.cpp
+++ b/tools/lldb-mi/MICmdCmdData.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdData.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -53,7 +52,6 @@ CMIUtilString IntToHexAddrStr(uint32_t number) {
} // namespace
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataEvaluateExpression constructor.
// Type: Method.
// Args: None.
@@ -72,7 +70,6 @@ CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataEvaluateExpression destructor.
// Type: Overrideable.
// Args: None.
@@ -82,7 +79,6 @@ CMICmdCmdDataEvaluateExpression::CMICmdCmdDataEvaluateExpression()
CMICmdCmdDataEvaluateExpression::~CMICmdCmdDataEvaluateExpression() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -99,7 +95,6 @@ bool CMICmdCmdDataEvaluateExpression::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -151,7 +146,6 @@ bool CMICmdCmdDataEvaluateExpression::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -206,7 +200,6 @@ bool CMICmdCmdDataEvaluateExpression::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -220,7 +213,6 @@ CMICmdBase *CMICmdCmdDataEvaluateExpression::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Examine the expression string to see if it contains invalid
// characters.
// Type: Method.
@@ -242,12 +234,8 @@ bool CMICmdCmdDataEvaluateExpression::HaveInvalidCharacterInExpression(
return bFoundInvalidCharInExpression;
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataDisassemble constructor.
// Type: Method.
// Args: None.
@@ -265,7 +253,6 @@ CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataDisassemble destructor.
// Type: Overrideable.
// Args: None.
@@ -275,7 +262,6 @@ CMICmdCmdDataDisassemble::CMICmdCmdDataDisassemble()
CMICmdCmdDataDisassemble::~CMICmdCmdDataDisassemble() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -297,7 +283,6 @@ bool CMICmdCmdDataDisassemble::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -416,10 +401,14 @@ bool CMICmdCmdDataDisassemble::Execute() {
const MIuint nLine = lineEntry.GetLine();
const char *pFileName = lineEntry.GetFileSpec().GetFilename();
pFileName = (pFileName != nullptr) ? pFileName : pUnknown;
+ // Get a full path to the file.
+ char pathBuffer[PATH_MAX];
+ lineEntry.GetFileSpec().GetPath(pathBuffer, PATH_MAX);
- // MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ]}"
+ // MI "src_and_asm_line={line=\"%u\",file=\"%s\",line_asm_insn=[ ],
+ // fullname=\"%s\"}"
const CMICmnMIValueConst miValueConst(
- CMIUtilString::Format("0x%u", nLine));
+ CMIUtilString::Format("%u", nLine));
const CMICmnMIValueResult miValueResult("line", miValueConst);
CMICmnMIValueTuple miValueTuple2(miValueResult);
const CMICmnMIValueConst miValueConst2(pFileName);
@@ -428,6 +417,9 @@ bool CMICmdCmdDataDisassemble::Execute() {
const CMICmnMIValueList miValueList(miValueTuple);
const CMICmnMIValueResult miValueResult3("line_asm_insn", miValueList);
miValueTuple2.Add(miValueResult3);
+ const CMICmnMIValueConst miValueConst5(pathBuffer);
+ const CMICmnMIValueResult miValueResult5("fullname", miValueConst5);
+ miValueTuple2.Add(miValueResult5);
const CMICmnMIValueResult miValueResult4("src_and_asm_line",
miValueTuple2);
m_miValueList.Add(miValueResult4);
@@ -440,7 +432,6 @@ bool CMICmdCmdDataDisassemble::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -461,7 +452,6 @@ bool CMICmdCmdDataDisassemble::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -474,12 +464,8 @@ CMICmdBase *CMICmdCmdDataDisassemble::CreateSelf() {
return new CMICmdCmdDataDisassemble();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemoryBytes constructor.
// Type: Method.
// Args: None.
@@ -498,7 +484,6 @@ CMICmdCmdDataReadMemoryBytes::CMICmdCmdDataReadMemoryBytes()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemoryBytes destructor.
// Type: Overrideable.
// Args: None.
@@ -513,7 +498,6 @@ CMICmdCmdDataReadMemoryBytes::~CMICmdCmdDataReadMemoryBytes() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -534,7 +518,6 @@ bool CMICmdCmdDataReadMemoryBytes::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -664,7 +647,6 @@ bool CMICmdCmdDataReadMemoryBytes::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -712,7 +694,6 @@ bool CMICmdCmdDataReadMemoryBytes::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -725,12 +706,8 @@ CMICmdBase *CMICmdCmdDataReadMemoryBytes::CreateSelf() {
return new CMICmdCmdDataReadMemoryBytes();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemory constructor.
// Type: Method.
// Args: None.
@@ -746,7 +723,6 @@ CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemory destructor.
// Type: Overrideable.
// Args: None.
@@ -756,7 +732,6 @@ CMICmdCmdDataReadMemory::CMICmdCmdDataReadMemory() {
CMICmdCmdDataReadMemory::~CMICmdCmdDataReadMemory() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -773,7 +748,6 @@ bool CMICmdCmdDataReadMemory::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -798,7 +772,6 @@ bool CMICmdCmdDataReadMemory::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -811,12 +784,8 @@ CMICmdBase *CMICmdCmdDataReadMemory::CreateSelf() {
return new CMICmdCmdDataReadMemory();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterNames constructor.
// Type: Method.
// Args: None.
@@ -833,7 +802,6 @@ CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataReadMemoryBytes destructor.
// Type: Overrideable.
// Args: None.
@@ -843,7 +811,6 @@ CMICmdCmdDataListRegisterNames::CMICmdCmdDataListRegisterNames()
CMICmdCmdDataListRegisterNames::~CMICmdCmdDataListRegisterNames() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -861,7 +828,6 @@ bool CMICmdCmdDataListRegisterNames::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -926,7 +892,6 @@ bool CMICmdCmdDataListRegisterNames::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -947,7 +912,6 @@ bool CMICmdCmdDataListRegisterNames::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -961,7 +925,6 @@ CMICmdBase *CMICmdCmdDataListRegisterNames::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -995,12 +958,8 @@ CMICmdCmdDataListRegisterNames::GetRegister(const MIuint vRegisterIndex) const {
return lldb::SBValue();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterValues constructor.
// Type: Method.
// Args: None.
@@ -1018,7 +977,6 @@ CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterValues destructor.
// Type: Overrideable.
// Args: None.
@@ -1028,7 +986,6 @@ CMICmdCmdDataListRegisterValues::CMICmdCmdDataListRegisterValues()
CMICmdCmdDataListRegisterValues::~CMICmdCmdDataListRegisterValues() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1051,7 +1008,6 @@ bool CMICmdCmdDataListRegisterValues::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1133,7 +1089,6 @@ bool CMICmdCmdDataListRegisterValues::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1154,7 +1109,6 @@ bool CMICmdCmdDataListRegisterValues::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1168,7 +1122,6 @@ CMICmdBase *CMICmdCmdDataListRegisterValues::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1203,7 +1156,6 @@ lldb::SBValue CMICmdCmdDataListRegisterValues::GetRegister(
}
//++
-//------------------------------------------------------------------------------------
// Details: Adds the register value to the output list.
// Type: Method.
// Args: Value of the register, its index and output format.
@@ -1225,12 +1177,8 @@ void CMICmdCmdDataListRegisterValues::AddToOutput(
m_miValueList.Add(miValueTuple);
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterChanged constructor.
// Type: Method.
// Args: None.
@@ -1246,7 +1194,6 @@ CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataListRegisterChanged destructor.
// Type: Overrideable.
// Args: None.
@@ -1256,7 +1203,6 @@ CMICmdCmdDataListRegisterChanged::CMICmdCmdDataListRegisterChanged() {
CMICmdCmdDataListRegisterChanged::~CMICmdCmdDataListRegisterChanged() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1274,7 +1220,6 @@ bool CMICmdCmdDataListRegisterChanged::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1296,7 +1241,6 @@ bool CMICmdCmdDataListRegisterChanged::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1309,12 +1253,8 @@ CMICmdBase *CMICmdCmdDataListRegisterChanged::CreateSelf() {
return new CMICmdCmdDataListRegisterChanged();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemoryBytes constructor.
// Type: Method.
// Args: None.
@@ -1332,7 +1272,6 @@ CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemoryBytes destructor.
// Type: Overrideable.
// Args: None.
@@ -1342,7 +1281,6 @@ CMICmdCmdDataWriteMemoryBytes::CMICmdCmdDataWriteMemoryBytes()
CMICmdCmdDataWriteMemoryBytes::~CMICmdCmdDataWriteMemoryBytes() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1363,7 +1301,6 @@ bool CMICmdCmdDataWriteMemoryBytes::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1388,7 +1325,6 @@ bool CMICmdCmdDataWriteMemoryBytes::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1410,7 +1346,6 @@ bool CMICmdCmdDataWriteMemoryBytes::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1423,12 +1358,8 @@ CMICmdBase *CMICmdCmdDataWriteMemoryBytes::CreateSelf() {
return new CMICmdCmdDataWriteMemoryBytes();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemory constructor.
// Type: Method.
// Args: None.
@@ -1448,7 +1379,6 @@ CMICmdCmdDataWriteMemory::CMICmdCmdDataWriteMemory()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataWriteMemory destructor.
// Type: Overrideable.
// Args: None.
@@ -1463,7 +1393,6 @@ CMICmdCmdDataWriteMemory::~CMICmdCmdDataWriteMemory() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1485,7 +1414,6 @@ bool CMICmdCmdDataWriteMemory::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1549,7 +1477,6 @@ bool CMICmdCmdDataWriteMemory::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1568,7 +1495,6 @@ bool CMICmdCmdDataWriteMemory::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1581,12 +1507,8 @@ CMICmdBase *CMICmdCmdDataWriteMemory::CreateSelf() {
return new CMICmdCmdDataWriteMemory();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataInfoLine constructor.
// Type: Method.
// Args: None.
@@ -1605,7 +1527,6 @@ CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdDataInfoLine destructor.
// Type: Overrideable.
// Args: None.
@@ -1615,7 +1536,6 @@ CMICmdCmdDataInfoLine::CMICmdCmdDataInfoLine()
CMICmdCmdDataInfoLine::~CMICmdCmdDataInfoLine() = default;
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1631,7 +1551,6 @@ bool CMICmdCmdDataInfoLine::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1726,7 +1645,6 @@ bool CMICmdCmdDataInfoLine::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1742,7 +1660,6 @@ bool CMICmdCmdDataInfoLine::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdData.h b/tools/lldb-mi/MICmdCmdData.h
index 0317db11a5354..19c5319faab37 100644
--- a/tools/lldb-mi/MICmdCmdData.h
+++ b/tools/lldb-mi/MICmdCmdData.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdData.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdEnviro.cpp b/tools/lldb-mi/MICmdCmdEnviro.cpp
index 298fe0d57becd..e7a92f3c9e893 100644
--- a/tools/lldb-mi/MICmdCmdEnviro.cpp
+++ b/tools/lldb-mi/MICmdCmdEnviro.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdEnviro.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "MICmnMIValueConst.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnvironmentCd constructor.
// Type: Method.
// Args: None.
@@ -35,7 +33,6 @@ CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdEnvironmentCd destructor.
// Type: Overrideable.
// Args: None.
@@ -45,7 +42,6 @@ CMICmdCmdEnvironmentCd::CMICmdCmdEnvironmentCd()
CMICmdCmdEnvironmentCd::~CMICmdCmdEnvironmentCd() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -62,7 +58,6 @@ bool CMICmdCmdEnvironmentCd::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -105,7 +100,6 @@ bool CMICmdCmdEnvironmentCd::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -138,7 +132,6 @@ bool CMICmdCmdEnvironmentCd::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdEnviro.h b/tools/lldb-mi/MICmdCmdEnviro.h
index 5c663203143a0..461ccd83a8f54 100644
--- a/tools/lldb-mi/MICmdCmdEnviro.h
+++ b/tools/lldb-mi/MICmdCmdEnviro.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdEnviro.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdExec.cpp b/tools/lldb-mi/MICmdCmdExec.cpp
index 1102b952407e3..ffdf171aef08a 100644
--- a/tools/lldb-mi/MICmdCmdExec.cpp
+++ b/tools/lldb-mi/MICmdCmdExec.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdExec.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,7 +41,6 @@
#include "MIDriver.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecRun constructor.
// Type: Method.
// Args: None.
@@ -58,7 +56,6 @@ CMICmdCmdExecRun::CMICmdCmdExecRun() : m_constStrArgStart("start") {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecRun destructor.
// Type: Overrideable.
// Args: None.
@@ -68,7 +65,6 @@ CMICmdCmdExecRun::CMICmdCmdExecRun() : m_constStrArgStart("start") {
CMICmdCmdExecRun::~CMICmdCmdExecRun() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. It parses the command line
// options'
// arguments to extract values for each of those arguments.
@@ -86,7 +82,6 @@ bool CMICmdCmdExecRun::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -148,7 +143,6 @@ bool CMICmdCmdExecRun::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -182,7 +176,6 @@ bool CMICmdCmdExecRun::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -193,12 +186,8 @@ bool CMICmdCmdExecRun::Acknowledge() {
//--
CMICmdBase *CMICmdCmdExecRun::CreateSelf() { return new CMICmdCmdExecRun(); }
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecContinue constructor.
// Type: Method.
// Args: None.
@@ -214,7 +203,6 @@ CMICmdCmdExecContinue::CMICmdCmdExecContinue() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecContinue destructor.
// Type: Overrideable.
// Args: None.
@@ -224,7 +212,6 @@ CMICmdCmdExecContinue::CMICmdCmdExecContinue() {
CMICmdCmdExecContinue::~CMICmdCmdExecContinue() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -254,7 +241,6 @@ bool CMICmdCmdExecContinue::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -271,7 +257,6 @@ bool CMICmdCmdExecContinue::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -284,12 +269,8 @@ CMICmdBase *CMICmdCmdExecContinue::CreateSelf() {
return new CMICmdCmdExecContinue();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNext constructor.
// Type: Method.
// Args: None.
@@ -305,7 +286,6 @@ CMICmdCmdExecNext::CMICmdCmdExecNext() : m_constStrArgNumber("number") {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNext destructor.
// Type: Overrideable.
// Args: None.
@@ -315,7 +295,6 @@ CMICmdCmdExecNext::CMICmdCmdExecNext() : m_constStrArgNumber("number") {
CMICmdCmdExecNext::~CMICmdCmdExecNext() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -331,7 +310,6 @@ bool CMICmdCmdExecNext::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -376,7 +354,6 @@ bool CMICmdCmdExecNext::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -393,7 +370,6 @@ bool CMICmdCmdExecNext::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -404,12 +380,8 @@ bool CMICmdCmdExecNext::Acknowledge() {
//--
CMICmdBase *CMICmdCmdExecNext::CreateSelf() { return new CMICmdCmdExecNext(); }
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStep constructor.
// Type: Method.
// Args: None.
@@ -425,7 +397,6 @@ CMICmdCmdExecStep::CMICmdCmdExecStep() : m_constStrArgNumber("number") {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStep destructor.
// Type: Overrideable.
// Args: None.
@@ -435,7 +406,6 @@ CMICmdCmdExecStep::CMICmdCmdExecStep() : m_constStrArgNumber("number") {
CMICmdCmdExecStep::~CMICmdCmdExecStep() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -451,7 +421,6 @@ bool CMICmdCmdExecStep::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -497,7 +466,6 @@ bool CMICmdCmdExecStep::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -514,7 +482,6 @@ bool CMICmdCmdExecStep::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -525,12 +492,8 @@ bool CMICmdCmdExecStep::Acknowledge() {
//--
CMICmdBase *CMICmdCmdExecStep::CreateSelf() { return new CMICmdCmdExecStep(); }
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNextInstruction constructor.
// Type: Method.
// Args: None.
@@ -547,7 +510,6 @@ CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecNextInstruction destructor.
// Type: Overrideable.
// Args: None.
@@ -557,7 +519,6 @@ CMICmdCmdExecNextInstruction::CMICmdCmdExecNextInstruction()
CMICmdCmdExecNextInstruction::~CMICmdCmdExecNextInstruction() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -573,7 +534,6 @@ bool CMICmdCmdExecNextInstruction::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -619,7 +579,6 @@ bool CMICmdCmdExecNextInstruction::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -636,7 +595,6 @@ bool CMICmdCmdExecNextInstruction::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -649,12 +607,8 @@ CMICmdBase *CMICmdCmdExecNextInstruction::CreateSelf() {
return new CMICmdCmdExecNextInstruction();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStepInstruction constructor.
// Type: Method.
// Args: None.
@@ -671,7 +625,6 @@ CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecStepInstruction destructor.
// Type: Overrideable.
// Args: None.
@@ -681,7 +634,6 @@ CMICmdCmdExecStepInstruction::CMICmdCmdExecStepInstruction()
CMICmdCmdExecStepInstruction::~CMICmdCmdExecStepInstruction() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -697,7 +649,6 @@ bool CMICmdCmdExecStepInstruction::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -743,7 +694,6 @@ bool CMICmdCmdExecStepInstruction::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -760,7 +710,6 @@ bool CMICmdCmdExecStepInstruction::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -773,12 +722,8 @@ CMICmdBase *CMICmdCmdExecStepInstruction::CreateSelf() {
return new CMICmdCmdExecStepInstruction();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecFinish constructor.
// Type: Method.
// Args: None.
@@ -794,7 +739,6 @@ CMICmdCmdExecFinish::CMICmdCmdExecFinish() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecFinish destructor.
// Type: Overrideable.
// Args: None.
@@ -804,7 +748,6 @@ CMICmdCmdExecFinish::CMICmdCmdExecFinish() {
CMICmdCmdExecFinish::~CMICmdCmdExecFinish() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -817,7 +760,6 @@ CMICmdCmdExecFinish::~CMICmdCmdExecFinish() {}
bool CMICmdCmdExecFinish::ParseArgs() { return ParseValidateCmdOptions(); }
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -862,7 +804,6 @@ bool CMICmdCmdExecFinish::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -879,7 +820,6 @@ bool CMICmdCmdExecFinish::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -892,12 +832,8 @@ CMICmdBase *CMICmdCmdExecFinish::CreateSelf() {
return new CMICmdCmdExecFinish();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecInterrupt constructor.
// Type: Method.
// Args: None.
@@ -913,7 +849,6 @@ CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecInterrupt destructor.
// Type: Overrideable.
// Args: None.
@@ -923,7 +858,6 @@ CMICmdCmdExecInterrupt::CMICmdCmdExecInterrupt() {
CMICmdCmdExecInterrupt::~CMICmdCmdExecInterrupt() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -954,7 +888,6 @@ bool CMICmdCmdExecInterrupt::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -971,7 +904,6 @@ bool CMICmdCmdExecInterrupt::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -984,12 +916,8 @@ CMICmdBase *CMICmdCmdExecInterrupt::CreateSelf() {
return new CMICmdCmdExecInterrupt();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecArguments constructor.
// Type: Method.
// Args: None.
@@ -1006,7 +934,6 @@ CMICmdCmdExecArguments::CMICmdCmdExecArguments()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecArguments destructor.
// Type: Overrideable.
// Args: None.
@@ -1016,7 +943,6 @@ CMICmdCmdExecArguments::CMICmdCmdExecArguments()
CMICmdCmdExecArguments::~CMICmdCmdExecArguments() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1034,7 +960,6 @@ bool CMICmdCmdExecArguments::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1058,13 +983,13 @@ bool CMICmdCmdExecArguments::Execute() {
}
lldb::SBLaunchInfo sbLaunchInfo = sbTarget.GetLaunchInfo();
- sbLaunchInfo.SetArguments(NULL, false);
+ sbLaunchInfo.SetArguments(nullptr, false);
CMIUtilString strArg;
size_t nArgIndex = 0;
while (pArgArguments->GetExpectedOption<CMICmdArgValString, CMIUtilString>(
strArg, nArgIndex)) {
- const char *argv[2] = {strArg.c_str(), NULL};
+ const char *argv[2] = {strArg.c_str(), nullptr};
sbLaunchInfo.SetArguments(argv, true);
++nArgIndex;
}
@@ -1075,7 +1000,6 @@ bool CMICmdCmdExecArguments::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1092,7 +1016,6 @@ bool CMICmdCmdExecArguments::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1105,12 +1028,8 @@ CMICmdBase *CMICmdCmdExecArguments::CreateSelf() {
return new CMICmdCmdExecArguments();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecAbort constructor.
// Type: Method.
// Args: None.
@@ -1126,7 +1045,6 @@ CMICmdCmdExecAbort::CMICmdCmdExecAbort() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdExecAbort destructor.
// Type: Overrideable.
// Args: None.
@@ -1136,7 +1054,6 @@ CMICmdCmdExecAbort::CMICmdCmdExecAbort() {
CMICmdCmdExecAbort::~CMICmdCmdExecAbort() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1169,7 +1086,6 @@ bool CMICmdCmdExecAbort::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1186,7 +1102,6 @@ bool CMICmdCmdExecAbort::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdExec.h b/tools/lldb-mi/MICmdCmdExec.h
index 451d25e29eb1d..8533915e24f82 100644
--- a/tools/lldb-mi/MICmdCmdExec.h
+++ b/tools/lldb-mi/MICmdCmdExec.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdExec.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdFile.cpp b/tools/lldb-mi/MICmdCmdFile.cpp
index 9e3ea273b07bb..8b105eb1d58a7 100644
--- a/tools/lldb-mi/MICmdCmdFile.cpp
+++ b/tools/lldb-mi/MICmdCmdFile.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdFile.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -24,7 +23,6 @@
#include "MIUtilFileStd.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdFileExecAndSymbols constructor.
// Type: Method.
// Args: None.
@@ -42,7 +40,6 @@ CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdFileExecAndSymbols destructor.
// Type: Overrideable.
// Args: None.
@@ -52,7 +49,6 @@ CMICmdCmdFileExecAndSymbols::CMICmdCmdFileExecAndSymbols()
CMICmdCmdFileExecAndSymbols::~CMICmdCmdFileExecAndSymbols() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -74,7 +70,6 @@ bool CMICmdCmdFileExecAndSymbols::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -160,7 +155,6 @@ bool CMICmdCmdFileExecAndSymbols::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -179,7 +173,6 @@ bool CMICmdCmdFileExecAndSymbols::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -193,7 +186,6 @@ CMICmdBase *CMICmdCmdFileExecAndSymbols::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: If the MI Driver is not operating via a client i.e. Eclipse but say
// operating
// on a executable passed in as a argument to the drive then what
diff --git a/tools/lldb-mi/MICmdCmdFile.h b/tools/lldb-mi/MICmdCmdFile.h
index 0a25200cda8d5..4607f748cba5c 100644
--- a/tools/lldb-mi/MICmdCmdFile.h
+++ b/tools/lldb-mi/MICmdCmdFile.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdFile.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdGdbInfo.cpp b/tools/lldb-mi/MICmdCmdGdbInfo.cpp
index 5988066883d1a..b351353ba1e94 100644
--- a/tools/lldb-mi/MICmdCmdGdbInfo.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbInfo.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbInfo.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,7 +26,6 @@ const CMICmdCmdGdbInfo::MapPrintFnNameToPrintFn_t
{"sharedlibrary", &CMICmdCmdGdbInfo::PrintFnSharedLibrary}};
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbInfo constructor.
// Type: Method.
// Args: None.
@@ -46,7 +44,6 @@ CMICmdCmdGdbInfo::CMICmdCmdGdbInfo()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbInfo destructor.
// Type: Overrideable.
// Args: None.
@@ -56,7 +53,6 @@ CMICmdCmdGdbInfo::CMICmdCmdGdbInfo()
CMICmdCmdGdbInfo::~CMICmdCmdGdbInfo() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -72,7 +68,6 @@ bool CMICmdCmdGdbInfo::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -100,7 +95,6 @@ bool CMICmdCmdGdbInfo::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -141,7 +135,6 @@ bool CMICmdCmdGdbInfo::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -153,7 +146,6 @@ bool CMICmdCmdGdbInfo::Acknowledge() {
CMICmdBase *CMICmdCmdGdbInfo::CreateSelf() { return new CMICmdCmdGdbInfo(); }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the print function's pointer for the matching print
// request.
// Type: Method.
@@ -178,7 +170,6 @@ bool CMICmdCmdGdbInfo::GetPrintFn(const CMIUtilString &vrPrintFnName,
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the request to prepare and send back
// information
// asked for.
diff --git a/tools/lldb-mi/MICmdCmdGdbInfo.h b/tools/lldb-mi/MICmdCmdGdbInfo.h
index 43daf8e827583..8ad69c49f59c2 100644
--- a/tools/lldb-mi/MICmdCmdGdbInfo.h
+++ b/tools/lldb-mi/MICmdCmdGdbInfo.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbInfo.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdGdbSet.cpp b/tools/lldb-mi/MICmdCmdGdbSet.cpp
index b433f76784497..162e3d5a345d9 100644
--- a/tools/lldb-mi/MICmdCmdGdbSet.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbSet.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbSet.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -32,7 +31,6 @@ const CMICmdCmdGdbSet::MapGdbOptionNameToFnGdbOptionPtr_t
{"breakpoint", &CMICmdCmdGdbSet::OptionFnBreakpoint}};
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbSet constructor.
// Type: Method.
// Args: None.
@@ -51,7 +49,6 @@ CMICmdCmdGdbSet::CMICmdCmdGdbSet()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbSet destructor.
// Type: Overrideable.
// Args: None.
@@ -61,7 +58,6 @@ CMICmdCmdGdbSet::CMICmdCmdGdbSet()
CMICmdCmdGdbSet::~CMICmdCmdGdbSet() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -79,7 +75,6 @@ bool CMICmdCmdGdbSet::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command is executed in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -133,7 +128,6 @@ bool CMICmdCmdGdbSet::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute() method.
@@ -180,7 +174,6 @@ bool CMICmdCmdGdbSet::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -192,7 +185,6 @@ bool CMICmdCmdGdbSet::Acknowledge() {
CMICmdBase *CMICmdCmdGdbSet::CreateSelf() { return new CMICmdCmdGdbSet(); }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the print function's pointer for the matching print
// request.
// Type: Method.
@@ -217,7 +209,6 @@ bool CMICmdCmdGdbSet::GetOptionFn(const CMIUtilString &vrPrintFnName,
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option 'target-async' to
// prepare
// and send back information asked for.
@@ -262,7 +253,6 @@ bool CMICmdCmdGdbSet::OptionFnTargetAsync(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option
// 'print-char-array-as-string' to
// prepare and send back information asked for.
@@ -313,7 +303,6 @@ bool CMICmdCmdGdbSet::OptionFnPrint(const CMIUtilString::VecString_t &vrWords) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option 'solib-search-path' to
// prepare
// and send back information asked for.
@@ -349,7 +338,6 @@ bool CMICmdCmdGdbSet::OptionFnSolibSearchPath(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option 'output-radix' to
// prepare
// and send back information asked for.
@@ -400,7 +388,6 @@ bool CMICmdCmdGdbSet::OptionFnOutputRadix(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option 'disassembly-flavor'
// to prepare
// and send back information asked for.
@@ -433,7 +420,6 @@ bool CMICmdCmdGdbSet::OptionFnDisassemblyFlavor(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option 'breakpoint' to
// prepare
// and send back information asked for.
@@ -483,7 +469,6 @@ bool CMICmdCmdGdbSet::OptionFnBreakpoint(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB set option to prepare and send
// back the
// requested information.
diff --git a/tools/lldb-mi/MICmdCmdGdbSet.h b/tools/lldb-mi/MICmdCmdGdbSet.h
index 7cca20c3348dd..c88f9976ef659 100644
--- a/tools/lldb-mi/MICmdCmdGdbSet.h
+++ b/tools/lldb-mi/MICmdCmdGdbSet.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbSet.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdGdbShow.cpp b/tools/lldb-mi/MICmdCmdGdbShow.cpp
index 196b8271064f9..9ebd36202b7d3 100644
--- a/tools/lldb-mi/MICmdCmdGdbShow.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbShow.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbShow.cpp -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -36,7 +35,6 @@ const CMICmdCmdGdbShow::MapGdbOptionNameToFnGdbOptionPtr_t
{"breakpoint", &CMICmdCmdGdbShow::OptionFnBreakpoint}};
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbShow constructor.
// Type: Method.
// Args: None.
@@ -55,7 +53,6 @@ CMICmdCmdGdbShow::CMICmdCmdGdbShow()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbShow destructor.
// Type: Overrideable.
// Args: None.
@@ -65,7 +62,6 @@ CMICmdCmdGdbShow::CMICmdCmdGdbShow()
CMICmdCmdGdbShow::~CMICmdCmdGdbShow() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -83,7 +79,6 @@ bool CMICmdCmdGdbShow::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command is executed in this
// function.
// Type: Overridden.
@@ -135,7 +130,6 @@ bool CMICmdCmdGdbShow::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute() method.
@@ -191,7 +185,6 @@ bool CMICmdCmdGdbShow::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -203,7 +196,6 @@ bool CMICmdCmdGdbShow::Acknowledge() {
CMICmdBase *CMICmdCmdGdbShow::CreateSelf() { return new CMICmdCmdGdbShow(); }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the print function's pointer for the matching print
// request.
// Type: Method.
@@ -228,7 +220,6 @@ bool CMICmdCmdGdbShow::GetOptionFn(const CMIUtilString &vrPrintFnName,
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option 'target-async' to
// prepare
// and send back the requested information.
@@ -252,7 +243,6 @@ bool CMICmdCmdGdbShow::OptionFnTargetAsync(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option 'print' to prepare
// and send
// back the requested information.
@@ -303,7 +293,6 @@ bool CMICmdCmdGdbShow::OptionFnPrint(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option 'language' to prepare
// and send back the requested information.
// Type: Method.
@@ -329,7 +318,6 @@ bool CMICmdCmdGdbShow::OptionFnLanguage(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option 'disassembly-flavor' to prepare
// and send back the requested information.
// Type: Method.
@@ -349,7 +337,6 @@ bool CMICmdCmdGdbShow::OptionFnDisassemblyFlavor(const CMIUtilString::VecString_
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option 'breakpoint' to
// prepare
// and send back the requested information.
@@ -386,7 +373,6 @@ bool CMICmdCmdGdbShow::OptionFnBreakpoint(
}
//++
-//------------------------------------------------------------------------------------
// Details: Carry out work to complete the GDB show option to prepare and send
// back the
// requested information.
diff --git a/tools/lldb-mi/MICmdCmdGdbShow.h b/tools/lldb-mi/MICmdCmdGdbShow.h
index 51f07092843f1..9de034c617cdf 100644
--- a/tools/lldb-mi/MICmdCmdGdbShow.h
+++ b/tools/lldb-mi/MICmdCmdGdbShow.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbShow.h ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdGdbThread.cpp b/tools/lldb-mi/MICmdCmdGdbThread.cpp
index 06dc0c8410993..132cf2c68ef8b 100644
--- a/tools/lldb-mi/MICmdCmdGdbThread.cpp
+++ b/tools/lldb-mi/MICmdCmdGdbThread.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbThread.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MICmnMIValueConst.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbThread constructor.
// Type: Method.
// Args: None.
@@ -31,7 +29,6 @@ CMICmdCmdGdbThread::CMICmdCmdGdbThread() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdThread destructor.
// Type: Overrideable.
// Args: None.
@@ -41,7 +38,6 @@ CMICmdCmdGdbThread::CMICmdCmdGdbThread() {
CMICmdCmdGdbThread::~CMICmdCmdGdbThread() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -59,7 +55,6 @@ bool CMICmdCmdGdbThread::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -81,7 +76,6 @@ bool CMICmdCmdGdbThread::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdGdbThread.h b/tools/lldb-mi/MICmdCmdGdbThread.h
index 2f8b0bc0ad52c..963001f01912f 100644
--- a/tools/lldb-mi/MICmdCmdGdbThread.h
+++ b/tools/lldb-mi/MICmdCmdGdbThread.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdGdbThread.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdMiscellanous.cpp b/tools/lldb-mi/MICmdCmdMiscellanous.cpp
index 87c0ee62f6585..5aa7959995356 100644
--- a/tools/lldb-mi/MICmdCmdMiscellanous.cpp
+++ b/tools/lldb-mi/MICmdCmdMiscellanous.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdMiscellanous.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,6 @@
#include "MIDriverBase.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbExit constructor.
// Type: Method.
// Args: None.
@@ -51,7 +49,6 @@ CMICmdCmdGdbExit::CMICmdCmdGdbExit() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdGdbExit destructor.
// Type: Overrideable.
// Args: None.
@@ -61,7 +58,6 @@ CMICmdCmdGdbExit::CMICmdCmdGdbExit() {
CMICmdCmdGdbExit::~CMICmdCmdGdbExit() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -81,7 +77,6 @@ bool CMICmdCmdGdbExit::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -110,7 +105,6 @@ bool CMICmdCmdGdbExit::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -121,12 +115,8 @@ bool CMICmdCmdGdbExit::Acknowledge() {
//--
CMICmdBase *CMICmdCmdGdbExit::CreateSelf() { return new CMICmdCmdGdbExit(); }
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdListThreadGroups constructor.
// Type: Method.
// Args: None.
@@ -146,7 +136,6 @@ CMICmdCmdListThreadGroups::CMICmdCmdListThreadGroups()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdListThreadGroups destructor.
// Type: Overrideable.
// Args: None.
@@ -158,7 +147,6 @@ CMICmdCmdListThreadGroups::~CMICmdCmdListThreadGroups() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -183,7 +171,6 @@ bool CMICmdCmdListThreadGroups::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -254,7 +241,6 @@ bool CMICmdCmdListThreadGroups::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -340,7 +326,9 @@ bool CMICmdCmdListThreadGroups::Acknowledge() {
const char *pDir = sbTrgt.GetExecutable().GetDirectory();
const char *pFileName = sbTrgt.GetExecutable().GetFilename();
const CMIUtilString strFile(
- CMIUtilString::Format("%s/%s", pDir, pFileName));
+ CMIUtilString::Format("%s/%s",
+ CMIUtilString::WithNullAsEmpty(pDir),
+ CMIUtilString::WithNullAsEmpty(pFileName)));
const CMICmnMIValueConst miValueConst4(strFile);
const CMICmnMIValueResult miValueResult4("executable", miValueConst4);
miTuple.Add(miValueResult4);
@@ -386,7 +374,6 @@ bool CMICmdCmdListThreadGroups::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -399,12 +386,8 @@ CMICmdBase *CMICmdCmdListThreadGroups::CreateSelf() {
return new CMICmdCmdListThreadGroups();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdInterpreterExec constructor.
// Type: Method.
// Args: None.
@@ -422,7 +405,6 @@ CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdInterpreterExec destructor.
// Type: Overrideable.
// Args: None.
@@ -432,7 +414,6 @@ CMICmdCmdInterpreterExec::CMICmdCmdInterpreterExec()
CMICmdCmdInterpreterExec::~CMICmdCmdInterpreterExec() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -451,7 +432,6 @@ bool CMICmdCmdInterpreterExec::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -467,8 +447,7 @@ bool CMICmdCmdInterpreterExec::Execute() {
CMICMDBASE_GETOPTION(pArgCommand, String, m_constStrArgNamedCommand);
// Handle the interpreter parameter by do nothing on purpose (set to 'handled'
- // in
- // the arg definition above)
+ // in the arg definition above)
const CMIUtilString &rStrInterpreter(pArgInterpreter->GetValue());
MIunused(rStrInterpreter);
@@ -484,7 +463,6 @@ bool CMICmdCmdInterpreterExec::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -522,7 +500,6 @@ bool CMICmdCmdInterpreterExec::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -535,12 +512,8 @@ CMICmdBase *CMICmdCmdInterpreterExec::CreateSelf() {
return new CMICmdCmdInterpreterExec();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdInferiorTtySet constructor.
// Type: Method.
// Args: None.
@@ -556,7 +529,6 @@ CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdInferiorTtySet destructor.
// Type: Overrideable.
// Args: None.
@@ -566,7 +538,6 @@ CMICmdCmdInferiorTtySet::CMICmdCmdInferiorTtySet() {
CMICmdCmdInferiorTtySet::~CMICmdCmdInferiorTtySet() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -584,7 +555,6 @@ bool CMICmdCmdInferiorTtySet::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -603,7 +573,6 @@ bool CMICmdCmdInferiorTtySet::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdMiscellanous.h b/tools/lldb-mi/MICmdCmdMiscellanous.h
index af75c19b4dfd9..614638e59345a 100644
--- a/tools/lldb-mi/MICmdCmdMiscellanous.h
+++ b/tools/lldb-mi/MICmdCmdMiscellanous.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdMiscellanous.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdStack.cpp b/tools/lldb-mi/MICmdCmdStack.cpp
index b491027bf80ec..599db37417f5f 100644
--- a/tools/lldb-mi/MICmdCmdStack.cpp
+++ b/tools/lldb-mi/MICmdCmdStack.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdStack.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,7 +34,6 @@
#include <algorithm>
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackInfoDepth constructor.
// Type: Method.
// Args: None.
@@ -52,7 +50,6 @@ CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackInfoDepth destructor.
// Type: Overrideable.
// Args: None.
@@ -62,7 +59,6 @@ CMICmdCmdStackInfoDepth::CMICmdCmdStackInfoDepth()
CMICmdCmdStackInfoDepth::~CMICmdCmdStackInfoDepth() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -78,7 +74,6 @@ bool CMICmdCmdStackInfoDepth::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -115,7 +110,6 @@ bool CMICmdCmdStackInfoDepth::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -138,7 +132,6 @@ bool CMICmdCmdStackInfoDepth::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -151,12 +144,8 @@ CMICmdBase *CMICmdCmdStackInfoDepth::CreateSelf() {
return new CMICmdCmdStackInfoDepth();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackInfoFrame constructor.
// Type: Method.
// Args: None.
@@ -172,7 +161,6 @@ CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackInfoFrame destructor.
// Type: Overrideable.
// Args: None.
@@ -182,7 +170,6 @@ CMICmdCmdStackInfoFrame::CMICmdCmdStackInfoFrame() {
CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -195,7 +182,6 @@ CMICmdCmdStackInfoFrame::~CMICmdCmdStackInfoFrame() {}
bool CMICmdCmdStackInfoFrame::ParseArgs() { return ParseValidateCmdOptions(); }
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -228,7 +214,6 @@ bool CMICmdCmdStackInfoFrame::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -249,7 +234,6 @@ bool CMICmdCmdStackInfoFrame::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -262,12 +246,8 @@ CMICmdBase *CMICmdCmdStackInfoFrame::CreateSelf() {
return new CMICmdCmdStackInfoFrame();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListFrames constructor.
// Type: Method.
// Args: None.
@@ -285,7 +265,6 @@ CMICmdCmdStackListFrames::CMICmdCmdStackListFrames()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListFrames destructor.
// Type: Overrideable.
// Args: None.
@@ -297,7 +276,6 @@ CMICmdCmdStackListFrames::~CMICmdCmdStackListFrames() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -314,7 +292,6 @@ bool CMICmdCmdStackListFrames::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -383,7 +360,6 @@ bool CMICmdCmdStackListFrames::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -439,7 +415,6 @@ bool CMICmdCmdStackListFrames::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -452,12 +427,8 @@ CMICmdBase *CMICmdCmdStackListFrames::CreateSelf() {
return new CMICmdCmdStackListFrames();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListArguments constructor.
// Type: Method.
// Args: None.
@@ -476,7 +447,6 @@ CMICmdCmdStackListArguments::CMICmdCmdStackListArguments()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListArguments destructor.
// Type: Overrideable.
// Args: None.
@@ -486,7 +456,6 @@ CMICmdCmdStackListArguments::CMICmdCmdStackListArguments()
CMICmdCmdStackListArguments::~CMICmdCmdStackListArguments() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -505,7 +474,6 @@ bool CMICmdCmdStackListArguments::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -599,7 +567,6 @@ bool CMICmdCmdStackListArguments::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -633,7 +600,6 @@ bool CMICmdCmdStackListArguments::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -646,12 +612,8 @@ CMICmdBase *CMICmdCmdStackListArguments::CreateSelf() {
return new CMICmdCmdStackListArguments();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListLocals constructor.
// Type: Method.
// Args: None.
@@ -669,7 +631,6 @@ CMICmdCmdStackListLocals::CMICmdCmdStackListLocals()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListLocals destructor.
// Type: Overrideable.
// Args: None.
@@ -679,7 +640,6 @@ CMICmdCmdStackListLocals::CMICmdCmdStackListLocals()
CMICmdCmdStackListLocals::~CMICmdCmdStackListLocals() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -696,7 +656,6 @@ bool CMICmdCmdStackListLocals::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -771,7 +730,6 @@ bool CMICmdCmdStackListLocals::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -804,7 +762,6 @@ bool CMICmdCmdStackListLocals::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -817,12 +774,8 @@ CMICmdBase *CMICmdCmdStackListLocals::CreateSelf() {
return new CMICmdCmdStackListLocals();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListVariables constructor.
// Type: Method.
// Args: None.
@@ -840,7 +793,6 @@ CMICmdCmdStackListVariables::CMICmdCmdStackListVariables()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackListVariables destructor.
// Type: Overrideable.
// Args: None.
@@ -850,7 +802,6 @@ CMICmdCmdStackListVariables::CMICmdCmdStackListVariables()
CMICmdCmdStackListVariables::~CMICmdCmdStackListVariables() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -867,7 +818,6 @@ bool CMICmdCmdStackListVariables::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -943,7 +893,6 @@ bool CMICmdCmdStackListVariables::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -976,7 +925,6 @@ bool CMICmdCmdStackListVariables::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -989,12 +937,8 @@ CMICmdBase *CMICmdCmdStackListVariables::CreateSelf() {
return new CMICmdCmdStackListVariables();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackSelectFrame constructor.
// Type: Method.
// Args: None.
@@ -1011,7 +955,6 @@ CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdStackSelectFrame destructor.
// Type: Overrideable.
// Args: None.
@@ -1021,7 +964,6 @@ CMICmdCmdStackSelectFrame::CMICmdCmdStackSelectFrame()
CMICmdCmdStackSelectFrame::~CMICmdCmdStackSelectFrame() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1037,7 +979,6 @@ bool CMICmdCmdStackSelectFrame::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1067,7 +1008,6 @@ bool CMICmdCmdStackSelectFrame::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1100,7 +1040,6 @@ bool CMICmdCmdStackSelectFrame::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdStack.h b/tools/lldb-mi/MICmdCmdStack.h
index 481186f5ddc5c..04aeb5db03400 100644
--- a/tools/lldb-mi/MICmdCmdStack.h
+++ b/tools/lldb-mi/MICmdCmdStack.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdStack.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdSupportInfo.cpp b/tools/lldb-mi/MICmdCmdSupportInfo.cpp
index e36d398b0a056..e17f70a90472a 100644
--- a/tools/lldb-mi/MICmdCmdSupportInfo.cpp
+++ b/tools/lldb-mi/MICmdCmdSupportInfo.cpp
@@ -1,9 +1,8 @@
-//===-- MICmdCmdSupportListInfo.cpp -----------------------------*- C++ -*-===//
+//===-- MICmdCmdSupportInfo.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "MICmnMIValueTuple.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSupportInfoMiCmdQuery constructor.
// Type: Method.
// Args: None.
@@ -35,7 +33,6 @@ CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSupportInfoMiCmdQuery destructor.
// Type: Overrideable.
// Args: None.
@@ -45,7 +42,6 @@ CMICmdCmdSupportInfoMiCmdQuery::CMICmdCmdSupportInfoMiCmdQuery()
CMICmdCmdSupportInfoMiCmdQuery::~CMICmdCmdSupportInfoMiCmdQuery() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -61,7 +57,6 @@ bool CMICmdCmdSupportInfoMiCmdQuery::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -86,7 +81,6 @@ bool CMICmdCmdSupportInfoMiCmdQuery::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -110,7 +104,6 @@ bool CMICmdCmdSupportInfoMiCmdQuery::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdSupportInfo.h b/tools/lldb-mi/MICmdCmdSupportInfo.h
index 7b503b1ee1ae6..ba3e4a6c66a54 100644
--- a/tools/lldb-mi/MICmdCmdSupportInfo.h
+++ b/tools/lldb-mi/MICmdCmdSupportInfo.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdSupportInfo.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdSupportList.cpp b/tools/lldb-mi/MICmdCmdSupportList.cpp
index c3a9c9ad257a9..e457e0101f4e2 100644
--- a/tools/lldb-mi/MICmdCmdSupportList.cpp
+++ b/tools/lldb-mi/MICmdCmdSupportList.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdSupportList.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,6 @@
#include "MICmnMIValueList.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSupportListFeatures constructor.
// Type: Method.
// Args: None.
@@ -32,7 +30,6 @@ CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSupportListFeatures destructor.
// Type: Overrideable.
// Args: None.
@@ -42,7 +39,6 @@ CMICmdCmdSupportListFeatures::CMICmdCmdSupportListFeatures() {
CMICmdCmdSupportListFeatures::~CMICmdCmdSupportListFeatures() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -60,7 +56,6 @@ bool CMICmdCmdSupportListFeatures::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -88,7 +83,6 @@ bool CMICmdCmdSupportListFeatures::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdSupportList.h b/tools/lldb-mi/MICmdCmdSupportList.h
index a9c27960bb9de..9e8a64bc11a19 100644
--- a/tools/lldb-mi/MICmdCmdSupportList.h
+++ b/tools/lldb-mi/MICmdCmdSupportList.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdSupportList.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdSymbol.cpp b/tools/lldb-mi/MICmdCmdSymbol.cpp
index 008e98d02e74f..d57d1b008e59e 100644
--- a/tools/lldb-mi/MICmdCmdSymbol.cpp
+++ b/tools/lldb-mi/MICmdCmdSymbol.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdSymbol.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -42,7 +41,6 @@ CreateMITuplePCLine(const uint32_t addr, const uint32_t line_number) {
using namespace lldb; // For operator==(const SBAddress &, const SBAddress &).
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSymbolListLines constructor.
// Type: Method.
// Args: None.
@@ -59,7 +57,6 @@ CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdSymbolListLines destructor.
// Type: Overrideable.
// Args: None.
@@ -69,7 +66,6 @@ CMICmdCmdSymbolListLines::CMICmdCmdSymbolListLines()
CMICmdCmdSymbolListLines::~CMICmdCmdSymbolListLines() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -85,7 +81,6 @@ bool CMICmdCmdSymbolListLines::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -150,7 +145,6 @@ bool CMICmdCmdSymbolListLines::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -170,7 +164,6 @@ bool CMICmdCmdSymbolListLines::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdSymbol.h b/tools/lldb-mi/MICmdCmdSymbol.h
index bd545345cf1b0..839b0153a772a 100644
--- a/tools/lldb-mi/MICmdCmdSymbol.h
+++ b/tools/lldb-mi/MICmdCmdSymbol.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdSymbol.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdTarget.cpp b/tools/lldb-mi/MICmdCmdTarget.cpp
index 0666fc4c60ec2..18ce038b16858 100644
--- a/tools/lldb-mi/MICmdCmdTarget.cpp
+++ b/tools/lldb-mi/MICmdCmdTarget.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdTarget.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -26,7 +25,6 @@
#include "MICmnMIValueConst.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetSelect constructor.
// Type: Method.
// Args: None.
@@ -44,7 +42,6 @@ CMICmdCmdTargetSelect::CMICmdCmdTargetSelect()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetSelect destructor.
// Type: Overrideable.
// Args: None.
@@ -54,7 +51,6 @@ CMICmdCmdTargetSelect::CMICmdCmdTargetSelect()
CMICmdCmdTargetSelect::~CMICmdCmdTargetSelect() = default;
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -72,7 +68,6 @@ bool CMICmdCmdTargetSelect::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -152,7 +147,6 @@ bool CMICmdCmdTargetSelect::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -188,7 +182,6 @@ bool CMICmdCmdTargetSelect::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -202,7 +195,6 @@ CMICmdBase *CMICmdCmdTargetSelect::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetAttach constructor.
// Type: Method.
// Args: None.
@@ -220,7 +212,6 @@ CMICmdCmdTargetAttach::CMICmdCmdTargetAttach()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetAttach destructor.
// Type: Overrideable.
// Args: None.
@@ -230,7 +221,6 @@ CMICmdCmdTargetAttach::CMICmdCmdTargetAttach()
CMICmdCmdTargetAttach::~CMICmdCmdTargetAttach() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -251,7 +241,6 @@ bool CMICmdCmdTargetAttach::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -276,7 +265,7 @@ bool CMICmdCmdTargetAttach::Execute() {
// If the current target is invalid, create one
lldb::SBTarget target = rSessionInfo.GetTarget();
if (!target.IsValid()) {
- target = rSessionInfo.GetDebugger().CreateTarget(NULL);
+ target = rSessionInfo.GetDebugger().CreateTarget(nullptr);
if (!target.IsValid()) {
SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_TARGET_CURRENT),
m_cmdData.strMiCmd.c_str()));
@@ -313,7 +302,6 @@ bool CMICmdCmdTargetAttach::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -349,7 +337,6 @@ bool CMICmdCmdTargetAttach::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -363,7 +350,6 @@ CMICmdBase *CMICmdCmdTargetAttach::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetDetach constructor.
// Type: Method.
// Args: None.
@@ -379,7 +365,6 @@ CMICmdCmdTargetDetach::CMICmdCmdTargetDetach() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTargetDetach destructor.
// Type: Overrideable.
// Args: None.
@@ -389,7 +374,6 @@ CMICmdCmdTargetDetach::CMICmdCmdTargetDetach() {
CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -402,7 +386,6 @@ CMICmdCmdTargetDetach::~CMICmdCmdTargetDetach() {}
bool CMICmdCmdTargetDetach::ParseArgs() { return MIstatus::success; }
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -434,7 +417,6 @@ bool CMICmdCmdTargetDetach::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -452,7 +434,6 @@ bool CMICmdCmdTargetDetach::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdTarget.h b/tools/lldb-mi/MICmdCmdTarget.h
index f0cad93bdbafa..5cb140fd68b94 100644
--- a/tools/lldb-mi/MICmdCmdTarget.h
+++ b/tools/lldb-mi/MICmdCmdTarget.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdTarget.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdThread.cpp b/tools/lldb-mi/MICmdCmdThread.cpp
index 32bdca5265bd2..e0c74f925a9b2 100644
--- a/tools/lldb-mi/MICmdCmdThread.cpp
+++ b/tools/lldb-mi/MICmdCmdThread.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdThread.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,6 @@
#include "MICmnMIValueConst.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdThreadInfo constructor.
// Type: Method.
// Args: None.
@@ -40,7 +38,6 @@ CMICmdCmdThreadInfo::CMICmdCmdThreadInfo()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdThreadInfo destructor.
// Type: Overrideable.
// Args: None.
@@ -50,7 +47,6 @@ CMICmdCmdThreadInfo::CMICmdCmdThreadInfo()
CMICmdCmdThreadInfo::~CMICmdCmdThreadInfo() { m_vecMIValueTuple.clear(); }
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -67,7 +63,6 @@ bool CMICmdCmdThreadInfo::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -136,7 +131,6 @@ bool CMICmdCmdThreadInfo::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -204,7 +198,6 @@ bool CMICmdCmdThreadInfo::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdThread.h b/tools/lldb-mi/MICmdCmdThread.h
index 7635e9fd9652c..413e293447ac6 100644
--- a/tools/lldb-mi/MICmdCmdThread.h
+++ b/tools/lldb-mi/MICmdCmdThread.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdThread.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdTrace.cpp b/tools/lldb-mi/MICmdCmdTrace.cpp
index c98ede225fafc..1daa18010c97b 100644
--- a/tools/lldb-mi/MICmdCmdTrace.cpp
+++ b/tools/lldb-mi/MICmdCmdTrace.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdTrace.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MICmnMIValueConst.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTraceStatus constructor.
// Type: Method.
// Args: None.
@@ -31,7 +29,6 @@ CMICmdCmdTraceStatus::CMICmdCmdTraceStatus() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdTraceStatus destructor.
// Type: Overrideable.
// Args: None.
@@ -41,7 +38,6 @@ CMICmdCmdTraceStatus::CMICmdCmdTraceStatus() {
CMICmdCmdTraceStatus::~CMICmdCmdTraceStatus() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -58,7 +54,6 @@ bool CMICmdCmdTraceStatus::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -80,7 +75,6 @@ bool CMICmdCmdTraceStatus::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdTrace.h b/tools/lldb-mi/MICmdCmdTrace.h
index b6cb3aea5d324..8796de55b9584 100644
--- a/tools/lldb-mi/MICmdCmdTrace.h
+++ b/tools/lldb-mi/MICmdCmdTrace.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdTrace.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCmdVar.cpp b/tools/lldb-mi/MICmdCmdVar.cpp
index 85f14ec29b939..3063b1b464dc6 100644
--- a/tools/lldb-mi/MICmdCmdVar.cpp
+++ b/tools/lldb-mi/MICmdCmdVar.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCmdVar.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -41,7 +40,6 @@
#include <algorithm>
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarCreate constructor.
// Type: Method.
// Args: None.
@@ -61,7 +59,6 @@ CMICmdCmdVarCreate::CMICmdCmdVarCreate()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarCreate destructor.
// Type: Overrideable.
// Args: None.
@@ -71,7 +68,6 @@ CMICmdCmdVarCreate::CMICmdCmdVarCreate()
CMICmdCmdVarCreate::~CMICmdCmdVarCreate() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -90,7 +86,6 @@ bool CMICmdCmdVarCreate::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -212,7 +207,6 @@ bool CMICmdCmdVarCreate::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -265,7 +259,6 @@ bool CMICmdCmdVarCreate::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -279,7 +272,6 @@ CMICmdBase *CMICmdCmdVarCreate::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Complete SBValue object and its children to get
// SBValue::GetValueDidChange
// work.
@@ -305,12 +297,8 @@ void CMICmdCmdVarCreate::CompleteSBValue(lldb::SBValue &vrwValue) {
}
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarUpdate constructor.
// Type: Method.
// Args: None.
@@ -328,7 +316,6 @@ CMICmdCmdVarUpdate::CMICmdCmdVarUpdate()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarUpdate destructor.
// Type: Overrideable.
// Args: None.
@@ -338,7 +325,6 @@ CMICmdCmdVarUpdate::CMICmdCmdVarUpdate()
CMICmdCmdVarUpdate::~CMICmdCmdVarUpdate() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -356,7 +342,6 @@ bool CMICmdCmdVarUpdate::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -409,7 +394,6 @@ bool CMICmdCmdVarUpdate::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -442,7 +426,6 @@ bool CMICmdCmdVarUpdate::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -456,7 +439,6 @@ CMICmdBase *CMICmdCmdVarUpdate::CreateSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Form the MI response for multiple variables.
// Type: Method.
// Args: vrStrVarName - (R) Session var object's name.
@@ -492,7 +474,6 @@ void CMICmdCmdVarUpdate::MIFormResponse(const CMIUtilString &vrStrVarName,
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if the var object was changed.
// Type: Method.
// Args: vrVarObj - (R) Session var object to examine.
@@ -528,12 +509,8 @@ bool CMICmdCmdVarUpdate::ExamineSBValueForChange(lldb::SBValue &vrwValue,
return MIstatus::success;
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarDelete constructor.
// Type: Method.
// Args: None.
@@ -549,7 +526,6 @@ CMICmdCmdVarDelete::CMICmdCmdVarDelete() : m_constStrArgName("name") {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -565,7 +541,6 @@ bool CMICmdCmdVarDelete::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarDelete destructor.
// Type: Overrideable.
// Args: None.
@@ -575,7 +550,6 @@ bool CMICmdCmdVarDelete::ParseArgs() {
CMICmdCmdVarDelete::~CMICmdCmdVarDelete() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -596,7 +570,6 @@ bool CMICmdCmdVarDelete::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -615,7 +588,6 @@ bool CMICmdCmdVarDelete::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -628,12 +600,8 @@ CMICmdBase *CMICmdCmdVarDelete::CreateSelf() {
return new CMICmdCmdVarDelete();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarAssign constructor.
// Type: Method.
// Args: None.
@@ -651,7 +619,6 @@ CMICmdCmdVarAssign::CMICmdCmdVarAssign()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarAssign destructor.
// Type: Overrideable.
// Args: None.
@@ -661,7 +628,6 @@ CMICmdCmdVarAssign::CMICmdCmdVarAssign()
CMICmdCmdVarAssign::~CMICmdCmdVarAssign() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -678,7 +644,6 @@ bool CMICmdCmdVarAssign::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -716,7 +681,6 @@ bool CMICmdCmdVarAssign::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -752,7 +716,6 @@ bool CMICmdCmdVarAssign::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -765,12 +728,8 @@ CMICmdBase *CMICmdCmdVarAssign::CreateSelf() {
return new CMICmdCmdVarAssign();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarSetFormat constructor.
// Type: Method.
// Args: None.
@@ -787,7 +746,6 @@ CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarSetFormat destructor.
// Type: Overrideable.
// Args: None.
@@ -797,7 +755,6 @@ CMICmdCmdVarSetFormat::CMICmdCmdVarSetFormat()
CMICmdCmdVarSetFormat::~CMICmdCmdVarSetFormat() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -814,7 +771,6 @@ bool CMICmdCmdVarSetFormat::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -855,7 +811,6 @@ bool CMICmdCmdVarSetFormat::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -898,7 +853,6 @@ bool CMICmdCmdVarSetFormat::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -911,12 +865,8 @@ CMICmdBase *CMICmdCmdVarSetFormat::CreateSelf() {
return new CMICmdCmdVarSetFormat();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarListChildren constructor.
// Type: Method.
// Args: None.
@@ -935,7 +885,6 @@ CMICmdCmdVarListChildren::CMICmdCmdVarListChildren()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarListChildren destructor.
// Type: Overrideable.
// Args: None.
@@ -945,7 +894,6 @@ CMICmdCmdVarListChildren::CMICmdCmdVarListChildren()
CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -965,7 +913,6 @@ bool CMICmdCmdVarListChildren::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1078,7 +1025,6 @@ bool CMICmdCmdVarListChildren::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1120,7 +1066,6 @@ bool CMICmdCmdVarListChildren::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1133,12 +1078,8 @@ CMICmdBase *CMICmdCmdVarListChildren::CreateSelf() {
return new CMICmdCmdVarListChildren();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarEvaluateExpression constructor.
// Type: Method.
// Args: None.
@@ -1156,7 +1097,6 @@ CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarEvaluateExpression destructor.
// Type: Overrideable.
// Args: None.
@@ -1166,7 +1106,6 @@ CMICmdCmdVarEvaluateExpression::CMICmdCmdVarEvaluateExpression()
CMICmdCmdVarEvaluateExpression::~CMICmdCmdVarEvaluateExpression() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1185,7 +1124,6 @@ bool CMICmdCmdVarEvaluateExpression::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1220,7 +1158,6 @@ bool CMICmdCmdVarEvaluateExpression::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1253,7 +1190,6 @@ bool CMICmdCmdVarEvaluateExpression::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1266,12 +1202,8 @@ CMICmdBase *CMICmdCmdVarEvaluateExpression::CreateSelf() {
return new CMICmdCmdVarEvaluateExpression();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarInfoPathExpression constructor.
// Type: Method.
// Args: None.
@@ -1288,7 +1220,6 @@ CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarInfoPathExpression destructor.
// Type: Overrideable.
// Args: None.
@@ -1298,7 +1229,6 @@ CMICmdCmdVarInfoPathExpression::CMICmdCmdVarInfoPathExpression()
CMICmdCmdVarInfoPathExpression::~CMICmdCmdVarInfoPathExpression() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1314,7 +1244,6 @@ bool CMICmdCmdVarInfoPathExpression::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1385,7 +1314,6 @@ bool CMICmdCmdVarInfoPathExpression::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1417,7 +1345,6 @@ bool CMICmdCmdVarInfoPathExpression::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
@@ -1430,12 +1357,8 @@ CMICmdBase *CMICmdCmdVarInfoPathExpression::CreateSelf() {
return new CMICmdCmdVarInfoPathExpression();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarShowAttributes constructor.
// Type: Method.
// Args: None.
@@ -1452,7 +1375,6 @@ CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdCmdVarShowAttributes destructor.
// Type: Overrideable.
// Args: None.
@@ -1462,7 +1384,6 @@ CMICmdCmdVarShowAttributes::CMICmdCmdVarShowAttributes()
CMICmdCmdVarShowAttributes::~CMICmdCmdVarShowAttributes() {}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The parses the command line
// options
// arguments to extract values for each of those arguments.
@@ -1478,7 +1399,6 @@ bool CMICmdCmdVarShowAttributes::ParseArgs() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command does work in this
// function.
// The command is likely to communicate with the LLDB SBDebugger in
@@ -1505,7 +1425,6 @@ bool CMICmdCmdVarShowAttributes::Execute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
// for the work carried out in the Execute().
@@ -1528,7 +1447,6 @@ bool CMICmdCmdVarShowAttributes::Acknowledge() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdFactory when registering *this command. The
// factory
// calls this function to create an instance of *this command.
diff --git a/tools/lldb-mi/MICmdCmdVar.h b/tools/lldb-mi/MICmdCmdVar.h
index 7bf583bfd3641..cdd036688ca33 100644
--- a/tools/lldb-mi/MICmdCmdVar.h
+++ b/tools/lldb-mi/MICmdCmdVar.h
@@ -1,9 +1,8 @@
//===-- MICmdCmdVar.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdCommands.cpp b/tools/lldb-mi/MICmdCommands.cpp
index 42983c428879f..cffc50a9ba6dd 100644
--- a/tools/lldb-mi/MICmdCommands.cpp
+++ b/tools/lldb-mi/MICmdCommands.cpp
@@ -1,9 +1,8 @@
//===-- MICmdCommands.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -46,7 +45,6 @@ template <typename T> static bool Register();
}
//++
-//------------------------------------------------------------------------------------
// Details: Command to command factory registration function.
// Type: Template function.
// Args: typename T - A command type class.
@@ -62,7 +60,6 @@ template <typename T> static bool MICmnCommands::Register() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Register commands with MI command factory
// Type: Function.
// Args: None.
diff --git a/tools/lldb-mi/MICmdCommands.h b/tools/lldb-mi/MICmdCommands.h
index c3f752857b841..f2e3bfde76038 100644
--- a/tools/lldb-mi/MICmdCommands.h
+++ b/tools/lldb-mi/MICmdCommands.h
@@ -1,9 +1,8 @@
//===-- MICmdCommands.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdData.cpp b/tools/lldb-mi/MICmdData.cpp
index faafaf52483da..6d0b679b85717 100644
--- a/tools/lldb-mi/MICmdData.cpp
+++ b/tools/lldb-mi/MICmdData.cpp
@@ -1,9 +1,8 @@
//===-- MICmdData.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdData.h b/tools/lldb-mi/MICmdData.h
index b0d52b5bf8097..3e46b54d835dd 100644
--- a/tools/lldb-mi/MICmdData.h
+++ b/tools/lldb-mi/MICmdData.h
@@ -1,9 +1,8 @@
//===-- MICmdData.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdFactory.cpp b/tools/lldb-mi/MICmdFactory.cpp
index ad4283e50215a..30995835c6881 100644
--- a/tools/lldb-mi/MICmdFactory.cpp
+++ b/tools/lldb-mi/MICmdFactory.cpp
@@ -1,9 +1,8 @@
//===-- MICmdFactory.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdFactory constructor.
// Type: Method.
// Args: None.
@@ -25,7 +23,6 @@
CMICmdFactory::CMICmdFactory() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdFactory destructor.
// Type: Overridable.
// Args: None.
@@ -35,7 +32,6 @@ CMICmdFactory::CMICmdFactory() {}
CMICmdFactory::~CMICmdFactory() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Command factory.
// Type: Method.
// Args: None.
@@ -57,7 +53,6 @@ bool CMICmdFactory::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Command Factory.
// Type: Method.
// Args: None.
@@ -80,7 +75,6 @@ bool CMICmdFactory::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Register a command's creator function with the command identifier
// the MI
// command name i.e. 'file-exec-and-symbols'.
@@ -117,7 +111,6 @@ bool CMICmdFactory::CmdRegister(const CMIUtilString &vMiCmd,
}
//++
-//------------------------------------------------------------------------------------
// Details: Check a command is already registered.
// Type: Method.
// Args: vMiCmd - (R) Command's name, the MI command.
@@ -132,7 +125,6 @@ bool CMICmdFactory::HaveAlready(const CMIUtilString &vMiCmd) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check a command's name is valid:
// - name is not empty
// - name does not have spaces
@@ -158,7 +150,6 @@ bool CMICmdFactory::IsValid(const CMIUtilString &vMiCmd) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check a command is already registered.
// Type: Method.
// Args: vMiCmd - (R) Command's name, the MI command.
@@ -171,7 +162,6 @@ bool CMICmdFactory::CmdExist(const CMIUtilString &vMiCmd) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Create a command given the specified MI command name. The command
// data object
// contains the options for the command.
diff --git a/tools/lldb-mi/MICmdFactory.h b/tools/lldb-mi/MICmdFactory.h
index 6d8a759ec67db..19987c281ad0f 100644
--- a/tools/lldb-mi/MICmdFactory.h
+++ b/tools/lldb-mi/MICmdFactory.h
@@ -1,9 +1,8 @@
//===-- MICmdFactory.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdInterpreter.cpp b/tools/lldb-mi/MICmdInterpreter.cpp
index 8dd99ed5e670d..9e37ac2d61089 100644
--- a/tools/lldb-mi/MICmdInterpreter.cpp
+++ b/tools/lldb-mi/MICmdInterpreter.cpp
@@ -1,9 +1,8 @@
//===-- MICmdInterpreter.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmdFactory.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdInterpreter constructor.
// Type: Method.
// Args: None.
@@ -23,7 +21,6 @@ CMICmdInterpreter::CMICmdInterpreter()
: m_rCmdFactory(CMICmdFactory::Instance()) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdInterpreter destructor.
// Type: Overridable.
// Args: None.
@@ -33,7 +30,6 @@ CMICmdInterpreter::CMICmdInterpreter()
CMICmdInterpreter::~CMICmdInterpreter() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Command Interpreter.
// Type: Method.
// Args: None.
@@ -53,7 +49,6 @@ bool CMICmdInterpreter::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Command Interpreter.
// Type: Method.
// Args: None.
@@ -74,7 +69,6 @@ bool CMICmdInterpreter::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Establish whether the text data is an MI format type command.
// Type: Method.
// Args: vTextLine - (R) Text data to interpret.
@@ -123,7 +117,6 @@ bool CMICmdInterpreter::ValidateIsMi(const CMIUtilString &vTextLine,
}
//++
-//------------------------------------------------------------------------------------
// Details: Establish whether the command name entered on the stdin stream is
// recognised by
// the MI driver.
@@ -138,7 +131,6 @@ bool CMICmdInterpreter::HasCmdFactoryGotMiCmd(const SMICmdData &vCmd) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Does the command entered match the criteria for a MI command format.
// The format to validate against is 'nn-' where there can be 1 to n
// digits.
@@ -175,7 +167,6 @@ bool CMICmdInterpreter::MiHasCmdTokenEndingHyphen(
}
//++
-//------------------------------------------------------------------------------------
// Details: Does the command entered match the criteria for a MI command format.
// The format to validate against is 'nnA' where there can be 1 to n
// digits.
@@ -211,7 +202,6 @@ bool CMICmdInterpreter::MiHasCmdTokenEndingAlpha(
}
//++
-//------------------------------------------------------------------------------------
// Details: Does the command entered match the criteria for a MI command format.
// Is the command token present before the hyphen?
// Type: Method.
@@ -225,7 +215,6 @@ bool CMICmdInterpreter::MiHasCmdTokenPresent(const CMIUtilString &vTextLine) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Does the command name entered match the criteria for a MI command
// format.
// Is a recognised command present? The command name is entered into
@@ -288,7 +277,6 @@ bool CMICmdInterpreter::MiHasCmd(const CMIUtilString &vTextLine) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the just entered new command from stdin. It contains the
// command
// name, number and any options.
diff --git a/tools/lldb-mi/MICmdInterpreter.h b/tools/lldb-mi/MICmdInterpreter.h
index 948e7515d5268..100d309ac772f 100644
--- a/tools/lldb-mi/MICmdInterpreter.h
+++ b/tools/lldb-mi/MICmdInterpreter.h
@@ -1,9 +1,8 @@
//===-- MICmdInterpreter.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdInvoker.cpp b/tools/lldb-mi/MICmdInvoker.cpp
index ea7116dd688b5..f4150a20ccd90 100644
--- a/tools/lldb-mi/MICmdInvoker.cpp
+++ b/tools/lldb-mi/MICmdInvoker.cpp
@@ -1,9 +1,8 @@
//===-- MICmdInvoker.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,6 @@
#include "MIDriver.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdInvoker constructor.
// Type: Method.
// Args: None.
@@ -26,7 +24,6 @@
CMICmdInvoker::CMICmdInvoker() : m_rStreamOut(CMICmnStreamStdout::Instance()) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdInvoker destructor.
// Type: Overridable.
// Args: None.
@@ -36,7 +33,6 @@ CMICmdInvoker::CMICmdInvoker() : m_rStreamOut(CMICmnStreamStdout::Instance()) {}
CMICmdInvoker::~CMICmdInvoker() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Command Invoker.
// Type: Method.
// Args: None.
@@ -56,7 +52,6 @@ bool CMICmdInvoker::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Stdin stream.
// Type: Method.
// Args: None.
@@ -79,7 +74,6 @@ bool CMICmdInvoker::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Empty the map of invoked commands doing work. Command objects are
// deleted too.
// Type: Method.
@@ -105,7 +99,6 @@ void CMICmdInvoker::CmdDeleteAll() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove from the map of invoked commands doing work a command that
// has finished
// its work. The command object is deleted too.
@@ -139,7 +132,6 @@ bool CMICmdInvoker::CmdDelete(const MIuint vId,
}
//++
-//------------------------------------------------------------------------------------
// Details: Add to the map of invoked commands doing work a command that is
// about to
// start to do work.
@@ -166,7 +158,6 @@ bool CMICmdInvoker::CmdAdd(const CMICmdBase &vCmd) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Having previously had the potential command validated and found
// valid now
// get the command executed.
@@ -213,7 +204,6 @@ bool CMICmdInvoker::CmdExecute(CMICmdBase &vCmd) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Called when a command has finished its Execution() work either
// synchronously
// because the command executed was the type a non event type or
@@ -270,7 +260,6 @@ bool CMICmdInvoker::CmdExecuteFinished(CMICmdBase &vCmd) {
}
//++
-//------------------------------------------------------------------------------------
// Details: If the MI Driver is not operating via a client i.e. Eclipse check
// the command
// on failure suggests the application exits. A command can be such
@@ -291,7 +280,6 @@ void CMICmdInvoker::CmdCauseAppExit(const CMICmdBase &vCmd) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Write to stdout and the Log file the command's MI formatted result.
// Type: vCmdData - (R) A command's information.
// Return: MIstatus::success - Functionality succeeded.
@@ -313,7 +301,6 @@ bool CMICmdInvoker::CmdStdout(const SMICmdData &vCmdData) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Required by the CMICmdMgr::ICmdDeleteCallback. *this object is
// registered
// with the Command Manager to receive callbacks when a command is
diff --git a/tools/lldb-mi/MICmdInvoker.h b/tools/lldb-mi/MICmdInvoker.h
index 40c4625f7ab1d..5db8d36ad26e2 100644
--- a/tools/lldb-mi/MICmdInvoker.h
+++ b/tools/lldb-mi/MICmdInvoker.h
@@ -1,9 +1,8 @@
//===-- MICmdInvoker.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdMgr.cpp b/tools/lldb-mi/MICmdMgr.cpp
index 8daa38c1af234..453ffedbd33df 100644
--- a/tools/lldb-mi/MICmdMgr.cpp
+++ b/tools/lldb-mi/MICmdMgr.cpp
@@ -1,9 +1,8 @@
//===-- MICmdMgr.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,7 +18,6 @@
#include "MIUtilSingletonHelper.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdMgr constructor.
// Type: Method.
// Args: None.
@@ -32,7 +30,6 @@ CMICmdMgr::CMICmdMgr()
m_invoker(CMICmdInvoker::Instance()) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmdMgr destructor.
// Type: Overridable.
// Args: None.
@@ -42,7 +39,6 @@ CMICmdMgr::CMICmdMgr()
CMICmdMgr::~CMICmdMgr() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Command Manager.
// Type: Method.
// Args: None.
@@ -91,7 +87,6 @@ bool CMICmdMgr::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Command Manager.
// Type: Method.
// Args: None.
@@ -148,7 +143,6 @@ bool CMICmdMgr::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Establish whether the text data is an MI format type command.
// Type: Method.
// Args: vTextLine - (R) Text data to interpret.
@@ -168,7 +162,6 @@ bool CMICmdMgr::CmdInterpret(const CMIUtilString &vTextLine, bool &vwbYesValid,
}
//++
-//------------------------------------------------------------------------------------
// Details: Having previously had the potential command validated and found
// valid now
// get the command executed.
@@ -210,7 +203,6 @@ bool CMICmdMgr::CmdExecute(const SMICmdData &vCmdData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Iterate all interested clients and tell them a command is being
// deleted.
// Type: Method.
@@ -229,7 +221,6 @@ bool CMICmdMgr::CmdDelete(SMICmdData vCmdData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Register an object to be called when a command object is deleted.
// Type: Method.
// Args: vObject - (R) A new interested client.
@@ -243,7 +234,6 @@ bool CMICmdMgr::CmdRegisterForDeleteNotification(
}
//++
-//------------------------------------------------------------------------------------
// Details: Unregister an object from being called when a command object is
// deleted.
// Type: Method.
diff --git a/tools/lldb-mi/MICmdMgr.h b/tools/lldb-mi/MICmdMgr.h
index 1e58b75329451..307ef897c58d1 100644
--- a/tools/lldb-mi/MICmdMgr.h
+++ b/tools/lldb-mi/MICmdMgr.h
@@ -1,9 +1,8 @@
//===-- MICmdMgr.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
index 1d21a1baaaf1c..d6146b8d276da 100644
--- a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
+++ b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.cpp
@@ -1,9 +1,8 @@
//===-- MICmdMgrSetCmdDeleteCallback.cpp ------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -13,7 +12,6 @@
namespace CMICmdMgrSetCmdDeleteCallback {
//++
-//------------------------------------------------------------------------------------
// Details: CSetClients constructor.
// Type: Method.
// Args: None.
@@ -23,7 +21,6 @@ namespace CMICmdMgrSetCmdDeleteCallback {
CSetClients::CSetClients() : m_bClientUnregistered(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CSetClients destructor.
// Type: Method.
// Args: None.
@@ -33,7 +30,6 @@ CSetClients::CSetClients() : m_bClientUnregistered(false) {}
CSetClients::~CSetClients() {}
//++
-//------------------------------------------------------------------------------------
// Details: Register an object to be called when a command object is deleted.
// Type: Method.
// Args: vObject - (R) A new interested client.
@@ -48,7 +44,6 @@ bool CSetClients::Register(ICallback &vObject) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Unregister an object from being called when a command object is
// deleted.
// Type: Method.
@@ -65,7 +60,6 @@ bool CSetClients::Unregister(ICallback &vObject) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Iterate all interested clients and tell them a command is being
// deleted.
// Type: Method.
diff --git a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h
index 0363831b76582..30df5e9cd4249 100644
--- a/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h
+++ b/tools/lldb-mi/MICmdMgrSetCmdDeleteCallback.h
@@ -1,9 +1,8 @@
//===-- MICmdMgrSetCmdDeleteCallback.h --------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//--
diff --git a/tools/lldb-mi/MICmnBase.cpp b/tools/lldb-mi/MICmnBase.cpp
index 7f82c6120e1a6..9d87064aa64cf 100644
--- a/tools/lldb-mi/MICmnBase.cpp
+++ b/tools/lldb-mi/MICmnBase.cpp
@@ -1,9 +1,8 @@
//===-- MICmnBase.cpp -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -16,7 +15,6 @@
#include "MICmnStreamStderr.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnBase constructor.
// Type: Method.
// Args: None.
@@ -28,17 +26,15 @@ CMICmnBase::CMICmnBase()
m_pLog(&CMICmnLog::Instance()), m_clientUsageRefCnt(0) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnBase destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMICmnBase::~CMICmnBase() { m_pLog = NULL; }
+CMICmnBase::~CMICmnBase() { m_pLog = nullptr; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve whether *this object has an error description set.
// Type: Method.
// Args: None.
@@ -50,7 +46,6 @@ bool CMICmnBase::HaveErrorDescription() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve MI's last error condition.
// Type: Method.
// Args: None.
@@ -62,7 +57,6 @@ const CMIUtilString &CMICmnBase::GetErrorDescription() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set MI's error condition description. This may be accessed by
// clients and
// seen by users. Message is available to the client using the server
@@ -82,7 +76,6 @@ void CMICmnBase::SetErrorDescription(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set MI's error condition description. This may be accessed by
// clients and
// seen by users. Message is available to the client using the server
@@ -98,7 +91,6 @@ void CMICmnBase::SetErrorDescriptionNoLog(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Clear MI's error condition description.
// Type: Method.
// Args: None.
@@ -110,7 +102,6 @@ void CMICmnBase::ClrErrorDescription() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set MI's error condition description. This may be accessed by
// clients and
// seen by users. Message is available to the client using the server
diff --git a/tools/lldb-mi/MICmnBase.h b/tools/lldb-mi/MICmnBase.h
index 2b604638b2dc0..368e912b6d8a6 100644
--- a/tools/lldb-mi/MICmnBase.h
+++ b/tools/lldb-mi/MICmnBase.h
@@ -1,9 +1,8 @@
//===-- MICmnBase.h ---------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnConfig.h b/tools/lldb-mi/MICmnConfig.h
index 78793c7b020cd..9dd57922cecf3 100644
--- a/tools/lldb-mi/MICmnConfig.h
+++ b/tools/lldb-mi/MICmnConfig.h
@@ -1,9 +1,8 @@
//===-- MICmnConfig.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//--
diff --git a/tools/lldb-mi/MICmnLLDBBroadcaster.cpp b/tools/lldb-mi/MICmnLLDBBroadcaster.cpp
index 8840261eaa57e..554ec1f7e9fda 100644
--- a/tools/lldb-mi/MICmnLLDBBroadcaster.cpp
+++ b/tools/lldb-mi/MICmnLLDBBroadcaster.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBBroadcaster.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "MICmnLLDBBroadcaster.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBBroadcaster constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@ CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster()
: lldb::SBBroadcaster("MI driver") {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBBroadcaster destructor.
// Type: Overridable.
// Args: None.
@@ -32,7 +29,6 @@ CMICmnLLDBBroadcaster::CMICmnLLDBBroadcaster()
CMICmnLLDBBroadcaster::~CMICmnLLDBBroadcaster() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this broadcaster object.
// Type: Method.
// Args: None.
@@ -52,7 +48,6 @@ bool CMICmnLLDBBroadcaster::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this broadcaster object.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmnLLDBBroadcaster.h b/tools/lldb-mi/MICmnLLDBBroadcaster.h
index dcf196f16dc85..326b6769fcb71 100644
--- a/tools/lldb-mi/MICmnLLDBBroadcaster.h
+++ b/tools/lldb-mi/MICmnLLDBBroadcaster.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBBroadcaster.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
index f7f43f001b7bc..5ec2c588e201c 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebugSessionInfo.cpp ---------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,7 +29,6 @@
#include "Platform.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfo constructor.
// Type: Method.
// Args: None.
@@ -47,7 +45,6 @@ CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo()
m_constStrPrintAggregateFieldNames("Print AggregateFieldNames") {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfo destructor.
// Type: Overridable.
// Args: None.
@@ -57,7 +54,6 @@ CMICmnLLDBDebugSessionInfo::CMICmnLLDBDebugSessionInfo()
CMICmnLLDBDebugSessionInfo::~CMICmnLLDBDebugSessionInfo() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this object.
// Type: Method.
// Args: None.
@@ -80,7 +76,6 @@ bool CMICmnLLDBDebugSessionInfo::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this object.
// Type: Method.
// Args: None.
@@ -107,7 +102,6 @@ bool CMICmnLLDBDebugSessionInfo::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Command instances can create and share data between other instances
// of commands.
// Data can also be assigned by a command and retrieved by LLDB event
@@ -129,7 +123,6 @@ void CMICmnLLDBDebugSessionInfo::SharedDataDestroy() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Record information about a LLDB break point so that is can be
// recalled in other
// commands or LLDB event handling functions.
@@ -149,7 +142,6 @@ bool CMICmnLLDBDebugSessionInfo::RecordBrkPtInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve information about a LLDB break point previous recorded
// either by
// commands or LLDB event handling functions.
@@ -173,7 +165,6 @@ bool CMICmnLLDBDebugSessionInfo::RecordBrkPtInfoGet(
}
//++
-//------------------------------------------------------------------------------------
// Details: Delete information about a specific LLDB break point object. This
// function
// should be called when a LLDB break point is deleted.
@@ -195,7 +186,6 @@ bool CMICmnLLDBDebugSessionInfo::RecordBrkPtInfoDelete(const MIuint vnBrkPtId) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the specified thread's frame information.
// Type: Method.
// Args: vCmdData - (R) A command's information.
@@ -242,7 +232,6 @@ bool CMICmnLLDBDebugSessionInfo::GetThreadFrames(
}
//++
-//------------------------------------------------------------------------------------
// Details: Return the resolved file's path for the given file.
// Type: Method.
// Args: vCmdData - (R) A command's information.
@@ -273,7 +262,6 @@ bool CMICmnLLDBDebugSessionInfo::ResolvePath(const SMICmdData &vCmdData,
}
//++
-//------------------------------------------------------------------------------------
// Details: Return the resolved file's path for the given file.
// Type: Method.
// Args: vstrUnknown - (R) String assigned to path when resolved path
@@ -321,7 +309,6 @@ bool CMICmnLLDBDebugSessionInfo::ResolvePath(const CMIUtilString &vstrUnknown,
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine the given file path exists or not.
// Type: Method.
// Args: vPath - (R) File name path.
@@ -343,7 +330,6 @@ bool CMICmnLLDBDebugSessionInfo::AccessPath(const CMIUtilString &vPath,
}
//++
-//------------------------------------------------------------------------------------
// Details: Form MI partial response by appending more MI value type objects to
// the
// tuple type object past in.
@@ -376,11 +362,9 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(
// Add "target-id"
const char *pThreadName = rThread.GetName();
- const MIuint len =
- (pThreadName != nullptr) ? CMIUtilString(pThreadName).length() : 0;
- const bool bHaveName = ((pThreadName != nullptr) && (len > 0) && (len < 32) &&
- CMIUtilString::IsAllValidAlphaAndNumeric(
- pThreadName)); // 32 is arbitrary number
+ const MIuint len = CMIUtilString(pThreadName).length();
+ const bool bHaveName = (len > 0) && (len < 32) && // 32 is arbitrary number
+ CMIUtilString::IsAllValidAlphaAndNumeric(pThreadName);
const char *pThrdFmt = bHaveName ? "%s" : "Thread %d";
CMIUtilString strThread;
if (bHaveName)
@@ -411,7 +395,6 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Form MI partial response by appending more MI value type objects to
// the
// tuple type object past in.
@@ -514,7 +497,6 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(
}
//++
-//------------------------------------------------------------------------------------
// Details: Extract the value's name and value or recurse into child value
// object.
// Type: Method.
@@ -538,7 +520,6 @@ bool CMICmnLLDBDebugSessionInfo::GetVariableInfo(const lldb::SBValue &vrValue,
}
//++
-//------------------------------------------------------------------------------------
// Details: Form MI partial response by appending more MI value type objects to
// the
// tuple type object past in.
@@ -609,7 +590,6 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the frame information from LLDB frame object.
// Type: Method.
// Args: vrFrame - (R) LLDB thread object.
@@ -651,7 +631,6 @@ bool CMICmnLLDBDebugSessionInfo::GetFrameInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Form MI partial response by appending more MI value type objects to
// the
// tuple type object past in.
@@ -686,7 +665,6 @@ void CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtFrameInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Form MI partial response by appending more MI value type objects to
// the
// tuple type object past in.
@@ -776,7 +754,6 @@ bool CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve breakpoint information and write into the given breakpoint
// information
// object. Note not all possible information is retrieved and so the
@@ -839,7 +816,6 @@ bool CMICmnLLDBDebugSessionInfo::GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt,
}
//++
-//------------------------------------------------------------------------------------
// Details: Get current debugger.
// Type: Method.
// Args: None.
@@ -851,7 +827,6 @@ lldb::SBDebugger &CMICmnLLDBDebugSessionInfo::GetDebugger() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get current listener.
// Type: Method.
// Args: None.
@@ -863,7 +838,6 @@ lldb::SBListener &CMICmnLLDBDebugSessionInfo::GetListener() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get current target.
// Type: Method.
// Args: None.
@@ -878,7 +852,6 @@ lldb::SBTarget CMICmnLLDBDebugSessionInfo::GetTarget() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get current process.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
index 818df3b81b170..1fa81951f43af 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebugSessionInfo.h -----------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -243,7 +242,6 @@ private:
};
//++
-//------------------------------------------------------------------------------------
// Details: Command instances can create and share data between other instances
// of commands.
// This function adds new data to the shared data. Using the same ID
@@ -269,7 +267,6 @@ bool CMICmnLLDBDebugSessionInfo::SharedDataAdd(const CMIUtilString &vKey,
}
//++
-//------------------------------------------------------------------------------------
// Details: Command instances can create and share data between other instances
// of commands.
// This function retrieves data from the shared data container.
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
index 234b4e631b499..fc0f76b6d4957 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebugSessionInfoVarObj.cpp ---------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -29,7 +28,6 @@ CMICmnLLDBDebugSessionInfoVarObj::varFormat_e
CMICmnLLDBDebugSessionInfoVarObj::ms_eDefaultFormat = eVarFormat_Natural;
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj constructor.
// Type: Method.
// Args: None.
@@ -42,7 +40,6 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj constructor.
// Type: Method.
// Args: vrStrNameReal - (R) The actual name of the variable, the
@@ -62,7 +59,6 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj constructor.
// Type: Method.
// Args: vrStrNameReal - (R) The actual name of the variable, the
@@ -85,7 +81,6 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj copy constructor.
// Type: Method.
// Args: vrOther - (R) The object to copy from.
@@ -98,7 +93,6 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj copy constructor.
// Type: Method.
// Args: vrOther - (R) The object to copy from.
@@ -111,7 +105,6 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj move constructor.
// Type: Method.
// Args: vrwOther - (R) The object to copy from.
@@ -124,7 +117,6 @@ CMICmnLLDBDebugSessionInfoVarObj::CMICmnLLDBDebugSessionInfoVarObj(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj assignment operator.
// Type: Method.
// Args: vrOther - (R) The object to copy from.
@@ -139,7 +131,6 @@ operator=(const CMICmnLLDBDebugSessionInfoVarObj &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj assignment operator.
// Type: Method.
// Args: vrwOther - (R) The object to copy from.
@@ -154,7 +145,6 @@ operator=(CMICmnLLDBDebugSessionInfoVarObj &&vrwOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Copy the other instance of that object to *this object.
// Type: Method.
// Args: vrOther - (R) The object to copy from.
@@ -180,7 +170,6 @@ bool CMICmnLLDBDebugSessionInfoVarObj::CopyOther(
}
//++
-//------------------------------------------------------------------------------------
// Details: Move that object to *this object.
// Type: Method.
// Args: vrwOther - (RW) The object to copy from.
@@ -207,7 +196,6 @@ bool CMICmnLLDBDebugSessionInfoVarObj::MoveOther(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugSessionInfoVarObj destructor.
// Type: Overridden.
// Args: None.
@@ -217,7 +205,6 @@ bool CMICmnLLDBDebugSessionInfoVarObj::MoveOther(
CMICmnLLDBDebugSessionInfoVarObj::~CMICmnLLDBDebugSessionInfoVarObj() {}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the var format enumeration for the specified string.
// Type: Static method.
// Args: vrStrFormat - (R) Text description of the var format.
@@ -239,7 +226,6 @@ CMICmnLLDBDebugSessionInfoVarObj::GetVarFormatForString(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the var format enumeration for the specified character.
// Type: Static method.
// Args: vcFormat - Character representing the var format.
@@ -263,7 +249,6 @@ CMICmnLLDBDebugSessionInfoVarObj::GetVarFormatForChar(char vcFormat) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Return the equivalent var value formatted string for the given value
// type,
// which was prepared for printing (i.e. value was escaped and now it's
@@ -298,7 +283,6 @@ CMIUtilString CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(
}
//++
-//------------------------------------------------------------------------------------
// Details: Return number formatted string according to the given value type.
// Type: Static method.
// Args: vnValue - (R) The number value to get formatted.
@@ -341,7 +325,6 @@ CMIUtilString CMICmnLLDBDebugSessionInfoVarObj::GetStringFormatted(
}
//++
-//------------------------------------------------------------------------------------
// Details: Delete internal container contents.
// Type: Static method.
// Args: None.
@@ -353,7 +336,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjClear() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add a var object to the internal container.
// Type: Static method.
// Args: vrVarObj - (R) The var value object.
@@ -368,7 +350,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjAdd(
}
//++
-//------------------------------------------------------------------------------------
// Details: Delete the var object from the internal container matching the
// specified name.
// Type: Static method.
@@ -386,7 +367,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjDelete(
}
//++
-//------------------------------------------------------------------------------------
// Details: Update an existing var object in the internal container.
// Type: Static method.
// Args: vrVarObj - (R) The var value object.
@@ -399,7 +379,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjUpdate(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the var object matching the specified name.
// Type: Static method.
// Args: vrVarName - (R) The var value name.
@@ -422,7 +401,6 @@ bool CMICmnLLDBDebugSessionInfoVarObj::VarObjGet(
}
//++
-//------------------------------------------------------------------------------------
// Details: A count is kept of the number of var value objects created. This is
// count is
// used to ID the var value object. Reset the count to 0.
@@ -436,7 +414,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjIdResetToZero() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Default format is globally used as the data format when "natural" is
// in effect, that is, this overrides the default
// Type: Static method.
@@ -450,7 +427,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(
}
//++
-//------------------------------------------------------------------------------------
// Details: A count is kept of the number of var value objects created. This is
// count is
// used to ID the var value object. Increment the count by 1.
@@ -462,7 +438,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::VarObjSetFormat(
void CMICmnLLDBDebugSessionInfoVarObj::VarObjIdInc() { ms_nVarUniqueId++; }
//++
-//------------------------------------------------------------------------------------
// Details: A count is kept of the number of var value objects created. This is
// count is
// used to ID the var value object. Retrieve ID.
@@ -476,7 +451,6 @@ MIuint CMICmnLLDBDebugSessionInfoVarObj::VarObjIdGet() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value formatted object's name.
// Type: Method.
// Args: None.
@@ -488,7 +462,6 @@ const CMIUtilString &CMICmnLLDBDebugSessionInfoVarObj::GetName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value formatted object's variable name as given in the
// MI command
// to create the var object.
@@ -502,7 +475,6 @@ const CMIUtilString &CMICmnLLDBDebugSessionInfoVarObj::GetNameReal() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value formatted string.
// Type: Method.
// Args: None.
@@ -515,7 +487,6 @@ CMICmnLLDBDebugSessionInfoVarObj::GetValueFormatted() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the LLDB Value object.
// Type: Method.
// Args: None.
@@ -527,7 +498,6 @@ lldb::SBValue &CMICmnLLDBDebugSessionInfoVarObj::GetValue() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the LLDB Value object.
// Type: Method.
// Args: None.
@@ -539,7 +509,6 @@ const lldb::SBValue &CMICmnLLDBDebugSessionInfoVarObj::GetValue() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the var format type for *this object and update the formatting.
// Type: Method.
// Args: None.
@@ -558,7 +527,6 @@ bool CMICmnLLDBDebugSessionInfoVarObj::SetVarFormat(
}
//++
-//------------------------------------------------------------------------------------
// Details: Update *this var obj. Update it's value and type.
// Type: Method.
// Args: None.
@@ -577,7 +545,6 @@ void CMICmnLLDBDebugSessionInfoVarObj::UpdateValue() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the enumeration type of the var object.
// Type: Method.
// Args: None.
@@ -590,7 +557,6 @@ CMICmnLLDBDebugSessionInfoVarObj::GetType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the parent var object's name, the parent var object to
// *this var
// object (if assigned). The parent is equivalent to LLDB SBValue
diff --git a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
index 49854051b7fe4..6cee598fccc33 100644
--- a/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
+++ b/tools/lldb-mi/MICmnLLDBDebugSessionInfoVarObj.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebugSessionInfoVarObj.h -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLLDBDebugger.cpp b/tools/lldb-mi/MICmnLLDBDebugger.cpp
index b102cab9f93a0..b22e7d9a1fe68 100644
--- a/tools/lldb-mi/MICmnLLDBDebugger.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebugger.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebugger.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -30,7 +29,6 @@
#include "MIUtilSingletonHelper.h"
//++
-//------------------------------------------------------------------------------------
// MI private summary providers
static inline bool MI_char_summary_provider(lldb::SBValue value,
lldb::SBTypeSummaryOptions options,
@@ -44,10 +42,11 @@ static inline bool MI_char_summary_provider(lldb::SBValue value,
lldb::BasicType type_code = value_type.GetBasicType();
if (type_code == lldb::eBasicTypeSignedChar)
- stream.Printf("%d %s", (int)value.GetValueAsSigned(), value.GetValue());
+ stream.Printf("%d %s", (int)value.GetValueAsSigned(),
+ CMIUtilString::WithNullAsEmpty(value.GetValue()));
else if (type_code == lldb::eBasicTypeUnsignedChar)
stream.Printf("%u %s", (unsigned)value.GetValueAsUnsigned(),
- value.GetValue());
+ CMIUtilString::WithNullAsEmpty(value.GetValue()));
else
return false;
@@ -55,7 +54,6 @@ static inline bool MI_char_summary_provider(lldb::SBValue value,
}
//++
-//------------------------------------------------------------------------------------
// MI summary helper routines
static inline bool MI_add_summary(lldb::SBTypeCategory category,
const char *typeName,
@@ -74,7 +72,6 @@ static inline bool MI_add_summary(lldb::SBTypeCategory category,
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugger constructor.
// Type: Method.
// Args: None.
@@ -85,7 +82,6 @@ CMICmnLLDBDebugger::CMICmnLLDBDebugger()
: m_constStrThisThreadId("MI debugger event") {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebugger destructor.
// Type: Overridable.
// Args: None.
@@ -95,7 +91,6 @@ CMICmnLLDBDebugger::CMICmnLLDBDebugger()
CMICmnLLDBDebugger::~CMICmnLLDBDebugger() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this debugger object.
// Type: Method.
// Args: None.
@@ -157,7 +152,6 @@ bool CMICmnLLDBDebugger::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this debugger object.
// Type: Method.
// Args: None.
@@ -217,7 +211,6 @@ bool CMICmnLLDBDebugger::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Return the LLDB debugger instance created for this debug session.
// Type: Method.
// Args: None.
@@ -229,7 +222,6 @@ lldb::SBDebugger &CMICmnLLDBDebugger::GetTheDebugger() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Return the LLDB listener instance created for this debug session.
// Type: Method.
// Args: None.
@@ -241,7 +233,6 @@ lldb::SBListener &CMICmnLLDBDebugger::GetTheListener() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the client driver that wants to use *this LLDB debugger. Call
// this function
// prior to Initialize().
@@ -258,7 +249,6 @@ bool CMICmnLLDBDebugger::SetDriver(const CMIDriverBase &vClientDriver) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get the client driver that is use *this LLDB debugger.
// Type: Method.
// Args: vClientDriver - (R) A driver.
@@ -270,7 +260,6 @@ CMIDriverBase &CMICmnLLDBDebugger::GetDriver() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Wait until all events have been handled.
// This function works in pair with
// CMICmnLLDBDebugger::MonitorSBListenerEvents
@@ -294,7 +283,6 @@ void CMICmnLLDBDebugger::WaitForHandleEvent() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check if need to rebroadcast stop event. This function will return
// true if
// debugger is in synchronouse mode. In such case the
@@ -321,7 +309,6 @@ bool CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Rebroadcast stop event if needed. This function should be called
// only if the
// CMICmnLLDBDebugger::CheckIfNeedToRebroadcastStopEvent() returned
@@ -342,7 +329,6 @@ void CMICmnLLDBDebugger::RebroadcastStopEvent() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize the LLDB Debugger object.
// Type: Method.
// Args: None.
@@ -363,7 +349,6 @@ bool CMICmnLLDBDebugger::InitSBDebugger() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the LLDB Debugger's std in, err and out streams. (Not
// implemented left
// here for reference. Was called in the
@@ -388,7 +373,6 @@ bool CMICmnLLDBDebugger::InitStdStreams() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set up the events from the SBDebugger's we would like to listen to.
// Type: Method.
// Args: None.
@@ -443,7 +427,6 @@ bool CMICmnLLDBDebugger::InitSBListener() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Register with the debugger, the SBListener, the type of events you
// are interested
// in. Others, like commands, may have already set the mask.
@@ -481,7 +464,6 @@ bool CMICmnLLDBDebugger::RegisterForEvent(
}
//++
-//------------------------------------------------------------------------------------
// Details: Register with the debugger, the SBListener, the type of events you
// are interested
// in. Others, like commands, may have already set the mask.
@@ -532,7 +514,6 @@ bool CMICmnLLDBDebugger::RegisterForEvent(
}
//++
-//------------------------------------------------------------------------------------
// Details: Unregister with the debugger, the SBListener, the type of events you
// are no
// longer interested in. Others, like commands, may still remain
@@ -558,7 +539,7 @@ bool CMICmnLLDBDebugger::UnregisterForEvent(
ClientGetMaskForAllClients(vBroadcasterClass);
MIuint newEventMask = 0;
for (MIuint i = 0; i < 32; i++) {
- const MIuint bit = 1 << i;
+ const MIuint bit = MIuint(1) << i;
const MIuint clientBit = bit & clientsEventMask;
const MIuint othersBit = bit & otherClientsEventMask;
if ((clientBit != 0) && (othersBit == 0)) {
@@ -579,7 +560,6 @@ bool CMICmnLLDBDebugger::UnregisterForEvent(
}
//++
-//------------------------------------------------------------------------------------
// Details: Given the SBBroadcaster class name retrieve it's current event mask.
// Type: Method.
// Args: vBroadcasterClass - (R) The SBBroadcaster's class name.
@@ -609,7 +589,6 @@ bool CMICmnLLDBDebugger::BroadcasterGetMask(
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove the event mask for the specified SBBroadcaster class name.
// Type: Method.
// Args: vBroadcasterClass - (R) The SBBroadcaster's class name.
@@ -629,7 +608,6 @@ bool CMICmnLLDBDebugger::BroadcasterRemoveMask(
}
//++
-//------------------------------------------------------------------------------------
// Details: Given the SBBroadcaster class name save it's current event mask.
// Type: Method.
// Args: vBroadcasterClass - (R) The SBBroadcaster's class name.
@@ -655,7 +633,6 @@ bool CMICmnLLDBDebugger::BroadcasterSaveMask(
}
//++
-//------------------------------------------------------------------------------------
// Details: Iterate all the clients who have registered event masks against
// particular
// SBBroadcasters and build up the mask that is for all of them.
@@ -683,7 +660,6 @@ MIuint CMICmnLLDBDebugger::ClientGetMaskForAllClients(
}
//++
-//------------------------------------------------------------------------------------
// Details: Given the client save its particular event requirements.
// Type: Method.
// Args: vClientName - (R) The Client's unique ID.
@@ -714,7 +690,6 @@ bool CMICmnLLDBDebugger::ClientSaveMask(const CMIUtilString &vClientName,
}
//++
-//------------------------------------------------------------------------------------
// Details: Given the client remove it's particular event requirements.
// Type: Method.
// Args: vClientName - (R) The Client's unique ID.
@@ -743,7 +718,6 @@ bool CMICmnLLDBDebugger::ClientRemoveTheirMask(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the client's event mask used for on a particular
// SBBroadcaster.
// Type: Method.
@@ -778,7 +752,6 @@ bool CMICmnLLDBDebugger::ClientGetTheirMask(
}
//++
-//------------------------------------------------------------------------------------
// Details: Momentarily wait for an events being broadcast and inspect those
// that do
// come this way. Check if the target should exit event if so start
@@ -848,7 +821,6 @@ bool CMICmnLLDBDebugger::MonitorSBListenerEvents(bool &vrbIsAlive) {
}
//++
-//------------------------------------------------------------------------------------
// Details: The main worker method for this thread.
// Type: Method.
// Args: vrbIsAlive - (W) True = *this thread is working, false = thread has
@@ -862,7 +834,6 @@ bool CMICmnLLDBDebugger::ThreadRun(bool &vrbIsAlive) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Let this thread clean up after itself.
// Type: Method.
// Args:
@@ -873,7 +844,6 @@ bool CMICmnLLDBDebugger::ThreadRun(bool &vrbIsAlive) {
bool CMICmnLLDBDebugger::ThreadFinish() { return MIstatus::success; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve *this thread object's name.
// Type: Overridden.
// Args: None.
@@ -885,7 +855,6 @@ const CMIUtilString &CMICmnLLDBDebugger::ThreadGetName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Loads lldb-mi formatters
// Type: Method.
// Args: None.
@@ -913,7 +882,6 @@ bool CMICmnLLDBDebugger::LoadMIFormatters(lldb::SBTypeCategory miCategory) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Registers lldb-mi custom summary providers
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmnLLDBDebugger.h b/tools/lldb-mi/MICmnLLDBDebugger.h
index bec9adf13830f..29cf9416e153b 100644
--- a/tools/lldb-mi/MICmnLLDBDebugger.h
+++ b/tools/lldb-mi/MICmnLLDBDebugger.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebugger.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
index cd54c2bb5bc4e..60cfd3563dae2 100644
--- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
+++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebuggerHandleEvents.cpp -----------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -44,7 +43,6 @@
#include <algorithm>
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebuggerHandleEvents constructor.
// Type: Method.
// Args: None.
@@ -54,7 +52,6 @@
CMICmnLLDBDebuggerHandleEvents::CMICmnLLDBDebuggerHandleEvents() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBDebuggerHandleEvents destructor.
// Type: Overridable.
// Args: None.
@@ -66,7 +63,6 @@ CMICmnLLDBDebuggerHandleEvents::~CMICmnLLDBDebuggerHandleEvents() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this broadcaster object.
// Type: Method.
// Args: None.
@@ -91,7 +87,6 @@ bool CMICmnLLDBDebuggerHandleEvents::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this broadcaster object.
// Type: Method.
// Args: None.
@@ -112,7 +107,6 @@ bool CMICmnLLDBDebuggerHandleEvents::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Interpret the event object to ascertain the action to take or
// information to
// to form and put in a MI Out-of-band record object which is given to
@@ -151,7 +145,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEvent(const lldb::SBEvent &vEvent,
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBProcess event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -202,7 +195,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBProcess(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBBreakpoint event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -275,7 +267,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakPoint(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBBreakpoint event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -300,7 +291,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointLocationsAdded(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBBreakpoint event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -369,7 +359,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointCmn(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBBreakpoint added event.
// Add more breakpoint information or overwrite existing information.
// Normally a break point session info objects exists by now when an MI
@@ -494,7 +483,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBBreakpointAdded(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBThread event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -543,7 +531,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBThread(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBThread event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -577,7 +564,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBThreadSuspended(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBThread event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -597,7 +583,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBThreadBitStackChanged(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBTarget event.
// Type: Method.
// Args: vEvent - (R) An LLDB broadcast event.
@@ -646,7 +631,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBTarget(
}
//++
-//------------------------------------------------------------------------------------
// Details: Print to stdout
// "=library-loaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded="%d"[,symbols-path=\"%s\"],loaded_addr=\"0x%016"
// PRIx64"\""
@@ -676,7 +660,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleTargetEventBroadcastBitModulesLoaded(
}
//++
-//------------------------------------------------------------------------------------
// Details: Print to stdout
// "=library-unloaded,id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded="%d"[,symbols-path=\"%s\"],loaded_addr=\"0x%016"
// PRIx64"\""
@@ -706,7 +689,6 @@ bool CMICmnLLDBDebuggerHandleEvents::
}
//++
-//------------------------------------------------------------------------------------
// Details: Build module information for =library-loaded/=library-unloaded:
// "id=\"%s\",target-name=\"%s\",host-name=\"%s\",symbols-loaded="%d"[,symbols-path=\"%s\"],loaded_addr=\"0x%016"
// PRIx64"\""
@@ -784,7 +766,6 @@ bool CMICmnLLDBDebuggerHandleEvents::MiHelpGetModuleInfo(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle a LLDB SBCommandInterpreter event.
// Type: Method.
// Args: vEvent - (R) An LLDB command interpreter event.
@@ -843,7 +824,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleEventSBCommandInterpreter(
}
//++
-//------------------------------------------------------------------------------------
// Details: Handle SBProcess event eBroadcastBitStateChanged.
// Type: Method.
// Args: vEvent - (R) An LLDB event object.
@@ -939,7 +919,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventBroadcastBitStateChanged(
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous event handler for LLDB Process state suspended.
// Type: Method.
// Args: vEvent - (R) An LLDB event object.
@@ -972,7 +951,7 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended(
} else {
const MIuint nTargetIndex = rDebugger.GetIndexOfTarget(target);
if (nTargetIndex != UINT_MAX)
- streamOut.Printf("Target %d: (", nTargetIndex);
+ streamOut.Printf("Target %" PRIu64 ": (", (uint64_t)nTargetIndex);
else
streamOut.Printf("Target <unknown index>: (");
target.GetDescription(streamOut, lldb::eDescriptionLevelBrief);
@@ -984,7 +963,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateSuspended(
}
//++
-//------------------------------------------------------------------------------------
// Details: Print to stdout MI formatted text to indicate process stopped.
// Type: Method.
// Args: vwrbShouldBrk - (W) True = Yes break, false = do not.
@@ -1053,7 +1031,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateStopped(
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous event handler for LLDB Process stop signal.
// Type: Method.
// Args: vrEvent - (R) An LLDB broadcast event.
@@ -1204,7 +1181,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopSignal(
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous event handler for LLDB Process stop exception.
// Type: Method.
// Args: None.
@@ -1245,7 +1221,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopException() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Form partial MI response in a MI value tuple object.
// Type: Method.
// Args: vwrMiValueTuple - (W) MI value tuple object.
@@ -1296,7 +1271,6 @@ bool CMICmnLLDBDebuggerHandleEvents::MiHelpGetCurrentThreadFrame(
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous event handler for LLDB Process stop reason breakpoint.
// Type: Method.
// Args: None.
@@ -1326,7 +1300,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonBreakpoint() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Form the MI Out-of-band response for stopped reason on hitting a
// break point.
// Type: Method.
@@ -1426,7 +1399,6 @@ bool CMICmnLLDBDebuggerHandleEvents::MiStoppedAtBreakPoint(
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous event handler for LLDB Process stop reason trace.
// Type: Method.
// Args: None.
@@ -1492,7 +1464,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStopReasonTrace() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous function update selected thread.
// Type: Method.
// Args: None.
@@ -1565,7 +1536,6 @@ bool CMICmnLLDBDebuggerHandleEvents::UpdateSelectedThread() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Print to stdout "*running,thread-id=\"all\"", "(gdb)".
// Type: Method.
// Args: None.
@@ -1585,7 +1555,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateRunning() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Print to stdout "=thread-exited,id=\"%ld\",group-id=\"i1\"",
// "=thread-group-exited,id=\"i1\",exit-code=\"0\""),
// "*stopped,reason=\"exited-normally\"",
@@ -1629,7 +1598,6 @@ bool CMICmnLLDBDebuggerHandleEvents::HandleProcessEventStateExited() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Drain all stdout so we don't see any output come after we print our
// prompts.
// The process has stuff waiting for stdout; get it and write it out to
@@ -1685,7 +1653,6 @@ bool CMICmnLLDBDebuggerHandleEvents::GetProcessStdout() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Drain all stderr so we don't see any output come after we print our
// prompts.
// The process has stuff waiting for stderr; get it and write it out to
@@ -1740,7 +1707,6 @@ bool CMICmnLLDBDebuggerHandleEvents::GetProcessStderr() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Asynchronous event function check for state changes.
// Type: Method.
// Args: None.
@@ -1836,7 +1802,6 @@ bool CMICmnLLDBDebuggerHandleEvents::ChkForStateChanges() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Take a fully formed MI result record and send to the stdout stream.
// Also output to the MI Log file.
// Type: Method.
@@ -1851,7 +1816,6 @@ bool CMICmnLLDBDebuggerHandleEvents::MiResultRecordToStdout(
}
//++
-//------------------------------------------------------------------------------------
// Details: Take a fully formed MI Out-of-band record and send to the stdout
// stream.
// Also output to the MI Log file.
@@ -1867,7 +1831,6 @@ bool CMICmnLLDBDebuggerHandleEvents::MiOutOfBandRecordToStdout(
}
//++
-//------------------------------------------------------------------------------------
// Details: Take a text data and send to the stdout stream. Also output to the
// MI Log
// file.
@@ -1882,7 +1845,6 @@ bool CMICmnLLDBDebuggerHandleEvents::TextToStdout(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Take a text data and send to the stderr stream. Also output to the
// MI Log
// file.
@@ -1897,7 +1859,6 @@ bool CMICmnLLDBDebuggerHandleEvents::TextToStderr(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize the member variables with the signal values in this
// process
// file.
diff --git a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
index 55764511a6a9b..378d85e6f5751 100644
--- a/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
+++ b/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBDebuggerHandleEvents.h -------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLLDBProxySBValue.cpp b/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
index 5a3e8e43b5fe4..14e39cd1f80ac 100644
--- a/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
+++ b/tools/lldb-mi/MICmnLLDBProxySBValue.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBProxySBValue.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "MIUtilString.h"
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the numerical value from the SBValue object. If the
// function fails
// it could indicate the SBValue object does not represent an internal
@@ -52,7 +50,6 @@ bool CMICmnLLDBProxySBValue::GetValueAsUnsigned(const lldb::SBValue &vrValue,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the numerical value from the SBValue object. If the
// function fails
// it could indicate the SBValue object does not represent an internal
@@ -86,7 +83,6 @@ bool CMICmnLLDBProxySBValue::GetValueAsSigned(const lldb::SBValue &vrValue,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the NUL terminated string from the SBValue object if it of
// the type
// unsigned char *.
diff --git a/tools/lldb-mi/MICmnLLDBProxySBValue.h b/tools/lldb-mi/MICmnLLDBProxySBValue.h
index 2559a60a1141d..4852b60763eae 100644
--- a/tools/lldb-mi/MICmnLLDBProxySBValue.h
+++ b/tools/lldb-mi/MICmnLLDBProxySBValue.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBProxySBValue.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp b/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
index 5785bf2a6329c..0e7df52b7b991 100644
--- a/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
+++ b/tools/lldb-mi/MICmnLLDBUtilSBValue.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLLDBUtilSBValue.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,6 @@ static const char *kUnknownValue = "??";
static const char *kUnresolvedCompositeValue = "{...}";
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBUtilSBValue constructor.
// Type: Method.
// Args: vrValue - (R) The LLDB value object.
@@ -42,7 +40,6 @@ CMICmnLLDBUtilSBValue::CMICmnLLDBUtilSBValue(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLLDBUtilSBValue destructor.
// Type: Method.
// Args: None.
@@ -52,7 +49,6 @@ CMICmnLLDBUtilSBValue::CMICmnLLDBUtilSBValue(
CMICmnLLDBUtilSBValue::~CMICmnLLDBUtilSBValue() {}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve from the LLDB SB Value object the name of the variable. If
// the name
// is invalid (or the SBValue object invalid) then "??" is returned.
@@ -69,7 +65,6 @@ CMIUtilString CMICmnLLDBUtilSBValue::GetName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve from the LLDB SB Value object the value of the variable
// described in
// text. If the value is invalid (or the SBValue object invalid) then
@@ -120,7 +115,6 @@ CMIUtilString CMICmnLLDBUtilSBValue::GetValue(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve from the LLDB SB Value object the value of the variable
// described in
// text if it has a simple format (not composite).
@@ -247,7 +241,6 @@ CMICmnLLDBUtilSBValue::GetValueSummary(bool valueOnly,
}
//++
-//------------------------------------------------------------------------------------
// Details: Check that basic type is a char type. Char type can be signed or
// unsigned.
// Type: Static.
@@ -269,7 +262,6 @@ bool CMICmnLLDBUtilSBValue::IsCharBasicType(lldb::BasicType eType) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the flag stating whether this value object is a char type
// or some
// other type. Char type can be signed or unsigned.
@@ -284,7 +276,6 @@ bool CMICmnLLDBUtilSBValue::IsCharType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the flag stating whether first child value object of *this
// object is
// a char type or some other type. Returns false if there are not
@@ -308,7 +299,6 @@ bool CMICmnLLDBUtilSBValue::IsFirstChildCharType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the flag stating whether pointee object of *this object is
// a char type or some other type. Returns false if there are not
// children. Char
@@ -331,7 +321,6 @@ bool CMICmnLLDBUtilSBValue::IsPointeeCharType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the flag stating whether this value object is a integer
// type or some
// other type. Char type can be signed or unsigned and short or
@@ -356,7 +345,6 @@ bool CMICmnLLDBUtilSBValue::IsIntegerType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the flag stating whether this value object is a pointer
// type or some
// other type.
@@ -370,7 +358,6 @@ bool CMICmnLLDBUtilSBValue::IsPointerType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the flag stating whether this value object is an array type
// or some
// other type.
@@ -384,7 +371,6 @@ bool CMICmnLLDBUtilSBValue::IsArrayType() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the C string data of value object by read the memory where
// the
// variable is held.
@@ -419,7 +405,6 @@ CMICmnLLDBUtilSBValue::ReadCStringFromHostMemory(lldb::SBValue &vrValue,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state of the value object's name.
// Type: Method.
// Args: None.
@@ -432,7 +417,6 @@ bool CMICmnLLDBUtilSBValue::IsNameUnknown() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the state of the value object's value data.
// Type: Method.
// Args: None.
@@ -445,7 +429,6 @@ bool CMICmnLLDBUtilSBValue::IsValueUnknown() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value object's type name if valid.
// Type: Method.
// Args: None.
@@ -460,7 +443,6 @@ CMIUtilString CMICmnLLDBUtilSBValue::GetTypeName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value object's display type name if valid.
// Type: Method.
// Args: None.
@@ -475,7 +457,6 @@ CMIUtilString CMICmnLLDBUtilSBValue::GetTypeNameDisplay() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve whether the value object's is valid or not.
// Type: Method.
// Args: None.
@@ -485,7 +466,6 @@ CMIUtilString CMICmnLLDBUtilSBValue::GetTypeNameDisplay() const {
bool CMICmnLLDBUtilSBValue::IsValid() const { return m_bValidSBValue; }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the value object' has a name. A value object can be valid
// but still
// have no name which suggest it is not a variable.
@@ -506,7 +486,6 @@ bool CMICmnLLDBUtilSBValue::HasName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if the value object' represents a LLDB variable i.e. "$0".
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmnLLDBUtilSBValue.h b/tools/lldb-mi/MICmnLLDBUtilSBValue.h
index ef5849e6eafc5..6804402b75d68 100644
--- a/tools/lldb-mi/MICmnLLDBUtilSBValue.h
+++ b/tools/lldb-mi/MICmnLLDBUtilSBValue.h
@@ -1,9 +1,8 @@
//===-- MICmnLLDBUtilSBValue.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLog.cpp b/tools/lldb-mi/MICmnLog.cpp
index d30c03f5063d8..fc4c3141915b5 100644
--- a/tools/lldb-mi/MICmnLog.cpp
+++ b/tools/lldb-mi/MICmnLog.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLog.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MIUtilDateTimeStd.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLog constructor.
// Type: Method.
// Args: None.
@@ -27,7 +25,6 @@ CMICmnLog::CMICmnLog() : m_bEnabled(false), m_bInitializingATM(false) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLog destructor.
// Type: Method.
// Args: None.
@@ -37,7 +34,6 @@ CMICmnLog::CMICmnLog() : m_bEnabled(false), m_bInitializingATM(false) {
CMICmnLog::~CMICmnLog() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Logger.
// Type: Method.
// Args: None.
@@ -95,7 +91,6 @@ bool CMICmnLog::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Logger.
// Type: Method.
// Args: None.
@@ -120,7 +115,6 @@ bool CMICmnLog::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Enabled or disable *this Logger from writing any data to registered
// clients.
// Type: Method.
@@ -136,7 +130,6 @@ bool CMICmnLog::SetEnabled(const bool vbYes) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve state whether *this Logger is enabled writing data to
// registered clients.
// Type: Method.
@@ -148,7 +141,6 @@ bool CMICmnLog::SetEnabled(const bool vbYes) {
bool CMICmnLog::GetEnabled() const { return m_bEnabled; }
//++
-//------------------------------------------------------------------------------------
// Details: Unregister all the Mediums registered with *this Logger.
// Type: Method.
// Args: None.
@@ -169,7 +161,6 @@ bool CMICmnLog::UnregisterMediumAll() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Register a Medium with *this Logger.
// Type: Method.
// Args: vrMedium - (R) The medium to register.
@@ -198,7 +189,6 @@ bool CMICmnLog::RegisterMedium(const IMedium &vrMedium) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Query the Logger to see if a medium is already registered.
// Type: Method.
// Args: vrMedium - (R) The medium to query.
@@ -213,7 +203,6 @@ bool CMICmnLog::HaveMediumAlready(const IMedium &vrMedium) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Unregister a medium from the Logger.
// Type: Method.
// Args: vrMedium - (R) The medium to unregister.
@@ -229,7 +218,6 @@ bool CMICmnLog::UnregisterMedium(const IMedium &vrMedium) {
}
//++
-//------------------------------------------------------------------------------------
// Details: The callee client uses this function to write to the Logger. The
// data to be
// written is given out to all the mediums registered. The verbosity
@@ -294,7 +282,6 @@ bool CMICmnLog::Write(const CMIUtilString &vData, const ELogVerbosity veType) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Short cut function call to write only to the Log file.
// The logger must be initialized successfully before a write to any
// registered
@@ -310,7 +297,6 @@ bool CMICmnLog::WriteLog(const CMIUtilString &vData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve a string detailing the last error.
// Type: Method.
// Args: None,
@@ -322,7 +308,6 @@ const CMIUtilString &CMICmnLog::GetErrorDescription() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the internal description of the last error.
// Type: Method.
// Args: (R) String containing a description of the last error.
@@ -334,7 +319,6 @@ void CMICmnLog::SetErrorDescription(const CMIUtilString &vrTxt) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Clear the last error.
// Type: None.
// Args: None.
diff --git a/tools/lldb-mi/MICmnLog.h b/tools/lldb-mi/MICmnLog.h
index 4b19c625a8708..909dc613b02ed 100644
--- a/tools/lldb-mi/MICmnLog.h
+++ b/tools/lldb-mi/MICmnLog.h
@@ -1,9 +1,8 @@
//===-- MICmnLog.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnLogMediumFile.cpp b/tools/lldb-mi/MICmnLogMediumFile.cpp
index 9f94caf3be7fe..7fbe28f3fe0f5 100644
--- a/tools/lldb-mi/MICmnLogMediumFile.cpp
+++ b/tools/lldb-mi/MICmnLogMediumFile.cpp
@@ -1,9 +1,8 @@
//===-- MICmnLogMediumFile.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLogMediumFile constructor.
// Type: Method.
// Args: None.
@@ -30,7 +28,6 @@ CMICmnLogMediumFile::CMICmnLogMediumFile()
m_fileHeaderTxt(MIRSRC(IDS_MEDIUMFILE_ERR_FILE_HEADER)) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnLogMediumFile destructor.
// Type: Overridden.
// Args: None.
@@ -40,7 +37,6 @@ CMICmnLogMediumFile::CMICmnLogMediumFile()
CMICmnLogMediumFile::~CMICmnLogMediumFile() {}
//++
-//------------------------------------------------------------------------------------
// Details: Get the singleton instance of *this class.
// Type: Static.
// Args: None.
@@ -54,7 +50,6 @@ CMICmnLogMediumFile &CMICmnLogMediumFile::Instance() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize setup *this medium ready for use.
// Type: Overridden.
// Args: None.
@@ -68,7 +63,6 @@ bool CMICmnLogMediumFile::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Unbind detach or release resources used by *this medium.
// Type: Method.
// Args: None.
@@ -84,7 +78,6 @@ bool CMICmnLogMediumFile::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the name of *this medium.
// Type: Overridden.
// Args: None.
@@ -96,7 +89,6 @@ const CMIUtilString &CMICmnLogMediumFile::GetName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: The callee client calls the write function on the Logger. The data
// to be
// written is given out to all the mediums registered. The verbosity
@@ -133,7 +125,6 @@ bool CMICmnLogMediumFile::Write(const CMIUtilString &vData,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve *this medium's last error condition.
// Type: Method.
// Args: None.
@@ -145,7 +136,6 @@ const CMIUtilString &CMICmnLogMediumFile::GetError() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the verbosity mode for this medium.
// Type: Method.
// Args: veType - (R) Mask value.
@@ -159,7 +149,6 @@ bool CMICmnLogMediumFile::SetVerbosity(const MIuint veType) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get the verbosity mode for this medium.
// Type: Method.
// Args: veType - (R) Mask value.
@@ -169,7 +158,6 @@ bool CMICmnLogMediumFile::SetVerbosity(const MIuint veType) {
MIuint CMICmnLogMediumFile::GetVerbosity() const { return m_eVerbosityType; }
//++
-//------------------------------------------------------------------------------------
// Details: Write data to a file English font.
// Type: Method.
// Args: vData - (R) The data to write to the logger.
@@ -181,7 +169,6 @@ bool CMICmnLogMediumFile::FileWriteEnglish(const CMIUtilString &vData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine and form the medium file's directory path and name.
// Type: Method.
// Args: None.
@@ -211,7 +198,6 @@ bool CMICmnLogMediumFile::FileFormFileNamePath() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the medium file's directory path and name.
// Type: Method.
// Args: None.
@@ -223,7 +209,6 @@ const CMIUtilString &CMICmnLogMediumFile::GetFileNamePath() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the medium file's name.
// Type: Method.
// Args: None.
@@ -235,7 +220,6 @@ const CMIUtilString &CMICmnLogMediumFile::GetFileName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Massage the data to behave correct when submitted to file. Insert
// extra log
// specific text. The veType is there to allow in the future to parse
@@ -273,7 +257,6 @@ CMICmnLogMediumFile::MassagedData(const CMIUtilString &vData,
}
//++
-//------------------------------------------------------------------------------------
// Details: Convert the Log's verbosity type number into a single char
// character.
// Type: Method.
@@ -300,7 +283,6 @@ char CMICmnLogMediumFile::ConvertLogVerbosityTypeToId(
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve state of whether the file medium is ok.
// Type: Method.
// Args: None.
@@ -311,7 +293,6 @@ char CMICmnLogMediumFile::ConvertLogVerbosityTypeToId(
bool CMICmnLogMediumFile::IsOk() const { return m_file.IsOk(); }
//++
-//------------------------------------------------------------------------------------
// Details: Status on the file log medium existing already.
// Type: Method.
// Args: None.
@@ -324,7 +305,6 @@ bool CMICmnLogMediumFile::IsFileExist() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Write the header text the logger file.
// Type: Method.
// Args: vText - (R) Text.
@@ -337,7 +317,6 @@ bool CMICmnLogMediumFile::FileWriteHeader() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Convert any carriage line returns to be compatible with the platform
// the
// Log file is being written to.
@@ -366,7 +345,6 @@ CMIUtilString CMICmnLogMediumFile::ConvertCr(const CMIUtilString &vData) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the header text that is written to the logger file at the
// beginning.
// Type: Method.
@@ -382,7 +360,6 @@ bool CMICmnLogMediumFile::SetHeaderTxt(const CMIUtilString &vText) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the file current carriage line return characters used.
// Type: Method.
// Args: None.
@@ -394,7 +371,6 @@ const CMIUtilString &CMICmnLogMediumFile::GetLineReturn() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the directory to place the log file.
// Type: Method.
// Args: vPath - (R) Path to log.
diff --git a/tools/lldb-mi/MICmnLogMediumFile.h b/tools/lldb-mi/MICmnLogMediumFile.h
index 0a734a1c77d5f..85b0a9d4f581d 100644
--- a/tools/lldb-mi/MICmnLogMediumFile.h
+++ b/tools/lldb-mi/MICmnLogMediumFile.h
@@ -1,9 +1,8 @@
//===-- MICmnLogMediumFile.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp b/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
index 029f76e65a856..59856a6f165e7 100644
--- a/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
+++ b/tools/lldb-mi/MICmnMIOutOfBandRecord.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIOutOfBandRecord.cpp ------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -54,7 +53,7 @@ MapOutOfBandToText(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
return "";
}
assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
- return NULL;
+ return nullptr;
}
static const char *
@@ -96,11 +95,10 @@ MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
return "&";
}
assert(false && "unknown CMICmnMIOutofBandRecord::OutOfBand_e");
- return NULL;
+ return nullptr;
}
//++
-//------------------------------------------------------------------------------------
// Details: Build the Out-of-band record's mandatory data part. The part up to
// the first
// (additional) result i.e. async-record ==> "*" type.
@@ -110,12 +108,13 @@ MapOutOfBandToToken(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
//--
static CMIUtilString
BuildAsyncRecord(CMICmnMIOutOfBandRecord::OutOfBand_e veType) {
- return CMIUtilString::Format("%s%s", MapOutOfBandToToken(veType),
- MapOutOfBandToText(veType));
+ auto Token = MapOutOfBandToToken(veType);
+ auto Text = MapOutOfBandToText(veType);
+ return CMIUtilString::Format("%s%s", CMIUtilString::WithNullAsEmpty(Token),
+ CMIUtilString::WithNullAsEmpty(Text));
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIOutOfBandRecord constructor.
// Type: Method.
// Args: None.
@@ -126,7 +125,6 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord()
: m_strAsyncRecord(MIRSRC(IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION)) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIOutOfBandRecord constructor.
// Type: Method.
// Args: veType - (R) A MI Out-of-Bound enumeration.
@@ -137,7 +135,6 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(OutOfBand_e veType)
: m_strAsyncRecord(BuildAsyncRecord(veType)) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIOutOfBandRecord constructor.
// Type: Method.
// Args: veType - (R) A MI Out-of-Bound enumeration.
@@ -152,7 +149,6 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIOutOfBandRecord constructor.
// Type: Method.
// Args: veType - (R) A MI Out-of-Bound enumeration.
@@ -167,7 +163,6 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIOutOfBandRecord destructor.
// Type: Overrideable.
// Args: None.
@@ -177,7 +172,6 @@ CMICmnMIOutOfBandRecord::CMICmnMIOutOfBandRecord(
CMICmnMIOutOfBandRecord::~CMICmnMIOutOfBandRecord() {}
//++
-//------------------------------------------------------------------------------------
// Details: Return the MI Out-of-band record as a string. The string is a direct
// result of
// work done on *this Out-of-band record so if not enough data is added
@@ -196,7 +190,6 @@ const CMIUtilString &CMICmnMIOutOfBandRecord::GetString() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add to *this Out-of-band record additional information.
// Type: Method.
// Args: vResult - (R) A MI result object.
diff --git a/tools/lldb-mi/MICmnMIOutOfBandRecord.h b/tools/lldb-mi/MICmnMIOutOfBandRecord.h
index 1bba38cf0ccad..ab1faab8bc465 100644
--- a/tools/lldb-mi/MICmnMIOutOfBandRecord.h
+++ b/tools/lldb-mi/MICmnMIOutOfBandRecord.h
@@ -1,9 +1,8 @@
//===-- MICmnMIOutOfBandRecord.h --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIResultRecord.cpp b/tools/lldb-mi/MICmnMIResultRecord.cpp
index ea6fcf8fc59cc..93bb5a60ec3dc 100644
--- a/tools/lldb-mi/MICmnMIResultRecord.cpp
+++ b/tools/lldb-mi/MICmnMIResultRecord.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIResultRecord.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: Map a result class to the corresponding string.
// Args: veType - (R) A MI result class enumeration.
// Return: const char* - The string corresponding to the result class.
@@ -36,11 +34,10 @@ MapResultClassToResultClassText(CMICmnMIResultRecord::ResultClass_e veType) {
return "exit";
}
assert(false && "unknown CMICmnMIResultRecord::ResultClass_e");
- return NULL;
+ return nullptr;
}
//++
-//------------------------------------------------------------------------------------
// Details: Build the result record's mandatory data part. The part up to the
// first
// (additional) result i.e. result-record ==> [ token ] "^"
@@ -54,11 +51,11 @@ static const CMIUtilString
BuildResultRecord(const CMIUtilString &vrToken,
CMICmnMIResultRecord::ResultClass_e veType) {
const char *pStrResultRecord = MapResultClassToResultClassText(veType);
- return CMIUtilString::Format("%s^%s", vrToken.c_str(), pStrResultRecord);
+ return CMIUtilString::Format("%s^%s", vrToken.c_str(),
+ CMIUtilString::WithNullAsEmpty(pStrResultRecord));
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIResultRecord constructor.
// Type: Method.
// Args: None.
@@ -69,7 +66,6 @@ CMICmnMIResultRecord::CMICmnMIResultRecord()
: m_strResultRecord(MIRSRC(IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION)) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIResultRecord constructor.
// Type: Method.
// Args: vrToken - (R) The command's transaction ID or token.
@@ -82,7 +78,6 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken,
: m_strResultRecord(BuildResultRecord(vrToken, veType)) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIResultRecord constructor.
// Type: Method.
// Args: vrToken - (R) The command's transaction ID or token.
@@ -99,7 +94,6 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken,
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIResultRecord destructor.
// Type: Overrideable.
// Args: None.
@@ -109,7 +103,6 @@ CMICmnMIResultRecord::CMICmnMIResultRecord(const CMIUtilString &vrToken,
CMICmnMIResultRecord::~CMICmnMIResultRecord() {}
//++
-//------------------------------------------------------------------------------------
// Details: Return the MI result record as a string. The string is a direct
// result of
// work done on *this result record so if not enough data is added then
@@ -128,7 +121,6 @@ const CMIUtilString &CMICmnMIResultRecord::GetString() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add to *this result record additional information.
// Type: Method.
// Args: vMIValue - (R) A MI value derived object.
diff --git a/tools/lldb-mi/MICmnMIResultRecord.h b/tools/lldb-mi/MICmnMIResultRecord.h
index 2018ad58e171d..ae57007257c34 100644
--- a/tools/lldb-mi/MICmnMIResultRecord.h
+++ b/tools/lldb-mi/MICmnMIResultRecord.h
@@ -1,9 +1,8 @@
//===-- MICmnMIResultRecord.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIValue.cpp b/tools/lldb-mi/MICmnMIValue.cpp
index 6907b9e19adf8..05ed71e584e0a 100644
--- a/tools/lldb-mi/MICmnMIValue.cpp
+++ b/tools/lldb-mi/MICmnMIValue.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIValue.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValue constructor.
// Type: Method.
// Args: None.
@@ -23,7 +21,6 @@ CMICmnMIValue::CMICmnMIValue()
: m_strValue(MIRSRC(IDS_WORD_INVALIDBRKTS)), m_bJustConstructed(true) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValue destructor.
// Type: Overrideable.
// Args: None.
@@ -33,7 +30,6 @@ CMICmnMIValue::CMICmnMIValue()
CMICmnMIValue::~CMICmnMIValue() {}
//++
-//------------------------------------------------------------------------------------
// Details: Return the MI value as a string. The string is a direct result of
// work done on *this value so if not enough data is added then it is
// possible to return a malformed value. If nothing has been set or
diff --git a/tools/lldb-mi/MICmnMIValue.h b/tools/lldb-mi/MICmnMIValue.h
index 484a818e7f498..8f10c67936166 100644
--- a/tools/lldb-mi/MICmnMIValue.h
+++ b/tools/lldb-mi/MICmnMIValue.h
@@ -1,9 +1,8 @@
//===-- MICmnMIValue.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIValueConst.cpp b/tools/lldb-mi/MICmnMIValueConst.cpp
index 6fe16ab8cca95..1cdbc6487b291 100644
--- a/tools/lldb-mi/MICmnMIValueConst.cpp
+++ b/tools/lldb-mi/MICmnMIValueConst.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIValueConst.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,6 @@
const CMIUtilString CMICmnMIValueConst::ms_constStrDblQuote("\"");
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueConst constructor.
// Type: Method.
// Args: vString - (R) MI Const c-string value.
@@ -27,7 +25,6 @@ CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString)
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueConst constructor.
// Type: Method.
// Args: vString - (R) MI Const c-string value.
@@ -43,7 +40,6 @@ CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString,
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueConst destructor.
// Type: Overrideable.
// Args: None.
@@ -53,7 +49,6 @@ CMICmnMIValueConst::CMICmnMIValueConst(const CMIUtilString &vString,
CMICmnMIValueConst::~CMICmnMIValueConst() {}
//++
-//------------------------------------------------------------------------------------
// Details: Build the Value Const data.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MICmnMIValueConst.h b/tools/lldb-mi/MICmnMIValueConst.h
index 6b2862d5f2575..4bac0864c9cff 100644
--- a/tools/lldb-mi/MICmnMIValueConst.h
+++ b/tools/lldb-mi/MICmnMIValueConst.h
@@ -1,9 +1,8 @@
//===-- MICmnMIValueConst.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIValueList.cpp b/tools/lldb-mi/MICmnMIValueList.cpp
index 28d21dbf3fb37..038d3ae36f02c 100644
--- a/tools/lldb-mi/MICmnMIValueList.cpp
+++ b/tools/lldb-mi/MICmnMIValueList.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIValueList.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueList constructor.
// Type: Method.
// Args: vbValueTypeList - (R) True = yes value type list, false = result
@@ -25,7 +23,6 @@ CMICmnMIValueList::CMICmnMIValueList(const bool vbValueTypeList) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueList constructor.
// Construct a results only list.
// return MIstatus::failure.
@@ -41,7 +38,6 @@ CMICmnMIValueList::CMICmnMIValueList(const CMICmnMIValueResult &vResult) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueList constructor.
// Construct a value only list.
// Type: Method.
@@ -56,7 +52,6 @@ CMICmnMIValueList::CMICmnMIValueList(const CMICmnMIValue &vValue) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueList destructor.
// Type: Overrideable.
// Args: None.
@@ -66,7 +61,6 @@ CMICmnMIValueList::CMICmnMIValueList(const CMICmnMIValue &vValue) {
CMICmnMIValueList::~CMICmnMIValueList() {}
//++
-//------------------------------------------------------------------------------------
// Details: Build the result value's mandatory data part, one tuple
// Type: Method.
// Args: None.
@@ -79,7 +73,6 @@ void CMICmnMIValueList::BuildList() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI result object to the value list's of list is
// results.
// Only result objects can be added to a list of result otherwise this
@@ -95,7 +88,6 @@ void CMICmnMIValueList::Add(const CMICmnMIValueResult &vResult) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI value object to the value list's of list is values.
// Only values objects can be added to a list of values otherwise this
// function
@@ -108,7 +100,6 @@ void CMICmnMIValueList::Add(const CMICmnMIValueResult &vResult) {
void CMICmnMIValueList::Add(const CMICmnMIValue &vValue) { BuildList(vValue); }
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI result object to the value list's of list is
// results.
// Only result objects can be added to a list of result otherwise this
@@ -135,7 +126,6 @@ void CMICmnMIValueList::BuildList(const CMICmnMIValueResult &vResult) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI value object to the value list's of list is values.
// Only values objects can be added to a list of values otherwise this
// function
@@ -165,7 +155,6 @@ void CMICmnMIValueList::BuildList(const CMICmnMIValue &vValue) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the contents of *this value object but without the outer
// most
// brackets.
diff --git a/tools/lldb-mi/MICmnMIValueList.h b/tools/lldb-mi/MICmnMIValueList.h
index 8cf2c38aede61..76062d0b28d2c 100644
--- a/tools/lldb-mi/MICmnMIValueList.h
+++ b/tools/lldb-mi/MICmnMIValueList.h
@@ -1,9 +1,8 @@
//===-- MICmnMIValueList.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIValueResult.cpp b/tools/lldb-mi/MICmnMIValueResult.cpp
index efbf0ddbbfb1a..5ef60741342bf 100644
--- a/tools/lldb-mi/MICmnMIValueResult.cpp
+++ b/tools/lldb-mi/MICmnMIValueResult.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIValueResult.cpp ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("=");
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueResult constructor.
// Type: Method.
// Args: None.
@@ -25,7 +23,6 @@ const CMIUtilString CMICmnMIValueResult::ms_constStrEqual("=");
CMICmnMIValueResult::CMICmnMIValueResult() : m_bEmptyConstruction(true) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueResult constructor.
// Type: Method.
// Args: vrVariable - (R) MI value's name.
@@ -41,7 +38,6 @@ CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable,
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueResult constructor.
// Type: Method.
// Args: vrVariable - (R) MI value's name.
@@ -60,7 +56,6 @@ CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable,
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueResult destructor.
// Type: Overrideable.
// Args: None.
@@ -70,7 +65,6 @@ CMICmnMIValueResult::CMICmnMIValueResult(const CMIUtilString &vrVariable,
CMICmnMIValueResult::~CMICmnMIValueResult() {}
//++
-//------------------------------------------------------------------------------------
// Details: Build the MI value result string.
// Type: Method.
// Args: None.
@@ -85,7 +79,6 @@ void CMICmnMIValueResult::BuildResult() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Build the MI value result string.
// Type: Method.
// Args: vrVariable - (R) MI value's name.
@@ -102,7 +95,6 @@ void CMICmnMIValueResult::BuildResult(const CMIUtilString &vVariable,
}
//++
-//------------------------------------------------------------------------------------
// Details: Append another MI value object to *this MI value result.
// Type: Method.
// Args: vrVariable - (R) MI value's name.
diff --git a/tools/lldb-mi/MICmnMIValueResult.h b/tools/lldb-mi/MICmnMIValueResult.h
index 8a285a99d835d..cfa101b86a5e2 100644
--- a/tools/lldb-mi/MICmnMIValueResult.h
+++ b/tools/lldb-mi/MICmnMIValueResult.h
@@ -1,9 +1,8 @@
-//===-- MICmnMIResult.h -----------------------------------------*- C++ -*-===//
+//===-- MICmnMIValueResult.h ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnMIValueTuple.cpp b/tools/lldb-mi/MICmnMIValueTuple.cpp
index 375ce50416cd2..2f05d219d4fc6 100644
--- a/tools/lldb-mi/MICmnMIValueTuple.cpp
+++ b/tools/lldb-mi/MICmnMIValueTuple.cpp
@@ -1,9 +1,8 @@
//===-- MICmnMIValueTuple.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "MICmnMIValueTuple.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueTuple constructor.
// Type: Method.
// Args: None.
@@ -23,7 +21,6 @@ CMICmnMIValueTuple::CMICmnMIValueTuple() : m_bSpaceAfterComma(false) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueTuple constructor.
// Type: Method.
// Args: vResult - (R) MI result object.
@@ -38,7 +35,6 @@ CMICmnMIValueTuple::CMICmnMIValueTuple(const CMICmnMIValueResult &vResult)
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueTuple constructor.
// Type: Method.
// Args: vResult - (R) MI result object.
@@ -56,7 +52,6 @@ CMICmnMIValueTuple::CMICmnMIValueTuple(const CMICmnMIValueResult &vResult,
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnMIValueTuple destructor.
// Type: Overrideable.
// Args: None.
@@ -66,7 +61,6 @@ CMICmnMIValueTuple::CMICmnMIValueTuple(const CMICmnMIValueResult &vResult,
CMICmnMIValueTuple::~CMICmnMIValueTuple() {}
//++
-//------------------------------------------------------------------------------------
// Details: Build the result value's mandatory data part, one tuple
// Type: Method.
// Args: None.
@@ -79,7 +73,6 @@ void CMICmnMIValueTuple::BuildTuple() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI result object to the value's list of tuples.
// Type: Method.
// Args: vResult - (R) The MI result object.
@@ -108,7 +101,6 @@ void CMICmnMIValueTuple::BuildTuple(const CMICmnMIValueResult &vResult) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add string value to the value's list of tuples.
// Type: Method.
// Args: vValue - (R) The string object.
@@ -130,7 +122,6 @@ void CMICmnMIValueTuple::BuildTuple(const CMIUtilString &vValue) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI value object to the value list's of list is values.
// Only values objects can be added to a list of values otherwise this
// function
@@ -145,7 +136,6 @@ void CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI value object to the value list's of list is values.
// Only values objects can be added to a list of values otherwise this
// function
@@ -164,7 +154,6 @@ void CMICmnMIValueTuple::Add(const CMICmnMIValueResult &vResult,
}
//++
-//------------------------------------------------------------------------------------
// Details: Add another MI value object to the value list's of list is values.
// Only values objects can be added to a list of values otherwise this
// function
@@ -183,7 +172,6 @@ void CMICmnMIValueTuple::Add(const CMICmnMIValueConst &vValue,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the contents of *this value object but without the outer
// most
// brackets.
diff --git a/tools/lldb-mi/MICmnMIValueTuple.h b/tools/lldb-mi/MICmnMIValueTuple.h
index 095de23139bae..4a04fd9214e6e 100644
--- a/tools/lldb-mi/MICmnMIValueTuple.h
+++ b/tools/lldb-mi/MICmnMIValueTuple.h
@@ -1,9 +1,8 @@
//===-- MICmnMIValueTuple.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnResources.cpp b/tools/lldb-mi/MICmnResources.cpp
index d8fa0a8292451..3925f0b01dc54 100644
--- a/tools/lldb-mi/MICmnResources.cpp
+++ b/tools/lldb-mi/MICmnResources.cpp
@@ -1,9 +1,8 @@
//===-- MICmnResources.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -462,7 +461,6 @@ const CMICmnResources::SRsrcTextData
"Command '%s'. Must specify either a PID or a Name"}};
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnResources constructor.
// Type: Method.
// Args: None.
@@ -474,7 +472,6 @@ CMICmnResources::CMICmnResources() : m_nResourceId2TextDataSize(0) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnResources destructor.
// Type: Overridden.
// Args: None.
@@ -486,7 +483,6 @@ CMICmnResources::~CMICmnResources() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize the resources and set locality for the server.
// Type: Method.
// Args: None.
@@ -506,7 +502,6 @@ bool CMICmnResources::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this object.
// Type: Method.
// Args: None.
@@ -530,7 +525,6 @@ bool CMICmnResources::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize the resources and set locality for the server.
// Type: Method.
// Args: None.
@@ -551,7 +545,6 @@ bool CMICmnResources::ReadResourceStringData() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the corresponding text assigned to the resource ID.
// Type: Method.
// Args: vResourceId - (R) MI resource ID.
@@ -568,7 +561,6 @@ CMIUtilString CMICmnResources::GetString(const MIuint vResourceId) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine the MI resource ID existings.
// Type: Method.
// Args: vResourceId - (R) MI resource ID.
@@ -582,7 +574,6 @@ bool CMICmnResources::HasString(const MIuint vResourceId) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the resource text data for the given resource ID. If a
// resource ID
// cannot be found and error is given returning the ID of the resource
diff --git a/tools/lldb-mi/MICmnResources.h b/tools/lldb-mi/MICmnResources.h
index 4177a95a5488e..111b0c33899d6 100644
--- a/tools/lldb-mi/MICmnResources.h
+++ b/tools/lldb-mi/MICmnResources.h
@@ -1,9 +1,8 @@
//===-- MICmnResources.h ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnStreamStderr.cpp b/tools/lldb-mi/MICmnStreamStderr.cpp
index 2bbbd4b505884..f4f6a3ab8fe94 100644
--- a/tools/lldb-mi/MICmnStreamStderr.cpp
+++ b/tools/lldb-mi/MICmnStreamStderr.cpp
@@ -1,10 +1,9 @@
//===-- MICmnStreamStderr.cpp ------------------------------------*- C++
//-*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MIDriver.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnStreamStderr constructor.
// Type: Method.
// Args: None.
@@ -25,7 +23,6 @@
CMICmnStreamStderr::CMICmnStreamStderr() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnStreamStderr destructor.
// Type: Overridable.
// Args: None.
@@ -35,7 +32,6 @@ CMICmnStreamStderr::CMICmnStreamStderr() {}
CMICmnStreamStderr::~CMICmnStreamStderr() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this stderr stream.
// Type: Method.
// Args: None.
@@ -65,7 +61,6 @@ bool CMICmnStreamStderr::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this stderr stream.
// Type: Method.
// Args: None.
@@ -88,7 +83,6 @@ bool CMICmnStreamStderr::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Write text data to stderr. Prefix the message with "MI:". The text
// data does
// not need to include a carriage line return as this is added to the
@@ -115,7 +109,6 @@ bool CMICmnStreamStderr::Write(const CMIUtilString &vText,
}
//++
-//------------------------------------------------------------------------------------
// Details: Write an LLDB text message to stderr.
// The text data does not need to include a carriage line return as
// this is added
@@ -142,7 +135,6 @@ bool CMICmnStreamStderr::WriteLLDBMsg(const CMIUtilString &vText,
}
//++
-//------------------------------------------------------------------------------------
// Details: Write text data to stderr. The text data does not need to
// include a carriage line return as this is added to the text. The
// function also
@@ -189,7 +181,6 @@ bool CMICmnStreamStderr::WritePriv(const CMIUtilString &vText,
}
//++
-//------------------------------------------------------------------------------------
// Details: Lock the availability of the stream stderr. Other users of *this
// stream will
// be stalled until it is available (Unlock()).
@@ -205,7 +196,6 @@ bool CMICmnStreamStderr::Lock() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release a previously locked stderr.
// Type: Method.
// Args: None.
@@ -219,7 +209,6 @@ bool CMICmnStreamStderr::Unlock() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Take MI Driver text message and send to the stderr stream. Also
// output to the
// MI Log file.
@@ -238,7 +227,6 @@ bool CMICmnStreamStderr::TextToStderr(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Take an LLDB message and send to the stderr stream. The message is
// not always
// an error message. The user has typed a command in to the Eclipse
diff --git a/tools/lldb-mi/MICmnStreamStderr.h b/tools/lldb-mi/MICmnStreamStderr.h
index 07943d02c4d0b..65eea440dd7f0 100644
--- a/tools/lldb-mi/MICmnStreamStderr.h
+++ b/tools/lldb-mi/MICmnStreamStderr.h
@@ -1,9 +1,8 @@
//===-- MICmnStreamStderr.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnStreamStdin.cpp b/tools/lldb-mi/MICmnStreamStdin.cpp
index 4d3fa2aabd969..4084b36a89162 100644
--- a/tools/lldb-mi/MICmnStreamStdin.cpp
+++ b/tools/lldb-mi/MICmnStreamStdin.cpp
@@ -1,9 +1,8 @@
//===-- MICmnStreamStdin.cpp ------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -22,7 +21,6 @@
#include "MIUtilSingletonHelper.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnStreamStdin constructor.
// Type: Method.
// Args: None.
@@ -33,7 +31,6 @@ CMICmnStreamStdin::CMICmnStreamStdin()
: m_strPromptCurrent("(gdb)"), m_bShowPrompt(true), m_pCmdBuffer(nullptr) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnStreamStdin destructor.
// Type: Overridable.
// Args: None.
@@ -43,7 +40,6 @@ CMICmnStreamStdin::CMICmnStreamStdin()
CMICmnStreamStdin::~CMICmnStreamStdin() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Stdin stream.
// Type: Method.
// Args: None.
@@ -80,7 +76,6 @@ bool CMICmnStreamStdin::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Stdin stream.
// Type: Method.
// Args: None.
@@ -118,7 +113,6 @@ bool CMICmnStreamStdin::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Validate and set the text that forms the prompt on the command line.
// Type: Method.
// Args: vNewPrompt - (R) Text description.
@@ -140,7 +134,6 @@ bool CMICmnStreamStdin::SetPrompt(const CMIUtilString &vNewPrompt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the command line prompt text currently being used.
// Type: Method.
// Args: None.
@@ -152,7 +145,6 @@ const CMIUtilString &CMICmnStreamStdin::GetPrompt() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set whether to display optional command line prompt. The prompt is
// output to
// stdout. Disable it when this may interfere with the client reading
@@ -170,7 +162,6 @@ void CMICmnStreamStdin::SetEnablePrompt(const bool vbYes) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get whether to display optional command line prompt. The prompt is
// output to
// stdout. Disable it when this may interfere with the client reading
@@ -185,7 +176,6 @@ void CMICmnStreamStdin::SetEnablePrompt(const bool vbYes) {
bool CMICmnStreamStdin::GetEnablePrompt() const { return m_bShowPrompt; }
//++
-//------------------------------------------------------------------------------------
// Details: Wait on new line of data from stdin stream (completed by '\n' or
// '\r').
// Type: Method.
diff --git a/tools/lldb-mi/MICmnStreamStdin.h b/tools/lldb-mi/MICmnStreamStdin.h
index 6483e90c6cbf4..b193757eb7475 100644
--- a/tools/lldb-mi/MICmnStreamStdin.h
+++ b/tools/lldb-mi/MICmnStreamStdin.h
@@ -1,9 +1,8 @@
//===-- MICmnStreamStdin.h --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnStreamStdout.cpp b/tools/lldb-mi/MICmnStreamStdout.cpp
index 064c74fab20cb..4a0e2d16adc1d 100644
--- a/tools/lldb-mi/MICmnStreamStdout.cpp
+++ b/tools/lldb-mi/MICmnStreamStdout.cpp
@@ -1,9 +1,8 @@
//===-- MICmnStreamStdout.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,6 @@
#include "MIDriver.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnStreamStdout constructor.
// Type: Method.
// Args: None.
@@ -24,7 +22,6 @@
CMICmnStreamStdout::CMICmnStreamStdout() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnStreamStdout destructor.
// Type: Overridable.
// Args: None.
@@ -34,7 +31,6 @@ CMICmnStreamStdout::CMICmnStreamStdout() {}
CMICmnStreamStdout::~CMICmnStreamStdout() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize resources for *this Stdout stream.
// Type: Method.
// Args: None.
@@ -64,7 +60,6 @@ bool CMICmnStreamStdout::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this Stdout stream.
// Type: Method.
// Args: None.
@@ -87,7 +82,6 @@ bool CMICmnStreamStdout::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Write an MI format type response to stdout. The text data does not
// need to
// include a carriage line return as this is added to the text. The
@@ -107,7 +101,6 @@ bool CMICmnStreamStdout::WriteMIResponse(const CMIUtilString &vText,
}
//++
-//------------------------------------------------------------------------------------
// Details: Write text data to stdout. The text data does not need to
// include a carriage line return as this is added to the text. The
// function also
@@ -133,7 +126,6 @@ bool CMICmnStreamStdout::Write(const CMIUtilString &vText,
}
//++
-//------------------------------------------------------------------------------------
// Details: Write text data to stdout. The text data does not need to
// include a carriage line return as this is added to the text. The
// function also
@@ -180,7 +172,6 @@ bool CMICmnStreamStdout::WritePriv(const CMIUtilString &vText,
}
//++
-//------------------------------------------------------------------------------------
// Details: Lock the availability of the stream stdout. Other users of *this
// stream will
// be stalled until it is available (Unlock()).
@@ -196,7 +187,6 @@ bool CMICmnStreamStdout::Lock() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release a previously locked stdout.
// Type: Method.
// Args: None.
@@ -210,7 +200,6 @@ bool CMICmnStreamStdout::Unlock() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Take a text data and send to the stdout stream. Also output to the
// MI Log
// file.
@@ -226,7 +215,6 @@ bool CMICmnStreamStdout::TextToStdout(const CMIUtilString &vrTxt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Write prompt to stdout if it's enabled.
// Type: Static method.
// Args: None.
diff --git a/tools/lldb-mi/MICmnStreamStdout.h b/tools/lldb-mi/MICmnStreamStdout.h
index 928dcc2c1c4ea..f73b56ca2ee4d 100644
--- a/tools/lldb-mi/MICmnStreamStdout.h
+++ b/tools/lldb-mi/MICmnStreamStdout.h
@@ -1,9 +1,8 @@
//===-- MICmnStreamStdout.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MICmnThreadMgrStd.cpp b/tools/lldb-mi/MICmnThreadMgrStd.cpp
index efa24d60250aa..25afbbcb5d1c9 100644
--- a/tools/lldb-mi/MICmnThreadMgrStd.cpp
+++ b/tools/lldb-mi/MICmnThreadMgrStd.cpp
@@ -1,9 +1,8 @@
//===-- MICmnThreadMgrStd.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -14,7 +13,6 @@
#include "MIUtilSingletonHelper.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnThreadMgr constructor.
// Type: Method.
// Args: None.
@@ -24,7 +22,6 @@
CMICmnThreadMgrStd::CMICmnThreadMgrStd() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMICmnThreadMgr destructor.
// Type: Method.
// Args: None.
@@ -34,7 +31,6 @@ CMICmnThreadMgrStd::CMICmnThreadMgrStd() {}
CMICmnThreadMgrStd::~CMICmnThreadMgrStd() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialise resources for *this thread manager.
// Type: Method.
// Args: None.
@@ -71,7 +67,6 @@ bool CMICmnThreadMgrStd::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release resources for *this thread manager.
// Type: Method.
// Args: None.
@@ -108,7 +103,6 @@ bool CMICmnThreadMgrStd::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Ask the thread manager to kill all threads and wait until they have
// died
// Type: Method.
@@ -135,7 +129,6 @@ bool CMICmnThreadMgrStd::ThreadAllTerminate() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Add a thread object to *this manager's list of thread objects. The
// list to
// used to manage thread objects centrally.
diff --git a/tools/lldb-mi/MICmnThreadMgrStd.h b/tools/lldb-mi/MICmnThreadMgrStd.h
index 86f5bc7373c9c..ce8dd70525f3c 100644
--- a/tools/lldb-mi/MICmnThreadMgrStd.h
+++ b/tools/lldb-mi/MICmnThreadMgrStd.h
@@ -1,9 +1,8 @@
//===-- MICmnThreadMgrStd.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -65,7 +64,6 @@ private:
};
//++
-//------------------------------------------------------------------------------------
// Details: Given a thread object start its (worker) thread to do work. The
// object is
// added to the *this manager for housekeeping and deletion of all
diff --git a/tools/lldb-mi/MIDataTypes.h b/tools/lldb-mi/MIDataTypes.h
index 59ff099389cb8..c1ed764e46c6f 100644
--- a/tools/lldb-mi/MIDataTypes.h
+++ b/tools/lldb-mi/MIDataTypes.h
@@ -1,9 +1,8 @@
//===-- MIDataTypes.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#pragma once
-//--------------------------------------------------------------------------------------
// Windows headers:
#ifdef _WIN32
@@ -26,7 +24,6 @@
#endif // _WIN32
-//--------------------------------------------------------------------------------------
// Common definitions:
// Function return status
@@ -56,7 +53,6 @@ typedef unsigned int MIuint;
#endif // _WIN32
#endif // _WIN64
-//--------------------------------------------------------------------------------------
// Common types:
// Fundamentals:
diff --git a/tools/lldb-mi/MIDriver.cpp b/tools/lldb-mi/MIDriver.cpp
index cb8fb1c2c25f8..3bf888e303d41 100644
--- a/tools/lldb-mi/MIDriver.cpp
+++ b/tools/lldb-mi/MIDriver.cpp
@@ -1,9 +1,8 @@
//===-- MIDriver.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -44,7 +43,6 @@ const CMIUtilString
const CMIUtilString CMIDriver::ms_constAppNameLong(MIRSRC(IDS_MI_APPNAME_LONG));
//++
-//------------------------------------------------------------------------------------
// Details: CMIDriver constructor.
// Type: Method.
// Args: None.
@@ -53,7 +51,7 @@ const CMIUtilString CMIDriver::ms_constAppNameLong(MIRSRC(IDS_MI_APPNAME_LONG));
//--
CMIDriver::CMIDriver()
: m_bFallThruToOtherDriverEnabled(false), m_bDriverIsExiting(false),
- m_handleMainThread(0), m_rStdin(CMICmnStreamStdin::Instance()),
+ m_handleMainThread(nullptr), m_rStdin(CMICmnStreamStdin::Instance()),
m_rLldbDebugger(CMICmnLLDBDebugger::Instance()),
m_rStdOut(CMICmnStreamStdout::Instance()),
m_eCurrentDriverState(eDriverState_NotRunning),
@@ -62,7 +60,6 @@ CMIDriver::CMIDriver()
m_bHaveCommandFileNamePathOnCmdLine(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIDriver destructor.
// Type: Overridden.
// Args: None.
@@ -72,7 +69,6 @@ CMIDriver::CMIDriver()
CMIDriver::~CMIDriver() {}
//++
-//------------------------------------------------------------------------------------
// Details: Set whether *this driver (the parent) is enabled to pass a command
// to its
// fall through (child) driver to interpret the command and do work
@@ -91,7 +87,6 @@ bool CMIDriver::SetEnableFallThru(const bool vbYes) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get whether *this driver (the parent) is enabled to pass a command
// to its
// fall through (child) driver to interpret the command and do work
@@ -107,7 +102,6 @@ bool CMIDriver::GetEnableFallThru() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve MI's application name of itself.
// Type: Method.
// Args: None.
@@ -119,7 +113,6 @@ const CMIUtilString &CMIDriver::GetAppNameShort() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve MI's application name of itself.
// Type: Method.
// Args: None.
@@ -131,7 +124,6 @@ const CMIUtilString &CMIDriver::GetAppNameLong() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve MI's version description of itself.
// Type: Method.
// Args: None.
@@ -143,7 +135,6 @@ const CMIUtilString &CMIDriver::GetVersionDescription() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Initialize setup *this driver ready for use.
// Type: Method.
// Args: None.
@@ -192,7 +183,6 @@ bool CMIDriver::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Unbind detach or release resources used by *this driver.
// Type: Method.
// Args: None.
@@ -239,7 +229,6 @@ bool CMIDriver::Shutdown() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Work function. Client (the driver's user) is able to append their
// own message
// in to the MI's Log trace file.
@@ -256,7 +245,6 @@ bool CMIDriver::WriteMessageToLog(const CMIUtilString &vMessage) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDriverMgr calls *this driver initialize setup ready for use.
// Type: Overridden.
// Args: None.
@@ -267,7 +255,6 @@ bool CMIDriver::WriteMessageToLog(const CMIUtilString &vMessage) {
bool CMIDriver::DoInitialize() { return CMIDriver::Instance().Initialize(); }
//++
-//------------------------------------------------------------------------------------
// Details: CDriverMgr calls *this driver to unbind detach or release resources
// used by
// *this driver.
@@ -280,7 +267,6 @@ bool CMIDriver::DoInitialize() { return CMIDriver::Instance().Initialize(); }
bool CMIDriver::DoShutdown() { return CMIDriver::Instance().Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the name for *this driver.
// Type: Overridden.
// Args: None.
@@ -297,7 +283,6 @@ const CMIUtilString &CMIDriver::GetName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve *this driver's last error condition.
// Type: Overridden.
// Args: None.
@@ -307,7 +292,6 @@ const CMIUtilString &CMIDriver::GetName() const {
CMIUtilString CMIDriver::GetError() const { return GetErrorDescription(); }
//++
-//------------------------------------------------------------------------------------
// Details: Call *this driver to return it's debugger.
// Type: Overridden.
// Args: None.
@@ -319,7 +303,6 @@ lldb::SBDebugger &CMIDriver::GetTheDebugger() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Specify another driver *this driver can call should this driver not
// be able
// to handle the client data input. DoFallThruToAnotherDriver() makes
@@ -337,7 +320,6 @@ bool CMIDriver::SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Proxy function CMIDriverMgr IDriver interface implementation. *this
// driver's
// implementation called from here to match the existing function name
@@ -374,7 +356,6 @@ lldb::SBError CMIDriver::DoParseArgs(const int argc, const char *argv[],
}
//++
-//------------------------------------------------------------------------------------
// Details: Check the arguments that were passed to this program to make sure
// they are
// valid and to get their argument values (if any). The following are
@@ -484,7 +465,6 @@ lldb::SBError CMIDriver::ParseArgs(const int argc, const char *argv[],
}
//++
-//------------------------------------------------------------------------------------
// Details: A client can ask if *this driver is GDB/MI compatible.
// Type: Overridden.
// Args: None.
@@ -495,7 +475,6 @@ lldb::SBError CMIDriver::ParseArgs(const int argc, const char *argv[],
bool CMIDriver::GetDriverIsGDBMICompatibleDriver() const { return true; }
//++
-//------------------------------------------------------------------------------------
// Details: Start worker threads for the driver.
// Type: Method.
// Args: None.
@@ -522,7 +501,6 @@ bool CMIDriver::StartWorkerThreads() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Stop worker threads for the driver.
// Type: Method.
// Args: None.
@@ -536,7 +514,6 @@ bool CMIDriver::StopWorkerThreads() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Call this function puts *this driver to work.
// This function is used by the application's main thread.
// Type: Overridden.
@@ -611,7 +588,6 @@ bool CMIDriver::DoMainLoop() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set things in motion, set state etc that brings *this driver (and
// the
// application) to a tidy shutdown.
@@ -635,7 +611,6 @@ bool CMIDriver::DoAppQuit() {
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver passes text commands to a fall through driver is it
// does not
// understand them (the LLDB driver).
@@ -687,7 +662,6 @@ bool CMIDriver::InterpretCommandFallThruDriver(const CMIUtilString &vTextLine,
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the name for *this driver.
// Type: Overridden.
// Args: None.
@@ -697,7 +671,6 @@ bool CMIDriver::InterpretCommandFallThruDriver(const CMIUtilString &vTextLine,
const CMIUtilString &CMIDriver::GetDriverName() const { return GetName(); }
//++
-//------------------------------------------------------------------------------------
// Details: Get the unique ID for *this driver.
// Type: Overridden.
// Args: None.
@@ -707,7 +680,6 @@ const CMIUtilString &CMIDriver::GetDriverName() const { return GetName(); }
const CMIUtilString &CMIDriver::GetDriverId() const { return GetId(); }
//++
-//------------------------------------------------------------------------------------
// Details: This function allows *this driver to call on another driver to
// perform work
// should this driver not be able to handle the client data input.
@@ -732,7 +704,6 @@ bool CMIDriver::DoFallThruToAnotherDriver(const CMIUtilString &vCmd,
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver provides a file stream to other drivers on which *this
// driver
// write's out to and they read as expected input. *this driver is
@@ -753,7 +724,6 @@ FILE *CMIDriver::GetStdin() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver provides a file stream to other pass through assigned
// drivers
// so they know what to write to.
@@ -767,11 +737,10 @@ FILE *CMIDriver::GetStdout() const {
// available before *this driver has been initialized! Flaw?
// Do not want to pass through driver to write to stdout
- return NULL;
+ return nullptr;
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver provides a error file stream to other pass through
// assigned drivers
// so they know what to write to.
@@ -790,7 +759,6 @@ FILE *CMIDriver::GetStderr() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set a unique ID for *this driver. It cannot be empty.
// Type: Overridden.
// Args: vId - (R) Text description.
@@ -810,7 +778,6 @@ bool CMIDriver::SetId(const CMIUtilString &vId) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get the unique ID for *this driver.
// Type: Overridden.
// Args: None.
@@ -820,7 +787,6 @@ bool CMIDriver::SetId(const CMIUtilString &vId) {
const CMIUtilString &CMIDriver::GetId() const { return m_strDriverId; }
//++
-//------------------------------------------------------------------------------------
// Details: Interpret the text data and match against current commands to see if
// there
// is a match. If a match then the command is issued and actioned on.
@@ -850,7 +816,6 @@ bool CMIDriver::InterpretCommand(const CMIUtilString &vTextLine) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Helper function for CMIDriver::InterpretCommandThisDriver.
// Convert a CLI command to MI command (just wrap any CLI command
// into "<tokens>-interpreter-exec command \"<CLI command>\"").
@@ -926,7 +891,6 @@ CMIDriver::WrapCLICommandIntoMICommand(const CMIUtilString &vTextLine) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Interpret the text data and match against current commands to see if
// there
// is a match. If a match then the command is issued and actioned on.
@@ -999,7 +963,6 @@ bool CMIDriver::InterpretCommandThisDriver(const CMIUtilString &vTextLine,
}
//++
-//------------------------------------------------------------------------------------
// Details: Having previously had the potential command validated and found
// valid now
// get the command executed.
@@ -1016,7 +979,6 @@ bool CMIDriver::ExecuteCommand(const SMICmdData &vCmdData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the MI Driver's exit application flag. The application checks
// this flag
// after every stdin line is read so the exit may not be instantaneous.
@@ -1049,7 +1011,6 @@ void CMIDriver::SetExitApplicationFlag(const bool vbForceExit) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get the MI Driver's exit exit application flag.
// This is related to the running state of the MI driver.
// Type: Method.
@@ -1061,7 +1022,6 @@ void CMIDriver::SetExitApplicationFlag(const bool vbForceExit) {
bool CMIDriver::GetExitApplicationFlag() const { return m_bExitApp; }
//++
-//------------------------------------------------------------------------------------
// Details: Get the current running state of the MI Driver.
// Type: Method.
// Args: None.
@@ -1073,7 +1033,6 @@ CMIDriver::DriverState_e CMIDriver::GetCurrentDriverState() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the current running state of the MI Driver to running and
// currently not in
// a debug session.
@@ -1120,7 +1079,6 @@ bool CMIDriver::SetDriverStateRunningNotDebugging() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the current running state of the MI Driver to running and
// currently not in
// a debug session. The driver's state must in the state running and in
@@ -1169,7 +1127,6 @@ bool CMIDriver::SetDriverStateRunningDebugging() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Prepare the client IDE so it will start working/communicating with
// *this MI
// driver.
@@ -1185,7 +1142,6 @@ bool CMIDriver::InitClientIDEToMIDriver() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: The IDE Eclipse when debugging locally expects "(gdb)\n" character
// sequence otherwise it refuses to communicate and times out. This
// should be
@@ -1201,7 +1157,6 @@ bool CMIDriver::InitClientIDEEclipse() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Ask *this driver whether it found an executable in the MI Driver's
// list of
// arguments which to open and debug. If so instigate commands to set
@@ -1220,7 +1175,6 @@ bool CMIDriver::HaveExecutableFileNamePathOnCmdLine() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve from *this driver executable file name path to start a
// debug session
// with (if present see HaveExecutableFileNamePathOnCmdLine()).
@@ -1234,7 +1188,6 @@ const CMIUtilString &CMIDriver::GetExecutableFileNamePathOnCmdLine() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Execute commands (by injecting them into the stdin line queue
// container) and
// other code to set up the MI Driver such that is can take the
@@ -1257,7 +1210,6 @@ bool CMIDriver::LocalDebugSessionStartupExecuteCommands() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the MI Driver into "its debugging an executable passed as an
// argument"
// mode as against running via a client like Eclipse.
@@ -1271,7 +1223,6 @@ void CMIDriver::SetDriverDebuggingArgExecutable() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the MI Driver state indicating if it is operating in "its
// debugging
// an executable passed as an argument" mode as against running via a
@@ -1287,7 +1238,6 @@ bool CMIDriver::IsDriverDebuggingArgExecutable() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Execute commands from command source file in specified mode, and
// set exit-flag if needed.
// Type: Method.
@@ -1353,7 +1303,6 @@ bool CMIDriver::ExecuteCommandFile(const bool vbAsyncMode) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Gets called when lldb-mi gets a signal. Stops the process if it was
// SIGINT.
//
diff --git a/tools/lldb-mi/MIDriver.h b/tools/lldb-mi/MIDriver.h
index 1b5865697da77..03bbb3e751519 100644
--- a/tools/lldb-mi/MIDriver.h
+++ b/tools/lldb-mi/MIDriver.h
@@ -1,9 +1,8 @@
//===-- MIDriver.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIDriverBase.cpp b/tools/lldb-mi/MIDriverBase.cpp
index f70da6ea08e10..b8844e288430f 100644
--- a/tools/lldb-mi/MIDriverBase.cpp
+++ b/tools/lldb-mi/MIDriverBase.cpp
@@ -1,9 +1,8 @@
//===-- MIDriverBase.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MIDriverBase.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIDriverBase constructor.
// Type: Method.
// Args: None.
@@ -26,17 +24,15 @@ CMIDriverBase::CMIDriverBase()
: m_pDriverFallThru(nullptr), m_pDriverParent(nullptr), m_bExitApp(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIDriverBase destructor.
// Type: Overrideable.
// Args: None.
// Return: None.
// Throws: None.
//--
-CMIDriverBase::~CMIDriverBase() { m_pDriverFallThru = NULL; }
+CMIDriverBase::~CMIDriverBase() { m_pDriverFallThru = nullptr; }
//++
-//------------------------------------------------------------------------------------
// Details: This function allows *this driver to call on another driver to
// perform work
// should this driver not be able to handle the client data input.
@@ -56,7 +52,6 @@ bool CMIDriverBase::DoFallThruToAnotherDriver(const CMIUtilString &vCmd,
}
//++
-//------------------------------------------------------------------------------------
// Details: This function allows *this driver to call on another driver to
// perform work
// should this driver not be able to handle the client data input.
@@ -75,7 +70,6 @@ bool CMIDriverBase::SetDriverToFallThruTo(const CMIDriverBase &vrOtherDriver) {
}
//++
-//------------------------------------------------------------------------------------
// Details: This function allows *this driver to call functionality on the
// parent driver
// ask for information for example.
@@ -94,7 +88,6 @@ bool CMIDriverBase::SetDriverParent(const CMIDriverBase &vrOtherDriver) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the parent driver to *this driver if one assigned. If
// assigned *this
// is the pass through driver that the parent driver passes work to.
@@ -109,7 +102,6 @@ CMIDriverBase *CMIDriverBase::GetDriversParent() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the pointer to the other fall through driver *this driver
// is using
// (or not using).
@@ -124,7 +116,6 @@ CMIDriverBase *CMIDriverBase::GetDriverToFallThruTo() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver provides a file stream to other drivers on which *this
// driver
// write's out to and they read as expected input. *this driver is
@@ -141,7 +132,6 @@ FILE *CMIDriverBase::GetStdin() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver provides a file stream to other pass through assigned
// drivers
// so they know what to write to.
@@ -156,7 +146,6 @@ FILE *CMIDriverBase::GetStdout() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: *this driver provides a error file stream to other pass through
// assigned drivers
// so they know what to write to.
@@ -171,7 +160,6 @@ FILE *CMIDriverBase::GetStderr() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set the MI Driver's exit application flag. The application checks
// this flag
// after every stdin line is read so the exit may not be instantaneous.
diff --git a/tools/lldb-mi/MIDriverBase.h b/tools/lldb-mi/MIDriverBase.h
index 8ac49ecd88df4..aec306e4b40ad 100644
--- a/tools/lldb-mi/MIDriverBase.h
+++ b/tools/lldb-mi/MIDriverBase.h
@@ -1,9 +1,8 @@
//===-- MIDriverBase.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIDriverMain.cpp b/tools/lldb-mi/MIDriverMain.cpp
index d347ecbbebeba..8bc4571a458d7 100644
--- a/tools/lldb-mi/MIDriverMain.cpp
+++ b/tools/lldb-mi/MIDriverMain.cpp
@@ -1,9 +1,8 @@
//===-- MIDriverMain.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -52,7 +51,6 @@
// CODETAG_IOR_SIGNALS
//++
-//------------------------------------------------------------------------------------
// Details: The SIGINT signal is sent to a process by its controlling terminal
// when a
// user wishes to interrupt the process. This is typically initiated by
@@ -86,7 +84,6 @@ void sigint_handler(int vSigno) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Init the MI driver system. Initialize the whole driver system which
// includes
// both the original LLDB driver and the MI driver.
@@ -112,7 +109,6 @@ bool DriverSystemInit() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Shutdown the debugger system. Release / terminate resources external
// to
// specifically the MI driver.
@@ -132,7 +128,6 @@ bool DriverSystemShutdown(const bool vbAppExitOk) {
}
//++
-//------------------------------------------------------------------------------------
// Details: MI's application start point of execution. The application runs in
// two modes.
// An LLDB native driver mode where it acts no different from the LLDB
diff --git a/tools/lldb-mi/MIDriverMgr.cpp b/tools/lldb-mi/MIDriverMgr.cpp
index 93070a5912d62..26195cdb74141 100644
--- a/tools/lldb-mi/MIDriverMgr.cpp
+++ b/tools/lldb-mi/MIDriverMgr.cpp
@@ -1,9 +1,8 @@
//===-- MIDriverMgr.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,7 +19,6 @@
#include "MIUtilSingletonHelper.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIDriverMgr constructor.
// Type: Method.
// Args: None.
@@ -30,7 +28,6 @@
CMIDriverMgr::CMIDriverMgr() : m_pDriverCurrent(nullptr), m_bInMi2Mode(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIDriverMgr destructor.
// Type: Overridden.
// Args: None.
@@ -40,7 +37,6 @@ CMIDriverMgr::CMIDriverMgr() : m_pDriverCurrent(nullptr), m_bInMi2Mode(false) {}
CMIDriverMgr::~CMIDriverMgr() { Shutdown(); }
//++
-//------------------------------------------------------------------------------------
// Details: Initialize *this manager.
// Type: Method.
// Args: None.
@@ -77,7 +73,6 @@ bool CMIDriverMgr::Initialize() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Unbind detach or release resources used by this server in general
// common
// functionality shared between versions of any server interfaces
@@ -120,7 +115,6 @@ bool CMIDriverMgr::Shutdown() {
return bOk;
}
//++
-//------------------------------------------------------------------------------------
// Details: Unregister all the Driver registered with *this manager. The manager
// also
// deletes
@@ -141,13 +135,12 @@ bool CMIDriverMgr::UnregisterDriverAll() {
}
m_mapDriverIdToDriver.clear();
- m_pDriverCurrent = NULL;
+ m_pDriverCurrent = nullptr;
return MIstatus::success;
}
//++
-//------------------------------------------------------------------------------------
// Details: Register a driver with *this Driver Manager. Call
// SetUseThisDriverToDoWork()
// inform the manager which driver is the one to the work. The manager
@@ -184,7 +177,6 @@ bool CMIDriverMgr::RegisterDriver(const IDriver &vrDriver,
}
//++
-//------------------------------------------------------------------------------------
// Details: Query the Driver Manager to see if *this manager has the driver
// already
// registered.
@@ -209,7 +201,6 @@ bool CMIDriverMgr::HaveDriverAlready(const IDriver &vrDriver) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Unregister a driver from the Driver Manager. Call the
// SetUseThisDriverToDoWork()
// function to define another driver to do work if the one being
@@ -241,7 +232,6 @@ bool CMIDriverMgr::UnregisterDriver(const IDriver &vrDriver) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Specify the driver to do work. The Driver Manager drives this
// driver. Any
// previous driver doing work is not called anymore (so be sure the
@@ -267,7 +257,6 @@ bool CMIDriverMgr::SetUseThisDriverToDoWork(const IDriver &vrADriver) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Ask *this manager which driver is currently doing the work.
// Type: Method.
// Args: None.
@@ -280,7 +269,6 @@ CMIDriverMgr::IDriver *CMIDriverMgr::GetUseThisDriverToDoWork() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Call this function puts *this driver to work.
// Type: Method.
// Args: None.
@@ -307,7 +295,6 @@ bool CMIDriverMgr::DriverMainLoop() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get the current driver to validate executable command line
// arguments.
// Type: Method.
@@ -357,7 +344,6 @@ bool CMIDriverMgr::DriverParseArgs(const int argc, const char *argv[],
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the current driver's last error condition.
// Type: Method.
// Args: None.
@@ -376,7 +362,6 @@ CMIUtilString CMIDriverMgr::DriverGetError() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the current driver's name.
// Type: Method.
// Args: None.
@@ -396,7 +381,6 @@ CMIUtilString CMIDriverMgr::DriverGetName() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the current driver's debugger object.
// Type: Method.
// Args: None.
@@ -417,7 +401,6 @@ lldb::SBDebugger *CMIDriverMgr::DriverGetTheDebugger() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check the arguments given on the command line. The main purpose of
// this
// function is to check for the presence of the --interpreter option.
@@ -494,7 +477,8 @@ bool CMIDriverMgr::ParseArgs(const int argc, const char *argv[],
bOk = bOk && m_pLog->Write(strArgs, CMICmnLog::eLogVerbosity_Log);
} else {
for (MIint i = 1; i < argc; i++) {
- strArgs += CMIUtilString::Format("%d:'%s' ", i, argv[i]);
+ strArgs += CMIUtilString::Format("%d:'%s' ", i,
+ CMIUtilString::WithNullAsEmpty(argv[i]));
}
bOk = bOk && m_pLog->Write(strArgs, CMICmnLog::eLogVerbosity_Log);
}
@@ -605,7 +589,6 @@ bool CMIDriverMgr::ParseArgs(const int argc, const char *argv[],
}
//++
-//------------------------------------------------------------------------------------
// Details: Return formatted application version and name information.
// Type: Method.
// Args: None.
@@ -623,7 +606,6 @@ CMIUtilString CMIDriverMgr::GetAppVersion() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Return formatted help information on all the MI command line
// options.
// Type: Method.
@@ -655,7 +637,6 @@ CMIUtilString CMIDriverMgr::GetHelpOnCmdLineArgOptions() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Search the registered drivers and return the first driver which says
// it is
// GDB/MI compatible i.e. the CMIDriver class.
@@ -684,7 +665,6 @@ CMIDriverMgr::IDriver *CMIDriverMgr::GetFirstMIDriver() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Search the registered drivers and return the first driver which says
// it is
// not GDB/MI compatible i.e. the LLDB Driver class.
@@ -713,7 +693,6 @@ CMIDriverMgr::IDriver *CMIDriverMgr::GetFirstNonMIDriver() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Search the registered drivers and return driver with the specified
// ID.
// Type: Method.
@@ -734,7 +713,6 @@ CMIDriverMgr::GetDriver(const CMIUtilString &vrDriverId) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Gets called when lldb-mi gets a signal. Passed signal to current
// driver.
//
diff --git a/tools/lldb-mi/MIDriverMgr.h b/tools/lldb-mi/MIDriverMgr.h
index dbdc4194e19dc..a7a1dbbb9bf2f 100644
--- a/tools/lldb-mi/MIDriverMgr.h
+++ b/tools/lldb-mi/MIDriverMgr.h
@@ -1,9 +1,8 @@
//===-- MIDriverMgr.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilDateTimeStd.cpp b/tools/lldb-mi/MIUtilDateTimeStd.cpp
index e06eadd6b6a08..e92250a4f2d2e 100644
--- a/tools/lldb-mi/MIUtilDateTimeStd.cpp
+++ b/tools/lldb-mi/MIUtilDateTimeStd.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilDateTimeStd.cpp -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,7 +11,6 @@
#include "MICmnResources.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilDateTimeStd constructor.
// Type: Method.
// Args: None.
@@ -22,7 +20,6 @@
CMIUtilDateTimeStd::CMIUtilDateTimeStd() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilDateTimeStd destructor.
// Type: Method.
// Args: None.
@@ -32,7 +29,6 @@ CMIUtilDateTimeStd::CMIUtilDateTimeStd() {}
CMIUtilDateTimeStd::~CMIUtilDateTimeStd() {}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve system local current date. Format is MM/DD/YYYY.
// Type: Method.
// Args: None.
@@ -51,7 +47,6 @@ CMIUtilString CMIUtilDateTimeStd::GetDate() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve system local current time. Format is HH:MM:SS 24 hour
// clock.
// Type: Method.
@@ -71,7 +66,6 @@ CMIUtilString CMIUtilDateTimeStd::GetTime() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve system local current date and time in yyyy-MM-dd--HH-mm-ss
// format for log file names.
// Type: Method.
diff --git a/tools/lldb-mi/MIUtilDateTimeStd.h b/tools/lldb-mi/MIUtilDateTimeStd.h
index 7afece807ebfc..1a8e30c5654f9 100644
--- a/tools/lldb-mi/MIUtilDateTimeStd.h
+++ b/tools/lldb-mi/MIUtilDateTimeStd.h
@@ -1,9 +1,8 @@
//===-- MIUtilDateTimeStd.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilDebug.cpp b/tools/lldb-mi/MIUtilDebug.cpp
index 598a1a71046b9..4b418f390ca73 100644
--- a/tools/lldb-mi/MIUtilDebug.cpp
+++ b/tools/lldb-mi/MIUtilDebug.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilDebug.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -18,7 +17,6 @@
#include "MIUtilDebug.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilDebug constructor.
// Type: Method.
// Args: None.
@@ -28,7 +26,6 @@
CMIUtilDebug::CMIUtilDebug() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilDebug destructor.
// Type: Method.
// Args: None.
@@ -38,7 +35,6 @@ CMIUtilDebug::CMIUtilDebug() {}
CMIUtilDebug::~CMIUtilDebug() {}
//++
-//------------------------------------------------------------------------------------
// Details: Temporarily stall the process/application to give the programmer the
// opportunity to attach a debugger. How to use: Put a break in the
// programmer
@@ -62,16 +58,12 @@ void CMIUtilDebug::WaitForDbgAttachInfinteLoop() {
}
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
// Instantiations:
CMICmnLog &CMIUtilDebugFnTrace::ms_rLog = CMICmnLog::Instance();
MIuint CMIUtilDebugFnTrace::ms_fnDepthCnt = 0;
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilDebugFnTrace constructor.
// Type: Method.
// Args: vFnName - (R) The text to insert into the log.
@@ -86,7 +78,6 @@ CMIUtilDebugFnTrace::CMIUtilDebugFnTrace(const CMIUtilString &vFnName)
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilDebugFnTrace destructor.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MIUtilDebug.h b/tools/lldb-mi/MIUtilDebug.h
index 16b080ee7b621..537907ae304f2 100644
--- a/tools/lldb-mi/MIUtilDebug.h
+++ b/tools/lldb-mi/MIUtilDebug.h
@@ -1,9 +1,8 @@
//===-- MIUtilDebug.h -------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilFileStd.cpp b/tools/lldb-mi/MIUtilFileStd.cpp
index abf0ef407d3b3..2d8a05985e590 100644
--- a/tools/lldb-mi/MIUtilFileStd.cpp
+++ b/tools/lldb-mi/MIUtilFileStd.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilFileStd.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -19,9 +18,9 @@
#include "lldb/Host/FileSystem.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilFileStd constructor.
// Type: Method.
// Args: None.
@@ -42,7 +41,6 @@ CMIUtilFileStd::CMIUtilFileStd()
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilFileStd destructor.
// Type: Method.
// Args: None.
@@ -52,7 +50,6 @@ CMIUtilFileStd::CMIUtilFileStd()
CMIUtilFileStd::~CMIUtilFileStd() { Close(); }
//++
-//------------------------------------------------------------------------------------
// Details: Open file for writing. On the first call to this function after
// *this object
// is created the file is either created or replace, from then on open
@@ -84,7 +81,8 @@ bool CMIUtilFileStd::CreateWrite(const CMIUtilString &vFileNamePath,
#if !defined(_MSC_VER)
// Open with 'write' and 'binary' mode
- m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb");
+ m_pFileHandle = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+ vFileNamePath.c_str(), "wb");
#else
// Open a file with exclusive write and shared read permissions
std::wstring path;
@@ -110,7 +108,6 @@ bool CMIUtilFileStd::CreateWrite(const CMIUtilString &vFileNamePath,
}
//++
-//------------------------------------------------------------------------------------
// Details: Write data to existing opened file.
// Type: Method.
// Args: vData - (R) Text data.
@@ -148,7 +145,6 @@ bool CMIUtilFileStd::Write(const CMIUtilString &vData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Write data to existing opened file.
// Type: Method.
// Args: vData - (R) Text data.
@@ -185,7 +181,6 @@ bool CMIUtilFileStd::Write(const char *vpData, const MIuint vCharCnt) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Close existing opened file. Note Close() must must an open!
// Type: Method.
// Args: None.
@@ -203,7 +198,6 @@ void CMIUtilFileStd::Close() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve state of whether the file is ok.
// Type: Method.
// Args: None.
@@ -214,7 +208,6 @@ void CMIUtilFileStd::Close() {
bool CMIUtilFileStd::IsOk() const { return !m_bFileError; }
//++
-//------------------------------------------------------------------------------------
// Details: Status on a file existing already.
// Type: Method.
// Args: vFileNamePath.
@@ -227,7 +220,8 @@ bool CMIUtilFileStd::IsFileExist(const CMIUtilString &vFileNamePath) const {
return false;
FILE *pTmp = nullptr;
- pTmp = ::fopen(vFileNamePath.c_str(), "wb");
+ pTmp = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+ vFileNamePath.c_str(), "wb");
if (pTmp != nullptr) {
::fclose(pTmp);
return true;
@@ -237,7 +231,6 @@ bool CMIUtilFileStd::IsFileExist(const CMIUtilString &vFileNamePath) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the file current carriage line return characters used.
// Type: Method.
// Args: None.
@@ -249,7 +242,6 @@ const CMIUtilString &CMIUtilFileStd::GetLineReturn() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Given a file name directory path, strip off the filename and return
// the path.
// It look for either backslash or forward slash.
@@ -273,7 +265,6 @@ CMIUtilFileStd::StripOffFileName(const CMIUtilString &vDirectoryPath) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Return either backslash or forward slash appropriate to the OS this
// application
// is running on.
diff --git a/tools/lldb-mi/MIUtilFileStd.h b/tools/lldb-mi/MIUtilFileStd.h
index 2120cc25e8a03..e2e590b6aaf4f 100644
--- a/tools/lldb-mi/MIUtilFileStd.h
+++ b/tools/lldb-mi/MIUtilFileStd.h
@@ -1,9 +1,8 @@
//===-- MIUtilFileStd.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.cpp b/tools/lldb-mi/MIUtilMapIdToVariant.cpp
index 0a4e7299e9262..9361cedab3e75 100644
--- a/tools/lldb-mi/MIUtilMapIdToVariant.cpp
+++ b/tools/lldb-mi/MIUtilMapIdToVariant.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilMapIdToVariant.cpp --------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "MIUtilMapIdToVariant.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilMapIdToVariant constructor.
// Type: Method.
// Args: None.
@@ -21,7 +19,6 @@
CMIUtilMapIdToVariant::CMIUtilMapIdToVariant() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilMapIdToVariant destructor.
// Type: Method.
// Args: None.
@@ -31,7 +28,6 @@ CMIUtilMapIdToVariant::CMIUtilMapIdToVariant() {}
CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant() {}
//++
-//------------------------------------------------------------------------------------
// Details: Remove at the data from *this container.
// Type: Method.
// Args: None.
@@ -41,7 +37,6 @@ CMIUtilMapIdToVariant::~CMIUtilMapIdToVariant() {}
void CMIUtilMapIdToVariant::Clear() { m_mapKeyToVariantValue.clear(); }
//++
-//------------------------------------------------------------------------------------
// Details: Check an ID is present already in *this container.
// Type: Method.
// Args: vId - (R) Unique ID i.e. GUID.
@@ -56,7 +51,6 @@ bool CMIUtilMapIdToVariant::HaveAlready(const CMIUtilString &vId) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if *this container is currently holding any data.
// Type: Method.
// Args: None.
@@ -68,7 +62,6 @@ bool CMIUtilMapIdToVariant::IsEmpty() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check the ID is valid to be registered.
// Type: Method.
// Args: vId - (R) Unique ID i.e. GUID.
@@ -86,7 +79,6 @@ bool CMIUtilMapIdToVariant::IsValid(const CMIUtilString &vId) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove from *this contain a data object specified by ID. The data
// object
// when removed also calls its destructor should it have one.
diff --git a/tools/lldb-mi/MIUtilMapIdToVariant.h b/tools/lldb-mi/MIUtilMapIdToVariant.h
index a56477c4dba9f..ba3e176e0c41c 100644
--- a/tools/lldb-mi/MIUtilMapIdToVariant.h
+++ b/tools/lldb-mi/MIUtilMapIdToVariant.h
@@ -1,9 +1,8 @@
//===-- MIUtilMapIdToVariant.h ----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -56,7 +55,6 @@ private:
};
//++
-//------------------------------------------------------------------------------------
// Details: Add to *this container a data object of general type identified by
// an ID.
// If the data with that ID already exists in the container it is
@@ -90,7 +88,6 @@ bool CMIUtilMapIdToVariant::Add(const CMIUtilString &vId, const T &vData) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve a data object from *this container identified by the
// specified ID.
// Type: Method.
diff --git a/tools/lldb-mi/MIUtilSingletonBase.h b/tools/lldb-mi/MIUtilSingletonBase.h
index d73627307e5f2..e76fff72b27c3 100644
--- a/tools/lldb-mi/MIUtilSingletonBase.h
+++ b/tools/lldb-mi/MIUtilSingletonBase.h
@@ -1,9 +1,8 @@
//===-- MIUtilSingletonBase.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilSingletonHelper.h b/tools/lldb-mi/MIUtilSingletonHelper.h
index 831c60aecfefb..b9ac61a58e7f7 100644
--- a/tools/lldb-mi/MIUtilSingletonHelper.h
+++ b/tools/lldb-mi/MIUtilSingletonHelper.h
@@ -1,9 +1,8 @@
//===-- MIUtilSingletonHelper.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilString.cpp b/tools/lldb-mi/MIUtilString.cpp
index 627c2f3d4d3b5..986de963450e9 100644
--- a/tools/lldb-mi/MIUtilString.cpp
+++ b/tools/lldb-mi/MIUtilString.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilString.cpp ----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,7 +20,6 @@
#include "MIUtilString.h"
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilString constructor.
// Type: Method.
// Args: None.
@@ -31,17 +29,16 @@
CMIUtilString::CMIUtilString() : std::string() {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilString constructor.
// Type: Method.
// Args: vpData - Pointer to UTF8 text data.
// Return: None.
// Throws: None.
//--
-CMIUtilString::CMIUtilString(const char *vpData) : std::string(vpData) {}
+CMIUtilString::CMIUtilString(const char *vpData)
+ : std::string(WithNullAsEmpty(vpData)) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilString constructor.
// Type: Method.
// Args: vpStr - Text data.
@@ -51,7 +48,6 @@ CMIUtilString::CMIUtilString(const char *vpData) : std::string(vpData) {}
CMIUtilString::CMIUtilString(const std::string &vrStr) : std::string(vrStr) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilString assignment operator.
// Type: Method.
// Args: vpRhs - Pointer to UTF8 text data.
@@ -59,12 +55,11 @@ CMIUtilString::CMIUtilString(const std::string &vrStr) : std::string(vrStr) {}
// Throws: None.
//--
CMIUtilString &CMIUtilString::operator=(const char *vpRhs) {
- assign(vpRhs);
+ assign(WithNullAsEmpty(vpRhs));
return *this;
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilString assignment operator.
// Type: Method.
// Args: vrRhs - The other string to copy from.
@@ -77,7 +72,6 @@ CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilString destructor.
// Type: Method.
// Args: None.
@@ -87,7 +81,6 @@ CMIUtilString &CMIUtilString::operator=(const std::string &vrRhs) {
CMIUtilString::~CMIUtilString() {}
//++
-//------------------------------------------------------------------------------------
// Details: Perform a snprintf format style on a string data. A new string
// object is
// created and returned.
@@ -104,12 +97,10 @@ CMIUtilString CMIUtilString::FormatPriv(const CMIUtilString &vrFormat,
MIint n = vrFormat.size();
// IOR: mysterious crash in this function on some windows builds not able to
- // duplicate
- // but found article which may be related. Crash occurs in vsnprintf() or
- // va_copy()
+ // duplicate but found article which may be related. Crash occurs in
+ // vsnprintf() or va_copy().
// Duplicate vArgs va_list argument pointer to ensure that it can be safely
- // used in
- // a new frame
+ // used in a new frame.
// http://julipedia.meroh.net/2011/09/using-vacopy-to-safely-pass-ap.html
va_list argsDup;
va_copy(argsDup, vArgs);
@@ -128,8 +119,8 @@ CMIUtilString CMIUtilString::FormatPriv(const CMIUtilString &vrFormat,
pFormatted.reset(new char[n + 1]); // +1 for safety margin
::strncpy(&pFormatted[0], vrFormat.c_str(), n);
- // We need to restore the variable argument list pointer to the start again
- // before running vsnprintf() more then once
+ // We need to restore the variable argument list pointer to the start again
+ // before running vsnprintf() more then once
va_copy(argsDup, argsCpy);
nFinal = ::vsnprintf(&pFormatted[0], n, vrFormat.c_str(), argsDup);
@@ -148,7 +139,6 @@ CMIUtilString CMIUtilString::FormatPriv(const CMIUtilString &vrFormat,
}
//++
-//------------------------------------------------------------------------------------
// Details: Perform a snprintf format style on a string data. A new string
// object is
// created and returned.
@@ -161,14 +151,14 @@ CMIUtilString CMIUtilString::FormatPriv(const CMIUtilString &vrFormat,
CMIUtilString CMIUtilString::Format(const char *vFormating, ...) {
va_list args;
va_start(args, vFormating);
- CMIUtilString strResult = CMIUtilString::FormatPriv(vFormating, args);
+ CMIUtilString strResult =
+ CMIUtilString::FormatPriv(WithNullAsEmpty(vFormating), args);
va_end(args);
return strResult;
}
//++
-//------------------------------------------------------------------------------------
// Details: Perform a snprintf format style on a string data. A new string
// object is
// created and returned.
@@ -184,7 +174,6 @@ CMIUtilString CMIUtilString::FormatValist(const CMIUtilString &vrFormating,
}
//++
-//------------------------------------------------------------------------------------
// Details: Splits string into array of strings using delimiter. If multiple
// delimiter
// are found in sequence then they are not added to the list of splits.
@@ -228,7 +217,6 @@ size_t CMIUtilString::Split(const CMIUtilString &vDelimiter,
}
//++
-//------------------------------------------------------------------------------------
// Details: Splits string into array of strings using delimiter. However the
// string is
// also considered for text surrounded by quotes. Text with quotes
@@ -287,7 +275,6 @@ size_t CMIUtilString::SplitConsiderQuotes(const CMIUtilString &vDelimiter,
}
//++
-//------------------------------------------------------------------------------------
// Details: Split string into lines using \n and return an array of strings.
// Type: Method.
// Args: vwVecSplits - (W) Container of splits found in string data.
@@ -299,7 +286,6 @@ size_t CMIUtilString::SplitLines(VecString_t &vwVecSplits) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove '\n' from the end of string if found. It does not alter
// *this string.
// Type: Method.
@@ -318,7 +304,6 @@ CMIUtilString CMIUtilString::StripCREndOfLine() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove all '\n' from the string and replace with a space. It does
// not alter
// *this string.
@@ -332,7 +317,6 @@ CMIUtilString CMIUtilString::StripCRAll() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Find and replace all matches of a sub string with another string. It
// does not
// alter *this string.
@@ -363,7 +347,6 @@ CMIUtilString::FindAndReplace(const CMIUtilString &vFind,
}
//++
-//------------------------------------------------------------------------------------
// Details: Check if *this string is a decimal number.
// Type: Method.
// Args: None.
@@ -382,7 +365,6 @@ bool CMIUtilString::IsNumber() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check if *this string is a hexadecimal number.
// Type: Method.
// Args: None.
@@ -400,7 +382,6 @@ bool CMIUtilString::IsHexadecimalNumber() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Extract the number from the string. The number can be either a
// hexadecimal or
// natural number. It cannot contain other non-numeric characters.
@@ -423,7 +404,6 @@ bool CMIUtilString::ExtractNumber(MIint64 &vwrNumber) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Extract the number from the hexadecimal string..
// Type: Method.
// Args: vwrNumber - (W) Number extracted from the string.
@@ -448,7 +428,6 @@ bool CMIUtilString::ExtractNumberFromHexadecimal(MIint64 &vwrNumber) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if the text is all valid alpha numeric characters. Letters
// can be
// either upper or lower case.
@@ -458,7 +437,7 @@ bool CMIUtilString::ExtractNumberFromHexadecimal(MIint64 &vwrNumber) const {
// Throws: None.
//--
bool CMIUtilString::IsAllValidAlphaAndNumeric(const char *vpText) {
- const size_t len = ::strlen(vpText);
+ const size_t len = ::strlen(WithNullAsEmpty(vpText));
if (len == 0)
return false;
@@ -472,7 +451,6 @@ bool CMIUtilString::IsAllValidAlphaAndNumeric(const char *vpText) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check if two strings share equal contents.
// Type: Method.
// Args: vrLhs - (R) String A.
@@ -490,7 +468,6 @@ bool CMIUtilString::Compare(const CMIUtilString &vrLhs,
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove from either end of *this string the following: " \t\n\v\f\r".
// Type: Method.
// Args: None.
@@ -513,7 +490,6 @@ CMIUtilString CMIUtilString::Trim() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove from either end of *this string the specified character.
// Type: Method.
// Args: None.
@@ -532,7 +508,6 @@ CMIUtilString CMIUtilString::Trim(const char vChar) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Do a printf equivalent for printing a number in binary i.e. "b%llB".
// Type: Static method.
// Args: vnDecimal - (R) The number to represent in binary.
@@ -565,7 +540,6 @@ CMIUtilString CMIUtilString::FormatBinary(const MIuint64 vnDecimal) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove from a string doubled up characters so only one set left.
// Characters
// are only removed if the previous character is already a same
@@ -581,7 +555,6 @@ CMIUtilString CMIUtilString::RemoveRepeatedCharacters(const char vChar) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Recursively remove from a string doubled up characters so only one
// set left.
// Characters are only removed if the previous character is already a
@@ -616,7 +589,6 @@ CMIUtilString CMIUtilString::RemoveRepeatedCharacters(size_t vnPos,
}
//++
-//------------------------------------------------------------------------------------
// Details: Is the text in *this string surrounded by quotes.
// Type: Method.
// Args: None.
@@ -634,7 +606,6 @@ bool CMIUtilString::IsQuoted() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Find first occurrence in *this string which matches the pattern.
// Type: Method.
// Args: vrPattern - (R) The pattern to search for.
@@ -649,7 +620,6 @@ size_t CMIUtilString::FindFirst(const CMIUtilString &vrPattern,
}
//++
-//------------------------------------------------------------------------------------
// Details: Find first occurrence in *this string which matches the pattern and
// isn't surrounded by quotes.
// Type: Method.
@@ -698,7 +668,6 @@ size_t CMIUtilString::FindFirst(const CMIUtilString &vrPattern,
}
//++
-//------------------------------------------------------------------------------------
// Details: Find first occurrence in *this string which doesn't match the
// pattern.
// Type: Method.
@@ -725,7 +694,6 @@ size_t CMIUtilString::FindFirstNot(const CMIUtilString &vrPattern,
}
//++
-//------------------------------------------------------------------------------------
// Details: Find first occurrence of not escaped quotation mark in *this string.
// Type: Method.
// Args: vnPos - Position of the first character in the string to be
@@ -756,7 +724,6 @@ size_t CMIUtilString::FindFirstQuote(size_t vnPos) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get escaped string from *this string.
// Type: Method.
// Args: None.
@@ -778,7 +745,6 @@ CMIUtilString CMIUtilString::Escape(bool vbEscapeQuotes /* = false */) const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Get string with backslashes in front of double quote '"' and
// backslash '\\'
// characters.
@@ -814,7 +780,6 @@ CMIUtilString CMIUtilString::AddSlashes() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Remove backslashes added by CMIUtilString::AddSlashes.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MIUtilString.h b/tools/lldb-mi/MIUtilString.h
index 2639141d0fb28..e9d3af7a6225d 100644
--- a/tools/lldb-mi/MIUtilString.h
+++ b/tools/lldb-mi/MIUtilString.h
@@ -1,9 +1,8 @@
//===-- MIUtilString.h ------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -35,6 +34,9 @@ public:
static CMIUtilString FormatValist(const CMIUtilString &vrFormating,
va_list vArgs);
static bool IsAllValidAlphaAndNumeric(const char *vpText);
+ static const char *WithNullAsEmpty(const char *vpText) {
+ return vpText ? vpText : "";
+ }
static bool Compare(const CMIUtilString &vrLhs, const CMIUtilString &vrRhs);
static CMIUtilString ConvertToPrintableASCII(const char vChar,
bool bEscapeQuotes = false);
diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.cpp b/tools/lldb-mi/MIUtilThreadBaseStd.cpp
index 85780083a5a5c..72cf1474a78b7 100644
--- a/tools/lldb-mi/MIUtilThreadBaseStd.cpp
+++ b/tools/lldb-mi/MIUtilThreadBaseStd.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilThreadBaseStd.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,7 +14,6 @@
#include "MIUtilThreadBaseStd.h"
//++
-//------------------------------------------------------------------------------------
// Details: Constructor.
// Type: None.
// Args: None.
@@ -26,7 +24,6 @@ CMIUtilThreadActiveObjBase::CMIUtilThreadActiveObjBase()
: m_references(0), m_bHasBeenKilled(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: Destructor.
// Type: None.
// Args: None.
@@ -39,7 +36,6 @@ CMIUtilThreadActiveObjBase::~CMIUtilThreadActiveObjBase() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Check if an object is already running.
// Type: Method.
// Args: None.
@@ -53,7 +49,6 @@ bool CMIUtilThreadActiveObjBase::ThreadIsActive() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set up *this thread.
// Type: Method.
// Args: None.
@@ -67,7 +62,6 @@ bool CMIUtilThreadActiveObjBase::ThreadExecute() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Acquire a reference to CMIUtilThreadActiveObjBase.
// Type: Method.
// Args: None.
@@ -86,7 +80,6 @@ bool CMIUtilThreadActiveObjBase::Acquire() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release a reference to CMIUtilThreadActiveObjBase.
// Type: Method.
// Args: None.
@@ -105,7 +98,6 @@ bool CMIUtilThreadActiveObjBase::Release() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Force this thread to stop, regardless of references
// Type: Method.
// Args: None.
@@ -124,7 +116,6 @@ bool CMIUtilThreadActiveObjBase::ThreadKill() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Proxy to thread join.
// Type: Method.
// Args: None.
@@ -135,7 +126,6 @@ bool CMIUtilThreadActiveObjBase::ThreadKill() {
bool CMIUtilThreadActiveObjBase::ThreadJoin() { return m_thread.Join(); }
//++
-//------------------------------------------------------------------------------------
// Details: This function is the entry point of this object thread.
// It is a trampoline to an instances operation manager.
// Type: Static method.
@@ -159,7 +149,6 @@ MIuint CMIUtilThreadActiveObjBase::ThreadEntry(void *vpThisClass) {
}
//++
-//------------------------------------------------------------------------------------
// Details: This function forms a small management routine, to handle the
// thread's running.
// Type: Method.
@@ -197,15 +186,11 @@ void CMIUtilThreadActiveObjBase::ThreadManage() {
m_thread.Finish();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//
CMIUtilThread::CMIUtilThread() : m_pThread(nullptr), m_bIsActive(false) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilThread destructor.
// Type: Method.
// Args: None.
@@ -215,7 +200,6 @@ CMIUtilThread::CMIUtilThread() : m_pThread(nullptr), m_bIsActive(false) {}
CMIUtilThread::~CMIUtilThread() { Join(); }
//++
-//------------------------------------------------------------------------------------
// Details: Wait for thread to stop.
// Type: Method.
// Args: None.
@@ -240,7 +224,6 @@ bool CMIUtilThread::Join() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Is the thread doing work.
// Type: Method.
// Args: None.
@@ -254,7 +237,6 @@ bool CMIUtilThread::IsActive() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Finish this thread
// Type: Method.
// Args: None.
@@ -268,7 +250,6 @@ void CMIUtilThread::Finish() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Set up *this thread.
// Type: Method.
// Args: vpFn (R) - Function pointer to thread's main function.
@@ -291,12 +272,8 @@ bool CMIUtilThread::Start(FnThreadProc vpFn, void *vpArg) {
return MIstatus::success;
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: Take resource.
// Type: Method.
// Args: None.
@@ -306,7 +283,6 @@ bool CMIUtilThread::Start(FnThreadProc vpFn, void *vpArg) {
void CMIUtilThreadMutex::Lock() { m_mutex.lock(); }
//++
-//------------------------------------------------------------------------------------
// Details: Release resource.
// Type: Method.
// Args: None.
@@ -316,7 +292,6 @@ void CMIUtilThreadMutex::Lock() { m_mutex.lock(); }
void CMIUtilThreadMutex::Unlock() { m_mutex.unlock(); }
//++
-//------------------------------------------------------------------------------------
// Details: Take resource if available. Immediately return in either case.
// Type: Method.
// Args: None.
diff --git a/tools/lldb-mi/MIUtilThreadBaseStd.h b/tools/lldb-mi/MIUtilThreadBaseStd.h
index 20b8fad9947a7..3fa03b6f072e9 100644
--- a/tools/lldb-mi/MIUtilThreadBaseStd.h
+++ b/tools/lldb-mi/MIUtilThreadBaseStd.h
@@ -1,9 +1,8 @@
//===-- MIUtilThreadBaseStd.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-mi/MIUtilVariant.cpp b/tools/lldb-mi/MIUtilVariant.cpp
index c317e3e687f2f..062dce80c4b99 100644
--- a/tools/lldb-mi/MIUtilVariant.cpp
+++ b/tools/lldb-mi/MIUtilVariant.cpp
@@ -1,9 +1,8 @@
//===-- MIUtilVariant.cpp----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -11,7 +10,6 @@
#include "MIUtilVariant.h"
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase constructor.
// Type: Method.
// Args: None.
@@ -21,7 +19,6 @@
CMIUtilVariant::CDataObjectBase::CDataObjectBase() {}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase copy constructor.
// Type: Method.
// Args: vrOther - (R) The other object.
@@ -34,7 +31,6 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase(
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase copy constructor.
// Type: Method.
// Args: vrOther - (R) The other object.
@@ -46,7 +42,6 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase move constructor.
// Type: Method.
// Args: vrwOther - (R) The other object.
@@ -58,7 +53,6 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &&vrwOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase destructor.
// Type: Overrideable.
// Args: None.
@@ -68,7 +62,6 @@ CMIUtilVariant::CDataObjectBase::CDataObjectBase(CDataObjectBase &&vrwOther) {
CMIUtilVariant::CDataObjectBase::~CDataObjectBase() { Destroy(); }
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase copy assignment.
// Type: Method.
// Args: vrOther - (R) The other object.
@@ -82,7 +75,6 @@ operator=(const CDataObjectBase &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObjectBase move assignment.
// Type: Method.
// Args: vrwOther - (R) The other object.
@@ -97,7 +89,6 @@ operator=(CDataObjectBase &&vrwOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Create a new copy of *this class.
// Type: Overrideable.
// Args: None.
@@ -111,7 +102,6 @@ CMIUtilVariant::CDataObjectBase::CreateCopyOfSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if *this object is a derived from CDataObjectBase.
// Type: Overrideable.
// Args: None.
@@ -125,7 +115,6 @@ bool CMIUtilVariant::CDataObjectBase::GetIsDerivedClass() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Perform a bitwise copy of *this object.
// Type: Overrideable.
// Args: vrOther - (R) The other object.
@@ -138,7 +127,6 @@ void CMIUtilVariant::CDataObjectBase::Copy(const CDataObjectBase &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release any resources used by *this object.
// Type: Overrideable.
// Args: None.
@@ -149,12 +137,8 @@ void CMIUtilVariant::CDataObjectBase::Destroy() {
// Do nothing - override to implement
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject copy constructor.
// Type: Method.
// Args: T - The object's type.
@@ -170,7 +154,6 @@ CMIUtilVariant::CDataObject<T>::CDataObject(const CDataObject &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject copy constructor.
// Type: Method.
// Args: T - The object's type.
@@ -186,7 +169,6 @@ CMIUtilVariant::CDataObject<T>::CDataObject(CDataObject &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject move constructor.
// Type: Method.
// Args: T - The object's type.
@@ -203,7 +185,6 @@ CMIUtilVariant::CDataObject<T>::CDataObject(CDataObject &&vrwOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject copy assignment.
// Type: Method.
// Args: T - The object's type.
@@ -221,7 +202,6 @@ operator=(const CDataObject &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject move assignment.
// Type: Method.
// Args: T - The object's type.
@@ -239,12 +219,8 @@ operator=(CDataObject &&vrwOther) {
return *this;
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant constructor.
// Type: Method.
// Args: None.
@@ -254,7 +230,6 @@ operator=(CDataObject &&vrwOther) {
CMIUtilVariant::CMIUtilVariant() : m_pDataObject(nullptr) {}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant copy constructor.
// Type: Method.
// Args: vrOther - (R) The other object.
@@ -270,7 +245,6 @@ CMIUtilVariant::CMIUtilVariant(const CMIUtilVariant &vrOther)
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant copy constructor.
// Type: Method.
// Args: vrOther - (R) The other object.
@@ -286,7 +260,6 @@ CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &vrOther)
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant move constructor.
// Type: Method.
// Args: vrwOther - (R) The other object.
@@ -303,7 +276,6 @@ CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &&vrwOther)
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant destructor.
// Type: Method.
// Args: None.
@@ -313,7 +285,6 @@ CMIUtilVariant::CMIUtilVariant(CMIUtilVariant &&vrwOther)
CMIUtilVariant::~CMIUtilVariant() { Destroy(); }
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant copy assignment.
// Type: Method.
// Args: vrOther - (R) The other object.
@@ -329,7 +300,6 @@ CMIUtilVariant &CMIUtilVariant::operator=(const CMIUtilVariant &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CMIUtilVariant move assignment.
// Type: Method.
// Args: vrwOther - (R) The other object.
@@ -346,7 +316,6 @@ CMIUtilVariant &CMIUtilVariant::operator=(CMIUtilVariant &&vrwOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release the resources used by *this object.
// Type: Method.
// Args: None.
@@ -360,7 +329,6 @@ void CMIUtilVariant::Destroy() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Bitwise copy another data object to *this variant object.
// Type: Method.
// Args: vrOther - (R) The other object.
diff --git a/tools/lldb-mi/MIUtilVariant.h b/tools/lldb-mi/MIUtilVariant.h
index 01dd615aad675..4c9db33021b50 100644
--- a/tools/lldb-mi/MIUtilVariant.h
+++ b/tools/lldb-mi/MIUtilVariant.h
@@ -1,9 +1,8 @@
//===-- MIUtilVariant.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -117,12 +116,8 @@ private:
CDataObjectBase *m_pDataObject;
};
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject constructor.
// Type: Method.
// Args: T - The object's type.
@@ -132,7 +127,6 @@ private:
template <typename T> CMIUtilVariant::CDataObject<T>::CDataObject() {}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject constructor.
// Type: Method.
// Args: T - The object's type.
@@ -146,7 +140,6 @@ CMIUtilVariant::CDataObject<T>::CDataObject(const T &vArg) {
}
//++
-//------------------------------------------------------------------------------------
// Details: CDataObject destructor.
// Type: Overridden.
// Args: T - The object's type.
@@ -158,7 +151,6 @@ template <typename T> CMIUtilVariant::CDataObject<T>::~CDataObject() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the data object hold by *this object wrapper.
// Type: Method.
// Args: T - The object's type.
@@ -170,7 +162,6 @@ template <typename T> T &CMIUtilVariant::CDataObject<T>::GetDataObject() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Create a new copy of *this class.
// Type: Overridden.
// Args: T - The object's type.
@@ -186,7 +177,6 @@ CMIUtilVariant::CDataObject<T>::CreateCopyOfSelf() {
}
//++
-//------------------------------------------------------------------------------------
// Details: Determine if *this object is a derived from CDataObjectBase.
// Type: Overridden.
// Args: T - The object's type.
@@ -200,7 +190,6 @@ bool CMIUtilVariant::CDataObject<T>::GetIsDerivedClass() const {
}
//++
-//------------------------------------------------------------------------------------
// Details: Perform a bitwise copy of *this object.
// Type: Overrideable.
// Args: T - The object's type.
@@ -215,7 +204,6 @@ void CMIUtilVariant::CDataObject<T>::Duplicate(const CDataObject &vrOther) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Release any resources used by *this object.
// Type: Overridden.
// Args: None.
@@ -226,12 +214,8 @@ template <typename T> void CMIUtilVariant::CDataObject<T>::Destroy() {
CDataObjectBase::Destroy();
}
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
-//---------------------------------------------------------------------------------------
//++
-//------------------------------------------------------------------------------------
// Details: Assign to the variant an object of a specified type.
// Type: Template method.
// Args: T - The object's type.
@@ -244,7 +228,6 @@ template <typename T> void CMIUtilVariant::Set(const T &vArg) {
}
//++
-//------------------------------------------------------------------------------------
// Details: Retrieve the data object from *this variant.
// Type: Template method.
// Args: T - The object's type.
diff --git a/tools/lldb-mi/Platform.h b/tools/lldb-mi/Platform.h
index ce2de1b6e97d3..aa999f51b9565 100644
--- a/tools/lldb-mi/Platform.h
+++ b/tools/lldb-mi/Platform.h
@@ -1,9 +1,8 @@
//===-- Platform.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#pragma once
diff --git a/tools/lldb-server/Acceptor.cpp b/tools/lldb-server/Acceptor.cpp
index 16db9e9d30df7..2cfb34d215c88 100644
--- a/tools/lldb-server/Acceptor.cpp
+++ b/tools/lldb-server/Acceptor.cpp
@@ -1,9 +1,8 @@
//===-- Acceptor.cpp --------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-server/Acceptor.h b/tools/lldb-server/Acceptor.h
index 7d1a5695a3640..1e7337f141139 100644
--- a/tools/lldb-server/Acceptor.h
+++ b/tools/lldb-server/Acceptor.h
@@ -1,9 +1,8 @@
//===-- Acceptor.h ----------------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef lldb_server_Acceptor_h_
diff --git a/tools/lldb-server/Darwin/resources/lldb-server-entitlements.plist b/tools/lldb-server/Darwin/resources/lldb-server-entitlements.plist
index 4134ee958613e..e05a9baa5d0be 100644
--- a/tools/lldb-server/Darwin/resources/lldb-server-entitlements.plist
+++ b/tools/lldb-server/Darwin/resources/lldb-server-entitlements.plist
@@ -18,7 +18,7 @@
<array>
<string>debugserver</string>
</array>
- <key>com.apple.diagnosticd.diagnostic</key>
+ <key>com.apple.private.logging.diagnostic</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
diff --git a/tools/lldb-server/Darwin/resources/lldb-server-macos-entitlements.plist b/tools/lldb-server/Darwin/resources/lldb-server-macos-entitlements.plist
index eddbaa0063ef3..edf79b3b3eed9 100644
--- a/tools/lldb-server/Darwin/resources/lldb-server-macos-entitlements.plist
+++ b/tools/lldb-server/Darwin/resources/lldb-server-macos-entitlements.plist
@@ -2,7 +2,7 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
- <key>com.apple.diagnosticd.diagnostic</key>
+ <key>com.apple.private.logging.diagnostic</key>
<true/>
</dict>
</plist>
diff --git a/tools/lldb-server/LLDBServerUtilities.cpp b/tools/lldb-server/LLDBServerUtilities.cpp
index 7d41b3b4c745e..095d281e9208a 100644
--- a/tools/lldb-server/LLDBServerUtilities.cpp
+++ b/tools/lldb-server/LLDBServerUtilities.cpp
@@ -1,15 +1,13 @@
//===-- LLDBServerUtilities.cpp ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "LLDBServerUtilities.h"
-#include "lldb/Core/StreamFile.h"
#include "lldb/Utility/Args.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
diff --git a/tools/lldb-server/LLDBServerUtilities.h b/tools/lldb-server/LLDBServerUtilities.h
index 36ec70d9ef94f..3ade1f9f5b8ad 100644
--- a/tools/lldb-server/LLDBServerUtilities.h
+++ b/tools/lldb-server/LLDBServerUtilities.h
@@ -1,9 +1,8 @@
//===-- LLDBServerUtilities.h -----------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/tools/lldb-server/SystemInitializerLLGS.cpp b/tools/lldb-server/SystemInitializerLLGS.cpp
index 93ef4d9d07617..b93e6b40dcd94 100644
--- a/tools/lldb-server/SystemInitializerLLGS.cpp
+++ b/tools/lldb-server/SystemInitializerLLGS.cpp
@@ -1,9 +1,8 @@
//===-- SystemInitializerLLGS.cpp -------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,19 +19,61 @@ using HostObjectFile = ObjectFilePECOFF;
using HostObjectFile = ObjectFileELF;
#endif
+#if defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
+#define LLDB_TARGET_ARM64
+#endif
+
+#if defined(__arm__) || defined(__arm) || defined(_ARM) || defined(_M_ARM) || \
+ defined(LLDB_TARGET_ARM64)
+#define LLDB_TARGET_ARM
+#include "Plugins/Instruction/ARM/EmulateInstructionARM.h"
+#endif
+
+#if defined(__mips64__) || defined(mips64) || defined(__mips64) || \
+ defined(__MIPS64__) || defined(_M_MIPS64)
+#define LLDB_TARGET_MIPS64
+#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
+#endif
+
+#if defined(__mips__) || defined(mips) || defined(__mips) || \
+ defined(__MIPS__) || defined(_M_MIPS) || defined(LLDB_TARGET_MIPS64)
+#define LLDB_TARGET_MIPS
+#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h"
+#endif
+
using namespace lldb_private;
-llvm::Error
-SystemInitializerLLGS::Initialize(const InitializerOptions &options) {
- if (auto e = SystemInitializerCommon::Initialize(options))
+llvm::Error SystemInitializerLLGS::Initialize() {
+ if (auto e = SystemInitializerCommon::Initialize())
return e;
HostObjectFile::Initialize();
+#if defined(LLDB_TARGET_ARM) || defined(LLDB_TARGET_ARM64)
+ EmulateInstructionARM::Initialize();
+#endif
+#if defined(LLDB_TARGET_MIPS) || defined(LLDB_TARGET_MIPS64)
+ EmulateInstructionMIPS::Initialize();
+#endif
+#if defined(LLDB_TARGET_MIPS64)
+ EmulateInstructionMIPS64::Initialize();
+#endif
+
return llvm::Error::success();
}
void SystemInitializerLLGS::Terminate() {
HostObjectFile::Terminate();
+
+#if defined(LLDB_TARGET_ARM) || defined(LLDB_TARGET_ARM64)
+ EmulateInstructionARM::Terminate();
+#endif
+#if defined(LLDB_TARGET_MIPS) || defined(LLDB_TARGET_MIPS64)
+ EmulateInstructionMIPS::Terminate();
+#endif
+#if defined(LLDB_TARGET_MIPS64)
+ EmulateInstructionMIPS64::Terminate();
+#endif
+
SystemInitializerCommon::Terminate();
}
diff --git a/tools/lldb-server/SystemInitializerLLGS.h b/tools/lldb-server/SystemInitializerLLGS.h
index 7feba3fe07bda..59a1fa14e81c0 100644
--- a/tools/lldb-server/SystemInitializerLLGS.h
+++ b/tools/lldb-server/SystemInitializerLLGS.h
@@ -1,9 +1,8 @@
//===-- SystemInitializerLLGS.h ---------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -15,8 +14,7 @@
class SystemInitializerLLGS : public lldb_private::SystemInitializerCommon {
public:
- llvm::Error
- Initialize(const lldb_private::InitializerOptions &options) override;
+ llvm::Error Initialize() override;
void Terminate() override;
};
diff --git a/tools/lldb-server/lldb-gdbserver.cpp b/tools/lldb-server/lldb-gdbserver.cpp
index 062bbd0c3b6ef..b479c2197bffa 100644
--- a/tools/lldb-server/lldb-gdbserver.cpp
+++ b/tools/lldb-server/lldb-gdbserver.cpp
@@ -1,9 +1,8 @@
//===-- lldb-gdbserver.cpp --------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,7 +22,6 @@
#include "LLDBServerUtilities.h"
#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h"
-#include "lldb/Core/PluginManager.h"
#include "lldb/Host/ConnectionFileDescriptor.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostGetOpt.h"
@@ -32,6 +30,7 @@
#include "lldb/Host/Socket.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
+#include "lldb/Target/Process.h"
#include "lldb/Utility/Status.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Errno.h"
@@ -80,9 +79,7 @@ public:
#endif
}
-//----------------------------------------------------------------------
// option descriptors for getopt_long_only()
-//----------------------------------------------------------------------
static int g_debug = 0;
static int g_verbose = 0;
@@ -90,26 +87,24 @@ static int g_verbose = 0;
static struct option g_long_options[] = {
{"debug", no_argument, &g_debug, 1},
{"verbose", no_argument, &g_verbose, 1},
- {"log-file", required_argument, NULL, 'l'},
- {"log-channels", required_argument, NULL, 'c'},
- {"attach", required_argument, NULL, 'a'},
- {"named-pipe", required_argument, NULL, 'N'},
- {"pipe", required_argument, NULL, 'U'},
- {"native-regs", no_argument, NULL,
+ {"log-file", required_argument, nullptr, 'l'},
+ {"log-channels", required_argument, nullptr, 'c'},
+ {"attach", required_argument, nullptr, 'a'},
+ {"named-pipe", required_argument, nullptr, 'N'},
+ {"pipe", required_argument, nullptr, 'U'},
+ {"native-regs", no_argument, nullptr,
'r'}, // Specify to use the native registers instead of the gdb defaults
// for the architecture. NOTE: this is a do-nothing arg as it's
// behavior is default now. FIXME remove call from lldb-platform.
- {"reverse-connect", no_argument, NULL,
+ {"reverse-connect", no_argument, nullptr,
'R'}, // Specifies that llgs attaches to the client address:port rather
// than llgs listening for a connection from address on port.
- {"setsid", no_argument, NULL,
+ {"setsid", no_argument, nullptr,
'S'}, // Call setsid() to make llgs run in its own session.
- {"fd", required_argument, NULL, 'F'},
- {NULL, 0, NULL, 0}};
+ {"fd", required_argument, nullptr, 'F'},
+ {nullptr, 0, nullptr, 0}};
-//----------------------------------------------------------------------
// Watch for signals
-//----------------------------------------------------------------------
static int g_sighup_received_count = 0;
#ifndef _WIN32
@@ -357,9 +352,7 @@ void ConnectToRemote(MainLoop &mainloop,
printf("Connection established.\n");
}
-//----------------------------------------------------------------------
// main
-//----------------------------------------------------------------------
int main_gdbserver(int argc, char *argv[]) {
Status error;
MainLoop mainloop;
@@ -534,7 +527,12 @@ int main_gdbserver(int argc, char *argv[]) {
return 1;
}
- mainloop.Run();
+ Status ret = mainloop.Run();
+ if (ret.Fail()) {
+ fprintf(stderr, "lldb-server terminating due to error: %s\n",
+ ret.AsCString());
+ return 1;
+ }
fprintf(stderr, "lldb-server exiting...\n");
return 0;
diff --git a/tools/lldb-server/lldb-platform.cpp b/tools/lldb-server/lldb-platform.cpp
index b7f7950d4ccfa..af78f624073e2 100644
--- a/tools/lldb-server/lldb-platform.cpp
+++ b/tools/lldb-server/lldb-platform.cpp
@@ -1,9 +1,8 @@
//===-- lldb-platform.cpp ---------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -40,9 +39,7 @@ using namespace lldb_private::lldb_server;
using namespace lldb_private::process_gdb_remote;
using namespace llvm;
-//----------------------------------------------------------------------
// option descriptors for getopt_long_only()
-//----------------------------------------------------------------------
static int g_debug = 0;
static int g_verbose = 0;
@@ -51,16 +48,16 @@ static int g_server = 0;
static struct option g_long_options[] = {
{"debug", no_argument, &g_debug, 1},
{"verbose", no_argument, &g_verbose, 1},
- {"log-file", required_argument, NULL, 'l'},
- {"log-channels", required_argument, NULL, 'c'},
- {"listen", required_argument, NULL, 'L'},
- {"port-offset", required_argument, NULL, 'p'},
- {"gdbserver-port", required_argument, NULL, 'P'},
- {"min-gdbserver-port", required_argument, NULL, 'm'},
- {"max-gdbserver-port", required_argument, NULL, 'M'},
- {"socket-file", required_argument, NULL, 'f'},
+ {"log-file", required_argument, nullptr, 'l'},
+ {"log-channels", required_argument, nullptr, 'c'},
+ {"listen", required_argument, nullptr, 'L'},
+ {"port-offset", required_argument, nullptr, 'p'},
+ {"gdbserver-port", required_argument, nullptr, 'P'},
+ {"min-gdbserver-port", required_argument, nullptr, 'm'},
+ {"max-gdbserver-port", required_argument, nullptr, 'M'},
+ {"socket-file", required_argument, nullptr, 'f'},
{"server", no_argument, &g_server, 1},
- {NULL, 0, NULL, 0}};
+ {nullptr, 0, nullptr, 0}};
#if defined(__APPLE__)
#define LOW_PORT (IPPORT_RESERVED)
@@ -70,9 +67,7 @@ static struct option g_long_options[] = {
#define HIGH_PORT (49151u)
#endif
-//----------------------------------------------------------------------
// Watch for signals
-//----------------------------------------------------------------------
static void signal_handler(int signo) {
switch (signo) {
case SIGHUP:
@@ -130,9 +125,7 @@ static Status save_socket_id_to_file(const std::string &socket_id,
return Status();
}
-//----------------------------------------------------------------------
// main
-//----------------------------------------------------------------------
int main_platform(int argc, char *argv[]) {
const char *progname = argv[0];
const char *subcommand = argv[1];
@@ -242,11 +235,11 @@ int main_platform(int argc, char *argv[]) {
return -1;
// Make a port map for a port range that was specified.
- if (min_gdbserver_port < max_gdbserver_port) {
+ if (min_gdbserver_port && min_gdbserver_port < max_gdbserver_port) {
for (uint16_t port = min_gdbserver_port; port < max_gdbserver_port; ++port)
gdbserver_portmap[port] = LLDB_INVALID_PROCESS_ID;
- } else if (min_gdbserver_port != max_gdbserver_port) {
- fprintf(stderr, "error: --min-gdbserver-port (%u) is greater than "
+ } else if (min_gdbserver_port || max_gdbserver_port) {
+ fprintf(stderr, "error: --min-gdbserver-port (%u) is not lower than "
"--max-gdbserver-port (%u)\n",
min_gdbserver_port, max_gdbserver_port);
option_error = 3;
diff --git a/tools/lldb-server/lldb-server.cpp b/tools/lldb-server/lldb-server.cpp
index c924fa22f3102..690aa6277bce4 100644
--- a/tools/lldb-server/lldb-server.cpp
+++ b/tools/lldb-server/lldb-server.cpp
@@ -1,9 +1,8 @@
//===-- lldb-server.cpp -----------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,17 +36,17 @@ static void display_usage(const char *progname) {
int main_gdbserver(int argc, char *argv[]);
int main_platform(int argc, char *argv[]);
+namespace llgs {
static void initialize() {
if (auto e = g_debugger_lifetime->Initialize(
- llvm::make_unique<SystemInitializerLLGS>(), {}, nullptr))
+ llvm::make_unique<SystemInitializerLLGS>(), nullptr))
llvm::consumeError(std::move(e));
}
-static void terminate() { g_debugger_lifetime->Terminate(); }
+static void terminate_debugger() { g_debugger_lifetime->Terminate(); }
+} // namespace llgs
-//----------------------------------------------------------------------
// main
-//----------------------------------------------------------------------
int main(int argc, char *argv[]) {
llvm::StringRef ToolName = argv[0];
llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
@@ -62,14 +61,14 @@ int main(int argc, char *argv[]) {
switch (argv[1][0]) {
case 'g':
- initialize();
+ llgs::initialize();
main_gdbserver(argc, argv);
- terminate();
+ llgs::terminate_debugger();
break;
case 'p':
- initialize();
+ llgs::initialize();
main_platform(argc, argv);
- terminate();
+ llgs::terminate_debugger();
break;
case 'v':
fprintf(stderr, "%s\n", lldb_private::GetVersion());